Bug 854790 2/4: DOM. r=mounir, a=leo+
authorVicamo Yang <vyang@mozilla.com>
Thu, 18 Apr 2013 09:09:55 +0800
changeset 119111 0d31c26a81d374a0cafd44b3113b0fd884f8cafd
parent 119110 48af69015b7da9b60aac94a73aa3f3fc2e8d68bc
child 119112 2491f4bec7efee779d62db3064a7775c4056ffdb
push id680
push uservyang@mozilla.com
push dateThu, 18 Apr 2013 01:11:41 +0000
reviewersmounir, leo
bugs854790
milestone18.0
Bug 854790 2/4: DOM. r=mounir, a=leo+
dom/mobilemessage/src/SmsFilter.cpp
--- a/dom/mobilemessage/src/SmsFilter.cpp
+++ b/dom/mobilemessage/src/SmsFilter.cpp
@@ -31,16 +31,17 @@ 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
@@ -253,10 +254,45 @@ SmsFilter::SetRead(JSContext* aCx, const
   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::Value* aThreadId)
+{
+  if (!mData.threadId()) {
+    *aThreadId = JSVAL_VOID;
+    return NS_OK;
+  }
+
+  aThreadId->setNumber(static_cast<double>(mData.threadId()));
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SmsFilter::SetThreadId(JSContext* aCx, const JS::Value& aThreadId)
+{
+  if (aThreadId == JSVAL_VOID) {
+    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