[Bbs2ch-cvs 242] [224] Components. XXX を定数化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 9月 29日 (土) 03:33:49 JST


Revision: 224
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=224
Author:   flyson
Date:     2007-09-29 03:33:48 +0900 (Sat, 29 Sep 2007)

Log Message:
-----------
Components.XXX を定数化

Modified Paths:
--------------
    trunk/bbs2chreader/components/b2rAboneManager.js
    trunk/bbs2chreader/components/b2rProtocolHandler.js
    trunk/bbs2chreader/components/b2rServer.js
    trunk/bbs2chreader/components/b2rThreadRedirector.js
    trunk/bbs2chreader/components/nsBbs2chService.js


-------------- next part --------------
Modified: trunk/bbs2chreader/components/b2rAboneManager.js
===================================================================
--- trunk/bbs2chreader/components/b2rAboneManager.js	2007-09-27 13:41:31 UTC (rev 223)
+++ trunk/bbs2chreader/components/b2rAboneManager.js	2007-09-28 18:33:48 UTC (rev 224)
@@ -35,17 +35,20 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+const Ci = Components.interfaces;
+const Cc = Components.classes;
 
+
 function b2rAboneManager(){
 
 }
 
 b2rAboneManager.prototype = {
 
-	get ABONE_TYPE_NAME(){ return Components.interfaces.b2rIAboneManager.ABONE_TYPE_NAME },
-	get ABONE_TYPE_MAIL(){ return Components.interfaces.b2rIAboneManager.ABONE_TYPE_MAIL },
-	get ABONE_TYPE_ID  (){ return Components.interfaces.b2rIAboneManager.ABONE_TYPE_ID   },
-	get ABONE_TYPE_WORD(){ return Components.interfaces.b2rIAboneManager.ABONE_TYPE_WORD },
+	get ABONE_TYPE_NAME(){ return Ci.b2rIAboneManager.ABONE_TYPE_NAME },
+	get ABONE_TYPE_MAIL(){ return Ci.b2rIAboneManager.ABONE_TYPE_MAIL },
+	get ABONE_TYPE_ID  (){ return Ci.b2rIAboneManager.ABONE_TYPE_ID   },
+	get ABONE_TYPE_WORD(){ return Ci.b2rIAboneManager.ABONE_TYPE_WORD },
 
 	_startup: function(){
 		this._loadAboneData();
@@ -65,8 +68,8 @@
 		this._aboneData["word"] = this._loadNgFile("NGwords.txt");
 	},
 	_loadNgFile: function(aNgFileName){
-		var bbs2chService = Components.classes["@mozilla.org/bbs2ch-service;1"]
-						.getService(Components.interfaces.nsIBbs2chService);
+		var bbs2chService = Cc["@mozilla.org/bbs2ch-service;1"]
+						.getService(Ci.nsIBbs2chService);
 
 		var ngFile = bbs2chService.getDataDir();
 		ngFile.appendRelativePath(aNgFileName);
@@ -89,8 +92,8 @@
 		this._saveNgFile("NGwords.txt", this._aboneData["word"]);
 	},
 	_saveNgFile: function(aNgFileName, aboneDataArray){
-		var bbs2chService = Components.classes["@mozilla.org/bbs2ch-service;1"]
-						.getService(Components.interfaces.nsIBbs2chService);
+		var bbs2chService = Cc["@mozilla.org/bbs2ch-service;1"]
+						.getService(Ci.nsIBbs2chService);
 
 		var ngFile = bbs2chService.getDataDir();
 		ngFile.appendRelativePath(aNgFileName);
@@ -131,8 +134,8 @@
 				return null;
 		}
 
-		var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
-					.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+		var unicodeConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+					.createInstance(Ci.nsIScriptableUnicodeConverter);
 		unicodeConverter.charset = "Shift_JIS";
 
 		var resultArray = ngArray.map(function testFunc(aElement, aIndex, aArray){
@@ -143,8 +146,8 @@
 
 
 	addAbone: function(aWord, aType){
-		var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
-					.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+		var unicodeConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+					.createInstance(Ci.nsIScriptableUnicodeConverter);
 		unicodeConverter.charset = "Shift_JIS";
 
 		var sjisWord = unicodeConverter.ConvertFromUnicode(aWord);
@@ -172,11 +175,8 @@
 
 		ngArray.push(sjisWord);
 
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
-
-		var type = Components.classes["@mozilla.org/supports-PRInt32;1"]
-				.createInstance(Components.interfaces.nsISupportsPRInt32);
+		var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+		var type = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
 		type.data = aType;
 
 		os.notifyObservers(type, "b2r-abone-data-add", aWord);
@@ -184,8 +184,8 @@
 
 
 	removeAbone: function(aWord, aType){
-		var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
-					.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+		var unicodeConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+					.createInstance(Ci.nsIScriptableUnicodeConverter);
 		unicodeConverter.charset = "Shift_JIS";
 
 		var sjisWord = unicodeConverter.ConvertFromUnicode(aWord);
@@ -211,10 +211,8 @@
 		var wordIndex = ngArray.indexOf(sjisWord);
 		if(wordIndex != -1) ngArray.splice(wordIndex, 1);
 
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
-		var type = Components.classes["@mozilla.org/supports-PRInt32;1"]
-				.createInstance(Components.interfaces.nsISupportsPRInt32);
+		var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+		var type = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
 		type.data = aType;
 		os.notifyObservers(type, "b2r-abone-data-remove", aWord);
 
@@ -226,8 +224,7 @@
   	// ********** ********* implements nsIObserver ********** **********
 
 	observe: function(aSubject, aTopic, aData){
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
 		switch(aTopic){
 			case "app-startup":
 				dump("b2rAboneManager\n");
@@ -255,10 +252,10 @@
 		return Components.ID("{ff8a31ea-d3c1-47f1-a72b-0a2a0975d69a}");
 	},
 	get implementationLanguage() {
-		return Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT;
+		return Ci.nsIProgrammingLanguage.JAVASCRIPT;
 	},
 	get flags() {
-		return Components.interfaces.nsIClassInfo.SINGLETON;
+		return Ci.nsIClassInfo.SINGLETON;
 	},
 	get contractID() {
     	return "@mozilla.org/b2r-abone-manager;1";
@@ -266,10 +263,10 @@
 
 	getInterfaces: function(aCount) {
 	    var interfaces = [
-			Components.interfaces.b2rIAboneManager,
-			Components.interfaces.nsIClassInfo,
-			Components.interfaces.nsIObserver,
-			Components.interfaces.nsISupports
+			Ci.b2rIAboneManager,
+			Ci.nsIClassInfo,
+			Ci.nsIObserver,
+			Ci.nsISupports
 		];
 	    aCount.value = interfaces.length;
     	return interfaces;
@@ -283,10 +280,10 @@
   	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.b2rIAboneManager) ||
-				aIID.equals(Components.interfaces.nsIClassInfo) ||
-				aIID.equals(Components.interfaces.nsIObserver) ||
-				aIID.equals(Components.interfaces.nsISupports)){
+		if(aIID.equals(Ci.b2rIAboneManager) ||
+				aIID.equals(Ci.nsIClassInfo) ||
+				aIID.equals(Ci.nsIObserver) ||
+				aIID.equals(Ci.nsISupports)){
 			return this;
 		}
 		throw Components.results.NS_ERROR_NO_INTERFACE;
@@ -305,13 +302,13 @@
 		if(aOuter != null)
 			throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.b2rIAboneManager))
+		if(aIID.equals(Ci.b2rIAboneManager))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIClassInfo))
+		if(aIID.equals(Ci.nsIClassInfo))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIObserver))
+		if(aIID.equals(Ci.nsIObserver))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return this.getInstance(aIID);
 
 		throw Components.results.NS_ERROR_INVALID_ARG;
@@ -334,21 +331,21 @@
 
 
 	registerSelf: function(aCompMgr, aFileSpec, aLocation, aType){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 		aCompMgr.registerFactoryLocation(this.CID, this.CNAME, this.CONTRACTID,
 											aFileSpec, aLocation, aType);
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.addCategoryEntry("app-startup", this.CONTRACTID,
 											this.CONTRACTID, true, true);
 	},
 
 
 	unregisterSelf: function(aCompMgr, aFileSpec, aLocation){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.deleteCategoryEntry("app-startup", this.CONTRACTID, true);
 	},
 
@@ -357,7 +354,7 @@
 		if(aCID.equals(this.CID))
 			return Factory;
 
-		if(!aIID.equals(Components.interfaces.nsIFactory))
+		if(!aIID.equals(Ci.nsIFactory))
 			throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;

Modified: trunk/bbs2chreader/components/b2rProtocolHandler.js
===================================================================
--- trunk/bbs2chreader/components/b2rProtocolHandler.js	2007-09-27 13:41:31 UTC (rev 223)
+++ trunk/bbs2chreader/components/b2rProtocolHandler.js	2007-09-28 18:33:48 UTC (rev 224)
@@ -35,7 +35,10 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+const Ci = Components.interfaces;
+const Cc = Components.classes;
 
+
 const B2R_PROTOCOL_HANDLER_CONTRACTID = "@mozilla.org/network/protocol;1?name=bbs2ch";
 const B2R_PROTOCOL_HANDLER_CID = Components.ID("{e40dcbe9-0d0a-44c2-b135-3b2a2afe8b97}");
 const B2R_PROTOCOL_HANDLER_CNAME = "b2rProtocolHandler js component";
@@ -48,8 +51,7 @@
 
 
 function b2rProtocolHandler(){
-	this._ioService = Components.classes["@mozilla.org/network/io-service;1"]
-			.getService(Components.interfaces.nsIIOService);
+	this._ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 }
 
 b2rProtocolHandler.prototype = {
@@ -64,12 +66,12 @@
 
 	_createStreamChannel: function(aURI, aContentType, aContentCharset){
 		var content = "";
-		var stream = Components.classes["@mozilla.org/io/string-input-stream;1"]
-				.createInstance(Components.interfaces.nsIStringInputStream);
+		var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+				.createInstance(Ci.nsIStringInputStream);
 		stream.setData(content, content.length);
-		var channel = Components.classes["@mozilla.org/network/input-stream-channel;1"]
-				.createInstance(Components.interfaces.nsIInputStreamChannel)
-				.QueryInterface(Components.interfaces.nsIChannel);
+		var channel = Cc["@mozilla.org/network/input-stream-channel;1"]
+				.createInstance(Ci.nsIInputStreamChannel)
+				.QueryInterface(Ci.nsIChannel);
 		channel.setURI(aURI);
 		channel.contentStream = stream;
 		channel.contentType = aContentType || "text/plain";
@@ -82,7 +84,7 @@
 
 	scheme: "bbs2ch",
 	defaultPort: -1,
-	protocolFlags: Components.interfaces.nsIProtocolHandler.URI_NOAUTH,
+	protocolFlags: Ci.nsIProtocolHandler.URI_NOAUTH,
 
 
 	allowPort: function(aPort, aScheme){
@@ -91,8 +93,7 @@
 
 
 	newURI: function(aSpec, aCharset, aBaseURI){
-		var simpleURI = Components.classes["@mozilla.org/network/simple-uri;1"]
-								.createInstance(Components.interfaces.nsIURI);
+		var simpleURI = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
 
 		if(aBaseURI && aSpec.charAt(0)=="#"){ // アンカー付 URL
 			var baseURISprc = aBaseURI.spec.replace(/#[^\/]+/, "");
@@ -141,8 +142,8 @@
 	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIProtocolHandler)) return this;
-		if(aIID.equals(Components.interfaces.nsISupports)) return this;
+		if(aIID.equals(Ci.nsIProtocolHandler)) return this;
+		if(aIID.equals(Ci.nsISupports)) return this;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
 	}
@@ -159,7 +160,7 @@
 	// ********** implements nsIContentHandler **********
 
 	handleContent: function(aContentType, aWindowContext, aRequest){
-		var channel = aRequest.QueryInterface(Components.interfaces.nsIChannel);
+		var channel = aRequest.QueryInterface(Ci.nsIChannel);
 		var uriSpec = channel.URI.spec;
 		var mode = uriSpec.match(/bbs2ch:(\w+:?)/) ? RegExp.$1 : "";
 		var targetURLSpec = uriSpec.match(/bbs2ch:[^:]+:(.+)/) ? RegExp.$1 : "";
@@ -180,11 +181,11 @@
 
 
 	_openPostWizaed: function(aURLSpec){
-		var argString = Components.classes["@mozilla.org/supports-string;1"]
-				.createInstance(Components.interfaces.nsISupportsString);
+		var argString = Cc["@mozilla.org/supports-string;1"]
+				.createInstance(Ci.nsISupportsString);
 		argString.data = aURLSpec;
-		var winWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-				.getService(Components.interfaces.nsIWindowWatcher);
+		var winWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"]
+				.getService(Ci.nsIWindowWatcher);
 		winWatcher.openWindow(null, "chrome://bbs2chreader/content/post-wizard.xul",
 				"_blank", "chrome, resizable, dialog", argString);
 	},
@@ -196,8 +197,8 @@
 			return false;
 		}
 			// ブラウザウィンドウを列挙
-		var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-								.getService(Components.interfaces.nsIWindowMediator);
+		var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]
+								.getService(Ci.nsIWindowMediator);
 		var browserWinEnu = windowMediator.getEnumerator("navigator:browser");
 		while(browserWinEnu.hasMoreElements()){
 			var browserWin = browserWinEnu.getNext();
@@ -217,8 +218,8 @@
 	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIContentHandler)) return this;
-		if(aIID.equals(Components.interfaces.nsISupports)) return this;
+		if(aIID.equals(Ci.nsIContentHandler)) return this;
+		if(aIID.equals(Ci.nsISupports)) return this;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
 	}
@@ -235,9 +236,9 @@
 		if(aOuter != null)
 			throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.nsIProtocolHandler))
+		if(aIID.equals(Ci.nsIProtocolHandler))
 			return new b2rProtocolHandler().QueryInterface(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return new b2rProtocolHandler().QueryInterface(aIID);
 
 		throw Components.results.NS_ERROR_INVALID_ARG;
@@ -252,9 +253,9 @@
 		if(aOuter != null)
 			throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.nsIContentHandler))
+		if(aIID.equals(Ci.nsIContentHandler))
 			return new b2rContentHandler().QueryInterface(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return new b2rContentHandler().QueryInterface(aIID);
 
 		throw Components.results.NS_ERROR_INVALID_ARG;
@@ -266,7 +267,7 @@
 var Module = {
 
 	registerSelf: function(aCompMgr, aFileSpec, aLocation, aType){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 
 		aCompMgr.registerFactoryLocation(
 						B2R_PROTOCOL_HANDLER_CID,
@@ -283,7 +284,7 @@
 
 
 	unregisterSelf: function(aCompMgr, aFileSpec, aLocation){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 	},
 
 
@@ -291,7 +292,7 @@
 		if(aCID.equals(B2R_PROTOCOL_HANDLER_CID)) return b2rProtocolHandlerFactory;
 		if(aCID.equals(B2R_CONTENTL_HANDLER_CID)) return b2rContentHandlerFactory;
 
-		if(!aIID.equals(Components.interfaces.nsIFactory))
+		if(!aIID.equals(Ci.nsIFactory))
 			throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;

Modified: trunk/bbs2chreader/components/b2rServer.js
===================================================================
--- trunk/bbs2chreader/components/b2rServer.js	2007-09-27 13:41:31 UTC (rev 223)
+++ trunk/bbs2chreader/components/b2rServer.js	2007-09-28 18:33:48 UTC (rev 224)
@@ -35,7 +35,10 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+const Ci = Components.interfaces;
+const Cc = Components.classes;
 
+
 // ********** ********* b2rServer ********** **********
 
 function b2rServer(){
@@ -54,20 +57,14 @@
 			return;
 		}
 
-        this._thread = Components.classes["@mozilla.org/thread;1"]
-        					.createInstance(Components.interfaces.nsIThread);
-        this._thread.init(this, 0,
-                   Components.interfaces.nsIThread.PRIORITY_NORMAL,
-                   Components.interfaces.nsIThread.SCOPE_GLOBAL,
-                   Components.interfaces.nsIThread.STATE_JOINABLE);
+        this._thread = Cc["@mozilla.org/thread;1"].createInstance(Ci.nsIThread);
+        this._thread.init(this, 0, Ci.nsIThread.PRIORITY_NORMAL,
+        					Ci.nsIThread.SCOPE_GLOBAL, Ci.nsIThread.STATE_JOINABLE);
 		dump("b2rServer.start\n");
 	},
 
 	stop: function(){
 		if(this._runningEventLoop){
-			var currentThread = Components.classes["@mozilla.org/thread;1"]
-        			.createInstance(Components.interfaces.nsIThread)
-        			.currentThread;
 	        this._thread.interrupt();
 	        this._thread = null;
        		dump("b2rServer.stop\n");
@@ -78,16 +75,14 @@
   	// ********** ********* implements nsIRunnable ********** **********
 
 	run: function (){
-		var eventQueueService = Components.classes["@mozilla.org/event-queue-service;1"]
-					.getService(Components.interfaces.nsIEventQueueService);
+		var eventQueueService = Cc["@mozilla.org/event-queue-service;1"]
+					.getService(Ci.nsIEventQueueService);
 		this._eventQueue = eventQueueService.createFromIThread(this.currentThread, false);
 
-		var pref = Components.classes["@mozilla.org/preferences-service;1"]
-						.getService(Components.interfaces.nsIPrefBranch);
+		var pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
 		var port = 0;
 		try{
-			var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
-    	    					.createInstance(Components.interfaces.nsIXULAppInfo);
+			var appInfo = Cc["@mozilla.org/xre/app-info;1"].createInstance(Ci.nsIXULAppInfo);
     	    if(appInfo.name == "Firefox"){
 				port = pref.getIntPref("extensions.bbs2chreader.server_port");
 			}else if(appInfo.name == "SeaMonkey"){
@@ -99,8 +94,8 @@
 			port = pref.getIntPref("extensions.bbs2chreader.server_port.other");
 		}
 
-		var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
-					.createInstance(Components.interfaces.nsIServerSocket);
+		var serverSocket = Cc["@mozilla.org/network/server-socket;1"]
+				.createInstance(Ci.nsIServerSocket);
 		serverSocket.init(port, true, 10);
 		serverSocket.asyncListen(this);
 
@@ -120,7 +115,7 @@
   	// ********** ********* implements nsIServerSocketListener ********** **********
 
 	onSocketAccepted: function(aServerSocket, aTransport){
-		const nsITransport = Components.interfaces.nsITransport;
+		const nsITransport = Ci.nsITransport;
 		aTransport.setTimeout(nsITransport.TIMEOUT_CONNECT, 30);
 		aTransport.setTimeout(nsITransport.TIMEOUT_READ_WRITE, 30);
 
@@ -139,8 +134,7 @@
 	// ********** ********* implements nsIObserver ********** **********
 
 	observe: function(aSubject, aTopic, aData){
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
 
 		switch(aTopic){
 			case "app-startup":
@@ -171,12 +165,12 @@
 	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIServerSocket)) return this;
-		if(aIID.equals(Components.interfaces.nsIServerSocketListener)) return this;
-		if(aIID.equals(Components.interfaces.nsIRunnable)) return this;
-		if(aIID.equals(Components.interfaces.nsIObserver)) return this;
-		if(aIID.equals(Components.interfaces.nsISupportsWeakReference)) return this;
-		if(aIID.equals(Components.interfaces.nsISupports)) return this;
+		if(aIID.equals(Ci.nsIServerSocket)) return this;
+		if(aIID.equals(Ci.nsIServerSocketListener)) return this;
+		if(aIID.equals(Ci.nsIRunnable)) return this;
+		if(aIID.equals(Ci.nsIObserver)) return this;
+		if(aIID.equals(Ci.nsISupportsWeakReference)) return this;
+		if(aIID.equals(Ci.nsISupports)) return this;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
 	}
@@ -204,8 +198,7 @@
 		}
 
 		if(!this._thread){
-			this._thread = Components.classes["@mozilla.org/thread-manager;1"]
-				.getService().newThread(0);
+			this._thread = Cc["@mozilla.org/thread-manager;1"].getService().newThread(0);
 		}
 		this._thread.dispatch(this, this._thread.DISPATCH_NORMAL);
 		dump("b2rServer_GECKO_1_9.start\n");
@@ -222,12 +215,11 @@
   	// ********** ********* implements nsIRunnable ********** **********
 
 	run: function (){
-		var pref = Components.classes["@mozilla.org/preferences-service;1"]
-						.getService(Components.interfaces.nsIPrefBranch);
+		var pref = Cc["@mozilla.org/preferences-service;1"]
+						.getService(Ci.nsIPrefBranch);
 		var port = 0;
 		try{
-			var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
-    	    					.createInstance(Components.interfaces.nsIXULAppInfo);
+			var appInfo = Cc["@mozilla.org/xre/app-info;1"].createInstance(Ci.nsIXULAppInfo);
     	    if(appInfo.name == "Firefox"){
 				port = pref.getIntPref("extensions.bbs2chreader.server_port");
 			}else if(appInfo.name == "SeaMonkey"){
@@ -239,8 +231,8 @@
 			port = pref.getIntPref("extensions.bbs2chreader.server_port.other");
 		}
 
-		var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
-					.createInstance(Components.interfaces.nsIServerSocket);
+		var serverSocket = Cc["@mozilla.org/network/server-socket;1"]
+					.createInstance(Ci.nsIServerSocket);
 		serverSocket.init(port, true, 10);
 		serverSocket.asyncListen(this);
 
@@ -257,7 +249,7 @@
   	// ********** ********* implements nsIServerSocketListener ********** **********
 
 	onSocketAccepted: function(aServerSocket, aTransport){
-		const nsITransport = Components.interfaces.nsITransport;
+		const nsITransport = Ci.nsITransport;
 		aTransport.setTimeout(nsITransport.TIMEOUT_CONNECT, 30);
 		aTransport.setTimeout(nsITransport.TIMEOUT_READ_WRITE, 30);
 
@@ -276,8 +268,8 @@
 	// ********** ********* implements nsIObserver ********** **********
 
 	observe: function(aSubject, aTopic, aData){
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"]
+					.getService(Ci.nsIObserverService);
 
 		switch(aTopic){
 			case "app-startup":
@@ -308,12 +300,12 @@
 	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIServerSocket)) return this;
-		if(aIID.equals(Components.interfaces.nsIServerSocketListener)) return this;
-		if(aIID.equals(Components.interfaces.nsIRunnable)) return this;
-		if(aIID.equals(Components.interfaces.nsIObserver)) return this;
-		if(aIID.equals(Components.interfaces.nsISupportsWeakReference)) return this;
-		if(aIID.equals(Components.interfaces.nsISupports)) return this;
+		if(aIID.equals(Ci.nsIServerSocket)) return this;
+		if(aIID.equals(Ci.nsIServerSocketListener)) return this;
+		if(aIID.equals(Ci.nsIRunnable)) return this;
+		if(aIID.equals(Ci.nsIObserver)) return this;
+		if(aIID.equals(Ci.nsISupportsWeakReference)) return this;
+		if(aIID.equals(Ci.nsISupports)) return this;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
 	}
@@ -375,9 +367,9 @@
 
 
 	_parseRequestData: function(){
-		var inputStram = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
-				.createInstance(Components.interfaces.nsIConverterInputStream)
-				.QueryInterface(Components.interfaces.nsIUnicharLineInputStream);
+		var inputStram = Cc["@mozilla.org/intl/converter-input-stream;1"]
+				.createInstance(Ci.nsIConverterInputStream)
+				.QueryInterface(Ci.nsIUnicharLineInputStream);
 		inputStram.init(this._input, "ISO-8859-1", 1024, 0xFFFD);
 		var line = {};
 
@@ -402,12 +394,10 @@
 			this._httpVersion = RegExp.$3;
 		}
 
-		var ioService = Components.classes["@mozilla.org/network/io-service;1"]
-				.getService(Components.interfaces.nsIIOService);
+		var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 		try{
 			var baseURI = ioService.newURI("http://127.0.0.1:" + this._port, null, null);
-			this._requestURL = ioService.newURI(uri, null, baseURI)
-							.QueryInterface(Components.interfaces.nsIURL);
+			this._requestURL = ioService.newURI(uri, null, baseURI).QueryInterface(Ci.nsIURL);
 		}catch(ex){}
 
 		if(this._requestURL){
@@ -435,8 +425,8 @@
 		var scriptURL = "chrome://bbs2chreader/content/server/%MODE%.js";
 		scriptURL = scriptURL.replace("%MODE%", mode);
 
-		var subScrLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
-				.getService(Components.interfaces.mozIJSSubScriptLoader);
+		var subScrLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
+				.getService(Ci.mozIJSSubScriptLoader);
 
 		try{
 			this._scope = { script:null };
@@ -567,17 +557,17 @@
 	createInstance: function (aOuter, aIID) {
 		if(aOuter != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.nsIServerSocket))
+		if(aIID.equals(Ci.nsIServerSocket))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIServerSocketListener))
+		if(aIID.equals(Ci.nsIServerSocketListener))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIRunnable))
+		if(aIID.equals(Ci.nsIRunnable))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIObserver))
+		if(aIID.equals(Ci.nsIObserver))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupportsWeakReference))
+		if(aIID.equals(Ci.nsISupportsWeakReference))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return this.getInstance(aIID);
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
@@ -608,23 +598,23 @@
 
 
 	registerSelf: function(aCompMgr, aFileSpec, aLocation, aType){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 
 		aCompMgr.registerFactoryLocation(this.CID, this.CNAME, this.CONTRACTID,
 											aFileSpec, aLocation, aType);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.addCategoryEntry("app-startup", this.CNAME, this.CONTRACTID, true, true);
 	},
 
 
 	unregisterSelf: function(aCompMgr, aFileSpec, aLocation){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 		aCompMgr.unregisterFactoryLocation(this.CID, aFileSpec);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.deleteCategoryEntry("app-startup", this.CONTRACTID, true);
 	},
 
@@ -633,7 +623,7 @@
 		if(aCID.equals(this.CID))
 				return Factory;
 
-		if(!aIID.equals(Components.interfaces.nsIFactory))
+		if(!aIID.equals(Ci.nsIFactory))
 				throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;

Modified: trunk/bbs2chreader/components/b2rThreadRedirector.js
===================================================================
--- trunk/bbs2chreader/components/b2rThreadRedirector.js	2007-09-27 13:41:31 UTC (rev 223)
+++ trunk/bbs2chreader/components/b2rThreadRedirector.js	2007-09-28 18:33:48 UTC (rev 224)
@@ -38,7 +38,10 @@
 
 // ********** ********* b2rThreadRedirector ********** **********
 
+const Ci = Components.interfaces;
+const Cc = Components.classes;
 
+
 function b2rThreadRedirector(){
 	this._init();
 }
@@ -54,10 +57,9 @@
 		this._PREF_ASK = "extensions.bbs2chreader.thread_redirector.ask";
 		this._PREF_THROW_BOOKMARKS = "extensions.bbs2chreader.thread_redirector.throw_bookmarks";
 
-		this._observerService = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
-		this._pref = Components.classes["@mozilla.org/preferences-service;1"]
-						.getService(Components.interfaces.nsIPrefBranch2);
+		this._observerService = Cc["@mozilla.org/observer-service;1"]
+					.getService(Ci.nsIObserverService);
+		this._pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2);
 
 		this._enabled = this._pref.getBoolPref(this._PREF_ENABLED);
 	},
@@ -80,10 +82,10 @@
 
 			case "profile-after-change":
 				if(this._enabled){
-						var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-									.getService(Components.interfaces.nsICategoryManager);
-						categoryManager.addCategoryEntry("content-policy", ComponentModule.CONTRACTID,
-												ComponentModule.CONTRACTID, true, true);
+					var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+								.getService(Ci.nsICategoryManager);
+					categoryManager.addCategoryEntry("content-policy", ComponentModule.CONTRACTID,
+											ComponentModule.CONTRACTID, true, true);
 				}
 				this._observerService.removeObserver(this, "profile-after-change");
 				break;
@@ -99,19 +101,19 @@
 
 	// ********** ********* implements nsIContentPolicy ********** **********
 
-	TYPE_OTHER			: Components.interfaces.nsIContentPolicy.TYPE_OTHER,
-	TYPE_SCRIPT			: Components.interfaces.nsIContentPolicy.TYPE_SCRIPT,
-	TYPE_IMAGE			: Components.interfaces.nsIContentPolicy.TYPE_IMAGE,
-	TYPE_STYLESHEET		: Components.interfaces.nsIContentPolicy.TYPE_STYLESHEET,
-	TYPE_OBJECT			: Components.interfaces.nsIContentPolicy.TYPE_OBJECT,
-	TYPE_DOCUMENT		: Components.interfaces.nsIContentPolicy.TYPE_DOCUMENT,
-	TYPE_SUBDOCUMENT	: Components.interfaces.nsIContentPolicy.TYPE_SUBDOCUMENT,
-	TYPE_REFRESH		: Components.interfaces.nsIContentPolicy.TYPE_REFRESH,
-	ACCEPT				: Components.interfaces.nsIContentPolicy.ACCEPT,
-	REJECT_REQUEST		: Components.interfaces.nsIContentPolicy.REJECT_REQUEST,
-	REJECT_TYPE			: Components.interfaces.nsIContentPolicy.REJECT_TYPE,
-	REJECT_SERVER		: Components.interfaces.nsIContentPolicy.REJECT_SERVER,
-	REJECT_OTHER		: Components.interfaces.nsIContentPolicy.REJECT_OTHER,
+	TYPE_OTHER			: Ci.nsIContentPolicy.TYPE_OTHER,
+	TYPE_SCRIPT			: Ci.nsIContentPolicy.TYPE_SCRIPT,
+	TYPE_IMAGE			: Ci.nsIContentPolicy.TYPE_IMAGE,
+	TYPE_STYLESHEET		: Ci.nsIContentPolicy.TYPE_STYLESHEET,
+	TYPE_OBJECT			: Ci.nsIContentPolicy.TYPE_OBJECT,
+	TYPE_DOCUMENT		: Ci.nsIContentPolicy.TYPE_DOCUMENT,
+	TYPE_SUBDOCUMENT	: Ci.nsIContentPolicy.TYPE_SUBDOCUMENT,
+	TYPE_REFRESH		: Ci.nsIContentPolicy.TYPE_REFRESH,
+	ACCEPT				: Ci.nsIContentPolicy.ACCEPT,
+	REJECT_REQUEST		: Ci.nsIContentPolicy.REJECT_REQUEST,
+	REJECT_TYPE			: Ci.nsIContentPolicy.REJECT_TYPE,
+	REJECT_SERVER		: Ci.nsIContentPolicy.REJECT_SERVER,
+	REJECT_OTHER		: Ci.nsIContentPolicy.REJECT_OTHER,
 
 
 	shouldLoad: function(aContentType, aContentLocation, aRequestOrigin,
@@ -144,8 +146,8 @@
 			var ask = this._pref.getBoolPref(this._PREF_ASK);
 
 			if(ask){
-				var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
-							.getService(Components.interfaces.nsIPromptService);
+				var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+							.getService(Ci.nsIPromptService);
 				var dialogTitle = "bbs2chreader";
 				var dialogText = "Do you want to view it in bbs2chreader?\n" +
 										aContentLocation.spec +"\n";
@@ -161,8 +163,8 @@
 			}
 
 			if(viewB2r){
-				var bbs2chService = Components.classes["@mozilla.org/bbs2ch-service;1"]
-							.getService(Components.interfaces.nsIBbs2chService);
+				var bbs2chService = Cc["@mozilla.org/bbs2ch-service;1"]
+							.getService(Ci.nsIBbs2chService);
 				var serverURL = "./thread/" + aContentLocation.spec;
 				serverURL = bbs2chService.serverURL.resolve(serverURL);
 				aContentLocation.spec = serverURL;
@@ -182,10 +184,10 @@
 	// ********** ********* implements nsISupports ********** **********
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIContentPolicy)) return this;
-		if(aIID.equals(Components.interfaces.nsISupportsWeakReference)) return this;
-		if(aIID.equals(Components.interfaces.nsIObserver)) return this;
-		if(aIID.equals(Components.interfaces.nsISupports)) return this;
+		if(aIID.equals(Ci.nsIContentPolicy)) return this;
+		if(aIID.equals(Ci.nsISupportsWeakReference)) return this;
+		if(aIID.equals(Ci.nsIObserver)) return this;
+		if(aIID.equals(Ci.nsISupports)) return this;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;
 	}
@@ -203,13 +205,13 @@
 	createInstance: function (aOuter, aIID) {
 		if(aOuter != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.nsIContentPolicy))
+		if(aIID.equals(Ci.nsIContentPolicy))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupportsWeakReference))
+		if(aIID.equals(Ci.nsISupportsWeakReference))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIObserver))
+		if(aIID.equals(Ci.nsIObserver))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return this.getInstance(aIID);
 
 		throw Components.results.NS_ERROR_INVALID_ARG;
@@ -236,13 +238,13 @@
 
 
 	registerSelf: function(aCompMgr, aFileSpec, aLocation, aType){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 
 		aCompMgr.registerFactoryLocation(this.CID, this.CNAME, this.CONTRACTID,
 											aFileSpec, aLocation, aType);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.addCategoryEntry("app-startup", this.CONTRACTID,
 											this.CONTRACTID, true, true);
 
@@ -250,11 +252,11 @@
 
 
 	unregisterSelf: function(aCompMgr, aFileSpec, aLocation){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 		aCompMgr.unregisterFactoryLocation(this.CID, aFileSpec);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.deleteCategoryEntry("app-startup", this.CONTRACTID, true);
 	},
 
@@ -263,7 +265,7 @@
 		if(aCID.equals(this.CID))
 				return b2rThreadRedirectorFactory;
 
-		if(!aIID.equals(Components.interfaces.nsIFactory))
+		if(!aIID.equals(Ci.nsIFactory))
 				throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;

Modified: trunk/bbs2chreader/components/nsBbs2chService.js
===================================================================
--- trunk/bbs2chreader/components/nsBbs2chService.js	2007-09-27 13:41:31 UTC (rev 223)
+++ trunk/bbs2chreader/components/nsBbs2chService.js	2007-09-28 18:33:48 UTC (rev 224)
@@ -35,7 +35,10 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+const Ci = Components.interfaces;
+const Cc = Components.classes;
 
+
 function b2rGlobalHistory(aBbs2chService){
 	this._init(aBbs2chService);
 }
@@ -47,8 +50,8 @@
 	},
 
 	_init: function(aBbs2chService){
-		var storageService = Components.classes["@mozilla.org/storage/service;1"]
-				.getService(Components.interfaces.mozIStorageService);
+		var storageService = Cc["@mozilla.org/storage/service;1"]
+				.getService(Ci.mozIStorageService);
 		var dbFile = aBbs2chService.getDataDir();
 		dbFile.appendRelativePath("history.sqlite");
 			// 初回起動でデータディレクトリが存在しない場合にそなえて先に作成
@@ -158,19 +161,19 @@
 
 nsBbs2chService.prototype = {
 
-	BOARD_TYPE_2CH:    Components.interfaces.nsIBbs2chService.BOARD_TYPE_2CH,
-	BOARD_TYPE_OLD2CH: Components.interfaces.nsIBbs2chService.BOARD_TYPE_OLD2CH,
-	BOARD_TYPE_BE2CH:  Components.interfaces.nsIBbs2chService.BOARD_TYPE_BE2CH,
-	BOARD_TYPE_JBBS:   Components.interfaces.nsIBbs2chService.BOARD_TYPE_JBBS,
-	BOARD_TYPE_MACHI:  Components.interfaces.nsIBbs2chService.BOARD_TYPE_MACHI,
-	BOARD_TYPE_PAGE:   Components.interfaces.nsIBbs2chService.BOARD_TYPE_PAGE,
+	BOARD_TYPE_2CH:    Ci.nsIBbs2chService.BOARD_TYPE_2CH,
+	BOARD_TYPE_OLD2CH: Ci.nsIBbs2chService.BOARD_TYPE_OLD2CH,
+	BOARD_TYPE_BE2CH:  Ci.nsIBbs2chService.BOARD_TYPE_BE2CH,
+	BOARD_TYPE_JBBS:   Ci.nsIBbs2chService.BOARD_TYPE_JBBS,
+	BOARD_TYPE_MACHI:  Ci.nsIBbs2chService.BOARD_TYPE_MACHI,
+	BOARD_TYPE_PAGE:   Ci.nsIBbs2chService.BOARD_TYPE_PAGE,
 
 
 	get _unicodeConverter(){
 		if(!this.__unicodeConverter){
 			this.__unicodeConverter =
-				Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
-					.getService(Components.interfaces.nsIScriptableUnicodeConverter);
+				Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+					.createInstance(Ci.nsIScriptableUnicodeConverter);
 		}
 		return this.__unicodeConverter;
 	},
@@ -178,8 +181,8 @@
 	get _ioService(){
 		if(!this.__ioService){
 			this.__ioService =
-				Components.classes["@mozilla.org/network/io-service;1"]
-				.getService(Components.interfaces.nsIIOService);
+				Cc["@mozilla.org/network/io-service;1"]
+				.getService(Ci.nsIIOService);
 		}
 		return this.__ioService;
 	},
@@ -187,17 +190,16 @@
 	get userAgent(){
 		if(!this._userAgent){
 			try{
-				var extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
-						.getService(Components.interfaces.nsIExtensionManager);
-				var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
-						.getService(Components.interfaces.nsIXULAppInfo);
+				var extensionManager = Cc["@mozilla.org/extensions/manager;1"]
+						.getService(Ci.nsIExtensionManager);
+				var appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
 				var bbs2chID = "{0B9D558E-6983-486b-9AAD-B6CBCD2FC807}";
 				var item = extensionManager.getItemForID(bbs2chID);
 				this._userAgent = new Array(
 							"Monazilla/1.00 (", item.name, "/", item.version, "; ",
 							appInfo.name, "/", appInfo.version, ")").join("");
 			}catch(ex){
-				this._userAgent = "Monazilla/1.00 (bbs2chreader/0.3.0)"
+				this._userAgent = "Monazilla/1.00 (bbs2chreader/0.4.0)"
 			}
 		}
 
@@ -210,8 +212,7 @@
 		if(!this._serverURL){
 			var port = 0;
 			try{
-				var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
-	    	    					.createInstance(Components.interfaces.nsIXULAppInfo);
+				var appInfo = Cc["@mozilla.org/xre/app-info;1"].createInstance(Ci.nsIXULAppInfo);
 	    	    if(appInfo.name == "Firefox"){
 					port = this.pref.getIntPref("extensions.bbs2chreader.server_port");
 				}else if(appInfo.name == "SeaMonkey"){
@@ -225,15 +226,14 @@
 
 			var spec = "http://127.0.0.1:" + port;
 			this._serverURL = this._ioService.newURI(spec, null, null)
-						.QueryInterface(Components.interfaces.nsIURL);
+						.QueryInterface(Ci.nsIURL);
 		}
 		return this._serverURL.clone();
 	},
 
 	get pref(){
 		if(!this._pref){
-			this._pref = Components.classes["@mozilla.org/preferences-service;1"]
-									.getService(Components.interfaces.nsIPrefBranch);
+			this._pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
 		}
 		return this._pref;
 	},
@@ -241,9 +241,8 @@
 
 	get prefDefault(){
 		if(!this._prefDefault){
-			this._prefDefault = Components.classes["@mozilla.org/preferences-service;1"]
-									.getService(Components.interfaces.nsIPrefService)
-										.getDefaultBranch("");
+			this._prefDefault = Cc["@mozilla.org/preferences-service;1"]
+						.getService(Ci.nsIPrefService).getDefaultBranch("");
 		}
 		return this._prefDefault;
 	},
@@ -351,8 +350,7 @@
 		if(aURLSpec.search(/^http:\/\/([^\.]+)\.machi\.to\/.+/) != -1)
 			return this.BOARD_TYPE_MACHI;
 
-		var url = this._ioService.newURI(aURLSpec, null, null)
-						.QueryInterface(Components.interfaces.nsIURL);
+		var url = this._ioService.newURI(aURLSpec, null, null).QueryInterface(Ci.nsIURL);
 
 			// スレッド URL
 		if(url.directory.indexOf("/test/read.cgi/") != -1)
@@ -364,8 +362,7 @@
 	},
 
 	getBoardURL: function(aURLSpec){
-		var url = this._ioService.newURI(aURLSpec, null, null)
-							.QueryInterface(Components.interfaces.nsIURL);
+		var url = this._ioService.newURI(aURLSpec, null, null).QueryInterface(Ci.nsIURL);
 
 		var boardURLSpec = url.resolve("../");
 
@@ -383,12 +380,12 @@
 				break;
 		}
 		return this._ioService.newURI(boardURLSpec, null, null)
-							.QueryInterface(Components.interfaces.nsIURL);
+							.QueryInterface(Ci.nsIURL);
 	},
 
 	openURL: function(aURLSpec, aReferrer, aAddTab){
-		var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-									.getService(Components.interfaces.nsIWindowMediator);
+		var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]
+									.getService(Ci.nsIWindowMediator);
 		var browserWindow = windowMediator.getMostRecentWindow("navigator:browser");
 		if(browserWindow){
 			var contentBrowser = browserWindow.document.getElementById("content");
@@ -408,13 +405,12 @@
 	},
 
 	openNewWindow: function(aURLSpec){
-		var argString = Components.classes["@mozilla.org/supports-string;1"]
-				.createInstance(Components.interfaces.nsISupportsString);
+		var argString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
 		argString.data = aURLSpec || "about:blank";;
 
 		var browserURL = this.pref.getCharPref("browser.chromeURL");
-		var winWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-				.getService(Components.interfaces.nsIWindowWatcher);
+		var winWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"]
+				.getService(Ci.nsIWindowWatcher);
 		winWatcher.openWindow(null, browserURL, "_blank",
 				"chrome,all,dialog=no", argString);
 	},
@@ -428,7 +424,7 @@
 		if(this.pref.getBoolPref("extensions.bbs2chreader.appoint_data_dir")){
 			try{
 				var dataDirPath = this.pref.getComplexValue("extensions.bbs2chreader.data_dir",
-										Components.interfaces.nsISupportsString).data;
+										Ci.nsISupportsString).data;
 				dataDir = this._createLocalFile(dataDirPath);
 				if(dataDir.leafName != DATA_DIR_NAME)
 					dataDir.appendRelativePath(DATA_DIR_NAME);
@@ -438,9 +434,8 @@
 		}
 
 			// 指定していないときはプロファイルディレクトリ
-		var dirService = Components.classes["@mozilla.org/file/directory_service;1"]
-								.getService(Components.interfaces.nsIProperties);
-		dataDir = dirService.get("ProfD", Components.interfaces.nsILocalFile);
+		var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
+		dataDir = dirService.get("ProfD", Ci.nsILocalFile);
 		dataDir.appendRelativePath(DATA_DIR_NAME);
 
 		return dataDir;
@@ -449,8 +444,7 @@
 	getLogFileAtURL: function(aURLSpec){
 		const LOGS_DIR_NAME = "logs";
 
-		var fromURL = this._ioService.newURI(aURLSpec, null, null)
-								.QueryInterface(Components.interfaces.nsIURL);
+		var fromURL = this._ioService.newURI(aURLSpec, null, null).QueryInterface(Ci.nsIURL);
 
 		var logFile = this.getDataDir();
 		logFile.appendRelativePath(LOGS_DIR_NAME);
@@ -466,17 +460,15 @@
 
 
 	geckoVersionCompare: function(aVersion){
-		var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
-				.getService(Components.interfaces.nsIVersionComparator);
-		var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
-				.getService(Components.interfaces.nsIXULAppInfo);
+		var versionComparator = Cc["@mozilla.org/xpcom/version-comparator;1"]
+				.getService(Ci.nsIVersionComparator);
+		var appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
 		return versionComparator.compare(aVersion, appInfo.platformVersion);
 	},
 
 
 	readLocalURI: function(aURISpec){
-		var	localURI = Components.classes["@mozilla.org/network/simple-uri;1"]
-							.createInstance(Components.interfaces.nsIURI);
+		var	localURI = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
 		localURI.spec = aURISpec;
 		localURI = this._ioService.getProtocolHandler(localURI.scheme)
 										.newURI(localURI.spec, null, null);
@@ -488,8 +480,8 @@
 		    }
 		};
 		var stream	= channel.open();
-		var scriptableStream = Components.classes['@mozilla.org/scriptableinputstream;1']
-						.createInstance(Components.interfaces.nsIScriptableInputStream);
+		var scriptableStream = Cc['@mozilla.org/scriptableinputstream;1']
+						.createInstance(Ci.nsIScriptableInputStream);
 		scriptableStream.init(stream);
 
 		var fileContents = scriptableStream.read(scriptableStream.available());
@@ -502,10 +494,10 @@
 
 
 	readFile: function(aFilePath){
-		var fileInputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-					.createInstance(Components.interfaces.nsIFileInputStream);
-		var scriptableInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
-					.createInstance(Components.interfaces.nsIScriptableInputStream);
+		var fileInputStream = Cc["@mozilla.org/network/file-input-stream;1"]
+					.createInstance(Ci.nsIFileInputStream);
+		var scriptableInputStream = Cc["@mozilla.org/scriptableinputstream;1"]
+					.createInstance(Ci.nsIScriptableInputStream);
 		try{
 			var localFile = this._createLocalFile(aFilePath);
 			fileInputStream.init(localFile, 0x01, 0666, 0);
@@ -523,13 +515,13 @@
 	readFileLine: function(aFilePath, aCount){
 		var fileLines = new Array();
 
-		var fileInputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-					.createInstance(Components.interfaces.nsIFileInputStream);
+		var fileInputStream = Cc["@mozilla.org/network/file-input-stream;1"]
+					.createInstance(Ci.nsIFileInputStream);
 		try{
 			var localFile = this._createLocalFile(aFilePath);
 				// 0x01=PR_RDONLY;
 			fileInputStream.init(localFile, 0x01, 0666, 0);
-			fileInputStream.QueryInterface(Components.interfaces.nsILineInputStream);
+			fileInputStream.QueryInterface(Ci.nsILineInputStream);
 
 			var more;
 			var line = {};
@@ -545,8 +537,8 @@
 	},
 
 	writeFile: function(aFilePath, aContent, aAppend){
-		var fileOutputStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
-						.createInstance(Components.interfaces.nsIFileOutputStream);
+		var fileOutputStream = Cc["@mozilla.org/network/file-output-stream;1"]
+						.createInstance(Ci.nsIFileOutputStream);
 		try{
 			var localFile = this._createLocalFile(aFilePath);
 				// nsILocalFIle.create は親フォルダをふくめて作成する
@@ -571,17 +563,17 @@
 		var proxyMode = this.pref.getIntPref("extensions.bbs2chreader.http_proxy_mode");
 		if(proxyMode != 0){
 			var httpProtocolHandler = this._ioService.getProtocolHandler("http")
-					.QueryInterface(Components.interfaces.nsIHttpProtocolHandler);
-			var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"]
-                    .getService(Components.interfaces.nsIProtocolProxyService);
+					.QueryInterface(Ci.nsIHttpProtocolHandler);
+			var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"]
+                    .getService(Ci.nsIProtocolProxyService);
 			if(proxyMode == 1){
 				var proxyInfo = pps.newProxyInfo("direct", "", -1, 0, 0, null);
 				httpChannel = httpProtocolHandler.newProxiedChannel(aURL, proxyInfo)
-						.QueryInterface(Components.interfaces.nsIHttpChannel);
+						.QueryInterface(Ci.nsIHttpChannel);
 			}else if(proxyMode == 2){
 					var httpProxyValue = this.pref.getComplexValue(
 							"extensions.bbs2chreader.http_proxy_value",
-								Components.interfaces.nsISupportsString).data;
+								Ci.nsISupportsString).data;
 					httpProxyValue = httpProxyValue.replace(/\s/g, "");
 					if(httpProxyValue.match(/([^:]+):(\d+)/)){
 						var host = RegExp.$1;
@@ -590,7 +582,7 @@
 							var proxyInfo = pps.newProxyInfo("http", host, port, 0, 10,
 									pps.newProxyInfo("direct", "", -1, 0, 0, null));
 							httpChannel = httpProtocolHandler.newProxiedChannel(aURL, proxyInfo)
-								.QueryInterface(Components.interfaces.nsIHttpChannel);
+								.QueryInterface(Ci.nsIHttpChannel);
 						}catch(ex){dump(ex)}
 					}
 			}
@@ -598,7 +590,7 @@
 
 		if(!httpChannel){
 			httpChannel = this._ioService.newChannelFromURI(aURL)
-					.QueryInterface(Components.interfaces.nsIHttpChannel);
+					.QueryInterface(Ci.nsIHttpChannel);
 		}
 
 		httpChannel.setRequestHeader("User-Agent", this.userAgent, false);
@@ -613,8 +605,7 @@
 
 
 	_createLocalFile: function(aFilePath){
-		var localFile = Components.classes["@mozilla.org/file/local;1"]
-						.createInstance(Components.interfaces.nsILocalFile);
+		var localFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
 		localFile.initWithPath(aFilePath);
 		return localFile;
 	},
@@ -646,14 +637,14 @@
 			this._maruSessionID = this.pref.getCharPref("extensions.bbs2chreader.maru_session_id");
 
 			dump("nsBbs2chService: 2ch Viewer Auth SKIP\n");
-			var os = Components.classes["@mozilla.org/observer-service;1"]
-						.getService(Components.interfaces.nsIObserverService);
+			var os = Cc["@mozilla.org/observer-service;1"]
+						.getService(Ci.nsIObserverService);
 			os.notifyObservers(null, "b2r-2ch-viewer-auth", "SKIP");
 			return;
 		}
 
-		var timer = Components.classes["@mozilla.org/timer;1"]
-						.createInstance(Components.interfaces.nsITimer);
+		var timer = Cc["@mozilla.org/timer;1"]
+						.createInstance(Ci.nsITimer);
 		var timerCallback = {};
 		timerCallback._context = this;
 		timerCallback.observe = function(aTimer){
@@ -669,15 +660,15 @@
 		var maruPass = this.pref.getCharPref("extensions.bbs2chreader.maru_password");
 
 		var maruAuthURL = this._ioService.newURI(maruAuthURLSpec, null, null)
-				.QueryInterface(Components.interfaces.nsIURL);
+				.QueryInterface(Ci.nsIURL);
 		var httpChannel = this.getHttpChannel(maruAuthURL);
 		httpChannel.setRequestHeader("User-Agent", "DOLIB/1.00", false);
 		httpChannel.setRequestHeader("X-2ch-UA", this.userAgent, false);
 		httpChannel.setRequestHeader("Content-Type",
 					"application/x-www-form-urlencoded", false);
-		httpChannel = httpChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
-		var strIStream = Components.classes["@mozilla.org/io/string-input-stream;1"]
-							.createInstance(Components.interfaces.nsIStringInputStream)
+		httpChannel = httpChannel.QueryInterface(Ci.nsIUploadChannel);
+		var strIStream = Cc["@mozilla.org/io/string-input-stream;1"]
+							.createInstance(Ci.nsIStringInputStream)
 		var postString = String("ID=" + maruID + "&PW=" + maruPass);
 		strIStream.setData(postString, postString.length);
 		httpChannel.setUploadStream(strIStream, "application/x-www-form-urlencoded", -1);
@@ -685,8 +676,8 @@
 
 		var listener = {
 			onStartRequest: function(aRequest, aContext){
-				this._bInputStream = Components.classes["@mozilla.org/binaryinputstream;1"]
-							.createInstance(Components.interfaces.nsIBinaryInputStream);
+				this._bInputStream = Cc["@mozilla.org/binaryinputstream;1"]
+							.createInstance(Ci.nsIBinaryInputStream);
 				this._data = new Array();
 			},
 			onDataAvailable: function (aRequest, aContext, aInputStream, aOffset, aCount){
@@ -715,8 +706,8 @@
 		this.pref.setIntPref("extensions.bbs2chreader.maru_last_auth_time", nowTime);
 		dump("nsBbs2chService: 2ch Viewer Auth OK\n");
 
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"]
+					.getService(Ci.nsIObserverService);
 		os.notifyObservers(null, "b2r-2ch-viewer-auth", "OK");
 	},
 
@@ -726,13 +717,13 @@
 		dump(this.maruSessionID + "\n");
 		dump("nsBbs2chService: 2ch Viewer Auth NG\n");
 
-		var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
-	            .getService(Components.interfaces.nsIAlertsService);
+		var alertsService = Cc["@mozilla.org/alerts-service;1"]
+	            .getService(Ci.nsIAlertsService);
 		alertsService.showAlertNotification("", "bbs2chreader",
 				"Login failed on 2ch Viewer", false, "", null);
 
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"]
+					.getService(Ci.nsIObserverService);
 		os.notifyObservers(null, "b2r-2ch-viewer-auth", "NG");
 	},
 
@@ -750,8 +741,8 @@
   	// ********** ********* implements nsIObserver ********** **********
 
 	observe: function(aSubject, aTopic, aData){
-		var os = Components.classes["@mozilla.org/observer-service;1"]
-					.getService(Components.interfaces.nsIObserverService);
+		var os = Cc["@mozilla.org/observer-service;1"]
+					.getService(Ci.nsIObserverService);
 		switch(aTopic){
 			case "app-startup":
 				os.addObserver(this, "final-ui-startup", false);
@@ -778,10 +769,10 @@
 		return Components.ID("{4b76cc9e-04ed-4966-af22-5cc5dbdca0eb}");
 	},
 	get implementationLanguage() {
-		return Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT;
+		return Ci.nsIProgrammingLanguage.JAVASCRIPT;
 	},
 	get flags() {
-		return Components.interfaces.nsIClassInfo.SINGLETON;
+		return Ci.nsIClassInfo.SINGLETON;
 	},
 	get contractID() {
     	return "@mozilla.org/bbs2ch-service;1";
@@ -789,10 +780,10 @@
 
 	getInterfaces: function(aCount) {
 	    var interfaces = [
-			Components.interfaces.nsIBbs2chService,
-			Components.interfaces.nsIClassInfo,
-			Components.interfaces.nsIObserver,
-			Components.interfaces.nsISupports
+			Ci.nsIBbs2chService,
+			Ci.nsIClassInfo,
+			Ci.nsIObserver,
+			Ci.nsISupports
 		];
 	    aCount.value = interfaces.length;
     	return interfaces;
@@ -803,10 +794,10 @@
 	},
 
 	QueryInterface: function(aIID){
-		if(aIID.equals(Components.interfaces.nsIBbs2chService) ||
-				aIID.equals(Components.interfaces.nsIClassInfo) ||
-				aIID.equals(Components.interfaces.nsIObserver) ||
-				aIID.equals(Components.interfaces.nsISupports)){
+		if(aIID.equals(Ci.nsIBbs2chService) ||
+				aIID.equals(Ci.nsIClassInfo) ||
+				aIID.equals(Ci.nsIObserver) ||
+				aIID.equals(Ci.nsISupports)){
 			return this;
 		}
 		throw Components.results.NS_ERROR_NO_INTERFACE;
@@ -824,13 +815,13 @@
 		if(aOuter != null)
 			throw Components.results.NS_ERROR_NO_AGGREGATION;
 
-		if(aIID.equals(Components.interfaces.nsIBbs2chService))
+		if(aIID.equals(Ci.nsIBbs2chService))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIClassInfo))
+		if(aIID.equals(Ci.nsIClassInfo))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsIObserver))
+		if(aIID.equals(Ci.nsIObserver))
 			return this.getInstance(aIID);
-		if(aIID.equals(Components.interfaces.nsISupports))
+		if(aIID.equals(Ci.nsISupports))
 			return this.getInstance(aIID);
 
 		throw Components.results.NS_ERROR_INVALID_ARG;
@@ -853,21 +844,21 @@
 
 
 	registerSelf: function(aCompMgr, aFileSpec, aLocation, aType){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 		aCompMgr.registerFactoryLocation(this.CID, this.CNAME, this.CONTRACTID,
 											aFileSpec, aLocation, aType);
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.addCategoryEntry("app-startup", this.CONTRACTID,
 											this.CONTRACTID, true, true);
 	},
 
 
 	unregisterSelf: function(aCompMgr, aFileSpec, aLocation){
-		aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
 
-		var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
-					.getService(Components.interfaces.nsICategoryManager);
+		var categoryManager = Cc["@mozilla.org/categorymanager;1"]
+					.getService(Ci.nsICategoryManager);
 		categoryManager.deleteCategoryEntry("app-startup", this.CONTRACTID, true);
 	},
 
@@ -876,7 +867,7 @@
 		if(aCID.equals(this.CID))
 			return Factory;
 
-		if(!aIID.equals(Components.interfaces.nsIFactory))
+		if(!aIID.equals(Ci.nsIFactory))
 			throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
 		throw Components.results.NS_ERROR_NO_INTERFACE;


bbs2ch-cvs メーリングリストの案内
Back to archive index