Bug 847744: Part 5 - IPC for retrieveMMS. r=vicamo
authorPatrick Wang <kk1fff@patrickz.net>
Wed, 10 Apr 2013 20:18:43 +0800
changeset 128308 684ed7a62fb67047dc5c0ced6281d859f73e2611
parent 128307 b6bb8c14385c5b568e7bdbd966158dcaf39f24d6
child 128309 53f30efb50b05d2c14ee61a2398366563e9c206a
push idunknown
push userunknown
push dateunknown
reviewersvicamo
bugs847744
milestone23.0a1
Bug 847744: Part 5 - IPC for retrieveMMS. r=vicamo
dom/mobilemessage/src/MobileMessageManager.cpp
dom/mobilemessage/src/android/MmsService.cpp
dom/mobilemessage/src/fallback/MmsService.cpp
dom/mobilemessage/src/ipc/PSms.ipdl
dom/mobilemessage/src/ipc/SmsIPCService.cpp
dom/mobilemessage/src/ipc/SmsParent.cpp
dom/mobilemessage/src/ipc/SmsParent.h
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -326,17 +326,17 @@ MobileMessageManager::GetThreads(nsIDOMD
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MobileMessageManager::RetrieveMMS(int32_t id,
                                   nsIDOMDOMRequest** aRequest)
 {
-    nsCOMPtr<nsIMmsService> mmsService = do_GetService(RIL_MMSSERVICE_CONTRACTID);
+    nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
     NS_ENSURE_TRUE(mmsService, NS_ERROR_FAILURE);
 
     nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
     nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
 
     nsresult rv = mmsService->Retrieve(id, msgCallback);
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/mobilemessage/src/android/MmsService.cpp
+++ b/dom/mobilemessage/src/android/MmsService.cpp
@@ -17,11 +17,19 @@ NS_IMPL_ISUPPORTS1(MmsService, nsIMmsSer
 NS_IMETHODIMP
 MmsService::Send(const JS::Value& aParameters,
                  nsIMobileMessageCallback *aRequest)
 {
   NS_NOTYETIMPLEMENTED("Implement me!");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+MmsService::Retrieve(int32_t aId, nsIMobileMessageCallback *aRequest)
+{
+  // TODO: Bug 860174, implement this function.
+  NS_NOTYETIMPLEMENTED("Implement me!");
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/fallback/MmsService.cpp
+++ b/dom/mobilemessage/src/fallback/MmsService.cpp
@@ -16,11 +16,18 @@ NS_IMPL_ISUPPORTS1(MmsService, nsIMmsSer
 NS_IMETHODIMP
 MmsService::Send(const JS::Value& aParameters,
                  nsIMobileMessageCallback *aRequest)
 {
   NS_NOTYETIMPLEMENTED("Implement me!");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+MmsService::Retrieve(int32_t aId, nsIMobileMessageCallback *aRequest)
+{
+  NS_NOTYETIMPLEMENTED("Implement me!");
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/ipc/PSms.ipdl
+++ b/dom/mobilemessage/src/ipc/PSms.ipdl
@@ -29,16 +29,21 @@ struct SendSmsMessageRequest
 };
 
 union SendMessageRequest
 {
   SendMmsMessageRequest;
   SendSmsMessageRequest;
 };
 
+struct RetrieveMessageRequest
+{
+  int32_t messageId;
+};
+
 struct GetMessageRequest
 {
   int32_t messageId;
 };
 
 struct DeleteMessageRequest
 {
   int32_t messageId;
@@ -58,16 +63,17 @@ struct MarkMessageReadRequest
 
 struct CreateThreadCursorRequest
 {
 };
 
 union IPCSmsRequest
 {
   SendMessageRequest;
+  RetrieveMessageRequest;
   GetMessageRequest;
   DeleteMessageRequest;
   MarkMessageReadRequest;
 };
 
 union IPCMobileMessageCursor
 {
   CreateMessageCursorRequest;
--- a/dom/mobilemessage/src/ipc/SmsIPCService.cpp
+++ b/dom/mobilemessage/src/ipc/SmsIPCService.cpp
@@ -110,17 +110,17 @@ SmsIPCService::GetSegmentInfoForText(con
 
 NS_IMETHODIMP
 SmsIPCService::Send(const nsAString& aNumber,
                     const nsAString& aMessage,
                     nsIMobileMessageCallback* aRequest)
 {
   return SendRequest(SendMessageRequest(SendSmsMessageRequest(nsString(aNumber),
                                                               nsString(aMessage))),
-                     aRequest) ? NS_OK : NS_ERROR_FAILURE;
+                     aRequest);
 }
 
 /*
  * Implementation of nsIMobileMessageDatabaseService.
  */
 NS_IMETHODIMP
 SmsIPCService::GetMessageMoz(int32_t aMessageId,
                              nsIMobileMessageCallback* aRequest)
@@ -251,8 +251,13 @@ SmsIPCService::Send(const JS::Value& aPa
 {
   SendMmsMessageRequest req;
   if (!GetSendMmsMessageRequestFromParams(aParameters, req)) {
     return NS_ERROR_UNEXPECTED;
   }
   return SendRequest(SendMessageRequest(req), aRequest);
 }
 
+NS_IMETHODIMP
+SmsIPCService::Retrieve(int32_t aId, nsIMobileMessageCallback *aRequest)
+{
+  return SendRequest(RetrieveMessageRequest(aId), aRequest);
+}
--- a/dom/mobilemessage/src/ipc/SmsParent.cpp
+++ b/dom/mobilemessage/src/ipc/SmsParent.cpp
@@ -312,16 +312,18 @@ bool
 SmsParent::RecvPSmsRequestConstructor(PSmsRequestParent* aActor,
                                       const IPCSmsRequest& aRequest)
 {
   SmsRequestParent* actor = static_cast<SmsRequestParent*>(aActor);
 
   switch (aRequest.type()) {
     case IPCSmsRequest::TSendMessageRequest:
       return actor->DoRequest(aRequest.get_SendMessageRequest());
+    case IPCSmsRequest::TRetrieveMessageRequest:
+      return actor->DoRequest(aRequest.get_RetrieveMessageRequest());
     case IPCSmsRequest::TGetMessageRequest:
       return actor->DoRequest(aRequest.get_GetMessageRequest());
     case IPCSmsRequest::TDeleteMessageRequest:
       return actor->DoRequest(aRequest.get_DeleteMessageRequest());
     case IPCSmsRequest::TMarkMessageReadRequest:
       return actor->DoRequest(aRequest.get_MarkMessageReadRequest());
     default:
       MOZ_NOT_REACHED("Unknown type!");
@@ -432,16 +434,33 @@ SmsRequestParent::DoRequest(const SendMe
   default:
     MOZ_NOT_REACHED("Unknown type of SendMessageRequest!");
     return false;
   }
   return true;
 }
 
 bool
+SmsRequestParent::DoRequest(const RetrieveMessageRequest& aRequest)
+{
+  nsresult rv = NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
+  if (mmsService) {
+    rv = mmsService->Retrieve(aRequest.messageId(), this);
+  }
+
+  if (NS_FAILED(rv)) {
+    return NS_SUCCEEDED(NotifyGetMessageFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
+  }
+
+  return true;
+}
+
+bool
 SmsRequestParent::DoRequest(const GetMessageRequest& aRequest)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
   if (dbService) {
     rv = dbService->GetMessageMoz(aRequest.messageId(), this);
--- a/dom/mobilemessage/src/ipc/SmsParent.h
+++ b/dom/mobilemessage/src/ipc/SmsParent.h
@@ -95,16 +95,19 @@ protected:
 
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
 
   bool
   DoRequest(const SendMessageRequest& aRequest);
 
   bool
+  DoRequest(const RetrieveMessageRequest& aRequest);
+
+  bool
   DoRequest(const GetMessageRequest& aRequest);
 
   bool
   DoRequest(const DeleteMessageRequest& aRequest);
 
   bool
   DoRequest(const MarkMessageReadRequest& aRequest);