Bug 885685 - B2G MMS: Use nsIURI Object in applyFilter for MmsProxyFilter. r=vyang,gene a=leo+
authorChia-hung Tai <ctai@mozilla.com>
Tue, 25 Jun 2013 14:36:59 +0800
changeset 119632 29933d1937dbceba33b461190f2208c8afe332b9
parent 119631 d80a28cf036458d991538e2878dac76848823392
child 119633 566203eec96dcd05dcfdd2081397da5a254af31b
push id909
push userclian@mozilla.com
push dateTue, 25 Jun 2013 06:44:44 +0000
reviewersvyang, gene, leo
bugs885685
milestone18.1
Bug 885685 - B2G MMS: Use nsIURI Object in applyFilter for MmsProxyFilter. r=vyang,gene a=leo+
dom/mobilemessage/src/ril/MmsService.js
--- a/dom/mobilemessage/src/ril/MmsService.js
+++ b/dom/mobilemessage/src/ril/MmsService.js
@@ -179,19 +179,16 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
                                false);
       Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false);
       this.settings.forEach(function(name) {
         Services.prefs.addObserver(name, this, false);
       }, this);
 
       try {
         this.mmsc = Services.prefs.getCharPref("ril.mms.mmsc");
-        if (this.mmsc.endsWith("/")) {
-          this.mmsc = this.mmsc.substr(0, this.mmsc.length - 1);
-        }
         this.proxy = Services.prefs.getCharPref("ril.mms.mmsproxy");
         this.port = Services.prefs.getIntPref("ril.mms.mmsport");
         this.updateProxyInfo();
       } catch (e) {
         if (DEBUG) debug("Unable to initialize the MMS proxy settings from " +
                          "the preference. This could happen at the first-run. " +
                          "Should be available later.");
         this.clearMmsProxySettings();
@@ -341,19 +338,16 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
             }
             return;
           }
 
           try {
             switch (data) {
               case "ril.mms.mmsc":
                 this.mmsc = Services.prefs.getCharPref("ril.mms.mmsc");
-                if (this.mmsc.endsWith("/")) {
-                  this.mmsc = this.mmsc.substr(0, this.mmsc.length - 1);
-                }
                 break;
               case "ril.mms.mmsproxy":
                 this.proxy = Services.prefs.getCharPref("ril.mms.mmsproxy");
                 this.updateProxyInfo();
                 break;
               case "ril.mms.mmsport":
                 this.port = Services.prefs.getIntPref("ril.mms.mmsport");
                 this.updateProxyInfo();
@@ -376,38 +370,33 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
     }
   };
   conn.init();
 
   return conn;
 });
 
 function MmsProxyFilter(url) {
-  this.url = url;
+  this.uri = Services.io.newURI(url, null, null);
 }
 MmsProxyFilter.prototype = {
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolProxyFilter]),
 
   // nsIProtocolProxyFilter
 
   applyFilter: function applyFilter(proxyService, uri, proxyInfo) {
-    let url = uri.prePath + uri.path;
-    if (url.endsWith("/")) {
-      url = url.substr(0, url.length - 1);
-    }
-
-    if (this.url != url) {
-      if (DEBUG) debug("applyFilter: content uri = " + this.url +
-                       " is not matched url = " + url + " .");
+    if (!this.uri.equals(uri)) {
+      if (DEBUG) debug("applyFilter: content uri = " + JSON.stringify(this.uri) +
+                       " is not matched with uri = " + JSON.stringify(uri) + " .");
       return proxyInfo;
     }
     // Fall-through, reutrn the MMS proxy info.
-    if (DEBUG) debug("applyFilter: MMSC is matched: " +
-                     JSON.stringify({ url: this.url,
+    if (DEBUG) debug("applyFilter: MMSC/Content Location is matched with: " +
+                     JSON.stringify({ uri: JSON.stringify(this.uri),
                                       proxyInfo: gMmsConnection.proxyInfo }));
     return gMmsConnection.proxyInfo ? gMmsConnection.proxyInfo : proxyInfo;
   }
 };
 
 XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function () {
   return {
     /**