Bug 831683 - B2G SMS & B2G MMS: make SMS database more generic for MMS (part 1, s/SmsDatabaseService/MobileMessageDatabaseService). r=vicamo a=leo+
authorGene Lian <clian@mozilla.com>
Tue, 05 Feb 2013 19:10:39 +0800
changeset 118637 6d8751e34809bef82d5b24d0a3a2fe3459deb3b4
parent 118636 e5b09bb5efb9441de68ef7e8ed4aba0b719b5ac5
child 118638 7e97fff932ee5dc4deccf548527e5adfcefe47ee
push id508
push userclian@mozilla.com
push dateFri, 01 Mar 2013 09:01:30 +0000
reviewersvicamo, leo
bugs831683
milestone18.0
Bug 831683 - B2G SMS & B2G MMS: make SMS database more generic for MMS (part 1, s/SmsDatabaseService/MobileMessageDatabaseService). r=vicamo a=leo+
dom/sms/interfaces/nsIRilSmsDatabaseService.idl
dom/sms/interfaces/nsISmsDatabaseService.idl
dom/sms/src/SmsCursor.cpp
dom/sms/src/SmsManager.cpp
dom/sms/src/SmsServicesFactory.cpp
dom/sms/src/SmsServicesFactory.h
dom/sms/src/android/SmsDatabaseService.cpp
dom/sms/src/android/SmsDatabaseService.h
dom/sms/src/fallback/SmsDatabaseService.cpp
dom/sms/src/fallback/SmsDatabaseService.h
dom/sms/src/ipc/SmsIPCService.cpp
dom/sms/src/ipc/SmsIPCService.h
dom/sms/src/ipc/SmsParent.cpp
dom/sms/src/ril/SmsDatabaseService.js
dom/sms/src/ril/SmsDatabaseService.manifest
dom/sms/tests/marionette/test_filter_mixed.js
dom/sms/tests/test_smsdatabaseservice.xul
dom/system/gonk/RadioInterfaceLayer.js
layout/build/nsLayoutModule.cpp
--- a/dom/sms/interfaces/nsIRilSmsDatabaseService.idl
+++ b/dom/sms/interfaces/nsIRilSmsDatabaseService.idl
@@ -2,32 +2,32 @@
  * 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 "nsISupports.idl"
 #include "nsISmsDatabaseService.idl"
 
 interface nsIDOMMozSmsMessage;
 
-[scriptable, function, uuid(04a08668-c020-469e-a1ad-8626c951ab2b)]
-interface nsIRilSmsDatabaseCallback : nsISupports
+[scriptable, function, uuid(9cd80750-6a08-11e2-ac93-bf895e53f40e)]
+interface nsIRilMobileMessageDatabaseCallback : nsISupports
 {
   void notify(in nsresult aRv, in nsIDOMMozSmsMessage aSms);
 };
 
-[scriptable, uuid(8e2acd73-0332-4d16-82cc-ff5bac59d245)]
-interface nsIRilSmsDatabaseService : nsISmsDatabaseService
+[scriptable, uuid(89528354-6a08-11e2-8243-af4cf90404a9)]
+interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
 {
   long saveReceivedMessage(in DOMString aSender,
                            in DOMString aBody,
                            in DOMString aMessageClass,
                            in unsigned long long aDate,
-                [optional] in nsIRilSmsDatabaseCallback aCallback);
+                [optional] in nsIRilMobileMessageDatabaseCallback aCallback);
   long saveSendingMessage(in DOMString aReceiver,
                           in DOMString aBody,
                           in DOMString aDeliveryStatus,
                           in unsigned long long aDate,
-               [optional] in nsIRilSmsDatabaseCallback aCallback);
+               [optional] in nsIRilMobileMessageDatabaseCallback aCallback);
   void setMessageDelivery(in long aMessageId,
                           in DOMString aDelivery,
                           in DOMString aDeliveryStatus,
-               [optional] in nsIRilSmsDatabaseCallback aCallback);
+               [optional] in nsIRilMobileMessageDatabaseCallback aCallback);
 };
--- a/dom/sms/interfaces/nsISmsDatabaseService.idl
+++ b/dom/sms/interfaces/nsISmsDatabaseService.idl
@@ -1,26 +1,26 @@
 /* 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 "nsISupports.idl"
 
 %{C++
-#define SMS_DATABASE_SERVICE_CID \
-{ 0x2454c2a1, 0xefdd, 0x4d96,    \
-{ 0x83, 0xbd, 0x51, 0xa2, 0x9a, 0x21, 0xf5, 0xab } }
-#define SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/smsdatabaseservice;1"
+#define MOBILE_MESSAGE_DATABASE_SERVICE_CID \
+{ 0x0d84b9c2, 0x8f76, 0x4ba4,    \
+{ 0xa5, 0xcd, 0xdb, 0xfb, 0x01, 0xdf, 0xda, 0x99 } }
+#define MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessagedatabaseservice;1"
 %}
 
 interface nsIDOMMozSmsFilter;
 interface nsISmsRequest;
 
-[scriptable, uuid(b1311c6d-d863-4da1-8755-2fd59eb0f386)]
-interface nsISmsDatabaseService : nsISupports
+[scriptable, uuid(ce9232ca-6a08-11e2-b971-c795004622e7)]
+interface nsIMobileMessageDatabaseService : nsISupports
 {
   [binaryname(GetMessageMoz)]
   void getMessage(in long messageId, in nsISmsRequest request);
   void deleteMessage(in long messageId, in nsISmsRequest request);
   void createMessageList(in nsIDOMMozSmsFilter filter, in boolean reverse, in nsISmsRequest request);
   void getNextMessageInList(in long listId, in nsISmsRequest request);
   void clearMessageList(in long listId);
   void markMessageRead(in long messageId, in boolean value, in nsISmsRequest request);
--- a/dom/sms/src/SmsCursor.cpp
+++ b/dom/sms/src/SmsCursor.cpp
@@ -38,24 +38,24 @@ SmsCursor::SmsCursor(int32_t aListId, ns
 {
 }
 
 SmsCursor::~SmsCursor()
 {
   NS_ASSERTION(!mMessage, "mMessage shouldn't be set!");
 
   if (mListId != -1) {
-    nsCOMPtr<nsISmsDatabaseService> smsDBService =
-      do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
+    nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+      do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 
-    if (!smsDBService) {
-      NS_ERROR("Can't find SmsDBService!");
+    if (!mobileMessageDBService) {
+      NS_ERROR("Can't find MobileMessageDBService!");
     }
 
-    smsDBService->ClearMessageList(mListId);
+    mobileMessageDBService->ClearMessageList(mListId);
   }
 }
 
 void
 SmsCursor::Disconnect()
 {
   NS_ASSERTION(!mMessage, "mMessage shouldn't be set!");
 
@@ -78,22 +78,22 @@ SmsCursor::Continue()
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
   nsRefPtr<SmsRequest> request = static_cast<SmsRequest*>(mRequest.get());
 
   mMessage = nullptr;
   request->Reset();
 
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(request);
-  smsDBService->GetNextMessageInList(mListId, forwarder);
+  mobileMessageDBService->GetNextMessageInList(mListId, forwarder);
 
   // We intenionally increase the refcount. The release will be called
   // in the corresponding callback.
   request.forget();
   return NS_OK;
 }
 
 } // namespace sms
--- a/dom/sms/src/SmsManager.cpp
+++ b/dom/sms/src/SmsManager.cpp
@@ -222,35 +222,35 @@ SmsManager::Send(const jsval& aNumber, c
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsManager::GetMessageMoz(int32_t aId, nsIDOMMozSmsRequest** aRequest)
 {
   nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  smsDBService->GetMessageMoz(aId, forwarder);
+  mobileMessageDBService->GetMessageMoz(aId, forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 nsresult
 SmsManager::Delete(int32_t aId, nsIDOMMozSmsRequest** aRequest)
 {
   nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  smsDBService->DeleteMessage(aId, forwarder);
+  mobileMessageDBService->DeleteMessage(aId, forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsManager::Delete(const jsval& aParam, nsIDOMMozSmsRequest** aRequest)
 {
   if (aParam.isInt32()) {
@@ -281,50 +281,50 @@ SmsManager::GetMessages(nsIDOMMozSmsFilt
 {
   nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
   
   if (!filter) {
     filter = new SmsFilter();
   }
 
   nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  smsDBService->CreateMessageList(filter, aReverse, forwarder);
+  mobileMessageDBService->CreateMessageList(filter, aReverse, forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsManager::MarkMessageRead(int32_t aId, bool aValue,
                             nsIDOMMozSmsRequest** aRequest)
 {
   nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
   nsCOMPtr<nsISmsRequest> forwarder =
     new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  smsDBService->MarkMessageRead(aId, aValue, forwarder);
+  mobileMessageDBService->MarkMessageRead(aId, aValue, forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsManager::GetThreadList(nsIDOMMozSmsRequest** aRequest)
 {
   nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
   nsCOMPtr<nsISmsRequest> forwarder =
     new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  smsDBService->GetThreadList(forwarder);
+  mobileMessageDBService->GetThreadList(forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 nsresult
 SmsManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName, nsIDOMMozSmsMessage* aMessage)
 {
   nsRefPtr<nsDOMEvent> event = new SmsEvent(nullptr, nullptr);
--- a/dom/sms/src/SmsServicesFactory.cpp
+++ b/dom/sms/src/SmsServicesFactory.cpp
@@ -7,17 +7,17 @@
 #include "nsXULAppAPI.h"
 #include "SmsService.h"
 #include "SmsIPCService.h"
 #ifndef MOZ_B2G_RIL
 #include "SmsDatabaseService.h"
 #endif
 #include "nsServiceManagerUtils.h"
 
-#define RIL_SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/rilsmsdatabaseservice;1"
+#define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 /* static */ already_AddRefed<nsISmsService>
 SmsServicesFactory::CreateSmsService()
 {
@@ -27,28 +27,28 @@ SmsServicesFactory::CreateSmsService()
     smsService = new SmsIPCService();
   } else {
     smsService = new SmsService();
   }
 
   return smsService.forget();
 }
 
-/* static */ already_AddRefed<nsISmsDatabaseService>
-SmsServicesFactory::CreateSmsDatabaseService()
+/* static */ already_AddRefed<nsIMobileMessageDatabaseService>
+SmsServicesFactory::CreateMobileMessageDatabaseService()
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService;
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    smsDBService = new SmsIPCService();
+    mobileMessageDBService = new SmsIPCService();
   } else {
 #ifdef MOZ_B2G_RIL
-    smsDBService = do_GetService(RIL_SMS_DATABASE_SERVICE_CONTRACTID);
+    mobileMessageDBService = do_GetService(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 #else
-    smsDBService = new SmsDatabaseService();
+    mobileMessageDBService = new MobileMessageDatabaseService();
 #endif
   }
 
-  return smsDBService.forget();
+  return mobileMessageDBService.forget();
 }
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/SmsServicesFactory.h
+++ b/dom/sms/src/SmsServicesFactory.h
@@ -4,26 +4,26 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_sms_SmsServicesFactory_h
 #define mozilla_dom_sms_SmsServicesFactory_h
 
 #include "nsCOMPtr.h"
 
 class nsISmsService;
-class nsISmsDatabaseService;
+class nsIMobileMessageDatabaseService;
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 class SmsServicesFactory
 {
 public:
   static already_AddRefed<nsISmsService> CreateSmsService();
-  static already_AddRefed<nsISmsDatabaseService> CreateSmsDatabaseService();
+  static already_AddRefed<nsIMobileMessageDatabaseService> CreateMobileMessageDatabaseService();
 };
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_sms_SmsServicesFactory_h
--- a/dom/sms/src/android/SmsDatabaseService.cpp
+++ b/dom/sms/src/android/SmsDatabaseService.cpp
@@ -6,85 +6,85 @@
 #include "SmsFilter.h"
 #include "SmsDatabaseService.h"
 #include "AndroidBridge.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
-NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
+NS_IMPL_ISUPPORTS1(MobileMessageDatabaseService, nsIMobileMessageDatabaseService)
 
 NS_IMETHODIMP
-SmsDatabaseService::GetMessageMoz(int32_t aMessageId, nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetMessageMoz(int32_t aMessageId, nsISmsRequest* aRequest)
 {
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->GetMessage(aMessageId, aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::DeleteMessage(int32_t aMessageId, nsISmsRequest* aRequest)
+MobileMessageDatabaseService::DeleteMessage(int32_t aMessageId, nsISmsRequest* aRequest)
 {
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->DeleteMessage(aMessageId, aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
-                                      bool aReverse, nsISmsRequest* aRequest)
+MobileMessageDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
+                                                bool aReverse, nsISmsRequest* aRequest)
 {
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->CreateMessageList(
     static_cast<SmsFilter*>(aFilter)->GetData(), aReverse, aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::GetNextMessageInList(int32_t aListId, nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetNextMessageInList(int32_t aListId, nsISmsRequest* aRequest)
 {
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->GetNextMessageInList(aListId, aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::ClearMessageList(int32_t aListId)
+MobileMessageDatabaseService::ClearMessageList(int32_t aListId)
 {
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->ClearMessageList(aListId);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::MarkMessageRead(int32_t aMessageId, bool aValue,
-                                    nsISmsRequest* aRequest)
+MobileMessageDatabaseService::MarkMessageRead(int32_t aMessageId, bool aValue,
+                                              nsISmsRequest* aRequest)
 {
   // TODO: This would need to be implemented as part of Bug 748391
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::GetThreadList(nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetThreadList(nsISmsRequest* aRequest)
 {
   NS_NOTYETIMPLEMENTED("Implement me!");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/android/SmsDatabaseService.h
+++ b/dom/sms/src/android/SmsDatabaseService.h
@@ -1,27 +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/. */
 
-#ifndef mozilla_dom_sms_SmsDatabaseService_h
-#define mozilla_dom_sms_SmsDatabaseService_h
+#ifndef mozilla_dom_sms_MobileMessageDatabaseService_h
+#define mozilla_dom_sms_MobileMessageDatabaseService_h
 
 #include "nsISmsDatabaseService.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
-class SmsDatabaseService MOZ_FINAL : public nsISmsDatabaseService
+class MobileMessageDatabaseService MOZ_FINAL : public nsIMobileMessageDatabaseService
 {
 public:
   NS_DECL_ISUPPORTS
-  NS_DECL_NSISMSDATABASESERVICE
+  NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
 };
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_sms_SmsDatabaseService_h
+#endif // mozilla_dom_sms_MobileMessageDatabaseService_h
--- a/dom/sms/src/fallback/SmsDatabaseService.cpp
+++ b/dom/sms/src/fallback/SmsDatabaseService.cpp
@@ -4,69 +4,69 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SmsDatabaseService.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
-NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
+NS_IMPL_ISUPPORTS1(MobileMessageDatabaseService, nsIMobileMessageDatabaseService)
 
 NS_IMETHODIMP
-SmsDatabaseService::GetMessageMoz(int32_t aMessageId,
-                                  nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetMessageMoz(int32_t aMessageId,
+                                            nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::DeleteMessage(int32_t aMessageId,
-                                  nsISmsRequest* aRequest)
+MobileMessageDatabaseService::DeleteMessage(int32_t aMessageId,
+                                            nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
-                                      bool aReverse,
-                                      nsISmsRequest* aRequest)
+MobileMessageDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
+                                                bool aReverse,
+                                                nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::GetNextMessageInList(int32_t aListId,
-                                         nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetNextMessageInList(int32_t aListId,
+                                                   nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::ClearMessageList(int32_t aListId)
+MobileMessageDatabaseService::ClearMessageList(int32_t aListId)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::MarkMessageRead(int32_t aMessageId,
-                                    bool aValue,
-                                    nsISmsRequest* aRequest)
+MobileMessageDatabaseService::MarkMessageRead(int32_t aMessageId,
+                                              bool aValue,
+                                              nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsDatabaseService::GetThreadList(nsISmsRequest* aRequest)
+MobileMessageDatabaseService::GetThreadList(nsISmsRequest* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/fallback/SmsDatabaseService.h
+++ b/dom/sms/src/fallback/SmsDatabaseService.h
@@ -1,27 +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/. */
 
-#ifndef mozilla_dom_sms_SmsDatabaseService_h
-#define mozilla_dom_sms_SmsDatabaseService_h
+#ifndef mozilla_dom_sms_MobileMessageDatabaseService_h
+#define mozilla_dom_sms_MobileMessageDatabaseService_h
 
 #include "nsISmsDatabaseService.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
-class SmsDatabaseService MOZ_FINAL : public nsISmsDatabaseService
+class MobileMessageDatabaseService MOZ_FINAL : public nsIMobileMessageDatabaseService
 {
 public:
   NS_DECL_ISUPPORTS
-  NS_DECL_NSISMSDATABASESERVICE
+  NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
 };
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_sms_SmsDatabaseService_h
+#endif // mozilla_dom_sms_MobileMessageDatabaseService_h
--- a/dom/sms/src/ipc/SmsIPCService.cpp
+++ b/dom/sms/src/ipc/SmsIPCService.cpp
@@ -14,17 +14,17 @@
 #include "SmsSegmentInfo.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 PSmsChild* gSmsChild;
 
-NS_IMPL_ISUPPORTS2(SmsIPCService, nsISmsService, nsISmsDatabaseService)
+NS_IMPL_ISUPPORTS2(SmsIPCService, nsISmsService, nsIMobileMessageDatabaseService)
 
 void
 SendRequest(const IPCSmsRequest& aRequest, nsISmsRequest* aRequestReply)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   NS_WARN_IF_FALSE(gSmsChild,
                    "Calling methods on SmsIPCService during "
@@ -106,17 +106,17 @@ SmsIPCService::CreateSmsSegmentInfo(int3
 {
   nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
       new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
   info.forget(aSegmentInfo);
   return NS_OK;
 }
 
 /*
- * Implementation of nsISmsDatabaseService.
+ * Implementation of nsIMobileMessageDatabaseService.
  */
 NS_IMETHODIMP
 SmsIPCService::GetMessageMoz(int32_t aMessageId,
                              nsISmsRequest* aRequest)
 {
   SendRequest(GetMessageRequest(aMessageId), aRequest);
   return NS_OK;
 }
--- a/dom/sms/src/ipc/SmsIPCService.h
+++ b/dom/sms/src/ipc/SmsIPCService.h
@@ -12,22 +12,22 @@
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 class PSmsChild;
 
 class SmsIPCService MOZ_FINAL : public nsISmsService
-                              , public nsISmsDatabaseService
+                              , public nsIMobileMessageDatabaseService
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISMSSERVICE
-  NS_DECL_NSISMSDATABASESERVICE
+  NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
 
 private:
   static PSmsChild* GetSmsChild();
 };
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/ipc/SmsParent.cpp
+++ b/dom/sms/src/ipc/SmsParent.cpp
@@ -171,21 +171,21 @@ SmsParent::RecvGetSegmentInfoForText(con
   aResult->charsPerSegment() = charsPerSegment;
   aResult->charsAvailableInLastSegment() = charsAvailableInLastSegment;
   return true;
 }
 
 bool
 SmsParent::RecvClearMessageList(const int32_t& aListId)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, true);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
 
-  smsDBService->ClearMessageList(aListId);
+  mobileMessageDBService->ClearMessageList(aListId);
   return true;
 }
 
 bool
 SmsParent::RecvPSmsRequestConstructor(PSmsRequestParent* aActor,
                                       const IPCSmsRequest& aRequest)
 {
   SmsRequestParent* actor = static_cast<SmsRequestParent*>(aActor);
@@ -271,99 +271,99 @@ SmsRequestParent::DoRequest(const SendMe
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const GetMessageRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, true);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
 
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
-  nsresult rv = smsDBService->GetMessageMoz(aRequest.messageId(), forwarder);
+  nsresult rv = mobileMessageDBService->GetMessageMoz(aRequest.messageId(), forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const DeleteMessageRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsDBService, true);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
 
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
-  nsresult rv = smsDBService->DeleteMessage(aRequest.messageId(), forwarder);
+  nsresult rv = mobileMessageDBService->DeleteMessage(aRequest.messageId(), forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const CreateMessageListRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 
-  NS_ENSURE_TRUE(smsDBService, true);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
   SmsFilter *filter = new SmsFilter(aRequest.filter());
-  nsresult rv = smsDBService->CreateMessageList(filter, aRequest.reverse(), forwarder);
+  nsresult rv = mobileMessageDBService->CreateMessageList(filter, aRequest.reverse(), forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const GetNextMessageInListRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 
-  NS_ENSURE_TRUE(smsDBService, true);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
-  nsresult rv = smsDBService->GetNextMessageInList(aRequest.aListId(), forwarder);
+  nsresult rv = mobileMessageDBService->GetNextMessageInList(aRequest.aListId(), forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const MarkMessageReadRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 
-  NS_ENSURE_TRUE(smsDBService, true);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
-  nsresult rv = smsDBService->MarkMessageRead(aRequest.messageId(), aRequest.value(), forwarder);
+  nsresult rv = mobileMessageDBService->MarkMessageRead(aRequest.messageId(), aRequest.value(), forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 SmsRequestParent::DoRequest(const GetThreadListRequest& aRequest)
 {
-  nsCOMPtr<nsISmsDatabaseService> smsDBService =
-    do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 
-  NS_ENSURE_TRUE(smsDBService, true);
+  NS_ENSURE_TRUE(mobileMessageDBService, true);
   mSmsRequest = SmsRequest::Create(this);
   nsCOMPtr<nsISmsRequest> forwarder = new SmsRequestForwarder(mSmsRequest);
-  nsresult rv = smsDBService->GetThreadList(forwarder);
+  nsresult rv = mobileMessageDBService->GetThreadList(forwarder);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/ril/SmsDatabaseService.js
+++ b/dom/sms/src/ril/SmsDatabaseService.js
@@ -5,18 +5,18 @@
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
 
-const RIL_SMSDATABASESERVICE_CONTRACTID = "@mozilla.org/sms/rilsmsdatabaseservice;1";
-const RIL_SMSDATABASESERVICE_CID = Components.ID("{a1fa610c-eb6c-4ac2-878f-b005d5e89249}");
+const RIL_MOBILEMESSAGEDATABASESERVICE_CONTRACTID = "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1";
+const RIL_MOBILEMESSAGEDATABASESERVICE_CID = Components.ID("{29785f90-6b5b-11e2-9201-3b280170b2ec}");
 
 const DEBUG = false;
 const DB_NAME = "sms";
 const DB_VERSION = 7;
 const STORE_NAME = "sms";
 const MOST_RECENT_STORE_NAME = "most-recent";
 
 const DELIVERY_SENDING = "sending";
@@ -54,19 +54,19 @@ XPCOMUtils.defineLazyServiceGetter(this,
 
 const GLOBAL_SCOPE = this;
 
 function numberFromMessage(message) {
   return message.delivery == DELIVERY_RECEIVED ? message.sender : message.receiver;
 }
 
 /**
- * SmsDatabaseService
+ * MobileMessageDatabaseService
  */
-function SmsDatabaseService() {
+function MobileMessageDatabaseService() {
   // Prime the directory service's cache to ensure that the ProfD entry exists
   // by the time IndexedDB queries for it off the main thread. (See bug 743635.)
   Services.dirsvc.get("ProfD", Ci.nsIFile);
 
   gIDBManager.initWindowless(GLOBAL_SCOPE);
 
   let that = this;
   this.newTxn(READ_ONLY, function(error, txn, store){
@@ -75,39 +75,39 @@ function SmsDatabaseService() {
     }
     // In order to get the highest key value, we open a key cursor in reverse
     // order and get only the first pointed value.
     let request = store.openCursor(null, PREV);
     request.onsuccess = function onsuccess(event) {
       let cursor = event.target.result;
       if (!cursor) {
         if (DEBUG) {
-          debug("Could not get the last key from sms database. " +
+          debug("Could not get the last key from mobile message database. " +
                 "Probably empty database");
         }
         return;
       }
       that.lastKey = cursor.key || 0;
       if (DEBUG) debug("Last assigned message ID was " + that.lastKey);
     };
     request.onerror = function onerror(event) {
       if (DEBUG) {
-        debug("Could not get the last key from sms database " +
+        debug("Could not get the last key from mobile message database " +
               event.target.errorCode);
       }
     };
   });
 
   this.messageLists = {};
 }
-SmsDatabaseService.prototype = {
+MobileMessageDatabaseService.prototype = {
 
-  classID:   RIL_SMSDATABASESERVICE_CID,
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIRilSmsDatabaseService,
-                                         Ci.nsISmsDatabaseService,
+  classID: RIL_MOBILEMESSAGEDATABASESERVICE_CID,
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIRilMobileMessageDatabaseService,
+                                         Ci.nsIMobileMessageDatabaseService,
                                          Ci.nsIObserver]),
 
   /**
    * Cache the DB here.
    */
   db: null,
 
   /**
@@ -217,20 +217,20 @@ SmsDatabaseService.prototype = {
 
   /**
    * Start a new transaction.
    *
    * @param txn_type
    *        Type of transaction (e.g. READ_WRITE)
    * @param callback
    *        Function to call when the transaction is available. It will
-   *        be invoked with the transaction and the 'sms' object store.
+   *        be invoked with the transaction and the mobile message object store.
    * @param objectStores
    *        Function to call when the transaction is available. It will
-   *        be invoked with the transaction and the 'sms' object store.
+   *        be invoked with the transaction and the mobile message object store.
    */
   newTxn: function newTxn(txn_type, callback, objectStores) {
     if (!objectStores) {
       objectStores = [STORE_NAME];
     }
     if (DEBUG) debug("Opening transaction for objectStores: " + objectStores);
     this.ensureDB(function (error, db) {
       if (error) {
@@ -267,17 +267,17 @@ SmsDatabaseService.prototype = {
 
   /**
    * Create the initial database schema.
    *
    * TODO need to worry about number normalization somewhere...
    * TODO full text search on body???
    */
   createSchema: function createSchema(db) {
-    // This objectStore holds the main SMS data.
+    // This objectStore holds the main mobile message data.
     let objectStore = db.createObjectStore(STORE_NAME, { keyPath: "id" });
     objectStore.createIndex("timestamp", "timestamp", { unique: false });
     if (DEBUG) debug("Created object stores and indexes");
   },
 
   /**
    * Upgrade to the corresponding database schema version.
    */
@@ -304,36 +304,36 @@ SmsDatabaseService.prototype = {
     // Delete redundant "id" index.
     let objectStore = transaction.objectStore(STORE_NAME);
     if (objectStore.indexNames.contains("id")) {
       objectStore.deleteIndex("id");
     }
 
     /**
      * This objectStore can be used to quickly construct a thread view of the
-     * SMS database. Each entry looks like this:
+     * mobile message database. Each entry looks like this:
      *
      * { senderOrReceiver: <String> (primary key),
      *   id: <Number>,
      *   timestamp: <Date>,
      *   body: <String>,
      *   unreadCount: <Number> }
      *
      */
     objectStore = db.createObjectStore(MOST_RECENT_STORE_NAME,
                                        { keyPath: "senderOrReceiver" });
     objectStore.createIndex("timestamp", "timestamp");
   },
 
   upgradeSchema4: function upgradeSchema4(transaction) {
     let threads = {};
-    let smsStore = transaction.objectStore(STORE_NAME);
+    let mobileMessageStore = transaction.objectStore(STORE_NAME);
     let mostRecentStore = transaction.objectStore(MOST_RECENT_STORE_NAME);
 
-    smsStore.openCursor().onsuccess = function(event) {
+    mobileMessageStore.openCursor().onsuccess = function(event) {
       let cursor = event.target.result;
       if (!cursor) {
         for (let thread in threads) {
           mostRecentStore.put(threads[thread]);
         }
         return;
       }
 
@@ -709,17 +709,17 @@ SmsDatabaseService.prototype = {
       };
     }, [STORE_NAME, MOST_RECENT_STORE_NAME]);
     // We return the key that we expect to store in the db
     return message.id;
   },
 
 
   /**
-   * nsIRilSmsDatabaseService API
+   * nsIRilMobileMessageDatabaseService API
    */
 
   saveReceivedMessage: function saveReceivedMessage(
       aSender, aBody, aMessageClass, aDate, aCallback) {
     let receiver = this.mRIL.rilContext.icc
                  ? this.mRIL.rilContext.icc.msisdn
                  : null;
 
@@ -874,17 +874,17 @@ SmsDatabaseService.prototype = {
                 + ", and Message.deliveryStatus set to: " + deliveryStatus);
         }
         store.put(message);
       };
     });
   },
 
   /**
-   * nsISmsDatabaseService API
+   * nsIMobileMessageDatabaseService API
    */
 
   getMessage: function getMessage(messageId, aRequest) {
     if (DEBUG) debug("Retrieving message with ID " + messageId);
     let self = this;
     this.newTxn(READ_ONLY, function (error, txn, store) {
       if (error) {
         if (DEBUG) debug(error);
@@ -938,27 +938,27 @@ SmsDatabaseService.prototype = {
         return;
       }
       txn.onerror = function onerror(event) {
         if (DEBUG) debug("Caught error on transaction", event.target.errorCode);
         //TODO look at event.target.errorCode, pick appropriate error constant
         aRequest.notifyDeleteMessageFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
       };
 
-      const smsStore = stores[0];
+      const mobileMessageStore = stores[0];
       const mruStore = stores[1];
 
       let deleted = false;
 
       txn.oncomplete = function oncomplete(event) {
         if (DEBUG) debug("Transaction " + txn + " completed.");
         aRequest.notifyMessageDeleted(deleted);
       };
 
-      smsStore.get(messageId).onsuccess = function(event) {
+      mobileMessageStore.get(messageId).onsuccess = function(event) {
         let message = event.target.result;
         if (message) {
           if (DEBUG) debug("Deleting message id " + messageId);
 
           // First actually delete the message.
           event.target.source.delete(messageId).onsuccess = function(event) {
             deleted = true;
 
@@ -971,18 +971,18 @@ SmsDatabaseService.prototype = {
 
               if (!message.read) {
                 mostRecentEntry.unreadCount--;
               }
 
               if (mostRecentEntry.id == messageId) {
                 // Check most recent sender/receiver.
                 let numberRange = IDBKeyRange.bound([number, 0], [number, ""]);
-                let numberRequest = smsStore.index("number")
-                                            .openCursor(numberRange, PREV);
+                let numberRequest = mobileMessageStore.index("number")
+                                                      .openCursor(numberRange, PREV);
                 numberRequest.onsuccess = function(event) {
                   let cursor = event.target.result;
                   if (!cursor) {
                     if (DEBUG) {
                       debug("Deleting mru entry for number '" + number + "'");
                     }
                     mruStore.delete(number);
                     return;
@@ -1428,19 +1428,19 @@ SmsDatabaseService.prototype = {
       };
       store.index("timestamp").mozGetAll().onsuccess = function(event) {
         aRequest.notifyThreadList(event.target.result);
       };
     }, [MOST_RECENT_STORE_NAME]);
   }
 };
 
-XPCOMUtils.defineLazyGetter(SmsDatabaseService.prototype, "mRIL", function () {
+XPCOMUtils.defineLazyGetter(MobileMessageDatabaseService.prototype, "mRIL", function () {
     return Cc["@mozilla.org/telephony/system-worker-manager;1"]
               .getService(Ci.nsIInterfaceRequestor)
               .getInterface(Ci.nsIRadioInterfaceLayer);
 });
 
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsDatabaseService]);
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileMessageDatabaseService]);
 
 function debug() {
-  dump("SmsDatabaseService: " + Array.slice(arguments).join(" ") + "\n");
+  dump("MobileMessageDatabaseService: " + Array.slice(arguments).join(" ") + "\n");
 }
--- a/dom/sms/src/ril/SmsDatabaseService.manifest
+++ b/dom/sms/src/ril/SmsDatabaseService.manifest
@@ -1,3 +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
+component {29785f90-6b5b-11e2-9201-3b280170b2ec} SmsDatabaseService.js
+contract @mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1 {29785f90-6b5b-11e2-9201-3b280170b2ec}
+category profile-after-change MobileMessageDatabaseService @mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1
--- a/dom/sms/tests/marionette/test_filter_mixed.js
+++ b/dom/sms/tests/marionette/test_filter_mixed.js
@@ -91,17 +91,17 @@ function deleteAllMessages(next) {
       tasks.finish();
     }
   });
 }
 
 tasks.push(deleteAllMessages);
 
 /**
- * Populate SmsDatabase with messages to being tests. We'll have NUM_THREADS
+ * Populate MobileMessageDB with messages to being tests. We'll have NUM_THREADS
  * sent and received messages, and NUM_THREADS/2 unread received messages.
  *
  *   send    to   "0"
  *   receive from "0", count = 1
  *   mark         received as read
  *
  *   send    to   "1"
  *   receive from "1", count = 2
--- a/dom/sms/tests/test_smsdatabaseservice.xul
+++ b/dom/sms/tests/test_smsdatabaseservice.xul
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="Test SmsDatabaseService"
+        title="Test MobileMessageDatabaseService by SMS"
         onload="run_test();">
-  <title>Test SmsDatabaseService</title>
+  <title>Test MobileMessageDatabaseService by SMS</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"><![CDATA[
 
 function run_test() {
   SimpleTest.waitForExplicitFinish();
   run_next_test();
 }
@@ -35,18 +35,18 @@ function run_next_test() {
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 let gIDBManager = Cc["@mozilla.org/dom/indexeddb/manager;1"]
                     .getService(Ci.nsIIndexedDatabaseManager);
 
-let gSmsDatabaseService = Cc["@mozilla.org/sms/rilsmsdatabaseservice;1"]
-                          .getService(Ci.nsISmsDatabaseService);
+let gMobileMessageDatabaseService = Cc["@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"]
+                                      .getService(Ci.nsIMobileMessageDatabaseService);
 
 let gRegistrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
 
 
 let SmsRequestManagerImpl = {
   notifySmsSent: function notifySmsSent(requestId, message) {
     ok(false, "Unexpected notifySmsSent.");
   },
@@ -192,46 +192,46 @@ let sms = [
     sender: "+34666000222",
     receiver: "+34666111222",
     body: "message 2",
     timestamp: 1329999861764
   },
 ];
 
 /**
- * nsISmsDatabaseService.saveReceivedMessage
+ * nsIMobileMessageDatabaseService.saveReceivedMessage
  */
 add_test(function test_saveReceivedMessage() {
   info("test_saveReceivedMessage");
-  let messageId = gSmsDatabaseService.saveReceivedMessage(sms[0].sender,
-                                                          sms[0].body,
-                                                          sms[0].timestamp);
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0].sender,
+                                                                    sms[0].body,
+                                                                    sms[0].timestamp);
   checkDB(function (store) {
     let request = store.get(messageId);
     request.onsuccess = function onsuccess() {
       let data = request.result;
       isnot(data, null);
       is(data.id,        messageId);
       is(data.sender,    sms[0].sender);
       is(data.receiver,  null);
       is(data.body,      sms[0].body);
       is(data.timestamp, sms[0].timestamp);
       is(data.read,      false);
     };
   });
 });
 
 /**
- * nsISmsDatabaseService.saveSentMessage
+ * nsIMobileMessageDatabaseService.saveSentMessage
  */
 add_test(function test_saveSentMessage() {
   info("test_saveSentMessage");
-  let messageId = gSmsDatabaseService.saveSentMessage(sms[1].receiver,
-                                                      sms[1].body,
-                                                      sms[1].timestamp);
+  let messageId = gMobileMessageDatabaseService.saveSentMessage(sms[1].receiver,
+                                                                sms[1].body,
+                                                                sms[1].timestamp);
 
   checkDB(function (store) {
     let request = store.get(messageId);
     request.onsuccess = function onsuccess() {
       let data = request.result;
       isnot(data, null);
       is(data.id,        messageId);
       is(data.sender,    null);
@@ -239,17 +239,17 @@ add_test(function test_saveSentMessage()
       is(data.body,      sms[1].body);
       is(data.timestamp, sms[1].timestamp);
       is(data.read,      true);
     };
   });
 });
 
 /**
- * nsISmsDatabaseService.getMessage
+ * nsIMobileMessageDatabaseService.getMessage
  */
 add_test(function test_getMessage_success() {
   info("test_getMessage_success");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyGotSms: function notifyGotSms(requestId, message) {
       is(requestId, fakeRequestId);
       ok(message instanceof Ci.nsIDOMMozSmsMessage);
@@ -257,39 +257,39 @@ add_test(function test_getMessage_succes
       is(message.delivery, "received");
       is(message.sender,   sms[2].sender);
       is(message.receiver, null);
       is(message.body,     sms[2].body);
       is(message.read,     false);
       run_next_test();
     }
   });
-  let messageId = gSmsDatabaseService.saveReceivedMessage(sms[2].sender,
-                                                          sms[2].body,
-                                                          sms[2].timestamp);
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2].sender,
+                                                                    sms[2].body,
+                                                                    sms[2].timestamp);
   SimpleTest.executeSoon(function () {
-    gSmsDatabaseService.getMessage(messageId, fakeRequestId);
+    gMobileMessageDatabaseService.getMessage(messageId, fakeRequestId);
   });
 });
 
 add_test(function test_getMessage_failed() {
   info("test_getMessage_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyGetSmsFailed: function notifyGetSmsFailed(requestId, error) {
       is(requestId, fakeRequestId);
       is(error, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
       run_next_test();
     }
   });
-  gSmsDatabaseService.getMessage(-1, fakeRequestId);
+  gMobileMessageDatabaseService.getMessage(-1, fakeRequestId);
 });
 
 /**
- * nsISmsDatabaseService.createMessageList
+ * nsIMobileMessageDatabaseService.createMessageList
  */
 function checkReceivedSms(message, i) {
   ok(message instanceof Ci.nsIDOMMozSmsMessage);
   is(message.sender,              sms[i].sender);
   is(message.receiver,            null);
   is(message.body,                sms[i].body);
   is(message.timestamp.getTime(), sms[i].timestamp);
   is(message.read,                false);
@@ -312,570 +312,570 @@ add_test(function test_createMessageList
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, i);
       auxListId = listId;
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       ok(message instanceof Ci.nsIDOMMozSmsMessage);
       i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       is(i, MAX_SMS);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_empty_filter_reverse() {
   info("test_createMessageList_empty_filter_reverse");
   let fakeRequestId = newRandomId();
   let auxListId;
   let i = 2;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, i);
       auxListId = listId;
       i -= 1;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       ok(message instanceof Ci.nsIDOMMozSmsMessage);
       i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
       i -= 1;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       is(i, -1);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
-  gSmsDatabaseService.createMessageList(filter, true, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, true, fakeRequestId);
 });
 
 add_test(function test_createMessageList_complete_filter_one_result() {
   info("test_createMessageList_complete_filter_one_result");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       ok(false, "No more messages expected");
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[0].timestamp);
   filter.endDate = new Date(sms[0].timestamp);
   filter.numbers = [sms[0].sender];
   filter.delivery = "received";
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_complete_filter_multi_result() {
   info("test_createMessageList_complete_filter_multi_result");
   let fakeRequestId = newRandomId();
   let auxListId;
   let secondMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       auxListId = listId;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
       ok(!secondMessage);
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 2);
       secondMessage = true;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(secondMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[0].timestamp);
   filter.endDate = new Date(sms[2].timestamp);
   filter.numbers = [sms[0].sender, sms[2].sender];
   filter.delivery = "received";
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_complete_filter_no_result() {
   info("test_createMessageList_complete_filter_no_result");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     },
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[0].timestamp);
   filter.endDate = new Date(sms[0].timestamp);
   filter.numbers = [sms[0].sender];
   filter.delivery = "sent";
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_delivery_sent_filter_success() {
   info("test_createMessageList_delivery_sent_filter_success");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkSentSms(message, 1);
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.delivery = "sent";
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_delivery_received_filter_success() {
   info("test_createMessageList_delivery_received_filter_success");
   let fakeRequestId = newRandomId();
   let auxListId;
   let secondMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       auxListId = listId;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
       ok(!secondMessage);
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 2);
       secondMessage = true;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(secondMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.delivery = "received";
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_startDate_filter_success() {
   info("test_createMessageList_startDate_filter_success");
   let fakeRequestId = newRandomId();
   let auxListId;
   let i = 0;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, i);
       auxListId = listId;
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       is(i, MAX_SMS);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[0].timestamp);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_startDate_filter_failed() {
   info("test_createMessageList_startDate_filter_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     },
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[2].timestamp + 1);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_endDate_filter_success() {
   info("test_createMessageList_endDate_filter_success");
   let fakeRequestId = newRandomId();
   let auxListId;
   let i = 0;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, i);
       auxListId = listId;
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       is(i, MAX_SMS);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.endDate = new Date(sms[2].timestamp);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_endDate_filter_failed() {
   info("test_createMessageList_endDate_filter_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
      notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.endDate = new Date(sms[0].timestamp - 1);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_fullDate_filter_success() {
   info("test_createMessageList_fullDate_filter_success");
   let fakeRequestId = newRandomId();
   let auxListId;
   let i = 0;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, i);
       auxListId = listId;
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId,
                                                         message) {
       is(requestId, fakeRequestId);
       i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
       i += 1;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       is(i, MAX_SMS);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[0].timestamp);
   filter.endDate = new Date(sms[MAX_SMS - 1].timestamp);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_fullDate_filter_failed() {
   info("test_createMessageList_fullDate_filter_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
      notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.startDate = new Date(sms[MAX_SMS - 1] + 1);
   filter.endDate = new Date(sms[MAX_SMS - 1] + 1);
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_single_number_success() {
   info("test_createMessageList_single_number_success");
   let fakeRequestId = newRandomId();
   let firstMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(firstMessage, false);
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       firstMessage = true;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(firstMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.numbers = [sms[0].sender];
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_single_number_failed() {
   info("test_createMessageList_single_number_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
      notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.numbers = ["00000000000"];
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_multi_number_success() {
   info("test_createMessageList_multi_number_success");
   let fakeRequestId = newRandomId();
   let auxListId;
   let secondMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       auxListId = listId;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
       ok(!secondMessage);
       is(requestId, fakeRequestId);
       checkSentSms(message, 1);
       secondMessage = true;
-      gSmsDatabaseService.getNextMessageInList(auxListId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(secondMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.numbers = [sms[0].sender, sms[1].receiver];
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_multi_number_wrong_number_success() {
   info("test_createMessageList_multi_number_wrong_number_success");
   let fakeRequestId = newRandomId();
   let firstMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(firstMessage, false);
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       firstMessage = true;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(firstMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.numbers = ["00000000000", sms[0].sender];
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 add_test(function test_createMessageList_multi_number_failed() {
   info("test_createMessageList_multi_number_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
      notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   let filter = new MozSmsFilter();
   filter.numbers = ["00000000000", "11111111111"];
-  gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
 });
 
 
 add_test(function test_createMessageList_read_filter_success() {
   info("test_createMessageList_read_filter_success");
   let fakeRequestId = newRandomId();
   let lId;
   let secondMessage = false;
   fakeSmsRequestManager({
     notifyCreateMessageList: function notifyCreateMessageList(requestId,
                                                               listId,
                                                               message) {
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 0);
       lId = listId;
-      gSmsDatabaseService.getNextMessageInList(listId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
     },
     notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
       ok(!secondMessage);
       is(requestId, fakeRequestId);
       checkReceivedSms(message, 2);
       secondMessage = true;
-      gSmsDatabaseService.getNextMessageInList(lId, requestId);
+      gMobileMessageDatabaseService.getNextMessageInList(lId, requestId);
     },
     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
       ok(secondMessage);
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   SimpleTest.executeSoon(function () {
     let filter = new MozSmsFilter();
     filter.read = false;
-    gSmsDatabaseService.createMessageList(filter, false, fakeRequestId);
+    gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
   });
 });
 
 /**
- * nsISmsDatabaseService.getNextMessageInList
+ * nsIMobileMessageDatabaseService.getNextMessageInList
  */
 add_test(function test_getNextMessageInList_unknown_list() {
   info("test_getNextMessageInList_unknown_list");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyReadMessageListFailed:
       function notifyReadMessageListFailed(requestId) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
-  gSmsDatabaseService.getNextMessageInList(-1, fakeRequestId);
+  gMobileMessageDatabaseService.getNextMessageInList(-1, fakeRequestId);
 });
 
 /**
- * nsISmsDatabaseService.deleteMessage
+ * nsIMobileMessageDatabaseService.deleteMessage
  */
 add_test(function test_deleteMessage_success() {
   info("test_deleteMessage_success");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
       is(requestId, fakeRequestId);
       ok(deleted);
       run_next_test();
     }
   });
-  let messageId = gSmsDatabaseService.saveReceivedMessage(sms[0].sender,
-                                                          sms[0].body,
-                                                          sms[0].timestamp);
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0].sender,
+                                                                    sms[0].body,
+                                                                    sms[0].timestamp);
   SimpleTest.executeSoon(function () {
-    gSmsDatabaseService.deleteMessage(messageId, fakeRequestId);
+    gMobileMessageDatabaseService.deleteMessage(messageId, fakeRequestId);
   });
 });
 
 add_test(function test_deleteMessage_failed() {
   info("test_deleteMessage_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
       is(requestId, fakeRequestId);
       is(deleted, false);
       run_next_test();
     }
   });
-  gSmsDatabaseService.deleteMessage(-1, fakeRequestId);
+  gMobileMessageDatabaseService.deleteMessage(-1, fakeRequestId);
 });
 
 add_test(function test_markMessageRead_success() {
   info("test_markMessageRead_success");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyMarkedMessageRead: function notifyMarkedMessageRead(requestId, read) {
       is(requestId, fakeRequestId);
       is(read, true);
       run_next_test();
     }
   });
-  let messageId = gSmsDatabaseService.saveReceivedMessage(sms[2].sender,
-                                                          sms[2].body,
-                                                          sms[2].timestamp); 
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2].sender,
+                                                                    sms[2].body,
+                                                                    sms[2].timestamp); 
   SimpleTest.executeSoon(function () {
-    gSmsDatabaseService.markMessageRead(messageId, true, fakeRequestId);
+    gMobileMessageDatabaseService.markMessageRead(messageId, true, fakeRequestId);
   });
 });
 
 add_test(function test_markMessageRead_failed() {
   info("test_markMessageRead_failed");
   let fakeRequestId = newRandomId();
   fakeSmsRequestManager({
     notifyMarkMessageReadFailed: function notifyMarkMessageReadFailed(requestId, error) {
       is(requestId, fakeRequestId);
       run_next_test();
     }
   });
   SimpleTest.executeSoon(function () {
-    gSmsDatabaseService.markMessageRead(-1, true, fakeRequestId);
+    gMobileMessageDatabaseService.markMessageRead(-1, true, fakeRequestId);
   });
 });
 
 ]]></script>
   <body xmlns="http://www.w3.org/1999/xhtml">
     <p id="display"></p>
     <div id="content" style="display: none"></div>
     <pre id="test"></pre>
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -113,19 +113,19 @@ const RIL_IPC_CELLBROADCAST_MSG_NAMES = 
 XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
                                    "@mozilla.org/power/powermanagerservice;1",
                                    "nsIPowerManagerService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
                                    "@mozilla.org/sms/smsservice;1",
                                    "nsISmsService");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gSmsDatabaseService",
-                                   "@mozilla.org/sms/rilsmsdatabaseservice;1",
-                                   "nsIRilSmsDatabaseService");
+XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageDatabaseService",
+                                   "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1",
+                                   "nsIRilMobileMessageDatabaseService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageBroadcaster");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
                                    "@mozilla.org/settingsService;1",
                                    "nsISettingsService");
@@ -1454,22 +1454,22 @@ RadioInterfaceLayer.prototype = {
           messageClass: message.messageClass,
           timestamp: message.timestamp,
           read: false
       });
       Services.obs.notifyObservers(sms, kSmsReceivedObserverTopic, null);
     }.bind(this);
 
     if (message.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
-      message.id = gSmsDatabaseService.saveReceivedMessage(
-          message.sender || null,
-          message.fullBody || null,
-          message.messageClass,
-          message.timestamp,
-          notifyReceived);
+      message.id = gMobileMessageDatabaseService.saveReceivedMessage(
+        message.sender || null,
+        message.fullBody || null,
+        message.messageClass,
+        message.timestamp,
+        notifyReceived);
     } else {
       message.id = -1;
       let sms = gSmsService.createSmsMessage(message.id,
                                              DOM_SMS_DELIVERY_RECEIVED,
                                              RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
                                              message.sender || null,
                                              message.receiver || null,
                                              message.fullBody || null,
@@ -1501,20 +1501,20 @@ RadioInterfaceLayer.prototype = {
   handleSmsSent: function handleSmsSent(message) {
     debug("handleSmsSent: " + JSON.stringify(message));
 
     let options = this._sentSmsEnvelopes[message.envelopeId];
     if (!options) {
       return;
     }
 
-    gSmsDatabaseService.setMessageDelivery(options.sms.id,
-                                           DOM_SMS_DELIVERY_SENT,
-                                           options.sms.deliveryStatus,
-                                           function notifyResult(rv, sms) {
+    gMobileMessageDatabaseService.setMessageDelivery(options.sms.id,
+                                                     DOM_SMS_DELIVERY_SENT,
+                                                     options.sms.deliveryStatus,
+                                                     function notifyResult(rv, sms) {
       //TODO bug 832140 handle !Components.isSuccessCode(rv)
       gSystemMessenger.broadcastMessage("sms-sent",
                                         {id: options.sms.id,
                                          delivery: DOM_SMS_DELIVERY_SENT,
                                          deliveryStatus: options.sms.deliveryStatus,
                                          sender: message.sender || null,
                                          receiver: options.sms.receiver,
                                          body: options.sms.body,
@@ -1539,20 +1539,20 @@ RadioInterfaceLayer.prototype = {
     debug("handleSmsDelivery: " + JSON.stringify(message));
 
     let options = this._sentSmsEnvelopes[message.envelopeId];
     if (!options) {
       return;
     }
     delete this._sentSmsEnvelopes[message.envelopeId];
 
-    gSmsDatabaseService.setMessageDelivery(options.sms.id,
-                                           options.sms.delivery,
-                                           message.deliveryStatus,
-                                           function notifyResult(rv, sms) {
+    gMobileMessageDatabaseService.setMessageDelivery(options.sms.id,
+                                                     options.sms.delivery,
+                                                     message.deliveryStatus,
+                                                     function notifyResult(rv, sms) {
       //TODO bug 832140 handle !Components.isSuccessCode(rv)
       let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
                   ? kSmsDeliverySuccessObserverTopic
                   : kSmsDeliveryErrorObserverTopic;
       Services.obs.notifyObservers(sms, topic, null);
     });
   },
 
@@ -1567,20 +1567,20 @@ RadioInterfaceLayer.prototype = {
 
     let error = Ci.nsISmsRequest.UNKNOWN_ERROR;
     switch (message.error) {
       case RIL.ERROR_RADIO_NOT_AVAILABLE:
         error = Ci.nsISmsRequest.NO_SIGNAL_ERROR;
         break;
     }
 
-    gSmsDatabaseService.setMessageDelivery(options.sms.id,
-                                           DOM_SMS_DELIVERY_ERROR,
-                                           RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
-                                           function notifyResult(rv, sms) {
+    gMobileMessageDatabaseService.setMessageDelivery(options.sms.id,
+                                                     DOM_SMS_DELIVERY_ERROR,
+                                                     RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
+                                                     function notifyResult(rv, sms) {
       //TODO bug 832140 handle !Components.isSuccessCode(rv)
       options.request.notifySendMessageFailed(error);
       Services.obs.notifyObservers(sms, kSmsFailedObserverTopic, null);
     });
   },
 
   /**
    * Handle data call state changes.
@@ -2518,18 +2518,18 @@ RadioInterfaceLayer.prototype = {
       options.segmentRef16Bit = this.segmentRef16Bit;
       options.segmentRef = this.nextSegmentRef;
     }
 
     let timestamp = Date.now();
     let deliveryStatus = options.requestStatusReport
                        ? RIL.GECKO_SMS_DELIVERY_STATUS_PENDING
                        : RIL.GECKO_SMS_DELIVERY_STATUS_NOT_APPLICABLE;
-    let id = gSmsDatabaseService.saveSendingMessage(number, message, deliveryStatus, timestamp,
-                                                    function notifyResult(rv, sms) {
+    let id = gMobileMessageDatabaseService.saveSendingMessage(number, message, deliveryStatus, timestamp,
+                                                              function notifyResult(rv, sms) {
       //TODO bug 832140 handle !Components.isSuccessCode(rv)
       Services.obs.notifyObservers(sms, kSmsSendingObserverTopic, null);
 
       // Keep current SMS message info for sent/delivered notifications
       options.envelopeId = this.createSmsEnvelope({
           request: request,
           sms: sms,
           requestStatusReport: options.requestStatusReport
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -316,17 +316,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceS
 
 #ifndef MOZ_WIDGET_GONK
 #if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback)
 #endif
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService, SmsServicesFactory::CreateSmsService)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsDatabaseService, SmsServicesFactory::CreateSmsDatabaseService)
+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageDatabaseService, SmsServicesFactory::CreateMobileMessageDatabaseService)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService,
                                          PowerManagerService::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIAlarmHalService,
                                          AlarmHalService::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITimeService,
                                          TimeService::GetInstance)
 
 #ifdef MOZ_WIDGET_GONK
@@ -851,17 +851,17 @@ NS_DEFINE_NAMED_CID(NS_DOMMUTATIONOBSERV
 NS_DEFINE_NAMED_CID(NS_DEVICE_SENSORS_CID);
 
 #ifndef MOZ_WIDGET_GONK
 #if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
 NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID);
 #endif
 #endif
 NS_DEFINE_NAMED_CID(SMS_SERVICE_CID);
-NS_DEFINE_NAMED_CID(SMS_DATABASE_SERVICE_CID);
+NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_DATABASE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
 NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_ALARMHALSERVICE_CID);
 NS_DEFINE_NAMED_CID(TCPSOCKETCHILD_CID);
 NS_DEFINE_NAMED_CID(NS_TIMESERVICE_CID);
 #ifdef MOZ_WIDGET_GONK
 NS_DEFINE_NAMED_CID(GONK_GPS_GEOLOCATION_PROVIDER_CID);
 #endif
@@ -1136,17 +1136,17 @@ static const mozilla::Module::CIDEntry k
 #if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
   { &kNS_HAPTICFEEDBACK_CID, false, NULL, nsHapticFeedbackConstructor },
 #endif
 #endif
   { &kTHIRDPARTYUTIL_CID, false, NULL, ThirdPartyUtilConstructor },
   { &kNS_STRUCTUREDCLONECONTAINER_CID, false, NULL, nsStructuredCloneContainerConstructor },
   { &kNS_DOMMUTATIONOBSERVER_CID, false, NULL, nsDOMMutationObserverConstructor },
   { &kSMS_SERVICE_CID, false, NULL, nsISmsServiceConstructor },
-  { &kSMS_DATABASE_SERVICE_CID, false, NULL, nsISmsDatabaseServiceConstructor },
+  { &kMOBILE_MESSAGE_DATABASE_SERVICE_CID, false, NULL, nsIMobileMessageDatabaseServiceConstructor },
   { &kNS_POWERMANAGERSERVICE_CID, false, NULL, nsIPowerManagerServiceConstructor },
   { &kOSFILECONSTANTSSERVICE_CID, true, NULL, OSFileConstantsServiceConstructor },
   { &kNS_ALARMHALSERVICE_CID, false, NULL, nsIAlarmHalServiceConstructor },
   { &kTCPSOCKETCHILD_CID, false, NULL, TCPSocketChildConstructor },
   { &kNS_TIMESERVICE_CID, false, NULL, nsITimeServiceConstructor },
 #ifdef MOZ_WIDGET_GONK
   { &kGONK_GPS_GEOLOCATION_PROVIDER_CID, false, NULL, nsIGeolocationProviderConstructor },
 #endif
@@ -1285,17 +1285,17 @@ static const mozilla::Module::ContractID
 #if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
   { "@mozilla.org/widget/hapticfeedback;1", &kNS_HAPTICFEEDBACK_CID },
 #endif
 #endif
   { THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID },
   { NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID },
   { NS_DOMMUTATIONOBSERVER_CONTRACTID, &kNS_DOMMUTATIONOBSERVER_CID },
   { SMS_SERVICE_CONTRACTID, &kSMS_SERVICE_CID },
-  { SMS_DATABASE_SERVICE_CONTRACTID, &kSMS_DATABASE_SERVICE_CID },
+  { MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_DATABASE_SERVICE_CID },
   { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID },
   { OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID },
   { ALARMHALSERVICE_CONTRACTID, &kNS_ALARMHALSERVICE_CID },
   { "@mozilla.org/tcp-socket-child;1", &kTCPSOCKETCHILD_CID },
   { TIMESERVICE_CONTRACTID, &kNS_TIMESERVICE_CID },
 #ifdef MOZ_WIDGET_GONK
   { GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID, &kGONK_GPS_GEOLOCATION_PROVIDER_CID },
 #endif