mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 080926480632 (bug 878533) for build failure ON A CLOSED TREE
This commit is contained in:
parent
c36b2bc9b5
commit
5c2d3b683b
@ -5,6 +5,8 @@
|
||||
* 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
|
||||
@ -123,6 +125,7 @@
|
||||
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMSmsFilter.h"
|
||||
#include "nsIDOMMozMobileMessageThread.h"
|
||||
|
||||
#ifdef MOZ_B2G_FM
|
||||
@ -345,6 +348,9 @@ 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)
|
||||
|
||||
@ -416,6 +422,7 @@ 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
|
||||
@ -915,6 +922,10 @@ 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,6 +55,7 @@ DOMCI_CLASS(ModalContentWindow)
|
||||
|
||||
DOMCI_CLASS(MozSmsMessage)
|
||||
DOMCI_CLASS(MozMmsMessage)
|
||||
DOMCI_CLASS(MozSmsFilter)
|
||||
DOMCI_CLASS(MozMobileMessageThread)
|
||||
|
||||
// @font-face in CSS
|
||||
|
@ -1996,6 +1996,7 @@ 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,6 +9,7 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMMozMmsMessage.idl',
|
||||
'nsIDOMMozMobileMessageThread.idl',
|
||||
'nsIDOMMozSmsMessage.idl',
|
||||
'nsIDOMSmsFilter.idl',
|
||||
'nsIMmsService.idl',
|
||||
'nsIMobileMessageCallback.idl',
|
||||
'nsIMobileMessageCursorCallback.idl',
|
||||
|
33
dom/mobilemessage/interfaces/nsIDOMSmsFilter.idl
Normal file
33
dom/mobilemessage/interfaces/nsIDOMSmsFilter.idl
Normal file
@ -0,0 +1,33 @@
|
||||
/* 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,10 +12,11 @@
|
||||
%}
|
||||
|
||||
interface nsICursorContinueCallback;
|
||||
interface nsIDOMMozSmsFilter;
|
||||
interface nsIMobileMessageCallback;
|
||||
interface nsIMobileMessageCursorCallback;
|
||||
|
||||
[scriptable, uuid(ead626bc-f5b4-47e1-921c-0b956c9298e0)]
|
||||
[scriptable, uuid(8439916f-abc1-4c67-aa45-8a276a0a7855)]
|
||||
interface nsIMobileMessageDatabaseService : nsISupports
|
||||
{
|
||||
[binaryname(GetMessageMoz)]
|
||||
@ -26,16 +27,7 @@ interface nsIMobileMessageDatabaseService : nsISupports
|
||||
in uint32_t count,
|
||||
in nsIMobileMessageCallback request);
|
||||
|
||||
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,
|
||||
nsICursorContinueCallback createMessageCursor(in nsIDOMMozSmsFilter filter,
|
||||
in boolean reverse,
|
||||
in nsIMobileMessageCursorCallback callback);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#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")
|
||||
@ -366,7 +367,7 @@ MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMes
|
||||
}
|
||||
|
||||
already_AddRefed<DOMCursor>
|
||||
MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
||||
MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
@ -377,61 +378,16 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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 EnumEntry& entry =
|
||||
MobileMessageFilterDeliveryValues::strings[aFilter.mDelivery.Value()];
|
||||
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();
|
||||
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
|
||||
if (!filter) {
|
||||
filter = new SmsFilter();
|
||||
}
|
||||
|
||||
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
|
||||
new MobileMessageCursorCallback();
|
||||
|
||||
nsCOMPtr<nsICursorContinueCallback> continueCallback;
|
||||
nsresult rv = dbService->CreateMessageCursor(hasStartDate, startDate,
|
||||
hasEndDate, endDate,
|
||||
ptrNumbers, numbersCount,
|
||||
delivery,
|
||||
hasRead, read,
|
||||
threadId,
|
||||
aReverse, cursorCallback,
|
||||
nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
|
||||
getter_AddRefs(continueCallback));
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
|
@ -14,6 +14,7 @@
|
||||
class nsISmsService;
|
||||
class nsIDOMMozSmsMessage;
|
||||
class nsIDOMMozMmsMessage;
|
||||
class nsIDOMMozSmsFilter;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -22,7 +23,6 @@ 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(const MobileMessageFilter& aFilter,
|
||||
GetMessages(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
292
dom/mobilemessage/src/SmsFilter.cpp
Normal file
292
dom/mobilemessage/src/SmsFilter.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
/* -*- 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
|
43
dom/mobilemessage/src/SmsFilter.h
Normal file
43
dom/mobilemessage/src/SmsFilter.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* -*- 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,7 +48,16 @@ enum ReadStatus {
|
||||
eReadStatus_EndGuard
|
||||
};
|
||||
|
||||
// For {Mms,Sms}MessageData.messageClass.
|
||||
// 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.
|
||||
enum MessageClass {
|
||||
eMessageClass_Normal = 0,
|
||||
eMessageClass_Class0,
|
||||
@ -106,6 +115,17 @@ 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,6 +3,7 @@
|
||||
* 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"
|
||||
|
||||
@ -46,16 +47,7 @@ MobileMessageDatabaseService::DeleteMessage(int32_t *aMessageIds,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
MobileMessageDatabaseService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse,
|
||||
nsIMobileMessageCursorCallback* aCallback,
|
||||
nsICursorContinueCallback** aResult)
|
||||
|
@ -3105,47 +3105,25 @@ MobileMessageDB.prototype = {
|
||||
}, [MESSAGE_STORE_NAME, THREAD_STORE_NAME]);
|
||||
},
|
||||
|
||||
createMessageCursor: function(aHasStartDate, aStartDate, aHasEndDate,
|
||||
aEndDate, aNumbers, aNumbersCount, aDelivery,
|
||||
aHasRead, aRead, aThreadId, aReverse, aCallback) {
|
||||
createMessageCursor: function(filter, reverse, callback) {
|
||||
if (DEBUG) {
|
||||
debug("Creating a message cursor. Filters:" +
|
||||
" startDate: " + (aHasStartDate ? aStartDate : "(null)") +
|
||||
" endDate: " + (aHasEndDate ? aEndDate : "(null)") +
|
||||
" delivery: " + aDelivery +
|
||||
" numbers: " + (aNumbersCount ? aNumbers : "(null)") +
|
||||
" read: " + (aHasRead ? aRead : "(null)") +
|
||||
" threadId: " + aThreadId +
|
||||
" reverse: " + aReverse);
|
||||
" startDate: " + filter.startDate +
|
||||
" endDate: " + filter.endDate +
|
||||
" delivery: " + filter.delivery +
|
||||
" numbers: " + filter.numbers +
|
||||
" read: " + filter.read +
|
||||
" threadId: " + filter.threadId +
|
||||
" reverse: " + reverse);
|
||||
}
|
||||
|
||||
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 cursor = new GetMessagesCursor(this, callback);
|
||||
|
||||
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, aReverse, collect);
|
||||
FilterSearcherHelper.transact(self, txn, error, filter, reverse, collect);
|
||||
}, [MESSAGE_STORE_NAME, PARTICIPANT_STORE_NAME]);
|
||||
|
||||
return cursor;
|
||||
@ -3333,11 +3311,11 @@ let FilterSearcherHelper = {
|
||||
filterTimestamp: function(startDate, endDate, direction, txn, collect) {
|
||||
let range = null;
|
||||
if (startDate != null && endDate != null) {
|
||||
range = IDBKeyRange.bound(startDate, endDate);
|
||||
range = IDBKeyRange.bound(startDate.getTime(), endDate.getTime());
|
||||
} else if (startDate != null) {
|
||||
range = IDBKeyRange.lowerBound(startDate);
|
||||
range = IDBKeyRange.lowerBound(startDate.getTime());
|
||||
} else if (endDate != null) {
|
||||
range = IDBKeyRange.upperBound(endDate);
|
||||
range = IDBKeyRange.upperBound(endDate.getTime());
|
||||
}
|
||||
this.filterIndex("timestamp", range, direction, txn, collect);
|
||||
},
|
||||
@ -3352,7 +3330,7 @@ let FilterSearcherHelper = {
|
||||
* @param error
|
||||
* Previous error while creating the transaction.
|
||||
* @param filter
|
||||
* A MobileMessageFilter dictionary.
|
||||
* A SmsFilter object.
|
||||
* @param reverse
|
||||
* A boolean value indicating whether we should filter message in
|
||||
* reversed order.
|
||||
@ -3390,10 +3368,10 @@ let FilterSearcherHelper = {
|
||||
// than all numeric values.
|
||||
let startDate = 0, endDate = "";
|
||||
if (filter.startDate != null) {
|
||||
startDate = filter.startDate;
|
||||
startDate = filter.startDate.getTime();
|
||||
}
|
||||
if (filter.endDate != null) {
|
||||
endDate = filter.endDate;
|
||||
endDate = filter.endDate.getTime();
|
||||
}
|
||||
|
||||
let single, intersectionCollector;
|
||||
|
@ -108,13 +108,8 @@ MobileMessageDatabaseService.prototype = {
|
||||
this.mmdb.deleteMessage(aMessageIds, aLength, aRequest);
|
||||
},
|
||||
|
||||
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);
|
||||
createMessageCursor: function(aFilter, aReverse, aCallback) {
|
||||
return this.mmdb.createMessageCursor(aFilter, aReverse, aCallback);
|
||||
},
|
||||
|
||||
markMessageRead: function(aMessageId, aValue, aSendReadReport, aRequest) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#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"
|
||||
@ -219,40 +220,13 @@ SmsIPCService::DeleteMessage(int32_t *aMessageIds, uint32_t aSize,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
SmsIPCService::CreateMessageCursor(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse,
|
||||
nsIMobileMessageCursorCallback* aCursorCallback,
|
||||
nsICursorContinueCallback** aResult)
|
||||
{
|
||||
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;
|
||||
const SmsFilterData& data =
|
||||
SmsFilterData(static_cast<SmsFilter*>(aFilter)->GetData());
|
||||
|
||||
return SendCursorRequest(CreateMessageCursorRequest(data, aReverse),
|
||||
aCursorCallback, aResult);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "SmsFilter.h"
|
||||
#include "MobileMessageThread.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
@ -773,31 +774,10 @@ MobileMessageCursorParent::DoRequest(const CreateMessageCursorRequest& aRequest)
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
if (dbService) {
|
||||
const SmsFilterData& filter = aRequest.filter();
|
||||
nsCOMPtr<nsIDOMMozSmsFilter> filter = new SmsFilter(aRequest.filter());
|
||||
bool reverse = aRequest.reverse();
|
||||
|
||||
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,
|
||||
rv = dbService->CreateMessageCursor(filter, reverse, this,
|
||||
getter_AddRefs(mContinueCallback));
|
||||
}
|
||||
|
||||
|
@ -77,14 +77,11 @@ union MobileMessageData
|
||||
|
||||
struct SmsFilterData
|
||||
{
|
||||
bool hasStartDate;
|
||||
uint64_t startDate;
|
||||
bool hasEndDate;
|
||||
uint64_t endDate;
|
||||
nsString[] numbers;
|
||||
nsString delivery;
|
||||
bool hasRead;
|
||||
bool read;
|
||||
DeliveryState delivery;
|
||||
ReadState read;
|
||||
uint64_t threadId;
|
||||
};
|
||||
|
||||
|
@ -40,6 +40,7 @@ EXPORTS.mozilla.dom += [
|
||||
'DOMMobileMessageError.h',
|
||||
'MmsMessage.h',
|
||||
'MobileMessageManager.h',
|
||||
'SmsFilter.h',
|
||||
'SmsMessage.h',
|
||||
]
|
||||
|
||||
@ -56,6 +57,7 @@ UNIFIED_SOURCES += [
|
||||
'MobileMessageManager.cpp',
|
||||
'MobileMessageService.cpp',
|
||||
'MobileMessageThread.cpp',
|
||||
'SmsFilter.cpp',
|
||||
'SmsMessage.cpp',
|
||||
'SmsServicesFactory.cpp',
|
||||
]
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
interface MozMmsMessage;
|
||||
interface MozSmsFilter;
|
||||
interface MozSmsMessage;
|
||||
|
||||
dictionary SmsSegmentInfo {
|
||||
@ -50,31 +51,6 @@ 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
|
||||
{
|
||||
@ -135,7 +111,7 @@ interface MozMobileMessageManager : EventTarget
|
||||
|
||||
// Iterates through Moz{Mms,Sms}Message.
|
||||
[Throws]
|
||||
DOMCursor getMessages(optional MobileMessageFilter filter,
|
||||
DOMCursor getMessages(optional MozSmsFilter? filter = null,
|
||||
optional boolean reverse = false);
|
||||
|
||||
[Throws]
|
||||
|
Loading…
Reference in New Issue
Block a user