From 6e519e5d558a33e51a87963b9869365a4c21ceef Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Wed, 10 Apr 2013 20:18:32 +0800 Subject: [PATCH] Bug 847744: Part 1 - Create MmsService for content process. r=vicamo --HG-- rename : dom/mobilemessage/src/SmsServicesFactory.h => dom/mobilemessage/src/android/MmsService.h rename : dom/mobilemessage/src/SmsServicesFactory.h => dom/mobilemessage/src/fallback/MmsService.h --- dom/mms/interfaces/nsIMmsService.idl | 4 ++- dom/mobilemessage/src/Makefile.in | 2 ++ .../src/MobileMessageManager.cpp | 2 +- dom/mobilemessage/src/SmsServicesFactory.cpp | 20 ++++++++++++++ dom/mobilemessage/src/SmsServicesFactory.h | 2 ++ dom/mobilemessage/src/android/MmsService.cpp | 27 +++++++++++++++++++ dom/mobilemessage/src/android/MmsService.h | 26 ++++++++++++++++++ dom/mobilemessage/src/fallback/MmsService.cpp | 26 ++++++++++++++++++ dom/mobilemessage/src/fallback/MmsService.h | 26 ++++++++++++++++++ dom/mobilemessage/src/ipc/SmsIPCService.cpp | 13 +++++++-- dom/mobilemessage/src/ipc/SmsIPCService.h | 3 +++ layout/build/nsLayoutModule.cpp | 6 +++++ 12 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 dom/mobilemessage/src/android/MmsService.cpp create mode 100644 dom/mobilemessage/src/android/MmsService.h create mode 100644 dom/mobilemessage/src/fallback/MmsService.cpp create mode 100644 dom/mobilemessage/src/fallback/MmsService.h diff --git a/dom/mms/interfaces/nsIMmsService.idl b/dom/mms/interfaces/nsIMmsService.idl index 5d817c9486f..aca7eaaa4e5 100644 --- a/dom/mms/interfaces/nsIMmsService.idl +++ b/dom/mms/interfaces/nsIMmsService.idl @@ -7,7 +7,9 @@ interface nsIMobileMessageCallback; interface nsIDOMBlob; %{C++ -#define RIL_MMSSERVICE_CONTRACTID "@mozilla.org/mms/rilmmsservice;1" +#define MMS_SERVICE_CID { 0x06d9124b, 0x80e0, 0x40ed, \ + { 0x98, 0x71, 0x4d, 0x23, 0x4a, 0x0f, 0xd4, 0x31 } } +#define MMS_SERVICE_CONTRACTID "@mozilla.org/mms/mmsservice;1" %} [scriptable, uuid(e5ef630a-eab7-425a-ac42-650ef5c4fcef)] diff --git a/dom/mobilemessage/src/Makefile.in b/dom/mobilemessage/src/Makefile.in index 96c76950d9d..18aa0aca025 100644 --- a/dom/mobilemessage/src/Makefile.in +++ b/dom/mobilemessage/src/Makefile.in @@ -92,10 +92,12 @@ EXTRA_COMPONENTS = \ else EXPORTS_mozilla/dom/mobilemessage += \ MobileMessageDatabaseService.h \ + MmsService.h \ $(NULL) CPPSRCS += \ MobileMessageDatabaseService.cpp \ + MmsService.cpp \ $(NULL) endif diff --git a/dom/mobilemessage/src/MobileMessageManager.cpp b/dom/mobilemessage/src/MobileMessageManager.cpp index 8df29893166..4d073f44d95 100644 --- a/dom/mobilemessage/src/MobileMessageManager.cpp +++ b/dom/mobilemessage/src/MobileMessageManager.cpp @@ -193,7 +193,7 @@ MobileMessageManager::Send(const JS::Value& aNumber, const nsAString& aMessage, NS_IMETHODIMP MobileMessageManager::SendMMS(const JS::Value& aParams, nsIDOMDOMRequest** aRequest) { - nsCOMPtr mmsService = do_GetService(RIL_MMSSERVICE_CONTRACTID); + nsCOMPtr mmsService = do_GetService(MMS_SERVICE_CONTRACTID); NS_ENSURE_TRUE(mmsService, NS_ERROR_FAILURE); nsRefPtr request = new DOMRequest(GetOwner()); diff --git a/dom/mobilemessage/src/SmsServicesFactory.cpp b/dom/mobilemessage/src/SmsServicesFactory.cpp index bafa84df721..efcf0171834 100644 --- a/dom/mobilemessage/src/SmsServicesFactory.cpp +++ b/dom/mobilemessage/src/SmsServicesFactory.cpp @@ -9,9 +9,11 @@ #include "SmsIPCService.h" #ifndef MOZ_B2G_RIL #include "MobileMessageDatabaseService.h" +#include "MmsService.h" #endif #include "nsServiceManagerUtils.h" +#define RIL_MMSSERVICE_CONTRACTID "@mozilla.org/mms/rilmmsservice;1" #define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1" namespace mozilla { @@ -49,6 +51,24 @@ SmsServicesFactory::CreateMobileMessageDatabaseService() return mobileMessageDBService.forget(); } +/* static */ already_AddRefed +SmsServicesFactory::CreateMmsService() +{ + nsCOMPtr mmsService; + + if (XRE_GetProcessType() == GeckoProcessType_Content) { + mmsService = new SmsIPCService(); + } else { +#ifdef MOZ_B2G_RIL + mmsService = do_CreateInstance(RIL_MMSSERVICE_CONTRACTID); +#else + mmsService = new MmsService(); +#endif + } + + return mmsService.forget(); +} + } // namespace mobilemessage } // namespace dom } // namespace mozilla diff --git a/dom/mobilemessage/src/SmsServicesFactory.h b/dom/mobilemessage/src/SmsServicesFactory.h index 962a6c12196..899e49e9d56 100644 --- a/dom/mobilemessage/src/SmsServicesFactory.h +++ b/dom/mobilemessage/src/SmsServicesFactory.h @@ -9,6 +9,7 @@ #include "nsCOMPtr.h" class nsISmsService; +class nsIMmsService; class nsIMobileMessageDatabaseService; namespace mozilla { @@ -20,6 +21,7 @@ class SmsServicesFactory public: static already_AddRefed CreateSmsService(); static already_AddRefed CreateMobileMessageDatabaseService(); + static already_AddRefed CreateMmsService(); }; } // namespace mobilemessage diff --git a/dom/mobilemessage/src/android/MmsService.cpp b/dom/mobilemessage/src/android/MmsService.cpp new file mode 100644 index 00000000000..604609e235f --- /dev/null +++ b/dom/mobilemessage/src/android/MmsService.cpp @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MobileMessageCallback.h" +#include "MmsService.h" +#include "AndroidBridge.h" +#include "jsapi.h" + +namespace mozilla { +namespace dom { +namespace mobilemessage { + +NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService) + +NS_IMETHODIMP +MmsService::Send(const JS::Value& aParameters, + nsIMobileMessageCallback *aRequest) +{ + NS_NOTYETIMPLEMENTED("Implement me!"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +} // namespace mobilemessage +} // namespace dom +} // namespace mozilla diff --git a/dom/mobilemessage/src/android/MmsService.h b/dom/mobilemessage/src/android/MmsService.h new file mode 100644 index 00000000000..37bab96f262 --- /dev/null +++ b/dom/mobilemessage/src/android/MmsService.h @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_mobilemessage_MmsService_h +#define mozilla_dom_mobilemessage_MmsService_h + +#include "nsIMmsService.h" + +namespace mozilla { +namespace dom { +namespace mobilemessage { + +class MmsService MOZ_FINAL : public nsIMmsService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMMSSERVICE +}; + +} // namespace mobilemessage +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_mobilemessage_MmsService_h diff --git a/dom/mobilemessage/src/fallback/MmsService.cpp b/dom/mobilemessage/src/fallback/MmsService.cpp new file mode 100644 index 00000000000..61ccac2266e --- /dev/null +++ b/dom/mobilemessage/src/fallback/MmsService.cpp @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MobileMessageCallback.h" +#include "MmsService.h" +#include "jsapi.h" + +namespace mozilla { +namespace dom { +namespace mobilemessage { + +NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService) + +NS_IMETHODIMP +MmsService::Send(const JS::Value& aParameters, + nsIMobileMessageCallback *aRequest) +{ + NS_NOTYETIMPLEMENTED("Implement me!"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +} // namespace mobilemessage +} // namespace dom +} // namespace mozilla diff --git a/dom/mobilemessage/src/fallback/MmsService.h b/dom/mobilemessage/src/fallback/MmsService.h new file mode 100644 index 00000000000..37bab96f262 --- /dev/null +++ b/dom/mobilemessage/src/fallback/MmsService.h @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_mobilemessage_MmsService_h +#define mozilla_dom_mobilemessage_MmsService_h + +#include "nsIMmsService.h" + +namespace mozilla { +namespace dom { +namespace mobilemessage { + +class MmsService MOZ_FINAL : public nsIMmsService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMMSSERVICE +}; + +} // namespace mobilemessage +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_mobilemessage_MmsService_h diff --git a/dom/mobilemessage/src/ipc/SmsIPCService.cpp b/dom/mobilemessage/src/ipc/SmsIPCService.cpp index ce541d8b662..3dfd24c80f1 100644 --- a/dom/mobilemessage/src/ipc/SmsIPCService.cpp +++ b/dom/mobilemessage/src/ipc/SmsIPCService.cpp @@ -71,9 +71,10 @@ SendCursorRequest(const IPCMobileMessageCursor& aRequest, } // anonymous namespace -NS_IMPL_ISUPPORTS2(SmsIPCService, +NS_IMPL_ISUPPORTS3(SmsIPCService, nsISmsService, - nsIMobileMessageDatabaseService); + nsIMmsService, + nsIMobileMessageDatabaseService) /* * Implementation of nsISmsService. @@ -159,3 +160,11 @@ SmsIPCService::CreateThreadCursor(nsIMobileMessageCursorCallback* aCursorCallbac return SendCursorRequest(CreateThreadCursorRequest(), aCursorCallback, aResult); } + +NS_IMETHODIMP +SmsIPCService::Send(const JS::Value& aParameters, + nsIMobileMessageCallback *aRequest) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + diff --git a/dom/mobilemessage/src/ipc/SmsIPCService.h b/dom/mobilemessage/src/ipc/SmsIPCService.h index 4e0e0a40647..98b9a7737ef 100644 --- a/dom/mobilemessage/src/ipc/SmsIPCService.h +++ b/dom/mobilemessage/src/ipc/SmsIPCService.h @@ -7,6 +7,7 @@ #define mozilla_dom_mobilemessage_SmsIPCService_h #include "nsISmsService.h" +#include "nsIMmsService.h" #include "nsIMobileMessageDatabaseService.h" #include "mozilla/Attributes.h" @@ -17,11 +18,13 @@ namespace mobilemessage { class PSmsChild; class SmsIPCService MOZ_FINAL : public nsISmsService + , public nsIMmsService , public nsIMobileMessageDatabaseService { public: NS_DECL_ISUPPORTS NS_DECL_NSISMSSERVICE + NS_DECL_NSIMMSSERVICE NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE }; diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 2fae2c5eea4..84cbffc1375 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -222,6 +222,7 @@ static void Shutdown(); #endif #include "nsCSPService.h" #include "nsISmsService.h" +#include "nsIMmsService.h" #include "nsIMobileMessageService.h" #include "nsIMobileMessageDatabaseService.h" #include "mozilla/dom/mobilemessage/MobileMessageService.h" @@ -317,6 +318,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService, SmsServicesFactory::CreateSmsService) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMmsService, + SmsServicesFactory::CreateMmsService) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageService, MobileMessageService::GetInstance) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageDatabaseService, @@ -825,6 +828,7 @@ NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID); #endif #endif NS_DEFINE_NAMED_CID(SMS_SERVICE_CID); +NS_DEFINE_NAMED_CID(MMS_SERVICE_CID); NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_SERVICE_CID); NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_DATABASE_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID); @@ -1110,6 +1114,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kTHIRDPARTYUTIL_CID, false, NULL, ThirdPartyUtilConstructor }, { &kNS_STRUCTUREDCLONECONTAINER_CID, false, NULL, nsStructuredCloneContainerConstructor }, { &kSMS_SERVICE_CID, false, NULL, nsISmsServiceConstructor }, + { &kMMS_SERVICE_CID, false, NULL, nsIMmsServiceConstructor }, { &kMOBILE_MESSAGE_SERVICE_CID, false, NULL, nsIMobileMessageServiceConstructor }, { &kMOBILE_MESSAGE_DATABASE_SERVICE_CID, false, NULL, nsIMobileMessageDatabaseServiceConstructor }, { &kNS_POWERMANAGERSERVICE_CID, false, NULL, nsIPowerManagerServiceConstructor }, @@ -1258,6 +1263,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID }, { NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID }, { SMS_SERVICE_CONTRACTID, &kSMS_SERVICE_CID }, + { MMS_SERVICE_CONTRACTID, &kMMS_SERVICE_CID }, { MOBILE_MESSAGE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_SERVICE_CID }, { MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_DATABASE_SERVICE_CID }, { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID },