Bug 1166647 - Implement MAP bMessage class, r=btian

This commit is contained in:
Shawn Huang 2015-10-01 16:30:58 +08:00
parent 43588d91ee
commit d49bbbf6b7
5 changed files with 607 additions and 24 deletions

View File

@ -0,0 +1,416 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "BluetoothMapBMessage.h"
#include "base/basictypes.h"
#include "plstr.h"
BEGIN_BLUETOOTH_NAMESPACE
namespace {
static const char kMapCrlf[] = "\r\n";
}
BluetoothMapBMessage::BluetoothMapBMessage(uint8_t* aObexBody, int aLength)
: mReadStatus(false)
, mPartId(0)
, mState(BMSG_PARSING_STATE_INVALID)
, mUnwindState(BMSG_PARSING_STATE_INVALID)
, mEnvelopeLevel(0)
{
const nsCString body = nsCString(reinterpret_cast<const char*>(aObexBody),
aLength);
ProcessDecode(body.get());
}
BluetoothMapBMessage::~BluetoothMapBMessage()
{}
/**
* Read one line by one line.
*
* @param aNextLineStart [in][out] On input, aNextLineStart is the start of
* the current line. On output, aNextLineStart is the start of the next
* line.
* @param aLine [out] The next line read.
*/
static int
ReadLine(const char* & aNextLineStart, nsACString& aLine)
{
aLine.Truncate();
for (;;) {
const char* eol = PL_strpbrk(aNextLineStart, kMapCrlf);
if (!eol) { // Reached end of file before newline
eol = aNextLineStart + strlen(aNextLineStart);
}
aLine.Append(aNextLineStart, eol - aNextLineStart);
if (*eol == '\r') {
++eol;
}
if (*eol == '\n') {
++eol;
}
aNextLineStart = eol;
if (*eol != ' ') {
// not a continuation
return 0;
}
}
}
static bool
ExtractParameter(const nsAutoCString& aCurrLine,
const char* aPattern, nsACString& aParam)
{
aParam.Truncate();
if (aCurrLine.Find(aPattern, false, 0, PL_strlen(aPattern)) == kNotFound) {
return false;
}
int32_t colonPos = aCurrLine.FindChar(':');
aParam = nsDependentCSubstring(aCurrLine, colonPos + 1, aCurrLine.Length());
return true;
}
/*
* |ProcessDecode| parses bMessage based on following MAP 3.1.3 Message Format.
* The state transition follows by BMsgParserState.
* BNF:
* <bmessage-object>::= {
* "BEGIN:BMSG" <CRLF>
* <bmessage-property>
* [<bmessage-originator>]*
* <bmessage-envelope>
* "END:BMSG" <CRLF>
* }
*
* <bmessage-envelope> ::= {
* "BEGIN:BENV" <CRLF>
* [<bmessage-recipient>]*
* <bmessage-envelope> | <bmessage-content>
* "END:BENV" <CRLF>
* }
*
* The state transition follows:
* BEGIN_BMSG->VERSION->STATUS->TYPE->FOLDER->ORIGINATOR->VCARD->ENVELOPE->
* VCARD->RECIPIENT->BODY->BMSG
*/
void
BluetoothMapBMessage::ProcessDecode(const char* aBuf)
{
mState = BMSG_PARSING_STATE_BEGIN_BMSG;
static void (BluetoothMapBMessage::* const ParserActions[])(const
nsAutoCString&) = {
nullptr, /* BMSG_PARSING_STATE_INVALID */
&BluetoothMapBMessage::ParseBeginBmsg,
&BluetoothMapBMessage::ParseVersion,
&BluetoothMapBMessage::ParseStatus,
&BluetoothMapBMessage::ParseType,
&BluetoothMapBMessage::ParseFolder,
&BluetoothMapBMessage::ParseOriginator,
&BluetoothMapBMessage::ParseVCard,
&BluetoothMapBMessage::ParseEnvelope,
&BluetoothMapBMessage::ParseRecipient,
&BluetoothMapBMessage::ParseBody,
&BluetoothMapBMessage::ParseBMsg
};
for (;;) {
nsAutoCString curLine;
if (ReadLine(aBuf, curLine) == -1) {
// Cannot find eol symbol
return;
}
if (curLine.IsEmpty()) {
// Blank line or eof, exit
return;
}
MOZ_ASSERT(mState != BMSG_PARSING_STATE_INVALID);
// Parse bMessage
(this->*(ParserActions[mState]))(curLine);
}
}
void
BluetoothMapBMessage::ParseBeginBmsg(const nsAutoCString& aCurrLine)
{
if (aCurrLine.EqualsLiteral("BEGIN:BMSG")) {
mState = BMSG_PARSING_STATE_VERSION;
}
}
void
BluetoothMapBMessage::ParseVersion(const nsAutoCString& aCurrLine)
{
nsCString version;
if (ExtractParameter(aCurrLine, "VERSION:", version)) {
/* The value for this property shall be "VERSION:1.0",
* based on Message Access Profile 3.1.3.
*/
if (version.EqualsLiteral("1.0")) {
mState = BMSG_PARSING_STATE_STATUS;
}
}
}
void
BluetoothMapBMessage::ParseStatus(const nsAutoCString& aCurrLine)
{
nsCString status;
if (ExtractParameter(aCurrLine, "STATUS:", status)) {
// only READ or UNREAD status
mReadStatus = status.EqualsLiteral("READ");
mState = BMSG_PARSING_STATE_TYPE;
}
}
void
BluetoothMapBMessage::ParseType(const nsAutoCString& aCurrLine)
{
nsCString type;
if (ExtractParameter(aCurrLine, "TYPE:", type)) {
mType = type;
mState = BMSG_PARSING_STATE_FOLDER;
}
}
void
BluetoothMapBMessage::ParseFolder(const nsAutoCString& aCurrLine)
{
nsCString folder;
if (ExtractParameter(aCurrLine, "FOLDER:", folder)) {
mFolderName = folder;
}
mState = BMSG_PARSING_STATE_ORIGINATOR;
}
void
BluetoothMapBMessage::ParseOriginator(const nsAutoCString& aCurrLine)
{
if (aCurrLine.EqualsLiteral("BEGIN:VCARD")) {
mOriginators.AppendElement(new VCard());
// We may parse vCard multiple times
mUnwindState = mState;
mState = BMSG_PARSING_STATE_VCARD;
} else if (aCurrLine.EqualsLiteral("BEGIN:BENV")) {
mState = BMSG_PARSING_STATE_BEGIN_ENVELOPE;
}
}
void
BluetoothMapBMessage::ParseVCard(const nsAutoCString& aCurrLine)
{
if (aCurrLine.EqualsLiteral("END:VCARD")) {
mState = mUnwindState;
return;
}
if (mUnwindState == BMSG_PARSING_STATE_ORIGINATOR &&
!mOriginators.IsEmpty()) {
mOriginators.LastElement()->Parse(aCurrLine);
} else if (mUnwindState == BMSG_PARSING_STATE_RECIPIENT &&
!mRecipients.IsEmpty()) {
mRecipients.LastElement()->Parse(aCurrLine);
}
}
void
BluetoothMapBMessage::ParseEnvelope(const nsAutoCString& aCurrLine)
{
if(!aCurrLine.EqualsLiteral("BEGIN:VCARD") &&
!aCurrLine.EqualsLiteral("BEGIN:BENV")) {
mState = BMSG_PARSING_STATE_BEGIN_BODY;
return;
}
if (aCurrLine.EqualsLiteral("BEGIN:BENV")) {
// nested BENV
// TODO: Check nested BENV envelope level for Email use case
++mEnvelopeLevel;
}
mRecipients.AppendElement(new VCard());
mState = BMSG_PARSING_STATE_VCARD;
// In case there are many recipients
mUnwindState = BMSG_PARSING_STATE_RECIPIENT;
}
void
BluetoothMapBMessage::ParseRecipient(const nsAutoCString& aCurrLine)
{
/* After parsing vCard, check whether it's bMessage BODY or VCARD.
* bmessage-recipient may appear more than once.
*/
if (aCurrLine.EqualsLiteral("BEGIN:BBODY")) {
mState = BMSG_PARSING_STATE_BEGIN_BODY;
} else if (aCurrLine.EqualsLiteral("BEGIN:VCARD")) {
mState = BMSG_PARSING_STATE_VCARD;
}
}
/* |ParseBody| parses based on the following BNF format:
* <bmessage-body-property>::=[<bmessage-body-encoding-property>]
* [<bmessage-body-charset-property>]
* [<bmessage-body-language-property>]
* <bmessage-body-content-length-property>
*
* <bmessage-content>::= {
* "BEGIN:BBODY"<CRLF>
* [<bmessage-body-part-ID> <CRLF>]
* <bmessage-body-property>
* <bmessage-body-content>* <CRLF>
* "END:BBODY"<CRLF>
* }
*/
void
BluetoothMapBMessage::ParseBody(const nsAutoCString& aCurrLine)
{
nsCString param;
if (ExtractParameter(aCurrLine, "PARTID::", param)) {
nsresult rv;
mPartId = param.ToInteger(&rv);
if (NS_FAILED(rv)) {
BT_LOGR("Failed to convert PARTID, error: 0x%x",
static_cast<uint32_t>(rv));
}
} else if (ExtractParameter(aCurrLine, "ENCODING:", param)) {
mEncoding = param;
} else if (ExtractParameter(aCurrLine, "CHARSET:", param)) {
mCharset = param;
} else if (ExtractParameter(aCurrLine, "LANGUAGE:", param)) {
mLanguage = param;
} else if (ExtractParameter(aCurrLine, "LENGTH:", param)) {
mBMsgLength = param;
} else if (aCurrLine.EqualsLiteral("BEGIN:MSG")) {
// Parse <bmessage-body-content>
mState = BMSG_PARSING_STATE_BEGIN_MSG;
}
}
/* |ParseBMsg| parses based on the following BNF format:
* <bmessage-body-content>::={
* "BEGIN:MSG"<CRLF>
* 'message'<CRLF>
* "END:MSG"<CRLF>
* }
*/
void
BluetoothMapBMessage::ParseBMsg(const nsAutoCString& aCurrLine)
{
/* TODO: Support binary message content
* For SMS: currently only UTF-8 is supported for textual content.
*/
if (aCurrLine.EqualsLiteral("END:MSG") ||
aCurrLine.EqualsLiteral("BEGIN:MSG")) {
/* Set state to STATE_BEGIN_MSG due to <bmessage-body-content> may appear
* many times.
*/
mState = BMSG_PARSING_STATE_BEGIN_MSG;
return;
}
mBMsgBody += aCurrLine.get();
// restore <CRLF>
mBMsgBody.AppendLiteral(kMapCrlf);
}
void
BluetoothMapBMessage::GetRecipients(nsTArray<nsRefPtr<VCard>>& aRecipients)
{
aRecipients = mRecipients;
}
void
BluetoothMapBMessage::GetOriginators(nsTArray<nsRefPtr<VCard>>& aOriginators)
{
aOriginators = mOriginators;
}
void
BluetoothMapBMessage::GetBody(nsACString& aBody)
{
aBody = mBMsgBody;
}
void
BluetoothMapBMessage::Dump()
{
BT_LOGR("Dump: message body %s", mBMsgBody.get());
BT_LOGR("Dump: read status %s", mReadStatus? "true" : "false");
BT_LOGR("Dump: folder %s", mFolderName.get());
BT_LOGR("Dump encoding %s", mEncoding.get());
BT_LOGR("Dump charset: %s" , mCharset.get());
BT_LOGR("Dump language: %s", mLanguage.get());
BT_LOGR("Dump length: %s", mBMsgLength.get());
BT_LOGR("Dump type: %s ", mType.get());
}
VCard::VCard()
{}
VCard::~VCard()
{}
void
VCard::Parse(const nsAutoCString& aCurrLine)
{
nsCString param;
if (ExtractParameter(aCurrLine, "N:", param)) {
mName = param;
} else if (ExtractParameter(aCurrLine, "FN:", param)) {
mFormattedName = param;
} else if (ExtractParameter(aCurrLine, "TEL:", param)) {
mTelephone = param;
} else if (ExtractParameter(aCurrLine, "Email:", param)) {
mEmail = param;
}
}
void
VCard::GetTelephone(nsACString& aTelephone)
{
aTelephone = mTelephone;
}
void
VCard::GetName(nsACString& aName)
{
aName = mName;
}
void
VCard::GetFormattedName(nsACString& aFormattedName)
{
aFormattedName = mFormattedName;
}
void
VCard::GetEmail(nsACString& aEmail)
{
aEmail = mEmail;
}
void
VCard::Dump()
{
BT_LOGR("Dump: Name %s", mName.get());
BT_LOGR("Dump: FormattedName %s", mFormattedName.get());
BT_LOGR("Dump: Telephone %s", mTelephone.get());
BT_LOGR("Dump: Email %s", mEmail.get());
}
END_BLUETOOTH_NAMESPACE

View File

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_dom_bluetooth_bluedroid_BluetoothMapBMessage_h
#define mozilla_dom_bluetooth_bluedroid_BluetoothMapBMessage_h
#include "BluetoothCommon.h"
#include "nsAutoPtr.h"
#include "nsRefPtrHashtable.h"
#include "nsTArray.h"
BEGIN_BLUETOOTH_NAMESPACE
enum BMsgParserState {
BMSG_PARSING_STATE_INVALID,
BMSG_PARSING_STATE_BEGIN_BMSG,
BMSG_PARSING_STATE_VERSION,
BMSG_PARSING_STATE_STATUS,
BMSG_PARSING_STATE_TYPE,
BMSG_PARSING_STATE_FOLDER,
BMSG_PARSING_STATE_ORIGINATOR,
BMSG_PARSING_STATE_VCARD,
BMSG_PARSING_STATE_BEGIN_ENVELOPE,
BMSG_PARSING_STATE_RECIPIENT,
BMSG_PARSING_STATE_BEGIN_BODY,
BMSG_PARSING_STATE_BEGIN_MSG,
};
class VCard {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VCard)
VCard();
void Parse(const nsAutoCString& aCurrLine);
void GetName(nsACString& aName);
void GetFormattedName(nsACString& aFormattedName);
void GetTelephone(nsACString& aTelephone);
void GetEmail(nsACString& aEmail);
void Dump();
private:
~VCard();
nsCString mName;
nsCString mFormattedName;
nsCString mTelephone;
nsCString mEmail;
};
/* This class represents MAP bMessage. The bMessage object encapsulates
* delivered message objects and provides additionally a suitable set properties
* with helpful information. The general encoding characteristics as defined for
* vCards.
*/
class BluetoothMapBMessage
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothMapBMessage)
// Parse OBEX body and return bMessage object.
BluetoothMapBMessage(uint8_t* aObexBody, int aLength);
void GetRecipients(nsTArray<nsRefPtr<VCard>>& aRecipients);
void GetOriginators(nsTArray<nsRefPtr<VCard>>& aRecipients);
void GetBody(nsACString& aBody);
void Dump();
private:
~BluetoothMapBMessage();
void ProcessDecode(const char* aBody);
void ParseBeginBmsg(const nsAutoCString& aCurrLine);
void ParseVersion(const nsAutoCString& aCurrLine);
void ParseStatus(const nsAutoCString& aCurrLine);
void ParseType(const nsAutoCString& aCurrLine);
void ParseFolder(const nsAutoCString& aCurrLine);
void ParseOriginator(const nsAutoCString& aCurrLine);
void ParseVCard(const nsAutoCString& aCurrLine);
void ParseEnvelope(const nsAutoCString& aCurrLine);
void ParseRecipient(const nsAutoCString& aCurrLine);
void ParseBody(const nsAutoCString& aCurrLine);
void ParseBMsg(const nsAutoCString& aCurrLine);
/* Indicate whether a message has been read by MCE or not.
* MCE shall be responsible to set this status.
*/
bool mReadStatus;
// Indicate bMessage location
nsCString mFolderName;
/* Part-ID is used when the content cannot be delivered in ones
* bmessage-content object.
* The first bmessage-content object's part-ID shall be 0, and the following
* ones have part-ID incremented by 1 each.
*/
int mPartId;
// The encoding used by bmessage-body-content if the content is binary
nsCString mEncoding;
/* The character-set is used in bmessage-body-content if the content
* is textual.
*/
nsCString mCharset;
// mLanguage may be used if the message includes textual content
nsCString mLanguage;
/* Length of the bmessage-body-content, starting with the "B" of the first
* occurrence of "BEGIN_BMSG" and ending with the <CRLF> of the last occurrence
* of "END:MSG"<CRLF>.
*/
nsCString mBMsgLength;
// mMessageBody represents bmessage-body-content
nsCString mBMsgBody;
// mType: EMAIL/SMS_GSM/SMS_CDMA/MMS
nsCString mType;
// Current parser state
enum BMsgParserState mState;
// Previous parser state
enum BMsgParserState mUnwindState;
/* Current level of bmessage-envelope. The maximum level of <bmessage-envelope>
* encapsulation shall be 3.
*/
int mEnvelopeLevel;
/* Based on the formal BNF definition of the bMessage format, originators
* and recipients may appear 0 or more times.
* |mOriginators| represents the original sender of the messages, and
* |mRecipients| represents the recipient of the message.
*/
nsTArray<nsRefPtr<VCard>> mOriginators;
nsTArray<nsRefPtr<VCard>> mRecipients;
};
END_BLUETOOTH_NAMESPACE
#endif //mozilla_dom_bluetooth_bluedroid_BluetoothMapBMessage_h

View File

@ -724,25 +724,23 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
case Map::AppParametersTagId::SubjectLength: {
uint8_t subLength = *((uint8_t *)buf);
// convert big endian to little endian
subLength = (subLength >> 8) | (subLength << 8);
BT_LOGR("msg subLength : %d", subLength);
AppendNamedValue(aValues, "subLength", subLength);
break;
}
case Map::AppParametersTagId::ParameterMask: {
// 4 bytes
uint32_t parameterMask = *((uint32_t *)buf);
// convert big endian to little endian
parameterMask = (parameterMask >> 8) | (parameterMask << 8);
/* Table 6.5, MAP 6.3.1. ParameterMask is Bit 16-31 Reserved for future
* use. The reserved bits shall be set to 0 by MCE and discarded by MSE.
* convert big endian to little endian
*/
uint32_t parameterMask = (buf[3] << 0) | (buf[2] << 8) |
(buf[1] << 16) | (buf[0] << 24);
BT_LOGR("msg parameterMask : %d", parameterMask);
AppendNamedValue(aValues, "parameterMask", parameterMask);
break;
}
case Map::AppParametersTagId::FilterMessageType: {
uint8_t filterMessageType = *((uint8_t *)buf);
// convert big endian to little endian
filterMessageType = (filterMessageType >> 8) | (filterMessageType << 8);
BT_LOGR("msg filterMessageType : %d", filterMessageType);
AppendNamedValue(aValues, "filterMessageType", filterMessageType);
break;
@ -761,8 +759,6 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
case Map::AppParametersTagId::FilterReadStatus: {
uint8_t filterReadStatus = *((uint8_t *)buf);
// convert big endian to little endian
filterReadStatus = (filterReadStatus >> 8) | (filterReadStatus << 8);
BT_LOGR("msg filter read status : %d", filterReadStatus);
AppendNamedValue(aValues, "filterReadStatus", filterReadStatus);
break;
@ -781,32 +777,24 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
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;
}
case Map::AppParametersTagId::StatusIndicator: {
uint8_t statusIndicator = *((uint8_t *)buf);
// convert big endian to little endian
statusIndicator = (statusIndicator >> 8) | (statusIndicator << 8);
BT_LOGR("msg filter statusIndicator: %d", statusIndicator);
AppendNamedValue(aValues, "statusIndicator",
static_cast<uint32_t>(statusIndicator));
@ -814,8 +802,6 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
case Map::AppParametersTagId::StatusValue: {
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));
@ -823,8 +809,6 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
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));
@ -832,8 +816,6 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId(
}
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;
@ -1007,6 +989,12 @@ BluetoothMapSmsManager::HandleSmsMmsPushMessage(const ObexHeaderSet& aHeader)
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
if (!aHeader.Has(ObexHeaderId::Body) &&
!aHeader.Has(ObexHeaderId::EndOfBody)) {
BT_LOGR("Error! Fail to find Body/EndOfBody. Ignore this push request");
return;
}
InfallibleTArray<BluetoothNamedValue> data;
nsString name;
aHeader.GetName(name);
@ -1015,8 +1003,47 @@ BluetoothMapSmsManager::HandleSmsMmsPushMessage(const ObexHeaderSet& aHeader)
AppendBtNamedValueByTagId(aHeader, data,
Map::AppParametersTagId::Transparent);
AppendBtNamedValueByTagId(aHeader, data, Map::AppParametersTagId::Retry);
/* TODO: Support native format charset (mandatory format).
*
* Charset indicates Gaia application how to deal with encoding.
* - Native: If the message object shall be delivered without trans-coding.
* - UTF-8: If the message text shall be trans-coded to UTF-8.
*
* We only support UTF-8 charset due to current SMS API limitation.
*/
AppendBtNamedValueByTagId(aHeader, data, Map::AppParametersTagId::Charset);
// Get Body
uint8_t* bodyPtr = nullptr;
aHeader.GetBody(&bodyPtr, &mBodySegmentLength);
mBodySegment = bodyPtr;
nsRefPtr<BluetoothMapBMessage> bmsg =
new BluetoothMapBMessage(bodyPtr, mBodySegmentLength);
/* If FolderName is outbox:
* 1. Parse body to get SMS
* 2. Get receipent subject
* 3. Send it to Gaia
* Otherwise reply HTTP_NOT_ACCEPTABLE
*/
nsCString subject;
bmsg->GetBody(subject);
// It's possible that subject is empty, send it anyway
AppendNamedValue(data, "subject", subject);
nsTArray<nsRefPtr<VCard>> recipients;
bmsg->GetRecipients(recipients);
// Get the topmost level, only one recipient for SMS case
if (!recipients.IsEmpty()) {
nsCString recipient;
recipients[0]->GetTelephone(recipient);
AppendNamedValue(data, "recipient", recipient);
}
bs->DistributeSignal(NS_LITERAL_STRING(MAP_PUSH_MESSAGE_REQ_ID),
NS_LITERAL_STRING(KEY_ADAPTER), data);
}

View File

@ -8,6 +8,7 @@
#define mozilla_dom_bluetooth_bluedroid_BluetoothMapSmsManager_h
#include "BluetoothCommon.h"
#include "BluetoothMapBMessage.h"
#include "BluetoothMapFolder.h"
#include "BluetoothProfileManagerBase.h"
#include "BluetoothSocketObserver.h"
@ -150,6 +151,9 @@ private:
// Message notification service client socket
nsRefPtr<BluetoothSocket> mMnsSocket;
int mBodySegmentLength;
nsAutoArrayPtr<uint8_t> mBodySegment;
};
END_BLUETOOTH_NAMESPACE

View File

@ -84,6 +84,7 @@ if CONFIG['MOZ_B2G_BT']:
'bluedroid/BluetoothDaemonSetupInterface.cpp',
'bluedroid/BluetoothDaemonSocketInterface.cpp',
'bluedroid/BluetoothGattManager.cpp',
'bluedroid/BluetoothMapBMessage.cpp',
'bluedroid/BluetoothMapFolder.cpp',
'bluedroid/BluetoothMapSmsManager.cpp',
'bluedroid/BluetoothOppManager.cpp',