From 8cb7ad155e7de28f0d7ca155a2e7d0a7c3c5175c Mon Sep 17 00:00:00 2001 From: Shawn Huang Date: Fri, 9 Oct 2015 18:23:20 +0800 Subject: [PATCH] Bug 1184017 - [MAP] Dispatch events to MAP event handlers, r=btian, sr=mrbkap --- dom/base/nsGkAtomList.h | 6 + dom/bindings/Bindings.conf | 4 + .../bluedroid/BluetoothMapSmsManager.cpp | 89 +++++-- dom/bluetooth/common/BluetoothCommon.h | 2 + .../common/webapi/BluetoothAdapter.cpp | 251 ++++++++++++++++++ .../common/webapi/BluetoothAdapter.h | 85 ++++++ .../webapi/BluetoothMapRequestHandle.cpp | 109 ++++++++ .../common/webapi/BluetoothMapRequestHandle.h | 117 ++++++++ .../webapi/BluetoothPbapRequestHandle.h | 2 +- dom/bluetooth/moz.build | 2 + .../test/test_all_synthetic_events.html | 24 ++ .../mochitest/general/test_interfaces.html | 14 + dom/webidl/BluetoothAdapter.webidl | 18 ++ .../BluetoothMapFolderListingEvent.webidl | 24 ++ dom/webidl/BluetoothMapGetMessageEvent.webidl | 24 ++ .../BluetoothMapMessageUpdateEvent.webidl | 22 ++ .../BluetoothMapMessagesListingEvent.webidl | 43 +++ dom/webidl/BluetoothMapParameters.webidl | 62 +++++ dom/webidl/BluetoothMapRequestHandle.webidl | 55 ++++ .../BluetoothMapSendMessageEvent.webidl | 26 ++ .../BluetoothMapSetMessageStatusEvent.webidl | 26 ++ dom/webidl/moz.build | 8 + 22 files changed, 993 insertions(+), 20 deletions(-) create mode 100644 dom/bluetooth/common/webapi/BluetoothMapRequestHandle.cpp create mode 100644 dom/bluetooth/common/webapi/BluetoothMapRequestHandle.h create mode 100644 dom/webidl/BluetoothMapFolderListingEvent.webidl create mode 100644 dom/webidl/BluetoothMapGetMessageEvent.webidl create mode 100644 dom/webidl/BluetoothMapMessageUpdateEvent.webidl create mode 100644 dom/webidl/BluetoothMapMessagesListingEvent.webidl create mode 100644 dom/webidl/BluetoothMapParameters.webidl create mode 100644 dom/webidl/BluetoothMapRequestHandle.webidl create mode 100644 dom/webidl/BluetoothMapSendMessageEvent.webidl create mode 100644 dom/webidl/BluetoothMapSetMessageStatusEvent.webidl diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index bb70d58f1012..9753b0893558 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -832,6 +832,12 @@ GK_ATOM(onMozMousePixelScroll, "onMozMousePixelScroll") GK_ATOM(onMozScrolledAreaChanged, "onMozScrolledAreaChanged") GK_ATOM(onmoznetworkupload, "onmoznetworkupload") GK_ATOM(onmoznetworkdownload, "onmoznetworkdownload") +GK_ATOM(onmapfolderlistingreq, "onmapfolderlistingreq") +GK_ATOM(onmapmessageslistingreq, "onmapmessageslistingreq") +GK_ATOM(onmapgetmessagereq, "onmapgetmessagereq") +GK_ATOM(onmapsetmessagestatusreq, "onmapsetmessagestatusreq") +GK_ATOM(onmapsendmessagereq, "onmapsendmessagereq") +GK_ATOM(onmapmessageupdatereq, "onmapmessageupdatereq") GK_ATOM(onnewrdsgroup, "onnewrdsgroup") GK_ATOM(onnotificationclick, "onnotificationclick") GK_ATOM(onnoupdate, "onnoupdate") diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index e7a02d786a9b..f79de248864d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -207,6 +207,10 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::bluetooth::BluetoothPbapRequestHandle', }, +'BluetoothMapRequestHandle': { + 'nativeType': 'mozilla::dom::bluetooth::BluetoothMapRequestHandle', +}, + 'BoxObject': { 'resultNotAddRefed': ['element'], }, diff --git a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp index 8db889213a69..f8ff74c9a34e 100644 --- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp @@ -13,6 +13,7 @@ #include "BluetoothUuid.h" #include "ObexBase.h" +#include "mozilla/dom/BluetoothMapParametersBinding.h" #include "mozilla/RefPtr.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" @@ -20,6 +21,11 @@ #include "nsIObserver.h" #include "nsIObserverService.h" +#define FILTER_NO_SMS_GSM 0x01 +#define FILTER_NO_SMS_CDMA 0x02 +#define FILTER_NO_EMAIL 0x04 +#define FILTER_NO_MMS 0x08 + USING_BLUETOOTH_NAMESPACE using namespace mozilla; using namespace mozilla::dom; @@ -711,7 +717,8 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId( // convert big endian to little endian maxListCount = (maxListCount >> 8) | (maxListCount << 8); BT_LOGR("max list count: %d", maxListCount); - AppendNamedValue(aValues, "maxListCount", maxListCount); + AppendNamedValue(aValues, "maxListCount", + static_cast(maxListCount)); break; } case Map::AppParametersTagId::StartOffset: { @@ -719,13 +726,14 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId( // convert big endian to little endian startOffset = (startOffset >> 8) | (startOffset << 8); BT_LOGR("start offset : %d", startOffset); - AppendNamedValue(aValues, "startOffset", startOffset); + AppendNamedValue(aValues, "startOffset", + static_cast(startOffset)); break; } case Map::AppParametersTagId::SubjectLength: { uint8_t subLength = *((uint8_t *)buf); BT_LOGR("msg subLength : %d", subLength); - AppendNamedValue(aValues, "subLength", subLength); + AppendNamedValue(aValues, "subLength", static_cast(subLength)); break; } case Map::AppParametersTagId::ParameterMask: { @@ -740,43 +748,81 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId( break; } case Map::AppParametersTagId::FilterMessageType: { - uint8_t filterMessageType = *((uint8_t *)buf); + /* Follow MAP 1.2, 6.3.1 + * 0000xxx1 = "SMS_GSM" + * 0000xx1x = "SMS_CDMA" + * 0000x1xx = "EMAIL" + * 00001xxx = "MMS" + * Where + * 0 = "no filtering, get this type" + * 1 = "filter out this type" + */ + uint32_t filterMessageType = *((uint8_t *)buf); + + if (filterMessageType == (FILTER_NO_EMAIL | FILTER_NO_MMS | + FILTER_NO_SMS_GSM) || + filterMessageType == (FILTER_NO_EMAIL | FILTER_NO_MMS | + FILTER_NO_SMS_CDMA)) { + filterMessageType = static_cast(MessageType::Sms); + } else if (filterMessageType == (FILTER_NO_EMAIL | FILTER_NO_SMS_GSM | + FILTER_NO_SMS_CDMA)) { + filterMessageType = static_cast(MessageType::Mms); + } else if (filterMessageType == (FILTER_NO_MMS | FILTER_NO_SMS_GSM | + FILTER_NO_SMS_CDMA)) { + filterMessageType = static_cast(MessageType::Email); + } else { + BT_LOGR("Unsupportted filter message type"); + filterMessageType = static_cast(MessageType::Sms); + } + BT_LOGR("msg filterMessageType : %d", filterMessageType); - AppendNamedValue(aValues, "filterMessageType", filterMessageType); + AppendNamedValue(aValues, "filterMessageType", + static_cast(filterMessageType)); break; } case Map::AppParametersTagId::FilterPeriodBegin: { nsCString filterPeriodBegin((char *) buf); BT_LOGR("msg FilterPeriodBegin : %s", filterPeriodBegin.get()); - AppendNamedValue(aValues, "filterPeriodBegin", filterPeriodBegin); + AppendNamedValue(aValues, "filterPeriodBegin", + NS_ConvertUTF8toUTF16(filterPeriodBegin)); break; } case Map::AppParametersTagId::FilterPeriodEnd: { nsCString filterPeriodEnd((char*)buf); BT_LOGR("msg filterPeriodEnd : %s", filterPeriodEnd.get()); - AppendNamedValue(aValues, "filterPeriodEnd", filterPeriodEnd); + AppendNamedValue(aValues, "filterPeriodEnd", + NS_ConvertUTF8toUTF16(filterPeriodEnd)); break; } case Map::AppParametersTagId::FilterReadStatus: { - uint8_t filterReadStatus = *((uint8_t *)buf); + using namespace mozilla::dom::ReadStatusValues; + uint32_t filterReadStatus = + buf[0] < ArrayLength(strings) ? static_cast(buf[0]) : 0; BT_LOGR("msg filter read status : %d", filterReadStatus); AppendNamedValue(aValues, "filterReadStatus", filterReadStatus); break; } case Map::AppParametersTagId::FilterRecipient: { + // FilterRecipient encodes as UTF-8 nsCString filterRecipient((char*) buf); BT_LOGR("msg filterRecipient : %s", filterRecipient.get()); - AppendNamedValue(aValues, "filterRecipient", filterRecipient); + AppendNamedValue(aValues, "filterRecipient", + NS_ConvertUTF8toUTF16(filterRecipient)); break; } case Map::AppParametersTagId::FilterOriginator: { + // FilterOriginator encodes as UTF-8 nsCString filterOriginator((char*) buf); BT_LOGR("msg filter Originator : %s", filterOriginator.get()); - AppendNamedValue(aValues, "filterOriginator", filterOriginator); + AppendNamedValue(aValues, "filterOriginator", + NS_ConvertUTF8toUTF16(filterOriginator)); break; } case Map::AppParametersTagId::FilterPriority: { - uint8_t filterPriority = *((uint8_t *)buf); + using namespace mozilla::dom::PriorityValues; + uint32_t filterPriority = + buf[0] < ArrayLength(strings) ? static_cast(buf[0]) : 0; + BT_LOGR("msg filter priority: %d", filterPriority); AppendNamedValue(aValues, "filterPriority", filterPriority); break; @@ -784,20 +830,25 @@ BluetoothMapSmsManager::AppendBtNamedValueByTagId( case Map::AppParametersTagId::Attachment: { uint8_t attachment = *((uint8_t *)buf); BT_LOGR("msg filter attachment: %d", attachment); - AppendNamedValue(aValues, "attachment", attachment); + AppendNamedValue(aValues, "attachment", static_cast(attachment)); break; } case Map::AppParametersTagId::Charset: { - uint8_t charset = *((uint8_t *)buf); - BT_LOGR("msg filter charset: %d", charset); - AppendNamedValue(aValues, "charset", charset); + using namespace mozilla::dom::FilterCharsetValues; + uint32_t filterCharset = + buf[0] < ArrayLength(strings) ? static_cast(buf[0]) : 0; + + BT_LOGR("msg filter charset: %d", filterCharset); + AppendNamedValue(aValues, "charset", filterCharset); break; } case Map::AppParametersTagId::StatusIndicator: { - uint8_t statusIndicator = *((uint8_t *)buf); - BT_LOGR("msg filter statusIndicator: %d", statusIndicator); - AppendNamedValue(aValues, "statusIndicator", - static_cast(statusIndicator)); + using namespace mozilla::dom::StatusIndicatorsValues; + uint32_t filterStatusIndicator = + buf[0] < ArrayLength(strings) ? static_cast(buf[0]) : 0; + + BT_LOGR("msg filter statusIndicator: %d", filterStatusIndicator); + AppendNamedValue(aValues, "statusIndicator", filterStatusIndicator); break; } case Map::AppParametersTagId::StatusValue: { diff --git a/dom/bluetooth/common/BluetoothCommon.h b/dom/bluetooth/common/BluetoothCommon.h index ac0852268e5b..714eb8977f65 100644 --- a/dom/bluetooth/common/BluetoothCommon.h +++ b/dom/bluetooth/common/BluetoothCommon.h @@ -255,6 +255,8 @@ extern bool gBluetoothDebugFlag; #define MAP_GET_MESSAGE_REQ_ID "mapgetmessagereq" #define MAP_SET_MESSAGE_STATUS_REQ_ID "mapsetmessagestatusreq" #define MAP_PUSH_MESSAGE_REQ_ID "mappushmessagereq" +#define MAP_FOLDER_LISTING_REQ_ID "mapfolderlistingreq" +#define MAP_MESSAGE_UPDATE_REQ_ID "mapmessageupdatereq" /** * When the value of a characteristic of a remote BLE device changes, we'll diff --git a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp index c7014772f6a2..3ada58fd9dc6 100644 --- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp +++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp @@ -16,6 +16,13 @@ #include "mozilla/dom/BluetoothAdapterBinding.h" #include "mozilla/dom/BluetoothAttributeEvent.h" +#include "mozilla/dom/BluetoothMapFolderListingEvent.h" +#include "mozilla/dom/BluetoothMapGetMessageEvent.h" +#include "mozilla/dom/BluetoothMapMessagesListingEvent.h" +#include "mozilla/dom/BluetoothMapMessageUpdateEvent.h" +#include "mozilla/dom/BluetoothMapSetMessageStatusEvent.h" +#include "mozilla/dom/BluetoothMapSendMessageEvent.h" + #include "mozilla/dom/BluetoothPhonebookPullingEvent.h" #include "mozilla/dom/BluetoothStatusChangedEvent.h" #include "mozilla/dom/BluetoothVCardListingEvent.h" @@ -534,6 +541,18 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData) HandlePullVCardEntryReq(aData.value()); } else if (aData.name().EqualsLiteral(PULL_VCARD_LISTING_REQ_ID)) { HandlePullVCardListingReq(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_MESSAGES_LISTING_REQ_ID)) { + HandleMapMessagesListing(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_FOLDER_LISTING_REQ_ID)) { + HandleMapFolderListing(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_GET_MESSAGE_REQ_ID)) { + HandleMapGetMessage(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_SET_MESSAGE_STATUS_REQ_ID)) { + HandleMapSetMessageStatus(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_PUSH_MESSAGE_REQ_ID)) { + HandleMapSendMessage(aData.value()); + } else if (aData.name().EqualsLiteral(MAP_MESSAGE_UPDATE_REQ_ID)) { + HandleMapMessageUpdate(aData.value()); } else { BT_WARNING("Not handling adapter signal: %s", NS_ConvertUTF16toUTF8(aData.name()).get()); @@ -1338,6 +1357,238 @@ BluetoothAdapter::getVCardProperties(const BluetoothValue &aValue) return propSelector; } +Sequence +BluetoothAdapter::GetParameterMask(const BluetoothValue &aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfuint32_t); + + Sequence parameterMask; + + const InfallibleTArray& parameterMaskArr = + aValue.get_ArrayOfuint32_t(); + for (uint32_t i = 0; i < parameterMaskArr.Length(); ++i) { + parameterMask.AppendElement( + static_cast(parameterMaskArr[i]), mozilla::fallible); + } + + return parameterMask; +} + +void +BluetoothAdapter::HandleMapFolderListing(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::Tuint32_t); + + BluetoothMapFolderListingEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("maxListCount")) { + init.mMaxListCount = value.get_uint32_t(); + } else if (name.EqualsLiteral("startOffset")) { + init.mListStartOffset = value.get_uint32_t(); + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapFolderListingEvent::Constructor(this, + NS_LITERAL_STRING(MAP_FOLDER_LISTING_REQ_ID), init); + DispatchTrustedEvent(event); +} + +void +BluetoothAdapter::HandleMapMessagesListing(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::Tuint32_t); + + BluetoothMapMessagesListingEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("maxListCount")) { + init.mMaxListCount = value.get_uint32_t(); + } else if (name.EqualsLiteral("startOffset")) { + init.mListStartOffset = value.get_uint32_t(); + } else if (name.EqualsLiteral("subLength")) { + init.mSubjectLength = value.get_uint32_t(); + } else if (name.EqualsLiteral("parameterMask")) { + init.mParameterMask = GetParameterMask(value); + } else if (name.EqualsLiteral("filterMessageType")) { + init.mFilterMessageType = static_cast(value.get_uint32_t()); + } else if (name.EqualsLiteral("filterPeriodBegin")) { + init.mFilterPeriodBegin = value.get_nsString(); + } else if (name.EqualsLiteral("filterPeriodEnd")) { + init.mFilterPeriodEnd = value.get_nsString(); + } else if (name.EqualsLiteral("filterReadStatus")) { + init.mFilterReadStatus = static_cast(value.get_uint32_t()); + } else if (name.EqualsLiteral("filterRecipient")) { + init.mFilterRecipient = value.get_nsString(); + } else if (name.EqualsLiteral("filterOriginator")) { + init.mFilterOriginator = value.get_nsString(); + } else if (name.EqualsLiteral("filterPriority")) { + init.mFilterPriority = static_cast(value.get_uint32_t()); + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapMessagesListingEvent::Constructor(this, + NS_LITERAL_STRING(MAP_MESSAGES_LISTING_REQ_ID), init); + DispatchTrustedEvent(event); +} + +void +BluetoothAdapter::HandleMapGetMessage(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::Tbool); + + BluetoothMapGetMessageEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("hasAttachment")) { + init.mHasAttachment = value.get_bool(); + } else if (name.EqualsLiteral("charset")) { + if (value.get_uint32_t() == 0) { + init.mCharset = FilterCharset::Native; + } else { + init.mCharset = FilterCharset::Utf_8; + } + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapGetMessageEvent::Constructor(this, + NS_LITERAL_STRING(MAP_GET_MESSAGE_REQ_ID), init); + DispatchTrustedEvent(event); +} + +void +BluetoothAdapter::HandleMapSetMessageStatus(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::Tuint32_t); + + BluetoothMapSetMessageStatusEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("handleId")) { + init.mHandleId = value.get_uint32_t(); + } else if (name.EqualsLiteral("statusIndicator")) { + if (value.get_uint32_t()) { + init.mStatusIndicator = StatusIndicators::Deletedstatus; + } else { + init.mStatusIndicator = StatusIndicators::Readstatus; + } + } else if (name.EqualsLiteral("statusValue")) { + init.mStatusValue = static_cast(value.get_uint32_t()); + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapSetMessageStatusEvent::Constructor(this, + NS_LITERAL_STRING(MAP_SET_MESSAGE_STATUS_REQ_ID), init); + DispatchTrustedEvent(event); +} + +void +BluetoothAdapter::HandleMapSendMessage(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::TnsString); + + BluetoothMapSendMessageEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("recipient")) { + init.mRecipient = value.get_nsString(); + } else if (name.EqualsLiteral("messageBody")) { + init.mMessageBody = value.get_nsString(); + } else if (name.EqualsLiteral("retry")) { + init.mRetry = value.get_uint32_t(); + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapSendMessageEvent::Constructor(this, + NS_LITERAL_STRING(MAP_PUSH_MESSAGE_REQ_ID), init); + DispatchTrustedEvent(event); +} + +void +BluetoothAdapter::HandleMapMessageUpdate(const BluetoothValue& aValue) +{ + MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); + + const InfallibleTArray& arr = + aValue.get_ArrayOfBluetoothNamedValue(); + + MOZ_ASSERT(arr.Length() >= 1 && + arr[0].value().type() == BluetoothValue::TnsString); + + BluetoothMapMessageUpdateEventInit init; + + for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) { + const nsString& name = arr[i].name(); + const BluetoothValue& value = arr[i].value(); + if (name.EqualsLiteral("instanceId")) { + init.mInstanceId = value.get_uint32_t(); + } + } + + init.mHandle = BluetoothMapRequestHandle::Create(GetOwner()); + + nsRefPtr event = + BluetoothMapMessageUpdateEvent::Constructor(this, + NS_LITERAL_STRING(MAP_MESSAGE_UPDATE_REQ_ID), init); + DispatchTrustedEvent(event); +} + + void BluetoothAdapter::DispatchAttributeEvent(const Sequence& aTypes) { diff --git a/dom/bluetooth/common/webapi/BluetoothAdapter.h b/dom/bluetooth/common/webapi/BluetoothAdapter.h index 9fdb633fdd12..7df52de4fee6 100644 --- a/dom/bluetooth/common/webapi/BluetoothAdapter.h +++ b/dom/bluetooth/common/webapi/BluetoothAdapter.h @@ -12,6 +12,7 @@ #include "mozilla/DOMEventTargetHelper.h" #include "mozilla/dom/BluetoothAdapterBinding.h" #include "mozilla/dom/BluetoothDeviceEvent.h" +#include "mozilla/dom/BluetoothMapParametersBinding.h" #include "mozilla/dom/BluetoothPbapParametersBinding.h" #include "mozilla/dom/Promise.h" #include "nsCOMPtr.h" @@ -95,6 +96,12 @@ public: IMPL_EVENT_HANDLER(pullvcardlistingreq); IMPL_EVENT_HANDLER(requestmediaplaystatus); IMPL_EVENT_HANDLER(scostatuschanged); + IMPL_EVENT_HANDLER(mapfolderlistingreq); + IMPL_EVENT_HANDLER(mapmessageslistingreq); + IMPL_EVENT_HANDLER(mapgetmessagereq); + IMPL_EVENT_HANDLER(mapsetmessagestatusreq); + IMPL_EVENT_HANDLER(mapsendmessagereq); + IMPL_EVENT_HANDLER(mapmessageupdatereq); /**************************************************************************** * Methods (Web API Implementation) @@ -342,6 +349,84 @@ private: */ Sequence getVCardProperties(const BluetoothValue &aValue); + /** + * Handle "MapFolderListing" bluetooth signal. + * + * @param aValue [in] Properties array of the MAP request. + * The array should contain a few properties: + * - uint32_t 'MaxListCount' + * - uint32_t 'ListStartOffset' + */ + void HandleMapFolderListing(const BluetoothValue& aValue); + + /** + * Handle "MapMessageListing" bluetooth signal. + * + * @param aValue [in] Properties array of the MAP request. + * The array should contain a few properties: + * - uint32_t 'MaxListCount' + * - uint32_t 'ListStartOffset' + * - uint32_t 'SubjectLength' + * - uint32_t 'ParameterMask' + * - uint32_t 'FilterMessageType' + * - nsString 'FilterPeriodBegin' + * - nsString 'FilterPeriodEnd' + * - uint32_t 'FilterReadStatus' + * - nsString 'FilterRecipient' + * - nsString 'FilterOriginator' + * - uint32_t 'FilterPriority' + */ + void HandleMapMessagesListing(const BluetoothValue& aValue); + + /** + * Handle "MapGetMessage" bluetooth signal. + * + * @param aValue [in] Properties array of the MAP request. + * The array should contain a few properties: + * - bool 'Attachment' + * - nsString 'Charset' + */ + void HandleMapGetMessage(const BluetoothValue& aValue); + + /** + * Handle "MapSetMessageStatus" bluetooth signal. + * + * @param aValue [in] Properties array of the scanned device. + * The array should contain a few properties: + * - long 'HandleId' + * - uint32_t 'StatusIndicator' + * - bool 'StatusValue' + */ + void HandleMapSetMessageStatus(const BluetoothValue& aValue); + + /** + * Handle "MapSendMessage" bluetooth signal. + * + * @param aValue [in] Properties array of the scanned device. + * The array should contain a few properties: + * - nsString 'Recipient' + * - nsString 'MessageBody' + * - uint32_t 'Retry' + */ + void HandleMapSendMessage(const BluetoothValue& aValue); + + /** + * Handle "MapMessageUpdate" bluetooth signal. + * + * @param aValue [in] Properties array of the scanned device. + * - nsString 'MASInstanceID' + */ + void HandleMapMessageUpdate(const BluetoothValue& aValue); + + /** + * Get a Sequence of ParameterMask from a BluetoothValue. The name of + * BluetoothValue must be parameterMask. + * + * @param aValue [in] a BluetoothValue with 'TArrayOfuint32_t' type + * The name of BluetoothValue must be 'parameterMask'. + */ + Sequence GetParameterMask(const BluetoothValue &aValue); + /** * Fire BluetoothAttributeEvent to trigger onattributechanged event handler. * diff --git a/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.cpp b/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.cpp new file mode 100644 index 000000000000..04f5e50277df --- /dev/null +++ b/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.cpp @@ -0,0 +1,109 @@ +/* -*- 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/. */ + +#include "BluetoothCommon.h" +#include "BluetoothMapRequestHandle.h" +#include "BluetoothReplyRunnable.h" +#include "BluetoothService.h" + +#include "mozilla/dom/BluetoothMapRequestHandleBinding.h" +#include "mozilla/dom/Promise.h" + +using namespace mozilla; +using namespace dom; + +USING_BLUETOOTH_NAMESPACE + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BluetoothMapRequestHandle, mOwner) +NS_IMPL_CYCLE_COLLECTING_ADDREF(BluetoothMapRequestHandle) +NS_IMPL_CYCLE_COLLECTING_RELEASE(BluetoothMapRequestHandle) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BluetoothMapRequestHandle) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +BluetoothMapRequestHandle::BluetoothMapRequestHandle(nsPIDOMWindow* aOwner) + : mOwner(aOwner) +{ + MOZ_ASSERT(aOwner); +} + +BluetoothMapRequestHandle::~BluetoothMapRequestHandle() +{ +} + +already_AddRefed +BluetoothMapRequestHandle::Create(nsPIDOMWindow* aOwner) +{ + MOZ_ASSERT(aOwner); + + nsRefPtr handle = + new BluetoothMapRequestHandle(aOwner); + + return handle.forget(); +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToFolderListing(long aMasId, + const nsAString& aFolderlists, ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToMessagesListing(long aMasId, + Blob& aBlob, + bool aNewMessage, + const nsAString& aTimestamp, + int aSize, + ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToGetMessage(long aMasId, Blob& aBlob, + ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToSetMessageStatus(long aMasId, + bool aStatus, + ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToSendMessage(long aMasId, + bool aStatus, + ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +already_AddRefed +BluetoothMapRequestHandle::ReplyToMessageUpdate(long aMasId, + bool aStatus, + ErrorResult& aRv) +{ + // TODO: Implement this fuction in Bug 1208492 + return nullptr; +} + +JSObject* +BluetoothMapRequestHandle::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) +{ + return BluetoothMapRequestHandleBinding::Wrap(aCx, this, aGivenProto); +} diff --git a/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.h b/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.h new file mode 100644 index 000000000000..6347aaa00d66 --- /dev/null +++ b/dom/bluetooth/common/webapi/BluetoothMapRequestHandle.h @@ -0,0 +1,117 @@ +/* -*- 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_BluetoothMapRequestHandle_h +#define mozilla_dom_bluetooth_BluetoothMapRequestHandle_h + +#include "nsCOMPtr.h" +#include "nsPIDOMWindow.h" +#include "nsWrapperCache.h" +#include "mozilla/dom/File.h" + +namespace mozilla { + class ErrorResult; + namespace dom { + class Promise; + } +} + +BEGIN_BLUETOOTH_NAMESPACE + +class BluetoothMapRequestHandle final : public nsISupports + , public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BluetoothMapRequestHandle) + + static already_AddRefed + Create(nsPIDOMWindow* aOwner); + + nsPIDOMWindow* GetParentObject() const + { + return mOwner; + } + + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + /** + * Reply to folder listing + * + * @param aMasId [in] MAS ID. + * @param aFolderlists [in] MAP folder Name. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToFolderListing(long aMasId, + const nsAString& aFolderlists, ErrorResult& aRv); + + /** + * Reply to messages listing + * + * @param aMasId [in] MAS ID. + * @param aBlob [in] MAP messages listing content. + * @param aNewMessage [in] Whether MSE has received a new message. + * @param aTimestamp [in] The local time basis and UTC offset of the + * MSE. MCE will interpret the timestamps of The + * messages listing entries. + * @param aSize [in] The number of accessible messages in the + * corresponding folder fulfilling. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToMessagesListing( + long aMasId, Blob& aBlob, bool aNewMessage, const nsAString& aTimestamp, + int aSize, ErrorResult& aRv); + + /** + * Reply to get-message request + * + * @param aMasId [in] MAS ID. + * @param aBlob [in] MAP get messages content. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToGetMessage(long aMasId, Blob& aBlob, + ErrorResult& aRv); + + /** + * Reply to get-message request + * + * @param aMasId [in] MAS ID. + * @param aStatus [in] MAP set message result. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToSetMessageStatus(long aMasId, bool aStatus, + ErrorResult& aRv); + + /** + * Reply to get-message request + * + * @param aMasId [in] MAS ID. + * @param aStatus [in] MAP send message result. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToSendMessage(long aMasId, bool aStatus, + ErrorResult& aRv); + + /** + * Reply to message update request + * + * @param aMasId [in] MAS ID. + * @param aStatus [in] Update inbox results. + * @param aRv [out] Error result to set in case of error. + */ + already_AddRefed ReplyToMessageUpdate(long aMasId, bool aStatus, + ErrorResult& aRv); + +private: + BluetoothMapRequestHandle(nsPIDOMWindow* aOwner); + ~BluetoothMapRequestHandle(); + + nsCOMPtr mOwner; +}; + +END_BLUETOOTH_NAMESPACE + +#endif // mozilla_dom_bluetooth_BluetoothMapRequestHandle_h diff --git a/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.h b/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.h index b1d979f8db49..907705bf5769 100644 --- a/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.h +++ b/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.h @@ -59,4 +59,4 @@ private: END_BLUETOOTH_NAMESPACE -#endif // mozilla_dom_bluetooth_bluetoothpbaprequesthandle_h \ No newline at end of file +#endif // mozilla_dom_bluetooth_bluetoothpbaprequesthandle_h diff --git a/dom/bluetooth/moz.build b/dom/bluetooth/moz.build index cf3d6966382f..79260fd4d918 100644 --- a/dom/bluetooth/moz.build +++ b/dom/bluetooth/moz.build @@ -37,6 +37,7 @@ if CONFIG['MOZ_B2G_BT']: 'common/webapi/BluetoothGattService.cpp', 'common/webapi/BluetoothLeDeviceEvent.cpp', 'common/webapi/BluetoothManager.cpp', + 'common/webapi/BluetoothMapRequestHandle.cpp', 'common/webapi/BluetoothPairingHandle.cpp', 'common/webapi/BluetoothPairingListener.cpp', 'common/webapi/BluetoothPbapRequestHandle.cpp', @@ -152,6 +153,7 @@ EXPORTS.mozilla.dom.bluetooth += [ 'common/webapi/BluetoothGattService.h', 'common/webapi/BluetoothLeDeviceEvent.h', 'common/webapi/BluetoothManager.h', + 'common/webapi/BluetoothMapRequestHandle.h', 'common/webapi/BluetoothPairingHandle.h', 'common/webapi/BluetoothPairingListener.h', 'common/webapi/BluetoothPbapRequestHandle.h' diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html index 8496e73d2271..147a54c2a34f 100644 --- a/dom/events/test/test_all_synthetic_events.html +++ b/dom/events/test/test_all_synthetic_events.html @@ -80,6 +80,30 @@ const kEventConstructors = { return new BluetoothPairingEvent(aName, aProps); }, }, + BluetoothMapFolderListingEvent: { create: function (aName, aProps) { + return new BluetoothMapFolderListingEvent(aName, aProps); + }, + }, + BluetoothMapGetMessageEvent: { create: function (aName, aProps) { + return new BluetoothMapGetMessageEvent(aName, aProps); + }, + }, + BluetoothMapMessagesListingEvent: { create: function (aName, aProps) { + return new BluetoothMapMessagesListingEvent(aName, aProps); + }, + }, + BluetoothMapMessageUpdateEvent: { create: function (aName, aProps) { + return new BluetoothMapMessageUpdateEvent(aName, aProps); + }, + }, + BluetoothMapSendMessageEvent: { create: function (aName, aProps) { + return new BluetoothMapSendMessageEvent(aName, aProps); + }, + }, + BluetoothMapSetMessageStatusEvent: { create: function (aName, aProps) { + return new BluetoothMapSetMessageStatusEvent(aName, aProps); + }, + }, BluetoothPhonebookPullingEvent: { create: function (aName, aProps) { return new BluetoothPhonebookPullingEvent(aName, aProps); }, diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 84e8b790ba14..46495d1eb6bc 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -219,6 +219,20 @@ var interfaceNamesInGlobalScope = {name: "BluetoothLeDeviceEvent", b2g: true, permission: ["bluetooth"]}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "BluetoothManager", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapFolderListingEvent", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapGetMessageEvent", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapMessagesListingEvent", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapMessageUpdateEvent", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapRequestHandle", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapSendMessageEvent", b2g: true, permission: ["bluetooth"]}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "BluetoothMapSetMessageStatusEvent", b2g: true, permission: ["bluetooth"]}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "BluetoothPbapRequestHandle", b2g: true, permission: ["bluetooth"]}, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/BluetoothAdapter.webidl b/dom/webidl/BluetoothAdapter.webidl index a8a7b5da7fcb..22579775b735 100644 --- a/dom/webidl/BluetoothAdapter.webidl +++ b/dom/webidl/BluetoothAdapter.webidl @@ -78,6 +78,24 @@ interface BluetoothAdapter : EventTarget { // Fired when PBAP manager requests for 'pullvcardlisting' attribute EventHandler onpullvcardlistingreq; + // Fired when remote devices request to list SMS/MMS/Email folders + attribute EventHandler onmapfolderlistingreq; + + // Fired when remote devices request to list SMS/MMS/Email messages + attribute EventHandler onmapmessageslistingreq; + + // Fired when remote devices fetch the specific message + attribute EventHandler onmapgetmessagereq; + + // Fired when remote devices set message status + attribute EventHandler onmapsetmessagestatusreq; + + // Fired when remote devices send out SMS/MMS/Email message + attribute EventHandler onmapsendmessagereq; + + // Fired when remote devices download SMS/MMS/Email messages + attribute EventHandler onmapmessageupdatereq; + /** * Enable/Disable a local bluetooth adapter by asynchronus methods and return * its result through a Promise. diff --git a/dom/webidl/BluetoothMapFolderListingEvent.webidl b/dom/webidl/BluetoothMapFolderListingEvent.webidl new file mode 100644 index 000000000000..fa450d4ada93 --- /dev/null +++ b/dom/webidl/BluetoothMapFolderListingEvent.webidl @@ -0,0 +1,24 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapFolderListingEventInit eventInitDict)] +interface BluetoothMapFolderListingEvent : Event +{ + readonly attribute unsigned long maxListCount; + readonly attribute unsigned long listStartOffset; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapFolderListingEventInit : EventInit +{ + unsigned long maxListCount = 0; + unsigned long listStartOffset = 0; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/BluetoothMapGetMessageEvent.webidl b/dom/webidl/BluetoothMapGetMessageEvent.webidl new file mode 100644 index 000000000000..b02baaf8846d --- /dev/null +++ b/dom/webidl/BluetoothMapGetMessageEvent.webidl @@ -0,0 +1,24 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapGetMessageEventInit eventInitDict)] +interface BluetoothMapGetMessageEvent : Event +{ + readonly attribute boolean hasAttachment; + readonly attribute FilterCharset charset; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapGetMessageEventInit : EventInit +{ + boolean hasAttachment = false; + FilterCharset charset = "utf-8"; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/BluetoothMapMessageUpdateEvent.webidl b/dom/webidl/BluetoothMapMessageUpdateEvent.webidl new file mode 100644 index 000000000000..d848e04d76a9 --- /dev/null +++ b/dom/webidl/BluetoothMapMessageUpdateEvent.webidl @@ -0,0 +1,22 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapMessageUpdateEventInit eventInitDict)] +interface BluetoothMapMessageUpdateEvent : Event +{ + readonly attribute unsigned long instanceId; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapMessageUpdateEventInit : EventInit +{ + unsigned long instanceId = 0; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/BluetoothMapMessagesListingEvent.webidl b/dom/webidl/BluetoothMapMessagesListingEvent.webidl new file mode 100644 index 000000000000..98762d4bd97d --- /dev/null +++ b/dom/webidl/BluetoothMapMessagesListingEvent.webidl @@ -0,0 +1,43 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapMessagesListingEventInit eventInitDict)] +interface BluetoothMapMessagesListingEvent : Event +{ + readonly attribute unsigned long maxListCount; + readonly attribute unsigned long listStartOffset; + readonly attribute unsigned long subjectLength; + [Cached, Constant] + readonly attribute sequence parameterMask; + readonly attribute MessageType filterMessageType; + readonly attribute DOMString filterPeriodBegin; + readonly attribute DOMString filterPeriodEnd; + readonly attribute ReadStatus filterReadStatus; + readonly attribute DOMString filterRecipient; + readonly attribute DOMString filterOriginator; + readonly attribute Priority filterPriority; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapMessagesListingEventInit : EventInit +{ + unsigned long maxListCount = 0; + unsigned long listStartOffset = 0; + unsigned long subjectLength = 0; + sequence parameterMask = []; + MessageType filterMessageType = "no-filtering"; + DOMString filterPeriodBegin = ""; + DOMString filterPeriodEnd = ""; + ReadStatus filterReadStatus = "no-filtering"; + DOMString filterRecipient = ""; + DOMString filterOriginator = ""; + Priority filterPriority = "no-filtering"; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/BluetoothMapParameters.webidl b/dom/webidl/BluetoothMapParameters.webidl new file mode 100644 index 000000000000..837635d88076 --- /dev/null +++ b/dom/webidl/BluetoothMapParameters.webidl @@ -0,0 +1,62 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +/** + * MAP Application Parameters + */ +enum MessageType +{ + "no-filtering", + "sms", + "email", + "mms" +}; + +enum ReadStatus +{ + "no-filtering", + "unread", + "read" +}; + +enum Priority +{ + "no-filtering", + "high-priority", + "non-priority" +}; + +enum ParameterMask +{ + "subject", + "datetime", + "sender_name", + "sender_addressing", + "recipient_name", + "recipient_addressing", + "type", + "size", + "reception_status", + "text", + "attachment_size", + "priority", + "read", + "sent", + "protected", + "replyto_addressing", +}; + +enum FilterCharset +{ + "native", + "utf-8" +}; + +enum StatusIndicators +{ + "readstatus", + "deletedstatus" +}; diff --git a/dom/webidl/BluetoothMapRequestHandle.webidl b/dom/webidl/BluetoothMapRequestHandle.webidl new file mode 100644 index 000000000000..666487ad294c --- /dev/null +++ b/dom/webidl/BluetoothMapRequestHandle.webidl @@ -0,0 +1,55 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +[CheckAnyPermissions="bluetooth"] +interface BluetoothMapRequestHandle +{ + /** + * Reply to Folder-Listing object for MAP request. The Promise will be + * rejected if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToFolderListing(long masId, DOMString folders); + + /** + * Reply the Messages-Listing object to the MAP request. The Promise will + * be rejected if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToMessagesListing( + long masId, + Blob messageslisting, + boolean newmessage, + DOMString timestamp, + unsigned long size); + + /** + * Reply GetMessage object to the MAP request. The Promise will be rejected + * if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToGetMessage(long masId, Blob bmessage); + + /** + * Reply SetMessage object to the MAP request. The Promise will be rejected + * if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToSetMessageStatus(long masId, boolean status); + + /** + * Reply SendMessage request to the MAP request. The Promise will be rejected + * if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToSendMessage(long masId, boolean status); + + /** + * Reply Message-Update object to the MAP request. The Promise will be + * rejected if the MAP request operation fails. + */ + [NewObject, Throws, AvailableIn=CertifiedApps] + Promise replyToMessageUpdate(long masId, boolean status); +}; diff --git a/dom/webidl/BluetoothMapSendMessageEvent.webidl b/dom/webidl/BluetoothMapSendMessageEvent.webidl new file mode 100644 index 000000000000..b4970470d795 --- /dev/null +++ b/dom/webidl/BluetoothMapSendMessageEvent.webidl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapSendMessageEventInit eventInitDict)] +interface BluetoothMapSendMessageEvent : Event +{ + readonly attribute DOMString recipient; + readonly attribute DOMString messageBody; + readonly attribute unsigned long retry; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapSendMessageEventInit : EventInit +{ + DOMString recipient = ""; + DOMString messageBody = ""; + unsigned long retry = 0; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/BluetoothMapSetMessageStatusEvent.webidl b/dom/webidl/BluetoothMapSetMessageStatusEvent.webidl new file mode 100644 index 000000000000..b5ea966d615c --- /dev/null +++ b/dom/webidl/BluetoothMapSetMessageStatusEvent.webidl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[CheckAnyPermissions="bluetooth", + Constructor(DOMString type, + optional BluetoothMapSetMessageStatusEventInit eventInitDict)] +interface BluetoothMapSetMessageStatusEvent : Event +{ + readonly attribute unsigned long handleId; + readonly attribute StatusIndicators statusIndicator; + readonly attribute boolean statusValue; + + readonly attribute BluetoothMapRequestHandle? handle; +}; + +dictionary BluetoothMapSetMessageStatusEventInit : EventInit +{ + unsigned long handleId = 0; + StatusIndicators statusIndicator = "readstatus"; + boolean statusValue = false; + + BluetoothMapRequestHandle? handle = null; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 7e936a49ad03..70667cb5274e 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -694,6 +694,8 @@ if CONFIG['MOZ_B2G_BT']: 'BluetoothGattService.webidl', 'BluetoothLeDeviceEvent.webidl', 'BluetoothManager.webidl', + 'BluetoothMapParameters.webidl', + 'BluetoothMapRequestHandle.webidl', 'BluetoothPairingHandle.webidl', 'BluetoothPairingListener.webidl', 'BluetoothPbapParameters.webidl', @@ -846,6 +848,12 @@ if CONFIG['MOZ_B2G_BT']: 'BluetoothAttributeEvent.webidl', 'BluetoothDeviceEvent.webidl', 'BluetoothGattCharacteristicEvent.webidl', + 'BluetoothMapFolderListingEvent.webidl', + 'BluetoothMapGetMessageEvent.webidl', + 'BluetoothMapMessagesListingEvent.webidl', + 'BluetoothMapMessageUpdateEvent.webidl', + 'BluetoothMapSendMessageEvent.webidl', + 'BluetoothMapSetMessageStatusEvent.webidl', 'BluetoothPairingEvent.webidl', 'BluetoothPhonebookPullingEvent.webidl', 'BluetoothStatusChangedEvent.webidl',