зеркало из https://github.com/mozilla/pjs.git
Bug 674725 - Part AJ - Create a message list when getMessages() is called. r=smaug
This commit is contained in:
Родитель
a5083056ec
Коммит
d8190dbc37
|
@ -38,8 +38,9 @@
|
|||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMMozSmsRequest;
|
||||
interface nsIDOMMozSmsFilter;
|
||||
|
||||
[scriptable, function, uuid(4e628d96-abc9-45e1-b158-8970885a2552)]
|
||||
[scriptable, function, uuid(c9916dce-2947-41bb-95c2-818f792a020c)]
|
||||
interface nsIDOMMozSmsManager : nsIDOMEventTarget
|
||||
{
|
||||
unsigned short getNumberOfMessagesForText(in DOMString text);
|
||||
|
@ -55,6 +56,8 @@ interface nsIDOMMozSmsManager : nsIDOMEventTarget
|
|||
// The parameter can be either a message id or a SmsMessage.
|
||||
nsIDOMMozSmsRequest delete(in jsval param);
|
||||
|
||||
nsIDOMMozSmsRequest getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
|
||||
|
||||
attribute nsIDOMEventListener onreceived;
|
||||
attribute nsIDOMEventListener onsent;
|
||||
attribute nsIDOMEventListener ondelivered;
|
||||
|
|
|
@ -38,12 +38,14 @@
|
|||
|
||||
%{C++
|
||||
#define SMS_DATABASE_SERVICE_CID \
|
||||
{ 0xcc939280, 0x36ba, 0x4a03, \
|
||||
{ 0xbe, 0x20, 0xd1, 0xfa, 0x7e, 0xb0, 0x44, 0x1e } }
|
||||
{ 0xcb971459, 0xe85a, 0x49b3, \
|
||||
{ 0xbc, 0x1c, 0x10, 0x40, 0x27, 0x1e, 0x04, 0x6c } }
|
||||
#define SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/smsdatabaseservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, function, uuid(8f217fbf-88d9-4e72-8399-8c4d5e5cf7d0)]
|
||||
interface nsIDOMMozSmsFilter;
|
||||
|
||||
[scriptable, function, uuid(33358749-d1b3-4bd6-835c-ef3869f0e966)]
|
||||
interface nsISmsDatabaseService : nsISupports
|
||||
{
|
||||
// Takes some information required to save the message and returns its id.
|
||||
|
@ -51,4 +53,6 @@ interface nsISmsDatabaseService : nsISupports
|
|||
|
||||
[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);
|
||||
|
||||
void createMessageList(in nsIDOMMozSmsFilter filter, in boolean reverse, in long requestId, [optional] in unsigned long long processId);
|
||||
};
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "SmsFilter.h"
|
||||
#include "SmsManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsISmsService.h"
|
||||
|
@ -266,6 +267,29 @@ SmsManager::Delete(const jsval& aParam, nsIDOMMozSmsRequest** aRequest)
|
|||
return Delete(id, aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter, bool aReverse,
|
||||
nsIDOMMozSmsRequest** aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
|
||||
|
||||
if (!filter) {
|
||||
filter = new SmsFilter();
|
||||
}
|
||||
|
||||
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->CreateMessageList(filter, aReverse, requestId, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, received)
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, sent)
|
||||
NS_IMPL_EVENT_HANDLER(SmsManager, delivered)
|
||||
|
|
|
@ -144,8 +144,9 @@ SmsMessage::GetDelivery(nsAString& aDelivery)
|
|||
aDelivery = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
NS_ASSERTION(true, "We shouldn't get an unknown delivery state!");
|
||||
NS_ASSERTION(true, "We shouldn't get any other delivery state!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,9 @@ namespace sms {
|
|||
enum DeliveryState {
|
||||
eDeliveryState_Sent,
|
||||
eDeliveryState_Received,
|
||||
eDeliveryState_Unknown,
|
||||
// This state should stay at the end.
|
||||
eDeliveryState_Unknown
|
||||
eDeliveryState_EndGuard
|
||||
};
|
||||
|
||||
} // namespace sms
|
||||
|
@ -65,7 +66,7 @@ template <>
|
|||
struct ParamTraits<mozilla::dom::sms::DeliveryState>
|
||||
: public EnumSerializer<mozilla::dom::sms::DeliveryState,
|
||||
mozilla::dom::sms::eDeliveryState_Sent,
|
||||
mozilla::dom::sms::eDeliveryState_Unknown>
|
||||
mozilla::dom::sms::eDeliveryState_EndGuard>
|
||||
{};
|
||||
|
||||
} // namespace IPC
|
||||
|
|
|
@ -83,6 +83,15 @@ SmsDatabaseService::DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
// TODO: implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -69,6 +69,15 @@ SmsDatabaseService::DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
|
||||
bool aReverse, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
NS_ERROR("We should not be here!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -107,6 +107,8 @@ parent:
|
|||
|
||||
DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
CreateMessageList(SmsFilterData aFilter, bool aReverse, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "jsapi.h"
|
||||
#include "mozilla/dom/sms/SmsChild.h"
|
||||
#include "mozilla/dom/sms/SmsMessage.h"
|
||||
#include "SmsFilter.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -135,6 +136,17 @@ SmsIPCService::DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::CreateMessageList(nsIDOMMozSmsFilter* aFilter, bool aReverse,
|
||||
PRInt32 aRequestId, PRUint64 aProcessId)
|
||||
{
|
||||
SmsFilter* filter = static_cast<SmsFilter*>(aFilter);
|
||||
GetSmsChild()->SendCreateMessageList(filter->GetData(), aReverse, aRequestId,
|
||||
ContentChild::GetSingleton()->GetID());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "mozilla/unused.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "nsISmsDatabaseService.h"
|
||||
#include "SmsFilter.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -216,6 +217,22 @@ SmsParent::RecvDeleteMessage(const PRInt32& aMessageId, const PRInt32& aRequestI
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::RecvCreateMessageList(const SmsFilterData& aFilter,
|
||||
const bool& aReverse,
|
||||
const PRInt32& aRequestId,
|
||||
const PRUint64& aProcessId)
|
||||
{
|
||||
nsCOMPtr<nsISmsDatabaseService> smsDBService =
|
||||
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsDBService, true);
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsFilter> filter = new SmsFilter(aFilter);
|
||||
smsDBService->CreateMessageList(filter, aReverse, aRequestId, aProcessId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
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);
|
||||
NS_OVERRIDE virtual bool RecvCreateMessageList(const SmsFilterData& aFilter, const bool& aReverse, const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
|
||||
protected:
|
||||
virtual void ActorDestroy(ActorDestroyReason why);
|
||||
|
|
Загрузка…
Ссылка в новой задаче