Bug 850127 - 2/3: DOM & IPC. r=mounir
authorVicamo Yang <vyang@mozilla.com>
Fri, 05 Apr 2013 20:15:52 +0800
changeset 127793 f7b7600dd8fa938da9d380d2b0d1eb8ffd81a7f9
parent 127792 4a62344fc87b9732c578828b2992e310a9b3f0d4
child 127794 624ff603f70cb17d0664eb7b23deabdf12949a2c
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherdermozilla-central@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs850127
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 850127 - 2/3: DOM & IPC. r=mounir
dom/mobilemessage/src/MmsMessage.cpp
dom/mobilemessage/src/MmsMessage.h
dom/mobilemessage/src/MobileMessageService.cpp
dom/mobilemessage/src/SmsMessage.cpp
dom/mobilemessage/src/SmsMessage.h
dom/mobilemessage/src/SmsRequest.cpp
--- a/dom/mobilemessage/src/MmsMessage.cpp
+++ b/dom/mobilemessage/src/MmsMessage.cpp
@@ -26,40 +26,43 @@ NS_INTERFACE_MAP_BEGIN(MmsMessage)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMmsMessage)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(MmsMessage)
 NS_IMPL_RELEASE(MmsMessage)
 
 MmsMessage::MmsMessage(int32_t                         aId,
+                       const uint64_t                  aThreadId,
                        DeliveryState                   aDelivery,
                        const nsTArray<DeliveryStatus>& aDeliveryStatus,
                        const nsAString&                aSender,
                        const nsTArray<nsString>&       aReceivers,
                        uint64_t                        aTimestamp,
                        bool                            aRead,
                        const nsAString&                aSubject,
                        const nsAString&                aSmil,
                        const nsTArray<MmsAttachment>&  aAttachments)
   : mId(aId),
+    mThreadId(aThreadId),
     mDelivery(aDelivery),
     mDeliveryStatus(aDeliveryStatus),
     mSender(aSender),
     mReceivers(aReceivers),
     mTimestamp(aTimestamp),
     mRead(aRead),
     mSubject(aSubject),
     mSmil(aSmil),
     mAttachments(aAttachments)
 {
 }
 
 /* static */ nsresult
 MmsMessage::Create(int32_t               aId,
+                   const uint64_t        aThreadId,
                    const nsAString&      aDelivery,
                    const JS::Value&      aDeliveryStatus,
                    const nsAString&      aSender,
                    const JS::Value&      aReceivers,
                    const JS::Value&      aTimestamp,
                    bool                  aRead,
                    const nsAString&      aSubject,
                    const nsAString&      aSmil,
@@ -188,16 +191,17 @@ MmsMessage::Create(int32_t              
     MmsAttachment attachment;
     nsresult rv = attachment.Init(aCx, &attachmentJsVal);
     NS_ENSURE_SUCCESS(rv, rv);
 
     attachments.AppendElement(attachment);
   }
 
   nsCOMPtr<nsIDOMMozMmsMessage> message = new MmsMessage(aId,
+                                                         aThreadId,
                                                          delivery,
                                                          deliveryStatus,
                                                          aSender,
                                                          receivers,
                                                          timestamp,
                                                          aRead,
                                                          aSubject,
                                                          aSmil,
@@ -216,16 +220,23 @@ MmsMessage::GetType(nsAString& aType)
 NS_IMETHODIMP
 MmsMessage::GetId(int32_t* aId)
 {
   *aId = mId;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+MmsMessage::GetThreadId(uint64_t* aThreadId)
+{
+  *aThreadId = mThreadId;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 MmsMessage::GetDelivery(nsAString& aDelivery)
 {
   switch (mDelivery) {
     case eDeliveryState_Received:
       aDelivery = DELIVERY_RECEIVED;
       break;
     case eDeliveryState_Sending:
       aDelivery = DELIVERY_SENDING;
--- a/dom/mobilemessage/src/MmsMessage.h
+++ b/dom/mobilemessage/src/MmsMessage.h
@@ -18,42 +18,45 @@ namespace dom {
 
 class MmsMessage MOZ_FINAL : public nsIDOMMozMmsMessage
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMMOZMMSMESSAGE
 
   MmsMessage(int32_t                                        aId,
+             const uint64_t                                 aThreadId,
              mobilemessage::DeliveryState                   aDelivery,
              const nsTArray<mobilemessage::DeliveryStatus>& aDeliveryStatus,
              const nsAString&                               aSender,
              const nsTArray<nsString>&                      aReceivers,
              uint64_t                                       aTimestamp,
              bool                                           aRead,
              const nsAString&                               aSubject,
              const nsAString&                               aSmil,
              const nsTArray<idl::MmsAttachment>&            aAttachments);
 
   static nsresult Create(int32_t               aId,
+                         const uint64_t        aThreadId,
                          const nsAString&      aDelivery,
                          const JS::Value&      aDeliveryStatus,
                          const nsAString&      aSender,
                          const JS::Value&      aReceivers,
                          const JS::Value&      aTimestamp,
                          bool                  aRead,
                          const nsAString&      aSubject,
                          const nsAString&      aSmil,
                          const JS::Value&      aAttachments,
                          JSContext*            aCx,
                          nsIDOMMozMmsMessage** aMessage);
 
 private:
 
   int32_t                                 mId;
+  uint64_t                                mThreadId;
   mobilemessage::DeliveryState            mDelivery;
   nsTArray<mobilemessage::DeliveryStatus> mDeliveryStatus;
   nsString                                mSender;
   nsTArray<nsString>                      mReceivers;
   uint64_t                                mTimestamp;
   bool                                    mRead;
   nsString                                mSubject;
   nsString                                mSmil;
--- a/dom/mobilemessage/src/MobileMessageService.cpp
+++ b/dom/mobilemessage/src/MobileMessageService.cpp
@@ -25,55 +25,59 @@ MobileMessageService::GetInstance()
   }
 
   nsRefPtr<MobileMessageService> service = sSingleton.get();
   return service.forget();
 }
 
 NS_IMETHODIMP
 MobileMessageService::CreateSmsMessage(int32_t aId,
+                                       uint64_t aThreadId,
                                        const nsAString& aDelivery,
                                        const nsAString& aDeliveryStatus,
                                        const nsAString& aSender,
                                        const nsAString& aReceiver,
                                        const nsAString& aBody,
                                        const nsAString& aMessageClass,
                                        const JS::Value& aTimestamp,
                                        const bool aRead,
                                        JSContext* aCx,
                                        nsIDOMMozSmsMessage** aMessage)
 {
   return SmsMessage::Create(aId,
+                            aThreadId,
                             aDelivery,
                             aDeliveryStatus,
                             aSender,
                             aReceiver,
                             aBody,
                             aMessageClass,
                             aTimestamp,
                             aRead,
                             aCx,
                             aMessage);
 }
 
 NS_IMETHODIMP
 MobileMessageService::CreateMmsMessage(int32_t               aId,
+                                       uint64_t              aThreadId,
                                        const nsAString&      aDelivery,
                                        const JS::Value&      aDeliveryStatus,
                                        const nsAString&      aSender,
                                        const JS::Value&      aReceivers,
                                        const JS::Value&      aTimestamp,
                                        bool                  aRead,
                                        const nsAString&      aSubject,
                                        const nsAString&      aSmil,
                                        const JS::Value&      aAttachments,
                                        JSContext*            aCx,
                                        nsIDOMMozMmsMessage** aMessage)
 {
   return MmsMessage::Create(aId,
+                            aThreadId,
                             aDelivery,
                             aDeliveryStatus,
                             aSender,
                             aReceivers,
                             aTimestamp,
                             aRead,
                             aSubject,
                             aSmil,
--- a/dom/mobilemessage/src/SmsMessage.cpp
+++ b/dom/mobilemessage/src/SmsMessage.cpp
@@ -21,36 +21,38 @@ NS_INTERFACE_MAP_BEGIN(SmsMessage)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsMessage)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(SmsMessage)
 NS_IMPL_RELEASE(SmsMessage)
 
 SmsMessage::SmsMessage(int32_t aId,
+                       const uint64_t aThreadId,
                        DeliveryState aDelivery,
                        DeliveryStatus aDeliveryStatus,
                        const nsString& aSender,
                        const nsString& aReceiver,
                        const nsString& aBody,
                        MessageClass aMessageClass,
                        uint64_t aTimestamp,
                        bool aRead)
-  : mData(aId, aDelivery, aDeliveryStatus, aSender, aReceiver, aBody,
+  : mData(aId, aThreadId, aDelivery, aDeliveryStatus, aSender, aReceiver, aBody,
           aMessageClass, aTimestamp, aRead)
 {
 }
 
 SmsMessage::SmsMessage(const SmsMessageData& aData)
   : mData(aData)
 {
 }
 
 /* static */ nsresult
 SmsMessage::Create(int32_t aId,
+                   const uint64_t aThreadId,
                    const nsAString& aDelivery,
                    const nsAString& aDeliveryStatus,
                    const nsAString& aSender,
                    const nsAString& aReceiver,
                    const nsAString& aBody,
                    const nsAString& aMessageClass,
                    const JS::Value& aTimestamp,
                    const bool aRead,
@@ -58,16 +60,17 @@ SmsMessage::Create(int32_t aId,
                    nsIDOMMozSmsMessage** aMessage)
 {
   *aMessage = nullptr;
 
   // SmsMessageData exposes these as references, so we can simply assign
   // to them.
   SmsMessageData data;
   data.id() = aId;
+  data.threadId() = aThreadId;
   data.sender() = nsString(aSender);
   data.receiver() = nsString(aReceiver);
   data.body() = nsString(aBody);
   data.read() = aRead;
 
   if (aDelivery.Equals(DELIVERY_RECEIVED)) {
     data.delivery() = eDeliveryState_Received;
   } else if (aDelivery.Equals(DELIVERY_SENDING)) {
@@ -145,16 +148,23 @@ SmsMessage::GetType(nsAString& aType)
 NS_IMETHODIMP
 SmsMessage::GetId(int32_t* aId)
 {
   *aId = mData.id();
   return NS_OK;
 }
 
 NS_IMETHODIMP
+SmsMessage::GetThreadId(uint64_t* aThreadId)
+{
+  *aThreadId = mData.threadId();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 SmsMessage::GetDelivery(nsAString& aDelivery)
 {
   switch (mData.delivery()) {
     case eDeliveryState_Received:
       aDelivery = DELIVERY_RECEIVED;
       break;
     case eDeliveryState_Sending:
       aDelivery = DELIVERY_SENDING;
--- a/dom/mobilemessage/src/SmsMessage.h
+++ b/dom/mobilemessage/src/SmsMessage.h
@@ -18,27 +18,29 @@ namespace dom {
 
 class SmsMessage MOZ_FINAL : public nsIDOMMozSmsMessage
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMMOZSMSMESSAGE
 
   SmsMessage(int32_t aId,
+             const uint64_t aThreadId,
              mobilemessage::DeliveryState aDelivery,
              mobilemessage::DeliveryStatus aDeliveryStatus,
              const nsString& aSender,
              const nsString& aReceiver,
              const nsString& aBody,
              mobilemessage::MessageClass aMessageClass,
              uint64_t aTimestamp,
              bool aRead);
   SmsMessage(const mobilemessage::SmsMessageData& aData);
 
   static nsresult Create(int32_t aId,
+                         const uint64_t aThreadId,
                          const nsAString& aDelivery,
                          const nsAString& aDeliveryStatus,
                          const nsAString& aSender,
                          const nsAString& aReceiver,
                          const nsAString& aBody,
                          const nsAString& aMessageClass,
                          const JS::Value& aTimestamp,
                          const bool aRead,
--- a/dom/mobilemessage/src/SmsRequest.cpp
+++ b/dom/mobilemessage/src/SmsRequest.cpp
@@ -527,16 +527,17 @@ SmsRequest::NotifyThreadList(const JS::V
 
         MOZ_ASSERT(arrayEntry.isObject());
 
         mozilla::idl::SmsThreadListItem item;
         nsresult rv = item.Init(aCx, &arrayEntry);
         NS_ENSURE_SUCCESS(rv, rv);
 
         ThreadListItem* ipcItem = ipcItems.AppendElement();
+        ipcItem->id() = item.id;
         ipcItem->senderOrReceiver() = item.senderOrReceiver;
         ipcItem->timestamp() = item.timestamp;
         ipcItem->body() = item.body;
         ipcItem->unreadCount() = item.unreadCount;
       }
     }
 
     return SendMessageReply(reply);
@@ -582,16 +583,18 @@ SmsRequest::NotifyThreadList(const Infal
   JSObject* array = JS_NewArrayObject(cx, aItems.Length(), nullptr);
   NS_ENSURE_TRUE_VOID(array);
 
   bool ok;
 
   for (uint32_t i = 0; i < aItems.Length(); i++) {
     const ThreadListItem& source = aItems[i];
 
+    jsval id = JS_NumberValue(double(source.id()));
+
     nsString temp = source.senderOrReceiver();
 
     JS::Value senderOrReceiver;
     ok = xpc::StringToJsval(cx, temp, &senderOrReceiver);
     NS_ENSURE_TRUE_VOID(ok);
 
     JSObject* timestampObj = JS_NewDateObjectMsec(cx, source.timestamp());
     NS_ENSURE_TRUE_VOID(timestampObj);
@@ -604,16 +607,19 @@ SmsRequest::NotifyThreadList(const Infal
     ok = xpc::StringToJsval(cx, temp, &body);
     NS_ENSURE_TRUE_VOID(ok);
 
     JS::Value unreadCount = JS_NumberValue(double(source.unreadCount()));
 
     JSObject* elementObj = JS_NewObject(cx, nullptr, nullptr, nullptr);
     NS_ENSURE_TRUE_VOID(elementObj);
 
+    ok = JS_SetProperty(cx, elementObj, "id", &id);
+    NS_ENSURE_TRUE_VOID(ok);
+
     ok = JS_SetProperty(cx, elementObj, "senderOrReceiver", &senderOrReceiver);
     NS_ENSURE_TRUE_VOID(ok);
 
     ok = JS_SetProperty(cx, elementObj, "timestamp", &timestamp);
     NS_ENSURE_TRUE_VOID(ok);
 
     ok = JS_SetProperty(cx, elementObj, "body", &body);
     NS_ENSURE_TRUE_VOID(ok);