Bug 674725 - Part AI - Implement SmsFilter. r=smaug,mrbkap
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 17 Jan 2012 19:48:58 +0100
changeset 84720 48725e4f215ac788f704f6c64ecbc3be034d3efc
parent 84719 3eb67a0b91f1230c68bd2f644774b86baaeee2cd
child 84721 3f4e4e0d231249db6b82bdecaf156618eabaeada
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmaug, mrbkap
bugs674725
milestone12.0a1
Bug 674725 - Part AI - Implement SmsFilter. r=smaug,mrbkap
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/sms/interfaces/Makefile.in
dom/sms/interfaces/nsIDOMSmsFilter.idl
dom/sms/src/Makefile.in
dom/sms/src/SmsFilter.cpp
dom/sms/src/SmsFilter.h
dom/sms/src/SmsMessage.cpp
dom/sms/src/Types.h
dom/sms/src/ipc/PSms.ipdl
dom/sms/tests/Makefile.in
dom/sms/tests/test_sms_basics.html
dom/sms/tests/test_smsfilter.html
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -34,16 +34,21 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
+#include "SmsFilter.h" // On top because it includes basictypes.h.
+
+#ifdef XP_WIN
+#undef GetClassName
+#endif
 
 // JavaScript includes
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "jsprvtd.h"    // we are using private JS typedefs...
 #include "jsdbgapi.h"
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
@@ -159,21 +164,16 @@
 #include "nsIDOMHTMLSelectElement.h"
 
 // HTMLEmbed/ObjectElement helper includes
 #include "nsNPAPIPluginInstance.h"
 #include "nsIObjectFrame.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsIPluginHost.h"
 
-// Oh, did I mention that I hate Microsoft for doing this to me?
-#ifdef XP_WIN
-#undef GetClassName
-#endif
-
 // HTMLOptionsCollection includes
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsIDOMHTMLOptionsCollection.h"
 
 // ContentList includes
 #include "nsContentList.h"
 #include "nsGenericElement.h"
 
@@ -510,16 +510,17 @@
 #include "dombindings.h"
 
 #include "nsIDOMBatteryManager.h"
 #include "BatteryManager.h"
 #include "nsIDOMSmsManager.h"
 #include "nsIDOMSmsMessage.h"
 #include "nsIDOMSmsEvent.h"
 #include "nsIDOMSmsRequest.h"
+#include "nsIDOMSmsFilter.h"
 #include "nsIPrivateDOMEvent.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "CallEvent.h"
 #endif
 
@@ -1410,16 +1411,19 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsRequest, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
+  NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
                            ARRAY_SCRIPTABLE_FLAGS)
 
 #if defined(MOZ_MEDIA)
   NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
@@ -1636,16 +1640,17 @@ static const nsConstructorFuncMapData kC
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PopStateEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(HashChangeEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PageTransitionEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CloseEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UIEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MouseEvent)
+  NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter)
 };
 
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
 nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
 bool nsDOMClassInfo::sIsInitialized = false;
 bool nsDOMClassInfo::sDisableDocumentAllSupport = false;
 bool nsDOMClassInfo::sDisableGlobalScopePollutionSupport = false;
 
@@ -3990,16 +3995,20 @@ nsDOMClassInfo::Init()
      DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsRequest, nsIDOMMozSmsRequest)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsRequest)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
+  DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
+     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
+  DOM_CLASSINFO_MAP_END
+
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
                                       nsIDOMCSSStyleDeclaration)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
   DOM_CLASSINFO_MAP_END
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -429,16 +429,17 @@ DOMCI_CLASS(GeoPositionAddress)
 DOMCI_CLASS(GeoPositionError)
 
 DOMCI_CLASS(MozBatteryManager)
 
 DOMCI_CLASS(MozSmsManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozSmsEvent)
 DOMCI_CLASS(MozSmsRequest)
+DOMCI_CLASS(MozSmsFilter)
 
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
 DOMCI_CLASS(CSSFontFaceStyleDecl)
 
 #if defined(MOZ_MEDIA)
 // WhatWG Video Element
 DOMCI_CLASS(HTMLVideoElement)
--- a/dom/sms/interfaces/Makefile.in
+++ b/dom/sms/interfaces/Makefile.in
@@ -48,11 +48,12 @@ include $(topsrcdir)/dom/dom-config.mk
 XPIDLSRCS = \
   nsIDOMNavigatorSms.idl \
   nsIDOMSmsManager.idl \
   nsISmsService.idl \
   nsIDOMSmsMessage.idl \
   nsIDOMSmsEvent.idl \
   nsISmsDatabaseService.idl \
   nsIDOMSmsRequest.idl \
+  nsIDOMSmsFilter.idl \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/sms/interfaces/nsIDOMSmsFilter.idl
@@ -0,0 +1,57 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+
+[scriptable, builtinclass, uuid(7da08e45-ee81-4293-912b-2f2fea5b6935)]
+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/dom/sms/src/Makefile.in
+++ b/dom/sms/src/Makefile.in
@@ -79,16 +79,17 @@ CPPSRCS = \
   SmsParent.cpp \
   SmsMessage.cpp \
   SmsEvent.cpp \
   Constants.cpp \
   SmsChild.cpp \
   SmsDatabaseService.cpp \
   SmsRequest.cpp \
   SmsRequestManager.cpp \
+  SmsFilter.cpp \
   $(NULL)
 
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/content/events/src \
   -I$(topsrcdir)/dom/base \
   $(NULL)
 
 # Add VPATH to LOCAL_INCLUDES so we are going to include the correct backend
new file mode 100644
--- /dev/null
+++ b/dom/sms/src/SmsFilter.cpp
@@ -0,0 +1,264 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "SmsFilter.h"
+#include "nsIDOMClassInfo.h"
+#include "Constants.h"
+#include "nsError.h"
+#include "Constants.h"
+#include "jsapi.h"
+#include "jsdate.h" // For js_DateGetMsecSinceEpoch.
+#include "js/Utility.h"
+#include "nsJSUtils.h"
+#include "nsDOMString.h"
+
+DOMCI_DATA(MozSmsFilter, mozilla::dom::sms::SmsFilter)
+
+namespace mozilla {
+namespace dom {
+namespace sms {
+
+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;
+}
+
+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, jsval* aStartDate)
+{
+  if (mData.startDate() == 0) {
+    *aStartDate = JSVAL_NULL;
+    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, const jsval& aStartDate)
+{
+  if (aStartDate == JSVAL_NULL) {
+    mData.startDate() = 0;
+    return NS_OK;
+  }
+
+  if (!aStartDate.isObject()) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  JSObject& obj = aStartDate.toObject();
+  if (!JS_ObjectIsDate(aCx, &obj)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  mData.startDate() = js_DateGetMsecSinceEpoch(aCx, &obj);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SmsFilter::GetEndDate(JSContext* aCx, jsval* aEndDate)
+{
+  if (mData.endDate() == 0) {
+    *aEndDate = JSVAL_NULL;
+    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, const jsval& aEndDate)
+{
+  if (aEndDate == JSVAL_NULL) {
+    mData.endDate() = 0;
+    return NS_OK;
+  }
+
+  if (!aEndDate.isObject()) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  JSObject& obj = aEndDate.toObject();
+  if (!JS_ObjectIsDate(aCx, &obj)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  mData.endDate() = js_DateGetMsecSinceEpoch(aCx, &obj);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SmsFilter::GetNumbers(JSContext* aCx, jsval* aNumbers)
+{
+  PRUint32 length = mData.numbers().Length();
+
+  if (length == 0) {
+    *aNumbers = JSVAL_NULL;
+    return NS_OK;
+  }
+
+  jsval* numbers = new jsval[length];
+
+  for (PRUint32 i=0; i<length; ++i) {
+    numbers[i].setString(JS_NewUCStringCopyN(aCx, mData.numbers()[i].get(),
+                                             mData.numbers()[i].Length()));
+  }
+
+  aNumbers->setObjectOrNull(JS_NewArrayObject(aCx, length, numbers));
+  NS_ENSURE_TRUE(aNumbers->isObject(), NS_ERROR_FAILURE);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SmsFilter::SetNumbers(JSContext* aCx, const jsval& aNumbers)
+{
+  if (aNumbers == JSVAL_NULL) {
+    mData.numbers().Clear();
+    return NS_OK;
+  }
+
+  if (!aNumbers.isObject()) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  JSObject& obj = aNumbers.toObject();
+  if (!JS_IsArrayObject(aCx, &obj)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  jsuint size;
+  JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, &obj, &size));
+
+  nsTArray<nsString> numbers;
+
+  for (jsuint i=0; i<size; ++i) {
+    jsval jsNumber;
+    if (!JS_GetElement(aCx, &obj, i, &jsNumber)) {
+      return NS_ERROR_INVALID_ARG;
+    }
+
+    if (!jsNumber.isString()) {
+      return NS_ERROR_INVALID_ARG;
+    }
+
+    nsDependentJSString number;
+    number.init(aCx, jsNumber.toString());
+
+    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;
+}
+
+} // namespace sms
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/sms/src/SmsFilter.h
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef mozilla_dom_sms_SmsFilter_h
+#define mozilla_dom_sms_SmsFilter_h
+
+#include "mozilla/dom/sms/PSms.h"
+#include "nsIDOMSmsFilter.h"
+#include "Types.h"
+
+namespace mozilla {
+namespace dom {
+namespace sms {
+
+class SmsFilter : public nsIDOMMozSmsFilter
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIDOMMOZSMSFILTER
+
+  SmsFilter();
+  SmsFilter(const SmsFilterData& aData);
+
+  const SmsFilterData& GetData() const;
+
+  static nsresult NewSmsFilter(nsISupports** aSmsFilter);
+
+private:
+  SmsFilterData mData;
+};
+
+inline const SmsFilterData&
+SmsFilter::GetData() const {
+  return mData;
+}
+
+} // namespace sms
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_sms_SmsFilter_h
--- a/dom/sms/src/SmsMessage.cpp
+++ b/dom/sms/src/SmsMessage.cpp
@@ -133,20 +133,20 @@ SmsMessage::GetId(PRInt32* aId)
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsMessage::GetDelivery(nsAString& aDelivery)
 {
   switch (mData.delivery()) {
     case eDeliveryState_Received:
-      aDelivery.AssignLiteral("received");
+      aDelivery = DELIVERY_RECEIVED;
       break;
     case eDeliveryState_Sent:
-      aDelivery.AssignLiteral("sent");
+      aDelivery = DELIVERY_SENT;
       break;
     case eDeliveryState_Unknown:
     default:
       NS_ASSERTION(true, "We shouldn't get an unknown delivery state!");
       return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
--- a/dom/sms/src/Types.h
+++ b/dom/sms/src/Types.h
@@ -33,16 +33,18 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_dom_sms_Types_h
 #define mozilla_dom_sms_Types_h
 
+#include "IPCMessageUtils.h"
+
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 // For SmsMessageDate.delivery.
 enum DeliveryState {
   eDeliveryState_Sent,
   eDeliveryState_Received,
--- a/dom/sms/src/ipc/PSms.ipdl
+++ b/dom/sms/src/ipc/PSms.ipdl
@@ -50,16 +50,23 @@ struct SmsMessageData {
   PRInt32       id;
   DeliveryState delivery;
   nsString      sender;
   nsString      receiver;
   nsString      body;
   PRUint64      timestamp; // ms since epoch.
 };
 
+struct SmsFilterData {
+  PRUint64      startDate;
+  PRUint64      endDate;
+  nsString[]    numbers;
+  DeliveryState delivery;
+};
+
 sync protocol PSms {
     manager PContent;
 
 child:
     NotifyReceivedMessage(SmsMessageData aMessageData);
 
     NotifySentMessage(SmsMessageData aMessageData);
 
--- a/dom/sms/tests/Makefile.in
+++ b/dom/sms/tests/Makefile.in
@@ -45,16 +45,17 @@ include $(DEPTH)/config/autoconf.mk
 
 DIRS = \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
   test_sms_basics.html \
+  test_smsfilter.html \
   $(NULL)
 
 _CHROME_TEST_FILES = \
   $(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
--- a/dom/sms/tests/test_sms_basics.html
+++ b/dom/sms/tests/test_sms_basics.html
@@ -41,16 +41,17 @@ function test() {
   var gSmsEnabled = SpecialPowers.getBoolPref("dom.sms.enabled");
   var gSmsWhiteList = SpecialPowers.getCharPref("dom.sms.whitelist");
 
   checkInterface("SmsManager");
   checkInterface("NavigatorSms");
   checkInterface("SmsMessage");
   checkInterface("SmsEvent");
   checkInterface("SmsRequest");
+  checkInterface("SmsFilter");
 
   // If sms are disabled and whitelist is empty, sms is disabled.
   SpecialPowers.setBoolPref("dom.sms.enabled", false);
   SpecialPowers.setCharPref("dom.sms.whitelist", "");
   checkSmsDisabled();
 
   // If sms are enabled and whitelist is empty, sms are disabled.
   SpecialPowers.setBoolPref("dom.sms.enabled", true);
new file mode 100644
--- /dev/null
+++ b/dom/sms/tests/test_smsfilter.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test SmsFilter</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+<iframe></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test SmsFilter **/
+
+function throwingCheck(aFilter, aProperty, disallowedValue)
+{
+  disallowedValue.forEach(function(v) {
+    var exception = false;
+    try {
+      aFilter[aProperty] = v;
+    } catch (e) {
+      exception = true;
+    }
+    ok(exception, "An exception should have been thrown");
+  });
+}
+
+var filter = new MozSmsFilter();
+
+isnot(filter, null, "filter should be set");
+
+is(filter.startDate, null, "Parameters shouldn't be initialized");
+is(filter.endDate, null, "Parameters shouldn't be initialized");
+is(filter.numbers, null, "Parameters shouldn't be initialized");
+is(filter.delivery, null, "Parameters shouldn't be initialized");
+
+var date = new Date();
+filter.startDate = date;
+is(filter.startDate, "" + date, "Setters and getters should work!");
+filter.startDate = null;
+is(filter.startDate, null, "null should revert the value to default");
+throwingCheck(filter, 'startDate', [ "foo", 42, [1, 2], function () {}, undefined ]);
+
+filter.endDate = date;
+is(filter.endDate, "" + date, "Setters and getters should work!");
+filter.endDate = null;
+is(filter.endDate, null, "null should revert the value to default");
+throwingCheck(filter, 'endDate', [ "foo", 42, [1, 2], function () {}, undefined ]);
+
+var numbers = [ "foo", "bar" ];
+filter.numbers = numbers;
+is(filter.numbers, "" + numbers, "Setters and getters should work!");
+filter.numbers = null;
+is(filter.numbers, null, "null should revert the value to default");
+throwingCheck(filter, 'numbers', [ "foo", 42, function () {}, new Date(), undefined ]);
+
+filter.delivery = "sent";
+is(filter.delivery, "sent", "Setters and getters should work!");
+filter.delivery = "received";
+is(filter.delivery, "received", "Setters and getters should work!");
+filter.delivery = "";
+is(filter.delivery, null, "The empty string should revert the value to default.");
+filter.delivery = null;
+is(filter.delivery, null, "'null' should revert the value to default.");
+throwingCheck(filter, 'delivery', [ "foo", 42, [1, 2], function () {}, new Date(), undefined ]);
+
+</script>
+</pre>
+</body>
+</html>
+