Bug 1195710 - [MAP]Implement PushMessage function, r=btian

This commit is contained in:
Shawn Huang 2015-09-13 19:03:23 +08:00
parent 1c854d38b1
commit 78ca01d880
3 changed files with 45 additions and 11 deletions

View File

@ -334,6 +334,8 @@ BluetoothMapSmsManager::MasDataHandler(UnixSocketBuffer* aMessage)
HandleEventReport(pktHeaders);
} else if (type.EqualsLiteral("x-bt/messageStatus")) {
HandleSetMessageStatus(pktHeaders);
} else if (type.EqualsLiteral("x-bt/message")) {
HandleSmsMmsPushMessage(pktHeaders);
}
}
break;
@ -819,6 +821,23 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
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;
@ -980,6 +999,28 @@ BluetoothMapSmsManager::HandleSetMessageStatus(const ObexHeaderSet& aHeader)
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)
{

View File

@ -98,6 +98,8 @@ private:
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);

View File

@ -186,22 +186,13 @@ extern bool gBluetoothDebugFlag;
#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