Bug 742790 - Part 2/5: DOM implementation, r=mounir

This commit is contained in:
Vicamo Yang 2012-10-30 18:53:24 +08:00
parent eec7d5c1e1
commit f560f5c605
20 changed files with 244 additions and 72 deletions

View File

@ -661,7 +661,8 @@ GK_ATOM(oncut, "oncut")
GK_ATOM(ondatachange, "ondatachange")
GK_ATOM(ondataerror, "ondataerror")
GK_ATOM(ondblclick, "ondblclick")
GK_ATOM(ondelivered, "ondelivered")
GK_ATOM(ondeliverysuccess, "ondeliverysuccess")
GK_ATOM(ondeliveryerror, "ondeliveryerror")
GK_ATOM(ondevicecreated, "ondevicecreated")
GK_ATOM(ondevicedisappeared, "ondevicedisappeared")
GK_ATOM(ondevicefound, "ondevicefound")

View File

@ -13,13 +13,14 @@
interface nsIDOMMozSmsFilter;
[scriptable, uuid(30e8cdfb-155d-44c7-8fb3-6bcd9c1c3f99)]
[scriptable, uuid(d6318c22-1ebd-4262-b991-432f61a96237)]
interface nsISmsDatabaseService : nsISupports
{
// Takes some information required to save the message and returns its id.
long saveReceivedMessage(in DOMString aSender, in DOMString aBody, in unsigned long long aDate);
// Takes some information required to save the message and returns its id.
long saveSentMessage(in DOMString aReceiver, in DOMString aBody, in unsigned long long aDate);
void setMessageDeliveryStatus(in long aMessageId, in DOMString aDeliveryStatus);
[binaryname(GetMessageMoz)] void getMessage(in long messageId, in long requestId, [optional] in unsigned long long processId);
void deleteMessage(in long messageId, in long requestId, [optional] in unsigned long long processId);

View File

@ -11,7 +11,7 @@ interface nsIDOMMozSmsMessage;
#define SMS_SERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1"
%}
[scriptable, builtinclass, uuid(00d23a50-6ed1-48b4-b1e9-5987b155e54b)]
[scriptable, builtinclass, uuid(a1367149-c09f-4e8c-a890-5812406bed61)]
interface nsISmsService : nsISupports
{
boolean hasSupport();
@ -22,6 +22,7 @@ interface nsISmsService : nsISupports
[implicit_jscontext]
nsIDOMMozSmsMessage createSmsMessage(in long id,
in DOMString delivery,
in DOMString deliveryStatus,
in DOMString sender,
in DOMString receiver,
in DOMString body,

View File

@ -7,9 +7,10 @@ namespace mozilla {
namespace dom {
namespace sms {
const char* kSmsReceivedObserverTopic = "sms-received";
const char* kSmsSentObserverTopic = "sms-sent";
const char* kSmsDeliveredObserverTopic = "sms-delivered";
const char* kSmsReceivedObserverTopic = "sms-received";
const char* kSmsSentObserverTopic = "sms-sent";
const char* kSmsDeliverySuccessObserverTopic = "sms-delivery-success";
const char* kSmsDeliveryErrorObserverTopic = "sms-delivery-error";
} // namespace sms
} // namespace dom

View File

@ -10,13 +10,19 @@ namespace mozilla {
namespace dom {
namespace sms {
extern const char* kSmsReceivedObserverTopic; // Defined in the .cpp.
extern const char* kSmsSentObserverTopic; // Defined in the .cpp.
extern const char* kSmsDeliveredObserverTopic; // Defined in the .cpp.
extern const char* kSmsReceivedObserverTopic; // Defined in the .cpp.
extern const char* kSmsSentObserverTopic; // Defined in the .cpp.
extern const char* kSmsDeliverySuccessObserverTopic; // Defined in the .cpp.
extern const char* kSmsDeliveryErrorObserverTopic; // Defined in the .cpp.
#define DELIVERY_RECEIVED NS_LITERAL_STRING("received")
#define DELIVERY_SENT NS_LITERAL_STRING("sent")
#define DELIVERY_STATUS_NOT_APPLICABLE NS_LITERAL_STRING("not-applicable")
#define DELIVERY_STATUS_SUCCESS NS_LITERAL_STRING("success")
#define DELIVERY_STATUS_PENDING NS_LITERAL_STRING("pending")
#define DELIVERY_STATUS_ERROR NS_LITERAL_STRING("error")
} // namespace sms
} // namespace dom
} // namespace mozilla

View File

@ -25,9 +25,10 @@
* We have to use macros here because our leak analysis tool things we are
* leaking strings when we have |static const nsString|. Sad :(
*/
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define SENT_EVENT_NAME NS_LITERAL_STRING("sent")
#define DELIVERED_EVENT_NAME NS_LITERAL_STRING("delivered")
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define SENT_EVENT_NAME NS_LITERAL_STRING("sent")
#define DELIVERY_SUCCESS_EVENT_NAME NS_LITERAL_STRING("deliverysuccess")
#define DELIVERY_ERROR_EVENT_NAME NS_LITERAL_STRING("deliveryerror")
DOMCI_DATA(MozSmsManager, mozilla::dom::sms::SmsManager)
@ -57,7 +58,8 @@ NS_IMPL_RELEASE_INHERITED(SmsManager, nsDOMEventTargetHelper)
NS_IMPL_EVENT_HANDLER(SmsManager, received)
NS_IMPL_EVENT_HANDLER(SmsManager, sent)
NS_IMPL_EVENT_HANDLER(SmsManager, delivered)
NS_IMPL_EVENT_HANDLER(SmsManager, deliverysuccess)
NS_IMPL_EVENT_HANDLER(SmsManager, deliveryerror)
/* static */already_AddRefed<SmsManager>
SmsManager::CreateInstanceIfAllowed(nsPIDOMWindow* aWindow)
@ -113,7 +115,8 @@ SmsManager::Init(nsPIDOMWindow *aWindow)
obs->AddObserver(this, kSmsReceivedObserverTopic, false);
obs->AddObserver(this, kSmsSentObserverTopic, false);
obs->AddObserver(this, kSmsDeliveredObserverTopic, false);
obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
}
void
@ -127,7 +130,8 @@ SmsManager::Shutdown()
obs->RemoveObserver(this, kSmsReceivedObserverTopic);
obs->RemoveObserver(this, kSmsSentObserverTopic);
obs->RemoveObserver(this, kSmsDeliveredObserverTopic);
obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
}
NS_IMETHODIMP
@ -381,14 +385,25 @@ SmsManager::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliveredObserverTopic)) {
if (!strcmp(aTopic, kSmsDeliverySuccessObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivered' topic without a valid message!");
NS_ERROR("Got a 'sms-delivery-success' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(DELIVERED_EVENT_NAME, message);
DispatchTrustedSmsEventToSelf(DELIVERY_SUCCESS_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliveryErrorObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivery-error' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(DELIVERY_ERROR_EVENT_NAME, message);
return NS_OK;
}

View File

@ -24,10 +24,16 @@ NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(SmsMessage)
NS_IMPL_RELEASE(SmsMessage)
SmsMessage::SmsMessage(int32_t aId, DeliveryState aDelivery,
const nsString& aSender, const nsString& aReceiver,
const nsString& aBody, uint64_t aTimestamp, bool aRead)
: mData(aId, aDelivery, aSender, aReceiver, aBody, aTimestamp, aRead)
SmsMessage::SmsMessage(int32_t aId,
DeliveryState aDelivery,
DeliveryStatus aDeliveryStatus,
const nsString& aSender,
const nsString& aReceiver,
const nsString& aBody,
uint64_t aTimestamp,
bool aRead)
: mData(aId, aDelivery, aDeliveryStatus, aSender, aReceiver, aBody,
aTimestamp, aRead)
{
}
@ -39,6 +45,7 @@ SmsMessage::SmsMessage(const SmsMessageData& aData)
/* static */ nsresult
SmsMessage::Create(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,
@ -66,6 +73,18 @@ SmsMessage::Create(int32_t aId,
return NS_ERROR_INVALID_ARG;
}
if (aDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
data.deliveryStatus() = eDeliveryStatus_NotApplicable;
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
data.deliveryStatus() = eDeliveryStatus_Success;
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
data.deliveryStatus() = eDeliveryStatus_Pending;
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
data.deliveryStatus() = eDeliveryStatus_Error;
} else {
return NS_ERROR_INVALID_ARG;
}
// We support both a Date object and a millisecond timestamp as a number.
if (aTimestamp.isObject()) {
JSObject& obj = aTimestamp.toObject();
@ -115,7 +134,32 @@ SmsMessage::GetDelivery(nsAString& aDelivery)
case eDeliveryState_Unknown:
case eDeliveryState_EndGuard:
default:
NS_ASSERTION(true, "We shouldn't get any other delivery state!");
MOZ_NOT_REACHED("We shouldn't get any other delivery state!");
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
NS_IMETHODIMP
SmsMessage::GetDeliveryStatus(nsAString& aDeliveryStatus)
{
switch (mData.deliveryStatus()) {
case eDeliveryStatus_NotApplicable:
aDeliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
break;
case eDeliveryStatus_Success:
aDeliveryStatus = DELIVERY_STATUS_SUCCESS;
break;
case eDeliveryStatus_Pending:
aDeliveryStatus = DELIVERY_STATUS_PENDING;
break;
case eDeliveryStatus_Error:
aDeliveryStatus = DELIVERY_STATUS_ERROR;
break;
case eDeliveryStatus_EndGuard:
default:
MOZ_NOT_REACHED("We shouldn't get any other delivery status!");
return NS_ERROR_UNEXPECTED;
}

View File

@ -23,13 +23,19 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZSMSMESSAGE
SmsMessage(int32_t aId, DeliveryState aDelivery, const nsString& aSender,
const nsString& aReceiver, const nsString& aBody,
uint64_t aTimestamp, bool aRead);
SmsMessage(int32_t aId,
DeliveryState aDelivery,
DeliveryStatus aDeliveryStatus,
const nsString& aSender,
const nsString& aReceiver,
const nsString& aBody,
uint64_t aTimestamp,
bool aRead);
SmsMessage(const SmsMessageData& aData);
static nsresult Create(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,

View File

@ -23,6 +23,16 @@ enum DeliveryState {
eDeliveryState_EndGuard
};
// For SmsMessageData.deliveryStatus.
enum DeliveryStatus {
eDeliveryStatus_NotApplicable = 0,
eDeliveryStatus_Success,
eDeliveryStatus_Pending,
eDeliveryStatus_Error,
// This state should stay at the end.
eDeliveryStatus_EndGuard
};
// For SmsFilterData.read
enum ReadState {
eReadState_Unknown = -1,
@ -48,6 +58,16 @@ struct ParamTraits<mozilla::dom::sms::DeliveryState>
mozilla::dom::sms::eDeliveryState_EndGuard>
{};
/**
* Delivery status serializer.
*/
template <>
struct ParamTraits<mozilla::dom::sms::DeliveryStatus>
: public EnumSerializer<mozilla::dom::sms::DeliveryStatus,
mozilla::dom::sms::eDeliveryStatus_NotApplicable,
mozilla::dom::sms::eDeliveryStatus_EndGuard>
{};
/**
* Read state serializer.
*/

View File

@ -38,6 +38,14 @@ SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::SetMessageDeliveryStatus(int32_t aMessageId,
const nsAString& aDeliveryStatus)
{
// TODO: Bug 803828: update delivery status for sent messages in Android.
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::GetMessageMoz(int32_t aMessageId, int32_t aRequestId,
uint64_t aProcessId)

View File

@ -49,6 +49,7 @@ SmsService::Send(const nsAString& aNumber, const nsAString& aMessage,
NS_IMETHODIMP
SmsService::CreateSmsMessage(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,
@ -57,8 +58,10 @@ SmsService::CreateSmsMessage(int32_t aId,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
{
return SmsMessage::Create(aId, aDelivery, aSender, aReceiver, aBody,
aTimestamp, aRead, aCx, aMessage);
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
aSender, aReceiver,
aBody, aTimestamp, aRead,
aCx, aMessage);
}
} // namespace sms

View File

@ -31,6 +31,14 @@ SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::SetMessageDeliveryStatus(int32_t aMessageId,
const nsAString& aDeliveryStatus)
{
NS_ERROR("We should not be here!");
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::GetMessageMoz(int32_t aMessageId, int32_t aRequestId,
uint64_t aProcessId)

View File

@ -39,6 +39,7 @@ SmsService::Send(const nsAString& aNumber, const nsAString& aMessage,
NS_IMETHODIMP
SmsService::CreateSmsMessage(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,
@ -47,8 +48,10 @@ SmsService::CreateSmsMessage(int32_t aId,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
{
return SmsMessage::Create(aId, aDelivery, aSender, aReceiver, aBody,
aTimestamp, aRead, aCx, aMessage);
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
aSender, aReceiver,
aBody, aTimestamp, aRead,
aCx, aMessage);
}
} // namespace sms

View File

@ -8,6 +8,7 @@ include protocol PContent;
include "mozilla/dom/sms/Types.h";
using DeliveryState;
using DeliveryStatus;
using ReadState;
namespace mozilla {
@ -15,13 +16,14 @@ namespace dom {
namespace sms {
struct SmsMessageData {
int32_t id;
DeliveryState delivery;
nsString sender;
nsString receiver;
nsString body;
uint64_t timestamp; // ms since epoch.
bool read;
int32_t id;
DeliveryState delivery;
DeliveryStatus deliveryStatus;
nsString sender;
nsString receiver;
nsString body;
uint64_t timestamp; // ms since epoch.
bool read;
};
struct SmsFilterData {
@ -40,7 +42,9 @@ child:
NotifySentMessage(SmsMessageData aMessageData);
NotifyDeliveredMessage(SmsMessageData aMessageData);
NotifyDeliverySuccessMessage(SmsMessageData aMessageData);
NotifyDeliveryErrorMessage(SmsMessageData aMessageData);
NotifyRequestSmsSent(SmsMessageData aMessageData, int32_t aRequestId,
uint64_t aProcessId);
@ -89,6 +93,8 @@ parent:
sync SaveSentMessage(nsString aReceiver, nsString aBody, uint64_t aDate)
returns (int32_t aId);
SetMessageDeliveryStatus(int32_t aMessageId, nsString aDeliveryStatus);
GetMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId);
DeleteMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId);

View File

@ -12,6 +12,26 @@
#include "SmsRequestManager.h"
#include "SmsRequest.h"
using namespace mozilla;
using namespace mozilla::dom::sms;
namespace {
void
NotifyObserversWithSmsMessage(const char* aEventName,
const SmsMessageData& aMessageData)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return;
}
nsCOMPtr<SmsMessage> message = new SmsMessage(aMessageData);
obs->NotifyObservers(message, aEventName, nullptr);
}
} // anonymous namespace
namespace mozilla {
namespace dom {
namespace sms {
@ -19,42 +39,28 @@ namespace sms {
bool
SmsChild::RecvNotifyReceivedMessage(const SmsMessageData& aMessageData)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return true;
}
nsCOMPtr<SmsMessage> message = new SmsMessage(aMessageData);
obs->NotifyObservers(message, kSmsReceivedObserverTopic, nullptr);
NotifyObserversWithSmsMessage(kSmsReceivedObserverTopic, aMessageData);
return true;
}
bool
SmsChild::RecvNotifySentMessage(const SmsMessageData& aMessageData)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return true;
}
nsCOMPtr<SmsMessage> message = new SmsMessage(aMessageData);
obs->NotifyObservers(message, kSmsSentObserverTopic, nullptr);
NotifyObserversWithSmsMessage(kSmsSentObserverTopic, aMessageData);
return true;
}
bool
SmsChild::RecvNotifyDeliveredMessage(const SmsMessageData& aMessageData)
SmsChild::RecvNotifyDeliverySuccessMessage(const SmsMessageData& aMessageData)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return true;
}
nsCOMPtr<SmsMessage> message = new SmsMessage(aMessageData);
obs->NotifyObservers(message, kSmsDeliveredObserverTopic, nullptr);
NotifyObserversWithSmsMessage(kSmsDeliverySuccessObserverTopic, aMessageData);
return true;
}
bool
SmsChild::RecvNotifyDeliveryErrorMessage(const SmsMessageData& aMessageData)
{
NotifyObserversWithSmsMessage(kSmsDeliveryErrorObserverTopic, aMessageData);
return true;
}

View File

@ -17,7 +17,8 @@ class SmsChild : public PSmsChild
public:
virtual bool RecvNotifyReceivedMessage(const SmsMessageData& aMessage) MOZ_OVERRIDE;
virtual bool RecvNotifySentMessage(const SmsMessageData& aMessage) MOZ_OVERRIDE;
virtual bool RecvNotifyDeliveredMessage(const SmsMessageData& aMessage) MOZ_OVERRIDE;
virtual bool RecvNotifyDeliverySuccessMessage(const SmsMessageData& aMessage) MOZ_OVERRIDE;
virtual bool RecvNotifyDeliveryErrorMessage(const SmsMessageData& aMessage) MOZ_OVERRIDE;
virtual bool RecvNotifyRequestSmsSent(const SmsMessageData& aMessage, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;
virtual bool RecvNotifyRequestSmsSendFailed(const int32_t& aError, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;
virtual bool RecvNotifyRequestGotSms(const SmsMessageData& aMessage, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;

View File

@ -61,6 +61,7 @@ SmsIPCService::Send(const nsAString& aNumber, const nsAString& aMessage,
NS_IMETHODIMP
SmsIPCService::CreateSmsMessage(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,
@ -69,8 +70,10 @@ SmsIPCService::CreateSmsMessage(int32_t aId,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
{
return SmsMessage::Create(aId, aDelivery, aSender, aReceiver, aBody,
aTimestamp, aRead, aCx, aMessage);
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
aSender, aReceiver,
aBody, aTimestamp, aRead,
aCx, aMessage);
}
/*
@ -98,6 +101,16 @@ SmsIPCService::SaveSentMessage(const nsAString& aReceiver,
return NS_OK;
}
NS_IMETHODIMP
SmsIPCService::SetMessageDeliveryStatus(int32_t aMessageId,
const nsAString& aDeliveryStatus)
{
GetSmsChild()->SendSetMessageDeliveryStatus(aMessageId,
nsString(aDeliveryStatus));
return NS_OK;
}
NS_IMETHODIMP
SmsIPCService::GetMessageMoz(int32_t aMessageId, int32_t aRequestId,
uint64_t aProcessId)

View File

@ -48,7 +48,8 @@ SmsParent::SmsParent()
obs->AddObserver(this, kSmsReceivedObserverTopic, false);
obs->AddObserver(this, kSmsSentObserverTopic, false);
obs->AddObserver(this, kSmsDeliveredObserverTopic, false);
obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
}
void
@ -61,7 +62,8 @@ SmsParent::ActorDestroy(ActorDestroyReason why)
obs->RemoveObserver(this, kSmsReceivedObserverTopic);
obs->RemoveObserver(this, kSmsSentObserverTopic);
obs->RemoveObserver(this, kSmsDeliveredObserverTopic);
obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
NS_ASSERTION(gSmsParents, "gSmsParents can't be null at that point!");
gSmsParents->RemoveElement(this);
@ -97,14 +99,25 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliveredObserverTopic)) {
if (!strcmp(aTopic, kSmsDeliverySuccessObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivered' topic without a valid message!");
NS_ERROR("Got a 'sms-delivery-success' topic without a valid message!");
return NS_OK;
}
unused << SendNotifyDeliveredMessage(static_cast<SmsMessage*>(message.get())->GetData());
unused << SendNotifyDeliverySuccessMessage(static_cast<SmsMessage*>(message.get())->GetData());
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliveryErrorObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivery-error' topic without a valid message!");
return NS_OK;
}
unused << SendNotifyDeliveryErrorMessage(static_cast<SmsMessage*>(message.get())->GetData());
return NS_OK;
}
@ -176,6 +189,18 @@ SmsParent::RecvSaveSentMessage(const nsString& aRecipient,
return true;
}
bool
SmsParent::RecvSetMessageDeliveryStatus(const int32_t& aMessageId,
const nsString& aDeliveryStatus)
{
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsDBService, true);
smsDBService->SetMessageDeliveryStatus(aMessageId, aDeliveryStatus);
return true;
}
bool
SmsParent::RecvGetMessage(const int32_t& aMessageId, const int32_t& aRequestId,
const uint64_t& aProcessId)

View File

@ -29,6 +29,7 @@ public:
virtual bool RecvSendMessage(const nsString& aNumber, const nsString& aMessage, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;
virtual bool RecvSaveReceivedMessage(const nsString& aSender, const nsString& aBody, const uint64_t& aDate, int32_t* aId) MOZ_OVERRIDE;
virtual bool RecvSaveSentMessage(const nsString& aRecipient, const nsString& aBody, const uint64_t& aDate, int32_t* aId) MOZ_OVERRIDE;
virtual bool RecvSetMessageDeliveryStatus(const int32_t& aMessageId, const nsString& aDeliveryStatus) MOZ_OVERRIDE;
virtual bool RecvGetMessage(const int32_t& aMessageId, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;
virtual bool RecvDeleteMessage(const int32_t& aMessageId, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;
virtual bool RecvCreateMessageList(const SmsFilterData& aFilter, const bool& aReverse, const int32_t& aRequestId, const uint64_t& aProcessId) MOZ_OVERRIDE;

View File

@ -64,6 +64,7 @@ SmsService::Send(const nsAString& aNumber,
NS_IMETHODIMP
SmsService::CreateSmsMessage(int32_t aId,
const nsAString& aDelivery,
const nsAString& aDeliveryStatus,
const nsAString& aSender,
const nsAString& aReceiver,
const nsAString& aBody,
@ -72,8 +73,10 @@ SmsService::CreateSmsMessage(int32_t aId,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
{
return SmsMessage::Create(aId, aDelivery, aSender, aReceiver, aBody,
aTimestamp, aRead, aCx, aMessage);
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
aSender, aReceiver,
aBody, aTimestamp, aRead,
aCx, aMessage);
}
} // namespace sms