mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 794011 - Add 'sessionEnded' to nsIDOMUSSDReceivedEvent. r=mounir
This commit is contained in:
parent
ffe77a0c82
commit
40ab2b91fe
@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include "nsIDOMEvent.idl"
|
#include "nsIDOMEvent.idl"
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(1b8ea6e4-8142-4aba-b174-4d580b5bc294)]
|
[scriptable, builtinclass, uuid(c0de7fba-725f-4180-b1f1-83163014d1e2)]
|
||||||
interface nsIDOMUSSDReceivedEvent : nsIDOMEvent
|
interface nsIDOMUSSDReceivedEvent : nsIDOMEvent
|
||||||
{
|
{
|
||||||
readonly attribute DOMString message;
|
readonly attribute DOMString message;
|
||||||
|
[infallible] readonly attribute boolean sessionEnded;
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "nsJSON.h"
|
#include "nsJSON.h"
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
|
|
||||||
|
#include "mozilla/dom/USSDReceivedEventBinding.h"
|
||||||
|
|
||||||
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
||||||
|
|
||||||
#define VOICECHANGE_EVENTNAME NS_LITERAL_STRING("voicechange")
|
#define VOICECHANGE_EVENTNAME NS_LITERAL_STRING("voicechange")
|
||||||
@ -157,13 +159,15 @@ MobileConnection::Observe(nsISupports* aSubject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(aTopic, kUssdReceivedTopic)) {
|
if (!strcmp(aTopic, kUssdReceivedTopic)) {
|
||||||
nsString ussd;
|
mozilla::dom::USSDReceivedEventDict dict;
|
||||||
ussd.Assign(aData);
|
bool ok = dict.Init(nsDependentString(aData));
|
||||||
nsRefPtr<USSDReceivedEvent> event = USSDReceivedEvent::Create(ussd);
|
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsRefPtr<USSDReceivedEvent> event =
|
||||||
|
USSDReceivedEvent::Create(dict.message, dict.sessionEnded);
|
||||||
NS_ASSERTION(event, "This should never fail!");
|
NS_ASSERTION(event, "This should never fail!");
|
||||||
|
|
||||||
nsresult rv =
|
nsresult rv = event->Dispatch(ToIDOMEventTarget(), USSDRECEIVED_EVENTNAME);
|
||||||
event->Dispatch(ToIDOMEventTarget(), USSDRECEIVED_EVENTNAME);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,14 @@ namespace dom {
|
|||||||
namespace network {
|
namespace network {
|
||||||
|
|
||||||
already_AddRefed<USSDReceivedEvent>
|
already_AddRefed<USSDReceivedEvent>
|
||||||
USSDReceivedEvent::Create(nsAString& aMessage)
|
USSDReceivedEvent::Create(nsAString& aMessage, bool aSessionEnded)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
|
NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
|
||||||
|
|
||||||
nsRefPtr<USSDReceivedEvent> event = new USSDReceivedEvent();
|
nsRefPtr<USSDReceivedEvent> event = new USSDReceivedEvent();
|
||||||
|
|
||||||
event->mMessage = aMessage;
|
event->mMessage = aMessage;
|
||||||
|
event->mSessionEnded = aSessionEnded;
|
||||||
|
|
||||||
return event.forget();
|
return event.forget();
|
||||||
}
|
}
|
||||||
@ -40,6 +41,13 @@ USSDReceivedEvent::GetMessage(nsAString& aMessage)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* [infallible] */ NS_IMETHODIMP
|
||||||
|
USSDReceivedEvent::GetSessionEnded(bool* aSessionEnded)
|
||||||
|
{
|
||||||
|
*aSessionEnded = mSessionEnded;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ class USSDReceivedEvent : public nsDOMEvent,
|
|||||||
public nsIDOMUSSDReceivedEvent
|
public nsIDOMUSSDReceivedEvent
|
||||||
{
|
{
|
||||||
nsString mMessage;
|
nsString mMessage;
|
||||||
|
bool mSessionEnded;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
@ -23,7 +24,7 @@ public:
|
|||||||
NS_DECL_NSIDOMUSSDRECEIVEDEVENT
|
NS_DECL_NSIDOMUSSDRECEIVEDEVENT
|
||||||
|
|
||||||
static already_AddRefed<USSDReceivedEvent>
|
static already_AddRefed<USSDReceivedEvent>
|
||||||
Create(nsAString& aMessage);
|
Create(nsAString& aMessage, bool aSessionEnded);
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
|
Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
|
||||||
|
@ -710,8 +710,9 @@ RILContentHelper.prototype = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "RIL:USSDReceived":
|
case "RIL:USSDReceived":
|
||||||
Services.obs.notifyObservers(null, kUssdReceivedTopic,
|
let res = JSON.stringify({message: msg.json.message,
|
||||||
msg.json.message);
|
sessionEnded: msg.json.sessionEnded});
|
||||||
|
Services.obs.notifyObservers(null, kUssdReceivedTopic, res);
|
||||||
break;
|
break;
|
||||||
case "RIL:SendMMI:Return:OK":
|
case "RIL:SendMMI:Return:OK":
|
||||||
case "RIL:CancelMMI:Return:OK":
|
case "RIL:CancelMMI:Return:OK":
|
||||||
|
@ -4845,14 +4845,11 @@ RIL[UNSOLICITED_ON_USSD] = function UNSOLICITED_ON_USSD() {
|
|||||||
debug("On USSD. Type Code: " + typeCode + " Message: " + message);
|
debug("On USSD. Type Code: " + typeCode + " Message: " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._ussdSession = (typeCode != "0" || typeCode != "2");
|
this._ussdSession = (typeCode != "0" && typeCode != "2");
|
||||||
|
|
||||||
// Empty message should not be progressed to the DOM.
|
|
||||||
if (!message || message == "") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.sendDOMMessage({rilMessageType: "USSDReceived",
|
this.sendDOMMessage({rilMessageType: "USSDReceived",
|
||||||
message: message});
|
message: message,
|
||||||
|
sessionEnded: !this._ussdSession});
|
||||||
};
|
};
|
||||||
RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED() {
|
RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED() {
|
||||||
let dateString = Buf.readString();
|
let dateString = Buf.readString();
|
||||||
|
10
dom/webidl/USSDReceivedEvent.webidl
Normal file
10
dom/webidl/USSDReceivedEvent.webidl
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/* -*- 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dictionary USSDReceivedEventDict {
|
||||||
|
DOMString message = "";
|
||||||
|
boolean sessionEnded = false;
|
||||||
|
};
|
@ -61,6 +61,12 @@ webidl_files += \
|
|||||||
$(NULL)
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef MOZ_B2G_RIL
|
||||||
|
webidl_files += \
|
||||||
|
USSDReceivedEvent.webidl \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef ENABLE_TESTS
|
ifdef ENABLE_TESTS
|
||||||
test_webidl_files := \
|
test_webidl_files := \
|
||||||
TestCodeGen.webidl \
|
TestCodeGen.webidl \
|
||||||
|
Loading…
Reference in New Issue
Block a user