mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 844431 - B2G MMS: provide nsIDOMMobileMessageManager interface (with sendMMS() first) (part 6, dispatch MMS events). r=vicamo,mounir sr=sicking a=leo+
This commit is contained in:
parent
489f230373
commit
1aab17284e
@ -860,6 +860,8 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
|
||||
return NS_NewDOMCustomEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
if (aEventType.LowerCaseEqualsLiteral("mozsmsevent"))
|
||||
return NS_NewDOMMozSmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
if (aEventType.LowerCaseEqualsLiteral("mozmmsevent"))
|
||||
return NS_NewDOMMozMmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
if (aEventType.LowerCaseEqualsLiteral("storageevent")) {
|
||||
return NS_NewDOMStorageEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ const RIL_MMSSERVICE_CID = Components.ID("{217ddd76-75db-4210-955d-8806cd8d87f9}
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
const kMmsSendingObserverTopic = "mms-sending";
|
||||
const kMmsSentObserverTopic = "mms-sent";
|
||||
const kMmsFailedObserverTopic = "mms-failed";
|
||||
|
||||
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
|
||||
const kXpcomShutdownObserverTopic = "xpcom-shutdown";
|
||||
const kPrefenceChangedObserverTopic = "nsPref:changed";
|
||||
@ -1098,7 +1102,13 @@ MmsService.prototype = {
|
||||
* The MMS message object.
|
||||
*/
|
||||
handleDeliveryIndication: function handleDeliveryIndication(msg) {
|
||||
// TODO: bug 811252 - implement MMS database
|
||||
// TODO Bug 850140 Two things we need to do in the future:
|
||||
//
|
||||
// 1. Use gMobileMessageDatabaseService.setMessageDelivery() to reset
|
||||
// the delivery status to "success" or "error" for a specific receiver.
|
||||
//
|
||||
// 2. Fire "mms-delivery-success" or "mms-delivery-error" observer
|
||||
// topics to MobileMessageManager.
|
||||
let messageId = msg.headers["message-id"];
|
||||
debug("handleDeliveryIndication: got delivery report for " + messageId);
|
||||
},
|
||||
@ -1231,9 +1241,11 @@ MmsService.prototype = {
|
||||
debug("Marking the delivery state/staus is done. Notify sent or failed.");
|
||||
if (!aIsSentSuccess) {
|
||||
aRequest.notifySendMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
|
||||
Services.obs.notifyObservers(aMmsMessage, kMmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
aRequest.notifyMessageSent(aMmsMessage);
|
||||
Services.obs.notifyObservers(aMmsMessage, kMmsSentObserverTopic, null);
|
||||
});
|
||||
};
|
||||
|
||||
@ -1243,6 +1255,7 @@ MmsService.prototype = {
|
||||
function notifySendingResult(sendingRv, sendingRecord) {
|
||||
debug("Saving sending message is done. Start to send.");
|
||||
let mmsMessage = self.createMmsMessageFromRecord(sendingRecord);
|
||||
Services.obs.notifyObservers(mmsMessage, kMmsSendingObserverTopic, null);
|
||||
let sendTransaction;
|
||||
try {
|
||||
sendTransaction = new SendTransaction(sendingRecord);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMMobileMessageManager.idl',
|
||||
'nsIDOMMozMmsEvent.idl',
|
||||
'nsIDOMMozMmsMessage.idl',
|
||||
'nsIDOMMozSmsEvent.idl',
|
||||
'nsIDOMMozSmsMessage.idl',
|
||||
|
23
dom/mobilemessage/interfaces/nsIDOMMozMmsEvent.idl
Normal file
23
dom/mobilemessage/interfaces/nsIDOMMozMmsEvent.idl
Normal file
@ -0,0 +1,23 @@
|
||||
/* 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 "nsIDOMEvent.idl"
|
||||
|
||||
interface nsIDOMMozMmsMessage;
|
||||
|
||||
[scriptable, builtinclass, uuid(b33cc0f2-8886-11e2-9433-eff9a8af9a70)]
|
||||
interface nsIDOMMozMmsEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute nsIDOMMozMmsMessage message;
|
||||
|
||||
[noscript] void initMozMmsEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in nsIDOMMozMmsMessage aMessage);
|
||||
};
|
||||
|
||||
dictionary MozMmsEventInit : EventInit
|
||||
{
|
||||
nsIDOMMozMmsMessage message;
|
||||
};
|
@ -14,6 +14,10 @@ const char* kSmsFailedObserverTopic = "sms-failed";
|
||||
const char* kSmsDeliverySuccessObserverTopic = "sms-delivery-success";
|
||||
const char* kSmsDeliveryErrorObserverTopic = "sms-delivery-error";
|
||||
|
||||
const char* kMmsSendingObserverTopic = "mms-sending";
|
||||
const char* kMmsSentObserverTopic = "mms-sent";
|
||||
const char* kMmsFailedObserverTopic = "mms-failed";
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -18,6 +18,10 @@ extern const char* kSmsFailedObserverTopic;
|
||||
extern const char* kSmsDeliverySuccessObserverTopic;
|
||||
extern const char* kSmsDeliveryErrorObserverTopic;
|
||||
|
||||
extern const char* kMmsSendingObserverTopic;
|
||||
extern const char* kMmsSentObserverTopic;
|
||||
extern const char* kMmsFailedObserverTopic;
|
||||
|
||||
#define DELIVERY_RECEIVED NS_LITERAL_STRING("received")
|
||||
#define DELIVERY_SENDING NS_LITERAL_STRING("sending")
|
||||
#define DELIVERY_SENT NS_LITERAL_STRING("sent")
|
||||
|
@ -13,7 +13,9 @@
|
||||
#include "mozilla/Services.h"
|
||||
#include "Constants.h"
|
||||
#include "nsIDOMMozSmsEvent.h"
|
||||
#include "nsIDOMMozMmsEvent.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -72,6 +74,10 @@ MobileMessageManager::Init(nsPIDOMWindow *aWindow)
|
||||
obs->AddObserver(this, kSmsFailedObserverTopic, false);
|
||||
obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
|
||||
obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
|
||||
|
||||
obs->AddObserver(this, kMmsSendingObserverTopic, false);
|
||||
obs->AddObserver(this, kMmsSentObserverTopic, false);
|
||||
obs->AddObserver(this, kMmsFailedObserverTopic, false);
|
||||
}
|
||||
|
||||
void
|
||||
@ -89,6 +95,10 @@ MobileMessageManager::Shutdown()
|
||||
obs->RemoveObserver(this, kSmsFailedObserverTopic);
|
||||
obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
|
||||
obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
|
||||
|
||||
obs->RemoveObserver(this, kMmsSendingObserverTopic);
|
||||
obs->RemoveObserver(this, kMmsSentObserverTopic);
|
||||
obs->RemoveObserver(this, kMmsFailedObserverTopic);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -305,13 +315,27 @@ MobileMessageManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsEvent> se = do_QueryInterface(event);
|
||||
MOZ_ASSERT(se);
|
||||
nsresult rv = se->InitMozSmsEvent(aEventName, false, false, aMessage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileMessageManager::DispatchTrustedMmsEventToSelf(const nsAString& aEventName,
|
||||
nsIDOMMozMmsMessage* aMessage)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMMozMmsEvent(getter_AddRefs(event), this, nullptr, nullptr);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsEvent> se = do_QueryInterface(event);
|
||||
nsresult rv = se->InitMozMmsEvent(aEventName, false, false, aMessage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageManager::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
@ -382,6 +406,39 @@ MobileMessageManager::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kMmsSendingObserverTopic)) {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = do_QueryInterface(aSubject);
|
||||
if (!message) {
|
||||
NS_ERROR("Got a 'mms-sending' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DispatchTrustedMmsEventToSelf(SENDING_EVENT_NAME, message);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kMmsSentObserverTopic)) {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = do_QueryInterface(aSubject);
|
||||
if (!message) {
|
||||
NS_ERROR("Got a 'mms-sent' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DispatchTrustedMmsEventToSelf(SENT_EVENT_NAME, message);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kMmsFailedObserverTopic)) {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = do_QueryInterface(aSubject);
|
||||
if (!message) {
|
||||
NS_ERROR("Got a 'mms-failed' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DispatchTrustedMmsEventToSelf(FAILED_EVENT_NAME, message);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
|
||||
class nsIDOMMozSmsMessage;
|
||||
class nsIDOMMozMmsMessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -43,6 +44,9 @@ private:
|
||||
|
||||
nsresult DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
|
||||
nsIDOMMozSmsMessage* aMessage);
|
||||
|
||||
nsresult DispatchTrustedMmsEventToSelf(const nsAString& aEventName,
|
||||
nsIDOMMozMmsMessage* aMessage);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -263,6 +263,7 @@ var interfaceNamesInGlobalScope =
|
||||
"SVGPathSegLinetoRel",
|
||||
"HTMLImageElement",
|
||||
"MozSmsEvent",
|
||||
"MozMmsEvent",
|
||||
"CustomEvent",
|
||||
"XMLHttpRequestUpload",
|
||||
"SVGFEFuncBElement",
|
||||
|
@ -41,6 +41,7 @@ simple_events = [
|
||||
#endif
|
||||
'ElementReplaceEvent',
|
||||
'MozSmsEvent',
|
||||
'MozMmsEvent',
|
||||
'DeviceStorageChangeEvent',
|
||||
'PopupBlockedEvent',
|
||||
'BlobEvent'
|
||||
|
Loading…
Reference in New Issue
Block a user