Bug 720632 - Part 2: XPCOMtaminate SmsRequestManager. r=cjones,mounir

This commit is contained in:
Philipp von Weitershausen 2012-02-20 00:44:29 +01:00
parent 3e3cc86931
commit 15384020f4
9 changed files with 149 additions and 160 deletions

View File

@ -25,11 +25,11 @@ interface nsISmsRequestManager : nsISupports
* Make sure to keep this list in sync with the list in:
* embedding/android/GeckoSmsManager.java
*/
const unsigned short NO_ERROR = 0;
const unsigned short NO_SIGNAL_ERROR = 1;
const unsigned short NOT_FOUND_ERROR = 2;
const unsigned short UNKNOWN_ERROR = 3;
const unsigned short INTERNAL_ERROR = 4;
const unsigned short SUCCESS_NO_ERROR = 0;
const unsigned short NO_SIGNAL_ERROR = 1;
const unsigned short NOT_FOUND_ERROR = 2;
const unsigned short UNKNOWN_ERROR = 3;
const unsigned short INTERNAL_ERROR = 4;
/**
* Create a new request object.

View File

@ -115,7 +115,11 @@ SmsCursor::Continue()
mMessage = nsnull;
static_cast<SmsRequest*>(mRequest.get())->Reset();
PRInt32 requestId = SmsRequestManager::GetInstance()->AddRequest(mRequest);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
PRInt32 requestId;
nsresult rv = requestManager->AddRequest(mRequest, &requestId);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);

View File

@ -146,17 +146,23 @@ SmsManager::Send(JSContext* aCx, JSObject* aGlobal, JSString* aNumber,
nsCOMPtr<nsIDOMMozSmsRequest> request;
int requestId =
SmsRequestManager::GetInstance()->CreateRequest(mOwner, mScriptContext,
getter_AddRefs(request));
NS_ASSERTION(request, "The request object must have been created!");
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
PRInt32 requestId;
nsresult rv = requestManager->CreateRequest(mOwner, mScriptContext,
getter_AddRefs(request),
&requestId);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the request!");
return rv;
}
nsDependentJSString number;
number.init(aCx, aNumber);
smsService->Send(number, aMessage, requestId, 0);
nsresult rv = nsContentUtils::WrapNative(aCx, aGlobal, request, aRequest);
rv = nsContentUtils::WrapNative(aCx, aGlobal, request, aRequest);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the js value!");
return rv;
@ -217,9 +223,15 @@ SmsManager::Send(const jsval& aNumber, const nsAString& aMessage, jsval* aReturn
NS_IMETHODIMP
SmsManager::GetMessageMoz(PRInt32 aId, nsIDOMMozSmsRequest** aRequest)
{
int requestId =
SmsRequestManager::GetInstance()->CreateRequest(mOwner, mScriptContext, aRequest);
NS_ASSERTION(*aRequest, "The request object must have been created!");
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
PRInt32 requestId;
nsresult rv = requestManager->CreateRequest(mOwner, mScriptContext, aRequest,
&requestId);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the request!");
return rv;
}
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
@ -233,9 +245,15 @@ SmsManager::GetMessageMoz(PRInt32 aId, nsIDOMMozSmsRequest** aRequest)
nsresult
SmsManager::Delete(PRInt32 aId, nsIDOMMozSmsRequest** aRequest)
{
int requestId =
SmsRequestManager::GetInstance()->CreateRequest(mOwner, mScriptContext, aRequest);
NS_ASSERTION(*aRequest, "The request object must have been created!");
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
PRInt32 requestId;
nsresult rv = requestManager->CreateRequest(mOwner, mScriptContext, aRequest,
&requestId);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the request!");
return rv;
}
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
@ -278,9 +296,15 @@ SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter, bool aReverse,
filter = new SmsFilter();
}
int requestId =
SmsRequestManager::GetInstance()->CreateRequest(mOwner, mScriptContext, aRequest);
NS_ASSERTION(*aRequest, "The request object must have been created!");
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
PRInt32 requestId;
nsresult rv = requestManager->CreateRequest(mOwner, mScriptContext, aRequest,
&requestId);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the request!");
return rv;
}
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);

View File

@ -41,6 +41,7 @@
#include "nsContentUtils.h"
#include "nsIDOMSmsMessage.h"
#include "nsIDOMSmsCursor.h"
#include "nsISmsRequestManager.h"
DOMCI_DATA(MozSmsRequest, mozilla::dom::sms::SmsRequest)
@ -92,7 +93,7 @@ NS_IMPL_EVENT_HANDLER(SmsRequest, error)
SmsRequest::SmsRequest(nsPIDOMWindow* aWindow, nsIScriptContext* aScriptContext)
: mResult(JSVAL_VOID)
, mResultRooted(false)
, mError(eNoError)
, mError(nsISmsRequestManager::SUCCESS_NO_ERROR)
, mDone(false)
{
// Those vars come from nsDOMEventTargetHelper.
@ -112,7 +113,8 @@ SmsRequest::Reset()
{
NS_ASSERTION(mDone, "mDone should be true if we try to reset!");
NS_ASSERTION(mResult != JSVAL_VOID, "mResult should be set if we try to reset!");
NS_ASSERTION(mError == eNoError, "There should be no error if we try to reset!");
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
"There should be no error if we try to reset!");
if (mResultRooted) {
UnrootResult();
@ -148,7 +150,8 @@ void
SmsRequest::SetSuccess(bool aResult)
{
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
NS_PRECONDITION(mError == eNoError, "mError shouldn't have been set!");
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
"mError shouldn't have been set!");
NS_PRECONDITION(mResult == JSVAL_NULL, "mResult shouldn't have been set!");
mResult.setBoolean(aResult);
@ -174,7 +177,8 @@ bool
SmsRequest::SetSuccessInternal(nsISupports* aObject)
{
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
NS_PRECONDITION(mError == eNoError, "mError shouldn't have been set!");
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
"mError shouldn't have been set!");
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
JSContext* cx = mScriptContext->GetNativeContext();
@ -186,7 +190,7 @@ SmsRequest::SetSuccessInternal(nsISupports* aObject)
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, global)) {
SetError(eInternalError);
SetError(nsISmsRequestManager::INTERNAL_ERROR);
return false;
}
@ -195,7 +199,7 @@ SmsRequest::SetSuccessInternal(nsISupports* aObject)
if (NS_FAILED(nsContentUtils::WrapNative(cx, global, aObject, &mResult))) {
UnrootResult();
mResult = JSVAL_VOID;
SetError(eInternalError);
SetError(nsISmsRequestManager::INTERNAL_ERROR);
return false;
}
@ -204,10 +208,11 @@ SmsRequest::SetSuccessInternal(nsISupports* aObject)
}
void
SmsRequest::SetError(ErrorType aError)
SmsRequest::SetError(PRInt32 aError)
{
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
NS_PRECONDITION(mError == eNoError, "mError shouldn't have been set!");
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
"mError shouldn't have been set!");
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
mDone = true;
@ -231,32 +236,35 @@ NS_IMETHODIMP
SmsRequest::GetError(nsAString& aError)
{
if (!mDone) {
NS_ASSERTION(mError == eNoError,
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
"There should be no error if the request is still processing!");
SetDOMStringToNull(aError);
return NS_OK;
}
NS_ASSERTION(mError == eNoError || mResult == JSVAL_VOID,
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR ||
mResult == JSVAL_VOID,
"mResult should be void when there is an error!");
switch (mError) {
case eNoError:
case nsISmsRequestManager::SUCCESS_NO_ERROR:
SetDOMStringToNull(aError);
break;
case eNoSignalError:
case nsISmsRequestManager::NO_SIGNAL_ERROR:
aError.AssignLiteral("NoSignalError");
break;
case eNotFoundError:
case nsISmsRequestManager::NOT_FOUND_ERROR:
aError.AssignLiteral("NotFoundError");
break;
case eUnknownError:
case nsISmsRequestManager::UNKNOWN_ERROR:
aError.AssignLiteral("UnknownError");
break;
case eInternalError:
case nsISmsRequestManager::INTERNAL_ERROR:
aError.AssignLiteral("InternalError");
break;
default:
MOZ_ASSERT(false, "Unknown error value.");
}
return NS_OK;

View File

@ -54,19 +54,6 @@ class SmsRequest : public nsIDOMMozSmsRequest
public:
friend class SmsRequestManager;
/**
* All SMS related errors that could apply to SmsRequest objects.
* Make sure to keep this list in sync with the list in:
* embedding/android/GeckoSmsManager.java
*/
enum ErrorType {
eNoError = 0,
eNoSignalError,
eNotFoundError,
eUnknownError,
eInternalError,
};
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZSMSREQUEST
@ -111,7 +98,7 @@ private:
/**
* Set the object in an error state with the error type being aError.
*/
void SetError(ErrorType aError);
void SetError(PRInt32 aError);
/**
* Set the object in a success state with the result being the nsISupports
@ -129,7 +116,7 @@ private:
jsval mResult;
bool mResultRooted;
ErrorType mError;
PRInt32 mError;
bool mDone;
nsCOMPtr<nsIDOMMozSmsCursor> mCursor;

View File

@ -51,33 +51,11 @@ namespace mozilla {
namespace dom {
namespace sms {
SmsRequestManager* SmsRequestManager::sInstance = nsnull;
NS_IMPL_ISUPPORTS1(SmsRequestManager, nsISmsRequestManager)
void
SmsRequestManager::Init()
{
NS_PRECONDITION(!sInstance,
"sInstance shouldn't be set. Did you call Init() twice?");
sInstance = new SmsRequestManager();
}
void
SmsRequestManager::Shutdown()
{
NS_PRECONDITION(sInstance, "sInstance should be set. Did you call Init()?");
delete sInstance;
sInstance = nsnull;
}
/* static */ SmsRequestManager*
SmsRequestManager::GetInstance()
{
return sInstance;
}
PRInt32
SmsRequestManager::AddRequest(nsIDOMMozSmsRequest* aRequest)
NS_IMETHODIMP
SmsRequestManager::AddRequest(nsIDOMMozSmsRequest* aRequest,
PRInt32* aRequestId)
{
// TODO: merge with CreateRequest
PRInt32 size = mRequests.Count();
@ -89,17 +67,21 @@ SmsRequestManager::AddRequest(nsIDOMMozSmsRequest* aRequest)
}
mRequests.ReplaceObjectAt(aRequest, i);
return i;
*aRequestId = i;
return NS_OK;
}
mRequests.AppendObject(aRequest);
return size;
*aRequestId = size;
return NS_OK;
}
PRInt32
NS_IMETHODIMP
SmsRequestManager::CreateRequest(nsPIDOMWindow* aWindow,
nsIScriptContext* aScriptContext,
nsIDOMMozSmsRequest** aRequest)
nsIDOMMozSmsRequest** aRequest,
PRInt32* aRequestId)
{
nsCOMPtr<nsIDOMMozSmsRequest> request =
new SmsRequest(aWindow, aScriptContext);
@ -114,12 +96,14 @@ SmsRequestManager::CreateRequest(nsPIDOMWindow* aWindow,
mRequests.ReplaceObjectAt(request, i);
NS_ADDREF(*aRequest = request);
return i;
*aRequestId = i;
return NS_OK;
}
mRequests.AppendObject(request);
NS_ADDREF(*aRequest = request);
return size;
*aRequestId = size;
return NS_OK;
}
nsresult
@ -149,66 +133,67 @@ SmsRequestManager::GetRequest(PRInt32 aRequestId)
}
template <class T>
void
nsresult
SmsRequestManager::NotifySuccess(PRInt32 aRequestId, T aParam)
{
SmsRequest* request = GetRequest(aRequestId);
request->SetSuccess(aParam);
DispatchTrustedEventToRequest(SUCCESS_EVENT_NAME, request);
nsresult rv = DispatchTrustedEventToRequest(SUCCESS_EVENT_NAME, request);
mRequests.ReplaceObjectAt(nsnull, aRequestId);
return rv;
}
void
SmsRequestManager::NotifyError(PRInt32 aRequestId, SmsRequest::ErrorType aError)
nsresult
SmsRequestManager::NotifyError(PRInt32 aRequestId, PRInt32 aError)
{
SmsRequest* request = GetRequest(aRequestId);
request->SetError(aError);
DispatchTrustedEventToRequest(ERROR_EVENT_NAME, request);
nsresult rv = DispatchTrustedEventToRequest(ERROR_EVENT_NAME, request);
mRequests.ReplaceObjectAt(nsnull, aRequestId);
return rv;
}
void
NS_IMETHODIMP
SmsRequestManager::NotifySmsSent(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage)
{
NotifySuccess<nsIDOMMozSmsMessage*>(aRequestId, aMessage);
return NotifySuccess<nsIDOMMozSmsMessage*>(aRequestId, aMessage);
}
void
SmsRequestManager::NotifySmsSendFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError)
NS_IMETHODIMP
SmsRequestManager::NotifySmsSendFailed(PRInt32 aRequestId, PRInt32 aError)
{
NotifyError(aRequestId, aError);
return NotifyError(aRequestId, aError);
}
void
NS_IMETHODIMP
SmsRequestManager::NotifyGotSms(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage)
{
NotifySuccess<nsIDOMMozSmsMessage*>(aRequestId, aMessage);
return NotifySuccess<nsIDOMMozSmsMessage*>(aRequestId, aMessage);
}
void
SmsRequestManager::NotifyGetSmsFailed(PRInt32 aRequestId,
SmsRequest::ErrorType aError)
NS_IMETHODIMP
SmsRequestManager::NotifyGetSmsFailed(PRInt32 aRequestId, PRInt32 aError)
{
NotifyError(aRequestId, aError);
return NotifyError(aRequestId, aError);
}
void
NS_IMETHODIMP
SmsRequestManager::NotifySmsDeleted(PRInt32 aRequestId, bool aDeleted)
{
NotifySuccess<bool>(aRequestId, aDeleted);
return NotifySuccess<bool>(aRequestId, aDeleted);
}
void
SmsRequestManager::NotifySmsDeleteFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError)
NS_IMETHODIMP
SmsRequestManager::NotifySmsDeleteFailed(PRInt32 aRequestId, PRInt32 aError)
{
NotifyError(aRequestId, aError);
return NotifyError(aRequestId, aError);
}
void
NS_IMETHODIMP
SmsRequestManager::NotifyNoMessageInList(PRInt32 aRequestId)
{
SmsRequest* request = GetRequest(aRequestId);
@ -220,10 +205,10 @@ SmsRequestManager::NotifyNoMessageInList(PRInt32 aRequestId)
static_cast<SmsCursor*>(cursor.get())->Disconnect();
}
NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
return NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
}
void
NS_IMETHODIMP
SmsRequestManager::NotifyCreateMessageList(PRInt32 aRequestId, PRInt32 aListId,
nsIDOMMozSmsMessage* aMessage)
{
@ -232,10 +217,10 @@ SmsRequestManager::NotifyCreateMessageList(PRInt32 aRequestId, PRInt32 aListId,
nsCOMPtr<SmsCursor> cursor = new SmsCursor(aListId, request);
cursor->SetMessage(aMessage);
NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
return NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
}
void
NS_IMETHODIMP
SmsRequestManager::NotifyGotNextMessage(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage)
{
SmsRequest* request = GetRequest(aRequestId);
@ -244,12 +229,11 @@ SmsRequestManager::NotifyGotNextMessage(PRInt32 aRequestId, nsIDOMMozSmsMessage*
NS_ASSERTION(cursor, "Request should have an cursor in that case!");
cursor->SetMessage(aMessage);
NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
return NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
}
void
SmsRequestManager::NotifyReadMessageListFailed(PRInt32 aRequestId,
SmsRequest::ErrorType aError)
NS_IMETHODIMP
SmsRequestManager::NotifyReadMessageListFailed(PRInt32 aRequestId, PRInt32 aError)
{
SmsRequest* request = GetRequest(aRequestId);
@ -258,7 +242,7 @@ SmsRequestManager::NotifyReadMessageListFailed(PRInt32 aRequestId,
static_cast<SmsCursor*>(cursor.get())->Disconnect();
}
NotifyError(aRequestId, aError);
return NotifyError(aRequestId, aError);
}
} // namespace sms

View File

@ -41,50 +41,26 @@
#include "nsCOMArray.h"
#include "SmsRequest.h"
class nsIDOMMozSmsRequest;
class nsPIDOMWindow;
class nsIScriptContext;
class nsIDOMMozSmsMessage;
#include "nsISmsRequestManager.h"
namespace mozilla {
namespace dom {
namespace sms {
class SmsRequestManager
class SmsRequestManager : nsISmsRequestManager
{
public:
static void Init();
static void Shutdown();
static SmsRequestManager* GetInstance();
PRInt32 CreateRequest(nsPIDOMWindow* aWindow,
nsIScriptContext* aScriptContext,
nsIDOMMozSmsRequest** aRequest);
PRInt32 AddRequest(nsIDOMMozSmsRequest* aRequest);
void NotifySmsSent(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
void NotifySmsSendFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
void NotifyGotSms(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
void NotifyGetSmsFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
void NotifySmsDeleted(PRInt32 aRequestId, bool aDeleted);
void NotifySmsDeleteFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
void NotifyNoMessageInList(PRInt32 aRequestId);
void NotifyCreateMessageList(PRInt32 aRequestId, PRInt32 aListId, nsIDOMMozSmsMessage* aMessage);
void NotifyGotNextMessage(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
void NotifyReadMessageListFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
NS_DECL_ISUPPORTS
NS_DECL_NSISMSREQUESTMANAGER
private:
static SmsRequestManager* sInstance;
nsresult DispatchTrustedEventToRequest(const nsAString& aEventName,
nsIDOMMozSmsRequest* aRequest);
SmsRequest* GetRequest(PRInt32 aRequestId);
template <class T>
void NotifySuccess(PRInt32 aRequestId, T aParam);
void NotifyError(PRInt32 aRequestId, SmsRequest::ErrorType aError);
nsresult NotifySuccess(PRInt32 aRequestId, T aParam);
nsresult NotifyError(PRInt32 aRequestId, PRInt32 aError);
nsCOMArray<nsIDOMMozSmsRequest> mRequests;
};

View File

@ -100,7 +100,8 @@ SmsChild::RecvNotifyRequestSmsSent(const SmsMessageData& aMessage,
}
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(aMessage);
SmsRequestManager::GetInstance()->NotifySmsSent(aRequestId, message);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifySmsSent(aRequestId, message);
return true;
}
@ -114,8 +115,8 @@ SmsChild::RecvNotifyRequestSmsSendFailed(const PRInt32& aError,
return true;
}
SmsRequestManager::GetInstance()->NotifySmsSendFailed(aRequestId,
SmsRequest::ErrorType(aError));
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifySmsSendFailed(aRequestId, aError);
return true;
}
@ -130,7 +131,8 @@ SmsChild::RecvNotifyRequestGotSms(const SmsMessageData& aMessage,
}
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(aMessage);
SmsRequestManager::GetInstance()->NotifyGotSms(aRequestId, message);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyGotSms(aRequestId, message);
return true;
}
@ -144,8 +146,8 @@ SmsChild::RecvNotifyRequestGetSmsFailed(const PRInt32& aError,
return true;
}
SmsRequestManager::GetInstance()->NotifyGetSmsFailed(aRequestId,
SmsRequest::ErrorType(aError));
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyGetSmsFailed(aRequestId, aError);
return true;
}
@ -159,7 +161,8 @@ SmsChild::RecvNotifyRequestSmsDeleted(const bool& aDeleted,
return true;
}
SmsRequestManager::GetInstance()->NotifySmsDeleted(aRequestId, aDeleted);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifySmsDeleted(aRequestId, aDeleted);
return true;
}
@ -173,8 +176,8 @@ SmsChild::RecvNotifyRequestSmsDeleteFailed(const PRInt32& aError,
return true;
}
SmsRequestManager::GetInstance()->NotifySmsDeleteFailed(aRequestId,
SmsRequest::ErrorType(aError));
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifySmsDeleteFailed(aRequestId, aError);
return true;
}
@ -187,7 +190,8 @@ SmsChild::RecvNotifyRequestNoMessageInList(const PRInt32& aRequestId,
return true;
}
SmsRequestManager::GetInstance()->NotifyNoMessageInList(aRequestId);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyNoMessageInList(aRequestId);
return true;
}
@ -202,7 +206,8 @@ SmsChild::RecvNotifyRequestCreateMessageList(const PRInt32& aListId,
}
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(aMessageData);
SmsRequestManager::GetInstance()->NotifyCreateMessageList(aRequestId, aListId, message);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyCreateMessageList(aRequestId, aListId, message);
return true;
}
@ -216,7 +221,8 @@ SmsChild::RecvNotifyRequestGotNextMessage(const SmsMessageData& aMessageData,
}
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(aMessageData);
SmsRequestManager::GetInstance()->NotifyGotNextMessage(aRequestId, message);
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyGotNextMessage(aRequestId, message);
return true;
}
@ -229,8 +235,8 @@ SmsChild::RecvNotifyRequestReadListFailed(const PRInt32& aError,
return true;
}
SmsRequestManager::GetInstance()->NotifyReadMessageListFailed(aRequestId,
SmsRequest::ErrorType(aError));
nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
requestManager->NotifyReadMessageListFailed(aRequestId, aError);
return true;
}

View File

@ -327,9 +327,9 @@ public class GeckoSmsManager
public final static String ACTION_SMS_DELIVERED = "org.mozilla.gecko.SMS_DELIVERED";
/*
* Make sure that the following error codes are in sync with |ErrorType| in:
* dom/sms/src/Types.h
* The error code are owned by the DOM.
* Make sure that the following error codes are in sync with the ones
* defined in dom/sms/interfaces/nsISmsRequestManager.idl. They are owned
* owned by the interface.
*/
public final static int kNoError = 0;
public final static int kNoSignalError = 1;