From 3f59d15b2aad30860185f2c675f3617bb9b891d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez?= Date: Fri, 5 Oct 2012 16:08:55 +0200 Subject: [PATCH] Bug 793186 - MMI Codes: implement sendMMI() and cancelMMI() - Part 1: Rename USSD-MMI; r=philikon --- .../interfaces/nsIDOMMobileConnection.idl | 26 +++++++--- .../nsIMobileConnectionProvider.idl | 4 +- dom/network/src/MobileConnection.cpp | 10 ++-- dom/system/gonk/RILContentHelper.js | 32 ++++++------ dom/system/gonk/RadioInterfaceLayer.js | 51 ++++++++++--------- dom/system/gonk/ril_worker.js | 4 +- 6 files changed, 68 insertions(+), 59 deletions(-) diff --git a/dom/network/interfaces/nsIDOMMobileConnection.idl b/dom/network/interfaces/nsIDOMMobileConnection.idl index 12bd76d6fa0e..8a0e8ef87f31 100644 --- a/dom/network/interfaces/nsIDOMMobileConnection.idl +++ b/dom/network/interfaces/nsIDOMMobileConnection.idl @@ -12,7 +12,7 @@ interface nsIDOMMozMobileNetworkInfo; interface nsIDOMMozMobileCellInfo; interface nsIDOMMozIccManager; -[scriptable, builtinclass, uuid(c07309ee-a424-11e1-a75c-00265511db39)] +[scriptable, builtinclass, uuid(f7bddd87-e967-4f97-9481-2042beb86a92)] interface nsIDOMMozMobileConnection : nsIDOMEventTarget { /** @@ -201,19 +201,29 @@ interface nsIDOMMozMobileConnection : nsIDOMEventTarget nsIDOMDOMRequest setCardLock(in jsval info); /** - * Send a USSD message. + * Send a MMI message. * - * The network reply will be reported via onussdreceived event. + * @param mmi + * DOMString containing an MMI string that can be associated to a + * USSD request or other RIL functionality. * - * The 'success' event for the request means the USSD message has been sent - * successfully. + * @return a nsIDOMDOMRequest + * The request's result will be an object containing information + * about the operation. + * + * In case that the MMI code requires sending an USSD request, the DOMrequest + * 'success' event means that the RIL has successfully processed and sent the + * USSD request to the network. The network reply will be reported via + * 'onussdreceived' event. If the MMI code is not associated to a USSD but to + * other RIL request its result, if one is needed, will be notified via the + * returned DOMRequest 'success' or 'error' event. */ - nsIDOMDOMRequest sendUSSD(in DOMString ussd); + nsIDOMDOMRequest sendMMI(in DOMString mmi); /** - * Cancel the current USSD session if one exists. + * Cancel the current MMI request if one exists. */ - nsIDOMDOMRequest cancelUSSD(); + nsIDOMDOMRequest cancelMMI(); /** * The 'cardstatechange' event is notified when the 'cardState' attribute diff --git a/dom/network/interfaces/nsIMobileConnectionProvider.idl b/dom/network/interfaces/nsIMobileConnectionProvider.idl index 67f92e1578f2..4d16e5d65375 100644 --- a/dom/network/interfaces/nsIMobileConnectionProvider.idl +++ b/dom/network/interfaces/nsIMobileConnectionProvider.idl @@ -31,8 +31,8 @@ interface nsIMobileConnectionProvider : nsISupports nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info); nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info); - nsIDOMDOMRequest sendUSSD(in nsIDOMWindow window, in DOMString ussd); - nsIDOMDOMRequest cancelUSSD(in nsIDOMWindow window); + nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi); + nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window); void sendStkResponse(in nsIDOMWindow window, in jsval command, diff --git a/dom/network/src/MobileConnection.cpp b/dom/network/src/MobileConnection.cpp index c7f5b1dc6e90..8a05839a90a8 100644 --- a/dom/network/src/MobileConnection.cpp +++ b/dom/network/src/MobileConnection.cpp @@ -304,24 +304,24 @@ MobileConnection::SetCardLock(const jsval& aInfo, nsIDOMDOMRequest** aDomRequest } NS_IMETHODIMP -MobileConnection::SendUSSD(const nsAString& aUSSDString, - nsIDOMDOMRequest** request) +MobileConnection::SendMMI(const nsAString& aMMIString, + nsIDOMDOMRequest** request) { if (!mProvider) { return NS_ERROR_FAILURE; } - return mProvider->SendUSSD(GetOwner(), aUSSDString, request); + return mProvider->SendMMI(GetOwner(), aMMIString, request); } NS_IMETHODIMP -MobileConnection::CancelUSSD(nsIDOMDOMRequest** request) +MobileConnection::CancelMMI(nsIDOMDOMRequest** request) { if (!mProvider) { return NS_ERROR_FAILURE; } - return mProvider->CancelUSSD(GetOwner(), request); + return mProvider->CancelMMI(GetOwner(), request); } } // namespace network diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 1f73c31084fe..0f0a3e748d17 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -55,11 +55,11 @@ const RIL_IPC_MSG_NAMES = [ "RIL:VoicemailNumberChanged", "RIL:CallError", "RIL:CardLockResult", - "RIL:UssdReceived", - "RIL:SendUssd:Return:OK", - "RIL:SendUssd:Return:KO", - "RIL:CancelUssd:Return:OK", - "RIL:CancelUssd:Return:KO", + "RIL:USSDReceived", + "RIL:SendMMI:Return:OK", + "RIL:SendMMI:Return:KO", + "RIL:CancelMMI:Return:OK", + "RIL:CancelMMI:Return:KO", "RIL:StkCommand", "RIL:StkSessionEnd", "RIL:DataError" @@ -409,27 +409,27 @@ RILContentHelper.prototype = { return request; }, - sendUSSD: function sendUSSD(window, ussd) { - debug("Sending USSD " + ussd); + sendMMI: function sendMMI(window, mmi) { + debug("Sending MMI " + mmi); if (!window) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_EXPECTED); } let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - cpmm.sendAsyncMessage("RIL:SendUSSD", {ussd: ussd, requestId: requestId}); + cpmm.sendAsyncMessage("RIL:SendMMI", {mmi: mmi, requestId: requestId}); return request; }, - cancelUSSD: function cancelUSSD(window) { - debug("Cancel USSD"); + cancelMMI: function cancelMMI(window) { + debug("Cancel MMI"); if (!window) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - cpmm.sendAsyncMessage("RIL:CancelUSSD", {requestId: requestId}); + cpmm.sendAsyncMessage("RIL:CancelMMI", {requestId: requestId}); return request; }, @@ -701,19 +701,19 @@ RILContentHelper.prototype = { this.fireRequestError(msg.json.requestId, msg.json); } break; - case "RIL:UssdReceived": + case "RIL:USSDReceived": Services.obs.notifyObservers(null, kUssdReceivedTopic, msg.json.message); break; - case "RIL:SendUssd:Return:OK": - case "RIL:CancelUssd:Return:OK": + case "RIL:SendMMI:Return:OK": + case "RIL:CancelMMI:Return:OK": request = this.takeRequest(msg.json.requestId); if (request) { Services.DOMRequest.fireSuccess(request, msg.json); } break; - case "RIL:SendUssd:Return:KO": - case "RIL:CancelUssd:Return:KO": + case "RIL:SendMMI:Return:KO": + case "RIL:CancelMMI:Return:KO": request = this.takeRequest(msg.json.requestId); if (request) { Services.DOMRequest.fireError(request, msg.json.errorMsg); diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index bcffd774cfaa..5219646ac7c9 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -69,8 +69,8 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [ "RIL:GetCardLock", "RIL:UnlockCardLock", "RIL:SetCardLock", - "RIL:SendUSSD", - "RIL:CancelUSSD", + "RIL:SendMMI", + "RIL:CancelMMI", "RIL:SendStkResponse", "RIL:SendStkMenuSelection", "RIL:SendStkEventDownload", @@ -371,13 +371,13 @@ RadioInterfaceLayer.prototype = { this.saveRequestTarget(msg); this.setCardLock(msg.json); break; - case "RIL:SendUSSD": + case "RIL:SendMMI": this.saveRequestTarget(msg); - this.sendUSSD(msg.json); + this.sendMMI(msg.json); break; - case "RIL:CancelUSSD": + case "RIL:CancelMMI": this.saveRequestTarget(msg); - this.cancelUSSD(msg.json); + this.cancelMMI(msg.json); break; case "RIL:SendStkResponse": this.sendStkResponse(msg.json); @@ -507,15 +507,15 @@ RadioInterfaceLayer.prototype = { case "iccmbdn": ppmm.broadcastAsyncMessage("RIL:VoicemailNumberChanged", message); break; - case "ussdreceived": - debug("ussdreceived " + JSON.stringify(message)); + case "USSDReceived": + debug("USSDReceived " + JSON.stringify(message)); this.handleUSSDReceived(message); break; - case "sendussd": - this.handleSendUSSD(message); + case "sendMMI": + this.handleSendMMI(message); break; - case "cancelussd": - this.handleCancelUSSD(message); + case "cancelMMI": + this.handleCancelMMI(message); break; case "stkcommand": this.handleStkProactiveCommand(message); @@ -1290,20 +1290,20 @@ RadioInterfaceLayer.prototype = { handleUSSDReceived: function handleUSSDReceived(ussd) { debug("handleUSSDReceived " + JSON.stringify(ussd)); - ppmm.broadcastAsyncMessage("RIL:UssdReceived", ussd); + ppmm.broadcastAsyncMessage("RIL:USSDReceived", ussd); }, - handleSendUSSD: function handleSendUSSD(message) { - debug("handleSendUSSD " + JSON.stringify(message)); - let messageType = message.success ? "RIL:SendUssd:Return:OK" : - "RIL:SendUssd:Return:KO"; + handleSendMMI: function handleSendMMI(message) { + debug("handleSendMMI " + JSON.stringify(message)); + let messageType = message.success ? "RIL:SendMMI:Return:OK" : + "RIL:SendMMI:Return:KO"; this._sendRequestResults(messageType, message); }, - handleCancelUSSD: function handleCancelUSSD(message) { - debug("handleCancelUSSD " + JSON.stringify(message)); - let messageType = message.success ? "RIL:CancelUssd:Return:OK" : - "RIL:CancelUssd:Return:KO"; + handleCancelMMI: function handleCancelMMI(message) { + debug("handleCancelMMI " + JSON.stringify(message)); + let messageType = message.success ? "RIL:CancelMMI:Return:OK" : + "RIL:CancelMMI:Return:KO"; this._sendRequestResults(messageType, message); }, @@ -1521,14 +1521,15 @@ RadioInterfaceLayer.prototype = { requestId: requestId}); }, - sendUSSD: function sendUSSD(message) { - debug("SendUSSD " + JSON.stringify(message)); + sendMMI: function sendMMI(message) { + debug("SendMMI " + JSON.stringify(message)); + // TODO: process MMI (in the next patch :) ) message.rilMessageType = "sendUSSD"; this.worker.postMessage(message); }, - cancelUSSD: function cancelUSSD(message) { - debug("Cancel pending USSD"); + cancelMMI: function cancelMMI(message) { + debug("Cancel pending MMI"); message.rilMessageType = "cancelUSSD"; this.worker.postMessage(message); }, diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index b14d8af6f0ec..3fd05438760e 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -4195,7 +4195,6 @@ RIL[REQUEST_SEND_USSD] = function REQUEST_SEND_USSD(length, options) { if (DEBUG) { debug("REQUEST_SEND_USSD " + JSON.stringify(options)); } - options.rilMessageType = "sendussd"; options.success = options.rilRequestError == 0 ? true : false; options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; this.sendDOMMessage(options); @@ -4204,7 +4203,6 @@ RIL[REQUEST_CANCEL_USSD] = function REQUEST_CANCEL_USSD(length, options) { if (DEBUG) { debug("REQUEST_CANCEL_USSD" + JSON.stringify(options)); } - options.rilMessageType = "cancelussd"; options.success = options.rilRequestError == 0 ? true : false; options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; this.sendDOMMessage(options); @@ -4631,7 +4629,7 @@ RIL[UNSOLICITED_ON_USSD] = function UNSOLICITED_ON_USSD() { if (!message || message == "") { return; } - this.sendDOMMessage({rilMessageType: "ussdreceived", + this.sendDOMMessage({rilMessageType: "USSDReceived", message: message}); }; RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED() {