mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 928821 - B2G MMS: put deliveryStatus[] into a more generic structure MmsDeliveryInfo[] sr=gene r=gene
This commit is contained in:
parent
b4d4b8fe5a
commit
1a6dab6e96
@ -15,7 +15,13 @@ dictionary MmsAttachment
|
||||
// for text should always be "utf-8".
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(2e5e1c16-b7af-11e2-af04-8f4b1610a600)]
|
||||
dictionary MmsDeliveryInfo
|
||||
{
|
||||
DOMString? receiver;
|
||||
DOMString? deliveryStatus;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(494bbca1-ac7c-47d2-9e90-4e7d07e1cb4f)]
|
||||
interface nsIDOMMozMmsMessage : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -33,7 +39,7 @@ interface nsIDOMMozMmsMessage : nsISupports
|
||||
readonly attribute DOMString delivery;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval deliveryStatus; // DOMString[]
|
||||
readonly attribute jsval deliveryInfo; // MmsDeliveryInfo[]
|
||||
|
||||
readonly attribute DOMString sender;
|
||||
|
||||
|
@ -14,7 +14,7 @@ interface nsIDOMMozSmsSegmentInfo;
|
||||
#define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(bea56ecf-472d-4b6b-b462-66753f3c1179)]
|
||||
[scriptable, builtinclass, uuid(2a231e8d-761d-47a9-8928-93de7b0cbaac)]
|
||||
interface nsIMobileMessageService : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
@ -33,7 +33,7 @@ interface nsIMobileMessageService : nsISupports
|
||||
nsIDOMMozMmsMessage createMmsMessage(in long id,
|
||||
in unsigned long long threadId,
|
||||
in DOMString delivery,
|
||||
in jsval deliveryStatus,
|
||||
in jsval deliveryInfo,
|
||||
in DOMString sender,
|
||||
in jsval receivers,
|
||||
in jsval timestamp,
|
||||
|
@ -33,22 +33,22 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_ADDREF(MmsMessage)
|
||||
NS_IMPL_RELEASE(MmsMessage)
|
||||
|
||||
MmsMessage::MmsMessage(int32_t aId,
|
||||
const uint64_t aThreadId,
|
||||
DeliveryState aDelivery,
|
||||
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,
|
||||
uint64_t aExpiryDate)
|
||||
MmsMessage::MmsMessage(int32_t aId,
|
||||
const uint64_t aThreadId,
|
||||
DeliveryState aDelivery,
|
||||
const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<MmsAttachment>& aAttachments,
|
||||
uint64_t aExpiryDate)
|
||||
: mId(aId),
|
||||
mThreadId(aThreadId),
|
||||
mDelivery(aDelivery),
|
||||
mDeliveryStatus(aDeliveryStatus),
|
||||
mDeliveryInfo(aDeliveryInfo),
|
||||
mSender(aSender),
|
||||
mReceivers(aReceivers),
|
||||
mTimestamp(aTimestamp),
|
||||
@ -64,7 +64,6 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
: mId(aData.id())
|
||||
, mThreadId(aData.threadId())
|
||||
, mDelivery(aData.delivery())
|
||||
, mDeliveryStatus(aData.deliveryStatus())
|
||||
, mSender(aData.sender())
|
||||
, mReceivers(aData.receivers())
|
||||
, mTimestamp(aData.timestamp())
|
||||
@ -89,6 +88,41 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
}
|
||||
mAttachments.AppendElement(att);
|
||||
}
|
||||
|
||||
len = aData.deliveryInfo().Length();
|
||||
mDeliveryInfo.SetCapacity(len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
MmsDeliveryInfo info;
|
||||
const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i];
|
||||
info.receiver = infoData.receiver();
|
||||
|
||||
nsString statusStr;
|
||||
switch (infoData.deliveryStatus()) {
|
||||
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_Reject:
|
||||
statusStr = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case eDeliveryStatus_Manual:
|
||||
statusStr = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
}
|
||||
info.deliveryStatus = statusStr;
|
||||
mDeliveryInfo.AppendElement(info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +162,7 @@ convertTimeToInt(JSContext* aCx, const JS::Value& aTime, uint64_t& aReturn)
|
||||
MmsMessage::Create(int32_t aId,
|
||||
const uint64_t aThreadId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
@ -158,47 +192,31 @@ MmsMessage::Create(int32_t aId,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Set |deliveryStatus|.
|
||||
if (!aDeliveryStatus.isObject()) {
|
||||
// Set |deliveryInfo|.
|
||||
if (!aDeliveryInfo.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> deliveryStatusObj(aCx, &aDeliveryStatus.toObject());
|
||||
if (!JS_IsArrayObject(aCx, deliveryStatusObj)) {
|
||||
JS::Rooted<JSObject*> deliveryInfoObj(aCx, &aDeliveryInfo.toObject());
|
||||
if (!JS_IsArrayObject(aCx, deliveryInfoObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryStatusObj, &length));
|
||||
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
|
||||
|
||||
nsTArray<DeliveryStatus> deliveryStatus;
|
||||
JS::Rooted<JS::Value> statusJsVal(aCx);
|
||||
nsTArray<MmsDeliveryInfo> deliveryInfo;
|
||||
JS::Rooted<JS::Value> infoJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, deliveryStatusObj, i, &statusJsVal) ||
|
||||
!statusJsVal.isString()) {
|
||||
if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) ||
|
||||
!infoJsVal.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsDependentJSString statusStr;
|
||||
statusStr.init(aCx, statusJsVal.toString());
|
||||
MmsDeliveryInfo info;
|
||||
nsresult rv = info.Init(aCx, infoJsVal.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
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 if (statusStr.Equals(DELIVERY_STATUS_REJECTED)) {
|
||||
status = eDeliveryStatus_Reject;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_MANUAL)) {
|
||||
status = eDeliveryStatus_Manual;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
deliveryStatus.AppendElement(status);
|
||||
deliveryInfo.AppendElement(info);
|
||||
}
|
||||
|
||||
// Set |receivers|.
|
||||
@ -263,7 +281,7 @@ MmsMessage::Create(int32_t aId,
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = new MmsMessage(aId,
|
||||
aThreadId,
|
||||
delivery,
|
||||
deliveryStatus,
|
||||
deliveryInfo,
|
||||
aSender,
|
||||
receivers,
|
||||
timestamp,
|
||||
@ -285,7 +303,6 @@ MmsMessage::GetData(ContentParent* aParent,
|
||||
aData.id() = mId;
|
||||
aData.threadId() = mThreadId;
|
||||
aData.delivery() = mDelivery;
|
||||
aData.deliveryStatus() = mDeliveryStatus;
|
||||
aData.sender().Assign(mSender);
|
||||
aData.receivers() = mReceivers;
|
||||
aData.timestamp() = mTimestamp;
|
||||
@ -294,6 +311,32 @@ MmsMessage::GetData(ContentParent* aParent,
|
||||
aData.smil() = mSmil;
|
||||
aData.expiryDate() = mExpiryDate;
|
||||
|
||||
aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length());
|
||||
for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) {
|
||||
MmsDeliveryInfoData infoData;
|
||||
const MmsDeliveryInfo &info = mDeliveryInfo[i];
|
||||
infoData.receiver().Assign(info.receiver);
|
||||
|
||||
DeliveryStatus status;
|
||||
if (info.deliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
status = eDeliveryStatus_NotApplicable;
|
||||
} else if (info.deliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
status = eDeliveryStatus_Success;
|
||||
} else if (info.deliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
status = eDeliveryStatus_Pending;
|
||||
} else if (info.deliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
status = eDeliveryStatus_Error;
|
||||
} else if (info.deliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) {
|
||||
status = eDeliveryStatus_Reject;
|
||||
} else if (info.deliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) {
|
||||
status = eDeliveryStatus_Manual;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
infoData.deliveryStatus() = status;
|
||||
aData.deliveryInfo().AppendElement(infoData);
|
||||
}
|
||||
|
||||
aData.attachments().SetCapacity(mAttachments.Length());
|
||||
for (uint32_t i = 0; i < mAttachments.Length(); i++) {
|
||||
MmsAttachmentData mma;
|
||||
@ -373,51 +416,62 @@ MmsMessage::GetDelivery(nsAString& aDelivery)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetDeliveryStatus(JSContext* aCx, JS::Value* aDeliveryStatus)
|
||||
MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo)
|
||||
{
|
||||
// TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage
|
||||
// to return a more correct value. Ex, if .delivery = 'received', we should
|
||||
// also make .deliveryStatus = null, since the .deliveryStatus is useless.
|
||||
uint32_t length = mDeliveryStatus.Length();
|
||||
// also make .deliveryInfo = null, since the .deliveryInfo is useless.
|
||||
uint32_t length = mDeliveryInfo.Length();
|
||||
if (length == 0) {
|
||||
*aDeliveryStatus = JSVAL_NULL;
|
||||
*aDeliveryInfo = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<nsString> tempStrArray;
|
||||
JS::Rooted<JSObject*> deliveryInfo(
|
||||
aCx, JS_NewArrayObject(aCx, length, nullptr));
|
||||
NS_ENSURE_TRUE(deliveryInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
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_Reject:
|
||||
statusStr = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case eDeliveryStatus_Manual:
|
||||
statusStr = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
const MmsDeliveryInfo &info = mDeliveryInfo[i];
|
||||
|
||||
JS::Rooted<JSObject*> infoJsObj(
|
||||
aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
NS_ENSURE_TRUE(infoJsObj, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JS::Value> tmpJsVal(aCx);
|
||||
JSString* tmpJsStr;
|
||||
|
||||
// Get |info.receiver|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
info.receiver.get(),
|
||||
info.receiver.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
tmpJsVal.setString(tmpJsStr);
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "receiver", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |info.deliveryStatus|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
info.deliveryStatus.get(),
|
||||
info.deliveryStatus.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
tmpJsVal.setString(tmpJsStr);
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "deliveryStatus", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
tmpJsVal = OBJECT_TO_JSVAL(infoJsObj);
|
||||
if (!JS_SetElement(aCx, deliveryInfo, i, &tmpJsVal)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
tempStrArray.AppendElement(statusStr);
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> deliveryStatusObj(aCx);
|
||||
nsresult rv = nsTArrayToJSArray(aCx, tempStrArray, deliveryStatusObj.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aDeliveryStatus->setObject(*deliveryStatusObj);
|
||||
aDeliveryInfo->setObject(*deliveryInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -475,13 +529,15 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
|
||||
{
|
||||
uint32_t length = mAttachments.Length();
|
||||
|
||||
JS::Rooted<JSObject*> attachments(aCx, JS_NewArrayObject(aCx, length, nullptr));
|
||||
JS::Rooted<JSObject*> attachments(
|
||||
aCx, 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];
|
||||
|
||||
JS::Rooted<JSObject*> attachmentObj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
JS::Rooted<JSObject*> attachmentObj(
|
||||
aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JS::Value> tmpJsVal(aCx);
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
MmsMessage(int32_t aId,
|
||||
const uint64_t aThreadId,
|
||||
mobilemessage::DeliveryState aDelivery,
|
||||
const nsTArray<mobilemessage::DeliveryStatus>& aDeliveryStatus,
|
||||
const nsTArray<idl::MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
@ -45,7 +45,7 @@ public:
|
||||
static nsresult Create(int32_t aId,
|
||||
const uint64_t aThreadId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
@ -65,7 +65,7 @@ private:
|
||||
int32_t mId;
|
||||
uint64_t mThreadId;
|
||||
mobilemessage::DeliveryState mDelivery;
|
||||
nsTArray<mobilemessage::DeliveryStatus> mDeliveryStatus;
|
||||
nsTArray<idl::MmsDeliveryInfo> mDeliveryInfo;
|
||||
nsString mSender;
|
||||
nsTArray<nsString> mReceivers;
|
||||
uint64_t mTimestamp;
|
||||
|
@ -60,7 +60,7 @@ NS_IMETHODIMP
|
||||
MobileMessageService::CreateMmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
@ -75,7 +75,7 @@ MobileMessageService::CreateMmsMessage(int32_t aId,
|
||||
return MmsMessage::Create(aId,
|
||||
aThreadId,
|
||||
aDelivery,
|
||||
aDeliveryStatus,
|
||||
aDeliveryInfo,
|
||||
aSender,
|
||||
aReceivers,
|
||||
aTimestamp,
|
||||
|
@ -1321,22 +1321,26 @@ MmsService.prototype = {
|
||||
retrievalMode) {
|
||||
intermediate.type = "mms";
|
||||
intermediate.delivery = DELIVERY_NOT_DOWNLOADED;
|
||||
// As a receiver, we don't need to care about the delivery status of others.
|
||||
let deliveryInfo = intermediate.deliveryInfo = [{
|
||||
receiver: this.getPhoneNumber(),
|
||||
deliveryStatus: DELIVERY_STATUS_NOT_APPLICABLE }];
|
||||
|
||||
switch(retrievalMode) {
|
||||
switch (retrievalMode) {
|
||||
case RETRIEVAL_MODE_MANUAL:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL];
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case RETRIEVAL_MODE_NEVER:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_REJECTED];
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case RETRIEVAL_MODE_AUTOMATIC:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case RETRIEVAL_MODE_AUTOMATIC_HOME:
|
||||
if (gMmsConnection.isVoiceRoaming()) {
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL];
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_MANUAL;
|
||||
} else {
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_PENDING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1377,7 +1381,7 @@ MmsService.prototype = {
|
||||
if (intermediate.headers[type]) {
|
||||
if (intermediate.headers[type] instanceof Array) {
|
||||
for (let index in intermediate.headers[type]) {
|
||||
savable.receivers.push(intermediate.headers[type][index].address)
|
||||
savable.receivers.push(intermediate.headers[type][index].address);
|
||||
}
|
||||
} else {
|
||||
savable.receivers.push(intermediate.headers[type].address);
|
||||
@ -1386,7 +1390,10 @@ MmsService.prototype = {
|
||||
}
|
||||
|
||||
savable.delivery = DELIVERY_RECEIVED;
|
||||
savable.deliveryStatus = [DELIVERY_STATUS_SUCCESS];
|
||||
// As a receiver, we don't need to care about the delivery status of others.
|
||||
savable.deliveryInfo = [{
|
||||
receiver: this.getPhoneNumber(),
|
||||
deliveryStatus: DELIVERY_STATUS_SUCCESS }];
|
||||
for (let field in intermediate.headers) {
|
||||
savable.headers[field] = intermediate.headers[field];
|
||||
}
|
||||
@ -1436,7 +1443,7 @@ MmsService.prototype = {
|
||||
id: aDomMessage.id,
|
||||
threadId: aDomMessage.threadId,
|
||||
delivery: aDomMessage.delivery,
|
||||
deliveryStatus: aDomMessage.deliveryStatus,
|
||||
deliveryInfo: aDomMessage.deliveryInfo,
|
||||
sender: aDomMessage.sender,
|
||||
receivers: aDomMessage.receivers,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
|
@ -24,7 +24,7 @@ const DISABLE_MMS_GROUPING_FOR_RECEIVING = true;
|
||||
|
||||
|
||||
const DB_NAME = "sms";
|
||||
const DB_VERSION = 12;
|
||||
const DB_VERSION = 13;
|
||||
const MESSAGE_STORE_NAME = "sms";
|
||||
const THREAD_STORE_NAME = "thread";
|
||||
const PARTICIPANT_STORE_NAME = "participant";
|
||||
@ -218,6 +218,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
self.upgradeSchema11(event.target.transaction, next);
|
||||
break;
|
||||
case 12:
|
||||
if (DEBUG) debug("Upgrade to version 13. Replaced deliveryStatus by deliveryInfo.");
|
||||
self.upgradeSchema12(event.target.transaction, next);
|
||||
break;
|
||||
case 13:
|
||||
// This will need to be moved for each new version
|
||||
if (DEBUG) debug("Upgrade finished.");
|
||||
break;
|
||||
@ -322,8 +326,8 @@ MobileMessageDatabaseService.prototype = {
|
||||
messageRecord.deliveryStatus = DELIVERY_STATUS_ERROR;
|
||||
} else {
|
||||
// Set delivery status to error.
|
||||
for (let i = 0; i < messageRecord.deliveryStatus.length; i++) {
|
||||
messageRecord.deliveryStatus[i] = DELIVERY_STATUS_ERROR;
|
||||
for (let i = 0; i < messageRecord.deliveryInfo.length; i++) {
|
||||
messageRecord.deliveryInfo[i].deliveryStatus = DELIVERY_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,9 +354,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
}
|
||||
|
||||
// Set delivery status to error.
|
||||
if (messageRecord.deliveryStatus.length == 1 &&
|
||||
messageRecord.deliveryStatus[0] == DELIVERY_STATUS_PENDING) {
|
||||
messageRecord.deliveryStatus = [DELIVERY_STATUS_ERROR];
|
||||
let deliveryInfo = messageRecord.deliveryInfo;
|
||||
if (deliveryInfo.length == 1 &&
|
||||
deliveryInfo[0].deliveryStatus == DELIVERY_STATUS_PENDING) {
|
||||
deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_ERROR;
|
||||
}
|
||||
|
||||
messageCursor.update(messageRecord);
|
||||
@ -793,6 +798,43 @@ MobileMessageDatabaseService.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Replace deliveryStatus by deliveryInfo.
|
||||
*/
|
||||
upgradeSchema12: function upgradeSchema12(transaction, next) {
|
||||
let messageStore = transaction.objectStore(MESSAGE_STORE_NAME);
|
||||
|
||||
messageStore.openCursor().onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
let messageRecord = cursor.value;
|
||||
if (messageRecord.type == "mms") {
|
||||
messageRecord.deliveryInfo = [];
|
||||
|
||||
if (messageRecord.deliveryStatus.length == 1 &&
|
||||
(messageRecord.delivery == DELIVERY_NOT_DOWNLOADED ||
|
||||
messageRecord.delivery == DELIVERY_RECEIVED)) {
|
||||
messageRecord.deliveryInfo.push({
|
||||
receiver: null,
|
||||
deliveryStatus: messageRecord.deliveryStatus[0] });
|
||||
} else {
|
||||
for (let i = 0; i < messageRecord.deliveryStatus.length; i++) {
|
||||
messageRecord.deliveryInfo.push({
|
||||
receiver: messageRecord.receivers[i],
|
||||
deliveryStatus: messageRecord.deliveryStatus[i] });
|
||||
}
|
||||
}
|
||||
delete messageRecord.deliveryStatus;
|
||||
cursor.update(messageRecord);
|
||||
}
|
||||
cursor.continue();
|
||||
};
|
||||
},
|
||||
|
||||
createDomMessageFromRecord: function createDomMessageFromRecord(aMessageRecord) {
|
||||
if (DEBUG) {
|
||||
debug("createDomMessageFromRecord: " + JSON.stringify(aMessageRecord));
|
||||
@ -855,7 +897,7 @@ MobileMessageDatabaseService.prototype = {
|
||||
return gMobileMessageService.createMmsMessage(aMessageRecord.id,
|
||||
aMessageRecord.threadId,
|
||||
aMessageRecord.delivery,
|
||||
aMessageRecord.deliveryStatus,
|
||||
aMessageRecord.deliveryInfo,
|
||||
aMessageRecord.sender,
|
||||
aMessageRecord.receivers,
|
||||
aMessageRecord.timestamp,
|
||||
@ -1246,9 +1288,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
}
|
||||
} else if (messageRecord.type == "mms") {
|
||||
if (!receiver) {
|
||||
for (let i = 0; i < messageRecord.deliveryStatus.length; i++) {
|
||||
if (messageRecord.deliveryStatus[i] != deliveryStatus) {
|
||||
messageRecord.deliveryStatus[i] = deliveryStatus;
|
||||
let deliveryInfo = messageRecord.deliveryInfo;
|
||||
for (let i = 0; i < deliveryInfo.length; i++) {
|
||||
if (deliveryInfo[i].deliveryStatus != deliveryStatus) {
|
||||
deliveryInfo[i].deliveryStatus = deliveryStatus;
|
||||
isRecordUpdated = true;
|
||||
}
|
||||
}
|
||||
@ -1296,9 +1339,15 @@ MobileMessageDatabaseService.prototype = {
|
||||
}
|
||||
|
||||
found = true;
|
||||
if (messageRecord.deliveryStatus[i] != deliveryStatus) {
|
||||
messageRecord.deliveryStatus[i] = deliveryStatus;
|
||||
isRecordUpdated = true;
|
||||
let deliveryInfo = messageRecord.deliveryInfo;
|
||||
for (let j = 0; j < deliveryInfo.length; j++) {
|
||||
if (deliveryInfo[j].receiver != storedReceiver) {
|
||||
continue;
|
||||
}
|
||||
if (deliveryInfo[j].deliveryStatus != deliveryStatus) {
|
||||
deliveryInfo[j].deliveryStatus = deliveryStatus;
|
||||
isRecordUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1345,7 +1394,7 @@ MobileMessageDatabaseService.prototype = {
|
||||
(aMessage.type == "sms" && aMessage.messageClass == undefined) ||
|
||||
(aMessage.type == "mms" && (aMessage.delivery == undefined ||
|
||||
aMessage.transactionId == undefined ||
|
||||
!Array.isArray(aMessage.deliveryStatus) ||
|
||||
!Array.isArray(aMessage.deliveryInfo) ||
|
||||
!Array.isArray(aMessage.receivers))) ||
|
||||
aMessage.sender == undefined ||
|
||||
aMessage.timestamp == undefined) {
|
||||
@ -1443,9 +1492,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
}
|
||||
return;
|
||||
}
|
||||
aMessage.deliveryStatus = [];
|
||||
aMessage.deliveryInfo = [];
|
||||
for (let i = 0; i < receivers.length; i++) {
|
||||
aMessage.deliveryStatus.push(deliveryStatus);
|
||||
aMessage.deliveryInfo.push({
|
||||
receiver: receivers[i], deliveryStatus: deliveryStatus });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,20 +45,26 @@ struct MmsAttachmentData
|
||||
PBlob content;
|
||||
};
|
||||
|
||||
struct MmsDeliveryInfoData
|
||||
{
|
||||
nsString receiver;
|
||||
DeliveryStatus deliveryStatus;
|
||||
};
|
||||
|
||||
struct MmsMessageData
|
||||
{
|
||||
int32_t id;
|
||||
uint64_t threadId;
|
||||
DeliveryState delivery;
|
||||
DeliveryStatus[] deliveryStatus;
|
||||
nsString sender;
|
||||
nsString[] receivers;
|
||||
uint64_t timestamp;
|
||||
bool read;
|
||||
nsString subject;
|
||||
nsString smil;
|
||||
MmsAttachmentData[] attachments;
|
||||
uint64_t expiryDate;
|
||||
int32_t id;
|
||||
uint64_t threadId;
|
||||
DeliveryState delivery;
|
||||
MmsDeliveryInfoData[] deliveryInfo;
|
||||
nsString sender;
|
||||
nsString[] receivers;
|
||||
uint64_t timestamp;
|
||||
bool read;
|
||||
nsString subject;
|
||||
nsString smil;
|
||||
MmsAttachmentData[] attachments;
|
||||
uint64_t expiryDate;
|
||||
};
|
||||
|
||||
union MobileMessageData
|
||||
|
Loading…
Reference in New Issue
Block a user