michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "SmsServicesFactory.h" michael@0: #include "nsXULAppAPI.h" michael@0: #include "ipc/SmsIPCService.h" michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: #include "android/MobileMessageDatabaseService.h" michael@0: #include "android/SmsService.h" michael@0: #elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) michael@0: #include "gonk/SmsService.h" michael@0: #endif michael@0: #include "nsServiceManagerUtils.h" michael@0: michael@0: #define RIL_MMSSERVICE_CONTRACTID "@mozilla.org/mms/rilmmsservice;1" michael@0: #define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: namespace mobilemessage { michael@0: michael@0: /* static */ already_AddRefed michael@0: SmsServicesFactory::CreateSmsService() michael@0: { michael@0: nsCOMPtr smsService; michael@0: michael@0: if (XRE_GetProcessType() == GeckoProcessType_Content) { michael@0: smsService = new SmsIPCService(); michael@0: } else { michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: smsService = new SmsService(); michael@0: #elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) michael@0: smsService = new SmsService(); michael@0: #endif michael@0: } michael@0: michael@0: return smsService.forget(); michael@0: } michael@0: michael@0: /* static */ already_AddRefed michael@0: SmsServicesFactory::CreateMobileMessageDatabaseService() michael@0: { michael@0: nsCOMPtr mobileMessageDBService; michael@0: if (XRE_GetProcessType() == GeckoProcessType_Content) { michael@0: mobileMessageDBService = new SmsIPCService(); michael@0: } else { michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: mobileMessageDBService = new MobileMessageDatabaseService(); michael@0: #elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) michael@0: mobileMessageDBService = do_GetService(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); michael@0: #endif michael@0: } michael@0: michael@0: return mobileMessageDBService.forget(); michael@0: } michael@0: michael@0: /* static */ already_AddRefed michael@0: SmsServicesFactory::CreateMmsService() michael@0: { michael@0: nsCOMPtr mmsService; michael@0: michael@0: if (XRE_GetProcessType() == GeckoProcessType_Content) { michael@0: mmsService = new SmsIPCService(); michael@0: } else { michael@0: #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) michael@0: mmsService = do_CreateInstance(RIL_MMSSERVICE_CONTRACTID); michael@0: #endif michael@0: } michael@0: michael@0: return mmsService.forget(); michael@0: } michael@0: michael@0: } // namespace mobilemessage michael@0: } // namespace dom michael@0: } // namespace mozilla