Bug 838467 2/5: DOM implementation. r=sicking,bent

This commit is contained in:
Vicamo Yang 2013-04-09 10:21:31 +08:00
parent 17c7709601
commit 3e803b53c7
17 changed files with 224 additions and 376 deletions

View File

@ -334,7 +334,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "nsIDOMMozMmsMessage.h"
#include "nsIDOMSmsRequest.h"
#include "nsIDOMSmsFilter.h"
#include "nsIDOMSmsCursor.h"
#include "nsIDOMSmsSegmentInfo.h"
#include "nsIDOMConnection.h"
#include "mozilla/dom/network/Utils.h"
@ -918,9 +917,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsCursor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsSegmentInfo, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -2367,10 +2363,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsCursor, nsIDOMMozSmsCursor)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsSegmentInfo, nsIDOMMozSmsSegmentInfo)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsSegmentInfo)
DOM_CLASSINFO_MAP_END

View File

@ -192,7 +192,6 @@ DOMCI_CLASS(MozSmsMessage)
DOMCI_CLASS(MozMmsMessage)
DOMCI_CLASS(MozSmsRequest)
DOMCI_CLASS(MozSmsFilter)
DOMCI_CLASS(MozSmsCursor)
DOMCI_CLASS(MozSmsSegmentInfo)
DOMCI_CLASS(MozConnection)

View File

@ -12,12 +12,12 @@ XPIDL_SOURCES += [
'nsIDOMMozSmsMessage.idl',
'nsIDOMNavigatorMobileMessage.idl',
'nsIDOMNavigatorSms.idl',
'nsIDOMSmsCursor.idl',
'nsIDOMSmsFilter.idl',
'nsIDOMSmsManager.idl',
'nsIDOMSmsRequest.idl',
'nsIDOMSmsSegmentInfo.idl',
'nsIMobileMessageCallback.idl',
'nsIMobileMessageCursorCallback.idl',
'nsIMobileMessageDatabaseService.idl',
'nsIMobileMessageService.idl',
'nsISmsService.idl',

View File

@ -53,6 +53,7 @@ EXPORTS_mozilla/dom/mobilemessage = \
$(NULL)
CPPSRCS = \
MobileMessageCursorCallback.cpp \
SmsManager.cpp \
MobileMessageManager.cpp \
SmsService.cpp \
@ -68,7 +69,6 @@ CPPSRCS = \
MobileMessageCallback.cpp \
SmsFilter.cpp \
SmsSegmentInfo.cpp \
SmsCursor.cpp \
$(NULL)
LOCAL_INCLUDES = \

View File

@ -39,8 +39,8 @@ MobileMessageCallback::~MobileMessageCallback()
nsresult
MobileMessageCallback::NotifySuccess(const JS::Value& aResult)
{
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
return rs ? rs->FireSuccess(mDOMRequest, aResult) : NS_ERROR_FAILURE;
mDOMRequest->FireSuccess(aResult);
return NS_OK;
}
nsresult
@ -54,11 +54,14 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
AutoPushJSContext cx(scriptContext->GetNativeContext());
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JSObject* global = scriptContext->GetNativeGlobal();
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, global);
JS::Value wrappedMessage;
rv = nsContentUtils::WrapNative(cx,
JS_GetGlobalObject(cx),
aMessage,
&wrappedMessage);
rv = nsContentUtils::WrapNative(cx, global, aMessage, &wrappedMessage);
NS_ENSURE_SUCCESS(rv, rv);
return NotifySuccess(wrappedMessage);
@ -67,20 +70,22 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
nsresult
MobileMessageCallback::NotifyError(int32_t aError)
{
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
switch (aError) {
case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
return rs->FireError(mDOMRequest, NS_LITERAL_STRING("NoSignalError"));
mDOMRequest->FireError(NS_LITERAL_STRING("NoSignalError"));
break;
case nsIMobileMessageCallback::NOT_FOUND_ERROR:
return rs->FireError(mDOMRequest, NS_LITERAL_STRING("NotFoundError"));
mDOMRequest->FireError(NS_LITERAL_STRING("NotFoundError"));
break;
case nsIMobileMessageCallback::UNKNOWN_ERROR:
return rs->FireError(mDOMRequest, NS_LITERAL_STRING("UnknownError"));
mDOMRequest->FireError(NS_LITERAL_STRING("UnknownError"));
break;
case nsIMobileMessageCallback::INTERNAL_ERROR:
return rs->FireError(mDOMRequest, NS_LITERAL_STRING("InternalError"));
mDOMRequest->FireError(NS_LITERAL_STRING("InternalError"));
break;
default: // SUCCESS_NO_ERROR is handled above.
MOZ_ASSERT(false, "Unknown error value.");
MOZ_NOT_REACHED("Should never get here!");
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -122,31 +127,6 @@ MobileMessageCallback::NotifyDeleteMessageFailed(int32_t aError)
return NotifyError(aError);
}
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageListCreated(int32_t aListId,
nsISupports *aMessage)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MobileMessageCallback::NotifyReadMessageListFailed(int32_t aError)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MobileMessageCallback::NotifyNextMessageInListGot(nsISupports *aMessage)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MobileMessageCallback::NotifyNoMessageInList()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageMarkedRead(bool aRead)
{

View File

@ -0,0 +1,97 @@
/* -*- 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 "MobileMessageCursorCallback.h"
#include "nsIDOMDOMRequest.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsIMobileMessageCallback.h"
#include "DOMCursor.h"
#include "nsServiceManagerUtils.h" // for do_GetService
namespace mozilla {
namespace dom {
namespace mobilemessage {
NS_IMPL_CYCLE_COLLECTION_1(MobileMessageCursorCallback, mDOMCursor)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileMessageCursorCallback)
NS_INTERFACE_MAP_ENTRY(nsIMobileMessageCursorCallback)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileMessageCursorCallback)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileMessageCursorCallback)
// nsIMobileMessageCursorCallback
NS_IMETHODIMP
MobileMessageCursorCallback::NotifyCursorError(int32_t aError)
{
MOZ_ASSERT(mDOMCursor);
nsRefPtr<DOMCursor> cursor = mDOMCursor.forget();
switch (aError) {
case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
cursor->FireError(NS_LITERAL_STRING("NoSignalError"));
break;
case nsIMobileMessageCallback::NOT_FOUND_ERROR:
cursor->FireError(NS_LITERAL_STRING("NotFoundError"));
break;
case nsIMobileMessageCallback::UNKNOWN_ERROR:
cursor->FireError(NS_LITERAL_STRING("UnknownError"));
break;
case nsIMobileMessageCallback::INTERNAL_ERROR:
cursor->FireError(NS_LITERAL_STRING("InternalError"));
break;
default: // SUCCESS_NO_ERROR is handled above.
MOZ_NOT_REACHED("Should never get here!");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
{
MOZ_ASSERT(mDOMCursor);
nsresult rv;
nsIScriptContext* scriptContext = mDOMCursor->GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
AutoPushJSContext cx(scriptContext->GetNativeContext());
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JSObject* global = scriptContext->GetNativeGlobal();
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, global);
JS::Value wrappedResult;
rv = nsContentUtils::WrapNative(cx, global, aResult, &wrappedResult);
NS_ENSURE_SUCCESS(rv, rv);
mDOMCursor->FireSuccess(wrappedResult);
return NS_OK;
}
NS_IMETHODIMP
MobileMessageCursorCallback::NotifyCursorDone()
{
MOZ_ASSERT(mDOMCursor);
nsRefPtr<DOMCursor> cursor = mDOMCursor.forget();
cursor->FireDone();
return NS_OK;
}
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,55 @@
/* -*- 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_MobileMessageCursorCallback_h
#define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
#include "nsIMobileMessageCursorCallback.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
class nsICursorContinueCallback;
namespace mozilla {
namespace dom {
class DOMCursor;
class MobileMessageManager;
class SmsManager;
namespace mobilemessage {
class MobileMessageCursorCallback : public nsIMobileMessageCursorCallback
{
friend class mozilla::dom::MobileMessageManager;
friend class mozilla::dom::SmsManager;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIMOBILEMESSAGECURSORCALLBACK
NS_DECL_CYCLE_COLLECTION_CLASS(MobileMessageCursorCallback)
MobileMessageCursorCallback()
{
MOZ_COUNT_CTOR(MobileMessageCursorCallback);
}
private:
virtual ~MobileMessageCursorCallback()
{
MOZ_COUNT_DTOR(MobileMessageCursorCallback);
}
nsRefPtr<DOMCursor> mDOMCursor;
};
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_MobileMessageCursorCallback_h

View File

@ -26,6 +26,8 @@
#include "DOMRequest.h"
#include "nsIMobileMessageCallback.h"
#include "MobileMessageCallback.h"
#include "MobileMessageCursorCallback.h"
#include "DOMCursor.h"
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define SENDING_EVENT_NAME NS_LITERAL_STRING("sending")
@ -271,23 +273,30 @@ MobileMessageManager::Delete(const JS::Value& aParam, nsIDOMDOMRequest** aReques
}
NS_IMETHODIMP
MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter, bool aReverse,
nsIDOMMozSmsRequest** aRequest)
MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIDOMDOMCursor** aCursor)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
if (!filter) {
filter = new SmsFilter();
}
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
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->CreateMessageList(filter, aReverse, forwarder);
req.forget(aRequest);
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
new MobileMessageCursorCallback();
nsCOMPtr<nsICursorContinueCallback> continueCallback;
nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
getter_AddRefs(continueCallback));
NS_ENSURE_SUCCESS(rv, rv);
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
return NS_OK;
}

View File

@ -1,100 +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 "SmsCursor.h"
#include "nsIDOMClassInfo.h"
#include "nsError.h"
#include "nsIDOMMozSmsMessage.h"
#include "SmsRequest.h"
#include "nsIMobileMessageDatabaseService.h"
DOMCI_DATA(MozSmsCursor, mozilla::dom::SmsCursor)
namespace mozilla {
namespace dom {
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SmsCursor)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsCursor)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsCursor)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_2(SmsCursor, mRequest, mMessage)
NS_IMPL_CYCLE_COLLECTING_ADDREF(SmsCursor)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SmsCursor)
SmsCursor::SmsCursor()
: mListId(-1)
{
}
SmsCursor::SmsCursor(int32_t aListId, nsIMobileMessageCallback* aRequest)
: mListId(aListId)
, mRequest(aRequest)
{
}
SmsCursor::~SmsCursor()
{
NS_ASSERTION(!mMessage, "mMessage shouldn't be set!");
if (mListId != -1) {
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
if (!mobileMessageDBService) {
NS_ERROR("Can't find MobileMessageDBService!");
}
mobileMessageDBService->ClearMessageList(mListId);
}
}
void
SmsCursor::Disconnect()
{
NS_ASSERTION(!mMessage, "mMessage shouldn't be set!");
mRequest = nullptr;
mListId = -1;
}
NS_IMETHODIMP
SmsCursor::GetMessage(nsIDOMMozSmsMessage** aMessage)
{
NS_IF_ADDREF(*aMessage = mMessage);
return NS_OK;
}
NS_IMETHODIMP
SmsCursor::Continue()
{
// No message means we are waiting for a message or we got the last one.
if (!mMessage) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
nsRefPtr<SmsRequest> request = static_cast<SmsRequest*>(mRequest.get());
mMessage = nullptr;
request->Reset();
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
nsCOMPtr<nsIMobileMessageCallback> forwarder = new SmsRequestForwarder(request);
mobileMessageDBService->GetNextMessageInList(mListId, forwarder);
// We intenionally increase the refcount. The release will be called
// in the corresponding callback.
request.forget();
return NS_OK;
}
} // namespace dom
} // namespace mozilla

View File

@ -1,52 +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_SmsCursor_h
#define mozilla_dom_mobilemessage_SmsCursor_h
#include "nsIDOMSmsCursor.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "mozilla/Attributes.h"
class nsIDOMMozSmsMessage;
class nsIMobileMessageCallback;
namespace mozilla {
namespace dom {
class SmsCursor MOZ_FINAL : public nsIDOMMozSmsCursor
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMMOZSMSCURSOR
NS_DECL_CYCLE_COLLECTION_CLASS(SmsCursor)
SmsCursor();
SmsCursor(int32_t aListId, nsIMobileMessageCallback* aRequest);
~SmsCursor();
void SetMessage(nsIDOMMozSmsMessage* aMessage);
void Disconnect();
private:
int32_t mListId;
nsCOMPtr<nsIMobileMessageCallback> mRequest;
nsCOMPtr<nsIDOMMozSmsMessage> mMessage;
};
inline void
SmsCursor::SetMessage(nsIDOMMozSmsMessage* aMessage)
{
mMessage = aMessage;
}
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_SmsCursor_h

View File

@ -6,7 +6,7 @@
#ifndef mozilla_dom_mobilemessage_SmsFilter_h
#define mozilla_dom_mobilemessage_SmsFilter_h
#include "mozilla/dom/mobilemessage/PSms.h"
#include "mozilla/dom/mobilemessage/SmsTypes.h"
#include "nsIDOMSmsFilter.h"
#include "Types.h"
#include "mozilla/Attributes.h"

View File

@ -20,6 +20,8 @@
#include "nsIXPConnect.h"
#include "nsIPermissionManager.h"
#include "GeneratedEvents.h"
#include "MobileMessageCursorCallback.h"
#include "DOMCursor.h"
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define SENDING_EVENT_NAME NS_LITERAL_STRING("sending")
@ -269,23 +271,30 @@ SmsManager::Delete(const JS::Value& aParam, nsIDOMMozSmsRequest** aRequest)
}
NS_IMETHODIMP
SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter, bool aReverse,
nsIDOMMozSmsRequest** aRequest)
SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIDOMDOMCursor** aCursor)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
if (!filter) {
filter = new SmsFilter();
}
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
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->CreateMessageList(filter, aReverse, forwarder);
req.forget(aRequest);
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
new MobileMessageCursorCallback();
nsCOMPtr<nsICursorContinueCallback> continueCallback;
nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
getter_AddRefs(continueCallback));
NS_ENSURE_SUCCESS(rv, rv);
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
return NS_OK;
}

View File

@ -6,7 +6,7 @@
#ifndef mozilla_dom_mobilemessage_SmsMessage_h
#define mozilla_dom_mobilemessage_SmsMessage_h
#include "mozilla/dom/mobilemessage/PSms.h"
#include "mozilla/dom/mobilemessage/SmsTypes.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsString.h"
#include "jspubtd.h"

View File

@ -11,7 +11,6 @@
#include "nsIDOMMozSmsMessage.h"
#include "nsIScriptGlobalObject.h"
#include "nsPIDOMWindow.h"
#include "SmsCursor.h"
#include "SmsMessage.h"
#include "SmsManager.h"
#include "MobileMessageManager.h"
@ -36,14 +35,12 @@ 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(mCursor)
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(mCursor)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -142,21 +139,6 @@ SmsRequest::SetSuccess(bool aResult)
SetSuccess(aResult ? JSVAL_TRUE : JSVAL_FALSE);
}
void
SmsRequest::SetSuccess(nsIDOMMozSmsCursor* aCursor)
{
if (!SetSuccessInternal(aCursor)) {
return;
}
NS_ASSERTION(!mCursor || mCursor == aCursor,
"SmsRequest can't change it's cursor!");
if (!mCursor) {
mCursor = aCursor;
}
}
void
SmsRequest::SetSuccess(const JS::Value& aResult)
{
@ -213,7 +195,6 @@ SmsRequest::SetError(int32_t aError)
"Can't call SetError() with SUCCESS_NO_ERROR!");
mDone = true;
mCursor = nullptr;
switch (aError) {
case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
@ -388,75 +369,6 @@ SmsRequest::NotifyDeleteMessageFailed(int32_t aError)
return NotifyError(aError);
}
NS_IMETHODIMP
SmsRequest::NotifyMessageListCreated(int32_t aListId, 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(ReplyCreateMessageList(aListId, data)));
} else {
nsCOMPtr<SmsCursor> cursor = new SmsCursor(aListId, this);
cursor->SetMessage(smsMessage);
return NotifySuccess<nsIDOMMozSmsCursor*>(cursor);
}
}
NS_IMETHODIMP
SmsRequest::NotifyReadMessageListFailed(int32_t aError)
{
if (mParent) {
return SendMessageReply(MessageReply(ReplyCreateMessageListFail(aError)));
}
if (mCursor) {
static_cast<SmsCursor*>(mCursor.get())->Disconnect();
}
return NotifyError(aError);
}
NS_IMETHODIMP
SmsRequest::NotifyNextMessageInListGot(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(ReplyGetNextMessage(data)));
}
nsCOMPtr<SmsCursor> cursor = static_cast<SmsCursor*>(mCursor.get());
NS_ASSERTION(cursor, "Request should have an cursor in that case!");
cursor->SetMessage(smsMessage);
return NotifySuccess<nsIDOMMozSmsCursor*>(cursor);
}
NS_IMETHODIMP
SmsRequest::NotifyNoMessageInList()
{
if (mParent) {
return SendMessageReply(MessageReply(ReplyNoMessageInList()));
}
nsCOMPtr<nsIDOMMozSmsCursor> cursor = mCursor;
if (!cursor) {
cursor = new SmsCursor();
} else {
static_cast<SmsCursor*>(cursor.get())->Disconnect();
}
return NotifySuccess<nsIDOMMozSmsCursor*>(cursor);
}
NS_IMETHODIMP
SmsRequest::NotifyMessageMarkedRead(bool aRead)
{

View File

@ -11,7 +11,6 @@
#include "nsDOMEventTargetHelper.h"
class nsIDOMMozSmsMessage;
class nsIDOMMozSmsCursor;
namespace mozilla {
namespace dom {
@ -56,8 +55,6 @@ class SmsRequest : public nsDOMEventTargetHelper
, public nsIMobileMessageCallback
{
public:
friend class SmsCursor;
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMREQUEST
NS_DECL_NSIMOBILEMESSAGECALLBACK
@ -72,8 +69,6 @@ public:
static already_AddRefed<nsIDOMMozSmsRequest> Create(MobileMessageManager* aManager);
static already_AddRefed<SmsRequest> Create(mobilemessage::SmsRequestParent* requestParent);
void Reset();
void SetActorDied() {
mParentAlive = false;
}
@ -101,11 +96,6 @@ private:
*/
void SetSuccess(bool aResult);
/**
* Set the object in a success state with the result being a SmsCursor.
*/
void SetSuccess(nsIDOMMozSmsCursor* aCursor);
/**
* Set the object in a success state with the result being the given JS::Value.
*/
@ -134,7 +124,6 @@ private:
bool mParentAlive;
mobilemessage::SmsRequestParent* mParent;
nsCOMPtr<nsIDOMDOMError> mError;
nsCOMPtr<nsIDOMMozSmsCursor> mCursor;
};
} // namespace dom

View File

@ -38,40 +38,12 @@ MobileMessageDatabaseService::DeleteMessage(int32_t aMessageId,
}
NS_IMETHODIMP
MobileMessageDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIMobileMessageCallback* aRequest)
MobileMessageDatabaseService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIMobileMessageCursorCallback* aCallback,
nsICursorContinueCallback** aResult)
{
if (!AndroidBridge::Bridge()) {
return NS_OK;
}
AndroidBridge::Bridge()->CreateMessageList(
static_cast<SmsFilter*>(aFilter)->GetData(), aReverse, aRequest);
return NS_OK;
}
NS_IMETHODIMP
MobileMessageDatabaseService::GetNextMessageInList(int32_t aListId,
nsIMobileMessageCallback* aRequest)
{
if (!AndroidBridge::Bridge()) {
return NS_OK;
}
AndroidBridge::Bridge()->GetNextMessageInList(aListId, aRequest);
return NS_OK;
}
NS_IMETHODIMP
MobileMessageDatabaseService::ClearMessageList(int32_t aListId)
{
if (!AndroidBridge::Bridge()) {
return NS_OK;
}
AndroidBridge::Bridge()->ClearMessageList(aListId);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP

View File

@ -28,24 +28,10 @@ MobileMessageDatabaseService::DeleteMessage(int32_t aMessageId,
}
NS_IMETHODIMP
MobileMessageDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIMobileMessageCallback* aRequest)
{
NS_ERROR("We should not be here!");
return NS_OK;
}
NS_IMETHODIMP
MobileMessageDatabaseService::GetNextMessageInList(int32_t aListId,
nsIMobileMessageCallback* aRequest)
{
NS_ERROR("We should not be here!");
return NS_OK;
}
NS_IMETHODIMP
MobileMessageDatabaseService::ClearMessageList(int32_t aListId)
MobileMessageDatabaseService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIMobileMessageCursorCallback* aCallback,
nsICursorContinueCallback** aResult)
{
NS_ERROR("We should not be here!");
return NS_OK;