home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / components / jsconsole-clhandler.js < prev    next >
Text File  |  2001-02-14  |  4KB  |  115 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.registerComponentWithType(JSCONSOLEHANDLER_CID, 
  62.             'JS Console Commandline Handler component',
  63.             JSCONSOLEHANDLER_CONTRACTID, fileSpec,
  64.             location, true, true, type);
  65.         var catman = Components.classes["@mozilla.org/categorymanager;1"]
  66.             .getService(Components.interfaces.nsICategoryManager);
  67.         catman.addCategoryEntry("command-line-argument-handlers", "jsconsole command line handler",
  68.             JSCONSOLEHANDLER_CONTRACTID,
  69.             true, true);
  70.     },
  71.  
  72.     unregisterSelf: function(compMgr, fileSpec, location) {
  73.         compMgr.unregisterComponentSpec(JSCONSOLEHANDLER_CID, fileSpec);
  74.         var catman = Components.classes["@mozilla.org/categorymanager;1"]
  75.             .getService(Components.interfaces.nsICategoryManager);
  76.         catman.deleteCategoryEntry("command-line-argument-handlers",
  77.             JSCONSOLEHANDLER_CONTRACTID, true);
  78.     },
  79.  
  80.     getClassObject: function(compMgr, cid, iid) {
  81.         if (!cid.equals(JSCONSOLEHANDLER_CID))
  82.             throw Components.results.NS_ERROR_NO_INTERFACE;
  83.  
  84.         if (!iid.equals(Components.interfaces.nsIFactory))
  85.             throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  86.  
  87.         return jsConsoleHandlerFactory;
  88.     },
  89.  
  90.     canUnload: function(compMgr) { return true; }
  91. };
  92.  
  93. /* jsConsoleHandler Class Factory */
  94. var jsConsoleHandlerFactory = {
  95.     createInstance: function(outer, iid) {
  96.         if (outer != null)
  97.             throw Components.results.NS_ERROR_NO_AGGREGATION;
  98.     
  99.         if (!iid.equals(Components.interfaces.nsICmdLineHandler) &&
  100.             !iid.equals(Components.interfaces.nsISupports))
  101.             throw Components.results.NS_ERROR_INVALID_ARG;
  102.  
  103.         return new jsConsoleHandler();
  104.     }
  105. }
  106.  
  107. /*
  108.  * Functions
  109.  */
  110.  
  111. /* module initialisation */
  112. function NSGetModule(comMgr, fileSpec) { return jsConsoleHandlerModule; }
  113.  
  114. // vim:sw=4:sr:sta:et:sts:
  115.