Bug 878533 - 1/3: move MozSmsFilter to webidl dictionary. r=smaug

This commit is contained in:
Vicamo Yang 2014-08-28 11:00:03 +08:00
Родитель 583ff56f7d
Коммит b479b9fef1
19 изменённых файлов: 206 добавлений и 449 удалений

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

@ -5,8 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
// On top because they include basictypes.h:
#include "mozilla/dom/SmsFilter.h"
#ifdef XP_WIN
#undef GetClassName
@ -125,7 +123,6 @@
#include "nsIDOMMozSmsMessage.h"
#include "nsIDOMMozMmsMessage.h"
#include "nsIDOMSmsFilter.h"
#include "nsIDOMMozMobileMessageThread.h"
#ifdef MOZ_B2G_FM
@ -348,9 +345,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -422,7 +416,6 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
{
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, DOMMultipartFileImpl::NewBlob)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, DOMMultipartFileImpl::NewFile)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, SmsFilter::NewSmsFilter)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
};
#undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
@ -913,10 +906,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
DOM_CLASSINFO_MAP_END

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

@ -55,7 +55,6 @@ DOMCI_CLASS(ModalContentWindow)
DOMCI_CLASS(MozSmsMessage)
DOMCI_CLASS(MozMmsMessage)
DOMCI_CLASS(MozSmsFilter)
DOMCI_CLASS(MozMobileMessageThread)
// @font-face in CSS

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

@ -1990,7 +1990,6 @@ addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
notflattened=True)
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozSmsFilter', headerFile='nsIDOMSmsFilter.h')
addExternalIface('MozSmsMessage')
addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
notflattened=True)

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

@ -9,7 +9,6 @@ XPIDL_SOURCES += [
'nsIDOMMozMmsMessage.idl',
'nsIDOMMozMobileMessageThread.idl',
'nsIDOMMozSmsMessage.idl',
'nsIDOMSmsFilter.idl',
'nsIMmsService.idl',
'nsIMobileMessageCallback.idl',
'nsIMobileMessageCursorCallback.idl',

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

@ -1,33 +0,0 @@
/* 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 "nsISupports.idl"
[scriptable, builtinclass, uuid(17890b60-0367-45c6-9729-62e5bf349b2b)]
interface nsIDOMMozSmsFilter : nsISupports
{
// A date that can return null.
[implicit_jscontext]
attribute jsval startDate;
// A date that can return null.
[implicit_jscontext]
attribute jsval endDate;
// An array of DOMString that can return null.
[implicit_jscontext]
attribute jsval numbers;
// A DOMString that can return and be set to "sent", "received" or null.
[Null(Empty)]
attribute DOMString delivery;
// A read flag that can return and be set to a boolean or null.
[implicit_jscontext]
attribute jsval read;
// A thread id that can return and be set to a numeric value or null.
[implicit_jscontext]
attribute jsval threadId;
};

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

@ -12,11 +12,10 @@
%}
interface nsICursorContinueCallback;
interface nsIDOMMozSmsFilter;
interface nsIMobileMessageCallback;
interface nsIMobileMessageCursorCallback;
[scriptable, uuid(8439916f-abc1-4c67-aa45-8a276a0a7855)]
[scriptable, uuid(ead626bc-f5b4-47e1-921c-0b956c9298e0)]
interface nsIMobileMessageDatabaseService : nsISupports
{
[binaryname(GetMessageMoz)]
@ -27,7 +26,16 @@ interface nsIMobileMessageDatabaseService : nsISupports
in uint32_t count,
in nsIMobileMessageCallback request);
nsICursorContinueCallback createMessageCursor(in nsIDOMMozSmsFilter filter,
nsICursorContinueCallback createMessageCursor(in boolean hasStartDate,
in unsigned long long startDate,
in boolean hasEndDate,
in unsigned long long endDate,
[array, size_is(numbersCount)] in wstring numbers,
in uint32_t numbersCount,
[Null(Null), Undefined(Null)] in DOMString delivery,
in boolean hasRead,
in boolean read,
in unsigned long long threadId,
in boolean reverse,
in nsIMobileMessageCursorCallback callback);

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

@ -26,7 +26,6 @@
#include "nsIObserverService.h"
#include "nsISmsService.h"
#include "nsServiceManagerUtils.h" // For do_GetService()
#include "SmsFilter.h"
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define RETRIEVING_EVENT_NAME NS_LITERAL_STRING("retrieving")
@ -367,7 +366,7 @@ MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMes
}
already_AddRefed<DOMCursor>
MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
bool aReverse,
ErrorResult& aRv)
{
@ -378,16 +377,62 @@ MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
return nullptr;
}
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
if (!filter) {
filter = new SmsFilter();
bool hasStartDate = !aFilter.mStartDate.IsNull();
uint64_t startDate = 0;
if (hasStartDate) {
startDate = aFilter.mStartDate.Value();
}
bool hasEndDate = !aFilter.mEndDate.IsNull();
uint64_t endDate = 0;
if (hasEndDate) {
endDate = aFilter.mEndDate.Value();
}
nsAutoArrayPtr<const char16_t*> ptrNumbers;
uint32_t numbersCount = 0;
if (!aFilter.mNumbers.IsNull() &&
aFilter.mNumbers.Value().Length()) {
const FallibleTArray<nsString>& numbers = aFilter.mNumbers.Value();
uint32_t index;
numbersCount = numbers.Length();
ptrNumbers = new const char16_t* [numbersCount];
for (index = 0; index < numbersCount; index++) {
ptrNumbers[index] = numbers[index].get();
}
}
nsString delivery;
delivery.SetIsVoid(true);
if (!aFilter.mDelivery.IsNull()) {
const uint32_t index = static_cast<uint32_t>(aFilter.mDelivery.Value());
const EnumEntry& entry =
MobileMessageFilterDeliveryValues::strings[index];
delivery.AssignASCII(entry.value, entry.length);
}
bool hasRead = !aFilter.mRead.IsNull();
bool read = false;
if (hasRead) {
read = aFilter.mRead.Value();
}
uint64_t threadId = 0;
if (!aFilter.mThreadId.IsNull()) {
threadId = aFilter.mThreadId.Value();
}
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
new MobileMessageCursorCallback();
nsCOMPtr<nsICursorContinueCallback> continueCallback;
nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
nsresult rv = dbService->CreateMessageCursor(hasStartDate, startDate,
hasEndDate, endDate,
ptrNumbers, numbersCount,
delivery,
hasRead, read,
threadId,
aReverse, cursorCallback,
getter_AddRefs(continueCallback));
if (NS_FAILED(rv)) {
aRv.Throw(rv);

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

@ -14,7 +14,6 @@
class nsISmsService;
class nsIDOMMozSmsMessage;
class nsIDOMMozMmsMessage;
class nsIDOMMozSmsFilter;
namespace mozilla {
namespace dom {
@ -23,6 +22,7 @@ class DOMRequest;
class DOMCursor;
struct MmsParameters;
struct MmsSendParameters;
struct MobileMessageFilter;
struct SmsSendParameters;
class MobileMessageManager MOZ_FINAL : public DOMEventTargetHelper
@ -90,7 +90,7 @@ public:
ErrorResult& aRv);
already_AddRefed<DOMCursor>
GetMessages(nsIDOMMozSmsFilter* aFilter,
GetMessages(const MobileMessageFilter& aFilter,
bool aReverse,
ErrorResult& aRv);

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

@ -1,292 +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 "SmsFilter.h"
#include "jsapi.h"
#include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch.
#include "js/Utility.h"
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
#include "mozilla/dom/ToJSValue.h"
#include "nsDOMString.h"
#include "nsError.h"
#include "nsIDOMClassInfo.h"
#include "nsJSUtils.h"
using namespace mozilla::dom::mobilemessage;
DOMCI_DATA(MozSmsFilter, mozilla::dom::SmsFilter)
namespace mozilla {
namespace dom {
NS_INTERFACE_MAP_BEGIN(SmsFilter)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsFilter)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsFilter)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(SmsFilter)
NS_IMPL_RELEASE(SmsFilter)
SmsFilter::SmsFilter()
{
mData.startDate() = 0;
mData.endDate() = 0;
mData.delivery() = eDeliveryState_Unknown;
mData.read() = eReadState_Unknown;
mData.threadId() = 0;
}
SmsFilter::SmsFilter(const SmsFilterData& aData)
: mData(aData)
{
}
/* static */ nsresult
SmsFilter::NewSmsFilter(nsISupports** aSmsFilter)
{
NS_ADDREF(*aSmsFilter = new SmsFilter());
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::GetStartDate(JSContext* aCx, JS::MutableHandle<JS::Value> aStartDate)
{
if (mData.startDate() == 0) {
aStartDate.setNull();
return NS_OK;
}
aStartDate.setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.startDate()));
NS_ENSURE_TRUE(aStartDate.isObject(), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetStartDate(JSContext* aCx, JS::Handle<JS::Value> aStartDate)
{
if (aStartDate.isNull()) {
mData.startDate() = 0;
return NS_OK;
}
if (!aStartDate.isObject()) {
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> obj(aCx, &aStartDate.toObject());
if (!JS_ObjectIsDate(aCx, obj)) {
return NS_ERROR_INVALID_ARG;
}
mData.startDate() = js_DateGetMsecSinceEpoch(obj);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::GetEndDate(JSContext* aCx, JS::MutableHandle<JS::Value> aEndDate)
{
if (mData.endDate() == 0) {
aEndDate.setNull();
return NS_OK;
}
aEndDate.setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.endDate()));
NS_ENSURE_TRUE(aEndDate.isObject(), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetEndDate(JSContext* aCx, JS::Handle<JS::Value> aEndDate)
{
if (aEndDate.isNull()) {
mData.endDate() = 0;
return NS_OK;
}
if (!aEndDate.isObject()) {
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> obj(aCx, &aEndDate.toObject());
if (!JS_ObjectIsDate(aCx, obj)) {
return NS_ERROR_INVALID_ARG;
}
mData.endDate() = js_DateGetMsecSinceEpoch(obj);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::GetNumbers(JSContext* aCx, JS::MutableHandle<JS::Value> aNumbers)
{
uint32_t length = mData.numbers().Length();
if (length == 0) {
aNumbers.setNull();
return NS_OK;
}
if (!ToJSValue(aCx, mData.numbers(), aNumbers)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetNumbers(JSContext* aCx, JS::Handle<JS::Value> aNumbers)
{
if (aNumbers.isNull()) {
mData.numbers().Clear();
return NS_OK;
}
if (!aNumbers.isObject()) {
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> obj(aCx, &aNumbers.toObject());
if (!JS_IsArrayObject(aCx, obj)) {
return NS_ERROR_INVALID_ARG;
}
uint32_t size;
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &size));
nsTArray<nsString> numbers;
for (uint32_t i=0; i<size; ++i) {
JS::Rooted<JS::Value> jsNumber(aCx);
if (!JS_GetElement(aCx, obj, i, &jsNumber)) {
return NS_ERROR_INVALID_ARG;
}
if (!jsNumber.isString()) {
return NS_ERROR_INVALID_ARG;
}
nsAutoJSString number;
if (!number.init(aCx, jsNumber.toString())) {
return NS_ERROR_FAILURE;
}
numbers.AppendElement(number);
}
mData.numbers().Clear();
mData.numbers().AppendElements(numbers);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::GetDelivery(nsAString& aDelivery)
{
switch (mData.delivery()) {
case eDeliveryState_Received:
aDelivery = DELIVERY_RECEIVED;
break;
case eDeliveryState_Sent:
aDelivery = DELIVERY_SENT;
break;
case eDeliveryState_Unknown:
SetDOMStringToNull(aDelivery);
break;
default:
NS_ASSERTION(false, "We shouldn't get another delivery state!");
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetDelivery(const nsAString& aDelivery)
{
if (aDelivery.IsEmpty()) {
mData.delivery() = eDeliveryState_Unknown;
return NS_OK;
}
if (aDelivery.Equals(DELIVERY_RECEIVED)) {
mData.delivery() = eDeliveryState_Received;
return NS_OK;
}
if (aDelivery.Equals(DELIVERY_SENT)) {
mData.delivery() = eDeliveryState_Sent;
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
SmsFilter::GetRead(JSContext* aCx, JS::MutableHandle<JS::Value> aRead)
{
if (mData.read() == eReadState_Unknown) {
aRead.setNull();
return NS_OK;
}
aRead.setBoolean(mData.read());
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetRead(JSContext* aCx, JS::Handle<JS::Value> aRead)
{
if (aRead.isNull()) {
mData.read() = eReadState_Unknown;
return NS_OK;
}
if (!aRead.isBoolean()) {
return NS_ERROR_INVALID_ARG;
}
mData.read() = aRead.toBoolean() ? eReadState_Read : eReadState_Unread;
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::GetThreadId(JSContext* aCx, JS::MutableHandle<JS::Value> aThreadId)
{
if (!mData.threadId()) {
aThreadId.setNull();
return NS_OK;
}
aThreadId.setNumber(static_cast<double>(mData.threadId()));
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetThreadId(JSContext* aCx, JS::Handle<JS::Value> aThreadId)
{
if (aThreadId.isNull()) {
mData.threadId() = 0;
return NS_OK;
}
if (!aThreadId.isNumber()) {
return NS_ERROR_INVALID_ARG;
}
double number = aThreadId.toNumber();
uint64_t integer = static_cast<uint64_t>(number);
if (integer == 0 || integer != number) {
return NS_ERROR_INVALID_ARG;
}
mData.threadId() = integer;
return NS_OK;
}
} // namespace dom
} // namespace mozilla

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

@ -1,43 +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_SmsFilter_h
#define mozilla_dom_mobilemessage_SmsFilter_h
#include "mozilla/dom/mobilemessage/SmsTypes.h"
#include "nsIDOMSmsFilter.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace dom {
class SmsFilter MOZ_FINAL : public nsIDOMMozSmsFilter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZSMSFILTER
SmsFilter();
SmsFilter(const mobilemessage::SmsFilterData& aData);
const mobilemessage::SmsFilterData& GetData() const;
static nsresult NewSmsFilter(nsISupports** aSmsFilter);
private:
~SmsFilter() {}
mobilemessage::SmsFilterData mData;
};
inline const mobilemessage::SmsFilterData&
SmsFilter::GetData() const {
return mData;
}
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_SmsFilter_h

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

@ -48,16 +48,7 @@ enum ReadStatus {
eReadStatus_EndGuard
};
// For {Mms,Sms}FilterData.read.
enum ReadState {
eReadState_Unknown = -1,
eReadState_Unread,
eReadState_Read,
// This state should stay at the end.
eReadState_EndGuard
};
// For {Mms,Sms}FilterData.messageClass.
// For {Mms,Sms}MessageData.messageClass.
enum MessageClass {
eMessageClass_Normal = 0,
eMessageClass_Class0,
@ -115,17 +106,6 @@ struct ParamTraits<mozilla::dom::mobilemessage::ReadStatus>
mozilla::dom::mobilemessage::eReadStatus_EndGuard>
{};
/**
* Read state serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::ReadState>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::ReadState,
mozilla::dom::mobilemessage::eReadState_Unknown,
mozilla::dom::mobilemessage::eReadState_EndGuard>
{};
/**
* Message class serializer.
*/

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

@ -3,7 +3,6 @@
* 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 "SmsFilter.h"
#include "MobileMessageDatabaseService.h"
#include "AndroidBridge.h"
@ -47,7 +46,16 @@ MobileMessageDatabaseService::DeleteMessage(int32_t *aMessageIds,
}
NS_IMETHODIMP
MobileMessageDatabaseService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
MobileMessageDatabaseService::CreateMessageCursor(bool aHasStartDate,
uint64_t aStartDate,
bool aHasEndDate,
uint64_t aEndDate,
const char16_t** aNumbers,
uint32_t aNumbersCount,
const nsAString& aDelivery,
bool aHasRead,
bool aRead,
uint64_t aThreadId,
bool aReverse,
nsIMobileMessageCursorCallback* aCallback,
nsICursorContinueCallback** aResult)

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

@ -3105,25 +3105,47 @@ MobileMessageDB.prototype = {
}, [MESSAGE_STORE_NAME, THREAD_STORE_NAME]);
},
createMessageCursor: function(filter, reverse, callback) {
createMessageCursor: function(aHasStartDate, aStartDate, aHasEndDate,
aEndDate, aNumbers, aNumbersCount, aDelivery,
aHasRead, aRead, aThreadId, aReverse, aCallback) {
if (DEBUG) {
debug("Creating a message cursor. Filters:" +
" startDate: " + filter.startDate +
" endDate: " + filter.endDate +
" delivery: " + filter.delivery +
" numbers: " + filter.numbers +
" read: " + filter.read +
" threadId: " + filter.threadId +
" reverse: " + reverse);
" startDate: " + (aHasStartDate ? aStartDate : "(null)") +
" endDate: " + (aHasEndDate ? aEndDate : "(null)") +
" delivery: " + aDelivery +
" numbers: " + (aNumbersCount ? aNumbers : "(null)") +
" read: " + (aHasRead ? aRead : "(null)") +
" threadId: " + aThreadId +
" reverse: " + aReverse);
}
let cursor = new GetMessagesCursor(this, callback);
let filter = {};
if (aHasStartDate) {
filter.startDate = aStartDate;
}
if (aHasEndDate) {
filter.endDate = aEndDate;
}
if (aNumbersCount) {
filter.numbers = aNumbers.slice();
}
if (aDelivery !== null) {
filter.delivery = aDelivery;
}
if (aHasRead) {
filter.read = aRead;
}
if (aThreadId) {
filter.threadId = aThreadId;
}
let cursor = new GetMessagesCursor(this, aCallback);
let self = this;
self.newTxn(READ_ONLY, function(error, txn, stores) {
let collector = cursor.collector;
let collect = collector.collect.bind(collector);
FilterSearcherHelper.transact(self, txn, error, filter, reverse, collect);
FilterSearcherHelper.transact(self, txn, error, filter, aReverse, collect);
}, [MESSAGE_STORE_NAME, PARTICIPANT_STORE_NAME]);
return cursor;
@ -3311,11 +3333,11 @@ let FilterSearcherHelper = {
filterTimestamp: function(startDate, endDate, direction, txn, collect) {
let range = null;
if (startDate != null && endDate != null) {
range = IDBKeyRange.bound(startDate.getTime(), endDate.getTime());
range = IDBKeyRange.bound(startDate, endDate);
} else if (startDate != null) {
range = IDBKeyRange.lowerBound(startDate.getTime());
range = IDBKeyRange.lowerBound(startDate);
} else if (endDate != null) {
range = IDBKeyRange.upperBound(endDate.getTime());
range = IDBKeyRange.upperBound(endDate);
}
this.filterIndex("timestamp", range, direction, txn, collect);
},
@ -3330,7 +3352,7 @@ let FilterSearcherHelper = {
* @param error
* Previous error while creating the transaction.
* @param filter
* A SmsFilter object.
* A MobileMessageFilter dictionary.
* @param reverse
* A boolean value indicating whether we should filter message in
* reversed order.
@ -3368,10 +3390,10 @@ let FilterSearcherHelper = {
// than all numeric values.
let startDate = 0, endDate = "";
if (filter.startDate != null) {
startDate = filter.startDate.getTime();
startDate = filter.startDate;
}
if (filter.endDate != null) {
endDate = filter.endDate.getTime();
endDate = filter.endDate;
}
let single, intersectionCollector;

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

@ -108,8 +108,13 @@ MobileMessageDatabaseService.prototype = {
this.mmdb.deleteMessage(aMessageIds, aLength, aRequest);
},
createMessageCursor: function(aFilter, aReverse, aCallback) {
return this.mmdb.createMessageCursor(aFilter, aReverse, aCallback);
createMessageCursor: function(aHasStartDate, aStartDate, aHasEndDate,
aEndDate, aNumbers, aNumbersCount, aDelivery,
aHasRead, aRead, aThreadId, aReverse, aCallback) {
return this.mmdb.createMessageCursor(aHasStartDate, aStartDate, aHasEndDate,
aEndDate, aNumbers, aNumbersCount,
aDelivery, aHasRead, aRead, aThreadId,
aReverse, aCallback);
},
markMessageRead: function(aMessageId, aValue, aSendReadReport, aRequest) {

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

@ -8,7 +8,6 @@
#include "nsXULAppAPI.h"
#include "mozilla/dom/mobilemessage/SmsChild.h"
#include "SmsMessage.h"
#include "SmsFilter.h"
#include "nsJSUtils.h"
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
#include "mozilla/dom/BindingUtils.h"
@ -220,13 +219,40 @@ SmsIPCService::DeleteMessage(int32_t *aMessageIds, uint32_t aSize,
}
NS_IMETHODIMP
SmsIPCService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
SmsIPCService::CreateMessageCursor(bool aHasStartDate,
uint64_t aStartDate,
bool aHasEndDate,
uint64_t aEndDate,
const char16_t** aNumbers,
uint32_t aNumbersCount,
const nsAString& aDelivery,
bool aHasRead,
bool aRead,
uint64_t aThreadId,
bool aReverse,
nsIMobileMessageCursorCallback* aCursorCallback,
nsICursorContinueCallback** aResult)
{
const SmsFilterData& data =
SmsFilterData(static_cast<SmsFilter*>(aFilter)->GetData());
SmsFilterData data;
data.hasStartDate() = aHasStartDate;
data.startDate() = aStartDate;
data.hasEndDate() = aHasEndDate;
data.startDate() = aEndDate;
if (aNumbersCount && aNumbers) {
nsTArray<nsString>& numbers = data.numbers();
uint32_t index;
for (index = 0; index < aNumbersCount; index++) {
numbers.AppendElement(aNumbers[index]);
}
}
data.delivery() = aDelivery;
data.hasRead() = aHasRead;
data.read() = aRead;
data.threadId() = aThreadId;
return SendCursorRequest(CreateMessageCursorRequest(data, aReverse),
aCursorCallback, aResult);

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

@ -14,7 +14,6 @@
#include "SmsMessage.h"
#include "MmsMessage.h"
#include "nsIMobileMessageDatabaseService.h"
#include "SmsFilter.h"
#include "MobileMessageThread.h"
#include "nsIDOMFile.h"
#include "mozilla/dom/ipc/Blob.h"
@ -774,10 +773,31 @@ MobileMessageCursorParent::DoRequest(const CreateMessageCursorRequest& aRequest)
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
if (dbService) {
nsCOMPtr<nsIDOMMozSmsFilter> filter = new SmsFilter(aRequest.filter());
bool reverse = aRequest.reverse();
const SmsFilterData& filter = aRequest.filter();
rv = dbService->CreateMessageCursor(filter, reverse, this,
const nsTArray<nsString>& numbers = filter.numbers();
nsAutoArrayPtr<const char16_t*> ptrNumbers;
uint32_t numbersCount = numbers.Length();
if (numbersCount) {
uint32_t index;
ptrNumbers = new const char16_t* [numbersCount];
for (index = 0; index < numbersCount; index++) {
ptrNumbers[index] = numbers[index].get();
}
}
rv = dbService->CreateMessageCursor(filter.hasStartDate(),
filter.startDate(),
filter.hasEndDate(),
filter.endDate(),
ptrNumbers, numbersCount,
filter.delivery(),
filter.hasRead(),
filter.read(),
filter.threadId(),
aRequest.reverse(),
this,
getter_AddRefs(mContinueCallback));
}

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

@ -77,11 +77,14 @@ union MobileMessageData
struct SmsFilterData
{
bool hasStartDate;
uint64_t startDate;
bool hasEndDate;
uint64_t endDate;
nsString[] numbers;
DeliveryState delivery;
ReadState read;
nsString delivery;
bool hasRead;
bool read;
uint64_t threadId;
};

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

@ -40,7 +40,6 @@ EXPORTS.mozilla.dom += [
'DOMMobileMessageError.h',
'MmsMessage.h',
'MobileMessageManager.h',
'SmsFilter.h',
'SmsMessage.h',
]
@ -57,7 +56,6 @@ UNIFIED_SOURCES += [
'MobileMessageManager.cpp',
'MobileMessageService.cpp',
'MobileMessageThread.cpp',
'SmsFilter.cpp',
'SmsMessage.cpp',
'SmsServicesFactory.cpp',
]

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

@ -5,7 +5,6 @@
*/
interface MozMmsMessage;
interface MozSmsFilter;
interface MozSmsMessage;
dictionary SmsSegmentInfo {
@ -51,6 +50,31 @@ dictionary MmsSendParameters {
// specified under the multi-sim scenario.
};
enum MobileMessageFilterDelivery { "sent", "received" };
dictionary MobileMessageFilter
{
// Close lower bound range for filtering by the message timestamp.
// Time in milliseconds since Epoch.
[EnforceRange] DOMTimeStamp? startDate = null;
// Close upper bound range for filtering by the message timestamp.
// Time in milliseconds since Epoch.
[EnforceRange] DOMTimeStamp? endDate = null;
// An array of string message participant addresses that any of which
// appears or matches a message's sendor or recipients addresses.
sequence<DOMString>? numbers = null;
MobileMessageFilterDelivery? delivery = null;
// Filtering by whether a message has been read or not.
boolean? read = null;
// Filtering by a message's threadId attribute.
[EnforceRange] unsigned long long? threadId = 0;
};
[Pref="dom.sms.enabled"]
interface MozMobileMessageManager : EventTarget
{
@ -111,7 +135,7 @@ interface MozMobileMessageManager : EventTarget
// Iterates through Moz{Mms,Sms}Message.
[Throws]
DOMCursor getMessages(optional MozSmsFilter? filter = null,
DOMCursor getMessages(optional MobileMessageFilter filter,
optional boolean reverse = false);
[Throws]