home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / phoenx05.zip / phoenix / components / jsconsole-clhandler.js < prev    next >
Text File  |  2002-12-10  |  4KB  |  120 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is mozilla.org code.
  13.  * 
  14.  * The Initial Developer of the Original Code is Netscape
  15.  * Communications Corporation.  Portions created by Netscape are
  16.  * Copyright (C) 1999 Netscape Communications Corporation.  All
  17.  * Rights Reserved.
  18.  * 
  19.  * Contributor(s): Martijn Pieters <mj@digicool.com>
  20.  */
  21.  
  22. /*
  23.  * -jsconsole commandline handler; starts up the JavaScript console.
  24.  */
  25.  
  26. /*
  27.  * Constants
  28.  */
  29.  
  30. const JSCONSOLEHANDLER_CONTRACTID =
  31.     "@mozilla.org/commandlinehandler/general-startup;1?type=jsconsole";
  32.  
  33. const JSCONSOLEHANDLER_CID = 
  34.     Components.ID('{1698ef18-c128-41a1-b4d0-7f9acd2ae86c}');
  35.  
  36. /*
  37.  * Classes
  38.  */
  39.  
  40. /* jsConsoleHandler class constructor */
  41. function jsConsoleHandler() {}
  42.  
  43. /* jsConsoleHandler class def */
  44. jsConsoleHandler.prototype = {
  45.     commandLineArgument: '-jsconsole',
  46.     prefNameForStartup: 'general.startup.jsconsole',
  47.     chromeUrlForTask: 'chrome://global/content/console.xul',
  48.     helpText: 'Start with Javascript Console',
  49.     handlesArgs: false,
  50.     defaultArgs: null,
  51.     openWindowWithArgs: false
  52. };
  53.  
  54. /*
  55.  * Objects
  56.  */
  57.  
  58. /* jsConsoleHandler Module (for XPCOM registration) */
  59. var jsConsoleHandlerModule = {
  60.     registerSelf: function(compMgr, fileSpec, location, type) {
  61.         compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  62.  
  63.         compMgr.registerFactoryLocation(JSCONSOLEHANDLER_CID, 
  64.                                         'JS Console Commandline Handler component',
  65.                                         JSCONSOLEHANDLER_CONTRACTID, 
  66.                                         fileSpec,
  67.                                         location, 
  68.                                         type);
  69.         var catman = Components.classes["@mozilla.org/categorymanager;1"]
  70.             .getService(Components.interfaces.nsICategoryManager);
  71.         catman.addCategoryEntry("command-line-argument-handlers", "jsconsole command line handler",
  72.             JSCONSOLEHANDLER_CONTRACTID,
  73.             true, true);
  74.     },
  75.  
  76.     unregisterSelf: function(compMgr, fileSpec, location) {
  77.         compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  78.         compMgr.unregisterFactoryLocation(JSCONSOLEHANDLER_CID, fileSpec);
  79.         var catman = Components.classes["@mozilla.org/categorymanager;1"]
  80.             .getService(Components.interfaces.nsICategoryManager);
  81.         catman.deleteCategoryEntry("command-line-argument-handlers",
  82.             JSCONSOLEHANDLER_CONTRACTID, true);
  83.     },
  84.  
  85.     getClassObject: function(compMgr, cid, iid) {
  86.         if (!cid.equals(JSCONSOLEHANDLER_CID))
  87.             throw Components.results.NS_ERROR_NO_INTERFACE;
  88.  
  89.         if (!iid.equals(Components.interfaces.nsIFactory))
  90.             throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  91.  
  92.         return jsConsoleHandlerFactory;
  93.     },
  94.  
  95.     canUnload: function(compMgr) { return true; }
  96. };
  97.  
  98. /* jsConsoleHandler Class Factory */
  99. var jsConsoleHandlerFactory = {
  100.     createInstance: function(outer, iid) {
  101.         if (outer != null)
  102.             throw Components.results.NS_ERROR_NO_AGGREGATION;
  103.     
  104.         if (!iid.equals(Components.interfaces.nsICmdLineHandler) &&
  105.             !iid.equals(Components.interfaces.nsISupports))
  106.             throw Components.results.NS_ERROR_INVALID_ARG;
  107.  
  108.         return new jsConsoleHandler();
  109.     }
  110. }
  111.  
  112. /*
  113.  * Functions
  114.  */
  115.  
  116. /* module initialisation */
  117. function NSGetModule(comMgr, fileSpec) { return jsConsoleHandlerModule; }
  118.  
  119. // vim:sw=4:sr:sta:et:sts:
  120.