From 006a2e9bb7af83ae2cba30f4f3b59ed77079cbcf Mon Sep 17 00:00:00 2001 From: amla70 Date: Fri, 30 Jul 2010 22:54:27 +0000 Subject: [PATCH] Remove dead locales. Simplified the protocol handler code and make it work with Firefox 4. For the moment it's back to handle only market: links until a preferences pane is implemented. --- .../firefox_sendtophone/chrome.manifest | 3 + .../chrome/content/overlay.js | 8 +- .../chrome/locale/en-US/about.dtd | 4 - .../chrome/locale/en-US/overlay.dtd | 4 - .../chrome/locale/en-US/overlay.properties | 6 - .../chrome/locale/es-ES/about.dtd | 4 - .../chrome/locale/es-ES/overlay.dtd | 4 - .../chrome/locale/es-ES/overlay.properties | 6 - .../chrome/locale/fr-FR/about.dtd | 4 - .../chrome/locale/fr-FR/overlay.dtd | 4 - .../chrome/locale/fr-FR/overlay.properties | 6 - .../chrome/locale/zh-CN/about.dtd | 4 - .../chrome/locale/zh-CN/overlay.dtd | 4 - .../chrome/locale/zh-CN/overlay.properties | 6 - .../components/protocolHandler.js | 74 +++++ .../components/protocoltophone.js | 285 ------------------ .../defaults/preferences/prefs.js | 6 +- third_party/firefox_sendtophone/install.rdf | 2 +- .../modules/sendtophone.js | 15 + 19 files changed, 100 insertions(+), 349 deletions(-) delete mode 100644 third_party/firefox_sendtophone/chrome/locale/en-US/about.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/en-US/overlay.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/en-US/overlay.properties delete mode 100644 third_party/firefox_sendtophone/chrome/locale/es-ES/about.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.properties delete mode 100644 third_party/firefox_sendtophone/chrome/locale/fr-FR/about.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.properties delete mode 100644 third_party/firefox_sendtophone/chrome/locale/zh-CN/about.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.dtd delete mode 100644 third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.properties create mode 100644 third_party/firefox_sendtophone/components/protocolHandler.js delete mode 100644 third_party/firefox_sendtophone/components/protocoltophone.js diff --git a/third_party/firefox_sendtophone/chrome.manifest b/third_party/firefox_sendtophone/chrome.manifest index abfdfdd..c116169 100644 --- a/third_party/firefox_sendtophone/chrome.manifest +++ b/third_party/firefox_sendtophone/chrome.manifest @@ -13,3 +13,6 @@ locale sendtophone zh chrome/locale/zh/ overlay chrome://browser/content/browser.xul chrome://sendtophone/content/ff-overlay.xul style chrome://global/content/customizeToolbar.xul chrome://sendtophone/skin/overlay.css + +component {751de080-95d1-11df-981c-0800200c9a66} components/protocolHandler.js +contract @mozilla.org/network/protocol;1?name=market {751de080-95d1-11df-981c-0800200c9a66} diff --git a/third_party/firefox_sendtophone/chrome/content/overlay.js b/third_party/firefox_sendtophone/chrome/content/overlay.js index 1acea93..b78e581 100644 --- a/third_party/firefox_sendtophone/chrome/content/overlay.js +++ b/third_party/firefox_sendtophone/chrome/content/overlay.js @@ -66,22 +66,20 @@ var sendtophone = { selection = info.selection; break; } -/* - if ((/https?:/i).test( info.url )) + + if ((/^(https?|market|tel|sms|ftp):/i).test( info.url )) { -*/ var max_length = 1024; if (selection.length > max_length) selection = selection.substring(0, max_length); sendtophoneCore.send(title, url, selection); -/* } else { this.alert(this.strings.getString("InvalidScheme")); } -*/ + }, // Shows a message in a modal alert diff --git a/third_party/firefox_sendtophone/chrome/locale/en-US/about.dtd b/third_party/firefox_sendtophone/chrome/locale/en-US/about.dtd deleted file mode 100644 index 9a855d5..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/en-US/about.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.dtd b/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.dtd deleted file mode 100644 index 43caa45..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.properties b/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.properties deleted file mode 100644 index 5bf2ddd..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/en-US/overlay.properties +++ /dev/null @@ -1,6 +0,0 @@ -extensions.sendtophone@martinezdelizarrondo.com.description=Sends the current page to your Android phone -SendToPhoneTitle=Send to phone -InvalidScheme=Invalid scheme, you can send only public web pages to your phone. -InfoSent=The data has been sent to your phone. -ErrorOnSend=There was an error sending the data: -LoginRequired=Login required to send the data. \ No newline at end of file diff --git a/third_party/firefox_sendtophone/chrome/locale/es-ES/about.dtd b/third_party/firefox_sendtophone/chrome/locale/es-ES/about.dtd deleted file mode 100644 index 1024378..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/es-ES/about.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.dtd b/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.dtd deleted file mode 100644 index 11a5b57..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.properties b/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.properties deleted file mode 100644 index 68af70e..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/es-ES/overlay.properties +++ /dev/null @@ -1,6 +0,0 @@ -extensions.sendtophone@martinezdelizarrondo.com.description=Envía la página actual a su teléfono Android -SendToPhoneTitle=Enviar a teléfono -InvalidScheme=esquema no válido, por favor, sólo envíe http:// o https:// Enlaces. -InfoSent=El enlace ha sido enviado a su teléfono. -ErrorOnSend=Se ha producido un error al enviar: -LoginRequired=Se requiere ingresar para enviar el enlace. \ No newline at end of file diff --git a/third_party/firefox_sendtophone/chrome/locale/fr-FR/about.dtd b/third_party/firefox_sendtophone/chrome/locale/fr-FR/about.dtd deleted file mode 100644 index 9bcefa7..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/fr-FR/about.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.dtd b/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.dtd deleted file mode 100644 index a2893b2..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.properties b/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.properties deleted file mode 100644 index 134918b..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/fr-FR/overlay.properties +++ /dev/null @@ -1,6 +0,0 @@ -extensions.sendtophone@martinezdelizarrondo.com.description=Envoie la page en cours sur votre téléphone Android -SendToPhoneTitle=Envoyer vers un téléphone -InvalidScheme=régime Blancs, s'il vous plaît envoyer uniquement des liens http:// ou https://. -InfoSent=Le lien a été envoyé à votre téléphone. -ErrorOnSend=Il y avait une erreur d'envoi: -LoginRequired=Login requis pour envoyer ce lien. \ No newline at end of file diff --git a/third_party/firefox_sendtophone/chrome/locale/zh-CN/about.dtd b/third_party/firefox_sendtophone/chrome/locale/zh-CN/about.dtd deleted file mode 100644 index ef2373b..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/zh-CN/about.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.dtd b/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.dtd deleted file mode 100644 index 0348796..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.dtd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.properties b/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.properties deleted file mode 100644 index 9bddd37..0000000 --- a/third_party/firefox_sendtophone/chrome/locale/zh-CN/overlay.properties +++ /dev/null @@ -1,6 +0,0 @@ -extensions.sendtophone@martinezdelizarrondo.com.description=发送当前页面到您的手机机器人 -SendToPhoneTitle=发送到手机 -InvalidScheme=无效的计划,请你只发送http://或https://联系。 -InfoSent=该链接已发送到您的手机。 -ErrorOnSend=它没有发送: -LoginRequired=登录后才可发送的链接。 \ No newline at end of file diff --git a/third_party/firefox_sendtophone/components/protocolHandler.js b/third_party/firefox_sendtophone/components/protocolHandler.js new file mode 100644 index 0000000..f6ccaee --- /dev/null +++ b/third_party/firefox_sendtophone/components/protocolHandler.js @@ -0,0 +1,74 @@ + +// components used in this file +const NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; +const URI_CONTRACTID = "@mozilla.org/network/simple-uri;1"; +const INPUTSTREAMCHANNEL_CONTRACTID = "@mozilla.org/network/input-stream-channel;1"; + +// interfaces used in this file +const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler; +const nsIURI = Components.interfaces.nsIURI; +const nsIPrefService = Components.interfaces.nsIPrefService; +const nsIChannel = Components.interfaces.nsIChannel; +const nsIContentPolicy = Components.interfaces.nsIContentPolicy; + +// some misc. constants +const PREF_BRANCH = "extensions.sendtophone."; + +const alert = Components.classes['@mozilla.org/alerts-service;1'] + .getService(Components.interfaces.nsIAlertsService) + .showAlertNotification; + + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +function SendToPhoneComponent(scheme) { + this.scheme = scheme; +} +SendToPhoneComponent.prototype = { + classDescription: "XPCOM component to handle protocols in SendToPhone", + // this must match whatever is in chrome.manifest! + classID: Components.ID("{751de080-95d1-11df-981c-0800200c9a66}"), + contractID: "@mozilla.org/network/protocol;1?name=market", + + QueryInterface: XPCOMUtils.generateQI([nsIProtocolHandler, nsIContentPolicy]), + + // nsIProtocolHandler implementation: + + // attribute defaults + protocolFlags : nsIProtocolHandler.URI_LOADABLE_BY_ANYONE, + + newURI : function(aSpec, aCharset, aBaseURI) + { + var uri = Components.classes[URI_CONTRACTID].createInstance(nsIURI); + uri.spec = aSpec; + return uri; + }, + + newChannel : function(aURI) + { + var myURI = decodeURI(aURI.spec); + + // Core functions + if (typeof sendtophoneCore == "undefined") + Components.utils.import("resource://sendtophone/sendtophone.js"); + + sendtophoneCore.send("Market link", myURI, "") + + alert(null, "test", myURI); + + // return a fake empty channel so current window doesn't change + return Components.classes[INPUTSTREAMCHANNEL_CONTRACTID].createInstance(nsIChannel); + } + +}; + +// The following line is what XPCOM uses to create components. Each component prototype +// must have a .classID which is used to create it. +/** +* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4). +* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6). +*/ +if (XPCOMUtils.generateNSGetFactory) + var NSGetFactory = XPCOMUtils.generateNSGetFactory([SendToPhoneComponent]); +else + var NSGetModule = XPCOMUtils.generateNSGetModule([SendToPhoneComponent]); \ No newline at end of file diff --git a/third_party/firefox_sendtophone/components/protocoltophone.js b/third_party/firefox_sendtophone/components/protocoltophone.js deleted file mode 100644 index 772ae75..0000000 --- a/third_party/firefox_sendtophone/components/protocoltophone.js +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the MLDonkey protocol handler 2.5. - * - * The Initial Developer of the Original Code is - * Simon Peter . - * Portions created by the Initial Developer are Copyright (C) 2003 - 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Sven Koch - * Len Walter - * Dan Fritz - * David Ciecierski - * Dennis Plöger - * Dominik Röttsches - * Stefan Huber - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/***** Defines *****/ - -// components defined in this file -const MARKETPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=market"; -const MARKETPROT_HANDLER_CID = - Components.ID("{76A4F09C-9B67-11DF-A9F4-6018E0D72085}"); - -const SMSPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=sms"; -const SMSPROT_HANDLER_CID = - Components.ID("{85F1603A-9B67-11DF-96B2-6118E0D72085}"); - -const SMSTOPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=smsto"; -const SMSTOPROT_HANDLER_CID = - Components.ID("{8A9EB484-9B67-11DF-9BAE-8818E0D72085}"); - -const MMSPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=mms"; -const MMSPROT_HANDLER_CID = - Components.ID("{A47959A0-9B70-11DF-92BC-6721E0D72085}"); - -const MMSTOPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=mmsto"; -const MMSTOPROT_HANDLER_CID = - Components.ID("{A9CE57D4-9B70-11DF-8AF1-6821E0D72085}"); - -const CALLTOPROT_HANDLER_CONTRACTID = - "@mozilla.org/network/protocol;1?name=callto"; -const CALLTOPROT_HANDLER_CID = - Components.ID("{E8763476-9B6A-11DF-86FD-B81BE0D72085}"); - -// components used in this file -const NS_IOSERVICE_CID = "{7fe2aeb0-95d1-11df-981c-0800200c9a66}"; -const NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; -const URI_CONTRACTID = "@mozilla.org/network/simple-uri;1"; -const NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1"; -const INPUTSTREAMCHANNEL_CONTRACTID = "@mozilla.org/network/input-stream-channel;1"; -const CATEGORY_MANAGER_CONTRACTID = "@mozilla.org/categorymanager;1"; -const HTTP_HANDLER_CONTRACTID = "@mozilla.org/network/protocol;1?name=http"; - -// interfaces used in this file -const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler; -const nsIURI = Components.interfaces.nsIURI; -const nsIPrefService = Components.interfaces.nsIPrefService; -const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; -const nsIChannel = Components.interfaces.nsIChannel; -const nsIContentPolicy = Components.interfaces.nsIContentPolicy; - -// some misc. constants -const PREF_BRANCH = "extensions.sendtophone."; - -/***** PhoneByProtocolHandler *****/ - -function PhoneByProtocolHandler(scheme) -{ - this.scheme = scheme; -} - -// attribute defaults -PhoneByProtocolHandler.prototype.defaultPort = -1; -PhoneByProtocolHandler.prototype.protocolFlags = nsIProtocolHandler.URI_NORELATIVE; -PhoneByProtocolHandler.prototype.withinLoad = false; - -PhoneByProtocolHandler.prototype.newURI = function(aSpec, aCharset, aBaseURI) -{ - var uri = Components.classes[URI_CONTRACTID].createInstance(nsIURI); - uri.spec = aSpec; - return uri; -} - -PhoneByProtocolHandler.prototype.loadPhoneToProtocol = function(aURI) -{ - var s2pTitle; - var s2pURL = encodeURIComponent(decodeURI(aURI.spec)); - - // read preferences again (otherwise saved settings won't be used until after restart - ProtocolToPhoneModule.readPreferences(PREF_BRANCH); - - // Core functions - if (typeof sendtophoneCore == "undefined") - Components.utils.import("resource://sendtophone/sendtophone.js"); - - if (!s2pURL.indexOf('market')){ - s2pTitle = "Market Link"; - } - else if (!s2pURL.indexOf('sms')){ - s2pTitle = "Send SMS"; - } - else if (!s2pURL.indexOf('mms')){ - s2pTitle = "Send MMS"; - } - else if (!s2pURL.indexOf('call')){ - s2pTitle = "Call Number"; - } - else{ - s2pTitle = "Other"; - } - - sendtophoneCore.send(s2pTitle, cfgUrl + s2pURL, "") - - return null; -} - -PhoneByProtocolHandler.prototype.newChannel = function(aURI) -{ - // pass URI to PhoneToProtocol - var chan = this.loadPhoneToProtocol(aURI); - - // return a fake empty channel so current window doesn't change - if(chan == null) chan = Components.classes[INPUTSTREAMCHANNEL_CONTRACTID].createInstance(nsIChannel); - return chan; -} - -/***** PhoneByProtocolHandlerFactory *****/ - -function PhoneByProtocolHandlerFactory(scheme) -{ - this.scheme = scheme; -} - -PhoneByProtocolHandlerFactory.prototype.createInstance = function(outer, iid) -{ - if(outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION; - - if(!iid.equals(nsIProtocolHandler) && !iid.equals(nsIContentPolicy)) - throw Components.results.NS_ERROR_INVALID_ARG; - - return new PhoneByProtocolHandler(this.scheme); -} - -var factory_market = new PhoneByProtocolHandlerFactory("market"); -var factory_sms = new PhoneByProtocolHandlerFactory("sms"); -var factory_smsto = new PhoneByProtocolHandlerFactory("smsto"); -var factory_mms = new PhoneByProtocolHandlerFactory("mms"); -var factory_mmsto = new PhoneByProtocolHandlerFactory("mmsto"); -var factory_callto = new PhoneByProtocolHandlerFactory("callto"); - -/***** ProtocolToPhoneModule *****/ - -var ProtocolToPhoneModule = new Object(); - -ProtocolToPhoneModule.readPreferences = function(pref_branch) -{ - // get preferences branch - var PrefService = Components.classes[NS_PREFSERVICE_CONTRACTID].getService(nsIPrefService); - var myPrefs = PrefService.getBranch(null); // Mozilla bug #107617 - - // read preferences (if available) - if(myPrefs.getPrefType(pref_branch + "url") == myPrefs.PREF_STRING) - cfgUrl = myPrefs.getCharPref(pref_branch + "url"); - if(myPrefs.getPrefType(pref_branch + "protocols") == myPrefs.PREF_STRING) - cfgProtocols = myPrefs.getCharPref(pref_branch + "protocols"); -} - -ProtocolToPhoneModule.registerSelf = function(compMgr, fileSpec, location, type) -{ - compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar); - - // register market protocol handler - compMgr.registerFactoryLocation(MARKETPROT_HANDLER_CID, - "market protocol handler", - MARKETPROT_HANDLER_CONTRACTID, - fileSpec, location, type); - - // register sms protocol handler - compMgr.registerFactoryLocation(SMSPROT_HANDLER_CID, - "sms protocol handler", - SMSPROT_HANDLER_CONTRACTID, - fileSpec, location, type); - - // register smsto protocol handler - compMgr.registerFactoryLocation(SMSTOPROT_HANDLER_CID, - "smsto protocol handler", - SMSTOPROT_HANDLER_CONTRACTID, - fileSpec, location, type); - // register mms protocol handler - compMgr.registerFactoryLocation(MMSPROT_HANDLER_CID, - "mms protocol handler", - MMSPROT_HANDLER_CONTRACTID, - fileSpec, location, type); - - // register mmsto protocol handler - compMgr.registerFactoryLocation(MMSTOPROT_HANDLER_CID, - "mmsto protocol handler", - MMSTOPROT_HANDLER_CONTRACTID, - fileSpec, location, type); - // register callto protocol handler - compMgr.registerFactoryLocation(CALLTOPROT_HANDLER_CID, - "calltoo protocol handler", - CALLTOPROT_HANDLER_CONTRACTID, - fileSpec, location, type); -} - -ProtocolToPhoneModule.unregisterSelf = function(compMgr, fileSpec, location) -{ - compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar); - - // unregister our components - compMgr.unregisterFactoryLocation(MARKETPROT_HANDLER_CID, fileSpec); - compMgr.unregisterFactoryLocation(SMSPROT_HANDLER_CID, fileSpec); - compMgr.unregisterFactoryLocation(SMSTOPROT_HANDLER_CID, fileSpec); - compMgr.unregisterFactoryLocation(MMSPROT_HANDLER_CID, fileSpec); - compMgr.unregisterFactoryLocation(MMSTOPROT_HANDLER_CID, fileSpec); - compMgr.unregisterFactoryLocation(CALLTOPROT_HANDLER_CID, fileSpec); - -} - -ProtocolToPhoneModule.getClassObject = function(compMgr, cid, iid) -{ - - if(!iid.equals(Components.interfaces.nsIFactory)) - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - - // read preferences - this.readPreferences(PREF_BRANCH); - - // return protocol handler factories - // To disable a protocol simply comment the line out. - if(cid.equals(MARKETPROT_HANDLER_CID)) { if(cfgProtocols.search("market") != -1) return factory_market; else return null; } - if(cid.equals(SMSPROT_HANDLER_CID)) { if(cfgProtocols.search("sms") != -1) return factory_sms; else return null; } - if(cid.equals(SMSTOPROT_HANDLER_CID)) { if (cfgProtocols.search("smsto") != -1) return factory_smsto; else return null; } - if(cid.equals(MMSPROT_HANDLER_CID)) { if(cfgProtocols.search("mms") != -1) return factory_mms; else return null; } - if(cid.equals(MMSTOPROT_HANDLER_CID)) { if (cfgProtocols.search("mmsto") != -1) return factory_mmsto; else return null; } - if(cid.equals(CALLTOPROT_HANDLER_CID)) { if (cfgProtocols.search("callto") != -1) return factory_callto; else return null; } - - throw Components.results.NS_ERROR_NO_INTERFACE; -} - -ProtocolToPhoneModule.canUnload = function(compMgr) -{ - return true; // our objects can be unloaded -} - -/***** Entrypoint *****/ - -function NSGetModule(compMgr, fileSpec) -{ - return ProtocolToPhoneModule; -} diff --git a/third_party/firefox_sendtophone/defaults/preferences/prefs.js b/third_party/firefox_sendtophone/defaults/preferences/prefs.js index fa7d597..1c419fc 100644 --- a/third_party/firefox_sendtophone/defaults/preferences/prefs.js +++ b/third_party/firefox_sendtophone/defaults/preferences/prefs.js @@ -1,7 +1,9 @@ pref("extensions.sendtophone.installedButton", false); pref("extensions.sendtophone.appUrl", "https://chrometophone.appspot.com"); -pref("extensions.sendtophone.url", "http://smallroomstudios.net/s2p.php?ml="); -pref("extensions.sendtophone.protocols", "market smsto sms mms mmsto callto"); + +pref("extensions.sendtophone.proxyUrl", "http://smallroomstudios.net/s2p.php?ml="); + +pref("extensions.sendtophone.protocols", "market"); // https://developer.mozilla.org/en/Localizing_extension_descriptions pref("extensions.sendtophone@martinezdelizarrondo.com.description", "chrome://sendtophone/locale/overlay.properties"); diff --git a/third_party/firefox_sendtophone/install.rdf b/third_party/firefox_sendtophone/install.rdf index 579b96f..f3ecf0e 100644 --- a/third_party/firefox_sendtophone/install.rdf +++ b/third_party/firefox_sendtophone/install.rdf @@ -14,7 +14,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 3.0 - 3.8.6 + 4.0b2 diff --git a/third_party/firefox_sendtophone/modules/sendtophone.js b/third_party/firefox_sendtophone/modules/sendtophone.js index a4d62b4..8418fb8 100644 --- a/third_party/firefox_sendtophone/modules/sendtophone.js +++ b/third_party/firefox_sendtophone/modules/sendtophone.js @@ -152,6 +152,21 @@ var sendtophoneCore = { if (!this.sendUrl) this.init(); + // Send the protocols that aren't currently whitelisted through a proxy server + if ((/^(market|tel|sms|ftp):/i).test( url )) + { + var encodedUri = encodeURIComponent( url); + + var prefs = Cc["@mozilla.org/preferences-service;1"] + .getService(Ci.nsIPrefService) + .getBranch("extensions.sendtophone.") ; + + var proxyUrl = prefs.getCharPref( "proxyUrl" ) ; + + // rewrite the URI so it's send first to the proxy + url = proxyUrl + encodedUri; + } + var data = 'title=' + encodeURIComponent(title) + '&url=' + encodeURIComponent(url) + '&sel=' + encodeURIComponent(selection);