mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 939302 - Use DOMTimestamp for timestamps in MMS. r=bz,gen
This commit is contained in:
parent
722f9ebc4c
commit
d453e99022
@ -2,6 +2,7 @@
|
||||
* 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 "domstubs.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMBlob;
|
||||
@ -19,14 +20,14 @@ dictionary MmsDeliveryInfo
|
||||
{
|
||||
DOMString? receiver;
|
||||
DOMString? deliveryStatus;
|
||||
jsval deliveryTimestamp; // Date object; null if not available (e.g.,
|
||||
// |delivery| = "received" or not yet delivered).
|
||||
DOMTimeStamp deliveryTimestamp; // 0 if not available (e.g.,
|
||||
// |delivery| = "received" or not yet delivered).
|
||||
DOMString? readStatus;
|
||||
jsval readTimestamp; // Date object. null if not available (e.g.,
|
||||
// |delivery| = "received" or not yet read).
|
||||
DOMTimeStamp readTimestamp; // 0 if not available (e.g.,
|
||||
// |delivery| = "received" or not yet read).
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(82ca2465-f967-4107-a4da-65b7a15d5dba)]
|
||||
[scriptable, builtinclass, uuid(4ca3a456-0e25-4331-974a-a8f11a5efb4b)]
|
||||
interface nsIDOMMozMmsMessage : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -58,8 +59,7 @@ interface nsIDOMMozMmsMessage : nsISupports
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval receivers; // DOMString[]
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval timestamp; // Date object
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
|
||||
readonly attribute boolean read;
|
||||
readonly attribute DOMString subject;
|
||||
@ -68,9 +68,7 @@ interface nsIDOMMozMmsMessage : nsISupports
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval attachments; // MmsAttachment[]
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval expiryDate; // Date object
|
||||
// Expiry date for an MMS to be
|
||||
readonly attribute DOMTimeStamp expiryDate; // Expiry date for an MMS to be
|
||||
// manually downloaded.
|
||||
|
||||
// Request read report from sender or not.
|
||||
|
@ -2,9 +2,10 @@
|
||||
* 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 "domstubs.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(9672c75d-61a2-470e-964b-2396dcff7cf6)]
|
||||
[scriptable, builtinclass, uuid(525ad3a6-59a9-11e3-bdc3-836486cb58be)]
|
||||
interface nsIDOMMozMobileMessageThread : nsISupports
|
||||
{
|
||||
// Unique identity of the thread.
|
||||
@ -24,8 +25,7 @@ interface nsIDOMMozMobileMessageThread : nsISupports
|
||||
readonly attribute jsval participants; // DOMString[]
|
||||
|
||||
// Timestamp of the last message in the thread.
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval timestamp; // jsval is for Date.
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
|
||||
// Message type of the last message in the thread.
|
||||
readonly attribute DOMString lastMessageType;
|
||||
|
@ -2,9 +2,10 @@
|
||||
* 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 "domstubs.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(db9ff254-2745-11e3-aa37-8793b90fc643)]
|
||||
[scriptable, builtinclass, uuid(c591dcf8-5322-11e3-899e-9baad640ca82)]
|
||||
interface nsIDOMMozSmsMessage : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -49,13 +50,11 @@ interface nsIDOMMozSmsMessage : nsISupports
|
||||
*/
|
||||
readonly attribute DOMString messageClass;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval timestamp; // Date object.
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval deliveryTimestamp;
|
||||
// Date object; null if not available (e.g.,
|
||||
// |delivery| = "received" or not yet delivered).
|
||||
readonly attribute DOMTimeStamp deliveryTimestamp;
|
||||
// 0 if not available (e.g., |delivery| =
|
||||
// "received" or not yet delivered).
|
||||
|
||||
readonly attribute boolean read;
|
||||
};
|
||||
|
@ -134,17 +134,7 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
info.deliveryStatus = statusStr;
|
||||
|
||||
// Prepare |info.deliveryTimestamp|.
|
||||
info.deliveryTimestamp = JSVAL_NULL;
|
||||
if (infoData.deliveryTimestamp() != 0) {
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*>
|
||||
dateObj(cx, JS_NewDateObjectMsec(cx, infoData.deliveryTimestamp()));
|
||||
if (!dateObj) {
|
||||
NS_WARNING("MmsMessage: Unable to create Date for deliveryTimestamp.");
|
||||
} else {
|
||||
info.deliveryTimestamp = OBJECT_TO_JSVAL(dateObj);
|
||||
}
|
||||
}
|
||||
info.deliveryTimestamp = infoData.deliveryTimestamp();
|
||||
|
||||
// Prepare |info.readStatus|.
|
||||
nsString statusReadString;
|
||||
@ -168,17 +158,7 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
info.readStatus = statusReadString;
|
||||
|
||||
// Prepare |info.readTimestamp|.
|
||||
info.readTimestamp = JSVAL_NULL;
|
||||
if (infoData.readTimestamp() != 0) {
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*>
|
||||
dateObj(cx, JS_NewDateObjectMsec(cx, infoData.readTimestamp()));
|
||||
if (!dateObj) {
|
||||
NS_WARNING("MmsMessage: Unable to create Data for readTimestamp.");
|
||||
} else {
|
||||
info.readTimestamp = OBJECT_TO_JSVAL(dateObj);
|
||||
}
|
||||
}
|
||||
info.readTimestamp = infoData.readTimestamp();
|
||||
|
||||
mDeliveryInfo.AppendElement(info);
|
||||
}
|
||||
@ -371,12 +351,7 @@ MmsMessage::GetData(ContentParent* aParent,
|
||||
infoData.deliveryStatus() = status;
|
||||
|
||||
// Prepare |infoData.deliveryTimestamp|.
|
||||
if (info.deliveryTimestamp == JSVAL_NULL) {
|
||||
infoData.deliveryTimestamp() = 0;
|
||||
} else {
|
||||
AutoJSContext cx;
|
||||
convertTimeToInt(cx, info.deliveryTimestamp, infoData.deliveryTimestamp());
|
||||
}
|
||||
infoData.deliveryTimestamp() = info.deliveryTimestamp;
|
||||
|
||||
// Prepare |infoData.readStatus|.
|
||||
ReadStatus readStatus;
|
||||
@ -394,12 +369,7 @@ MmsMessage::GetData(ContentParent* aParent,
|
||||
infoData.readStatus() = readStatus;
|
||||
|
||||
// Prepare |infoData.readTimestamp|.
|
||||
if (info.readTimestamp == JSVAL_NULL) {
|
||||
infoData.readTimestamp() = 0;
|
||||
} else {
|
||||
AutoJSContext cx;
|
||||
convertTimeToInt(cx, info.readTimestamp, infoData.readTimestamp());
|
||||
}
|
||||
infoData.readTimestamp() = info.readTimestamp;
|
||||
|
||||
aData.deliveryInfo().AppendElement(infoData);
|
||||
}
|
||||
@ -540,8 +510,8 @@ MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo)
|
||||
}
|
||||
|
||||
// Get |info.deliveryTimestamp|.
|
||||
if (!JS_DefineProperty(aCx, infoJsObj,
|
||||
"deliveryTimestamp", info.deliveryTimestamp,
|
||||
tmpJsVal.setNumber(static_cast<double>(info.deliveryTimestamp));
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "deliveryTimestamp", tmpJsVal,
|
||||
nullptr, nullptr, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -554,13 +524,14 @@ MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo)
|
||||
|
||||
tmpJsVal.setString(tmpJsStr);
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "readStatus", tmpJsVal,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
nullptr, nullptr, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |info.readTimestamp|.
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "readTimestamp", info.readTimestamp,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
tmpJsVal.setNumber(static_cast<double>(info.readTimestamp));
|
||||
if (!JS_DefineProperty(aCx, infoJsObj, "readTimestamp", tmpJsVal,
|
||||
nullptr, nullptr, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -593,12 +564,9 @@ MmsMessage::GetReceivers(JSContext* aCx, JS::Value* aReceivers)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
|
||||
MmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
JSObject *obj = JS_NewDateObjectMsec(cx, mTimestamp);
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
*aTimestamp = mTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -691,12 +659,9 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetExpiryDate(JSContext* cx, JS::Value* aDate)
|
||||
MmsMessage::GetExpiryDate(DOMTimeStamp* aExpiryDate)
|
||||
{
|
||||
JSObject *obj = JS_NewDateObjectMsec(cx, mExpiryDate);
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
*aExpiryDate = mExpiryDate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -174,13 +174,9 @@ MobileMessageThread::GetParticipants(JSContext* aCx,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetTimestamp(JSContext* aCx,
|
||||
JS::Value* aDate)
|
||||
MobileMessageThread::GetTimestamp(DOMTimeStamp* aDate)
|
||||
{
|
||||
JSObject *obj = JS_NewDateObjectMsec(aCx, mData.timestamp());
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
*aDate = mData.timestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -260,27 +260,16 @@ SmsMessage::GetMessageClass(nsAString& aMessageClass)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
|
||||
SmsMessage::GetTimestamp(DOMTimeStamp* aDate)
|
||||
{
|
||||
JSObject *obj = JS_NewDateObjectMsec(cx, mData.timestamp());
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
*aDate = mData.timestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetDeliveryTimestamp(JSContext* aCx, JS::Value* aDate)
|
||||
SmsMessage::GetDeliveryTimestamp(DOMTimeStamp* aDate)
|
||||
{
|
||||
if (mData.deliveryTimestamp() == 0) {
|
||||
*aDate = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject *obj = JS_NewDateObjectMsec(aCx, mData.deliveryTimestamp());
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
*aDate = mData.deliveryTimestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ def attributeVariableTypeAndName(a):
|
||||
l = ["nsString %s" % a.name]
|
||||
elif a.realtype.nativeType('in').count("JS::Value"):
|
||||
l = ["JS::Value %s" % a.name]
|
||||
elif a.realtype.nativeType('in').count("DOMTimeStamp"):
|
||||
l = ["uint64_t /* DOMTimeStamp */ %s" % a.name]
|
||||
else:
|
||||
l = ["%s%s" % (a.realtype.nativeType('in'),
|
||||
a.name)]
|
||||
@ -291,7 +293,7 @@ def write_getter(a, iface, fd):
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToUint32(aCx, v, &aDict.%s));\n" % a.name)
|
||||
elif realtype.count("int32_t"):
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToInt32(aCx, v, &aDict.%s));\n" % a.name)
|
||||
elif realtype.count("uint64_t"):
|
||||
elif realtype.count("uint64_t") or realtype.count("DOMTimeStamp"):
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToUint64(aCx, v, &aDict.%s));\n" % a.name)
|
||||
elif realtype.count("int64_t"):
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToInt64(aCx, v, &aDict.%s));\n" % a.name)
|
||||
|
Loading…
Reference in New Issue
Block a user