Bug 729042 - SMS: Add nsISmsDatabaseService::saveIncomingMessage(). r=mounir

This commit is contained in:
Philipp von Weitershausen 2012-02-22 09:55:01 +01:00
parent 73bd59a760
commit 5760604a6a
8 changed files with 57 additions and 1 deletions

View File

@ -45,9 +45,11 @@
interface nsIDOMMozSmsFilter;
[scriptable, function, uuid(3ddf7dc3-626c-47ee-8b41-3f55d5af49c9)]
[scriptable, function, uuid(86b3b538-359d-40b0-acdf-8dfd698ff117)]
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);

View File

@ -45,6 +45,16 @@ namespace sms {
NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
NS_IMETHODIMP
SmsDatabaseService::SaveReceivedMessage(const nsAString& aSender,
const nsAString& aBody,
PRUint64 aDate, PRInt32* aId)
{
// The Android stock SMS app does this already.
*aId = -1;
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
const nsAString& aBody,

View File

@ -43,6 +43,16 @@ namespace sms {
NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
NS_IMETHODIMP
SmsDatabaseService::SaveReceivedMessage(const nsAString& aSender,
const nsAString& aBody,
PRUint64 aDate, PRInt32* aId)
{
*aId = -1;
NS_ERROR("We should not be here!");
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
const nsAString& aBody,

View File

@ -109,6 +109,9 @@ parent:
SendMessage(nsString aNumber, nsString aMessage, PRInt32 aRequestId,
PRUint64 aProcessId);
sync SaveReceivedMessage(nsString aSender, nsString aBody, PRUint64 aDate)
returns (PRInt32 aId);
sync SaveSentMessage(nsString aReceiver, nsString aBody, PRUint64 aDate)
returns (PRInt32 aId);

View File

@ -107,6 +107,17 @@ SmsIPCService::CreateSmsMessage(PRInt32 aId,
/*
* Implementation of nsISmsDatabaseService.
*/
NS_IMETHODIMP
SmsIPCService::SaveReceivedMessage(const nsAString& aSender,
const nsAString& aBody,
PRUint64 aDate, PRInt32* aId)
{
GetSmsChild()->SendSaveReceivedMessage(nsString(aSender), nsString(aBody),
aDate, aId);
return NS_OK;
}
NS_IMETHODIMP
SmsIPCService::SaveSentMessage(const nsAString& aReceiver,
const nsAString& aBody,

View File

@ -178,6 +178,21 @@ SmsParent::RecvSendMessage(const nsString& aNumber, const nsString& aMessage,
return true;
}
bool
SmsParent::RecvSaveReceivedMessage(const nsString& aSender,
const nsString& aBody,
const PRUint64& aDate, PRInt32* aId)
{
*aId = -1;
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsDBService, true);
smsDBService->SaveReceivedMessage(aSender, aBody, aDate, aId);
return true;
}
bool
SmsParent::RecvSaveSentMessage(const nsString& aRecipient,
const nsString& aBody,

View File

@ -59,6 +59,7 @@ public:
NS_OVERRIDE virtual bool RecvHasSupport(bool* aHasSupport);
NS_OVERRIDE virtual bool RecvGetNumberOfMessagesForText(const nsString& aText, PRUint16* aResult);
NS_OVERRIDE virtual bool RecvSendMessage(const nsString& aNumber, const nsString& aMessage, const PRInt32& aRequestId, const PRUint64& aProcessId);
NS_OVERRIDE virtual bool RecvSaveReceivedMessage(const nsString& aSender, const nsString& aBody, const PRUint64& aDate, PRInt32* aId);
NS_OVERRIDE virtual bool RecvSaveSentMessage(const nsString& aRecipient, const nsString& aBody, const PRUint64& aDate, PRInt32* aId);
NS_OVERRIDE virtual bool RecvGetMessage(const PRInt32& aMessageId, const PRInt32& aRequestId, const PRUint64& aProcessId);
NS_OVERRIDE virtual bool RecvDeleteMessage(const PRInt32& aMessageId, const PRInt32& aRequestId, const PRUint64& aProcessId);

View File

@ -23,6 +23,10 @@ SmsDatabaseService.prototype = {
// nsISmsDatabaseService
saveReceivedMessage: function saveReceivedMessage(sender, body, date) {
return -1;
},
saveSentMessage: function saveSentMessage(receiver, body, date) {
return -1;
},