michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "MmsMessage.h" michael@0: #include "nsIDOMClassInfo.h" michael@0: #include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec michael@0: #include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch michael@0: #include "nsJSUtils.h" michael@0: #include "nsContentUtils.h" michael@0: #include "nsIDOMFile.h" michael@0: #include "nsTArrayHelpers.h" michael@0: #include "mozilla/dom/ContentParent.h" michael@0: #include "mozilla/dom/mobilemessage/Constants.h" // For MessageType michael@0: #include "mozilla/dom/mobilemessage/SmsTypes.h" michael@0: #include "mozilla/dom/ToJSValue.h" michael@0: #include "nsDOMFile.h" michael@0: #include "nsCxPusher.h" michael@0: michael@0: using namespace mozilla::dom::mobilemessage; michael@0: michael@0: DOMCI_DATA(MozMmsMessage, mozilla::dom::MmsMessage) michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: NS_INTERFACE_MAP_BEGIN(MmsMessage) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDOMMozMmsMessage) michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMmsMessage) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: NS_IMPL_ADDREF(MmsMessage) michael@0: NS_IMPL_RELEASE(MmsMessage) michael@0: michael@0: MmsMessage::MmsMessage(int32_t aId, michael@0: uint64_t aThreadId, michael@0: const nsAString& aIccId, michael@0: DeliveryState aDelivery, michael@0: const nsTArray& aDeliveryInfo, michael@0: const nsAString& aSender, michael@0: const nsTArray& aReceivers, michael@0: uint64_t aTimestamp, michael@0: uint64_t aSentTimestamp, michael@0: bool aRead, michael@0: const nsAString& aSubject, michael@0: const nsAString& aSmil, michael@0: const nsTArray& aAttachments, michael@0: uint64_t aExpiryDate, michael@0: bool aReadReportRequested) michael@0: : mId(aId), michael@0: mThreadId(aThreadId), michael@0: mIccId(aIccId), michael@0: mDelivery(aDelivery), michael@0: mDeliveryInfo(aDeliveryInfo), michael@0: mSender(aSender), michael@0: mReceivers(aReceivers), michael@0: mTimestamp(aTimestamp), michael@0: mSentTimestamp(aSentTimestamp), michael@0: mRead(aRead), michael@0: mSubject(aSubject), michael@0: mSmil(aSmil), michael@0: mAttachments(aAttachments), michael@0: mExpiryDate(aExpiryDate), michael@0: mReadReportRequested(aReadReportRequested) michael@0: { michael@0: } michael@0: michael@0: MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData) michael@0: : mId(aData.id()) michael@0: , mThreadId(aData.threadId()) michael@0: , mIccId(aData.iccId()) michael@0: , mDelivery(aData.delivery()) michael@0: , mSender(aData.sender()) michael@0: , mReceivers(aData.receivers()) michael@0: , mTimestamp(aData.timestamp()) michael@0: , mSentTimestamp(aData.sentTimestamp()) michael@0: , mRead(aData.read()) michael@0: , mSubject(aData.subject()) michael@0: , mSmil(aData.smil()) michael@0: , mExpiryDate(aData.expiryDate()) michael@0: , mReadReportRequested(aData.readReportRequested()) michael@0: { michael@0: uint32_t len = aData.attachments().Length(); michael@0: mAttachments.SetCapacity(len); michael@0: for (uint32_t i = 0; i < len; i++) { michael@0: MmsAttachment att; michael@0: const MmsAttachmentData &element = aData.attachments()[i]; michael@0: att.mId = element.id(); michael@0: att.mLocation = element.location(); michael@0: if (element.contentParent()) { michael@0: att.mContent = static_cast(element.contentParent())->GetBlob(); michael@0: } else if (element.contentChild()) { michael@0: att.mContent = static_cast(element.contentChild())->GetBlob(); michael@0: } else { michael@0: NS_WARNING("MmsMessage: Unable to get attachment content."); michael@0: } michael@0: mAttachments.AppendElement(att); michael@0: } michael@0: michael@0: len = aData.deliveryInfo().Length(); michael@0: mDeliveryInfo.SetCapacity(len); michael@0: for (uint32_t i = 0; i < len; i++) { michael@0: MmsDeliveryInfo info; michael@0: const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i]; michael@0: michael@0: // Prepare |info.mReceiver|. michael@0: info.mReceiver = infoData.receiver(); michael@0: michael@0: // Prepare |info.mDeliveryStatus|. michael@0: nsString statusStr; michael@0: switch (infoData.deliveryStatus()) { michael@0: case eDeliveryStatus_NotApplicable: michael@0: statusStr = DELIVERY_STATUS_NOT_APPLICABLE; michael@0: break; michael@0: case eDeliveryStatus_Success: michael@0: statusStr = DELIVERY_STATUS_SUCCESS; michael@0: break; michael@0: case eDeliveryStatus_Pending: michael@0: statusStr = DELIVERY_STATUS_PENDING; michael@0: break; michael@0: case eDeliveryStatus_Error: michael@0: statusStr = DELIVERY_STATUS_ERROR; michael@0: break; michael@0: case eDeliveryStatus_Reject: michael@0: statusStr = DELIVERY_STATUS_REJECTED; michael@0: break; michael@0: case eDeliveryStatus_Manual: michael@0: statusStr = DELIVERY_STATUS_MANUAL; michael@0: break; michael@0: case eDeliveryStatus_EndGuard: michael@0: default: michael@0: MOZ_CRASH("We shouldn't get any other delivery status!"); michael@0: } michael@0: info.mDeliveryStatus = statusStr; michael@0: michael@0: // Prepare |info.mDeliveryTimestamp|. michael@0: info.mDeliveryTimestamp = infoData.deliveryTimestamp(); michael@0: michael@0: // Prepare |info.mReadStatus|. michael@0: nsString statusReadString; michael@0: switch(infoData.readStatus()) { michael@0: case eReadStatus_NotApplicable: michael@0: statusReadString = READ_STATUS_NOT_APPLICABLE; michael@0: break; michael@0: case eReadStatus_Success: michael@0: statusReadString = READ_STATUS_SUCCESS; michael@0: break; michael@0: case eReadStatus_Pending: michael@0: statusReadString = READ_STATUS_PENDING; michael@0: break; michael@0: case eReadStatus_Error: michael@0: statusReadString = READ_STATUS_ERROR; michael@0: break; michael@0: case eReadStatus_EndGuard: michael@0: default: michael@0: MOZ_CRASH("We shouldn't get any other read status!"); michael@0: } michael@0: info.mReadStatus = statusReadString; michael@0: michael@0: // Prepare |info.mReadTimestamp|. michael@0: info.mReadTimestamp = infoData.readTimestamp(); michael@0: michael@0: mDeliveryInfo.AppendElement(info); michael@0: } michael@0: } michael@0: michael@0: /* static */ nsresult michael@0: MmsMessage::Create(int32_t aId, michael@0: uint64_t aThreadId, michael@0: const nsAString& aIccId, michael@0: const nsAString& aDelivery, michael@0: const JS::Value& aDeliveryInfo, michael@0: const nsAString& aSender, michael@0: const JS::Value& aReceivers, michael@0: uint64_t aTimestamp, michael@0: uint64_t aSentTimestamp, michael@0: bool aRead, michael@0: const nsAString& aSubject, michael@0: const nsAString& aSmil, michael@0: const JS::Value& aAttachments, michael@0: uint64_t aExpiryDate, michael@0: bool aIsReadReportRequested, michael@0: JSContext* aCx, michael@0: nsIDOMMozMmsMessage** aMessage) michael@0: { michael@0: *aMessage = nullptr; michael@0: michael@0: // Set |delivery|. michael@0: DeliveryState delivery; michael@0: if (aDelivery.Equals(DELIVERY_SENT)) { michael@0: delivery = eDeliveryState_Sent; michael@0: } else if (aDelivery.Equals(DELIVERY_RECEIVED)) { michael@0: delivery = eDeliveryState_Received; michael@0: } else if (aDelivery.Equals(DELIVERY_SENDING)) { michael@0: delivery = eDeliveryState_Sending; michael@0: } else if (aDelivery.Equals(DELIVERY_NOT_DOWNLOADED)) { michael@0: delivery = eDeliveryState_NotDownloaded; michael@0: } else if (aDelivery.Equals(DELIVERY_ERROR)) { michael@0: delivery = eDeliveryState_Error; michael@0: } else { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: // Set |deliveryInfo|. michael@0: if (!aDeliveryInfo.isObject()) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: JS::Rooted deliveryInfoObj(aCx, &aDeliveryInfo.toObject()); michael@0: if (!JS_IsArrayObject(aCx, deliveryInfoObj)) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: uint32_t length; michael@0: MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length)); michael@0: michael@0: nsTArray deliveryInfo; michael@0: JS::Rooted infoJsVal(aCx); michael@0: for (uint32_t i = 0; i < length; ++i) { michael@0: if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) || michael@0: !infoJsVal.isObject()) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: MmsDeliveryInfo info; michael@0: if (!info.Init(aCx, infoJsVal)) { michael@0: return NS_ERROR_TYPE_ERR; michael@0: } michael@0: michael@0: deliveryInfo.AppendElement(info); michael@0: } michael@0: michael@0: // Set |receivers|. michael@0: if (!aReceivers.isObject()) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: JS::Rooted receiversObj(aCx, &aReceivers.toObject()); michael@0: if (!JS_IsArrayObject(aCx, receiversObj)) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length)); michael@0: michael@0: nsTArray receivers; michael@0: JS::Rooted receiverJsVal(aCx); michael@0: for (uint32_t i = 0; i < length; ++i) { michael@0: if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) || michael@0: !receiverJsVal.isString()) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: nsDependentJSString receiverStr; michael@0: receiverStr.init(aCx, receiverJsVal.toString()); michael@0: receivers.AppendElement(receiverStr); michael@0: } michael@0: michael@0: // Set |attachments|. michael@0: if (!aAttachments.isObject()) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: JS::Rooted attachmentsObj(aCx, &aAttachments.toObject()); michael@0: if (!JS_IsArrayObject(aCx, attachmentsObj)) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: nsTArray attachments; michael@0: MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length)); michael@0: michael@0: JS::Rooted attachmentJsVal(aCx); michael@0: for (uint32_t i = 0; i < length; ++i) { michael@0: if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) { michael@0: return NS_ERROR_INVALID_ARG; michael@0: } michael@0: michael@0: MmsAttachment attachment; michael@0: if (!attachment.Init(aCx, attachmentJsVal)) { michael@0: return NS_ERROR_TYPE_ERR; michael@0: } michael@0: michael@0: attachments.AppendElement(attachment); michael@0: } michael@0: michael@0: nsCOMPtr message = new MmsMessage(aId, michael@0: aThreadId, michael@0: aIccId, michael@0: delivery, michael@0: deliveryInfo, michael@0: aSender, michael@0: receivers, michael@0: aTimestamp, michael@0: aSentTimestamp, michael@0: aRead, michael@0: aSubject, michael@0: aSmil, michael@0: attachments, michael@0: aExpiryDate, michael@0: aIsReadReportRequested); michael@0: message.forget(aMessage); michael@0: return NS_OK; michael@0: } michael@0: michael@0: bool michael@0: MmsMessage::GetData(ContentParent* aParent, michael@0: mobilemessage::MmsMessageData& aData) michael@0: { michael@0: NS_ASSERTION(aParent, "aParent is null"); michael@0: michael@0: aData.id() = mId; michael@0: aData.threadId() = mThreadId; michael@0: aData.iccId() = mIccId; michael@0: aData.delivery() = mDelivery; michael@0: aData.sender().Assign(mSender); michael@0: aData.receivers() = mReceivers; michael@0: aData.timestamp() = mTimestamp; michael@0: aData.sentTimestamp() = mSentTimestamp; michael@0: aData.read() = mRead; michael@0: aData.subject() = mSubject; michael@0: aData.smil() = mSmil; michael@0: aData.expiryDate() = mExpiryDate; michael@0: aData.readReportRequested() = mReadReportRequested; michael@0: michael@0: aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length()); michael@0: for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) { michael@0: MmsDeliveryInfoData infoData; michael@0: const MmsDeliveryInfo &info = mDeliveryInfo[i]; michael@0: michael@0: // Prepare |infoData.mReceiver|. michael@0: infoData.receiver().Assign(info.mReceiver); michael@0: michael@0: // Prepare |infoData.mDeliveryStatus|. michael@0: DeliveryStatus status; michael@0: if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) { michael@0: status = eDeliveryStatus_NotApplicable; michael@0: } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) { michael@0: status = eDeliveryStatus_Success; michael@0: } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) { michael@0: status = eDeliveryStatus_Pending; michael@0: } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) { michael@0: status = eDeliveryStatus_Error; michael@0: } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) { michael@0: status = eDeliveryStatus_Reject; michael@0: } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) { michael@0: status = eDeliveryStatus_Manual; michael@0: } else { michael@0: return false; michael@0: } michael@0: infoData.deliveryStatus() = status; michael@0: michael@0: // Prepare |infoData.mDeliveryTimestamp|. michael@0: infoData.deliveryTimestamp() = info.mDeliveryTimestamp; michael@0: michael@0: // Prepare |infoData.mReadStatus|. michael@0: ReadStatus readStatus; michael@0: if (info.mReadStatus.Equals(READ_STATUS_NOT_APPLICABLE)) { michael@0: readStatus = eReadStatus_NotApplicable; michael@0: } else if (info.mReadStatus.Equals(READ_STATUS_SUCCESS)) { michael@0: readStatus = eReadStatus_Success; michael@0: } else if (info.mReadStatus.Equals(READ_STATUS_PENDING)) { michael@0: readStatus = eReadStatus_Pending; michael@0: } else if (info.mReadStatus.Equals(READ_STATUS_ERROR)) { michael@0: readStatus = eReadStatus_Error; michael@0: } else { michael@0: return false; michael@0: } michael@0: infoData.readStatus() = readStatus; michael@0: michael@0: // Prepare |infoData.mReadTimestamp|. michael@0: infoData.readTimestamp() = info.mReadTimestamp; michael@0: michael@0: aData.deliveryInfo().AppendElement(infoData); michael@0: } michael@0: michael@0: aData.attachments().SetCapacity(mAttachments.Length()); michael@0: for (uint32_t i = 0; i < mAttachments.Length(); i++) { michael@0: MmsAttachmentData mma; michael@0: const Attachment &element = mAttachments[i]; michael@0: mma.id().Assign(element.id); michael@0: mma.location().Assign(element.location); michael@0: michael@0: // This is a workaround. Sometimes the blob we get from the database michael@0: // doesn't have a valid last modified date, making the ContentParent michael@0: // send a "Mystery Blob" to the ContentChild. Attempting to get the michael@0: // last modified date of blob can force that value to be initialized. michael@0: nsDOMFileBase* file = static_cast(element.content.get()); michael@0: if (file->IsDateUnknown()) { michael@0: uint64_t date; michael@0: if (NS_FAILED(file->GetMozLastModifiedDate(&date))) { michael@0: NS_WARNING("Failed to get last modified date!"); michael@0: } michael@0: } michael@0: michael@0: mma.contentParent() = aParent->GetOrCreateActorForBlob(element.content); michael@0: if (!mma.contentParent()) { michael@0: return false; michael@0: } michael@0: aData.attachments().AppendElement(mma); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetType(nsAString& aType) michael@0: { michael@0: aType = NS_LITERAL_STRING("mms"); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetId(int32_t* aId) michael@0: { michael@0: *aId = mId; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetThreadId(uint64_t* aThreadId) michael@0: { michael@0: *aThreadId = mThreadId; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetIccId(nsAString& aIccId) michael@0: { michael@0: aIccId = mIccId; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetDelivery(nsAString& aDelivery) michael@0: { michael@0: switch (mDelivery) { michael@0: case eDeliveryState_Received: michael@0: aDelivery = DELIVERY_RECEIVED; michael@0: break; michael@0: case eDeliveryState_Sending: michael@0: aDelivery = DELIVERY_SENDING; michael@0: break; michael@0: case eDeliveryState_Sent: michael@0: aDelivery = DELIVERY_SENT; michael@0: break; michael@0: case eDeliveryState_Error: michael@0: aDelivery = DELIVERY_ERROR; michael@0: break; michael@0: case eDeliveryState_NotDownloaded: michael@0: aDelivery = DELIVERY_NOT_DOWNLOADED; michael@0: break; michael@0: case eDeliveryState_Unknown: michael@0: case eDeliveryState_EndGuard: michael@0: default: michael@0: MOZ_CRASH("We shouldn't get any other delivery state!"); michael@0: } michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle aDeliveryInfo) michael@0: { michael@0: // TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage michael@0: // to return a more correct value. Ex, if .delivery = 'received', we should michael@0: // also make .deliveryInfo = null, since the .deliveryInfo is useless. michael@0: uint32_t length = mDeliveryInfo.Length(); michael@0: if (length == 0) { michael@0: aDeliveryInfo.setNull(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!ToJSValue(aCx, mDeliveryInfo, aDeliveryInfo)) { michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: } michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetSender(nsAString& aSender) michael@0: { michael@0: aSender = mSender; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle aReceivers) michael@0: { michael@0: JS::Rooted reveiversObj(aCx); michael@0: nsresult rv = nsTArrayToJSArray(aCx, mReceivers, reveiversObj.address()); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: aReceivers.setObject(*reveiversObj); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp) michael@0: { michael@0: *aTimestamp = mTimestamp; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp) michael@0: { michael@0: *aSentTimestamp = mSentTimestamp; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetRead(bool* aRead) michael@0: { michael@0: *aRead = mRead; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetSubject(nsAString& aSubject) michael@0: { michael@0: aSubject = mSubject; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetSmil(nsAString& aSmil) michael@0: { michael@0: aSmil = mSmil; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle aAttachments) michael@0: { michael@0: uint32_t length = mAttachments.Length(); michael@0: michael@0: JS::Rooted attachments( michael@0: aCx, JS_NewArrayObject(aCx, length)); michael@0: NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY); michael@0: michael@0: for (uint32_t i = 0; i < length; ++i) { michael@0: const Attachment &attachment = mAttachments[i]; michael@0: michael@0: JS::Rooted attachmentObj( michael@0: aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr())); michael@0: NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY); michael@0: michael@0: JS::Rooted tmpJsStr(aCx); michael@0: michael@0: // Get |attachment.mId|. michael@0: tmpJsStr = JS_NewUCStringCopyN(aCx, michael@0: attachment.id.get(), michael@0: attachment.id.Length()); michael@0: NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY); michael@0: michael@0: if (!JS_DefineProperty(aCx, attachmentObj, "id", tmpJsStr, JSPROP_ENUMERATE)) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: // Get |attachment.mLocation|. michael@0: tmpJsStr = JS_NewUCStringCopyN(aCx, michael@0: attachment.location.get(), michael@0: attachment.location.Length()); michael@0: NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY); michael@0: michael@0: if (!JS_DefineProperty(aCx, attachmentObj, "location", tmpJsStr, JSPROP_ENUMERATE)) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: // Get |attachment.mContent|. michael@0: JS::Rooted tmpJsVal(aCx); michael@0: nsresult rv = nsContentUtils::WrapNative(aCx, michael@0: attachment.content, michael@0: &NS_GET_IID(nsIDOMBlob), michael@0: &tmpJsVal); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: if (!JS_DefineProperty(aCx, attachmentObj, "content", tmpJsVal, JSPROP_ENUMERATE)) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: if (!JS_SetElement(aCx, attachments, i, attachmentObj)) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: } michael@0: michael@0: aAttachments.setObject(*attachments); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetExpiryDate(DOMTimeStamp* aExpiryDate) michael@0: { michael@0: *aExpiryDate = mExpiryDate; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MmsMessage::GetReadReportRequested(bool* aReadReportRequested) michael@0: { michael@0: *aReadReportRequested = mReadReportRequested; michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla