зеркало из https://github.com/mozilla/pjs.git
Bug 674725 - Part AA - Implement DOM and IPC boilerplate for getMessage(). r=smaug
This commit is contained in:
Родитель
060f25611a
Коммит
115d3dd54e
|
@ -37,8 +37,9 @@
|
|||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMMozSmsRequest;
|
||||
|
||||
[scriptable, function, uuid(1b40f025-33b0-4a95-b7b1-89857bfb8d7c)]
|
||||
[scriptable, function, uuid(8bebc119-845c-4ae1-96e7-7b7ee970485b)]
|
||||
interface nsIDOMMozSmsManager : nsIDOMEventTarget
|
||||
{
|
||||
unsigned short getNumberOfMessagesForText(in DOMString text);
|
||||
|
@ -49,6 +50,8 @@ interface nsIDOMMozSmsManager : nsIDOMEventTarget
|
|||
// An array of SmsRequest objects otherwise.
|
||||
jsval send(in jsval number, in DOMString message);
|
||||
|
||||
[binaryname(GetMessageMoz)] nsIDOMMozSmsRequest getMessage(in long id);
|
||||
|
||||
attribute nsIDOMEventListener onreceived;
|
||||
attribute nsIDOMEventListener onsent;
|
||||
attribute nsIDOMEventListener ondelivered;
|
||||
|
|
|
@ -38,14 +38,16 @@
|
|||
|
||||
%{C++
|
||||
#define SMS_DATABASE_SERVICE_CID \
|
||||
{ 0x1cb004a0, 0xe003, 0x48b9, \
|
||||
{ 0x9f, 0xd6, 0xe9, 0x1f, 0xbb, 0xb1, 0x97, 0x89 } }
|
||||
{ 0xa33977ef, 0x1a16, 0x473a, \
|
||||
{ 0x86, 0x62, 0x44, 0x10, 0xfe, 0xf3, 0xf1, 0x2b } }
|
||||
#define SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/smsdatabaseservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, function, uuid(ab23f736-f545-4fcd-a298-3d6e2b380042)]
|
||||
[scriptable, function, uuid(f1ff6e13-d49f-4b38-8697-8e45be49f1e7)]
|
||||
interface nsISmsDatabaseService : nsISupports
|
||||
{
|
||||
// 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);
|
||||
|
||||
[binaryname(GetMessageMoz)] void getMessage(in long messageId, in long requestId, [optional] in unsigned long long processId);
|
||||
};
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "SmsRequestManager.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsISmsDatabaseService.h"
|
||||
|
||||
/**
|
||||
* We have to use macros here because our leak analysis tool things we are
|
||||
|
@ -210,6 +211,22 @@ SmsManager::Send(const jsval& aNumber, const nsAString& aMessage, jsval* aReturn
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsManager::GetMessageMoz(PRInt32 aId, nsIDOMMozSmsRequest** aRequest)
|
||||
{
|
||||
int requestId =
|
||||
SmsRequestManager::GetInstance()->CreateRequest(mOwner, mScriptContext, aRequest);
|
||||
NS_ASSERTION(*aRequest, "The request object must have been created!");
|
||||
|
||||
nsCOMPtr<nsISmsDatabaseService> smsDBService =
|
||||
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
|
||||
|
||||
smsDBService->GetMessageMoz(aId, requestId, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, received)
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, sent)
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, delivered)
|
||||
|
|
|
@ -59,6 +59,14 @@ SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::GetMessageMoz(PRInt32 aMessageId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
// TODO: implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -53,6 +53,14 @@ SmsDatabaseService::SaveSentMessage(const nsAString& aReceiver,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::GetMessageMoz(PRInt32 aMessageId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
NS_ERROR("We should not be here!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -84,6 +84,8 @@ parent:
|
|||
sync SaveSentMessage(nsString aReceiver, nsString aBody, PRUint64 aDate)
|
||||
returns (PRInt32 aId);
|
||||
|
||||
GetMessage(PRInt32 aMessageId, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
|
|
@ -117,6 +117,15 @@ SmsIPCService::SaveSentMessage(const nsAString& aReceiver,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::GetMessageMoz(PRInt32 aMessageId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
GetSmsChild()->SendGetMessage(aMessageId, aRequestId,
|
||||
ContentChild::GetSingleton()->GetID());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -192,6 +192,18 @@ SmsParent::RecvSaveSentMessage(const nsString& aRecipient,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::RecvGetMessage(const PRInt32& aMessageId, const PRInt32& aRequestId,
|
||||
const PRUint64& aProcessId)
|
||||
{
|
||||
nsCOMPtr<nsISmsDatabaseService> smsDBService =
|
||||
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsDBService, true);
|
||||
|
||||
smsDBService->GetMessageMoz(aMessageId, aRequestId, aProcessId);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
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 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);
|
||||
|
||||
protected:
|
||||
virtual void ActorDestroy(ActorDestroyReason why);
|
||||
|
|
Загрузка…
Ссылка в новой задаче