Bug 729104 - B2G SMS: Make SmsDatabaseService stub a JS component. r=mounir
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Tue, 21 Feb 2012 01:34:18 +0100
changeset 88942 75ea99f22bf7ccca29a144999ba32aa33017373e
parent 88941 83c85131bcfee30ac02052b295e8feb64488fac5
child 88943 3ef541a42d1275aee5e29de9c4eb878dd9bb206f
push idunknown
push userunknown
push dateunknown
reviewersmounir
bugs729104
milestone13.0a1
Bug 729104 - B2G SMS: Make SmsDatabaseService stub a JS component. r=mounir
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/sms/src/Makefile.in
dom/sms/src/SmsServicesFactory.cpp
dom/sms/src/ril/SmsDatabaseService.cpp
dom/sms/src/ril/SmsDatabaseService.h
dom/sms/src/ril/SmsDatabaseService.js
dom/sms/src/ril/SmsDatabaseService.manifest
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -396,16 +396,18 @@
 @BINPATH@/components/contentAreaDropListener.js
 @BINPATH@/components/messageWakeupService.js
 @BINPATH@/components/messageWakeupService.manifest
 @BINPATH@/components/nsFilePicker.js
 @BINPATH@/components/nsFilePicker.manifest
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/RadioInterfaceLayer.manifest
 @BINPATH@/components/RadioInterfaceLayer.js
+@BINPATH@/components/SmsDatabaseService.manifest
+@BINPATH@/components/SmsDatabaseService.js
 @BINPATH@/components/nsWifiWorker.js
 @BINPATH@/components/nsWifiWorker.manifest
 #endif
 #ifdef XP_MACOSX
 @BINPATH@/components/libalerts.dylib
 #endif
 #ifdef MOZ_ENABLE_DBUS
 @BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -374,16 +374,18 @@
 @BINPATH@/components/nsInputListAutoComplete.js
 @BINPATH@/components/contentSecurityPolicy.manifest
 @BINPATH@/components/contentSecurityPolicy.js
 @BINPATH@/components/contentAreaDropListener.manifest
 @BINPATH@/components/contentAreaDropListener.js
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/RadioInterfaceLayer.manifest
 @BINPATH@/components/RadioInterfaceLayer.js
+@BINPATH@/components/SmsDatabaseService.manifest
+@BINPATH@/components/SmsDatabaseService.js
 @BINPATH@/components/nsWifiWorker.js
 @BINPATH@/components/nsWifiWorker.manifest
 #endif
 @BINPATH@/components/BrowserProfileMigrators.manifest
 @BINPATH@/components/ChromeProfileMigrator.js
 @BINPATH@/components/FirefoxProfileMigrator.js
 #ifdef XP_MACOSX
 @BINPATH@/components/libalerts.dylib
--- a/dom/sms/src/Makefile.in
+++ b/dom/sms/src/Makefile.in
@@ -76,17 +76,16 @@ CPPSRCS = \
   SmsService.cpp \
   SmsIPCService.cpp \
   SmsServicesFactory.cpp \
   SmsParent.cpp \
   SmsMessage.cpp \
   SmsEvent.cpp \
   Constants.cpp \
   SmsChild.cpp \
-  SmsDatabaseService.cpp \
   SmsRequest.cpp \
   SmsRequestManager.cpp \
   SmsFilter.cpp \
   SmsCursor.cpp \
   $(NULL)
 
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/content/events/src \
@@ -97,13 +96,22 @@ LOCAL_INCLUDES = \
 # subdirectory (and the ipc one).
 LOCAL_INCLUDES += $(VPATH:%=-I%)
 
 ifdef MOZ_B2G_RIL
 LOCAL_INCLUDES += \
   -I$(topsrcdir)/dom/telephony \
   -I$(topsrcdir)/dom/system/b2g \
   $(NULL)
+
+EXTRA_COMPONENTS = \
+  ril/SmsDatabaseService.js \
+  ril/SmsDatabaseService.manifest \
+  $(NULL)
+else
+CPPSRCS += \
+  SmsDatabaseService.cpp \
+  $(NULL)  
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
--- a/dom/sms/src/SmsServicesFactory.cpp
+++ b/dom/sms/src/SmsServicesFactory.cpp
@@ -33,18 +33,23 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SmsServicesFactory.h"
 #include "nsXULAppAPI.h"
 #include "SmsService.h"
+#include "SmsIPCService.h"
+#ifndef MOZ_B2G_RIL
 #include "SmsDatabaseService.h"
-#include "SmsIPCService.h"
+#endif
+#include "nsServiceManagerUtils.h"
+
+#define RIL_SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/rilsmsdatabaseservice;1"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 /* static */ already_AddRefed<nsISmsService>
 SmsServicesFactory::CreateSmsService()
 {
@@ -62,17 +67,21 @@ SmsServicesFactory::CreateSmsService()
 /* static */ already_AddRefed<nsISmsDatabaseService>
 SmsServicesFactory::CreateSmsDatabaseService()
 {
   nsCOMPtr<nsISmsDatabaseService> smsDBService;
 
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     smsDBService = new SmsIPCService();
   } else {
+#ifdef MOZ_B2G_RIL
+    smsDBService = do_GetService(RIL_SMS_DATABASE_SERVICE_CONTRACTID);
+#else
     smsDBService = new SmsDatabaseService();
+#endif
   }
 
   return smsDBService.forget();
 }
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
deleted file mode 100644
--- a/dom/sms/src/ril/SmsDatabaseService.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "SmsDatabaseService.h"
-
-namespace mozilla {
-namespace dom {
-namespace sms {
-
-NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
-
-NS_IMETHODIMP
-SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
-                                    const nsAString& aBody,
-                                    PRUint64 aDate, PRInt32* aId)
-{
-  *aId = -1;
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsDatabaseService::GetMessageMoz(PRInt32 aMessageId, PRInt32 aRequestId,
-                                  PRUint64 aProcessId)
-{
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsDatabaseService::DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId,
-                                  PRUint64 aProcessId)
-{
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
-                                      bool aReverse, PRInt32 aRequestId,
-                                      PRUint64 aProcessId)
-{
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsDatabaseService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
-                                         PRUint64 aProcessId)
-{
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsDatabaseService::ClearMessageList(PRInt32 aListId)
-{
-  NS_ERROR("We should not be here!");
-  return NS_OK;
-}
-
-} // namespace sms
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/sms/src/ril/SmsDatabaseService.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef mozilla_dom_sms_SmsDatabaseService_h
-#define mozilla_dom_sms_SmsDatabaseService_h
-
-#include "nsISmsDatabaseService.h"
-
-namespace mozilla {
-namespace dom {
-namespace sms {
-
-class SmsDatabaseService : public nsISmsDatabaseService
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISMSDATABASESERVICE
-};
-
-} // namespace sms
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_sms_SmsDatabaseService_h
new file mode 100644
--- /dev/null
+++ b/dom/sms/src/ril/SmsDatabaseService.js
@@ -0,0 +1,47 @@
+/* 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/. */
+
+"use strict";
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const RIL_SMSDATABASESERVICE_CONTRACTID = "@mozilla.org/sms/rilsmsdatabaseservice;1";
+const RIL_SMSDATABASESERVICE_CID = Components.ID("{a1fa610c-eb6c-4ac2-878f-b005d5e89249}");
+
+/**
+ * SmsDatabaseService
+ */
+function SmsDatabaseService() {
+}
+SmsDatabaseService.prototype = {
+
+  classID:   RIL_SMSDATABASESERVICE_CID,
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsISmsDatabaseService]),
+
+  // nsISmsDatabaseService
+
+  saveSentMessage: function saveSentMessage(receiver, body, date) {
+    return -1;
+  },
+
+  getMessage: function getMessage(messageId, requestId) {
+  },
+
+  deleteMessage: function deleteMessage(messageId, requestId) {
+  },
+
+  createMessageList: function createMessageList(filter, reverse, requestId) {
+  },
+
+  getNextMessageInList: function getNextMessageInList(listId, requestId) {
+  },
+
+  clearMessageList: function clearMessageList(listId) {
+  }
+
+};
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsDatabaseService]);
new file mode 100644
--- /dev/null
+++ b/dom/sms/src/ril/SmsDatabaseService.manifest
@@ -0,0 +1,3 @@
+component {a1fa610c-eb6c-4ac2-878f-b005d5e89249} SmsDatabaseService.js
+contract @mozilla.org/sms/rilsmsdatabaseservice;1 {a1fa610c-eb6c-4ac2-878f-b005d5e89249}
+category profile-after-change SmsDatabaseService @mozilla.org/sms/rilsmsdatabaseservice;1