Bug 853715 - 0005. Handle incoming Wap Push messages. r=vicamo
authorChuck Lee <chulee@mozilla.com>
Tue, 04 Jun 2013 18:51:02 +0800
changeset 145968 434ede79f88f324b06445cf7764b5490ba2aa08f
parent 145967 aba5a6ca7427d3207d30d4c4eba3460463beb262
child 145969 a84316d835363d1cd4b164c3bca3ecc422219d5b
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs853715
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 853715 - 0005. Handle incoming Wap Push messages. r=vicamo
dom/mobilemessage/src/Makefile.in
dom/mobilemessage/src/ril/WapPushManager.js
dom/mobilemessage/src/ril/WspPduHelper.jsm
dom/wappush/src/Makefile.in
dom/wappush/src/gonk/WapPushManager.js
--- a/dom/mobilemessage/src/Makefile.in
+++ b/dom/mobilemessage/src/Makefile.in
@@ -49,16 +49,15 @@ EXTRA_COMPONENTS = \
   ril/MobileMessageDatabaseService.js \
   ril/MobileMessageDatabaseService.manifest \
   $(NULL)
 
 EXTRA_JS_MODULES = \
   ril/mms_consts.js \
   ril/MmsPduHelper.jsm \
   ril/wap_consts.js \
-  ril/WapPushManager.js \
   ril/WspPduHelper.jsm \
   $(NULL)
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
--- a/dom/mobilemessage/src/ril/WspPduHelper.jsm
+++ b/dom/mobilemessage/src/ril/WspPduHelper.jsm
@@ -862,18 +862,18 @@ this.UintVar = {
     }
     Octet.encode(data, value);
   },
 };
 
 /**
  * This encoding is used for token values, which have no well-known binary
  * encoding, or when the assigned number of the well-known encoding is small
- * enough to fit into Short-Integer. We change Extension-Media from 
- * NullTerminatedTexts to TextString because of Bug 823816. 
+ * enough to fit into Short-Integer. We change Extension-Media from
+ * NullTerminatedTexts to TextString because of Bug 823816.
  *
  *   Constrained-encoding = Extension-Media | Short-integer
  *   Extension-Media = TextString
  *
  * @see WAP-230-WSP-20010705-a clause 8.4.2.1
  * @see https://bugzilla.mozilla.org/show_bug.cgi?id=823816
  */
 this.ConstrainedEncoding = {
@@ -2792,16 +2792,17 @@ this.OMNA_PUSH_APPLICATION_IDS = (functi
     let entry = {
       urn: urn,
       number: number,
     };
 
     ids[urn] = ids[number] = entry;
   }
 
+  add("x-wap-application:wml.ua", 0x02);
   add("x-wap-application:mms.ua", 0x04);
 
   return ids;
 })();
 
 let debug;
 if (DEBUG) {
   debug = function (s) {
--- a/dom/wappush/src/Makefile.in
+++ b/dom/wappush/src/Makefile.in
@@ -14,13 +14,14 @@ include $(DEPTH)/config/autoconf.mk
 ifdef MOZ_B2G_RIL
 EXTRA_COMPONENTS = \
   $(NULL)
 
 EXTRA_JS_MODULES = \
   gonk/WbxmlPduHelper.jsm \
   gonk/SiPduHelper.jsm \
   gonk/SlPduHelper.jsm \
+  gonk/WapPushManager.js \
   $(NULL)
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/config/rules.mk
rename from dom/mobilemessage/src/ril/WapPushManager.js
rename to dom/wappush/src/gonk/WapPushManager.js
--- a/dom/mobilemessage/src/ril/WapPushManager.js
+++ b/dom/wappush/src/gonk/WapPushManager.js
@@ -9,16 +9,31 @@ const {classes: Cc, interfaces: Ci, util
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 Cu.import("resource://gre/modules/WspPduHelper.jsm", this);
 
 const DEBUG = false; // set to true to see debug messages
 
 /**
+ * WAP Push decoders
+ */
+XPCOMUtils.defineLazyGetter(this, "SI", function () {
+  let SI = {};
+  Cu.import("resource://gre/modules/SiPduHelper.jsm", SI);
+  return SI;
+});
+
+XPCOMUtils.defineLazyGetter(this, "SL", function () {
+  let SL = {};
+  Cu.import("resource://gre/modules/SlPduHelper.jsm", SL);
+  return SL;
+});
+
+/**
  * Helpers for WAP PDU processing.
  */
 this.WapPushManager = {
 
   /**
    * Parse raw PDU data and deliver to a proper target.
    *
    * @param data
@@ -36,24 +51,57 @@ this.WapPushManager = {
     }
 
     let appid = options.headers["x-wap-application-id"];
     if (!appid) {
       debug("Push message doesn't contains X-Wap-Application-Id.");
       return;
     }
 
+    // MMS
     if (appid == "x-wap-application:mms.ua") {
       let mmsService = Cc["@mozilla.org/mms/rilmmsservice;1"]
                        .getService(Ci.nsIMmsService);
       mmsService.QueryInterface(Ci.nsIWapPushApplication)
                 .receiveWapPush(data.array, data.array.length, data.offset, options);
+      return;
+    }
+
+    /**
+    * Non-MMS, handled according to content type
+    *
+    * WAP Type            content-type                              x-wap-application-id
+    * MMS                 "application/vnd.wap.mms-message"         "x-wap-application:mms.ua"
+    * SI                  "text/vnd.wap.si"                         "x-wap-application:wml.ua"
+    * SI(WBXML)           "application/vnd.wap.sic"                 "x-wap-application:wml.ua"
+    * SL                  "text/vnd.wap.sl"                         "x-wap-application:wml.ua"
+    * SL(WBXML)           "application/vnd.wap.slc"                 "x-wap-application:wml.ua"
+    * Provisioning        "text/vnd.wap.connectivity-xml"           "x-wap-application:wml.ua"
+    * Provisioning(WBXML) "application/vnd.wap.connectivity-wbxml"  "x-wap-application:wml.ua"
+    *
+    * @see http://technical.openmobilealliance.org/tech/omna/omna-wsp-content-type.aspx
+    */
+    let contentType = options.headers["content-type"].media;
+    let msg = { contentType: contentType };
+
+    if (contentType === "text/vnd.wap.si" ||
+        contentType === "application/vnd.wap.sic") {
+      SI.PduHelper.parse(data, contentType, msg);
+    } else if (contentType === "text/vnd.wap.sl" ||
+               contentType === "application/vnd.wap.slc") {
+      SL.PduHelper.parse(data, contentType, msg);
+    } else if (contentType === "text/vnd.wap.connectivity-xml" ||
+               contentType === "application/vnd.wap.connectivity-wbxml") {
+      // TODO: Bug 869291 - Support Receiving WAP-Push-CP
     } else {
-      debug("No WAP Push application registered for " + appid);
+      // Unsupported type, provide raw data.
+      msg.content = data.array;
     }
+
+    // TODO: Bug 853782 - Notify receiving of WAP Push messages
   },
 
   /**
    * @param array
    *        A Uint8Array or an octet array representing raw PDU data.
    * @param length
    *        Length of the array.
    * @param offset