[or-cvs] r19747: {torbutton} changed tabbing and did torlogging (torbutton/branches/gsoc2009-koryk/src/components)

koryk at seul.org koryk at seul.org
Sat Jun 20 01:35:53 UTC 2009


Author: koryk
Date: 2009-06-19 21:35:52 -0400 (Fri, 19 Jun 2009)
New Revision: 19747

Modified:
   torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js
Log:
changed tabbing and did torlogging 

Modified: torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js	2009-06-19 21:18:30 UTC (rev 19746)
+++ torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js	2009-06-20 01:35:52 UTC (rev 19747)
@@ -1,37 +1,27 @@
 
 function LOG(text)
 {
-        var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
-        consoleService.logStringMessage(text);
-
+  var logger = Components.classes["@torproject.org/torbutton-logger;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
+  logger.log(text);
 }
 
 
 
-var refObserver = {
-    
+var refObserver = {    
   observe: function(subject, topic, data)
   {
-      if (topic == "http-on-modify-request") {
-
-          LOG("----------------------------> (" + subject + ") mod request");
-
-          var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
-          httpChannel.setRequestHeader("referer", "http://foo.com", false);
-          return;
+    if (topic == "http-on-modify-request") {
+      LOG("----------------------------> (" + subject + ") mod request");
+      var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+      httpChannel.setRequestHeader("referer", "http://foo.com", false);
+      return;
       }
-
-
-      if (topic == "app-startup") {
-
-          LOG("----------------------------> app-startup");
-
-          var os = Components.classes["@mozilla.org/observer-service;1"]
-                             .getService(Components.interfaces.nsIObserverService);
-
-          os.addObserver(this, "http-on-modify-request", false);
-          return;
-      }
+    if (topic == "app-startup") {
+      LOG("----------------------------> app-startup");
+      var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
+      os.addObserver(this, "http-on-modify-request", false);
+      return;
+    }
   },
  
   QueryInterface: function(iid)
@@ -39,82 +29,60 @@
 		if (!iid.equals(Components.interfaces.nsISupports) &&
 			!iid.equals(Components.interfaces.nsIObserver) &&
 			!iid.equals(Components.interfaces.nsISupportsWeakReference))
-			throw Components.results.NS_ERROR_NO_INTERFACE;
-		
+			throw Components.results.NS_ERROR_NO_INTERFACE;		
 		return this;
   }
 };
 
 var myModule = {
     
-    myCID: Components.ID("{65be2be0-ceb4-44c2-91a5-9c75c53430bf}"),
+  myCID: Components.ID("{65be2be0-ceb4-44c2-91a5-9c75c53430bf}"),
+  myProgID: "@torproject.org/torRefSpoofer;1",
+  myName:   "Ref Spoofer Component",
+  registerSelf: function (compMgr, fileSpec, location, type) {
+    var compMgr = compMgr.QueryInterface(Components.interfacesnsIComponentRegistrar);
+    compMgr.registerFactoryLocation(this.myCID,this.myName,this.myProgID,fileSpec,location,type);
+    LOG("----------------------------> registerSelf");
+    var catMgr = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);
+    catMgr.addCategoryEntry("app-startup", this.myName, this.myProgID, true, true);
+  },
+  
+  getClassObject: function (compMgr, cid, iid) {
+    LOG("----------------------------> getClassObject");
+    return this.myFactory;
+  },
 
-    myProgID: "@torproject.org/torRefSpoofer;1",
+  canUnload: function(compMgr) {
+    return true;
+  },    
 
-    myName:   "Ref Spoofer Component",
-    
-    registerSelf: function (compMgr, fileSpec, location, type) {
-
-        var compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
-        compMgr.registerFactoryLocation(this.myCID,
-                                        this.myName,
-                                        this.myProgID,
-                                        fileSpec,
-                                        location,
-                                        type);
-
-
-          LOG("----------------------------> registerSelf");
-
-        var catMgr = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);
-        catMgr.addCategoryEntry("app-startup", this.myName, this.myProgID, true, true);
-    },
-
-
-    getClassObject: function (compMgr, cid, iid) {
-
-          LOG("----------------------------> getClassObject");
-
-        return this.myFactory;
-    },
-
-    canUnload: function(compMgr) {
-        return true;
-    },
-    
-    unregisterSelf: function(compMgr, fileSpec, location)
-    {
+  unregisterSelf: function(compMgr, fileSpec, location) {
 		// Remove the auto-startup
-		  compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
-		  compMgr.unregisterFactoryLocation(this.myCID, fileSpec);
-
-		  var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);
-		  catMan.deleteCategoryEntry("app-startup", this.myProgID, true);
-    },
+		compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+		compMgr.unregisterFactoryLocation(this.myCID, fileSpec);
+    var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);
+		catMan.deleteCategoryEntry("app-startup", this.myProgID, true);
+  },
     
-    getClassObject: function(compMgr, cid, iid)
-    {
+  getClassObject: function(compMgr, cid, iid) {
 		if (!cid.equals(this.myCID))
 			throw Components.results.NS_ERROR_FACTORY_NOT_REGISTERED;
-
 		if (!iid.equals(Components.interfaces.nsIFactory))
 			throw Components.results.NS_ERROR_NO_INTERFACE;
-
 		return this.myFactory;
     },
     
-    myFactory: {
+  myFactory: {
 		// Implement nsIFactory
 		createInstance: function(outer, iid)
 		{
 			if (outer != null)
-				throw Components.results.NS_ERROR_NO_AGGREGATION;
-			
+				throw Components.results.NS_ERROR_NO_AGGREGATION;			
 			return myObserver.QueryInterface(iid);
-	    }
-	 }    
+    }
+  }    
 };
 
 function NSGetModule(compMgr, fileSpec) {
-    return myModule;
+  return myModule;
 }



More information about the tor-commits mailing list