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
This commit is contained in:
Patrick Wang 2013-04-10 20:18:32 +08:00
parent 7d182a2102
commit 6e519e5d55
12 changed files with 153 additions and 4 deletions

View File

@ -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)]

View File

@ -92,10 +92,12 @@ EXTRA_COMPONENTS = \
else
EXPORTS_mozilla/dom/mobilemessage += \
MobileMessageDatabaseService.h \
MmsService.h \
$(NULL)
CPPSRCS += \
MobileMessageDatabaseService.cpp \
MmsService.cpp \
$(NULL)
endif

View File

@ -193,7 +193,7 @@ MobileMessageManager::Send(const JS::Value& aNumber, const nsAString& aMessage,
NS_IMETHODIMP
MobileMessageManager::SendMMS(const JS::Value& aParams, nsIDOMDOMRequest** aRequest)
{
nsCOMPtr<nsIMmsService> mmsService = do_GetService(RIL_MMSSERVICE_CONTRACTID);
nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(mmsService, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());

View File

@ -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<nsIMmsService>
SmsServicesFactory::CreateMmsService()
{
nsCOMPtr<nsIMmsService> 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

View File

@ -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<nsISmsService> CreateSmsService();
static already_AddRefed<nsIMobileMessageDatabaseService> CreateMobileMessageDatabaseService();
static already_AddRefed<nsIMmsService> CreateMmsService();
};
} // namespace mobilemessage

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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
};

View File

@ -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 },