1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This file implements the URLs for SMS
9 * https://www.rfc-editor.org/rfc/rfc5724.txt
15 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
17 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
18 Cu.import("resource:///modules/TelURIParser.jsm");
20 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
21 "@mozilla.org/childprocessmessagemanager;1",
24 function SmsProtocolHandler() {
27 SmsProtocolHandler.prototype = {
31 protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE |
32 Ci.nsIProtocolHandler.URI_NOAUTH |
33 Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
34 Ci.nsIProtocolHandler.URI_DOES_NOT_RETURN_DATA,
35 allowPort: function() false,
37 newURI: function Proto_newURI(aSpec, aOriginCharset) {
38 let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
43 newChannel: function Proto_newChannel(aURI) {
44 let number = TelURIParser.parseURI('sms', aURI.spec);
46 let query = aURI.spec.split("?")[1];
49 let params = query.split("&");
50 params.forEach(function(aParam) {
51 let [name, value] = aParam.split("=");
52 if (name === "body") {
53 body = decodeURIComponent(value);
59 cpmm.sendAsyncMessage("sms-handler", {
65 throw Components.results.NS_ERROR_ILLEGAL_VALUE;
68 classID: Components.ID("{81ca20cb-0dad-4e32-8566-979c8998bd73}"),
69 QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])
72 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsProtocolHandler]);