зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 7 changesets (bug 824717) for bustage. r=khuey because the webidl hook is dumb
Backed out changeset bd7c604de980 (bug 824717) Backed out changeset 4c4b8b15da37 (bug 824717) Backed out changeset fd9e72e50518 (bug 824717) Backed out changeset d66a08988272 (bug 824717) Backed out changeset 5eaab20bb1aa (bug 824717) Backed out changeset c80dbc9a693a (bug 824717) Backed out changeset 62e12031b8bc (bug 824717)
This commit is contained in:
Родитель
7e385221e9
Коммит
81ea3fe8bc
|
@ -5,7 +5,7 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIDOMSmsSegmentInfo.idl"
|
||||
|
||||
[scriptable, uuid(0e6f8ace-cc59-11e3-aad5-e32847abfda1)]
|
||||
[scriptable, uuid(41db87b0-b0a1-11e3-a04f-cf487d837ee3)]
|
||||
interface nsIMobileMessageCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ interface nsIMobileMessageCallback : nsISupports
|
|||
* |message| can be nsIDOMMoz{Mms,Sms}Message.
|
||||
*/
|
||||
void notifyMessageSent(in nsISupports message);
|
||||
void notifySendMessageFailed(in long error, in nsISupports message);
|
||||
void notifySendMessageFailed(in long error);
|
||||
|
||||
/**
|
||||
* |message| can be nsIDOMMoz{Mms,Sms}Message.
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMMobileMessageError.h"
|
||||
#include "mozilla/dom/DOMMobileMessageErrorBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMobileMessageError)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMMobileMessageError, DOMError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSms)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMms)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DOMMobileMessageError, DOMError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSms)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMms)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMMobileMessageError)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMError)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DOMMobileMessageError, DOMError)
|
||||
NS_IMPL_RELEASE_INHERITED(DOMMobileMessageError, DOMError)
|
||||
|
||||
DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aName,
|
||||
nsIDOMMozSmsMessage* aSms)
|
||||
: DOMError(aWindow, aName)
|
||||
, mSms(aSms)
|
||||
, mMms(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aName,
|
||||
nsIDOMMozMmsMessage* aMms)
|
||||
: DOMError(aWindow, aName)
|
||||
, mSms(nullptr)
|
||||
, mMms(aMms)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DOMMobileMessageError::GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) const
|
||||
{
|
||||
if (mSms) {
|
||||
aRetVal.SetAsMozSmsMessage() = mSms;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMms) {
|
||||
aRetVal.SetAsMozMmsMessage() = mMms;
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSUME_UNREACHABLE("Bad object with invalid mSms and mMms.");
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMMobileMessageError::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return DOMMobileMessageErrorBinding::Wrap(aCx, this);
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MobileMessageError_h
|
||||
#define mozilla_dom_MobileMessageError_h
|
||||
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
|
||||
class nsIDOMMozMmsMessage;
|
||||
class nsIDOMMozSmsMessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class OwningMozSmsMessageOrMozMmsMessage;
|
||||
|
||||
class DOMMobileMessageError MOZ_FINAL : public DOMError
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMobileMessageError, DOMError)
|
||||
|
||||
DOMMobileMessageError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
||||
nsIDOMMozSmsMessage* aSms);
|
||||
|
||||
DOMMobileMessageError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
||||
nsIDOMMozMmsMessage* aMms);
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
void GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) const;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> mSms;
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mMms;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MobileMessageError_h
|
|
@ -16,7 +16,6 @@
|
|||
#include "xpcpublic.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
#include "DOMMobileMessageError.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -79,7 +78,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage, bool aAsync)
|
|||
}
|
||||
|
||||
nsresult
|
||||
MobileMessageCallback::NotifyError(int32_t aError, nsISupports *aData, bool aAsync)
|
||||
MobileMessageCallback::NotifyError(int32_t aError, bool aAsync)
|
||||
{
|
||||
nsAutoString errorStr;
|
||||
switch (aError) {
|
||||
|
@ -120,10 +119,6 @@ MobileMessageCallback::NotifyError(int32_t aError, nsISupports *aData, bool aAsy
|
|||
MOZ_CRASH("Should never get here!");
|
||||
}
|
||||
|
||||
if (aData && aAsync) {
|
||||
MOZ_CRASH("No Support to FireDetailedErrorAsync() in nsIDOMRequestService!");
|
||||
}
|
||||
|
||||
if (aAsync) {
|
||||
nsCOMPtr<nsIDOMRequestService> rs =
|
||||
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
|
@ -132,23 +127,6 @@ MobileMessageCallback::NotifyError(int32_t aError, nsISupports *aData, bool aAsy
|
|||
return rs->FireErrorAsync(mDOMRequest, errorStr);
|
||||
}
|
||||
|
||||
if (aData) {
|
||||
nsCOMPtr<nsISupports> domMobileMessageError;
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aData);
|
||||
if (smsMsg) {
|
||||
domMobileMessageError =
|
||||
new DOMMobileMessageError(mDOMRequest->GetOwner(), errorStr, smsMsg);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aData);
|
||||
domMobileMessageError =
|
||||
new DOMMobileMessageError(mDOMRequest->GetOwner(), errorStr, mmsMsg);
|
||||
}
|
||||
NS_ASSERTION(domMobileMessageError, "Invalid DOMMobileMessageError!");
|
||||
mDOMRequest->FireDetailedError(domMobileMessageError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mDOMRequest->FireError(errorStr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -160,9 +138,9 @@ MobileMessageCallback::NotifyMessageSent(nsISupports *aMessage)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageCallback::NotifySendMessageFailed(int32_t aError, nsISupports *aMessage)
|
||||
MobileMessageCallback::NotifySendMessageFailed(int32_t aError)
|
||||
{
|
||||
return NotifyError(aError, aMessage);
|
||||
return NotifyError(aError);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -233,7 +211,7 @@ MobileMessageCallback::NotifySegmentInfoForTextGot(nsIDOMMozSmsSegmentInfo *aInf
|
|||
NS_IMETHODIMP
|
||||
MobileMessageCallback::NotifyGetSegmentInfoForTextFailed(int32_t aError)
|
||||
{
|
||||
return NotifyError(aError, nullptr, true);
|
||||
return NotifyError(aError, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -31,7 +31,7 @@ private:
|
|||
|
||||
nsresult NotifySuccess(JS::Handle<JS::Value> aResult, bool aAsync = false);
|
||||
nsresult NotifySuccess(nsISupports *aMessage, bool aAsync = false);
|
||||
nsresult NotifyError(int32_t aError, nsISupports *aData = nullptr, bool aAsync = false);
|
||||
nsresult NotifyError(int32_t aError, bool aAsync = false);
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
|
|
|
@ -1955,7 +1955,8 @@ MmsService.prototype = {
|
|||
.setMessageReadStatusByEnvelopeId(envelopeId, address, readStatus,
|
||||
(function(aRv, aDomMessage) {
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Failed to update read status: " + aRv);
|
||||
// Notifying observers the read status is error.
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsReadSuccessObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2170,7 +2171,7 @@ MmsService.prototype = {
|
|||
// If the messsage has been deleted (because the sending process is
|
||||
// cancelled), we don't need to reset the its delievery state/status.
|
||||
if (aErrorCode == Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR) {
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
@ -2187,7 +2188,7 @@ MmsService.prototype = {
|
|||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
if (!isSentSuccess) {
|
||||
if (DEBUG) debug("Sending MMS failed.");
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
@ -2213,8 +2214,7 @@ MmsService.prototype = {
|
|||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Error! Fail to save sending message! rv = " + aRv);
|
||||
aRequest.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv),
|
||||
aDomMessage);
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv));
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ include protocol PSms;
|
|||
include protocol PBlob;
|
||||
include SmsTypes;
|
||||
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
@ -30,16 +28,9 @@ struct ReplyMessageSend
|
|||
MobileMessageData messageData;
|
||||
};
|
||||
|
||||
union OptionalMobileMessageData
|
||||
{
|
||||
void_t;
|
||||
MobileMessageData;
|
||||
};
|
||||
|
||||
struct ReplyMessageSendFail
|
||||
{
|
||||
int32_t error;
|
||||
OptionalMobileMessageData messageData;
|
||||
};
|
||||
|
||||
struct ReplyGetMessage
|
||||
|
|
|
@ -191,18 +191,8 @@ SmsRequestChild::Recv__delete__(const MessageReply& aReply)
|
|||
mReplyRequest->NotifyMessageSent(msg);
|
||||
}
|
||||
break;
|
||||
case MessageReply::TReplyMessageSendFail: {
|
||||
const ReplyMessageSendFail &replyFail = aReply.get_ReplyMessageSendFail();
|
||||
nsCOMPtr<nsISupports> msg;
|
||||
|
||||
if (replyFail.messageData().type() ==
|
||||
OptionalMobileMessageData::TMobileMessageData) {
|
||||
msg = CreateMessageFromMessageData(
|
||||
replyFail.messageData().get_MobileMessageData());
|
||||
}
|
||||
|
||||
mReplyRequest->NotifySendMessageFailed(replyFail.error(), msg);
|
||||
}
|
||||
case MessageReply::TReplyMessageSendFail:
|
||||
mReplyRequest->NotifySendMessageFailed(aReply.get_ReplyMessageSendFail().error());
|
||||
break;
|
||||
case MessageReply::TReplyGetMessage: {
|
||||
const MobileMessageData& data =
|
||||
|
|
|
@ -126,40 +126,6 @@ GetParamsFromSendMmsMessageRequest(JSContext* aCx,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetMobileMessageDataFromMessage(ContentParent* aParent,
|
||||
nsISupports *aMsg,
|
||||
MobileMessageData &aData)
|
||||
{
|
||||
if (!aMsg) {
|
||||
NS_WARNING("Invalid message to convert!");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
if (mmsMsg) {
|
||||
if (!aParent) {
|
||||
NS_ERROR("Invalid ContentParent to convert MMS Message!");
|
||||
return false;
|
||||
}
|
||||
MmsMessageData data;
|
||||
if (!static_cast<MmsMessage*>(mmsMsg.get())->GetData(aParent, data)) {
|
||||
return false;
|
||||
}
|
||||
aData = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
if (smsMsg) {
|
||||
aData = static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_WARNING("Cannot get MobileMessageData");
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(SmsParent, nsIObserver)
|
||||
|
||||
SmsParent::SmsParent()
|
||||
|
@ -206,11 +172,9 @@ NS_IMETHODIMP
|
|||
SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager());
|
||||
|
||||
if (!strcmp(aTopic, kSmsReceivedObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-received' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -221,7 +185,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsRetrievingObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-retrieving' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -232,7 +196,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsSendingObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-sending' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -243,7 +207,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsSentObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-sent' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -254,7 +218,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsFailedObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-failed' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -265,7 +229,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsDeliverySuccessObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-sending' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -276,7 +240,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsDeliveryErrorObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-delivery-error' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -303,9 +267,10 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp(aTopic, kSmsReadSuccessObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-read-success' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -316,7 +281,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (!strcmp(aTopic, kSmsReadErrorObserverTopic)) {
|
||||
MobileMessageData msgData;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aSubject, msgData)) {
|
||||
if (!GetMobileMessageDataFromMessage(aSubject, msgData)) {
|
||||
NS_ERROR("Got a 'sms-read-error' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -329,6 +294,31 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::GetMobileMessageDataFromMessage(nsISupports *aMsg,
|
||||
MobileMessageData &aData)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
if (mmsMsg) {
|
||||
MmsMessageData data;
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager());
|
||||
if (!static_cast<MmsMessage*>(mmsMsg.get())->GetData(parent, data)) {
|
||||
return false;
|
||||
}
|
||||
aData = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
if (smsMsg) {
|
||||
aData = static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_WARNING("Cannot get MobileMessageData");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::RecvAddSilentNumber(const nsString& aNumber)
|
||||
{
|
||||
|
@ -629,27 +619,30 @@ SmsRequestParent::NotifyMessageSent(nsISupports *aMessage)
|
|||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
MobileMessageData data;
|
||||
if (GetMobileMessageDataFromMessage(parent, aMessage, data)) {
|
||||
return SendReply(ReplyMessageSend(data));
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mms = do_QueryInterface(aMessage);
|
||||
if (mms) {
|
||||
MmsMessage *msg = static_cast<MmsMessage*>(mms.get());
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
MmsMessageData data;
|
||||
if (!msg->GetData(parent, data)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return SendReply(ReplyMessageSend(MobileMessageData(data)));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> sms = do_QueryInterface(aMessage);
|
||||
if (sms) {
|
||||
SmsMessage* msg = static_cast<SmsMessage*>(sms.get());
|
||||
return SendReply(ReplyMessageSend(MobileMessageData(msg->GetData())));
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequestParent::NotifySendMessageFailed(int32_t aError, nsISupports *aMessage)
|
||||
SmsRequestParent::NotifySendMessageFailed(int32_t aError)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
MobileMessageData data;
|
||||
if (!GetMobileMessageDataFromMessage(parent, aMessage, data)) {
|
||||
return SendReply(ReplyMessageSendFail(aError, OptionalMobileMessageData(void_t())));
|
||||
}
|
||||
|
||||
return SendReply(ReplyMessageSendFail(aError, OptionalMobileMessageData(data)));
|
||||
return SendReply(ReplyMessageSendFail(aError));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -657,10 +650,21 @@ SmsRequestParent::NotifyMessageGot(nsISupports *aMessage)
|
|||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
MobileMessageData data;
|
||||
if (GetMobileMessageDataFromMessage(parent, aMessage, data)) {
|
||||
return SendReply(ReplyGetMessage(data));
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mms = do_QueryInterface(aMessage);
|
||||
if (mms) {
|
||||
MmsMessage *msg = static_cast<MmsMessage*>(mms.get());
|
||||
ContentParent *parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
MmsMessageData data;
|
||||
if (!msg->GetData(parent, data)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return SendReply(ReplyGetMessage(MobileMessageData(data)));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> sms = do_QueryInterface(aMessage);
|
||||
if (sms) {
|
||||
SmsMessage* msg = static_cast<SmsMessage*>(sms.get());
|
||||
return SendReply(ReplyGetMessage(MobileMessageData(msg->GetData())));
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -66,6 +66,9 @@ protected:
|
|||
virtual bool
|
||||
DeallocPMobileMessageCursorParent(PMobileMessageCursorParent* aActor) MOZ_OVERRIDE;
|
||||
|
||||
bool
|
||||
GetMobileMessageDataFromMessage(nsISupports* aMsg, MobileMessageData& aData);
|
||||
|
||||
private:
|
||||
nsTArray<nsString> mSilentNumbers;
|
||||
};
|
||||
|
|
|
@ -37,7 +37,6 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
|
|||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'DOMMobileMessageError.h',
|
||||
'MmsMessage.h',
|
||||
'MobileMessageManager.h',
|
||||
'SmsFilter.h',
|
||||
|
@ -47,7 +46,6 @@ EXPORTS.mozilla.dom += [
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'Constants.cpp',
|
||||
'DOMMobileMessageError.cpp',
|
||||
'ipc/SmsChild.cpp',
|
||||
'ipc/SmsIPCService.cpp',
|
||||
'ipc/SmsParent.cpp',
|
||||
|
|
|
@ -70,33 +70,6 @@ function waitForManagerEvent(aEventName) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap DOMRequest onsuccess/onerror events to Promise resolve/reject.
|
||||
*
|
||||
* Fulfill params: A DOMEvent.
|
||||
* Reject params: A DOMEvent.
|
||||
*
|
||||
* @param aRequest
|
||||
* A DOMRequest instance.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function wrapDomRequestAsPromise(aRequest) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
ok(aRequest instanceof DOMRequest,
|
||||
"aRequest is instanceof " + aRequest.constructor);
|
||||
|
||||
aRequest.addEventListener("success", function(aEvent) {
|
||||
deferred.resolve(aEvent);
|
||||
});
|
||||
aRequest.addEventListener("error", function(aEvent) {
|
||||
deferred.reject(aEvent);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a SMS message to a single receiver. Resolve if it succeeds, reject
|
||||
* otherwise.
|
||||
|
@ -113,42 +86,17 @@ function wrapDomRequestAsPromise(aRequest) {
|
|||
* @return A deferred promise.
|
||||
*/
|
||||
function sendSmsWithSuccess(aReceiver, aText) {
|
||||
let request = manager.send(aReceiver, aText);
|
||||
return wrapDomRequestAsPromise(request)
|
||||
.then((aEvent) => { return aEvent.target.result; },
|
||||
(aEvent) => { throw aEvent.target.error; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a SMS message to a single receiver.
|
||||
* Resolve if it fails, reject otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
* {
|
||||
* message, -- the failed MmsMessage
|
||||
* error, -- error of the send request
|
||||
* }
|
||||
*
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aReceiver the address of the receiver.
|
||||
* @param aText the text body of the message.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function sendSmsWithFailure(aReceiver, aText) {
|
||||
let promises = [];
|
||||
promises.push(waitForManagerEvent("failed")
|
||||
.then((aEvent) => { return aEvent.message; }));
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = manager.send(aReceiver, aText);
|
||||
promises.push(wrapDomRequestAsPromise(request)
|
||||
.then((aEvent) => { throw aEvent; },
|
||||
(aEvent) => { return aEvent.target.error; }));
|
||||
request.onsuccess = function(event) {
|
||||
deferred.resolve(event.target.result);
|
||||
};
|
||||
request.onerror = function(event) {
|
||||
deferred.reject(event.target.error);
|
||||
};
|
||||
|
||||
return Promise.all(promises)
|
||||
.then((aResults) => { return { message: aResults[0],
|
||||
error: aResults[1] }; });
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,18 +118,30 @@ function sendSmsWithFailure(aReceiver, aText) {
|
|||
* @return A deferred promise.
|
||||
*/
|
||||
function sendMmsWithFailure(aMmsParameters, aSendParameters) {
|
||||
let promises = [];
|
||||
promises.push(waitForManagerEvent("failed")
|
||||
.then((aEvent) => { return aEvent.message; }));
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let result = { message: null, error: null };
|
||||
function got(which, value) {
|
||||
result[which] = value;
|
||||
if (result.message != null && result.error != null) {
|
||||
deferred.resolve(result);
|
||||
}
|
||||
}
|
||||
|
||||
manager.addEventListener("failed", function onfailed(event) {
|
||||
manager.removeEventListener("failed", onfailed);
|
||||
got("message", event.message);
|
||||
});
|
||||
|
||||
let request = manager.sendMMS(aMmsParameters, aSendParameters);
|
||||
promises.push(wrapDomRequestAsPromise(request)
|
||||
.then((aEvent) => { throw aEvent; },
|
||||
(aEvent) => { return aEvent.target.error; }));
|
||||
request.onsuccess = function(event) {
|
||||
deferred.reject();
|
||||
};
|
||||
request.onerror = function(event) {
|
||||
got("error", event.target.error);
|
||||
}
|
||||
|
||||
return Promise.all(promises)
|
||||
.then((aResults) => { return { message: aResults[0],
|
||||
error: aResults[1] }; });
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,9 +272,15 @@ function deleteMessagesById(aMessageIds) {
|
|||
return [];
|
||||
}
|
||||
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = manager.delete(aMessageIds);
|
||||
return wrapDomRequestAsPromise(request)
|
||||
.then((aEvent) => { return aEvent.target.result; });
|
||||
request.onsuccess = function(event) {
|
||||
deferred.resolve(event.target.result);
|
||||
};
|
||||
request.onerror = deferred.reject.bind(deferred);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,4 +49,3 @@ qemu = true
|
|||
[test_mt_sms_concatenation.js]
|
||||
[test_error_of_mms_manual_retrieval.js]
|
||||
[test_error_of_mms_send.js]
|
||||
[test_error_of_sms_send.js]
|
||||
|
|
|
@ -14,31 +14,13 @@ function testSendFailed(aCause, aServiceId) {
|
|||
sendParameters = { serviceId: aServiceId };
|
||||
}
|
||||
|
||||
let testSubject = "Test";
|
||||
let testReceivers = ["+0987654321"];
|
||||
|
||||
let mmsParameters = { subject: testSubject,
|
||||
receivers: testReceivers,
|
||||
let mmsParameters = { subject: "Test",
|
||||
receivers: ["+0987654321"],
|
||||
attachments: [] };
|
||||
|
||||
return sendMmsWithFailure(mmsParameters, sendParameters)
|
||||
.then((result) => {
|
||||
is(result.error.name, aCause, "Checking failure cause.");
|
||||
|
||||
let domMessage = result.error.data;
|
||||
is(domMessage.id, result.message.id, "Checking message id.");
|
||||
is(domMessage.subject, testSubject, "Checking subject.");
|
||||
is(domMessage.receivers.length, testReceivers.length, "Checking no. of receivers.");
|
||||
for (let i = 0; i < testReceivers.length; i++) {
|
||||
is(domMessage.receivers[i], testReceivers[i], "Checking receiver address.");
|
||||
}
|
||||
|
||||
let deliveryInfo = domMessage.deliveryInfo;
|
||||
is(deliveryInfo.length, testReceivers.length, "Checking no. of deliveryInfo.");
|
||||
for (let i = 0; i < deliveryInfo.length; i++) {
|
||||
is(deliveryInfo[i].receiver, testReceivers[i], "Checking receiver address.");
|
||||
is(deliveryInfo[i].deliveryStatus, "error", "Checking deliveryStatus.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const kPrefRilRadioDisabled = "ril.radio.disabled";
|
||||
|
||||
let connection;
|
||||
function ensureMobileConnection() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let permissions = [{
|
||||
"type": "mobileconnection",
|
||||
"allow": true,
|
||||
"context": document,
|
||||
}];
|
||||
SpecialPowers.pushPermissions(permissions, function() {
|
||||
ok(true, "permissions pushed: " + JSON.stringify(permissions));
|
||||
|
||||
connection = window.navigator.mozMobileConnections[0];
|
||||
if (connection) {
|
||||
log("navigator.mozMobileConnections[0] is instance of " + connection.constructor);
|
||||
} else {
|
||||
log("navigator.mozMobileConnections[0] is undefined.");
|
||||
}
|
||||
|
||||
if (connection instanceof MozMobileConnection) {
|
||||
deferred.resolve(connection);
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function waitRadioState(state) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
waitFor(function() {
|
||||
deferred.resolve();
|
||||
}, function() {
|
||||
return connection.radioState == state;
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function setRadioEnabled(enabled) {
|
||||
log("setRadioEnabled to " + enabled);
|
||||
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let finalState = (enabled) ? "enabled" : "disabled";
|
||||
connection.onradiostatechange = function() {
|
||||
let state = connection.radioState;
|
||||
log("Received 'radiostatechange' event, radioState: " + state);
|
||||
|
||||
if (state == finalState) {
|
||||
deferred.resolve();
|
||||
connection.onradiostatechange = null;
|
||||
}
|
||||
};
|
||||
|
||||
let req = connection.setRadioEnabled(enabled);
|
||||
|
||||
req.onsuccess = function() {
|
||||
log("setRadioEnabled success");
|
||||
};
|
||||
|
||||
req.onerror = function() {
|
||||
ok(false, "setRadioEnabled should not fail");
|
||||
deferred.reject();
|
||||
};
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testSendFailed(aCause) {
|
||||
log("testSendFailed, aCause: " + aCause);
|
||||
|
||||
let testReceiver = "+0987654321";
|
||||
let testMessage = "quick fox jump over the lazy dog";
|
||||
|
||||
return sendSmsWithFailure(testReceiver, testMessage)
|
||||
.then((result) => {
|
||||
is(result.error.name, aCause, "Checking failure cause.");
|
||||
|
||||
let domMessage = result.error.data;
|
||||
is(domMessage.id, result.message.id, "Checking message id.");
|
||||
is(domMessage.receiver, testReceiver, "Checking receiver address.");
|
||||
is(domMessage.body, testMessage, "Checking message body.");
|
||||
is(domMessage.delivery, "error", "Checking delivery.");
|
||||
is(domMessage.deliveryStatus, "error", "Checking deliveryStatus.");
|
||||
});
|
||||
}
|
||||
|
||||
startTestCommon(function testCaseMain() {
|
||||
return ensureMobileConnection()
|
||||
.then(() => waitRadioState("enabled"))
|
||||
.then(() => setRadioEnabled(false))
|
||||
.then(() => testSendFailed("RadioDisabledError"))
|
||||
.then(() => setRadioEnabled(true));
|
||||
});
|
|
@ -4082,8 +4082,7 @@ RadioInterface.prototype = {
|
|||
if (!Components.isSuccessCode(rv)) {
|
||||
if (DEBUG) this.debug("Error! Fail to save sending message! rv = " + rv);
|
||||
request.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(rv),
|
||||
domMessage);
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(rv));
|
||||
Services.obs.notifyObservers(domMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
@ -4109,7 +4108,7 @@ RadioInterface.prototype = {
|
|||
}
|
||||
if (errorCode) {
|
||||
if (silent) {
|
||||
request.notifySendMessageFailed(errorCode, domMessage);
|
||||
request.notifySendMessageFailed(errorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4121,7 +4120,7 @@ RadioInterface.prototype = {
|
|||
null,
|
||||
function notifyResult(rv, domMessage) {
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||
request.notifySendMessageFailed(errorCode, domMessage);
|
||||
request.notifySendMessageFailed(errorCode);
|
||||
Services.obs.notifyObservers(domMessage, kSmsFailedObserverTopic, null);
|
||||
});
|
||||
return;
|
||||
|
@ -4151,25 +4150,7 @@ RadioInterface.prototype = {
|
|||
}
|
||||
|
||||
if (context.silent) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
let sms = context.sms;
|
||||
context.request.notifySendMessageFailed(
|
||||
error,
|
||||
gMobileMessageService.createSmsMessage(sms.id,
|
||||
sms.threadId,
|
||||
sms.iccId,
|
||||
DOM_MOBILE_MESSAGE_DELIVERY_ERROR,
|
||||
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
|
||||
sms.sender,
|
||||
sms.receiver,
|
||||
sms.body,
|
||||
sms.messageClass,
|
||||
sms.timestamp,
|
||||
0,
|
||||
0,
|
||||
sms.read));
|
||||
context.request.notifySendMessageFailed(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4181,7 +4162,7 @@ RadioInterface.prototype = {
|
|||
null,
|
||||
function notifyResult(rv, domMessage) {
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||
context.request.notifySendMessageFailed(error, domMessage);
|
||||
context.request.notifySendMessageFailed(error);
|
||||
Services.obs.notifyObservers(domMessage, kSmsFailedObserverTopic, null);
|
||||
});
|
||||
return false;
|
||||
|
|
|
@ -305,8 +305,6 @@ var interfaceNamesInGlobalScope =
|
|||
"DOMImplementation",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "DOMMMIError", b2g: true, pref: "dom.mobileconnection.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "DOMMobileMessageError", b2g: true, pref: "dom.sms.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"DOMParser",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.sms.enabled"]
|
||||
interface DOMMobileMessageError : DOMError {
|
||||
readonly attribute (MozSmsMessage or MozMmsMessage) data;
|
||||
};
|
|
@ -88,7 +88,6 @@ WEBIDL_FILES = [
|
|||
'DOMError.webidl',
|
||||
'DOMException.webidl',
|
||||
'DOMImplementation.webidl',
|
||||
'DOMMobileMessageError.webidl',
|
||||
'DOMParser.webidl',
|
||||
'DOMPoint.webidl',
|
||||
'DOMQuad.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче