Bug 859764 - Part 1.1: Turn IDL Implementation into Internal-Only Interface. r=echen, r=smaug

--HG--
rename : dom/mobilemessage/MmsMessage.cpp => dom/mobilemessage/MmsMessageInternal.cpp
rename : dom/mobilemessage/MmsMessage.h => dom/mobilemessage/MmsMessageInternal.h
rename : dom/mobilemessage/MobileMessageThread.cpp => dom/mobilemessage/MobileMessageThreadInternal.cpp
rename : dom/mobilemessage/MobileMessageThread.h => dom/mobilemessage/MobileMessageThreadInternal.h
rename : dom/mobilemessage/SmsMessage.cpp => dom/mobilemessage/SmsMessageInternal.cpp
rename : dom/mobilemessage/SmsMessage.h => dom/mobilemessage/SmsMessageInternal.h
rename : dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl => dom/mobilemessage/interfaces/nsIMmsMessage.idl
rename : dom/mobilemessage/interfaces/nsIDOMMozMobileMessageThread.idl => dom/mobilemessage/interfaces/nsIMobileMessageThread.idl
rename : dom/mobilemessage/interfaces/nsIDOMMozSmsMessage.idl => dom/mobilemessage/interfaces/nsISmsMessage.idl
This commit is contained in:
Bevis Tseng 2015-10-19 19:46:08 +08:00
Родитель 64960a5cce
Коммит 05e37667fb
15 изменённых файлов: 295 добавлений и 365 удалений

Просмотреть файл

@ -100,10 +100,6 @@
#include "nsWrapperCacheInlines.h"
#include "mozilla/dom/HTMLCollectionBinding.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsIDOMMozMmsMessage.h"
#include "nsIDOMMozMobileMessageThread.h"
#ifdef MOZ_B2G_FM
#include "FMRadio.h"
#endif
@ -243,15 +239,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -651,18 +638,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSSupportsRule)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
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(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_END

Просмотреть файл

@ -32,10 +32,6 @@ DOMCI_CLASS(XULTreeBuilder)
DOMCI_CLASS(CSSMozDocumentRule)
DOMCI_CLASS(CSSSupportsRule)
DOMCI_CLASS(MozSmsMessage)
DOMCI_CLASS(MozMmsMessage)
DOMCI_CLASS(MozMobileMessageThread)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)

Просмотреть файл

@ -1977,12 +1977,10 @@ addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
addExternalIface('MozControllers', nativeType='nsIControllers')
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
addExternalIface('MozMmsMessage')
addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
notflattened=True)
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozSmsMessage')
addExternalIface('MozTreeView', nativeType='nsITreeView',
headerFile='nsITreeView.h', notflattened=True)
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')

Просмотреть файл

@ -4,7 +4,8 @@
* 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 "MmsMessageInternal.h"
#include "nsIDOMClassInfo.h"
#include "jsapi.h" // For JS_IsArrayObject, JS_GetElement, etc.
#include "nsJSUtils.h"
@ -19,21 +20,34 @@
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/dom/ipc/BlobParent.h"
using namespace mozilla::dom::mobilemessage;
namespace mozilla {
namespace dom {
namespace mobilemessage {
NS_INTERFACE_MAP_BEGIN(MmsMessage)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMmsMessage)
NS_IMPL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MmsMessageInternal)
for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttachments[i].mContent)
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MmsMessageInternal)
for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttachments[i].mContent)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MmsMessageInternal)
NS_INTERFACE_MAP_ENTRY(nsIMmsMessage)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMmsMessage)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(MmsMessage)
NS_IMPL_RELEASE(MmsMessage)
NS_IMPL_CYCLE_COLLECTING_ADDREF(MmsMessageInternal)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MmsMessageInternal)
MmsMessage::MmsMessage(int32_t aId,
MmsMessageInternal::MmsMessageInternal(int32_t aId,
uint64_t aThreadId,
const nsAString& aIccId,
DeliveryState aDelivery,
@ -45,7 +59,7 @@ MmsMessage::MmsMessage(int32_t aId,
bool aRead,
const nsAString& aSubject,
const nsAString& aSmil,
const nsTArray<Attachment>& aAttachments,
const nsTArray<MmsAttachment>& aAttachments,
uint64_t aExpiryDate,
bool aReadReportRequested)
: mId(aId),
@ -66,7 +80,7 @@ MmsMessage::MmsMessage(int32_t aId,
{
}
MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
MmsMessageInternal::MmsMessageInternal(const MmsMessageData& aData)
: mId(aData.id())
, mThreadId(aData.threadId())
, mIccId(aData.iccId())
@ -171,7 +185,7 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
}
/* static */ nsresult
MmsMessage::Create(int32_t aId,
MmsMessageInternal::Create(int32_t aId,
uint64_t aThreadId,
const nsAString& aIccId,
const nsAString& aDelivery,
@ -187,7 +201,7 @@ MmsMessage::Create(int32_t aId,
uint64_t aExpiryDate,
bool aIsReadReportRequested,
JSContext* aCx,
nsIDOMMozMmsMessage** aMessage)
nsIMmsMessage** aMessage)
{
*aMessage = nullptr;
@ -281,7 +295,7 @@ MmsMessage::Create(int32_t aId,
return NS_ERROR_INVALID_ARG;
}
nsTArray<Attachment> attachments;
nsTArray<MmsAttachment> attachments;
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
JS::Rooted<JS::Value> attachmentJsVal(aCx);
@ -295,10 +309,13 @@ MmsMessage::Create(int32_t aId,
return NS_ERROR_TYPE_ERR;
}
NS_ENSURE_TRUE(attachment.mContent, NS_ERROR_TYPE_ERR);
attachments.AppendElement(attachment);
}
nsCOMPtr<nsIDOMMozMmsMessage> message = new MmsMessage(aId,
nsCOMPtr<nsIMmsMessage> message =
new MmsMessageInternal(aId,
aThreadId,
aIccId,
delivery,
@ -318,8 +335,8 @@ MmsMessage::Create(int32_t aId,
}
bool
MmsMessage::GetData(ContentParent* aParent,
mobilemessage::MmsMessageData& aData)
MmsMessageInternal::GetData(ContentParent* aParent,
MmsMessageData& aData)
{
NS_ASSERTION(aParent, "aParent is null");
@ -391,15 +408,15 @@ MmsMessage::GetData(ContentParent* aParent,
aData.attachments().SetCapacity(mAttachments.Length());
for (uint32_t i = 0; i < mAttachments.Length(); i++) {
MmsAttachmentData mma;
const Attachment &element = mAttachments[i];
mma.id().Assign(element.id);
mma.location().Assign(element.location);
const MmsAttachment &element = mAttachments[i];
mma.id().Assign(element.mId);
mma.location().Assign(element.mLocation);
// This is a workaround. Sometimes the blob we get from the database
// doesn't have a valid last modified date, making the ContentParent
// send a "Mystery Blob" to the ContentChild. Attempting to get the
// last modified date of blob can force that value to be initialized.
RefPtr<BlobImpl> impl = element.content->Impl();
RefPtr<BlobImpl> impl = element.mContent->Impl();
if (impl && impl->IsDateUnknown()) {
ErrorResult rv;
impl->GetLastModified(rv);
@ -409,7 +426,7 @@ MmsMessage::GetData(ContentParent* aParent,
}
}
mma.contentParent() = aParent->GetOrCreateActorForBlob(element.content);
mma.contentParent() = aParent->GetOrCreateActorForBlob(element.mContent);
if (!mma.contentParent()) {
return false;
}
@ -420,35 +437,35 @@ MmsMessage::GetData(ContentParent* aParent,
}
NS_IMETHODIMP
MmsMessage::GetType(nsAString& aType)
MmsMessageInternal::GetType(nsAString& aType)
{
aType = NS_LITERAL_STRING("mms");
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetId(int32_t* aId)
MmsMessageInternal::GetId(int32_t* aId)
{
*aId = mId;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetThreadId(uint64_t* aThreadId)
MmsMessageInternal::GetThreadId(uint64_t* aThreadId)
{
*aThreadId = mThreadId;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetIccId(nsAString& aIccId)
MmsMessageInternal::GetIccId(nsAString& aIccId)
{
aIccId = mIccId;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetDelivery(nsAString& aDelivery)
MmsMessageInternal::GetDelivery(nsAString& aDelivery)
{
switch (mDelivery) {
case eDeliveryState_Received:
@ -476,7 +493,7 @@ MmsMessage::GetDelivery(nsAString& aDelivery)
}
NS_IMETHODIMP
MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDeliveryInfo)
MmsMessageInternal::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<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
@ -495,14 +512,14 @@ MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDelive
}
NS_IMETHODIMP
MmsMessage::GetSender(nsAString& aSender)
MmsMessageInternal::GetSender(nsAString& aSender)
{
aSender = mSender;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
MmsMessageInternal::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
{
JS::Rooted<JSObject*> receiversObj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
@ -513,116 +530,85 @@ MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers
}
NS_IMETHODIMP
MmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
MmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
{
*aTimestamp = mTimestamp;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
MmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
{
*aSentTimestamp = mSentTimestamp;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetRead(bool* aRead)
MmsMessageInternal::GetRead(bool* aRead)
{
*aRead = mRead;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetSubject(nsAString& aSubject)
MmsMessageInternal::GetSubject(nsAString& aSubject)
{
aSubject = mSubject;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetSmil(nsAString& aSmil)
MmsMessageInternal::GetSmil(nsAString& aSmil)
{
aSmil = mSmil;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
MmsMessageInternal::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
{
uint32_t length = mAttachments.Length();
JS::Rooted<JSObject*> attachments(
aCx, JS_NewArrayObject(aCx, length));
NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < length; ++i) {
const Attachment &attachment = mAttachments[i];
JS::Rooted<JSObject*> attachmentObj(aCx, JS_NewPlainObject(aCx));
NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JSString*> tmpJsStr(aCx);
// Get |attachment.mId|.
tmpJsStr = JS_NewUCStringCopyN(aCx,
attachment.id.get(),
attachment.id.Length());
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
if (!JS_DefineProperty(aCx, attachmentObj, "id", tmpJsStr, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
if (length == 0) {
aAttachments.setNull();
return NS_OK;
}
// Get |attachment.mLocation|.
tmpJsStr = JS_NewUCStringCopyN(aCx,
attachment.location.get(),
attachment.location.Length());
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
if (!JS_DefineProperty(aCx, attachmentObj, "location", tmpJsStr, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
// Get |attachment.mContent|.
// Duplicating the File with the correct parent object.
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
// Duplicating the Blob with the correct parent object.
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
MOZ_ASSERT(global);
RefPtr<Blob> newBlob = Blob::Create(global, attachment.content->Impl());
JS::Rooted<JS::Value> val(aCx);
if (!ToJSValue(aCx, newBlob, &val)) {
return NS_ERROR_FAILURE;
nsTArray<MmsAttachment> result;
for (uint32_t i = 0; i < length; i++) {
MmsAttachment attachment;
const MmsAttachment &element = mAttachments[i];
attachment.mId = element.mId;
attachment.mLocation = element.mLocation;
attachment.mContent = Blob::Create(global, element.mContent->Impl());
result.AppendElement(attachment);
}
if (!JS_DefineProperty(aCx, attachmentObj, "content", val, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
if (!ToJSValue(aCx, result, aAttachments)) {
JS_ClearPendingException(aCx);
return NS_ERROR_TYPE_ERR;
}
if (!JS_DefineElement(aCx, attachments, i, attachmentObj, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
}
aAttachments.setObject(*attachments);
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetExpiryDate(DOMTimeStamp* aExpiryDate)
MmsMessageInternal::GetExpiryDate(DOMTimeStamp* aExpiryDate)
{
*aExpiryDate = mExpiryDate;
return NS_OK;
}
NS_IMETHODIMP
MmsMessage::GetReadReportRequested(bool* aReadReportRequested)
MmsMessageInternal::GetReadReportRequested(bool* aReadReportRequested)
{
*aReadReportRequested = mReadReportRequested;
return NS_OK;
}
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -4,48 +4,35 @@
* 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
#ifndef mozilla_dom_mobilemessage_MmsMessageInternal_h
#define mozilla_dom_mobilemessage_MmsMessageInternal_h
#include "nsIDOMMozMmsMessage.h"
#include "nsIMmsMessage.h"
#include "nsString.h"
#include "mozilla/dom/mobilemessage/Types.h"
#include "mozilla/dom/MozMmsMessageBinding.h"
#include "mozilla/dom/MmsMessageBinding.h"
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace dom {
class ContentParent;
class Blob;
struct MmsAttachment;
namespace mobilemessage {
class MmsMessageData;
} // namespace mobilemessage
class ContentParent;
class MmsMessage final : public nsIDOMMozMmsMessage
class MmsMessageInternal final : public nsIMmsMessage
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZMMSMESSAGE
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
NS_DECL_NSIMMSMESSAGE
// If this is changed, change the WebIDL dictionary as well.
struct Attachment final
{
RefPtr<Blob> content;
nsString id;
nsString location;
explicit Attachment(const MmsAttachment& aAttachment) :
content(aAttachment.mContent),
id(aAttachment.mId),
location(aAttachment.mLocation)
{}
};
MmsMessage(int32_t aId,
MmsMessageInternal(int32_t aId,
uint64_t aThreadId,
const nsAString& aIccId,
mobilemessage::DeliveryState aDelivery,
@ -57,11 +44,11 @@ public:
bool aRead,
const nsAString& aSubject,
const nsAString& aSmil,
const nsTArray<Attachment>& aAttachments,
const nsTArray<MmsAttachment>& aAttachments,
uint64_t aExpiryDate,
bool aReadReportRequested);
explicit MmsMessage(const mobilemessage::MmsMessageData& aData);
explicit MmsMessageInternal(const MmsMessageData& aData);
static nsresult Create(int32_t aId,
uint64_t aThreadId,
@ -79,14 +66,14 @@ public:
uint64_t aExpiryDate,
bool aReadReportRequested,
JSContext* aCx,
nsIDOMMozMmsMessage** aMessage);
nsIMmsMessage** aMessage);
bool GetData(ContentParent* aParent,
mobilemessage::MmsMessageData& aData);
MmsMessageData& aData);
private:
~MmsMessage() {}
~MmsMessageInternal() {}
int32_t mId;
uint64_t mThreadId;
@ -100,12 +87,13 @@ private:
bool mRead;
nsString mSubject;
nsString mSmil;
nsTArray<Attachment> mAttachments;
nsTArray<MmsAttachment> mAttachments;
uint64_t mExpiryDate;
bool mReadReportRequested;
};
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_MmsMessage_h
#endif // mozilla_dom_mobilemessage_MmsMessageInternal_h

Просмотреть файл

@ -4,29 +4,21 @@
* 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 "MobileMessageThread.h"
#include "MobileMessageThreadInternal.h"
#include "nsIDOMClassInfo.h"
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
#include "nsJSUtils.h" // For nsAutoJSString
#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
using namespace mozilla::dom::mobilemessage;
namespace mozilla {
namespace dom {
namespace mobilemessage {
NS_INTERFACE_MAP_BEGIN(MobileMessageThread)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileMessageThread)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileMessageThread)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(MobileMessageThread)
NS_IMPL_RELEASE(MobileMessageThread)
NS_IMPL_ISUPPORTS(MobileMessageThreadInternal, nsIMobileMessageThread)
/* static */ nsresult
MobileMessageThread::Create(uint64_t aId,
MobileMessageThreadInternal::Create(uint64_t aId,
const JS::Value& aParticipants,
uint64_t aTimestamp,
const nsAString& aLastMessageSubject,
@ -34,7 +26,7 @@ MobileMessageThread::Create(uint64_t aId,
uint64_t aUnreadCount,
const nsAString& aLastMessageType,
JSContext* aCx,
nsIDOMMozMobileMessageThread** aThread)
nsIMobileMessageThread** aThread)
{
*aThread = nullptr;
@ -97,12 +89,13 @@ MobileMessageThread::Create(uint64_t aId,
data.lastMessageType() = lastMessageType;
}
nsCOMPtr<nsIDOMMozMobileMessageThread> thread = new MobileMessageThread(data);
nsCOMPtr<nsIMobileMessageThread> thread =
new MobileMessageThreadInternal(data);
thread.forget(aThread);
return NS_OK;
}
MobileMessageThread::MobileMessageThread(uint64_t aId,
MobileMessageThreadInternal::MobileMessageThreadInternal(uint64_t aId,
const nsTArray<nsString>& aParticipants,
uint64_t aTimestamp,
const nsString& aLastMessageSubject,
@ -115,42 +108,42 @@ MobileMessageThread::MobileMessageThread(uint64_t aId,
MOZ_ASSERT(aParticipants.Length());
}
MobileMessageThread::MobileMessageThread(const ThreadData& aData)
MobileMessageThreadInternal::MobileMessageThreadInternal(const ThreadData& aData)
: mData(aData)
{
MOZ_ASSERT(aData.participants().Length());
}
NS_IMETHODIMP
MobileMessageThread::GetId(uint64_t* aId)
MobileMessageThreadInternal::GetId(uint64_t* aId)
{
*aId = mData.id();
return NS_OK;
}
NS_IMETHODIMP
MobileMessageThread::GetLastMessageSubject(nsAString& aLastMessageSubject)
MobileMessageThreadInternal::GetLastMessageSubject(nsAString& aLastMessageSubject)
{
aLastMessageSubject = mData.lastMessageSubject();
return NS_OK;
}
NS_IMETHODIMP
MobileMessageThread::GetBody(nsAString& aBody)
MobileMessageThreadInternal::GetBody(nsAString& aBody)
{
aBody = mData.body();
return NS_OK;
}
NS_IMETHODIMP
MobileMessageThread::GetUnreadCount(uint64_t* aUnreadCount)
MobileMessageThreadInternal::GetUnreadCount(uint64_t* aUnreadCount)
{
*aUnreadCount = mData.unreadCount();
return NS_OK;
}
NS_IMETHODIMP
MobileMessageThread::GetParticipants(JSContext* aCx,
MobileMessageThreadInternal::GetParticipants(JSContext* aCx,
JS::MutableHandle<JS::Value> aParticipants)
{
JS::Rooted<JSObject*> obj(aCx);
@ -163,14 +156,14 @@ MobileMessageThread::GetParticipants(JSContext* aCx,
}
NS_IMETHODIMP
MobileMessageThread::GetTimestamp(DOMTimeStamp* aDate)
MobileMessageThreadInternal::GetTimestamp(DOMTimeStamp* aDate)
{
*aDate = mData.timestamp();
return NS_OK;
}
NS_IMETHODIMP
MobileMessageThread::GetLastMessageType(nsAString& aLastMessageType)
MobileMessageThreadInternal::GetLastMessageType(nsAString& aLastMessageType)
{
switch (mData.lastMessageType()) {
case eMessageType_SMS:
@ -187,5 +180,6 @@ MobileMessageThread::GetLastMessageType(nsAString& aLastMessageType)
return NS_OK;
}
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -4,27 +4,28 @@
* 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_MobileMessageThread_h
#define mozilla_dom_mobilemessage_MobileMessageThread_h
#ifndef mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
#define mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
#include "mozilla/Attributes.h"
#include "mozilla/dom/mobilemessage/SmsTypes.h"
#include "nsIDOMMozMobileMessageThread.h"
#include "nsIMobileMessageThread.h"
#include "nsString.h"
namespace mozilla {
namespace dom {
namespace mobilemessage {
class MobileMessageThread final : public nsIDOMMozMobileMessageThread
class ThreadData;
class MobileMessageThreadInternal final : public nsIMobileMessageThread
{
private:
typedef mobilemessage::ThreadData ThreadData;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZMOBILEMESSAGETHREAD
NS_DECL_NSIMOBILEMESSAGETHREAD
MobileMessageThread(uint64_t aId,
MobileMessageThreadInternal(uint64_t aId,
const nsTArray<nsString>& aParticipants,
uint64_t aTimestamp,
const nsString& aLastMessageSubject,
@ -32,7 +33,7 @@ public:
uint64_t aUnreadCount,
mobilemessage::MessageType aLastMessageType);
explicit MobileMessageThread(const ThreadData& aData);
explicit MobileMessageThreadInternal(const ThreadData& aData);
static nsresult Create(uint64_t aId,
const JS::Value& aParticipants,
@ -42,20 +43,21 @@ public:
uint64_t aUnreadCount,
const nsAString& aLastMessageType,
JSContext* aCx,
nsIDOMMozMobileMessageThread** aThread);
nsIMobileMessageThread** aThread);
const ThreadData& GetData() const { return mData; }
private:
~MobileMessageThread() {}
~MobileMessageThreadInternal() {}
// Don't try to use the default constructor.
MobileMessageThread() = delete;
MobileMessageThreadInternal() = delete;
ThreadData mData;
};
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_MobileMessageThread_h
#endif // mozilla_dom_mobilemessage_MobileMessageThreadInternal_h

Просмотреть файл

@ -4,25 +4,17 @@
* 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 "SmsMessage.h"
#include "SmsMessageInternal.h"
#include "nsIDOMClassInfo.h"
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
using namespace mozilla::dom::mobilemessage;
namespace mozilla {
namespace dom {
namespace mobilemessage {
NS_INTERFACE_MAP_BEGIN(SmsMessage)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsMessage)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsMessage)
NS_INTERFACE_MAP_END
NS_IMPL_ISUPPORTS(SmsMessageInternal, nsISmsMessage)
NS_IMPL_ADDREF(SmsMessage)
NS_IMPL_RELEASE(SmsMessage)
SmsMessage::SmsMessage(int32_t aId,
SmsMessageInternal::SmsMessageInternal(int32_t aId,
uint64_t aThreadId,
const nsString& aIccId,
DeliveryState aDelivery,
@ -41,13 +33,13 @@ SmsMessage::SmsMessage(int32_t aId,
{
}
SmsMessage::SmsMessage(const SmsMessageData& aData)
SmsMessageInternal::SmsMessageInternal(const SmsMessageData& aData)
: mData(aData)
{
}
/* static */ nsresult
SmsMessage::Create(int32_t aId,
SmsMessageInternal::Create(int32_t aId,
uint64_t aThreadId,
const nsAString& aIccId,
const nsAString& aDelivery,
@ -61,7 +53,7 @@ SmsMessage::Create(int32_t aId,
uint64_t aDeliveryTimestamp,
bool aRead,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
nsISmsMessage** aMessage)
{
*aMessage = nullptr;
@ -123,47 +115,47 @@ SmsMessage::Create(int32_t aId,
// Set |deliveryTimestamp|.
data.deliveryTimestamp() = aDeliveryTimestamp;
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(data);
nsCOMPtr<nsISmsMessage> message = new SmsMessageInternal(data);
message.swap(*aMessage);
return NS_OK;
}
const SmsMessageData&
SmsMessage::GetData() const
SmsMessageInternal::GetData() const
{
return mData;
}
NS_IMETHODIMP
SmsMessage::GetType(nsAString& aType)
SmsMessageInternal::GetType(nsAString& aType)
{
aType = NS_LITERAL_STRING("sms");
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetId(int32_t* aId)
SmsMessageInternal::GetId(int32_t* aId)
{
*aId = mData.id();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetThreadId(uint64_t* aThreadId)
SmsMessageInternal::GetThreadId(uint64_t* aThreadId)
{
*aThreadId = mData.threadId();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetIccId(nsAString& aIccId)
SmsMessageInternal::GetIccId(nsAString& aIccId)
{
aIccId = mData.iccId();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetDelivery(nsAString& aDelivery)
SmsMessageInternal::GetDelivery(nsAString& aDelivery)
{
switch (mData.delivery()) {
case eDeliveryState_Received:
@ -188,7 +180,7 @@ SmsMessage::GetDelivery(nsAString& aDelivery)
}
NS_IMETHODIMP
SmsMessage::GetDeliveryStatus(nsAString& aDeliveryStatus)
SmsMessageInternal::GetDeliveryStatus(nsAString& aDeliveryStatus)
{
switch (mData.deliveryStatus()) {
case eDeliveryStatus_NotApplicable:
@ -212,28 +204,28 @@ SmsMessage::GetDeliveryStatus(nsAString& aDeliveryStatus)
}
NS_IMETHODIMP
SmsMessage::GetSender(nsAString& aSender)
SmsMessageInternal::GetSender(nsAString& aSender)
{
aSender = mData.sender();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetReceiver(nsAString& aReceiver)
SmsMessageInternal::GetReceiver(nsAString& aReceiver)
{
aReceiver = mData.receiver();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetBody(nsAString& aBody)
SmsMessageInternal::GetBody(nsAString& aBody)
{
aBody = mData.body();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetMessageClass(nsAString& aMessageClass)
SmsMessageInternal::GetMessageClass(nsAString& aMessageClass)
{
switch (mData.messageClass()) {
case eMessageClass_Normal:
@ -259,32 +251,33 @@ SmsMessage::GetMessageClass(nsAString& aMessageClass)
}
NS_IMETHODIMP
SmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
SmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
{
*aTimestamp = mData.timestamp();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
SmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
{
*aSentTimestamp = mData.sentTimestamp();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetDeliveryTimestamp(DOMTimeStamp* aDate)
SmsMessageInternal::GetDeliveryTimestamp(DOMTimeStamp* aDate)
{
*aDate = mData.deliveryTimestamp();
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetRead(bool* aRead)
SmsMessageInternal::GetRead(bool* aRead)
{
*aRead = mData.read();
return NS_OK;
}
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -4,25 +4,28 @@
* 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_SmsMessage_h
#define mozilla_dom_mobilemessage_SmsMessage_h
#ifndef mozilla_dom_mobilemessage_SmsMessageInternal_h
#define mozilla_dom_mobilemessage_SmsMessageInternal_h
#include "mozilla/dom/mobilemessage/SmsTypes.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsISmsMessage.h"
#include "nsString.h"
#include "mozilla/dom/mobilemessage/Types.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace dom {
namespace mobilemessage {
class SmsMessage final : public nsIDOMMozSmsMessage
class SmsMessageData;
class SmsMessageInternal final : public nsISmsMessage
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZSMSMESSAGE
NS_DECL_NSISMSMESSAGE
SmsMessage(int32_t aId,
SmsMessageInternal(int32_t aId,
uint64_t aThreadId,
const nsString& aIccId,
mobilemessage::DeliveryState aDelivery,
@ -36,7 +39,7 @@ public:
uint64_t aDeliveryTimestamp,
bool aRead);
explicit SmsMessage(const mobilemessage::SmsMessageData& aData);
explicit SmsMessageInternal(const SmsMessageData& aData);
static nsresult Create(int32_t aId,
uint64_t aThreadId,
@ -52,19 +55,20 @@ public:
uint64_t aDeliveryTimestamp,
bool aRead,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage);
const mobilemessage::SmsMessageData& GetData() const;
nsISmsMessage** aMessage);
const SmsMessageData& GetData() const;
private:
~SmsMessage() {}
~SmsMessageInternal() {}
// Don't try to use the default constructor.
SmsMessage();
SmsMessageInternal();
mobilemessage::SmsMessageData mData;
SmsMessageData mData;
};
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_SmsMessage_h
#endif // mozilla_dom_mobilemessage_SmsMessageInternal_h

Просмотреть файл

@ -6,14 +6,14 @@
XPIDL_SOURCES += [
'nsIDeletedMessageInfo.idl',
'nsIDOMMozMmsMessage.idl',
'nsIDOMMozMobileMessageThread.idl',
'nsIDOMMozSmsMessage.idl',
'nsIMmsMessage.idl',
'nsIMmsService.idl',
'nsIMobileMessageCallback.idl',
'nsIMobileMessageCursorCallback.idl',
'nsIMobileMessageDatabaseService.idl',
'nsIMobileMessageService.idl',
'nsIMobileMessageThread.idl',
'nsISmsMessage.idl',
'nsISmsService.idl',
'nsIWapPushApplication.idl',
]

Просмотреть файл

@ -7,8 +7,8 @@
interface nsIDOMBlob;
[scriptable, builtinclass, uuid(f41d7400-0026-11e3-829d-eb7459c03810)]
interface nsIDOMMozMmsMessage : nsISupports
[scriptable, builtinclass, uuid(cd2ff09a-8853-11e5-ac49-0f655992cef6)]
interface nsIMmsMessage : nsISupports
{
/**
* |type| is always "mms".

Просмотреть файл

@ -5,8 +5,8 @@
#include "domstubs.idl"
#include "nsISupports.idl"
[scriptable, builtinclass, uuid(525ad3a6-59a9-11e3-bdc3-836486cb58be)]
interface nsIDOMMozMobileMessageThread : nsISupports
[scriptable, builtinclass, uuid(dd6794cc-8853-11e5-89b4-278852073d45)]
interface nsIMobileMessageThread : nsISupports
{
// Unique identity of the thread.
readonly attribute unsigned long long id;

Просмотреть файл

@ -5,8 +5,8 @@
#include "domstubs.idl"
#include "nsISupports.idl"
[scriptable, builtinclass, uuid(fc8153d2-0026-11e3-bf31-8b0c1d5e7638)]
interface nsIDOMMozSmsMessage : nsISupports
[scriptable, builtinclass, uuid(d7670dfa-8853-11e5-8e3e-43cd171289cc)]
interface nsISmsMessage : nsISupports
{
/**
* |type| is always "sms".

Просмотреть файл

@ -59,13 +59,13 @@ UNIFIED_SOURCES += [
'ipc/SmsChild.cpp',
'ipc/SmsIPCService.cpp',
'ipc/SmsParent.cpp',
'MmsMessage.cpp',
'MmsMessageInternal.cpp',
'MobileMessageCallback.cpp',
'MobileMessageCursorCallback.cpp',
'MobileMessageManager.cpp',
'MobileMessageService.cpp',
'MobileMessageThread.cpp',
'SmsMessage.cpp',
'MobileMessageThreadInternal.cpp',
'SmsMessageInternal.cpp',
]
IPDL_SOURCES += [

Просмотреть файл

@ -812,8 +812,6 @@ var interfaceNamesInGlobalScope =
{name: "MozInputContext", b2g: true, permission: ["input"]},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozInputMethodManager", b2g: true, permission: ["input"]},
// IMPORTANT: Do not change this list without review from a DOM peer!
"MozMmsMessage",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozMobileCellInfo", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -824,8 +822,6 @@ var interfaceNamesInGlobalScope =
{name: "MozMobileConnectionInfo", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozMobileNetworkInfo", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
"MozMobileMessageThread",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozNDEFRecord", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -842,8 +838,6 @@ var interfaceNamesInGlobalScope =
"MozSettingsEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozSettingsTransactionEvent", permission: ["settings-api-read"]},
// IMPORTANT: Do not change this list without review from a DOM peer!
"MozSmsMessage",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MozSpeakerManager", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!