mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changesets 3ad7043d2116, 774f695d8c0a, c7d7762d5e27, and 87cd44cd57b7 (bug 1058397) for non-unified bustage.
This commit is contained in:
parent
5a0b110499
commit
c639baaf14
@ -25,8 +25,8 @@ const MOBILENETWORKINFO_CID =
|
||||
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
|
||||
const MOBILECELLINFO_CID =
|
||||
Components.ID("{0635d9ab-997e-4cdf-84e7-c1883752dff3}");
|
||||
const TELEPHONYDIALCALLBACK_CID =
|
||||
Components.ID("{c2af1a5d-3649-44ef-a1ff-18e9ac1dec51}");
|
||||
const TELEPHONYCALLBACK_CID =
|
||||
Components.ID("{6e1af17e-37f3-11e4-aed3-60a44c237d2b}");
|
||||
|
||||
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
||||
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
||||
@ -141,14 +141,14 @@ MMIResult.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrap a MobileConnectionCallback to a TelephonyDialCallback.
|
||||
* Wrap a MobileConnectionCallback to a TelephonyCallback.
|
||||
*/
|
||||
function TelephonyDialCallback(aCallback) {
|
||||
function TelephonyCallback(aCallback) {
|
||||
this.callback = aCallback;
|
||||
}
|
||||
TelephonyDialCallback.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyDialCallback]),
|
||||
classID: TELEPHONYDIALCALLBACK_CID,
|
||||
TelephonyCallback.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]),
|
||||
classID: TELEPHONYCALLBACK_CID,
|
||||
|
||||
notifyDialMMI: function(mmiServiceCode) {
|
||||
this.serviceCode = mmiServiceCode;
|
||||
@ -725,8 +725,8 @@ MobileConnectionProvider.prototype = {
|
||||
},
|
||||
|
||||
sendMMI: function(aMmi, aCallback) {
|
||||
let callback = new TelephonyDialCallback(aCallback);
|
||||
gGonkTelephonyService.dialMMI(this._clientId, aMmi, callback);
|
||||
let telephonyCallback = new TelephonyCallback(aCallback);
|
||||
gGonkTelephonyService.dialMMI(this._clientId, aMmi, telephonyCallback);
|
||||
},
|
||||
|
||||
cancelMMI: function(aCallback) {
|
||||
@ -1056,6 +1056,14 @@ MobileConnectionService.prototype = {
|
||||
|
||||
this.getItemByServiceId(aClientId)
|
||||
.deliverListenerEvent("notifyUssdReceived", [aMessage, aSessionEnded]);
|
||||
|
||||
let info = {
|
||||
message: aMessage,
|
||||
sessionEnded: aSessionEnded,
|
||||
serviceId: aClientId
|
||||
};
|
||||
|
||||
gSystemMessenger.broadcastMessage("ussd-received", info);
|
||||
},
|
||||
|
||||
notifyDataError: function(aClientId, aMessage) {
|
||||
|
@ -1976,18 +1976,13 @@ RadioInterface.prototype = {
|
||||
gTelephonyService.notifyConferenceCallStateChanged(message.state);
|
||||
break;
|
||||
case "cdmaCallWaiting":
|
||||
gTelephonyService.notifyCdmaCallWaiting(this.clientId,
|
||||
message.waitingCall);
|
||||
gTelephonyService.notifyCdmaCallWaiting(this.clientId, message.waitingCall);
|
||||
break;
|
||||
case "suppSvcNotification":
|
||||
gTelephonyService.notifySupplementaryService(this.clientId,
|
||||
message.callIndex,
|
||||
message.notification);
|
||||
break;
|
||||
case "ussdreceived":
|
||||
gTelephonyService.notifyUssdReceived(this.clientId, message.message,
|
||||
message.sessionEnded);
|
||||
break;
|
||||
case "datacallerror":
|
||||
connHandler.handleDataCallError(message);
|
||||
break;
|
||||
@ -2041,6 +2036,11 @@ RadioInterface.prototype = {
|
||||
gRadioEnabledController.notifyRadioStateChanged(this.clientId,
|
||||
message.radioState);
|
||||
break;
|
||||
case "ussdreceived":
|
||||
gMobileConnectionService.notifyUssdReceived(this.clientId,
|
||||
message.message,
|
||||
message.sessionEnded);
|
||||
break;
|
||||
case "cardstatechange":
|
||||
this.rilContext.cardState = message.cardState;
|
||||
gRadioEnabledController.receiveCardState(this.clientId);
|
||||
|
@ -2641,48 +2641,22 @@ RilObject.prototype = {
|
||||
}
|
||||
|
||||
options.ussd = mmi.fullMMI;
|
||||
|
||||
if (options.startNewSession && this._ussdSession) {
|
||||
if (DEBUG) this.context.debug("Cancel existing ussd session.");
|
||||
this.cachedUSSDRequest = options;
|
||||
this.cancelUSSD({});
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendUSSD(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Cache the request for send out a new ussd when there is an existing
|
||||
* session. We should do cancelUSSD first.
|
||||
*/
|
||||
cachedUSSDRequest : null,
|
||||
|
||||
/**
|
||||
* Send USSD.
|
||||
*
|
||||
* @param ussd
|
||||
* String containing the USSD code.
|
||||
* @param checkSession
|
||||
* True if an existing session should be there.
|
||||
*
|
||||
*/
|
||||
sendUSSD: function(options) {
|
||||
if (options.checkSession && !this._ussdSession) {
|
||||
options.success = false;
|
||||
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
|
||||
this.sendChromeMessage(options);
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendRilRequestSendUSSD(options);
|
||||
},
|
||||
|
||||
sendRilRequestSendUSSD: function(options) {
|
||||
let Buf = this.context.Buf;
|
||||
Buf.newParcel(REQUEST_SEND_USSD, options);
|
||||
Buf.writeString(options.ussd);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
sendUSSD: function(options) {
|
||||
let Buf = this.context.Buf;
|
||||
Buf.newParcel(REQUEST_SEND_USSD, options);
|
||||
Buf.writeString(options.ussd);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancel pending USSD.
|
||||
@ -5707,19 +5681,9 @@ RilObject.prototype[REQUEST_CANCEL_USSD] = function REQUEST_CANCEL_USSD(length,
|
||||
if (DEBUG) {
|
||||
this.context.debug("REQUEST_CANCEL_USSD" + JSON.stringify(options));
|
||||
}
|
||||
|
||||
options.success = (options.rilRequestError === 0);
|
||||
this._ussdSession = !options.success;
|
||||
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
|
||||
|
||||
// The cancelUSSD is triggered by ril_worker itself.
|
||||
if (this.cachedUSSDRequest) {
|
||||
if (DEBUG) this.context.debug("Send out the cached ussd request");
|
||||
this.sendUSSD(this.cachedUSSDRequest);
|
||||
this.cachedUSSDRequest = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendChromeMessage(options);
|
||||
};
|
||||
RilObject.prototype[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, options) {
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "TelephonyCall.h"
|
||||
#include "TelephonyCallGroup.h"
|
||||
#include "TelephonyCallId.h"
|
||||
#include "TelephonyDialCallback.h"
|
||||
#include "TelephonyCallback.h"
|
||||
|
||||
// Service instantiation
|
||||
#include "ipc/TelephonyIPCService.h"
|
||||
@ -235,8 +235,8 @@ Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber,
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITelephonyDialCallback> callback =
|
||||
new TelephonyDialCallback(GetOwner(), this, promise, aServiceId);
|
||||
nsCOMPtr<nsITelephonyCallback> callback =
|
||||
new TelephonyCallback(GetOwner(), this, promise, aServiceId);
|
||||
|
||||
nsresult rv = mService->Dial(aServiceId, aNumber, aEmergency, callback);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -23,7 +23,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace telephony {
|
||||
|
||||
class TelephonyDialCallback;
|
||||
class TelephonyCallback;
|
||||
|
||||
} // namespace telephony
|
||||
|
||||
@ -43,7 +43,7 @@ class Telephony MOZ_FINAL : public DOMEventTargetHelper,
|
||||
class EnumerationAck;
|
||||
|
||||
friend class EnumerationAck;
|
||||
friend class telephony::TelephonyDialCallback;
|
||||
friend class telephony::TelephonyCallback;
|
||||
|
||||
nsCOMPtr<nsITelephonyService> mService;
|
||||
nsRefPtr<Listener> mListener;
|
||||
|
@ -4,31 +4,136 @@
|
||||
|
||||
#include "TelephonyCallback.h"
|
||||
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "mozilla/dom/DOMMMIError.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::telephony;
|
||||
|
||||
NS_IMPL_ISUPPORTS(TelephonyCallback, nsITelephonyCallback)
|
||||
|
||||
TelephonyCallback::TelephonyCallback(Promise* aPromise)
|
||||
: mPromise(aPromise)
|
||||
TelephonyCallback::TelephonyCallback(nsPIDOMWindow* aWindow,
|
||||
Telephony* aTelephony,
|
||||
Promise* aPromise,
|
||||
uint32_t aServiceId)
|
||||
: mWindow(aWindow), mTelephony(aTelephony), mPromise(aPromise),
|
||||
mServiceId(aServiceId)
|
||||
{
|
||||
MOZ_ASSERT(mTelephony);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyCallback::NotifyDialMMISuccess(const nsAString& aStatusMessage)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!NS_WARN_IF(jsapi.Init(mWindow))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
MozMMIResult result;
|
||||
|
||||
result.mServiceCode.Assign(mServiceCode);
|
||||
result.mStatusMessage.Assign(aStatusMessage);
|
||||
|
||||
return NotifyDialMMISuccess(cx, result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyCallback::NotifyDialMMISuccess(JSContext* aCx,
|
||||
const nsAString& aStatusMessage,
|
||||
JS::Handle<JS::Value> aInfo)
|
||||
{
|
||||
RootedDictionary<MozMMIResult> result(aCx);
|
||||
|
||||
result.mServiceCode.Assign(mServiceCode);
|
||||
result.mStatusMessage.Assign(aStatusMessage);
|
||||
result.mAdditionalInformation.Construct().SetAsObject() = &aInfo.toObject();
|
||||
|
||||
return NotifyDialMMISuccess(aCx, result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyCallback::NotifyDialMMISuccess(JSContext* aCx,
|
||||
const MozMMIResult& aResult)
|
||||
{
|
||||
JS::Rooted<JS::Value> jsResult(aCx);
|
||||
|
||||
if (!ToJSValue(aCx, aResult, &jsResult)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NotifyDialMMISuccess(jsResult);
|
||||
}
|
||||
|
||||
// nsITelephonyCallback
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifySuccess()
|
||||
TelephonyCallback::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
{
|
||||
mPromise->MaybeResolve(JS::UndefinedHandleValue);
|
||||
mMMIRequest = new DOMRequest(mWindow);
|
||||
mServiceCode.Assign(aServiceCode);
|
||||
|
||||
mPromise->MaybeResolve(mMMIRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifyError(const nsAString& aError)
|
||||
TelephonyCallback::NotifyDialError(const nsAString& aError)
|
||||
{
|
||||
mPromise->MaybeRejectBrokenly(aError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifyDialCallSuccess(uint32_t aCallIndex,
|
||||
const nsAString& aNumber)
|
||||
{
|
||||
nsRefPtr<TelephonyCallId> id = mTelephony->CreateCallId(aNumber);
|
||||
nsRefPtr<TelephonyCall> call =
|
||||
mTelephony->CreateCall(id, mServiceId, aCallIndex,
|
||||
nsITelephonyService::CALL_STATE_DIALING);
|
||||
|
||||
mPromise->MaybeResolve(call);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifyDialMMISuccess(JS::Handle<JS::Value> aResult)
|
||||
{
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireSuccessAsync(mMMIRequest, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifyDialMMIError(const nsAString& aError)
|
||||
{
|
||||
Nullable<int16_t> info;
|
||||
|
||||
nsRefPtr<DOMError> error =
|
||||
new DOMMMIError(mWindow, aError, EmptyString(), mServiceCode, info);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireDetailedError(mMMIRequest, error);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyCallback::NotifyDialMMIErrorWithInfo(const nsAString& aError,
|
||||
uint16_t aInfo)
|
||||
{
|
||||
Nullable<int16_t> info(aInfo);
|
||||
|
||||
nsRefPtr<DOMError> error =
|
||||
new DOMMMIError(mWindow, aError, EmptyString(), mServiceCode, info);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireDetailedError(mMMIRequest, error);
|
||||
}
|
||||
|
@ -5,30 +5,73 @@
|
||||
#ifndef mozilla_dom_TelephonyCallback_h
|
||||
#define mozilla_dom_TelephonyCallback_h
|
||||
|
||||
#include "Telephony.h"
|
||||
#include "mozilla/dom/DOMRequest.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITelephonyService.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
|
||||
namespace telephony {
|
||||
|
||||
class TelephonyCallback : public nsITelephonyCallback
|
||||
class TelephonyCallback MOZ_FINAL : public nsITelephonyCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYCALLBACK
|
||||
|
||||
TelephonyCallback(Promise* aPromise);
|
||||
TelephonyCallback(nsPIDOMWindow* aWindow, Telephony* aTelephony,
|
||||
Promise* aPromise, uint32_t aServiceId);
|
||||
|
||||
protected:
|
||||
virtual ~TelephonyCallback() {}
|
||||
nsresult
|
||||
NotifyDialMMISuccess(const nsAString& aStatusMessage);
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
nsresult
|
||||
NotifyDialMMISuccess(const nsAString& aStatusMessage, const T& aInfo)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!NS_WARN_IF(jsapi.Init(mWindow))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JS::Value> info(cx);
|
||||
|
||||
if (!ToJSValue(cx, aInfo, &info)) {
|
||||
JS_ClearPendingException(cx);
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NotifyDialMMISuccess(cx, aStatusMessage, info);
|
||||
}
|
||||
|
||||
private:
|
||||
~TelephonyCallback() {}
|
||||
|
||||
nsresult
|
||||
NotifyDialMMISuccess(JSContext* aCx, const nsAString& aStatusMessage,
|
||||
JS::Handle<JS::Value> aInfo);
|
||||
|
||||
nsresult
|
||||
NotifyDialMMISuccess(JSContext* aCx, const MozMMIResult& aResult);
|
||||
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsRefPtr<Telephony> mTelephony;
|
||||
nsRefPtr<Promise> mPromise;
|
||||
uint32_t mServiceId;
|
||||
|
||||
nsRefPtr<DOMRequest> mMMIRequest;
|
||||
nsString mServiceCode;
|
||||
};
|
||||
|
||||
} // namespace telephony
|
||||
|
@ -1,133 +0,0 @@
|
||||
/* 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 "TelephonyDialCallback.h"
|
||||
|
||||
#include "mozilla/dom/DOMMMIError.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::telephony;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(TelephonyDialCallback, TelephonyCallback,
|
||||
nsITelephonyDialCallback)
|
||||
|
||||
TelephonyDialCallback::TelephonyDialCallback(nsPIDOMWindow* aWindow,
|
||||
Telephony* aTelephony,
|
||||
Promise* aPromise,
|
||||
uint32_t aServiceId)
|
||||
: TelephonyCallback(aPromise), mWindow(aWindow), mTelephony(aTelephony),
|
||||
mServiceId(aServiceId)
|
||||
{
|
||||
MOZ_ASSERT(mTelephony);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyDialCallback::NotifyDialMMISuccess(const nsAString& aStatusMessage)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!NS_WARN_IF(jsapi.Init(mWindow))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
MozMMIResult result;
|
||||
|
||||
result.mServiceCode.Assign(mServiceCode);
|
||||
result.mStatusMessage.Assign(aStatusMessage);
|
||||
|
||||
return NotifyDialMMISuccess(cx, result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyDialCallback::NotifyDialMMISuccess(JSContext* aCx,
|
||||
const nsAString& aStatusMessage,
|
||||
JS::Handle<JS::Value> aInfo)
|
||||
{
|
||||
RootedDictionary<MozMMIResult> result(aCx);
|
||||
|
||||
result.mServiceCode.Assign(mServiceCode);
|
||||
result.mStatusMessage.Assign(aStatusMessage);
|
||||
result.mAdditionalInformation.Construct().SetAsObject() = &aInfo.toObject();
|
||||
|
||||
return NotifyDialMMISuccess(aCx, result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyDialCallback::NotifyDialMMISuccess(JSContext* aCx,
|
||||
const MozMMIResult& aResult)
|
||||
{
|
||||
JS::Rooted<JS::Value> jsResult(aCx);
|
||||
|
||||
if (!ToJSValue(aCx, aResult, &jsResult)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NotifyDialMMISuccess(jsResult);
|
||||
}
|
||||
|
||||
// nsITelephonyDialCallback
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyDialCallback::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
{
|
||||
mMMIRequest = new DOMRequest(mWindow);
|
||||
mServiceCode.Assign(aServiceCode);
|
||||
|
||||
mPromise->MaybeResolve(mMMIRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyDialCallback::NotifyDialCallSuccess(uint32_t aCallIndex,
|
||||
const nsAString& aNumber)
|
||||
{
|
||||
nsRefPtr<TelephonyCallId> id = mTelephony->CreateCallId(aNumber);
|
||||
nsRefPtr<TelephonyCall> call =
|
||||
mTelephony->CreateCall(id, mServiceId, aCallIndex,
|
||||
nsITelephonyService::CALL_STATE_DIALING);
|
||||
|
||||
mPromise->MaybeResolve(call);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyDialCallback::NotifyDialMMISuccess(JS::Handle<JS::Value> aResult)
|
||||
{
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireSuccessAsync(mMMIRequest, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyDialCallback::NotifyDialMMIError(const nsAString& aError)
|
||||
{
|
||||
Nullable<int16_t> info;
|
||||
|
||||
nsRefPtr<DOMError> error =
|
||||
new DOMMMIError(mWindow, aError, EmptyString(), mServiceCode, info);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireDetailedError(mMMIRequest, error);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyDialCallback::NotifyDialMMIErrorWithInfo(const nsAString& aError,
|
||||
uint16_t aInfo)
|
||||
{
|
||||
Nullable<int16_t> info(aInfo);
|
||||
|
||||
nsRefPtr<DOMError> error =
|
||||
new DOMMMIError(mWindow, aError, EmptyString(), mServiceCode, info);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
return rs->FireDetailedError(mMMIRequest, error);
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/* 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_TelephonyDialCallback_h
|
||||
#define mozilla_dom_TelephonyDialCallback_h
|
||||
|
||||
#include "Telephony.h"
|
||||
#include "mozilla/dom/DOMRequest.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/telephony/TelephonyCallback.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITelephonyService.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace telephony {
|
||||
|
||||
class TelephonyDialCallback MOZ_FINAL : public TelephonyCallback,
|
||||
public nsITelephonyDialCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSITELEPHONYDIALCALLBACK
|
||||
|
||||
TelephonyDialCallback(nsPIDOMWindow* aWindow, Telephony* aTelephony,
|
||||
Promise* aPromise, uint32_t aServiceId);
|
||||
|
||||
NS_FORWARD_NSITELEPHONYCALLBACK(TelephonyCallback::)
|
||||
|
||||
nsresult
|
||||
NotifyDialMMISuccess(const nsAString& aStatusMessage);
|
||||
|
||||
template<typename T>
|
||||
nsresult
|
||||
NotifyDialMMISuccess(const nsAString& aStatusMessage, const T& aInfo)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!NS_WARN_IF(jsapi.Init(mWindow))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JS::Value> info(cx);
|
||||
|
||||
if (!ToJSValue(cx, aInfo, &info)) {
|
||||
JS_ClearPendingException(cx);
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NotifyDialMMISuccess(cx, aStatusMessage, info);
|
||||
}
|
||||
|
||||
private:
|
||||
~TelephonyDialCallback() {}
|
||||
|
||||
nsresult
|
||||
NotifyDialMMISuccess(JSContext* aCx, const nsAString& aStatusMessage,
|
||||
JS::Handle<JS::Value> aInfo);
|
||||
|
||||
nsresult
|
||||
NotifyDialMMISuccess(JSContext* aCx, const MozMMIResult& aResult);
|
||||
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsRefPtr<Telephony> mTelephony;
|
||||
uint32_t mServiceId;
|
||||
|
||||
nsRefPtr<DOMRequest> mMMIRequest;
|
||||
nsString mServiceCode;
|
||||
};
|
||||
|
||||
} // namespace telephony
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_TelephonyDialCallback_h
|
@ -1,96 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "mozilla/dom/USSDSession.h"
|
||||
|
||||
#include "mozilla/dom/USSDSessionBinding.h"
|
||||
#include "mozilla/dom/telephony/TelephonyCallback.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::telephony;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(USSDSession, mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(USSDSession)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(USSDSession)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(USSDSession)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
USSDSession::USSDSession(nsPIDOMWindow* aWindow, nsITelephonyService* aService,
|
||||
uint32_t aServiceId)
|
||||
: mWindow(aWindow), mService(aService), mServiceId(aServiceId)
|
||||
{
|
||||
}
|
||||
|
||||
USSDSession::~USSDSession()
|
||||
{
|
||||
}
|
||||
|
||||
nsPIDOMWindow*
|
||||
USSDSession::GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
USSDSession::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return USSDSessionBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
// WebIDL
|
||||
|
||||
already_AddRefed<USSDSession>
|
||||
USSDSession::Constructor(const GlobalObject& aGlobal, uint32_t aServiceId,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITelephonyService> ril =
|
||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
||||
if (!ril) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<USSDSession> session = new USSDSession(window, ril, aServiceId);
|
||||
return session.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
USSDSession::Send(const nsAString& aUssd, ErrorResult& aRv)
|
||||
{
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
|
||||
|
||||
nsresult rv = mService->SendUSSD(mServiceId, aUssd, callback);
|
||||
if (NS_FAILED(rv)) {
|
||||
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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_USSDSession_h
|
||||
#define mozilla_dom_USSDSession_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsITelephonyService.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class USSDSession MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(USSDSession)
|
||||
|
||||
USSDSession(nsPIDOMWindow* aWindow, nsITelephonyService* aService,
|
||||
uint32_t aServiceId);
|
||||
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const;
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
static already_AddRefed<USSDSession>
|
||||
Constructor(const GlobalObject& aGlobal, uint32_t aServiceId,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Send(const nsAString& aUssd, ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
~USSDSession();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsCOMPtr<nsITelephonyService> mService;
|
||||
uint32_t mServiceId;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_USSDSession_h
|
@ -564,7 +564,7 @@ TelephonyService.prototype = {
|
||||
// Note: isPlainPhoneNumber also accepts USSD and SS numbers
|
||||
if (!gPhoneNumberUtils.isPlainPhoneNumber(aNumber)) {
|
||||
if (DEBUG) debug("Error: Number '" + aNumber + "' is not viable. Drop.");
|
||||
aCallback.notifyError(DIAL_ERROR_BAD_NUMBER);
|
||||
aCallback.notifyDialError(DIAL_ERROR_BAD_NUMBER);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -581,11 +581,11 @@ TelephonyService.prototype = {
|
||||
} else {
|
||||
// Reject MMI code from dialEmergency api.
|
||||
if (aIsDialEmergency) {
|
||||
aCallback.notifyError(DIAL_ERROR_BAD_NUMBER);
|
||||
aCallback.notifyDialError(DIAL_ERROR_BAD_NUMBER);
|
||||
return;
|
||||
}
|
||||
|
||||
this._dialMMI(aClientId, mmi, aCallback, true);
|
||||
this._dialMMI(aClientId, mmi, aCallback);
|
||||
}
|
||||
},
|
||||
|
||||
@ -597,14 +597,14 @@ TelephonyService.prototype = {
|
||||
_dialCall: function(aClientId, aOptions, aCallback) {
|
||||
if (this._isDialing) {
|
||||
if (DEBUG) debug("Error: Already has a dialing call.");
|
||||
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
aCallback.notifyDialError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
// We can only have at most two calls on the same line (client).
|
||||
if (this._numCallsOnLine(aClientId) >= 2) {
|
||||
if (DEBUG) debug("Error: Already has more than 2 calls on line.");
|
||||
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
aCallback.notifyDialError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -612,7 +612,7 @@ TelephonyService.prototype = {
|
||||
// any new call on other SIM.
|
||||
if (this._hasCallsOnOtherClient(aClientId)) {
|
||||
if (DEBUG) debug("Error: Already has a call on other sim.");
|
||||
aCallback.notifyError(DIAL_ERROR_OTHER_CONNECTION_IN_USE);
|
||||
aCallback.notifyDialError(DIAL_ERROR_OTHER_CONNECTION_IN_USE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ TelephonyService.prototype = {
|
||||
aClientId = gRadioInterfaceLayer.getClientIdForEmergencyCall() ;
|
||||
if (aClientId === -1) {
|
||||
if (DEBUG) debug("Error: No client is avaialble for emergency call.");
|
||||
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
aCallback.notifyDialError(DIAL_ERROR_INVALID_STATE_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -655,7 +655,7 @@ TelephonyService.prototype = {
|
||||
this._isDialing = false;
|
||||
|
||||
if (!response.success) {
|
||||
aCallback.notifyError(response.errorMsg);
|
||||
aCallback.notifyDialError(response.errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -673,24 +673,16 @@ TelephonyService.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param aClientId
|
||||
* Client id.
|
||||
* @param aMmi
|
||||
* Parsed MMI structure.
|
||||
* @param aCallback
|
||||
* A nsITelephonyDialCallback object.
|
||||
* @param aStartNewSession
|
||||
* True to start a new session for ussd request.
|
||||
*/
|
||||
_dialMMI: function(aClientId, aMmi, aCallback, aStartNewSession) {
|
||||
_dialMMI: function(aClientId, aMmi, aCallback) {
|
||||
let mmiServiceCode = aMmi ?
|
||||
this._serviceCodeToKeyString(aMmi.serviceCode) : RIL.MMI_KS_SC_USSD;
|
||||
|
||||
aCallback.notifyDialMMI(mmiServiceCode);
|
||||
|
||||
this._sendToRilWorker(aClientId, "sendMMI",
|
||||
{ mmi: aMmi,
|
||||
startNewSession: aStartNewSession }, response => {
|
||||
this._sendToRilWorker(aClientId, "sendMMI", { mmi: aMmi }, response => {
|
||||
if (DEBUG) debug("MMI response: " + JSON.stringify(response));
|
||||
|
||||
if (!response.success) {
|
||||
@ -1056,18 +1048,6 @@ TelephonyService.prototype = {
|
||||
this._sendToRilWorker(aClientId, "resumeConference");
|
||||
},
|
||||
|
||||
sendUSSD: function(aClientId, aUssd, aCallback) {
|
||||
this._sendToRilWorker(aClientId, "sendUSSD",
|
||||
{ ussd: aUssd, checkSession: true },
|
||||
response => {
|
||||
if (!response.success) {
|
||||
aCallback.notifyError(response.errorMsg);
|
||||
} else {
|
||||
aCallback.notifySuccess();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
get microphoneMuted() {
|
||||
return gAudioManager.microphoneMuted;
|
||||
},
|
||||
@ -1286,27 +1266,9 @@ TelephonyService.prototype = {
|
||||
this._notifyAllListeners("conferenceCallStateChanged", [aState]);
|
||||
},
|
||||
|
||||
notifyUssdReceived: function(aClientId, aMessage, aSessionEnded) {
|
||||
if (DEBUG) {
|
||||
debug("notifyUssdReceived for " + aClientId + ": " +
|
||||
aMessage + " (sessionEnded : " + aSessionEnded + ")");
|
||||
}
|
||||
|
||||
let info = {
|
||||
serviceId: aClientId,
|
||||
message: aMessage,
|
||||
sessionEnded: aSessionEnded
|
||||
};
|
||||
|
||||
gSystemMessenger.broadcastMessage("ussd-received", info);
|
||||
|
||||
gGonkMobileConnectionService.notifyUssdReceived(aClientId, aMessage,
|
||||
aSessionEnded);
|
||||
},
|
||||
|
||||
dialMMI: function(aClientId, aMmiString, aCallback) {
|
||||
let mmi = this._parseMMI(aMmiString, this._hasCalls(aClientId));
|
||||
this._dialMMI(aClientId, mmi, aCallback, false);
|
||||
this._dialMMI(aClientId, mmi, aCallback);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1333,38 +1295,4 @@ TelephonyService.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This implements nsISystemMessagesWrapper.wrapMessage(), which provides a
|
||||
* plugable way to wrap a "ussd-received" type system message.
|
||||
*
|
||||
* Please see SystemMessageManager.js to know how it customizes the wrapper.
|
||||
*/
|
||||
function USSDReceivedWrapper() {
|
||||
if (DEBUG) debug("USSDReceivedWrapper()");
|
||||
}
|
||||
USSDReceivedWrapper.prototype = {
|
||||
// nsISystemMessagesWrapper implementation.
|
||||
wrapMessage: function(aMessage, aWindow) {
|
||||
if (DEBUG) debug("wrapMessage: " + JSON.stringify(aMessage));
|
||||
|
||||
let session = aMessage.sessionEnded ? null :
|
||||
new aWindow.USSDSession(aMessage.serviceId);
|
||||
|
||||
let event = new aWindow.USSDReceivedEvent("ussdreceived", {
|
||||
serviceId: aMessage.serviceId,
|
||||
message: aMessage.message,
|
||||
sessionEnded: aMessage.sessionEnded,
|
||||
session: session
|
||||
});
|
||||
|
||||
return event;
|
||||
},
|
||||
|
||||
classDescription: "USSDReceivedWrapper",
|
||||
classID: Components.ID("{d03684ed-ede4-4210-8206-f4f32772d9f5}"),
|
||||
contractID: "@mozilla.org/dom/system-messages/wrapper/ussd-received;1",
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesWrapper])
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelephonyService,
|
||||
USSDReceivedWrapper]);
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelephonyService]);
|
||||
|
@ -1,5 +1,2 @@
|
||||
component {67d26434-d063-4d28-9f48-5b3189788155} TelephonyService.js
|
||||
contract @mozilla.org/telephony/gonktelephonyservice;1 {67d26434-d063-4d28-9f48-5b3189788155}
|
||||
|
||||
component {d03684ed-ede4-4210-8206-f4f32772d9f5} TelephonyService.js
|
||||
contract @mozilla.org/dom/system-messages/wrapper/ussd-received;1 {d03684ed-ede4-4210-8206-f4f32772d9f5}
|
||||
|
@ -24,17 +24,10 @@ struct DialRequest
|
||||
bool isEmergency;
|
||||
};
|
||||
|
||||
struct USSDRequest
|
||||
{
|
||||
uint32_t clientId;
|
||||
nsString ussd;
|
||||
};
|
||||
|
||||
union IPCTelephonyRequest
|
||||
{
|
||||
EnumerateCallsRequest;
|
||||
DialRequest;
|
||||
USSDRequest;
|
||||
};
|
||||
|
||||
sync protocol PTelephony {
|
||||
|
@ -16,12 +16,7 @@ struct EnumerateCallsResponse
|
||||
// empty.
|
||||
};
|
||||
|
||||
struct SuccessResponse
|
||||
{
|
||||
// empty.
|
||||
};
|
||||
|
||||
struct ErrorResponse
|
||||
struct DialResponseError
|
||||
{
|
||||
nsString name;
|
||||
};
|
||||
@ -47,12 +42,8 @@ struct DialResponseMMIError
|
||||
union IPCTelephonyResponse
|
||||
{
|
||||
EnumerateCallsResponse;
|
||||
|
||||
// General.
|
||||
SuccessResponse;
|
||||
ErrorResponse;
|
||||
|
||||
// dial
|
||||
DialResponseError;
|
||||
DialResponseCallSuccess;
|
||||
DialResponseMMISuccess;
|
||||
DialResponseMMIError;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "TelephonyChild.h"
|
||||
|
||||
#include "mozilla/dom/telephony/TelephonyDialCallback.h"
|
||||
#include "mozilla/dom/telephony/TelephonyCallback.h"
|
||||
#include "TelephonyIPCService.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
@ -147,10 +147,8 @@ TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
|
||||
case IPCTelephonyResponse::TEnumerateCallsResponse:
|
||||
mListener->EnumerateCallStateComplete();
|
||||
break;
|
||||
case IPCTelephonyResponse::TSuccessResponse:
|
||||
return DoResponse(aResponse.get_SuccessResponse());
|
||||
case IPCTelephonyResponse::TErrorResponse:
|
||||
return DoResponse(aResponse.get_ErrorResponse());
|
||||
case IPCTelephonyResponse::TDialResponseError:
|
||||
return DoResponse(aResponse.get_DialResponseError());
|
||||
case IPCTelephonyResponse::TDialResponseCallSuccess:
|
||||
return DoResponse(aResponse.get_DialResponseCallSuccess());
|
||||
case IPCTelephonyResponse::TDialResponseMMISuccess:
|
||||
@ -189,24 +187,16 @@ bool
|
||||
TelephonyRequestChild::RecvNotifyDialMMI(const nsString& aServiceCode)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
||||
callback->NotifyDialMMI(aServiceCode);
|
||||
|
||||
mCallback->NotifyDialMMI(aServiceCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestChild::DoResponse(const SuccessResponse& aResponse)
|
||||
TelephonyRequestChild::DoResponse(const DialResponseError& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
mCallback->NotifySuccess();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestChild::DoResponse(const ErrorResponse& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
mCallback->NotifyError(aResponse.name());
|
||||
mCallback->NotifyDialError(aResponse.name());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -214,8 +204,7 @@ bool
|
||||
TelephonyRequestChild::DoResponse(const DialResponseCallSuccess& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
||||
callback->NotifyDialCallSuccess(aResponse.callIndex(), aResponse.number());
|
||||
mCallback->NotifyDialCallSuccess(aResponse.callIndex(), aResponse.number());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -226,8 +215,7 @@ TelephonyRequestChild::DoResponse(const DialResponseMMISuccess& aResponse)
|
||||
|
||||
// FIXME: Need to overload NotifyDialMMISuccess in the IDL. mCallback is not
|
||||
// necessarily an instance of TelephonyCallback.
|
||||
nsCOMPtr<nsITelephonyDialCallback> dialCallback = do_QueryInterface(mCallback);
|
||||
nsRefPtr<TelephonyDialCallback> callback = static_cast<TelephonyDialCallback*>(dialCallback.get());
|
||||
nsRefPtr<TelephonyCallback> callback = static_cast<TelephonyCallback*>(mCallback.get());
|
||||
|
||||
nsAutoString statusMessage(aResponse.statusMessage());
|
||||
AdditionalInformation info(aResponse.additionalInformation());
|
||||
@ -254,17 +242,16 @@ bool
|
||||
TelephonyRequestChild::DoResponse(const DialResponseMMIError& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
||||
|
||||
nsAutoString name(aResponse.name());
|
||||
AdditionalInformation info(aResponse.additionalInformation());
|
||||
|
||||
switch (info.type()) {
|
||||
case AdditionalInformation::Tvoid_t:
|
||||
callback->NotifyDialMMIError(name);
|
||||
mCallback->NotifyDialMMIError(name);
|
||||
break;
|
||||
case AdditionalInformation::Tuint16_t:
|
||||
callback->NotifyDialMMIErrorWithInfo(name, info.get_uint16_t());
|
||||
mCallback->NotifyDialMMIErrorWithInfo(name, info.get_uint16_t());
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Received invalid type!");
|
||||
|
@ -84,10 +84,7 @@ protected:
|
||||
|
||||
private:
|
||||
bool
|
||||
DoResponse(const SuccessResponse& aResponse);
|
||||
|
||||
bool
|
||||
DoResponse(const ErrorResponse& aResponse);
|
||||
DoResponse(const DialResponseError& aResponse);
|
||||
|
||||
bool
|
||||
DoResponse(const DialResponseCallSuccess& aResponse);
|
||||
|
@ -162,8 +162,7 @@ TelephonyIPCService::EnumerateCalls(nsITelephonyListener *aListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCService::Dial(uint32_t aClientId, const nsAString& aNumber,
|
||||
bool aIsEmergency,
|
||||
nsITelephonyDialCallback *aCallback)
|
||||
bool aIsEmergency, nsITelephonyCallback *aCallback)
|
||||
{
|
||||
return SendRequest(nullptr, aCallback,
|
||||
DialRequest(aClientId, nsString(aNumber), aIsEmergency));
|
||||
@ -301,14 +300,6 @@ TelephonyIPCService::StopTone(uint32_t aClientId)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCService::SendUSSD(uint32_t aClientId, const nsAString& aUssd,
|
||||
nsITelephonyCallback *aCallback)
|
||||
{
|
||||
return SendRequest(nullptr, aCallback,
|
||||
USSDRequest(aClientId, nsString(aUssd)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCService::GetMicrophoneMuted(bool* aMuted)
|
||||
{
|
||||
|
@ -43,8 +43,6 @@ TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActo
|
||||
return actor->DoRequest(aRequest.get_EnumerateCallsRequest());
|
||||
case IPCTelephonyRequest::TDialRequest:
|
||||
return actor->DoRequest(aRequest.get_DialRequest());
|
||||
case IPCTelephonyRequest::TUSSDRequest:
|
||||
return actor->DoRequest(aRequest.get_USSDRequest());
|
||||
default:
|
||||
MOZ_CRASH("Unknown type!");
|
||||
}
|
||||
@ -387,8 +385,7 @@ TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
|
||||
NS_IMPL_ISUPPORTS(TelephonyRequestParent,
|
||||
nsITelephonyListener,
|
||||
nsITelephonyCallback,
|
||||
nsITelephonyDialCallback)
|
||||
nsITelephonyCallback)
|
||||
|
||||
TelephonyRequestParent::TelephonyRequestParent()
|
||||
: mActorDestroyed(false)
|
||||
@ -429,23 +426,9 @@ TelephonyRequestParent::DoRequest(const DialRequest& aRequest)
|
||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
||||
if (service) {
|
||||
service->Dial(aRequest.clientId(), aRequest.number(),
|
||||
aRequest.isEmergency(), this);
|
||||
aRequest.isEmergency(), this);
|
||||
} else {
|
||||
return NS_SUCCEEDED(NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestParent::DoRequest(const USSDRequest& aRequest)
|
||||
{
|
||||
nsCOMPtr<nsITelephonyService> service =
|
||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
||||
if (service) {
|
||||
service->SendUSSD(aRequest.clientId(), aRequest.ussd(), this);
|
||||
} else {
|
||||
return NS_SUCCEEDED(NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
||||
return NS_SUCCEEDED(NotifyDialError(NS_LITERAL_STRING("InvalidStateError")));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -549,7 +532,7 @@ TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
MOZ_CRASH("Not a TelephonyParent!");
|
||||
}
|
||||
|
||||
// nsITelephonyDialCallback
|
||||
// nsITelephonyCallback
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
@ -560,15 +543,9 @@ TelephonyRequestParent::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifySuccess()
|
||||
TelephonyRequestParent::NotifyDialError(const nsAString& aError)
|
||||
{
|
||||
return SendResponse(SuccessResponse());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyError(const nsAString& aError)
|
||||
{
|
||||
return SendResponse(ErrorResponse(nsAutoString(aError)));
|
||||
return SendResponse(DialResponseError(nsAutoString(aError)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
|
||||
class TelephonyRequestParent : public PTelephonyRequestParent
|
||||
, public nsITelephonyListener
|
||||
, public nsITelephonyDialCallback
|
||||
, public nsITelephonyCallback
|
||||
{
|
||||
friend class TelephonyParent;
|
||||
|
||||
@ -106,7 +106,6 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYLISTENER
|
||||
NS_DECL_NSITELEPHONYCALLBACK
|
||||
NS_DECL_NSITELEPHONYDIALCALLBACK
|
||||
|
||||
protected:
|
||||
TelephonyRequestParent();
|
||||
@ -126,9 +125,6 @@ private:
|
||||
|
||||
bool
|
||||
DoRequest(const DialRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const USSDRequest& aRequest);
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
@ -16,7 +16,6 @@ EXPORTS.mozilla.dom += [
|
||||
'TelephonyCall.h',
|
||||
'TelephonyCallGroup.h',
|
||||
'TelephonyCallId.h',
|
||||
'USSDSession.h'
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom.telephony += [
|
||||
@ -24,7 +23,6 @@ EXPORTS.mozilla.dom.telephony += [
|
||||
'ipc/TelephonyParent.h',
|
||||
'TelephonyCallback.h',
|
||||
'TelephonyCommon.h',
|
||||
'TelephonyDialCallback.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
@ -37,8 +35,6 @@ UNIFIED_SOURCES += [
|
||||
'TelephonyCallback.cpp',
|
||||
'TelephonyCallGroup.cpp',
|
||||
'TelephonyCallId.cpp',
|
||||
'TelephonyDialCallback.cpp',
|
||||
'USSDSession.cpp',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
|
@ -10,7 +10,7 @@
|
||||
"@mozilla.org/telephony/gonktelephonyservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(79eec3c3-2dfc-4bbf-b106-af5457651ae0)]
|
||||
[scriptable, uuid(8790e2cc-2c68-4ce9-90dc-f68e1b6e4886)]
|
||||
interface nsIGonkTelephonyService : nsITelephonyService
|
||||
{
|
||||
void notifyCallDisconnected(in unsigned long clientId, in jsval call);
|
||||
@ -27,9 +27,6 @@ interface nsIGonkTelephonyService : nsITelephonyService
|
||||
|
||||
void notifyConferenceCallStateChanged(in short state);
|
||||
|
||||
void notifyUssdReceived(in unsigned long clientId, in DOMString message,
|
||||
in boolean sessionEnded);
|
||||
|
||||
void dialMMI(in unsigned long clientId, in AString mmiString,
|
||||
in nsITelephonyDialCallback callback);
|
||||
in nsITelephonyCallback callback);
|
||||
};
|
||||
|
@ -177,20 +177,10 @@ interface nsITelephonyListener : nsISupports
|
||||
};
|
||||
|
||||
/**
|
||||
* A callback interface for handling asynchronous response.
|
||||
* A callback interface for handling asynchronous response of Telephony.dial().
|
||||
*/
|
||||
[scriptable, uuid(cffc3f9d-2c88-4a14-8ebc-f216caf0cc1d)]
|
||||
[scriptable, uuid(67533db3-cd38-475c-a774-8d0bbf9169fb)]
|
||||
interface nsITelephonyCallback : nsISupports
|
||||
{
|
||||
void notifySuccess();
|
||||
void notifyError(in AString error);
|
||||
};
|
||||
|
||||
/**
|
||||
* A callback interface for handling asynchronous response for telephony.dial.
|
||||
*/
|
||||
[scriptable, uuid(4481212f-72e9-4aef-97e1-5397af782113)]
|
||||
interface nsITelephonyDialCallback : nsITelephonyCallback
|
||||
{
|
||||
/**
|
||||
* Called when a dial request is treated as an MMI code and it is about to
|
||||
@ -201,6 +191,14 @@ interface nsITelephonyDialCallback : nsITelephonyCallback
|
||||
*/
|
||||
void notifyDialMMI(in AString serviceCode);
|
||||
|
||||
/**
|
||||
* Called when a dial request fails.
|
||||
*
|
||||
* @param error
|
||||
* Error from RIL.
|
||||
*/
|
||||
void notifyDialError(in AString error);
|
||||
|
||||
/**
|
||||
* Called when a dial request is treated as a call setup and the result
|
||||
* succeeds.
|
||||
@ -240,7 +238,7 @@ interface nsITelephonyDialCallback : nsITelephonyCallback
|
||||
* XPCOM component (in the content process) that provides the telephony
|
||||
* information.
|
||||
*/
|
||||
[scriptable, uuid(79188caa-046a-48e1-b9c5-2e891504dc7a)]
|
||||
[scriptable, uuid(4ff3ecb7-b024-4752-9dd6-c3623c6e6b8a)]
|
||||
interface nsITelephonyService : nsISupports
|
||||
{
|
||||
const unsigned short CALL_STATE_UNKNOWN = 0;
|
||||
@ -283,7 +281,7 @@ interface nsITelephonyService : nsISupports
|
||||
* Functionality for making and managing phone calls.
|
||||
*/
|
||||
void dial(in unsigned long clientId, in DOMString number,
|
||||
in boolean isEmergency, in nsITelephonyDialCallback callback);
|
||||
in boolean isEmergency, in nsITelephonyCallback callback);
|
||||
void hangUp(in unsigned long clientId, in unsigned long callIndex);
|
||||
|
||||
void startTone(in unsigned long clientId, in DOMString dtmfChar);
|
||||
@ -299,16 +297,6 @@ interface nsITelephonyService : nsISupports
|
||||
void holdConference(in unsigned long clientId);
|
||||
void resumeConference(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* Send an USSD on existing session. It results in error if the session is
|
||||
* not existed.
|
||||
*
|
||||
* If successful, callback.notifySuccess() will be called.
|
||||
* Otherwise, callback.notifyError() will be called.
|
||||
*/
|
||||
void sendUSSD(in unsigned long clientId, in DOMString ussd,
|
||||
in nsITelephonyCallback callback);
|
||||
|
||||
attribute bool microphoneMuted;
|
||||
attribute bool speakerEnabled;
|
||||
};
|
||||
|
@ -4,22 +4,16 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.telephony.enabled",
|
||||
CheckPermissions="telephony mobileconnection",
|
||||
AvailableIn="CertifiedApps",
|
||||
[Pref="dom.mobileconnection.enabled",
|
||||
Constructor(DOMString type, optional USSDReceivedEventInit eventInitDict)]
|
||||
interface USSDReceivedEvent : Event
|
||||
{
|
||||
readonly attribute unsigned long serviceId;
|
||||
readonly attribute DOMString? message;
|
||||
readonly attribute USSDSession? session; // null if session is ended.
|
||||
readonly attribute boolean sessionEnded; // deprecated. Bug 1070831
|
||||
readonly attribute boolean sessionEnded;
|
||||
};
|
||||
|
||||
dictionary USSDReceivedEventInit : EventInit
|
||||
{
|
||||
unsigned long serviceId = 0;
|
||||
DOMString? message = null;
|
||||
USSDSession? session = null;
|
||||
boolean sessionEnded = false;
|
||||
};
|
||||
|
@ -1,14 +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.telephony.enabled",
|
||||
CheckPermissions="telephony",
|
||||
AvailableIn="CertifiedApps",
|
||||
Constructor(unsigned long serviceId)]
|
||||
interface USSDSession {
|
||||
[Throws]
|
||||
Promise<void> send(DOMString ussd);
|
||||
};
|
@ -501,7 +501,6 @@ WEBIDL_FILES = [
|
||||
'URLSearchParams.webidl',
|
||||
'URLUtils.webidl',
|
||||
'URLUtilsReadOnly.webidl',
|
||||
'USSDSession.webidl',
|
||||
'ValidityState.webidl',
|
||||
'VideoPlaybackQuality.webidl',
|
||||
'VideoStreamTrack.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user