mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1057915 - 1/2: [MobileMessage] Ability to return multiple entries in getMessages/getThreads cursor.result. DOM & IPDL changes. r=smaug
This commit is contained in:
parent
05b67b7329
commit
f1f889e5f0
@ -8,11 +8,94 @@
|
|||||||
#include "nsIDOMDOMRequest.h"
|
#include "nsIDOMDOMRequest.h"
|
||||||
#include "nsIDOMMozSmsMessage.h"
|
#include "nsIDOMMozSmsMessage.h"
|
||||||
#include "nsIMobileMessageCallback.h"
|
#include "nsIMobileMessageCallback.h"
|
||||||
#include "DOMCursor.h"
|
|
||||||
#include "nsServiceManagerUtils.h" // for do_GetService
|
#include "nsServiceManagerUtils.h" // for do_GetService
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(MobileMessageCursor, DOMCursor,
|
||||||
|
mPendingResults)
|
||||||
|
|
||||||
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileMessageCursor)
|
||||||
|
NS_INTERFACE_MAP_END_INHERITING(DOMCursor)
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(MobileMessageCursor, DOMCursor)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(MobileMessageCursor, DOMCursor)
|
||||||
|
|
||||||
|
MobileMessageCursor::MobileMessageCursor(nsPIDOMWindow* aWindow,
|
||||||
|
nsICursorContinueCallback* aCallback)
|
||||||
|
: DOMCursor(aWindow, aCallback)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
MobileMessageCursor::Continue()
|
||||||
|
{
|
||||||
|
// We have originally:
|
||||||
|
//
|
||||||
|
// DOMCursor::Continue()
|
||||||
|
// +-> DOMCursor::Continue(ErrorResult& aRv)
|
||||||
|
//
|
||||||
|
// Now it becomes:
|
||||||
|
//
|
||||||
|
// MobileMessageCursor::Continue()
|
||||||
|
// +-> DOMCursor::Continue()
|
||||||
|
// +-> MobileMessageCursor::Continue(ErrorResult& aRv)
|
||||||
|
// o-> DOMCursor::Continue(ErrorResult& aRv)
|
||||||
|
return DOMCursor::Continue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MobileMessageCursor::Continue(ErrorResult& aRv)
|
||||||
|
{
|
||||||
|
// An ordinary DOMCursor works in following flow:
|
||||||
|
//
|
||||||
|
// DOMCursor::Continue()
|
||||||
|
// +-> DOMCursor::Reset()
|
||||||
|
// +-> nsICursorContinueCallback::HandleContinue()
|
||||||
|
// +-> nsIMobileMessageCursorCallback::NotifyCursorResult()
|
||||||
|
// +-> DOMCursor::FireSuccess()
|
||||||
|
//
|
||||||
|
// With no pending result, we call to |DOMCursor::Continue()| as usual.
|
||||||
|
if (!mPendingResults.Length()) {
|
||||||
|
DOMCursor::Continue(aRv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, reset current result and fire a success event with the last
|
||||||
|
// pending one.
|
||||||
|
Reset();
|
||||||
|
|
||||||
|
nsresult rv = FireSuccessWithNextPendingResult();
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
aRv.Throw(rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
MobileMessageCursor::FireSuccessWithNextPendingResult()
|
||||||
|
{
|
||||||
|
// We're going to pop the last element from mPendingResults, so it must not
|
||||||
|
// be empty.
|
||||||
|
MOZ_ASSERT(mPendingResults.Length());
|
||||||
|
|
||||||
|
AutoJSAPI jsapi;
|
||||||
|
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSContext* cx = jsapi.cx();
|
||||||
|
JS::Rooted<JS::Value> val(cx);
|
||||||
|
nsresult rv =
|
||||||
|
nsContentUtils::WrapNative(cx, mPendingResults.LastElement(), &val);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
mPendingResults.RemoveElementAt(mPendingResults.Length() - 1);
|
||||||
|
|
||||||
|
FireSuccess(val);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
namespace mobilemessage {
|
namespace mobilemessage {
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION(MobileMessageCursorCallback, mDOMCursor)
|
NS_IMPL_CYCLE_COLLECTION(MobileMessageCursorCallback, mDOMCursor)
|
||||||
@ -55,21 +138,29 @@ MobileMessageCursorCallback::NotifyCursorError(int32_t aError)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
|
MobileMessageCursorCallback::NotifyCursorResult(nsISupports** aResults,
|
||||||
|
uint32_t aSize)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mDOMCursor);
|
MOZ_ASSERT(mDOMCursor);
|
||||||
|
// We should only be notified with valid results. Or, either
|
||||||
|
// |NotifyCursorDone()| or |NotifyCursorError()| should be called instead.
|
||||||
|
MOZ_ASSERT(aResults && *aResults && aSize);
|
||||||
|
// There shouldn't be unexpected notifications before |Continue()| is called.
|
||||||
|
nsTArray<nsCOMPtr<nsISupports>>& pending = mDOMCursor->mPendingResults;
|
||||||
|
MOZ_ASSERT(pending.Length() == 0);
|
||||||
|
|
||||||
AutoJSAPI jsapi;
|
// Push pending results in reversed order.
|
||||||
if (NS_WARN_IF(!jsapi.Init(mDOMCursor->GetOwner()))) {
|
pending.SetCapacity(pending.Length() + aSize);
|
||||||
return NS_ERROR_FAILURE;
|
while (aSize) {
|
||||||
|
--aSize;
|
||||||
|
pending.AppendElement(aResults[aSize]);
|
||||||
}
|
}
|
||||||
JSContext* cx = jsapi.cx();
|
|
||||||
|
|
||||||
JS::Rooted<JS::Value> wrappedResult(cx);
|
nsresult rv = mDOMCursor->FireSuccessWithNextPendingResult();
|
||||||
nsresult rv = nsContentUtils::WrapNative(cx, aResult, &wrappedResult);
|
if (NS_FAILED(rv)) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NotifyCursorError(nsIMobileMessageCallback::INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
mDOMCursor->FireSuccess(wrappedResult);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#ifndef mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
|
#ifndef mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
|
||||||
#define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
|
#define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
|
||||||
|
|
||||||
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/dom/DOMCursor.h"
|
||||||
#include "nsIMobileMessageCursorCallback.h"
|
#include "nsIMobileMessageCursorCallback.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
@ -16,12 +18,46 @@ class nsICursorContinueCallback;
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
class DOMCursor;
|
|
||||||
class MobileMessageManager;
|
class MobileMessageManager;
|
||||||
|
|
||||||
namespace mobilemessage {
|
namespace mobilemessage {
|
||||||
|
class MobileMessageCursorCallback;
|
||||||
|
} // namespace mobilemessage
|
||||||
|
|
||||||
class MobileMessageCursorCallback : public nsIMobileMessageCursorCallback
|
class MobileMessageCursor MOZ_FINAL : public DOMCursor
|
||||||
|
{
|
||||||
|
friend class mobilemessage::MobileMessageCursorCallback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileMessageCursor, DOMCursor)
|
||||||
|
|
||||||
|
MobileMessageCursor(nsPIDOMWindow* aWindow,
|
||||||
|
nsICursorContinueCallback* aCallback);
|
||||||
|
|
||||||
|
// Override XPIDL continue function to suppress -Werror,-Woverloaded-virtual.
|
||||||
|
NS_IMETHOD
|
||||||
|
Continue(void) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
Continue(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||||
|
~MobileMessageCursor() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// List of read-ahead results in reversed order.
|
||||||
|
nsTArray<nsCOMPtr<nsISupports>> mPendingResults;
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
FireSuccessWithNextPendingResult();
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace mobilemessage {
|
||||||
|
|
||||||
|
class MobileMessageCursorCallback MOZ_FINAL : public nsIMobileMessageCursorCallback
|
||||||
{
|
{
|
||||||
friend class mozilla::dom::MobileMessageManager;
|
friend class mozilla::dom::MobileMessageManager;
|
||||||
|
|
||||||
@ -37,12 +73,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~MobileMessageCursorCallback()
|
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||||
|
~MobileMessageCursorCallback()
|
||||||
{
|
{
|
||||||
MOZ_COUNT_DTOR(MobileMessageCursorCallback);
|
MOZ_COUNT_DTOR(MobileMessageCursorCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<DOMCursor> mDOMCursor;
|
nsRefPtr<MobileMessageCursor> mDOMCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mobilemessage
|
} // namespace mobilemessage
|
||||||
|
@ -439,9 +439,10 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
|
cursorCallback->mDOMCursor =
|
||||||
|
new MobileMessageCursor(GetOwner(), continueCallback);
|
||||||
|
|
||||||
nsRefPtr<DOMCursor> cursor = cursorCallback->mDOMCursor;
|
nsRefPtr<DOMCursor> cursor(cursorCallback->mDOMCursor);
|
||||||
return cursor.forget();
|
return cursor.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,9 +492,10 @@ MobileMessageManager::GetThreads(ErrorResult& aRv)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
|
cursorCallback->mDOMCursor =
|
||||||
|
new MobileMessageCursor(GetOwner(), continueCallback);
|
||||||
|
|
||||||
nsRefPtr<DOMCursor> cursor = cursorCallback->mDOMCursor;
|
nsRefPtr<DOMCursor> cursor(cursorCallback->mDOMCursor);
|
||||||
return cursor.forget();
|
return cursor.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3807,7 +3807,7 @@ GetMessagesCursor.prototype = {
|
|||||||
}
|
}
|
||||||
let domMessage =
|
let domMessage =
|
||||||
self.mmdb.createDomMessageFromRecord(event.target.result);
|
self.mmdb.createDomMessageFromRecord(event.target.result);
|
||||||
self.callback.notifyCursorResult(domMessage);
|
self.callback.notifyCursorResult([domMessage], 1);
|
||||||
};
|
};
|
||||||
getRequest.onerror = function(event) {
|
getRequest.onerror = function(event) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@ -3888,7 +3888,7 @@ GetThreadsCursor.prototype = {
|
|||||||
threadRecord.body,
|
threadRecord.body,
|
||||||
threadRecord.unreadCount,
|
threadRecord.unreadCount,
|
||||||
threadRecord.lastMessageType);
|
threadRecord.lastMessageType);
|
||||||
self.callback.notifyCursorResult(thread);
|
self.callback.notifyCursorResult([thread], 1);
|
||||||
};
|
};
|
||||||
getRequest.onerror = function(event) {
|
getRequest.onerror = function(event) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(8fd0dba2-032e-4190-a751-07cc3782e93e)]
|
[scriptable, builtinclass, uuid(134a6958-543b-46e2-b419-4631a2314164)]
|
||||||
interface nsIMobileMessageCursorCallback : nsISupports
|
interface nsIMobileMessageCursorCallback : nsISupports
|
||||||
{
|
{
|
||||||
void notifyCursorError(in long error);
|
void notifyCursorError(in long error);
|
||||||
void notifyCursorResult(in nsISupports result);
|
void notifyCursorResult([array, size_is(size)] in nsISupports results,
|
||||||
|
in uint32_t size);
|
||||||
void notifyCursorDone();
|
void notifyCursorDone();
|
||||||
};
|
};
|
||||||
|
@ -293,22 +293,17 @@ MobileMessageCursorChild::RecvNotifyResult(const MobileMessageCursorData& aData)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(mCursorCallback);
|
MOZ_ASSERT(mCursorCallback);
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> result;
|
|
||||||
switch(aData.type()) {
|
switch(aData.type()) {
|
||||||
case MobileMessageCursorData::TMmsMessageData:
|
case MobileMessageCursorData::TMobileMessageArrayData:
|
||||||
result = new MmsMessage(aData.get_MmsMessageData());
|
DoNotifyResult(aData.get_MobileMessageArrayData().messages());
|
||||||
break;
|
break;
|
||||||
case MobileMessageCursorData::TSmsMessageData:
|
case MobileMessageCursorData::TThreadArrayData:
|
||||||
result = new SmsMessage(aData.get_SmsMessageData());
|
DoNotifyResult(aData.get_ThreadArrayData().threads());
|
||||||
break;
|
|
||||||
case MobileMessageCursorData::TThreadData:
|
|
||||||
result = new MobileMessageThread(aData.get_ThreadData());
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MOZ_CRASH("Received invalid response parameters!");
|
MOZ_CRASH("Received invalid response parameters!");
|
||||||
}
|
}
|
||||||
|
|
||||||
mCursorCallback->NotifyCursorResult(result);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +333,48 @@ MobileMessageCursorChild::HandleContinue()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MobileMessageCursorChild::DoNotifyResult(const nsTArray<MobileMessageData>& aDataArray)
|
||||||
|
{
|
||||||
|
const uint32_t length = aDataArray.Length();
|
||||||
|
MOZ_ASSERT(length);
|
||||||
|
|
||||||
|
AutoFallibleTArray<nsISupports*, 1> autoArray;
|
||||||
|
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
|
||||||
|
|
||||||
|
AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> messages;
|
||||||
|
NS_ENSURE_TRUE_VOID(messages.SetCapacity(length));
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < length; i++) {
|
||||||
|
nsCOMPtr<nsISupports> message = CreateMessageFromMessageData(aDataArray[i]);
|
||||||
|
NS_ENSURE_TRUE_VOID(messages.AppendElement(message));
|
||||||
|
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(message.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
|
||||||
|
{
|
||||||
|
const uint32_t length = aDataArray.Length();
|
||||||
|
MOZ_ASSERT(length);
|
||||||
|
|
||||||
|
AutoFallibleTArray<nsISupports*, 1> autoArray;
|
||||||
|
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
|
||||||
|
|
||||||
|
AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> threads;
|
||||||
|
NS_ENSURE_TRUE_VOID(threads.SetCapacity(length));
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < length; i++) {
|
||||||
|
nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
|
||||||
|
NS_ENSURE_TRUE_VOID(threads.AppendElement(thread));
|
||||||
|
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mobilemessage
|
} // namespace mobilemessage
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -129,6 +129,13 @@ protected:
|
|||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
Recv__delete__(const int32_t& aError) MOZ_OVERRIDE;
|
Recv__delete__(const int32_t& aError) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void
|
||||||
|
DoNotifyResult(const nsTArray<MobileMessageData>& aData);
|
||||||
|
|
||||||
|
void
|
||||||
|
DoNotifyResult(const nsTArray<ThreadData>& aData);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mobilemessage
|
} // namespace mobilemessage
|
||||||
|
@ -843,40 +843,59 @@ MobileMessageCursorParent::NotifyCursorError(int32_t aError)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
MobileMessageCursorParent::NotifyCursorResult(nsISupports* aResult)
|
MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults,
|
||||||
|
uint32_t aSize)
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aResults && *aResults && aSize);
|
||||||
|
|
||||||
// The child process could die before this asynchronous notification, in which
|
// The child process could die before this asynchronous notification, in which
|
||||||
// case ActorDestroy() was called and mContinueCallback is now null. Return an
|
// case ActorDestroy() was called and mContinueCallback is now null. Return an
|
||||||
// error here to avoid sending a message to the dead process.
|
// error here to avoid sending a message to the dead process.
|
||||||
NS_ENSURE_TRUE(mContinueCallback, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(mContinueCallback, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMMozSmsMessage> iSms = do_QueryInterface(aResult);
|
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||||
if (iSms) {
|
do_QueryInterface(aResults[0]);
|
||||||
SmsMessage* message = static_cast<SmsMessage*>(aResult);
|
|
||||||
return SendNotifyResult(MobileMessageCursorData(message->GetData()))
|
|
||||||
? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMMozMmsMessage> iMms = do_QueryInterface(aResult);
|
|
||||||
if (iMms) {
|
|
||||||
MmsMessage* message = static_cast<MmsMessage*>(aResult);
|
|
||||||
ContentParent* parent = static_cast<ContentParent*>(Manager()->Manager());
|
|
||||||
MmsMessageData data;
|
|
||||||
if (!message->GetData(parent, data)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return SendNotifyResult(MobileMessageCursorData(data))
|
|
||||||
? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread = do_QueryInterface(aResult);
|
|
||||||
if (iThread) {
|
if (iThread) {
|
||||||
MobileMessageThread* thread = static_cast<MobileMessageThread*>(aResult);
|
nsTArray<ThreadData> threads;
|
||||||
return SendNotifyResult(MobileMessageCursorData(thread->GetData()))
|
|
||||||
|
for (uint32_t i = 0; i < aSize; i++) {
|
||||||
|
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||||
|
do_QueryInterface(aResults[i]);
|
||||||
|
NS_ENSURE_TRUE(iThread, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
MobileMessageThread* thread =
|
||||||
|
static_cast<MobileMessageThread*>(iThread.get());
|
||||||
|
threads.AppendElement(thread->GetData());
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendNotifyResult(MobileMessageCursorData(ThreadArrayData(threads)))
|
||||||
? NS_OK : NS_ERROR_FAILURE;
|
? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_CRASH("Received invalid response parameters!");
|
ContentParent* parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||||
|
nsTArray<MobileMessageData> messages;
|
||||||
|
for (uint32_t i = 0; i < aSize; i++) {
|
||||||
|
nsCOMPtr<nsIDOMMozSmsMessage> iSms = do_QueryInterface(aResults[i]);
|
||||||
|
if (iSms) {
|
||||||
|
SmsMessage* sms = static_cast<SmsMessage*>(iSms.get());
|
||||||
|
messages.AppendElement(sms->GetData());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMMozMmsMessage> iMms = do_QueryInterface(aResults[i]);
|
||||||
|
if (iMms) {
|
||||||
|
MmsMessage* mms = static_cast<MmsMessage*>(iMms.get());
|
||||||
|
MmsMessageData mmsData;
|
||||||
|
NS_ENSURE_TRUE(mms->GetData(parent, mmsData), NS_ERROR_FAILURE);
|
||||||
|
messages.AppendElement(mmsData);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendNotifyResult(MobileMessageCursorData(MobileMessageArrayData(messages)))
|
||||||
|
? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -99,11 +99,20 @@ struct ThreadData
|
|||||||
MessageType lastMessageType;
|
MessageType lastMessageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MobileMessageArrayData
|
||||||
|
{
|
||||||
|
MobileMessageData[] messages;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ThreadArrayData
|
||||||
|
{
|
||||||
|
ThreadData[] threads;
|
||||||
|
};
|
||||||
|
|
||||||
union MobileMessageCursorData
|
union MobileMessageCursorData
|
||||||
{
|
{
|
||||||
MmsMessageData;
|
MobileMessageArrayData;
|
||||||
SmsMessageData;
|
ThreadArrayData;
|
||||||
ThreadData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeletedMessageInfoData
|
struct DeletedMessageInfoData
|
||||||
|
@ -303,9 +303,9 @@ function createMmdbCursor(aMmdb, aMethodName) {
|
|||||||
deferred.reject([aRv, results]);
|
deferred.reject([aRv, results]);
|
||||||
},
|
},
|
||||||
|
|
||||||
notifyCursorResult: function(aResult) {
|
notifyCursorResult: function(aResults, aSize) {
|
||||||
ok(true, "notifyCursorResult: " + aResult.id);
|
ok(true, "notifyCursorResult: " + aResults.map(function(aElement) { return aElement.id; }));
|
||||||
results.push(aResult);
|
results = results.concat(aResults);
|
||||||
cursor.handleContinue();
|
cursor.handleContinue();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user