Bug 849739 1/4 - WebSMS: Replace GetThreadList() with DOMCursor based GetThreads(). Interface changes. sr=mounir, r=bent, a=leo+
authorVicamo Yang <vyang@mozilla.com>
Thu, 18 Apr 2013 09:09:40 +0800
changeset 119097 d303c877d3a0da8f018190d8f6300a36cf0fab87
parent 119096 585bc5156688d95d17f1f4a1bda61d63f6057d57
child 119098 ffb4d2086b56578af9fc65e0f613b989f51243b0
push id680
push uservyang@mozilla.com
push dateThu, 18 Apr 2013 01:11:41 +0000
reviewersmounir, bent, leo
bugs849739
milestone18.0
Bug 849739 1/4 - WebSMS: Replace GetThreadList() with DOMCursor based GetThreads(). Interface changes. sr=mounir, r=bent, a=leo+
dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
dom/mobilemessage/interfaces/nsIDOMMozMobileMessageThread.idl
dom/mobilemessage/interfaces/nsIDOMSmsManager.idl
dom/mobilemessage/interfaces/nsIMobileMessageCallback.idl
dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
dom/mobilemessage/interfaces/nsIMobileMessageService.idl
dom/mobilemessage/src/ipc/PMobileMessageCursor.ipdl
dom/mobilemessage/src/ipc/PSms.ipdl
dom/mobilemessage/src/ipc/PSmsRequest.ipdl
dom/mobilemessage/src/ipc/SmsTypes.ipdlh
--- a/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
+++ b/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl
@@ -15,17 +15,17 @@ interface nsIDOMBlob;
 dictionary MmsParameters
 {
   jsval      receivers; // DOMString[]
   DOMString? subject;
   DOMString? smil;
   jsval      attachments; // MmsAttachment[]
 };
 
-[scriptable, builtinclass, uuid(44346294-6c8f-4a06-a412-1f38f7d45f2e)]
+[scriptable, builtinclass, uuid(370da692-b79a-45d3-a07a-f9284e8c392b)]
 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.
@@ -34,21 +34,23 @@ interface nsIDOMMozMobileMessageManager 
   nsIDOMDOMRequest sendMMS(in jsval parameters /* MmsParameters */);
 
   [binaryname(GetMessageMoz)]
   nsIDOMDOMRequest getMessage(in long id);
 
   // The parameter can be either a message id or a nsIDOMMoz{Mms,Sms}Message.
   nsIDOMDOMRequest delete(in jsval param);
 
+  // Iterates through nsIDOMMoz{Mms,Sms}Message.
   nsIDOMDOMCursor getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
 
   nsIDOMDOMRequest markMessageRead(in long id, in boolean aValue);
 
-  nsIDOMMozSmsRequest getThreadList();
+  // Iterates through nsIDOMMozMobileMessageThread.
+  nsIDOMDOMCursor getThreads();
 
   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;
new file mode 100644
--- /dev/null
+++ b/dom/mobilemessage/interfaces/nsIDOMMozMobileMessageThread.idl
@@ -0,0 +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"
+
+[scriptable, builtinclass, uuid(ebc1db1a-07f9-4d79-b487-150298900ccc)]
+interface nsIDOMMozMobileMessageThread : nsISupports
+{
+  // Unique identity of the thread.
+  readonly attribute unsigned long long id;
+
+  // Message body of the last message in the thread.
+  readonly attribute DOMString          body;
+
+  // Total unread messages in the thread.
+  readonly attribute unsigned long long unreadCount;
+
+  // Participant addresses of the thread.
+  [implicit_jscontext]
+  readonly attribute jsval              participants; // DOMString[]
+
+  // Timestamp of the last message in the thread.
+  [implicit_jscontext]
+  readonly attribute jsval              timestamp; // jsval is for Date.
+};
--- a/dom/mobilemessage/interfaces/nsIDOMSmsManager.idl
+++ b/dom/mobilemessage/interfaces/nsIDOMSmsManager.idl
@@ -5,38 +5,40 @@
 #include "nsIDOMEventTarget.idl"
 
 interface nsIDOMDOMCursor;
 interface nsIDOMEventListener;
 interface nsIDOMMozSmsRequest;
 interface nsIDOMMozSmsFilter;
 interface nsIDOMMozSmsSegmentInfo;
 
-[scriptable, builtinclass, uuid(aa03b43e-82ec-4325-906e-a1ea018e1b01)]
+[scriptable, builtinclass, uuid(7371acd3-136b-4081-b368-8f5c69a22103)]
 interface nsIDOMMozSmsManager : 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.
   jsval send(in jsval number, in DOMString message);
 
   [binaryname(GetMessageMoz)]
   nsIDOMMozSmsRequest getMessage(in long id);
 
   // The parameter can be either a message id or a SmsMessage.
   nsIDOMMozSmsRequest delete(in jsval param);
 
+  // Iterates through nsIDOMMozSmsMessage.
   nsIDOMDOMCursor getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
 
   nsIDOMMozSmsRequest markMessageRead(in long id, in boolean aValue);
 
-  nsIDOMMozSmsRequest getThreadList();
+  // Iterates through nsIDOMMozMobileMessageThread.
+  nsIDOMDOMCursor getThreads();
 
   [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/nsIMobileMessageCallback.idl
+++ b/dom/mobilemessage/interfaces/nsIMobileMessageCallback.idl
@@ -8,17 +8,17 @@ dictionary SmsThreadListItem
 {
   unsigned long long id;
   DOMString senderOrReceiver;
   unsigned long long timestamp;
   DOMString body;
   unsigned long long unreadCount;
 };
 
-[scriptable, builtinclass, uuid(47498737-972d-49c9-8d4e-80ae2da51778)]
+[scriptable, builtinclass, uuid(5e993cfc-fb34-46a8-bb14-3df5c09ff748)]
 interface nsIMobileMessageCallback : nsISupports
 {
   /**
    * All SMS related errors that could apply to SmsRequest objects.
    * Make sure to keep this list in sync with the list in:
    * embedding/android/GeckoSmsManager.java
    */
   const unsigned short SUCCESS_NO_ERROR = 0;
@@ -39,13 +39,9 @@ interface nsIMobileMessageCallback : nsI
   void notifyMessageGot(in nsISupports message);
   void notifyGetMessageFailed(in long error);
 
   void notifyMessageDeleted(in boolean deleted);
   void notifyDeleteMessageFailed(in long error);
 
   void notifyMessageMarkedRead(in boolean read);
   void notifyMarkMessageReadFailed(in long error);
-
-  [implicit_jscontext]
-  void notifyThreadList(in jsval threadList);
-  void notifyThreadListFailed(in long error);
 };
--- a/dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
+++ b/dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
@@ -11,17 +11,17 @@
 #define MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessagedatabaseservice;1"
 %}
 
 interface nsICursorContinueCallback;
 interface nsIDOMMozSmsFilter;
 interface nsIMobileMessageCallback;
 interface nsIMobileMessageCursorCallback;
 
-[scriptable, uuid(487d15e1-fd23-40cc-ba45-7c0115032e17)]
+[scriptable, uuid(ec1ca45f-e621-4c67-9c50-74c16842e780)]
 interface nsIMobileMessageDatabaseService : nsISupports
 {
   [binaryname(GetMessageMoz)]
   void getMessage(in long messageId,
                   in nsIMobileMessageCallback request);
 
   void deleteMessage(in long messageId,
                      in nsIMobileMessageCallback request);
@@ -29,10 +29,10 @@ interface nsIMobileMessageDatabaseServic
   nsICursorContinueCallback createMessageCursor(in nsIDOMMozSmsFilter filter,
                                                 in boolean reverse,
                                                 in nsIMobileMessageCursorCallback callback);
 
   void markMessageRead(in long messageId,
                        in boolean value,
                        in nsIMobileMessageCallback request);
 
-  void getThreadList(in nsIMobileMessageCallback request);
+  nsICursorContinueCallback createThreadCursor(in nsIMobileMessageCursorCallback callback);
 };
--- a/dom/mobilemessage/interfaces/nsIMobileMessageService.idl
+++ b/dom/mobilemessage/interfaces/nsIMobileMessageService.idl
@@ -1,24 +1,25 @@
 /* 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"
 
 interface nsIDOMMozSmsMessage;
 interface nsIDOMMozMmsMessage;
+interface nsIDOMMozMobileMessageThread;
 interface nsIDOMMozSmsSegmentInfo;
 
 %{C++
 #define MOBILE_MESSAGE_SERVICE_CID { 0x829c1dd6, 0x0466, 0x4591, { 0x83, 0x6f, 0xb8, 0xf6, 0xfd, 0x1f, 0x7b, 0xa5 } }
 #define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
 %}
 
-[scriptable, builtinclass, uuid(944297ed-0dc7-4dee-89a6-c962ea0218d3)]
+[scriptable, builtinclass, uuid(18e4b86e-4e19-4ee5-90bf-a29328149677)]
 interface nsIMobileMessageService : nsISupports
 {
   [implicit_jscontext]
   nsIDOMMozSmsMessage createSmsMessage(in long      id,
                                        in unsigned long long threadId,
                                        in DOMString delivery,
                                        in DOMString deliveryStatus,
                                        in DOMString sender,
@@ -39,9 +40,16 @@ interface nsIMobileMessageService : nsIS
                                        in boolean   read,
                                        in DOMString subject,
                                        in DOMString smil,
                                        in jsval     attachments);
 
   nsIDOMMozSmsSegmentInfo createSmsSegmentInfo(in long segments,
                                                in long charsPerSegment,
                                                in long charsAvailableInLastSegment);
+
+  [implicit_jscontext]
+  nsIDOMMozMobileMessageThread createThread(in unsigned long long id,
+                                            in jsval              participants,
+                                            in jsval              timestamp,
+                                            in DOMString          body,
+                                            in unsigned long long unreadCount);
 };
--- a/dom/mobilemessage/src/ipc/PMobileMessageCursor.ipdl
+++ b/dom/mobilemessage/src/ipc/PMobileMessageCursor.ipdl
@@ -13,17 +13,17 @@ namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 protocol PMobileMessageCursor
 {
   manager PSms;
 
 child:
-  NotifyResult(SmsMessageData aMessageData);
+  NotifyResult(MobileMessageCursorData aData);
 
   /**
    * Sent when the asynchronous cursor request has completed.
    */
   __delete__(int32_t aError);
 
 parent:
   Continue();
--- a/dom/mobilemessage/src/ipc/PSms.ipdl
+++ b/dom/mobilemessage/src/ipc/PSms.ipdl
@@ -36,27 +36,32 @@ struct CreateMessageCursorRequest
 };
 
 struct MarkMessageReadRequest
 {
   int32_t messageId;
   bool value;
 };
 
-struct GetThreadListRequest
+struct CreateThreadCursorRequest
 {
 };
 
 union IPCSmsRequest
 {
   SendMessageRequest;
   GetMessageRequest;
   DeleteMessageRequest;
   MarkMessageReadRequest;
-  GetThreadListRequest;
+};
+
+union IPCMobileMessageCursor
+{
+  CreateMessageCursorRequest;
+  CreateThreadCursorRequest;
 };
 
 sync protocol PSms {
     manager PContent;
     manages PSmsRequest;
     manages PMobileMessageCursor;
 
 child:
@@ -81,17 +86,17 @@ parent:
   /**
    * Sent when the child makes an asynchronous request to the parent.
    */
   PSmsRequest(IPCSmsRequest request);
 
   /**
    * Sent when the child makes an asynchronous cursor to the parent.
    */
-  PMobileMessageCursor(CreateMessageCursorRequest request);
+  PMobileMessageCursor(IPCMobileMessageCursor request);
 
   sync HasSupport()
       returns (bool aHasSupport);
 
   sync GetSegmentInfoForText(nsString aText)
       returns (SmsSegmentInfoData aResult);
 };
 
--- a/dom/mobilemessage/src/ipc/PSmsRequest.ipdl
+++ b/dom/mobilemessage/src/ipc/PSmsRequest.ipdl
@@ -60,35 +60,23 @@ struct ReplyMarkeMessageRead
   bool read;
 };
 
 struct ReplyMarkeMessageReadFail
 {
   int32_t error;
 };
 
-struct ReplyThreadList
-{
-  ThreadListItem[] items;
-};
-
-struct ReplyThreadListFail
-{
-  int32_t error;
-};
-
 union MessageReply
 {
   ReplyMessageSend;
   ReplyMessageSendFail;
   ReplyGetMessage;
   ReplyGetMessageFail;
   ReplyMessageDelete;
   ReplyMessageDeleteFail;
   ReplyMarkeMessageRead;
   ReplyMarkeMessageReadFail;
-  ReplyThreadList;
-  ReplyThreadListFail;
 };
 
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/ipc/SmsTypes.ipdlh
+++ b/dom/mobilemessage/src/ipc/SmsTypes.ipdlh
@@ -40,20 +40,26 @@ struct SmsFilterData
 {
   uint64_t      startDate;
   uint64_t      endDate;
   nsString[]    numbers;
   DeliveryState delivery;
   ReadState     read;
 };
 
-struct ThreadListItem
+struct ThreadData
 {
   uint64_t id;
-  nsString senderOrReceiver;
+  nsString[] participants;
   uint64_t timestamp;
   nsString body;
   uint64_t unreadCount;
 };
 
+union MobileMessageCursorData
+{
+  SmsMessageData;
+  ThreadData;
+};
+
 }
 }
 }