Changeset 2383


Ignore:
Timestamp:
Sep 30, 2014, 2:24:36 PM (4 years ago)
Author:
matthijs
Message:

Move from nsIJSON to native JSON

The nsIJSON interface is deprecated, so switch to the native JSON
interface that is available since Firefox 3.5. Also bump the minimum
version.

Location:
desktop/foneradownloader/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • desktop/foneradownloader/trunk/chrome/content/js/downloader.js

    r1914 r2383  
    107107        let url = FoneraDownloader.transmissionUrl();
    108108        // https://developer.mozilla.org/En/Using_XMLHttpRequest
    109         // https://developer.mozilla.org/en/nsIJSON
    110         let nJSON = Components.classes["@mozilla.org/dom/json;1"]
    111             .createInstance(Components.interfaces.nsIJSON);
    112 
    113109        // Send
    114110        let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
     
    497493
    498494        // https://developer.mozilla.org/En/Using_XMLHttpRequest
    499         // https://developer.mozilla.org/en/nsIJSON
    500         let nJSON = Components.classes["@mozilla.org/dom/json;1"]
    501             .createInstance(Components.interfaces.nsIJSON);
    502 
    503495        // Send
    504496        let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
    505497            .createInstance(Components.interfaces.nsIXMLHttpRequest);
    506498
    507         let stream = nJSON.encode(rpcCall);
     499        let stream = JSON.stringify(rpcCall);
    508500
    509501        Fonera.Application.console.log("Send URL : " + url + "\n");
     
    531523                Fonera.Application.console.log("Response :" + req.responseText + "\n");
    532524                if (req.status == 200) {
    533                     let response = nJSON.decode(req.responseText);
     525                    let response = JSON.parse(req.responseText);
    534526                    callback(response);
    535527                } else if (req.status == 409) {
  • desktop/foneradownloader/trunk/chrome/content/js/fonera.js

    r1914 r2383  
    213213        }
    214214
    215         let nJSON = Components.classes["@mozilla.org/dom/json;1"]
    216             .createInstance(Components.interfaces.nsIJSON);
    217215        // Send
    218216        let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
    219217            .createInstance(Components.interfaces.nsIXMLHttpRequest);
    220218        let url =  this.foneraURL() + "/fon_rpc/ff/auth";
    221         let stream = nJSON.encode({"method": "plain",
     219        let stream = JSON.stringify({"method": "plain",
    222220            "params" : [this.getUsername(),
    223221                        Fonera.getPassword()] });
     
    234232                Fonera.Application.console.log("Response :" + req.responseText + "\n");
    235233                if(req.status == 200) {
    236                     let response = nJSON.decode(req.responseText);
     234                    let response = JSON.parse(req.responseText);
    237235                    if (response.error == null && response.result != null) {
    238236                        Fonera.Application.console.log(Fonera.AUTHTOKEN + " : " + response.result);
     
    261259
    262260        // https://developer.mozilla.org/En/Using_XMLHttpRequest
    263         // https://developer.mozilla.org/en/nsIJSON
    264         let nJSON = Components.classes["@mozilla.org/dom/json;1"]
    265             .createInstance(Components.interfaces.nsIJSON);
    266 
    267261        // Send
    268262        let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
     
    272266        let url =  Fonera.foneraURL() + "/fon_rpc/ff?auth=" + authToken;
    273267        let rpcCall = {"method": "get_discs"};
    274         let stream = nJSON.encode(rpcCall);
     268        let stream = JSON.stringify(rpcCall);
    275269
    276270        Fonera.Application.console.log("POST : " + stream + "\n");
     
    286280                Fonera.Application.console.log("Response :" + req.responseText + "\n");
    287281                if (req.status == 200) {
    288                     let response = nJSON.decode(req.responseText);
     282                    let response = JSON.parse(req.responseText);
    289283                    if (response.error == null) {
    290284                        if (response.result == null) {
  • desktop/foneradownloader/trunk/install.rdf

    r1914 r2383  
    2020      <Description>
    2121        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
    22         <em:minVersion>3.0</em:minVersion>
     22        <em:minVersion>3.5</em:minVersion>
    2323        <em:maxVersion>6.*</em:maxVersion>
    2424      </Description>
Note: See TracChangeset for help on using the changeset viewer.