Bug 1166679 - Implement GetMessage function, r=btian
authorShawn Huang <shuang@mozilla.com>
Fri, 11 Sep 2015 21:21:19 +0800
changeset 294557 e03440d6f24919ff4235d136b6f4ee722e4d8d54
parent 294556 f7c1cc16ce7443d783c5a833fedbb289c6215e92
child 294558 e51bd925202895621bde14a11f05ccb016de837a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1166679
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 1166679 - Implement GetMessage 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
@@ -345,18 +345,18 @@ BluetoothMapSmsManager::MasDataHandler(U
           ReplyError(ObexResponseCode::BadRequest);
           return;
         }
         pktHeaders.GetContentType(type);
         if (type.EqualsLiteral("x-obex/folder-listing")) {
           HandleSmsMmsFolderListing(pktHeaders);
         } else if (type.EqualsLiteral("x-bt/MAP-msg-listing")) {
           HandleSmsMmsMsgListing(pktHeaders);
-        } else if (type.EqualsLiteral("x-bt/message"))  {
-          // TODO: Implement this feature in Bug 1166679
+        } else if (type.EqualsLiteral("x-bt/message")) {
+          HandleSmsMmsGetMessage(pktHeaders);
         } else {
           BT_LOGR("Unknown MAP request type: %s",
             NS_ConvertUTF16toUTF8(type).get());
         }
       }
       break;
     default:
       ReplyError(ObexResponseCode::NotImplemented);
@@ -780,16 +780,32 @@ BluetoothMapSmsManager::AppendBtNamedVal
     case Map::AppParametersTagId::FilterPriority: {
       uint8_t filterPriority = *((uint8_t *)buf);
       // convert big endian to little endian
       filterPriority = (filterPriority >> 8) | (filterPriority << 8);
       BT_LOGR("msg filter priority: %d", filterPriority);
       AppendNamedValue(aValues, "filterPriority", filterPriority);
       break;
     }
+    case Map::AppParametersTagId::Attachment: {
+      uint8_t attachment = *((uint8_t *)buf);
+      // convert big endian to little endian
+      attachment = (attachment >> 8) | (attachment << 8);
+      BT_LOGR("msg filter attachment: %d", attachment);
+      AppendNamedValue(aValues, "attachment", attachment);
+      break;
+    }
+    case Map::AppParametersTagId::Charset: {
+      uint8_t charset = *((uint8_t *)buf);
+      // convert big endian to little endian
+      charset = (charset >> 8) | (charset << 8);
+      BT_LOGR("msg filter charset: %d", charset);
+      AppendNamedValue(aValues, "charset", charset);
+      break;
+    }
     default:
       BT_LOGR("Unsupported AppParameterTag: %x", aTagId);
       break;
   }
 }
 
 void
 BluetoothMapSmsManager::HandleSmsMmsMsgListing(const ObexHeaderSet& aHeader)
@@ -819,16 +835,39 @@ BluetoothMapSmsManager::HandleSmsMmsMsgL
   }
 
   bs->DistributeSignal(NS_LITERAL_STRING(MAP_MESSAGES_LISTING_REQ_ID),
                        NS_LITERAL_STRING(KEY_ADAPTER),
                        data);
 }
 
 void
+BluetoothMapSmsManager::HandleSmsMmsGetMessage(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, "handle", name);
+
+  AppendBtNamedValueByTagId(aHeader, data,
+                            Map::AppParametersTagId::Attachment);
+  AppendBtNamedValueByTagId(aHeader, data,
+                            Map::AppParametersTagId::Charset);
+
+  bs->DistributeSignal(NS_LITERAL_STRING(MAP_GET_MESSAGE_REQ_ID),
+                       NS_LITERAL_STRING(KEY_ADAPTER),
+                       data);
+}
+
+void
 BluetoothMapSmsManager::BuildDefaultFolderStructure()
 {
   /* MAP specification defines virtual folders structure
    * /
    * /telecom
    * /telecom/msg
    * /telecom/msg/inbox
    * /telecom/msg/draft
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
@@ -92,16 +92,17 @@ private:
   void ReplyToPut();
   void ReplyError(uint8_t aError);
 
   void HandleNotificationRegistration(const ObexHeaderSet& aHeader);
   void HandleEventReport(const ObexHeaderSet& aHeader);
   void HandleMessageStatus(const ObexHeaderSet& aHeader);
   void HandleSmsMmsFolderListing(const ObexHeaderSet& aHeader);
   void HandleSmsMmsMsgListing(const ObexHeaderSet& aHeader);
+  void HandleSmsMmsGetMessage(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
@@ -187,16 +187,22 @@ extern bool gBluetoothDebugFlag;
 
 /**
  * When receiving a MAP request of 'messages listing' 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 the value of a characteristic of a remote BLE device changes, we'll
  * dispatch an event
  */
 #define GATT_CHARACTERISTIC_CHANGED_ID       "characteristicchanged"
 
 /**
  * When a remote BLE device gets connected / disconnected, we'll dispatch an
  * event.