Bug 843445 - B2G MMS: provide nsIDOMMobileMessageManager.retrieveMMS() to retrieve MMS for the deferred retrieval mode, part-1:idl part. r=vyang, sr=sicking, a=leo+
authorVicamo Yang <vyang@mozilla.com>
Thu, 18 Apr 2013 09:09:30 +0800
changeset 119088 51c4987b8206b7ffb22b1fe364b73a1b775f34ba
parent 119087 23f909c9bff203b8ddb61118a043cdd00ed22ac1
child 119089 3847fb528e5598970367958556ee1c1444b53609
push id680
push uservyang@mozilla.com
push dateThu, 18 Apr 2013 01:11:41 +0000
reviewersvyang, sicking, leo
bugs843445
milestone18.0
Bug 843445 - B2G MMS: provide nsIDOMMobileMessageManager.retrieveMMS() to retrieve MMS for the deferred retrieval mode, part-1:idl part. r=vyang, sr=sicking, a=leo+
dom/mms/interfaces/nsIMmsService.idl
dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl
dom/mobilemessage/src/MobileMessageManager.cpp
--- a/dom/mms/interfaces/nsIMmsService.idl
+++ b/dom/mms/interfaces/nsIMmsService.idl
@@ -5,14 +5,17 @@
 #include "nsISupports.idl"
 interface nsIMobileMessageCallback;
 interface nsIDOMBlob;
 
 %{C++
 #define RIL_MMSSERVICE_CONTRACTID "@mozilla.org/mms/rilmmsservice;1"
 %}
 
-[scriptable, uuid(3ec33286-8559-11e2-9f38-e76b58650568)]
+[scriptable, uuid(e5ef630a-eab7-425a-ac42-650ef5c4fcef)]
 interface nsIMmsService : nsISupports
 {
   void send(in jsval parameters /* MmsParameters */,
             in nsIMobileMessageCallback request);
+
+  void retrieve(in long id,
+                in nsIMobileMessageCallback request);
 };
--- a/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
+++ b/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
@@ -14,17 +14,17 @@ interface nsIDOMBlob;
 dictionary MmsParameters
 {
   jsval      receivers; // DOMString[]
   DOMString? subject;
   DOMString? smil;
   jsval      attachments; // MmsAttachment[]
 };
 
-[scriptable, builtinclass, uuid(e4db3360-8e9d-11e2-8ca6-0ba19c435073)]
+[scriptable, builtinclass, uuid(4ed1f928-360d-4767-b02b-f74cdc58727d)]
 interface nsIDOMMozMobileMessageManager : nsIDOMEventTarget
 {
   nsIDOMMozSmsSegmentInfo getSegmentInfoForText(in DOMString text);
 
   // The first parameter can be either a DOMString (only one number) or an array
   // of DOMStrings.
   // The method returns a SmsRequest object if one number has been passed.
   // An array of SmsRequest objects otherwise.
@@ -39,15 +39,17 @@ interface nsIDOMMozMobileMessageManager 
   nsIDOMDOMRequest delete(in jsval param);
 
   nsIDOMMozSmsRequest getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
 
   nsIDOMDOMRequest markMessageRead(in long id, in boolean aValue);
 
   nsIDOMMozSmsRequest getThreadList();
 
+  nsIDOMDOMRequest retrieveMMS(in long id);
+
   [implicit_jscontext] attribute jsval onreceived;
   [implicit_jscontext] attribute jsval onsending;
   [implicit_jscontext] attribute jsval onsent;
   [implicit_jscontext] attribute jsval onfailed;
   [implicit_jscontext] attribute jsval ondeliverysuccess;
   [implicit_jscontext] attribute jsval ondeliveryerror;
 };
--- a/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl
+++ b/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl
@@ -10,17 +10,26 @@
 interface nsIRilMobileMessageDatabaseCallback : nsISupports
 {
   /**
    * |aDomMessage|: the nsIDOMMoz{Mms,Sms}Message
    */
   void notify(in nsresult aRv, in nsISupports aDomMessage);
 };
 
-[scriptable, uuid(a31b1716-8631-11e2-afaa-2fbd087f426e)]
+[scriptable, function, uuid(2be52603-5885-412c-9225-f78a78f1bbbd)]
+interface nsIRilMobileMessageDatabaseRecordCallback : nsISupports
+{
+  /**
+   * |aMessageRecord| Object: the mobile-message database record
+   */
+  void notify(in nsresult aRv, in jsval aMessageRecord);
+};
+
+[scriptable, uuid(8f49216f-bc0c-420e-b77e-7f1cbdcd245f)]
 interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
 {
   /**
    * |aMessage| Object: should contain the following properties for internal use:
    *   - |type| DOMString: "sms" or "mms"
    *   - |sender| DOMString: the phone number of sender
    *   - |timestamp| Number: the timestamp of received message
    *
@@ -60,9 +69,17 @@ interface nsIRilMobileMessageDatabaseSer
    * |aDeliveryStatus| DOMString: the new delivery status to update (can be null).
    * |aCallback| nsIRilMobileMessageDatabaseCallback: an optional callback.
    */
   void setMessageDelivery(in long aMessageId,
                           in DOMString aReceiver,
                           in DOMString aDelivery,
                           in DOMString aDeliveryStatus,
                [optional] in nsIRilMobileMessageDatabaseCallback aCallback);
+
+  /**
+   * |aMessageId| Number: the message's DB record ID.
+   * |aCallback| nsIRilMobileMessageDatabaseCallback: a callback which takes
+   *   result flag and message record as parameters.
+   */
+  void getMessageRecordById(in long aMessageId,
+                            in nsIRilMobileMessageDatabaseRecordCallback aCallback);
 };
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -329,16 +329,33 @@ MobileMessageManager::GetThreadList(nsID
   NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
   nsCOMPtr<nsIMobileMessageCallback> forwarder =
     new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
   mobileMessageDBService->GetThreadList(forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
+NS_IMETHODIMP
+MobileMessageManager::RetrieveMMS(int32_t id,
+                                  nsIDOMDOMRequest** aRequest)
+{
+    nsCOMPtr<nsIMmsService> mmsService = do_GetService(RIL_MMSSERVICE_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);
+
+    request.forget(aRequest);
+    return NS_OK;
+}
+
 nsresult
 MobileMessageManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
                                                     nsIDOMMozSmsMessage* aMessage)
 {
   nsRefPtr<nsDOMEvent> event = new SmsEvent(nullptr, nullptr);
   nsresult rv = static_cast<SmsEvent*>(event.get())->Init(aEventName, false,
                                                           false, aMessage);
   NS_ENSURE_SUCCESS(rv, rv);