Bug 854790 2/4: DOM. r=mounir

This commit is contained in:
Vicamo Yang 2013-04-12 14:56:16 +08:00
parent 4b239ac3db
commit 7d2b63b230

View File

@ -36,6 +36,7 @@ SmsFilter::SmsFilter()
mData.endDate() = 0;
mData.delivery() = eDeliveryState_Unknown;
mData.read() = eReadState_Unknown;
mData.threadId() = 0;
}
SmsFilter::SmsFilter(const SmsFilterData& aData)
@ -258,5 +259,40 @@ SmsFilter::SetRead(JSContext* aCx, const JS::Value& aRead)
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