Bug 833229 - 3.f/4: voicemail factory class. r=smaug

This commit is contained in:
Vicamo Yang 2014-09-26 13:00:25 +08:00
Родитель 0e6fe8c43a
Коммит 6b8c0d8ed1
4 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -15,6 +15,13 @@
#include "nsContentUtils.h"
#include "nsServiceManagerUtils.h"
// Service instantiation
#include "ipc/VoicemailIPCService.h"
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
#include "nsIGonkVoicemailService.h"
#endif
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
using namespace mozilla::dom;
using mozilla::ErrorResult;
@ -237,3 +244,21 @@ Voicemail::NotifyStatusChanged(nsIVoicemailProvider* aProvider)
MozVoicemailEvent::Constructor(this, NS_LITERAL_STRING("statuschanged"), init);
return DispatchTrustedEvent(event);
}
already_AddRefed<nsIVoicemailService>
NS_CreateVoicemailService()
{
nsCOMPtr<nsIVoicemailService> service;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
service = new mozilla::dom::voicemail::VoicemailIPCService();
} else {
#if defined(MOZ_B2G_RIL)
#if defined(MOZ_WIDGET_GONK)
service = do_GetService(GONK_VOICEMAIL_SERVICE_CONTRACTID);
#endif // MOZ_WIDGET_GONK
#endif // MOZ_B2G_RIL
}
return service.forget();
}

Просмотреть файл

@ -4,6 +4,11 @@
#include "nsIVoicemailService.idl"
%{C++
#define GONK_VOICEMAIL_SERVICE_CONTRACTID \
"@mozilla.org/voicemail/gonkvoicemailservice;1"
%}
[scriptable, uuid(d21dbc55-f540-417d-aa3e-9e890764e957)]
interface nsIGonkVoicemailService : nsIVoicemailService
{

Просмотреть файл

@ -49,6 +49,13 @@ interface nsIVoicemailService : nsISupports
void unregisterListener(in nsIVoicemailListener listener);
};
%{C++
template<typename T> struct already_AddRefed;
already_AddRefed<nsIVoicemailService>
NS_CreateVoicemailService();
%}
[scriptable, uuid(a0bc19a2-3216-4f3f-89d3-8976a48cb829)]
interface nsIVoicemailProvider : nsISupports
{

Просмотреть файл

@ -234,6 +234,7 @@ static void Shutdown();
#include "StreamingProtocolService.h"
#include "nsITelephonyService.h"
#include "nsIVoicemailService.h"
#ifdef MOZ_WIDGET_GONK
#include "GonkGPSGeolocationProvider.h"
@ -352,6 +353,8 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileConnectionService,
NS_CreateMobileConnectionService)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITelephonyService,
NS_CreateTelephonyService)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIVoicemailService,
NS_CreateVoicemailService)
//-----------------------------------------------------------------------------
@ -790,6 +793,7 @@ NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID);
NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(TELEPHONY_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_VOICEMAIL_SERVICE_CID);
NS_DEFINE_NAMED_CID(GECKO_MEDIA_PLUGIN_SERVICE_CID);
@ -1079,6 +1083,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
#endif
{ &kTELEPHONY_SERVICE_CID, false, nullptr, nsITelephonyServiceConstructor },
{ &kNS_MOBILE_CONNECTION_SERVICE_CID, false, NULL, nsIMobileConnectionServiceConstructor },
{ &kNS_VOICEMAIL_SERVICE_CID, false, nullptr, nsIVoicemailServiceConstructor },
{ nullptr }
};
@ -1237,6 +1242,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ TELEPHONY_SERVICE_CONTRACTID, &kTELEPHONY_SERVICE_CID },
{ "@mozilla.org/gecko-media-plugin-service;1", &kGECKO_MEDIA_PLUGIN_SERVICE_CID },
{ NS_MOBILE_CONNECTION_SERVICE_CONTRACTID, &kNS_MOBILE_CONNECTION_SERVICE_CID },
{ NS_VOICEMAIL_SERVICE_CONTRACTID, &kNS_VOICEMAIL_SERVICE_CID },
{ nullptr }
};