mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 749086 - 2/3: DOM & IPC changes. r=bent
This commit is contained in:
parent
b8d7ccd8f9
commit
55f1595738
@ -332,7 +332,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
|
||||
#include "nsIDOMMobileMessageManager.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMSmsRequest.h"
|
||||
#include "nsIDOMSmsFilter.h"
|
||||
#include "nsIDOMSmsSegmentInfo.h"
|
||||
#include "nsIDOMMozMobileMessageThread.h"
|
||||
@ -912,9 +911,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozSmsRequest, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -2358,11 +2354,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozSmsRequest, nsIDOMMozSmsRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -190,7 +190,6 @@ DOMCI_CLASS(MozSmsManager)
|
||||
DOMCI_CLASS(MozMobileMessageManager)
|
||||
DOMCI_CLASS(MozSmsMessage)
|
||||
DOMCI_CLASS(MozMmsMessage)
|
||||
DOMCI_CLASS(MozSmsRequest)
|
||||
DOMCI_CLASS(MozSmsFilter)
|
||||
DOMCI_CLASS(MozSmsSegmentInfo)
|
||||
DOMCI_CLASS(MozMobileMessageThread)
|
||||
|
@ -15,7 +15,6 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMNavigatorSms.idl',
|
||||
'nsIDOMSmsFilter.idl',
|
||||
'nsIDOMSmsManager.idl',
|
||||
'nsIDOMSmsRequest.idl',
|
||||
'nsIDOMSmsSegmentInfo.idl',
|
||||
'nsIMobileMessageCallback.idl',
|
||||
'nsIMobileMessageCursorCallback.idl',
|
||||
|
@ -37,7 +37,6 @@ EXPORTS_mozilla/dom = \
|
||||
MobileMessageManager.h \
|
||||
SmsMessage.h \
|
||||
MmsMessage.h \
|
||||
SmsRequest.h \
|
||||
SmsSegmentInfo.h \
|
||||
SmsFilter.h \
|
||||
$(NULL)
|
||||
@ -66,7 +65,6 @@ CPPSRCS = \
|
||||
MmsMessage.cpp \
|
||||
Constants.cpp \
|
||||
SmsChild.cpp \
|
||||
SmsRequest.cpp \
|
||||
MobileMessageCallback.cpp \
|
||||
SmsFilter.cpp \
|
||||
SmsSegmentInfo.cpp \
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsIDOMMozMmsEvent.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
@ -120,21 +119,21 @@ MobileMessageManager::Send(JSContext* aCx, JSObject* aGlobal, JSString* aNumber,
|
||||
const nsAString& aMessage, JS::Value* aRequest)
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
|
||||
if (!smsService) {
|
||||
NS_ERROR("No SMS Service!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> request = SmsRequest::Create(this);
|
||||
nsDependentJSString number;
|
||||
number.init(aCx, aNumber);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(request.get()));
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
|
||||
new MobileMessageCallback(request);
|
||||
|
||||
smsService->Send(number, aMessage, forwarder);
|
||||
nsresult rv = smsService->Send(number, aMessage, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, aGlobal, request, aRequest);
|
||||
rv = nsContentUtils::WrapNative(aCx, aGlobal,
|
||||
static_cast<nsIDOMDOMRequest*>(request.get()),
|
||||
aRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Failed to create the js value!");
|
||||
return rv;
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include "Constants.h"
|
||||
#include "nsIDOMMozSmsEvent.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "GeneratedEvents.h"
|
||||
#include "MobileMessageCallback.h"
|
||||
#include "MobileMessageCursorCallback.h"
|
||||
#include "DOMCursor.h"
|
||||
|
||||
@ -145,21 +145,21 @@ SmsManager::Send(JSContext* aCx, JSObject* aGlobal, JSString* aNumber,
|
||||
const nsAString& aMessage, JS::Value* aRequest)
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
|
||||
if (!smsService) {
|
||||
NS_ERROR("No SMS Service!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> request = SmsRequest::Create(this);
|
||||
nsDependentJSString number;
|
||||
number.init(aCx, aNumber);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(request.get()));
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
|
||||
new MobileMessageCallback(request);
|
||||
|
||||
smsService->Send(number, aMessage, forwarder);
|
||||
nsresult rv = smsService->Send(number, aMessage, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, aGlobal, request, aRequest);
|
||||
rv = nsContentUtils::WrapNative(aCx, aGlobal,
|
||||
static_cast<nsIDOMDOMRequest*>(request.get()),
|
||||
aRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Failed to create the js value!");
|
||||
return rv;
|
||||
@ -217,36 +217,43 @@ SmsManager::Send(const JS::Value& aNumber, const nsAString& aMessage, JS::Value*
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsManager::GetMessageMoz(int32_t aId, nsIDOMMozSmsRequest** aRequest)
|
||||
SmsManager::GetMessageMoz(int32_t aId, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
|
||||
mobileMessageDBService->GetMessageMoz(aId, forwarder);
|
||||
req.forget(aRequest);
|
||||
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
|
||||
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
|
||||
new MobileMessageCallback(request);
|
||||
|
||||
nsresult rv = dbService->GetMessageMoz(aId, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
request.forget(aRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SmsManager::Delete(int32_t aId, nsIDOMMozSmsRequest** aRequest)
|
||||
SmsManager::Delete(int32_t aId, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
|
||||
mobileMessageDBService->DeleteMessage(aId, forwarder);
|
||||
req.forget(aRequest);
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
|
||||
new MobileMessageCallback(request);
|
||||
|
||||
nsresult rv = dbService->DeleteMessage(aId, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
request.forget(aRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsManager::Delete(const JS::Value& aParam, nsIDOMMozSmsRequest** aRequest)
|
||||
SmsManager::Delete(const JS::Value& aParam, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
if (aParam.isInt32()) {
|
||||
return Delete(aParam.toInt32(), aRequest);
|
||||
@ -300,16 +307,20 @@ SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsManager::MarkMessageRead(int32_t aId, bool aValue,
|
||||
nsIDOMMozSmsRequest** aRequest)
|
||||
nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
|
||||
mobileMessageDBService->MarkMessageRead(aId, aValue, forwarder);
|
||||
req.forget(aRequest);
|
||||
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
|
||||
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
|
||||
new MobileMessageCallback(request);
|
||||
|
||||
nsresult rv = dbService->MarkMessageRead(aId, aValue, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
request.forget(aRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
/**
|
||||
* Internal Delete() method used to delete a message.
|
||||
*/
|
||||
nsresult Delete(int32_t aId, nsIDOMMozSmsRequest** aRequest);
|
||||
nsresult Delete(int32_t aId, nsIDOMDOMRequest** aRequest);
|
||||
|
||||
nsresult DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
|
||||
nsIDOMMozSmsMessage* aMessage);
|
||||
|
@ -1,380 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 "SmsRequest.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsManager.h"
|
||||
#include "MobileMessageManager.h"
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
#include "SmsParent.h"
|
||||
#include "jsapi.h"
|
||||
#include "DictionaryHelpers.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
#define SUCCESS_EVENT_NAME NS_LITERAL_STRING("success")
|
||||
#define ERROR_EVENT_NAME NS_LITERAL_STRING("error")
|
||||
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
|
||||
DOMCI_DATA(MozSmsRequest, mozilla::dom::SmsRequest)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SmsRequestForwarder, nsIMobileMessageCallback)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
tmp->mResult = JSVAL_VOID;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mResult)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(SmsRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMobileMessageCallback)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(SmsRequest, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(SmsRequest, nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(SmsRequest, success)
|
||||
NS_IMPL_EVENT_HANDLER(SmsRequest, error)
|
||||
|
||||
already_AddRefed<nsIDOMMozSmsRequest>
|
||||
SmsRequest::Create(SmsManager* aManager)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> request = new SmsRequest(aManager);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMMozSmsRequest>
|
||||
SmsRequest::Create(MobileMessageManager* aManager)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> request = new SmsRequest(aManager);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<SmsRequest>
|
||||
SmsRequest::Create(SmsRequestParent* aRequestParent)
|
||||
{
|
||||
nsRefPtr<SmsRequest> request = new SmsRequest(aRequestParent);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
SmsRequest::SmsRequest(SmsManager* aManager)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mDone(false)
|
||||
, mParentAlive(false)
|
||||
, mParent(nullptr)
|
||||
{
|
||||
BindToOwner(aManager);
|
||||
}
|
||||
|
||||
SmsRequest::SmsRequest(MobileMessageManager* aManager)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mDone(false)
|
||||
, mParentAlive(false)
|
||||
, mParent(nullptr)
|
||||
{
|
||||
BindToOwner(aManager);
|
||||
}
|
||||
|
||||
SmsRequest::SmsRequest(SmsRequestParent* aRequestParent)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mDone(false)
|
||||
, mParentAlive(true)
|
||||
, mParent(aRequestParent)
|
||||
{
|
||||
MOZ_ASSERT(aRequestParent);
|
||||
}
|
||||
|
||||
SmsRequest::~SmsRequest()
|
||||
{
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, SmsRequest);
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::SetSuccess(nsIDOMMozSmsMessage* aMessage)
|
||||
{
|
||||
SetSuccessInternal(aMessage);
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::SetSuccess(bool aResult)
|
||||
{
|
||||
SetSuccess(aResult ? JSVAL_TRUE : JSVAL_FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::SetSuccess(const JS::Value& aResult)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(JSVAL_IS_VOID(mResult), "mResult shouldn't have been set!");
|
||||
|
||||
mResult = aResult;
|
||||
mDone = true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsRequest::SetSuccessInternal(nsISupports* aObject)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
|
||||
|
||||
nsresult rv;
|
||||
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
|
||||
if (!sc) {
|
||||
SetError(nsIMobileMessageCallback::INTERNAL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
NS_ASSERTION(cx, "Failed to get a context!");
|
||||
|
||||
JSObject* global = sc->GetNativeGlobal();
|
||||
NS_ASSERTION(global, "Failed to get global object!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
NS_HOLD_JS_OBJECTS(this, SmsRequest);
|
||||
|
||||
if (NS_FAILED(nsContentUtils::WrapNative(cx, global, aObject, &mResult))) {
|
||||
mResult = JSVAL_VOID;
|
||||
SetError(nsIMobileMessageCallback::INTERNAL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
mDone = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::SetError(int32_t aError)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
|
||||
NS_PRECONDITION(aError != nsIMobileMessageCallback::SUCCESS_NO_ERROR,
|
||||
"Can't call SetError() with SUCCESS_NO_ERROR!");
|
||||
|
||||
mDone = true;
|
||||
|
||||
switch (aError) {
|
||||
case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NoSignalError"));
|
||||
break;
|
||||
case nsIMobileMessageCallback::NOT_FOUND_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NotFoundError"));
|
||||
break;
|
||||
case nsIMobileMessageCallback::UNKNOWN_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("UnknownError"));
|
||||
break;
|
||||
case nsIMobileMessageCallback::INTERNAL_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("InternalError"));
|
||||
break;
|
||||
default: // SUCCESS_NO_ERROR is handled above.
|
||||
MOZ_ASSERT(false, "Unknown error value.");
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::GetReadyState(nsAString& aReadyState)
|
||||
{
|
||||
if (mDone) {
|
||||
aReadyState.AssignLiteral("done");
|
||||
} else {
|
||||
aReadyState.AssignLiteral("processing");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::GetError(nsIDOMDOMError** aError)
|
||||
{
|
||||
NS_ASSERTION(mDone || !mError, "mError should be null when pending");
|
||||
NS_ASSERTION(!mError || mResult == JSVAL_VOID,
|
||||
"mResult should be void when there is an error!");
|
||||
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::GetResult(JS::Value* aResult)
|
||||
{
|
||||
if (!mDone) {
|
||||
NS_ASSERTION(mResult == JSVAL_VOID,
|
||||
"When not done, result should be null!");
|
||||
|
||||
*aResult = JSVAL_VOID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aResult = mResult;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SmsRequest::DispatchTrustedEvent(const nsAString& aEventName)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
|
||||
nsresult rv = event->InitEvent(aEventName, false, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
event->SetTrusted(true);
|
||||
|
||||
bool dummy;
|
||||
return DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
nsresult
|
||||
SmsRequest::NotifySuccess(T aParam)
|
||||
{
|
||||
SetSuccess(aParam);
|
||||
nsresult rv = DispatchTrustedEvent(SUCCESS_EVENT_NAME);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SmsRequest::NotifyError(int32_t aError)
|
||||
{
|
||||
SetError(aError);
|
||||
|
||||
nsresult rv = DispatchTrustedEvent(ERROR_EVENT_NAME);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SmsRequest::SendMessageReply(const MessageReply& aReply)
|
||||
{
|
||||
if (mParentAlive) {
|
||||
mParent->SendReply(aReply);
|
||||
mParent = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyMessageSent(nsISupports *aMessage)
|
||||
{
|
||||
// We only support nsIDOMMozSmsMessage for SmsRequest.
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> message(do_QueryInterface(aMessage));
|
||||
if (!message) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
SmsMessage* smsMessage = static_cast<SmsMessage*>(message.get());
|
||||
|
||||
if (mParent) {
|
||||
SmsMessageData data = SmsMessageData(smsMessage->GetData());
|
||||
return SendMessageReply(MessageReply(ReplyMessageSend(data)));
|
||||
}
|
||||
return NotifySuccess<nsIDOMMozSmsMessage*>(smsMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifySendMessageFailed(int32_t aError)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyMessageSendFail(aError)));
|
||||
}
|
||||
return NotifyError(aError);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyMessageGot(nsISupports *aMessage)
|
||||
{
|
||||
// We only support nsIDOMMozSmsMessage for SmsRequest.
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> message(do_QueryInterface(aMessage));
|
||||
if (!message) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
SmsMessage* smsMessage = static_cast<SmsMessage*>(message.get());
|
||||
|
||||
if (mParent) {
|
||||
SmsMessageData data = SmsMessageData(smsMessage->GetData());
|
||||
return SendMessageReply(MessageReply(ReplyGetMessage(data)));
|
||||
}
|
||||
return NotifySuccess<nsIDOMMozSmsMessage*>(smsMessage);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyGetMessageFailed(int32_t aError)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyGetMessageFail(aError)));
|
||||
}
|
||||
return NotifyError(aError);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyMessageDeleted(bool aDeleted)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyMessageDelete(aDeleted)));
|
||||
}
|
||||
return NotifySuccess<bool>(aDeleted);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyDeleteMessageFailed(int32_t aError)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyMessageDeleteFail(aError)));
|
||||
}
|
||||
return NotifyError(aError);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyMessageMarkedRead(bool aRead)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyMarkeMessageRead(aRead)));
|
||||
}
|
||||
return NotifySuccess<bool>(aRead);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::NotifyMarkMessageReadFailed(int32_t aError)
|
||||
{
|
||||
if (mParent) {
|
||||
return SendMessageReply(MessageReply(ReplyMarkeMessageReadFail(aError)));
|
||||
}
|
||||
return NotifyError(aError);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,132 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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_SmsRequest_h
|
||||
#define mozilla_dom_mobilemessage_SmsRequest_h
|
||||
|
||||
#include "nsIDOMSmsRequest.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
|
||||
class nsIDOMMozSmsMessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
namespace mobilemessage {
|
||||
class SmsRequestChild;
|
||||
class SmsRequestParent;
|
||||
class MessageReply;
|
||||
class ThreadListItem;
|
||||
}
|
||||
|
||||
// We need this forwarder to avoid a QI to nsIClassInfo.
|
||||
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=775997#c51
|
||||
class SmsRequestForwarder : public nsIMobileMessageCallback
|
||||
{
|
||||
friend class mobilemessage::SmsRequestChild;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_NSIMOBILEMESSAGECALLBACK(mRealRequest->)
|
||||
|
||||
SmsRequestForwarder(nsIMobileMessageCallback* aRealRequest) {
|
||||
mRealRequest = aRealRequest;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual
|
||||
~SmsRequestForwarder() {}
|
||||
|
||||
nsIMobileMessageCallback* GetRealRequest() {
|
||||
return mRealRequest;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> mRealRequest;
|
||||
};
|
||||
|
||||
class SmsManager;
|
||||
class MobileMessageManager;
|
||||
|
||||
class SmsRequest : public nsDOMEventTargetHelper
|
||||
, public nsIDOMMozSmsRequest
|
||||
, public nsIMobileMessageCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMDOMREQUEST
|
||||
NS_DECL_NSIMOBILEMESSAGECALLBACK
|
||||
NS_DECL_NSIDOMMOZSMSREQUEST
|
||||
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
|
||||
static already_AddRefed<nsIDOMMozSmsRequest> Create(SmsManager* aManager);
|
||||
static already_AddRefed<nsIDOMMozSmsRequest> Create(MobileMessageManager* aManager);
|
||||
|
||||
static already_AddRefed<SmsRequest> Create(mobilemessage::SmsRequestParent* requestParent);
|
||||
void SetActorDied() {
|
||||
mParentAlive = false;
|
||||
}
|
||||
|
||||
void
|
||||
NotifyThreadList(const InfallibleTArray<mobilemessage::ThreadListItem>& aItems);
|
||||
|
||||
private:
|
||||
SmsRequest() MOZ_DELETE;
|
||||
|
||||
SmsRequest(SmsManager* aManager);
|
||||
SmsRequest(MobileMessageManager* aManager);
|
||||
SmsRequest(mobilemessage::SmsRequestParent* aParent);
|
||||
~SmsRequest();
|
||||
|
||||
nsresult SendMessageReply(const mobilemessage::MessageReply& aReply);
|
||||
|
||||
/**
|
||||
* Set the object in a success state with the result being aMessage.
|
||||
*/
|
||||
void SetSuccess(nsIDOMMozSmsMessage* aMessage);
|
||||
|
||||
/**
|
||||
* Set the object in a success state with the result being a boolean.
|
||||
*/
|
||||
void SetSuccess(bool aResult);
|
||||
|
||||
/**
|
||||
* Set the object in a success state with the result being the given JS::Value.
|
||||
*/
|
||||
void SetSuccess(const JS::Value& aVal);
|
||||
|
||||
/**
|
||||
* Set the object in an error state with the error type being aError.
|
||||
*/
|
||||
void SetError(int32_t aError);
|
||||
|
||||
/**
|
||||
* Set the object in a success state with the result being the nsISupports
|
||||
* object in parameter.
|
||||
* @return whether setting the object was a success
|
||||
*/
|
||||
bool SetSuccessInternal(nsISupports* aObject);
|
||||
|
||||
nsresult DispatchTrustedEvent(const nsAString& aEventName);
|
||||
|
||||
template <class T>
|
||||
nsresult NotifySuccess(T aParam);
|
||||
nsresult NotifyError(int32_t aError);
|
||||
|
||||
JS::Value mResult;
|
||||
bool mDone;
|
||||
bool mParentAlive;
|
||||
mobilemessage::SmsRequestParent* mParent;
|
||||
nsCOMPtr<nsIDOMDOMError> mError;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_SmsRequest_h
|
@ -8,7 +8,6 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "MobileMessageThread.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsFilter.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "SmsSegmentInfo.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "SmsMessage.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "SmsFilter.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "SmsSegmentInfo.h"
|
||||
#include "MobileMessageThread.h"
|
||||
|
||||
@ -195,13 +194,19 @@ SmsParent::RecvPSmsRequestConstructor(PSmsRequestParent* aActor,
|
||||
PSmsRequestParent*
|
||||
SmsParent::AllocPSmsRequest(const IPCSmsRequest& aRequest)
|
||||
{
|
||||
return new SmsRequestParent();
|
||||
SmsRequestParent* actor = new SmsRequestParent();
|
||||
// Add an extra ref for IPDL. Will be released in
|
||||
// SmsParent::DeallocPSmsRequest().
|
||||
actor->AddRef();
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::DeallocPSmsRequest(PSmsRequestParent* aActor)
|
||||
{
|
||||
delete aActor;
|
||||
// SmsRequestParent is refcounted, must not be freed manually.
|
||||
static_cast<SmsRequestParent*>(aActor)->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -248,44 +253,27 @@ SmsParent::DeallocPMobileMessageCursor(PMobileMessageCursorParent* aActor)
|
||||
* SmsRequestParent
|
||||
******************************************************************************/
|
||||
|
||||
SmsRequestParent::SmsRequestParent()
|
||||
{
|
||||
MOZ_COUNT_CTOR(SmsRequestParent);
|
||||
}
|
||||
|
||||
SmsRequestParent::~SmsRequestParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SmsRequestParent);
|
||||
}
|
||||
NS_IMPL_ISUPPORTS1(SmsRequestParent, nsIMobileMessageCallback)
|
||||
|
||||
void
|
||||
SmsRequestParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mSmsRequest) {
|
||||
mSmsRequest->SetActorDied();
|
||||
mSmsRequest = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequestParent::SendReply(const MessageReply& aReply) {
|
||||
nsRefPtr<SmsRequest> request;
|
||||
mSmsRequest.swap(request);
|
||||
if (!Send__delete__(this, aReply)) {
|
||||
NS_WARNING("Failed to send response to child process!");
|
||||
}
|
||||
mActorDestroyed = true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsRequestParent::DoRequest(const SendMessageRequest& aRequest)
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsService, true);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mSmsRequest = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder = new SmsRequestForwarder(mSmsRequest);
|
||||
nsresult rv = smsService->Send(aRequest.number(), aRequest.message(), forwarder);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
|
||||
if (smsService) {
|
||||
rv = smsService->Send(aRequest.number(), aRequest.message(), this);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_SUCCEEDED(NotifySendMessageFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -293,14 +281,17 @@ SmsRequestParent::DoRequest(const SendMessageRequest& aRequest)
|
||||
bool
|
||||
SmsRequestParent::DoRequest(const GetMessageRequest& aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, true);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mSmsRequest = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder = new SmsRequestForwarder(mSmsRequest);
|
||||
nsresult rv = mobileMessageDBService->GetMessageMoz(aRequest.messageId(), forwarder);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
if (dbService) {
|
||||
rv = dbService->GetMessageMoz(aRequest.messageId(), this);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_SUCCEEDED(NotifyGetMessageFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -308,14 +299,17 @@ SmsRequestParent::DoRequest(const GetMessageRequest& aRequest)
|
||||
bool
|
||||
SmsRequestParent::DoRequest(const DeleteMessageRequest& aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, true);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mSmsRequest = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder = new SmsRequestForwarder(mSmsRequest);
|
||||
nsresult rv = mobileMessageDBService->DeleteMessage(aRequest.messageId(), forwarder);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
if (dbService) {
|
||||
rv = dbService->DeleteMessage(aRequest.messageId(), this);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_SUCCEEDED(NotifyDeleteMessageFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -323,18 +317,85 @@ SmsRequestParent::DoRequest(const DeleteMessageRequest& aRequest)
|
||||
bool
|
||||
SmsRequestParent::DoRequest(const MarkMessageReadRequest& aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, true);
|
||||
mSmsRequest = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder = new SmsRequestForwarder(mSmsRequest);
|
||||
nsresult rv = mobileMessageDBService->MarkMessageRead(aRequest.messageId(), aRequest.value(), forwarder);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
if (dbService) {
|
||||
rv = dbService->MarkMessageRead(aRequest.messageId(), aRequest.value(),
|
||||
this);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_SUCCEEDED(NotifyMarkMessageReadFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SmsRequestParent::SendReply(const MessageReply& aReply)
|
||||
{
|
||||
// The child process could die before this asynchronous notification, in which
|
||||
// case ActorDestroy() was called and mActorDestroyed is set to true. Return
|
||||
// an error here to avoid sending a message to the dead process.
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// nsIMobileMessageCallback
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyMessageSent(nsISupports *aMessage)
|
||||
{
|
||||
SmsMessage* message = static_cast<SmsMessage*>(aMessage);
|
||||
return SendReply(ReplyMessageSend(message->GetData()));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifySendMessageFailed(int32_t aError)
|
||||
{
|
||||
return SendReply(ReplyMessageSendFail(aError));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyMessageGot(nsISupports *aMessage)
|
||||
{
|
||||
SmsMessage* message = static_cast<SmsMessage*>(aMessage);
|
||||
return SendReply(ReplyGetMessage(message->GetData()));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyGetMessageFailed(int32_t aError)
|
||||
{
|
||||
return SendReply(ReplyGetMessageFail(aError));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyMessageDeleted(bool aDeleted)
|
||||
{
|
||||
return SendReply(ReplyMessageDelete(aDeleted));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyDeleteMessageFailed(int32_t aError)
|
||||
{
|
||||
return SendReply(ReplyMessageDeleteFail(aError));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyMessageMarkedRead(bool aRead)
|
||||
{
|
||||
return SendReply(ReplyMarkeMessageRead(aRead));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifyMarkMessageReadFailed(int32_t aError)
|
||||
{
|
||||
return SendReply(ReplyMarkeMessageReadFail(aError));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* MobileMessageCursorParent
|
||||
******************************************************************************/
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/dom/mobilemessage/PSmsRequestParent.h"
|
||||
#include "mozilla/dom/mobilemessage/PMobileMessageCursorParent.h"
|
||||
#include "nsIDOMDOMCursor.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsIMobileMessageCursorCallback.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
@ -17,7 +18,6 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ContentParent;
|
||||
class SmsRequest;
|
||||
|
||||
namespace mobilemessage {
|
||||
|
||||
@ -68,18 +68,27 @@ protected:
|
||||
};
|
||||
|
||||
class SmsRequestParent : public PSmsRequestParent
|
||||
, public nsIMobileMessageCallback
|
||||
{
|
||||
friend class SmsParent;
|
||||
|
||||
nsRefPtr<SmsRequest> mSmsRequest;
|
||||
bool mActorDestroyed;
|
||||
|
||||
public:
|
||||
void
|
||||
SendReply(const MessageReply& aReply);
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILEMESSAGECALLBACK
|
||||
|
||||
protected:
|
||||
SmsRequestParent();
|
||||
virtual ~SmsRequestParent();
|
||||
SmsRequestParent()
|
||||
: mActorDestroyed(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SmsRequestParent);
|
||||
}
|
||||
|
||||
virtual ~SmsRequestParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SmsRequestParent);
|
||||
}
|
||||
|
||||
virtual void
|
||||
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
||||
@ -95,6 +104,9 @@ protected:
|
||||
|
||||
bool
|
||||
DoRequest(const MarkMessageReadRequest& aRequest);
|
||||
|
||||
nsresult
|
||||
SendReply(const MessageReply& aReply);
|
||||
};
|
||||
|
||||
class MobileMessageCursorParent : public PMobileMessageCursorParent
|
||||
|
@ -1801,10 +1801,8 @@ let RIL = {
|
||||
* String containing the recipient number.
|
||||
* @param body
|
||||
* String containing the message text.
|
||||
* @param requestId
|
||||
* String identifying the sms request used by the SmsRequestManager.
|
||||
* @param processId
|
||||
* String containing the processId for the SmsRequestManager.
|
||||
* @param envelopeId
|
||||
* Numeric value identifying the sms request.
|
||||
*/
|
||||
sendSMS: function sendSMS(options) {
|
||||
options.langIndex = options.langIndex || PDU_NL_IDENTIFIER_DEFAULT;
|
||||
|
Loading…
Reference in New Issue
Block a user