const CLASSNAME = "SKAS_ConsoleListener"; const CONTRACTID = "@skrul.com/audioscrobbler-consolelistener;1"; const CID = Components.ID("{8cf2c8a1-91ab-43db-9c3f-066fda8cf017}"); const Cc = Components.classes; const Ci = Components.interfaces; function ConsoleListener() { } // nsISupports ConsoleListener.prototype.QueryInterface = function(aIID) { if(!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.nsIConsoleListener)) throw Components.results.NS_ERROR_NO_INTERFACE; return this; } // nsIConsoleListener ConsoleListener.prototype.observe = function(aMessage) { dump("**********************\n"); dump("* " + aMessage.message + "\n"); dump("**********************\n"); } /** * XPCOM Registration */ var Module = new Object(); Module.registerSelf = function(compMgr, fileSpec, location, type) { compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar); compMgr.registerFactoryLocation(CID, CLASSNAME, CONTRACTID, fileSpec, location, type); } Module.getClassObject = function(compMgr, cid, iid) { if(!cid.equals(CID)) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; } if(!iid.equals(Ci.nsIFactory)) { throw Components.results.NS_ERROR_NO_INTERFACE; } return Factory; } Module.canUnload = function(compMgr) { return true; } var Factory = {}; Factory.createInstance = function(outer, iid) { if(outer != null) { throw Components.results.NS_ERROR_NO_AGGREGATION; } return (new ConsoleListener()).QueryInterface(iid); } function NSGetModule(compMgr, fileSpec) { return Module; }