Bug 1195710 - [MAP]Implement PushMessage function, r=btian
authorShawn Huang <shuang@mozilla.com>
Sun, 13 Sep 2015 19:03:23 +0800
changeset 262197 af74f0f2ade62cd9c250377eb7b848e2848f6f39
parent 262196 788a8f910b289e9a6cfe96210d63783ca6cc0792
child 262198 bfb98584a86728285570923fc2859012f1bdf089
push id29364
push userphilringnalda@gmail.com
push dateSun, 13 Sep 2015 17:54:20 +0000
treeherdermozilla-central@d9ec62232cf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1195710
milestone43.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 1195710 - [MAP]Implement PushMessage function, r=btian
dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
dom/bluetooth/common/BluetoothCommon.h
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
@@ -329,16 +329,18 @@ BluetoothMapSmsManager::MasDataHandler(U
         ReplyToPut();
 
         if (type.EqualsLiteral("x-bt/MAP-NotificationRegistration")) {
           HandleNotificationRegistration(pktHeaders);
         } else if (type.EqualsLiteral("x-bt/MAP-event-report")) {
           HandleEventReport(pktHeaders);
         } else if (type.EqualsLiteral("x-bt/messageStatus")) {
           HandleSetMessageStatus(pktHeaders);
+        } else if (type.EqualsLiteral("x-bt/message")) {
+          HandleSmsMmsPushMessage(pktHeaders);
         }
       }
       break;
     case ObexRequestCode::Get:
     case ObexRequestCode::GetFinal: {
         // [opcode:1][length:2][Headers:var]
         if (receivedLength < 3 ||
           !ParseHeaders(&data[3], receivedLength - 3, &pktHeaders)) {
@@ -814,16 +816,33 @@ BluetoothMapSmsManager::AppendBtNamedVal
       uint8_t statusValue = *((uint8_t *)buf);
       // convert big endian to little endian
       statusValue = (statusValue >> 8) | (statusValue << 8);
       BT_LOGR("msg filter statusvalue: %d", statusValue);
       AppendNamedValue(aValues, "statusValue",
                        static_cast<uint32_t>(statusValue));
       break;
     }
+    case Map::AppParametersTagId::Transparent: {
+      uint8_t transparent = *((uint8_t *)buf);
+      // convert big endian to little endian
+      transparent = (transparent >> 8) | (transparent << 8);
+      BT_LOGR("msg filter statusvalue: %d", transparent);
+      AppendNamedValue(aValues, "transparent",
+                       static_cast<uint32_t>(transparent));
+      break;
+    }
+    case Map::AppParametersTagId::Retry: {
+      uint8_t retry = *((uint8_t *)buf);
+      // convert big endian to little endian
+      retry = (retry >> 8) | (retry << 8);
+      BT_LOGR("msg filter retry: %d", retry);
+      AppendNamedValue(aValues, "retry", static_cast<uint32_t>(retry));
+      break;
+    }
     default:
       BT_LOGR("Unsupported AppParameterTag: %x", aTagId);
       break;
   }
 }
 
 void
 BluetoothMapSmsManager::HandleSmsMmsMsgListing(const ObexHeaderSet& aHeader)
@@ -976,16 +995,38 @@ BluetoothMapSmsManager::HandleSetMessage
   AppendBtNamedValueByTagId(aHeader, data,
                             Map::AppParametersTagId::StatusValue);
 
   bs->DistributeSignal(NS_LITERAL_STRING(MAP_SET_MESSAGE_STATUS_REQ_ID),
                        NS_LITERAL_STRING(KEY_ADAPTER), data);
 }
 
 void
+BluetoothMapSmsManager::HandleSmsMmsPushMessage(const ObexHeaderSet& aHeader)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  BluetoothService* bs = BluetoothService::Get();
+  NS_ENSURE_TRUE_VOID(bs);
+
+  InfallibleTArray<BluetoothNamedValue> data;
+  nsString name;
+  aHeader.GetName(name);
+  AppendNamedValue(data, "folderName", name);
+
+  AppendBtNamedValueByTagId(aHeader, data,
+                            Map::AppParametersTagId::Transparent);
+  AppendBtNamedValueByTagId(aHeader, data, Map::AppParametersTagId::Retry);
+  AppendBtNamedValueByTagId(aHeader, data, Map::AppParametersTagId::Charset);
+
+  bs->DistributeSignal(NS_LITERAL_STRING(MAP_PUSH_MESSAGE_REQ_ID),
+                       NS_LITERAL_STRING(KEY_ADAPTER), data);
+}
+
+void
 BluetoothMapSmsManager::ReplyError(uint8_t aError)
 {
   BT_LOGR("[0x%x]", aError);
 
   // Section 3.2 "Response Format", IrOBEX 1.2
   // [opcode:1][length:2][Headers:var]
   uint8_t req[255];
   int index = 3;
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
@@ -93,16 +93,18 @@ private:
   void ReplyError(uint8_t aError);
 
   void HandleNotificationRegistration(const ObexHeaderSet& aHeader);
   void HandleEventReport(const ObexHeaderSet& aHeader);
   void HandleSetMessageStatus(const ObexHeaderSet& aHeader);
   void HandleSmsMmsFolderListing(const ObexHeaderSet& aHeader);
   void HandleSmsMmsMsgListing(const ObexHeaderSet& aHeader);
   void HandleSmsMmsGetMessage(const ObexHeaderSet& aHeader);
+  void HandleSmsMmsPushMessage(const ObexHeaderSet& aHeader);
+
   void AppendBtNamedValueByTagId(const ObexHeaderSet& aHeader,
     InfallibleTArray<BluetoothNamedValue>& aValues,
     const Map::AppParametersTagId aTagId);
   void SendMasObexData(uint8_t* aData, uint8_t aOpcode, int aSize);
   void SendMnsObexData(uint8_t* aData, uint8_t aOpcode, int aSize);
 
   uint8_t SetPath(uint8_t flags, const ObexHeaderSet& aHeader);
   bool CompareHeaderTarget(const ObexHeaderSet& aHeader);
--- a/dom/bluetooth/common/BluetoothCommon.h
+++ b/dom/bluetooth/common/BluetoothCommon.h
@@ -181,32 +181,23 @@ extern bool gBluetoothDebugFlag;
 /**
  * When receiving a PBAP request from a remote device, we'll dispatch an event.
  */
 #define PULL_PHONEBOOK_REQ_ID                "pullphonebookreq"
 #define PULL_VCARD_ENTRY_REQ_ID              "pullvcardentryreq"
 #define PULL_VCARD_LISTING_REQ_ID            "pullvcardlistingreq"
 
 /**
- * When receiving a MAP request of 'messages listing' from a remote device,
+ * When receiving a MAP request from a remote device,
  * we'll dispatch an event.
  */
 #define MAP_MESSAGES_LISTING_REQ_ID          "mapmessageslistingreq"
-
-/**
- * When receiving a MAP request of 'get message' from a remote device,
- * we'll dispatch an event.
- */
 #define MAP_GET_MESSAGE_REQ_ID               "mapgetmessagereq"
-
-/**
- * When receiving a MAP request of 'set message' from a remote device,
- * we'll dispatch an event.
- */
 #define MAP_SET_MESSAGE_STATUS_REQ_ID        "mapsetmessagestatusreq"
+#define MAP_PUSH_MESSAGE_REQ_ID              "mappushmessagereq"
 
 /**
  * When the value of a characteristic of a remote BLE device changes, we'll
  * dispatch an event
  */
 #define GATT_CHARACTERISTIC_CHANGED_ID       "characteristicchanged"
 
 /**