mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 901457 - [sms][mms] We need a property for the "sent" timestamp (part 2, implementation). r=vicamo
This commit is contained in:
parent
e8d5279420
commit
b94e9d8c60
@ -14,7 +14,7 @@ interface nsIDOMMozSmsSegmentInfo;
|
||||
#define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(7255f557-0dd1-42f9-82fa-031cebb76bb5)]
|
||||
[scriptable, builtinclass, uuid(67d038b2-0039-11e3-9fd3-83de190730f7)]
|
||||
interface nsIMobileMessageService : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
@ -28,6 +28,7 @@ interface nsIMobileMessageService : nsISupports
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in jsval timestamp,
|
||||
in jsval sentTimestamp,
|
||||
in jsval deliveryTimestamp,
|
||||
in bool read);
|
||||
|
||||
@ -40,6 +41,7 @@ interface nsIMobileMessageService : nsISupports
|
||||
in DOMString sender,
|
||||
in jsval receivers,
|
||||
in jsval timestamp,
|
||||
in jsval sentTimestamp,
|
||||
in boolean read,
|
||||
in DOMString subject,
|
||||
in DOMString smil,
|
||||
|
@ -43,6 +43,7 @@ MmsMessage::MmsMessage(int32_t aId,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
@ -57,6 +58,7 @@ MmsMessage::MmsMessage(int32_t aId,
|
||||
mSender(aSender),
|
||||
mReceivers(aReceivers),
|
||||
mTimestamp(aTimestamp),
|
||||
mSentTimestamp(aSentTimestamp),
|
||||
mRead(aRead),
|
||||
mSubject(aSubject),
|
||||
mSmil(aSmil),
|
||||
@ -74,6 +76,7 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
, mSender(aData.sender())
|
||||
, mReceivers(aData.receivers())
|
||||
, mTimestamp(aData.timestamp())
|
||||
, mSentTimestamp(aData.sentTimestamp())
|
||||
, mRead(aData.read())
|
||||
, mSubject(aData.subject())
|
||||
, mSmil(aData.smil())
|
||||
@ -173,6 +176,7 @@ MmsMessage::Create(int32_t aId,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
@ -256,6 +260,11 @@ MmsMessage::Create(int32_t aId,
|
||||
nsresult rv = convertTimeToInt(aCx, aTimestamp, timestamp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set |sentTimestamp|.
|
||||
uint64_t sentTimestamp;
|
||||
rv = convertTimeToInt(aCx, aSentTimestamp, sentTimestamp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set |attachments|.
|
||||
if (!aAttachments.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -294,6 +303,7 @@ MmsMessage::Create(int32_t aId,
|
||||
aSender,
|
||||
receivers,
|
||||
timestamp,
|
||||
sentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
@ -317,6 +327,7 @@ MmsMessage::GetData(ContentParent* aParent,
|
||||
aData.sender().Assign(mSender);
|
||||
aData.receivers() = mReceivers;
|
||||
aData.timestamp() = mTimestamp;
|
||||
aData.sentTimestamp() = mSentTimestamp;
|
||||
aData.read() = mRead;
|
||||
aData.subject() = mSubject;
|
||||
aData.smil() = mSmil;
|
||||
@ -573,8 +584,8 @@ MmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
{
|
||||
*aSentTimestamp = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aSentTimestamp = mSentTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
@ -52,6 +53,7 @@ public:
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
@ -74,6 +76,7 @@ private:
|
||||
nsString mSender;
|
||||
nsTArray<nsString> mReceivers;
|
||||
uint64_t mTimestamp;
|
||||
uint64_t mSentTimestamp;
|
||||
bool mRead;
|
||||
nsString mSubject;
|
||||
nsString mSmil;
|
||||
|
@ -39,6 +39,7 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
@ -54,6 +55,7 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
aBody,
|
||||
aMessageClass,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aDeliveryTimestamp,
|
||||
aRead,
|
||||
aCx,
|
||||
@ -69,6 +71,7 @@ MobileMessageService::CreateMmsMessage(int32_t aId,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
@ -86,6 +89,7 @@ MobileMessageService::CreateMmsMessage(int32_t aId,
|
||||
aSender,
|
||||
aReceivers,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
|
@ -36,10 +36,11 @@ SmsMessage::SmsMessage(int32_t aId,
|
||||
const nsString& aBody,
|
||||
MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead)
|
||||
: mData(aId, aThreadId, aIccId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver, aBody, aMessageClass, aTimestamp,
|
||||
aSender, aReceiver, aBody, aMessageClass, aTimestamp, aSentTimestamp,
|
||||
aDeliveryTimestamp, aRead)
|
||||
{
|
||||
}
|
||||
@ -60,6 +61,7 @@ SmsMessage::Create(int32_t aId,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
@ -120,6 +122,10 @@ SmsMessage::Create(int32_t aId,
|
||||
nsresult rv = convertTimeToInt(aCx, aTimestamp, data.timestamp());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set |sentTimestamp|.
|
||||
rv = convertTimeToInt(aCx, aSentTimestamp, data.sentTimestamp());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set |deliveryTimestamp|.
|
||||
rv = convertTimeToInt(aCx, aDeliveryTimestamp, data.deliveryTimestamp());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -269,8 +275,8 @@ SmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
{
|
||||
*aSentTimestamp = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aSentTimestamp = mData.sentTimestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
const nsString& aBody,
|
||||
mobilemessage::MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead);
|
||||
SmsMessage(const mobilemessage::SmsMessageData& aData);
|
||||
@ -45,6 +46,7 @@ public:
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aSentTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
|
@ -1504,7 +1504,10 @@ MmsService.prototype = {
|
||||
mergeRetrievalConfirmation: function mergeRetrievalConfirmation(mmsConnection,
|
||||
intermediate,
|
||||
savable) {
|
||||
// Prepare timestamp/sentTimestamp.
|
||||
savable.timestamp = Date.now();
|
||||
savable.sentTimestamp = intermediate.headers["date"].getTime();
|
||||
|
||||
savable.receivers = [];
|
||||
// We don't have Bcc in recevied MMS message.
|
||||
for each (let type in ["cc", "to"]) {
|
||||
@ -1572,19 +1575,20 @@ MmsService.prototype = {
|
||||
// because the system message mechamism will rewrap the object
|
||||
// based on the content window, which needs to know the properties.
|
||||
gSystemMessenger.broadcastMessage(aName, {
|
||||
type: aDomMessage.type,
|
||||
id: aDomMessage.id,
|
||||
threadId: aDomMessage.threadId,
|
||||
delivery: aDomMessage.delivery,
|
||||
deliveryInfo: aDomMessage.deliveryInfo,
|
||||
sender: aDomMessage.sender,
|
||||
receivers: aDomMessage.receivers,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
read: aDomMessage.read,
|
||||
subject: aDomMessage.subject,
|
||||
smil: aDomMessage.smil,
|
||||
attachments: aDomMessage.attachments,
|
||||
expiryDate: aDomMessage.expiryDate
|
||||
type: aDomMessage.type,
|
||||
id: aDomMessage.id,
|
||||
threadId: aDomMessage.threadId,
|
||||
delivery: aDomMessage.delivery,
|
||||
deliveryInfo: aDomMessage.deliveryInfo,
|
||||
sender: aDomMessage.sender,
|
||||
receivers: aDomMessage.receivers,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
sentTimestamp: aDomMessage.sentTimestamp,
|
||||
read: aDomMessage.read,
|
||||
subject: aDomMessage.subject,
|
||||
smil: aDomMessage.smil,
|
||||
attachments: aDomMessage.attachments,
|
||||
expiryDate: aDomMessage.expiryDate
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -23,7 +23,7 @@ const DEBUG = false;
|
||||
const DISABLE_MMS_GROUPING_FOR_RECEIVING = true;
|
||||
|
||||
|
||||
const DB_VERSION = 20;
|
||||
const DB_VERSION = 21;
|
||||
const MESSAGE_STORE_NAME = "sms";
|
||||
const THREAD_STORE_NAME = "thread";
|
||||
const PARTICIPANT_STORE_NAME = "participant";
|
||||
@ -218,6 +218,10 @@ MobileMessageDB.prototype = {
|
||||
self.upgradeSchema19(event.target.transaction, next);
|
||||
break;
|
||||
case 20:
|
||||
if (DEBUG) debug("Upgrade to version 21. Add sentTimestamp.");
|
||||
self.upgradeSchema20(event.target.transaction, next);
|
||||
break;
|
||||
case 21:
|
||||
// This will need to be moved for each new version
|
||||
if (DEBUG) debug("Upgrade finished.");
|
||||
break;
|
||||
@ -1265,6 +1269,32 @@ MobileMessageDB.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Add sentTimestamp.
|
||||
*/
|
||||
upgradeSchema20: function upgradeSchema20(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;
|
||||
messageRecord.sentTimestamp = 0;
|
||||
|
||||
// We can still have changes to assign |sentTimestamp| for the existing
|
||||
// MMS message records.
|
||||
if (messageRecord.type == "mms" && messageRecord.headers["date"]) {
|
||||
messageRecord.sentTimestamp = messageRecord.headers["date"].getTime();
|
||||
}
|
||||
|
||||
cursor.update(messageRecord);
|
||||
cursor.continue();
|
||||
};
|
||||
},
|
||||
|
||||
matchParsedPhoneNumbers: function matchParsedPhoneNumbers(addr1, parsedAddr1,
|
||||
addr2, parsedAddr2) {
|
||||
if ((parsedAddr1.internationalNumber &&
|
||||
@ -1328,6 +1358,7 @@ MobileMessageDB.prototype = {
|
||||
aMessageRecord.body,
|
||||
aMessageRecord.messageClass,
|
||||
aMessageRecord.timestamp,
|
||||
aMessageRecord.sentTimestamp,
|
||||
aMessageRecord.deliveryTimestamp,
|
||||
aMessageRecord.read);
|
||||
} else if (aMessageRecord.type == "mms") {
|
||||
@ -1383,6 +1414,7 @@ MobileMessageDB.prototype = {
|
||||
aMessageRecord.sender,
|
||||
aMessageRecord.receivers,
|
||||
aMessageRecord.timestamp,
|
||||
aMessageRecord.sentTimestamp,
|
||||
aMessageRecord.read,
|
||||
subject,
|
||||
smil,
|
||||
@ -1884,6 +1916,13 @@ MobileMessageDB.prototype = {
|
||||
messageRecord.delivery = delivery;
|
||||
messageRecord.deliveryIndex = [delivery, messageRecord.timestamp];
|
||||
isRecordUpdated = true;
|
||||
|
||||
// When updating an message's delivey state to 'sent', we also update
|
||||
// its |sentTimestamp| by the current device timestamp to represent
|
||||
// when the message is successfully sent.
|
||||
if (delivery == DELIVERY_SENT) {
|
||||
messageRecord.sentTimestamp = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to update |deliveryStatus| and |deliveryTimestamp| of:
|
||||
@ -2080,6 +2119,11 @@ MobileMessageDB.prototype = {
|
||||
aMessage.readIndex = [FILTER_READ_UNREAD, timestamp];
|
||||
aMessage.read = FILTER_READ_UNREAD;
|
||||
|
||||
// If |sentTimestamp| is not specified, use 0 as default.
|
||||
if (aMessage.sentTimestamp == undefined) {
|
||||
aMessage.sentTimestamp = 0;
|
||||
}
|
||||
|
||||
if (aMessage.type == "mms") {
|
||||
aMessage.transactionIdIndex = aMessage.headers["x-mms-transaction-id"];
|
||||
aMessage.isReadReportSent = false;
|
||||
@ -2171,6 +2215,9 @@ MobileMessageDB.prototype = {
|
||||
aMessage.messageClass = MESSAGE_CLASS_NORMAL;
|
||||
aMessage.read = FILTER_READ_READ;
|
||||
|
||||
// |sentTimestamp| is not available when the message is still sedning.
|
||||
aMessage.sentTimestamp = 0;
|
||||
|
||||
let addresses;
|
||||
if (aMessage.type == "sms") {
|
||||
addresses = [aMessage.receiver];
|
||||
|
@ -36,6 +36,7 @@ struct SmsMessageData
|
||||
nsString body;
|
||||
MessageClass messageClass;
|
||||
uint64_t timestamp; // ms since epoch.
|
||||
uint64_t sentTimestamp; // ms since epoch.
|
||||
uint64_t deliveryTimestamp; // ms since epoch.
|
||||
bool read;
|
||||
};
|
||||
@ -65,12 +66,13 @@ struct MmsMessageData
|
||||
MmsDeliveryInfoData[] deliveryInfo;
|
||||
nsString sender;
|
||||
nsString[] receivers;
|
||||
uint64_t timestamp;
|
||||
uint64_t timestamp; // ms since epoch.
|
||||
uint64_t sentTimestamp; // ms since epoch.
|
||||
bool read;
|
||||
nsString subject;
|
||||
nsString smil;
|
||||
MmsAttachmentData[] attachments;
|
||||
uint64_t expiryDate;
|
||||
uint64_t expiryDate; // ms since epoch.
|
||||
bool readReportRequested;
|
||||
};
|
||||
|
||||
|
@ -2010,6 +2010,7 @@ RadioInterface.prototype = {
|
||||
body: aDomMessage.body,
|
||||
messageClass: aDomMessage.messageClass,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
sentTimestamp: aDomMessage.sentTimestamp,
|
||||
deliveryTimestamp: aDomMessage.deliveryTimestamp,
|
||||
read: aDomMessage.read
|
||||
});
|
||||
@ -2099,6 +2100,7 @@ RadioInterface.prototype = {
|
||||
message.body,
|
||||
message.messageClass,
|
||||
message.timestamp,
|
||||
message.sentTimestamp,
|
||||
0,
|
||||
message.read);
|
||||
|
||||
@ -2168,6 +2170,7 @@ RadioInterface.prototype = {
|
||||
message.body,
|
||||
message.messageClass,
|
||||
message.timestamp,
|
||||
message.sentTimestamp,
|
||||
0,
|
||||
message.read);
|
||||
|
||||
@ -3354,6 +3357,7 @@ RadioInterface.prototype = {
|
||||
sms.body,
|
||||
sms.messageClass,
|
||||
sms.timestamp,
|
||||
Date.now(),
|
||||
0,
|
||||
sms.read));
|
||||
// We don't wait for SMS-DELIVER-REPORT for silent one.
|
||||
@ -3394,8 +3398,8 @@ RadioInterface.prototype = {
|
||||
};
|
||||
|
||||
if (silent) {
|
||||
let deliveryStatus = RIL.GECKO_SMS_DELIVERY_STATUS_PENDING;
|
||||
let delivery = DOM_MOBILE_MESSAGE_DELIVERY_SENDING;
|
||||
let deliveryStatus = RIL.GECKO_SMS_DELIVERY_STATUS_PENDING;
|
||||
let domMessage =
|
||||
gMobileMessageService.createSmsMessage(-1, // id
|
||||
0, // threadId
|
||||
@ -3408,6 +3412,7 @@ RadioInterface.prototype = {
|
||||
"normal", // message class
|
||||
sendingMessage.timestamp,
|
||||
0,
|
||||
0,
|
||||
false);
|
||||
notifyResult(Cr.NS_OK, domMessage);
|
||||
return;
|
||||
|
@ -7470,7 +7470,7 @@ let GsmPDUHelper = {
|
||||
// - TP-Data-Coding-Scheme -
|
||||
this.readDataCodingScheme(msg);
|
||||
// - TP-Service-Center-Time-Stamp -
|
||||
msg.timestamp = this.readTimestamp();
|
||||
msg.sentTimestamp = this.readTimestamp();
|
||||
// - TP-User-Data-Length -
|
||||
let userDataLength = this.readHexOctet();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user