зеркало из https://github.com/mozilla/gecko-dev.git
Bug 844431 - B2G MMS: provide nsIDOMMobileMessageManager interface (with sendMMS() first) (part 2, nsIDOMMozMmsMessage). r=vicamo,mounir,mrbkap sr=sicking a=leo+
This commit is contained in:
Родитель
24d0695b40
Коммит
cc115912d5
|
@ -338,6 +338,7 @@ using mozilla::dom::workers::ResolveWorkerClasses;
|
|||
#include "nsIDOMSmsManager.h"
|
||||
#include "nsIDOMMobileMessageManager.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMSmsRequest.h"
|
||||
#include "nsIDOMSmsFilter.h"
|
||||
#include "nsIDOMSmsCursor.h"
|
||||
|
@ -973,6 +974,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozSmsRequest, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
@ -2532,6 +2536,10 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozMmsMessage, nsIDOMMozMmsMessage)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozSmsRequest, nsIDOMMozSmsRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
|
|
|
@ -207,6 +207,7 @@ DOMCI_CLASS(MozWakeLock)
|
|||
DOMCI_CLASS(MozSmsManager)
|
||||
DOMCI_CLASS(MozMobileMessageManager)
|
||||
DOMCI_CLASS(MozSmsMessage)
|
||||
DOMCI_CLASS(MozMmsMessage)
|
||||
DOMCI_CLASS(MozSmsRequest)
|
||||
DOMCI_CLASS(MozSmsFilter)
|
||||
DOMCI_CLASS(MozSmsCursor)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMMobileMessageManager.idl',
|
||||
'nsIDOMMozMmsMessage.idl',
|
||||
'nsIDOMMozSmsEvent.idl',
|
||||
'nsIDOMMozSmsMessage.idl',
|
||||
'nsIDOMNavigatorMobileMessage.idl',
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* 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 "nsISupports.idl"
|
||||
|
||||
interface nsIDOMBlob;
|
||||
|
||||
dictionary MmsAttachment
|
||||
{
|
||||
DOMString? id;
|
||||
DOMString? location;
|
||||
nsIDOMBlob content;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(df002ad2-71d7-11e2-9f1c-af6fa139069f)]
|
||||
interface nsIDOMMozMmsMessage : nsISupports
|
||||
{
|
||||
readonly attribute long id;
|
||||
|
||||
/**
|
||||
* Should be "not-downloaded", "received", "sending", "sent" or "error".
|
||||
*/
|
||||
readonly attribute DOMString state;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval deliveryStatus; // DOMString[]
|
||||
|
||||
readonly attribute DOMString sender;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval receivers; // DOMString[]
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval timestamp; // Date
|
||||
|
||||
readonly attribute boolean read;
|
||||
readonly attribute DOMString subject;
|
||||
readonly attribute DOMString smil;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval attachments; // MmsAttachment[]
|
||||
};
|
|
@ -11,6 +11,10 @@ interface nsIDOMMozSmsMessage : nsISupports
|
|||
|
||||
/**
|
||||
* Should be "received", "sending", "sent" or "error".
|
||||
*
|
||||
* TODO Bug 850530 Please see the IDL proposal at Bug 760065.
|
||||
* We need to s/delivery/state in nsIDOMMozSmsMessage, which sounds
|
||||
* a better name and can be consistent with nsIDOMMozMmsMessage.
|
||||
*/
|
||||
readonly attribute DOMString delivery;
|
||||
|
||||
|
|
|
@ -18,10 +18,11 @@ extern const char* kSmsFailedObserverTopic;
|
|||
extern const char* kSmsDeliverySuccessObserverTopic;
|
||||
extern const char* kSmsDeliveryErrorObserverTopic;
|
||||
|
||||
#define DELIVERY_RECEIVED NS_LITERAL_STRING("received")
|
||||
#define DELIVERY_SENDING NS_LITERAL_STRING("sending")
|
||||
#define DELIVERY_SENT NS_LITERAL_STRING("sent")
|
||||
#define DELIVERY_ERROR NS_LITERAL_STRING("error")
|
||||
#define DELIVERY_RECEIVED NS_LITERAL_STRING("received")
|
||||
#define DELIVERY_SENDING NS_LITERAL_STRING("sending")
|
||||
#define DELIVERY_SENT NS_LITERAL_STRING("sent")
|
||||
#define DELIVERY_ERROR NS_LITERAL_STRING("error")
|
||||
#define DELIVERY_NOT_DOWNLOADED NS_LITERAL_STRING("not-downloaded")
|
||||
|
||||
#define DELIVERY_STATUS_NOT_APPLICABLE NS_LITERAL_STRING("not-applicable")
|
||||
#define DELIVERY_STATUS_SUCCESS NS_LITERAL_STRING("success")
|
||||
|
|
|
@ -38,6 +38,7 @@ EXPORTS_mozilla/dom = \
|
|||
SmsManager.h \
|
||||
MobileMessageManager.h \
|
||||
SmsMessage.h \
|
||||
MmsMessage.h \
|
||||
SmsRequest.h \
|
||||
SmsSegmentInfo.h \
|
||||
SmsFilter.h \
|
||||
|
@ -59,6 +60,7 @@ CPPSRCS = \
|
|||
SmsServicesFactory.cpp \
|
||||
SmsParent.cpp \
|
||||
SmsMessage.cpp \
|
||||
MmsMessage.cpp \
|
||||
Constants.cpp \
|
||||
SmsChild.cpp \
|
||||
SmsRequest.cpp \
|
||||
|
|
|
@ -0,0 +1,411 @@
|
|||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#include "MmsMessage.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
|
||||
#include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch
|
||||
#include "nsJSUtils.h"
|
||||
#include "Constants.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
|
||||
using namespace mozilla::idl;
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
|
||||
DOMCI_DATA(MozMmsMessage, mozilla::dom::MmsMessage)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MmsMessage)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMmsMessage)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMmsMessage)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(MmsMessage)
|
||||
NS_IMPL_RELEASE(MmsMessage)
|
||||
|
||||
MmsMessage::MmsMessage(int32_t aId,
|
||||
DeliveryState aState,
|
||||
const nsTArray<DeliveryStatus>& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<MmsAttachment>& aAttachments)
|
||||
: mId(aId),
|
||||
mState(aState),
|
||||
mDeliveryStatus(aDeliveryStatus),
|
||||
mSender(aSender),
|
||||
mReceivers(aReceivers),
|
||||
mTimestamp(aTimestamp),
|
||||
mRead(aRead),
|
||||
mSubject(aSubject),
|
||||
mSmil(aSmil),
|
||||
mAttachments(aAttachments)
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
MmsMessage::Create(int32_t aId,
|
||||
const nsAString& aState,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage)
|
||||
{
|
||||
*aMessage = nullptr;
|
||||
|
||||
// Set |state|.
|
||||
DeliveryState state;
|
||||
if (aState.Equals(DELIVERY_SENT)) {
|
||||
state = eDeliveryState_Sent;
|
||||
} else if (aState.Equals(DELIVERY_RECEIVED)) {
|
||||
state = eDeliveryState_Received;
|
||||
} else if (aState.Equals(DELIVERY_SENDING)) {
|
||||
state = eDeliveryState_Sending;
|
||||
} else if (aState.Equals(DELIVERY_NOT_DOWNLOADED)) {
|
||||
state = eDeliveryState_NotDownloaded;
|
||||
} else if (aState.Equals(DELIVERY_ERROR)) {
|
||||
state = eDeliveryState_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Set |deliveryStatus|.
|
||||
if (!aDeliveryStatus.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JSObject* deliveryStatusObj = &aDeliveryStatus.toObject();
|
||||
if (!JS_IsArrayObject(aCx, deliveryStatusObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryStatusObj, &length));
|
||||
|
||||
nsTArray<DeliveryStatus> deliveryStatus;
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Value statusJsVal;
|
||||
if (!JS_GetElement(aCx, deliveryStatusObj, i, &statusJsVal) ||
|
||||
!statusJsVal.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsDependentJSString statusStr;
|
||||
statusStr.init(aCx, statusJsVal.toString());
|
||||
|
||||
DeliveryStatus status;
|
||||
if (statusStr.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
status = eDeliveryStatus_NotApplicable;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
status = eDeliveryStatus_Success;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
status = eDeliveryStatus_Pending;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
status = eDeliveryStatus_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
deliveryStatus.AppendElement(status);
|
||||
}
|
||||
|
||||
// Set |receivers|.
|
||||
if (!aReceivers.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JSObject* receiversObj = &aReceivers.toObject();
|
||||
if (!JS_IsArrayObject(aCx, receiversObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
|
||||
|
||||
nsTArray<nsString> receivers;
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Value receiverJsVal;
|
||||
if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) ||
|
||||
!receiverJsVal.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsDependentJSString receiverStr;
|
||||
receiverStr.init(aCx, receiverJsVal.toString());
|
||||
receivers.AppendElement(receiverStr);
|
||||
}
|
||||
|
||||
// Set |timestamp|.
|
||||
uint64_t timestamp;
|
||||
if (aTimestamp.isObject()) {
|
||||
JSObject* timestampObj = &aTimestamp.toObject();
|
||||
if (!JS_ObjectIsDate(aCx, timestampObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
timestamp = js_DateGetMsecSinceEpoch(timestampObj);
|
||||
} else {
|
||||
if (!aTimestamp.isNumber()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
double number = aTimestamp.toNumber();
|
||||
if (static_cast<uint64_t>(number) != number) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
timestamp = static_cast<uint64_t>(number);
|
||||
}
|
||||
|
||||
// Set |attachments|.
|
||||
if (!aAttachments.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JSObject* attachmentsObj = &aAttachments.toObject();
|
||||
if (!JS_IsArrayObject(aCx, attachmentsObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsTArray<MmsAttachment> attachments;
|
||||
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Value attachmentJsVal;
|
||||
if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
MmsAttachment attachment;
|
||||
nsresult rv = attachment.Init(aCx, &attachmentJsVal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
attachments.AppendElement(attachment);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = new MmsMessage(aId,
|
||||
state,
|
||||
deliveryStatus,
|
||||
aSender,
|
||||
receivers,
|
||||
timestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
attachments);
|
||||
message.forget(aMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetId(int32_t* aId)
|
||||
{
|
||||
*aId = mId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetState(nsAString& aState)
|
||||
{
|
||||
switch (mState) {
|
||||
case eDeliveryState_Received:
|
||||
aState = DELIVERY_RECEIVED;
|
||||
break;
|
||||
case eDeliveryState_Sending:
|
||||
aState = DELIVERY_SENDING;
|
||||
break;
|
||||
case eDeliveryState_Sent:
|
||||
aState = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Error:
|
||||
aState = DELIVERY_ERROR;
|
||||
break;
|
||||
case eDeliveryState_NotDownloaded:
|
||||
aState = DELIVERY_NOT_DOWNLOADED;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
MOZ_NOT_REACHED("We shouldn't get any other delivery state!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetDeliveryStatus(JSContext* aCx, JS::Value* aDeliveryStatus)
|
||||
{
|
||||
// TODO Bug 850525 It would be better to depend on the state of MmsMessage
|
||||
// to return a more correct value. Ex, when .state = 'received', we should
|
||||
// also make .deliveryStatus = null, since the .deliveryStatus is useless.
|
||||
uint32_t length = mDeliveryStatus.Length();
|
||||
if (length == 0) {
|
||||
*aDeliveryStatus = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<nsString> tempStrArray;
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsString statusStr;
|
||||
switch (mDeliveryStatus[i]) {
|
||||
case eDeliveryStatus_NotApplicable:
|
||||
statusStr = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eDeliveryStatus_Success:
|
||||
statusStr = DELIVERY_STATUS_SUCCESS;
|
||||
break;
|
||||
case eDeliveryStatus_Pending:
|
||||
statusStr = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case eDeliveryStatus_Error:
|
||||
statusStr = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_NOT_REACHED("We shouldn't get any other delivery status!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
tempStrArray.AppendElement(statusStr);
|
||||
}
|
||||
|
||||
JSObject* deliveryStatusObj = nullptr;
|
||||
nsresult rv = nsTArrayToJSArray(aCx, tempStrArray, &deliveryStatusObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aDeliveryStatus->setObject(*deliveryStatusObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSender(nsAString& aSender)
|
||||
{
|
||||
aSender = mSender;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetReceivers(JSContext* aCx, JS::Value* aReceivers)
|
||||
{
|
||||
uint32_t length = mReceivers.Length();
|
||||
if (length == 0) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JSObject* reveiversObj = nullptr;
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &reveiversObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aReceivers->setObject(*reveiversObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
|
||||
{
|
||||
*aDate = OBJECT_TO_JSVAL(JS_NewDateObjectMsec(cx, mTimestamp));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetRead(bool* aRead)
|
||||
{
|
||||
*aRead = mRead;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSubject(nsAString& aSubject)
|
||||
{
|
||||
aSubject = mSubject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSmil(nsAString& aSmil)
|
||||
{
|
||||
aSmil = mSmil;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
|
||||
{
|
||||
// TODO Bug 850529 We should return an empty array (or null)
|
||||
// when it has no attachments? Need to further check this.
|
||||
uint32_t length = mAttachments.Length();
|
||||
if (length == 0) {
|
||||
*aAttachments = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject* attachments = JS_NewArrayObject(aCx, length, nullptr);
|
||||
NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
const MmsAttachment &attachment = mAttachments[i];
|
||||
|
||||
JSObject* attachmentObj = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||
NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Value tmpJsVal;
|
||||
JSString* tmpJsStr;
|
||||
|
||||
// Get |attachment.mId|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
attachment.id.get(),
|
||||
attachment.id.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
tmpJsVal.setString(tmpJsStr);
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "id", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |attachment.mLocation|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
attachment.location.get(),
|
||||
attachment.location.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
tmpJsVal.setString(tmpJsStr);
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "location", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |attachment.mContent|.
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx,
|
||||
JS_GetGlobalForScopeChain(aCx),
|
||||
attachment.content,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&tmpJsVal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "content", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
tmpJsVal = OBJECT_TO_JSVAL(attachmentObj);
|
||||
if (!JS_SetElement(aCx, attachments, i, &tmpJsVal)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
aAttachments->setObject(*attachments);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#ifndef mozilla_dom_mobilemessage_MmsMessage_h
|
||||
#define mozilla_dom_mobilemessage_MmsMessage_h
|
||||
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsString.h"
|
||||
#include "jspubtd.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "DictionaryHelpers.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MmsMessage MOZ_FINAL : public nsIDOMMozMmsMessage
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMMOZMMSMESSAGE
|
||||
|
||||
MmsMessage(int32_t aId,
|
||||
mobilemessage::DeliveryState aState,
|
||||
const nsTArray<mobilemessage::DeliveryStatus>& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<idl::MmsAttachment>& aAttachments);
|
||||
|
||||
static nsresult Create(int32_t aId,
|
||||
const nsAString& aState,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage);
|
||||
|
||||
private:
|
||||
|
||||
int32_t mId;
|
||||
mobilemessage::DeliveryState mState;
|
||||
nsTArray<mobilemessage::DeliveryStatus> mDeliveryStatus;
|
||||
nsString mSender;
|
||||
nsTArray<nsString> mReceivers;
|
||||
uint64_t mTimestamp;
|
||||
bool mRead;
|
||||
nsString mSubject;
|
||||
nsString mSmil;
|
||||
nsTArray<idl::MmsAttachment> mAttachments;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MmsMessage_h
|
|
@ -12,7 +12,7 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
// For SmsMessageData.delivery.
|
||||
// For MmsMessageData.state and SmsMessageData.deliveryState
|
||||
// Please keep the following files in sync with enum below:
|
||||
// embedding/android/GeckoSmsManager.java
|
||||
enum DeliveryState {
|
||||
|
@ -21,11 +21,12 @@ enum DeliveryState {
|
|||
eDeliveryState_Sending,
|
||||
eDeliveryState_Error,
|
||||
eDeliveryState_Unknown,
|
||||
eDeliveryState_NotDownloaded,
|
||||
// This state should stay at the end.
|
||||
eDeliveryState_EndGuard
|
||||
};
|
||||
|
||||
// For SmsMessageData.deliveryStatus.
|
||||
// For {Mms,Sms}MessageData.deliveryStatus.
|
||||
enum DeliveryStatus {
|
||||
eDeliveryStatus_NotApplicable = 0,
|
||||
eDeliveryStatus_Success,
|
||||
|
@ -35,7 +36,7 @@ enum DeliveryStatus {
|
|||
eDeliveryStatus_EndGuard
|
||||
};
|
||||
|
||||
// For SmsFilterData.read
|
||||
// For {Mms,Sms}FilterData.read.
|
||||
enum ReadState {
|
||||
eReadState_Unknown = -1,
|
||||
eReadState_Unread,
|
||||
|
@ -44,7 +45,7 @@ enum ReadState {
|
|||
eReadState_EndGuard
|
||||
};
|
||||
|
||||
// For SmsFilterData.messageClass
|
||||
// For {Mms,Sms}FilterData.messageClass.
|
||||
enum MessageClass {
|
||||
eMessageClass_Normal = 0,
|
||||
eMessageClass_Class0,
|
||||
|
|
|
@ -251,6 +251,7 @@ var interfaceNamesInGlobalScope =
|
|||
"SVGViewSpec",
|
||||
"DOMException",
|
||||
"MozSmsMessage",
|
||||
"MozMmsMessage",
|
||||
"SVGFESpecularLightingElement",
|
||||
"StorageObsolete",
|
||||
"ContactManager",
|
||||
|
|
|
@ -319,10 +319,13 @@ public class GeckoSmsManager
|
|||
* Keep the following state codes in syng with |DeliveryState| in:
|
||||
* dom/mobilemessage/src/Types.h
|
||||
*/
|
||||
private final static int kDeliveryStateSent = 0;
|
||||
private final static int kDeliveryStateReceived = 1;
|
||||
private final static int kDeliveryStateUnknown = 2;
|
||||
private final static int kDeliveryStateEndGuard = 3;
|
||||
private final static int kDeliveryStateSent = 0;
|
||||
private final static int kDeliveryStateReceived = 1;
|
||||
private final static int kDeliveryStateSending = 2;
|
||||
private final static int kDeliveryStateError = 3;
|
||||
private final static int kDeliveryStateUnknown = 4;
|
||||
private final static int kDeliveryStateNotDownloaded = 5;
|
||||
private final static int kDeliveryStateEndGuard = 6;
|
||||
|
||||
/*
|
||||
* Keep the following status codes in sync with |DeliveryStatus| in:
|
||||
|
|
|
@ -20,7 +20,8 @@ dictionaries = [
|
|||
[ 'CameraSelector', 'nsIDOMCameraManager.idl' ],
|
||||
[ 'CameraPictureOptions', 'nsIDOMCameraManager.idl' ],
|
||||
[ 'CameraRecordingOptions', 'nsIDOMCameraManager.idl' ],
|
||||
[ 'SmsThreadListItem', 'nsISmsRequest.idl' ]
|
||||
[ 'SmsThreadListItem', 'nsISmsRequest.idl' ],
|
||||
[ 'MmsAttachment', 'nsIDOMMozMmsMessage.idl' ]
|
||||
]
|
||||
|
||||
# include file names
|
||||
|
|
|
@ -313,10 +313,13 @@ public class GeckoSmsManager
|
|||
* Keep the following state codes in syng with |DeliveryState| in:
|
||||
* dom/mobilemessage/src/Types.h
|
||||
*/
|
||||
private final static int kDeliveryStateSent = 0;
|
||||
private final static int kDeliveryStateReceived = 1;
|
||||
private final static int kDeliveryStateUnknown = 2;
|
||||
private final static int kDeliveryStateEndGuard = 3;
|
||||
private final static int kDeliveryStateSent = 0;
|
||||
private final static int kDeliveryStateReceived = 1;
|
||||
private final static int kDeliveryStateSending = 2;
|
||||
private final static int kDeliveryStateError = 3;
|
||||
private final static int kDeliveryStateUnknown = 4;
|
||||
private final static int kDeliveryStateNotDownloaded = 5;
|
||||
private final static int kDeliveryStateEndGuard = 6;
|
||||
|
||||
/*
|
||||
* Keep the following status codes in sync with |DeliveryStatus| in:
|
||||
|
|
Загрузка…
Ссылка в новой задаче