From 33e5ea582cde035eb97bc9921fbea0c864465e02 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 5 Nov 2009 16:09:49 -0500 Subject: [PATCH] Fix some symlink woes. Closes issue #140. --HG-- rename : common/components/about-handler.js => muttator/components/about-handler.js rename : common/components/commandline-handler.js => muttator/components/commandline-handler.js rename : common/components/about-handler.js => vimperator/components/about-handler.js rename : common/components/commandline-handler.js => vimperator/components/commandline-handler.js rename : common/components/about-handler.js => xulmus/components/about-handler.js rename : common/components/commandline-handler.js => xulmus/components/commandline-handler.js --- common/content/liberator.js | 3 ++ common/modules/commandline-handler.jsm | 48 ++++++++++++++++++ muttator/components | 1 - muttator/components/about-handler.js | 43 ++++++++++++++++ muttator/components/commandline-handler.js | 49 +++++++++++++++++++ muttator/content/config.js | 3 -- vimperator/components | 1 - vimperator/components/about-handler.js | 43 ++++++++++++++++ vimperator/components/commandline-handler.js | 49 +++++++++++++++++++ vimperator/content/config.js | 3 -- xulmus/components | 1 - .../components/about-handler.js | 13 +++-- .../components/commandline-handler.js | 18 ++++--- xulmus/content/config.js | 3 -- 14 files changed, 255 insertions(+), 23 deletions(-) create mode 100644 common/modules/commandline-handler.jsm delete mode 120000 muttator/components create mode 100644 muttator/components/about-handler.js create mode 100644 muttator/components/commandline-handler.js delete mode 120000 vimperator/components create mode 100644 vimperator/components/about-handler.js create mode 100644 vimperator/components/commandline-handler.js delete mode 120000 xulmus/components rename {common => xulmus}/components/about-handler.js (66%) rename {common => xulmus}/components/commandline-handler.js (68%) diff --git a/common/content/liberator.js b/common/content/liberator.js index a6c3ec12..2ab21379 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -1919,6 +1919,9 @@ const liberator = (function () //{{{ liberator.log("All modules loaded", 3); + services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name.toLowerCase(), + Ci.nsICommandLineHandler); + let commandline = services.get("commandLineHandler").wrappedJSObject.optionValue; if (commandline) { diff --git a/common/modules/commandline-handler.jsm b/common/modules/commandline-handler.jsm new file mode 100644 index 00000000..523bb70d --- /dev/null +++ b/common/modules/commandline-handler.jsm @@ -0,0 +1,48 @@ +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. + +var EXPORTED_SYMBOLS = ["CommandLineHandler", "NSGetModule"]; +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +var CommandLineHandler; + +function initCommandLineHandler(Name) { + var name = Name.toLowerCase(); + CommandLineHandler = function CommandLineHandler() + { + this.wrappedJSObject = this; + } + CommandLineHandler.prototype = { + + classDescription: Name + " Command-line Handler", + + classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"), + + contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=" + name, + + _xpcom_categories: [{ + category: "command-line-handler", + entry: "m-" + name + }], + + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), + + handle: function (commandLine) + { + // TODO: handle remote launches differently? + try + { + this.optionValue = commandLine.handleFlagWithParam(name, false); + } + catch (e) + { + //"vimperator: option -vimperator requires an argument" + } + } + }; +} + +function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]); + +// vim: set ft=javascript fdm=marker sw=4 ts=4 et: diff --git a/muttator/components b/muttator/components deleted file mode 120000 index 577a655a..00000000 --- a/muttator/components +++ /dev/null @@ -1 +0,0 @@ -../common/components \ No newline at end of file diff --git a/muttator/components/about-handler.js b/muttator/components/about-handler.js new file mode 100644 index 00000000..7acb339d --- /dev/null +++ b/muttator/components/about-handler.js @@ -0,0 +1,43 @@ +// Header: +const Name = "Muttator"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/about-handler.jsm"); + +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const Cc = Components.classes; +const Ci = Components.interfaces; + +const name = Name.toLowerCase(); +function AboutHandler() {} +AboutHandler.prototype = { + + classDescription: "About " + Name + " Page", + + classID: Components.ID("81495d80-89ee-4c36-a88d-ea7c4e5ac63f"), + + contractID: "@mozilla.org/network/protocol/about;1?what=" + name, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), + + newChannel: function (uri) + { + let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService) + .newChannel("chrome://" + name + "/content/about.html", null, null); + + channel.originalURI = uri; + + return channel; + }, + + getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT, +}; + +function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]); + +// vim: set fdm=marker sw=4 ts=4 et: diff --git a/muttator/components/commandline-handler.js b/muttator/components/commandline-handler.js new file mode 100644 index 00000000..1f468e03 --- /dev/null +++ b/muttator/components/commandline-handler.js @@ -0,0 +1,49 @@ +// Header: +const Name = "Muttator"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/commandline-handler.jsm"); + +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const name = Name.toLowerCase(); +function CommandLineHandler() +{ + this.wrappedJSObject = this; +} +CommandLineHandler.prototype = { + + classDescription: Name + " Command-line Handler", + + classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"), + + contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=" + name, + + _xpcom_categories: [{ + category: "command-line-handler", + entry: "m-" + name + }], + + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), + + handle: function (commandLine) + { + // TODO: handle remote launches differently? + try + { + this.optionValue = commandLine.handleFlagWithParam(name, false); + } + catch (e) + { + //"vimperator: option -vimperator requires an argument" + } + } +}; + +function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]); + +// vim: set ft=javascript fdm=marker sw=4 ts=4 et: diff --git a/muttator/content/config.js b/muttator/content/config.js index 0c7141a0..97c18436 100644 --- a/muttator/content/config.js +++ b/muttator/content/config.js @@ -175,9 +175,6 @@ const config = (function () //{{{ init: function () { - services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=muttator", - Ci.nsICommandLineHandler); - // don't wait too long when selecting new messages // GetThreadTree()._selectDelay = 300; // TODO: make configurable diff --git a/vimperator/components b/vimperator/components deleted file mode 120000 index 577a655a..00000000 --- a/vimperator/components +++ /dev/null @@ -1 +0,0 @@ -../common/components \ No newline at end of file diff --git a/vimperator/components/about-handler.js b/vimperator/components/about-handler.js new file mode 100644 index 00000000..3d2692fc --- /dev/null +++ b/vimperator/components/about-handler.js @@ -0,0 +1,43 @@ +// Header: +const Name = "Vimperator"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/about-handler.jsm"); + +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const Cc = Components.classes; +const Ci = Components.interfaces; + +const name = Name.toLowerCase(); +function AboutHandler() {} +AboutHandler.prototype = { + + classDescription: "About " + Name + " Page", + + classID: Components.ID("81495d80-89ee-4c36-a88d-ea7c4e5ac63f"), + + contractID: "@mozilla.org/network/protocol/about;1?what=" + name, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), + + newChannel: function (uri) + { + let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService) + .newChannel("chrome://" + name + "/content/about.html", null, null); + + channel.originalURI = uri; + + return channel; + }, + + getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT, +}; + +function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]); + +// vim: set fdm=marker sw=4 ts=4 et: diff --git a/vimperator/components/commandline-handler.js b/vimperator/components/commandline-handler.js new file mode 100644 index 00000000..4fd3bb75 --- /dev/null +++ b/vimperator/components/commandline-handler.js @@ -0,0 +1,49 @@ +// Header: +const Name = "Vimperator"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/commandline-handler.jsm"); + +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const name = Name.toLowerCase(); +function CommandLineHandler() +{ + this.wrappedJSObject = this; +} +CommandLineHandler.prototype = { + + classDescription: Name + " Command-line Handler", + + classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"), + + contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=" + name, + + _xpcom_categories: [{ + category: "command-line-handler", + entry: "m-" + name + }], + + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), + + handle: function (commandLine) + { + // TODO: handle remote launches differently? + try + { + this.optionValue = commandLine.handleFlagWithParam(name, false); + } + catch (e) + { + //"vimperator: option -vimperator requires an argument" + } + } +}; + +function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]); + +// vim: set ft=javascript fdm=marker sw=4 ts=4 et: diff --git a/vimperator/content/config.js b/vimperator/content/config.js index 1dbc1cb9..c9c6e9d9 100644 --- a/vimperator/content/config.js +++ b/vimperator/content/config.js @@ -128,9 +128,6 @@ const config = { //{{{ init: function () { - services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=vimperator", - Ci.nsICommandLineHandler); - // load Vimperator specific modules // FIXME: Why aren't these listed in config.scripts? // FIXME: Why isn't this automatic? -> how would one know which classes to load where? --mst diff --git a/xulmus/components b/xulmus/components deleted file mode 120000 index 577a655a..00000000 --- a/xulmus/components +++ /dev/null @@ -1 +0,0 @@ -../common/components \ No newline at end of file diff --git a/common/components/about-handler.js b/xulmus/components/about-handler.js similarity index 66% rename from common/components/about-handler.js rename to xulmus/components/about-handler.js index 6476f214..de2f98cc 100644 --- a/common/components/about-handler.js +++ b/xulmus/components/about-handler.js @@ -1,3 +1,8 @@ +// Header: +const Name = "Xulmus"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/about-handler.jsm"); + // Copyright (c) 2009 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are @@ -8,22 +13,22 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); const Cc = Components.classes; const Ci = Components.interfaces; +const name = Name.toLowerCase(); function AboutHandler() {} - AboutHandler.prototype = { - classDescription: "About Vimperator Page", + classDescription: "About " + Name + " Page", classID: Components.ID("81495d80-89ee-4c36-a88d-ea7c4e5ac63f"), - contractID: "@mozilla.org/network/protocol/about;1?what=vimperator", + contractID: "@mozilla.org/network/protocol/about;1?what=" + name, QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), newChannel: function (uri) { let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService) - .newChannel("chrome://vimperator/content/about.html", null, null); + .newChannel("chrome://" + name + "/content/about.html", null, null); channel.originalURI = uri; diff --git a/common/components/commandline-handler.js b/xulmus/components/commandline-handler.js similarity index 68% rename from common/components/commandline-handler.js rename to xulmus/components/commandline-handler.js index 054f6369..05b81c07 100644 --- a/common/components/commandline-handler.js +++ b/xulmus/components/commandline-handler.js @@ -1,27 +1,31 @@ +// Header: +const Name = "Xulmus"; +// The following doesn't work here, so this module's code is sadly suplicated: +// Components.utils.import("resource://liberator/commandline-handler.jsm"); + // Copyright (c) 2009 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. - Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +const name = Name.toLowerCase(); function CommandLineHandler() { this.wrappedJSObject = this; } - CommandLineHandler.prototype = { - classDescription: "Vimperator Command-line Handler", + classDescription: Name + " Command-line Handler", classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"), - contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=vimperator", + contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=" + name, _xpcom_categories: [{ category: "command-line-handler", - entry: "m-vimperator" + entry: "m-" + name }], QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), @@ -31,7 +35,7 @@ CommandLineHandler.prototype = { // TODO: handle remote launches differently? try { - this.optionValue = commandLine.handleFlagWithParam("vimperator", false); + this.optionValue = commandLine.handleFlagWithParam(name, false); } catch (e) { @@ -42,4 +46,4 @@ CommandLineHandler.prototype = { function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set ft=javascript fdm=marker sw=4 ts=4 et: diff --git a/xulmus/content/config.js b/xulmus/content/config.js index cc8d0cf0..73c5312e 100644 --- a/xulmus/content/config.js +++ b/xulmus/content/config.js @@ -163,9 +163,6 @@ const config = { //{{{ init: function () { - services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=xulmus", - Ci.nsICommandLineHandler); - // Adding a mode for Player //modes.addMode("PLAYER"); // Player mode for songbird