fix log4moz calls (new api), fix module imports for renamed modules
authorDan Mills <thunder@mozilla.com>
Mon, 03 Nov 2008 15:00:38 -0800
changeset 45019 624436d590b7e9384c0d3206cf4ee00530dac182
parent 45018 b82aafc1aa4bc11500beafe3fcc0cf99a529aaaa
child 45020 c5303c449d8b9b683698438f78cf207c97c3b1cf
push idunknown
push userunknown
push dateunknown
fix log4moz calls (new api), fix module imports for renamed modules
services/sync/modules/async.js
services/sync/modules/clientData.js
services/sync/modules/crypto.js
services/sync/modules/engines.js
services/sync/modules/engines/bookmarks.js
services/sync/modules/faultTolerance.js
services/sync/modules/notifications.js
services/sync/modules/oauth.js
services/sync/modules/stores.js
services/sync/modules/syncCores.js
services/sync/modules/trackers.js
services/sync/modules/xmpp/transportLayer.js
services/sync/modules/xmpp/xmppClient.js
--- a/services/sync/modules/async.js
+++ b/services/sync/modules/async.js
@@ -102,17 +102,17 @@ function AsyncException(asyncStack, exce
     toString: function AsyncException_toString() {
       return this._originalException.toString();
     }
   };
 }
 
 function Generator(thisArg, method, onComplete, args) {
   this._outstandingCbs = 0;
-  this._log = Log4Moz.Service.getLogger("Async.Generator");
+  this._log = Log4Moz.repository.getLogger("Async.Generator");
   this._log.level =
     Log4Moz.Level[Utils.prefs.getCharPref("log.logger.async")];
   this._thisArg = thisArg;
   this._method = method;
   this._id = gCurrentId++;
   this.onComplete = onComplete;
   this._args = args;
   this._stackAtLastCallbackGen = null;
--- a/services/sync/modules/clientData.js
+++ b/services/sync/modules/clientData.js
@@ -40,18 +40,17 @@ const EXPORTED_SYMBOLS = ['ClientData'];
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/util.js");
-Cu.import("resource://weave/dav.js");
-Cu.import("resource://weave/remote.js");
+Cu.import("resource://weave/resource.js");
 Cu.import("resource://weave/async.js");
 
 Function.prototype.async = Async.sugar;
 
 Utils.lazy(this, 'ClientData', ClientDataSvc);
 
 function ClientDataSvc() {
   this._init();
@@ -89,17 +88,17 @@ ClientDataSvc.prototype = {
     } catch (e) {
       value = defaultCb();
       Utils.prefs.setCharPref(pref, value);
     }
     return value;
   },
 
   _init: function ClientData__init() {
-    this._log = Log4Moz.Service.getLogger("Service.ClientData");
+    this._log = Log4Moz.repository.getLogger("Service.ClientData");
     this._remote = new Resource("meta/clients");
     this._remote.pushFilter(new JsonFilter());
   },
 
   _wrap: function ClientData__wrap() {
     return {
       GUID: this.GUID,
       name: this.name,
--- a/services/sync/modules/crypto.js
+++ b/services/sync/modules/crypto.js
@@ -79,17 +79,17 @@ CryptoSvc.prototype = {
     return Utils.prefs.getCharPref("encryption");
   },
   set defaultAlgorithm(value) {
     if (value != Utils.prefs.getCharPref("encryption"))
       Utils.prefs.setCharPref("encryption", value);
   },
 
   _init: function Crypto__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
     this._log.level =
       Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.crypto")];
     let branch = Cc["@mozilla.org/preferences-service;1"]
       .getService(Ci.nsIPrefBranch2);
     branch.addObserver("extensions.weave.encryption", this, false);
   },
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupports]),
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -43,18 +43,17 @@ const Cr = Components.results;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/util.js");
 Cu.import("resource://weave/wrap.js");
 Cu.import("resource://weave/crypto.js");
-Cu.import("resource://weave/dav.js");
-Cu.import("resource://weave/remote.js");
+Cu.import("resource://weave/resource.js");
 Cu.import("resource://weave/clientData.js");
 Cu.import("resource://weave/identity.js");
 Cu.import("resource://weave/stores.js");
 Cu.import("resource://weave/syncCores.js");
 Cu.import("resource://weave/trackers.js");
 Cu.import("resource://weave/async.js");
 
 Function.prototype.async = Async.sugar;
@@ -168,17 +167,17 @@ Engine.prototype = {
   },
 
   _init: function Engine__init() {
     let levelPref = "log.logger.service.engine." + this.name;
     let level = "Debug";
     try { level = Utils.prefs.getCharPref(levelPref); }
     catch (e) { /* ignore unset prefs */ }
 
-    this._log = Log4Moz.Service.getLogger("Service." + this.logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this.logName);
     this._log.level = Log4Moz.Level[level];
     this._osPrefix = "weave:" + this.name + ":";
   },
 
   _serializeCommands: function Engine__serializeCommands(commands) {
     let json = this._json.encode(commands);
     //json = json.replace(/ {action/g, "\n {action");
     return json;
@@ -499,18 +498,19 @@ BlobEngine.prototype = {
   // NOTE: a version file will be needed in the future to optimize the case
   //       where there are no changes
   _sync: function BlobEngine__sync() {
     let self = yield;
 
     this._log.info("Beginning sync");
     this._os.notifyObservers(null, "weave:service:sync:engine:start", this.name);
 
-    if (!(yield DAV.MKCOL(this.serverPrefix, self.cb)))
-      throw "Could not create remote folder";
+    // FIXME
+    //if (!(yield DAV.MKCOL(this.serverPrefix, self.cb)))
+    //  throw "Could not create remote folder";
 
     try {
       if ("none" != Utils.prefs.getCharPref("encryption"))
         yield this._keys.getKeyAndIV(self.cb, this.engineId);
       yield this._file.get(self.cb);
       yield this._merge.async(this, self.cb);
       yield this._file.put(self.cb);
 
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -50,29 +50,28 @@ const SERVER_PATH_ANNO = "weave/shared-s
 const KEYRING_FILE_NAME = "keyring";
 const SHARED_BOOKMARK_FILE_NAME = "shared_bookmarks";
 // Information for the folder that contains all incoming shares
 const INCOMING_SHARE_ROOT_ANNO = "weave/mounted-shares-folder";
 const INCOMING_SHARE_ROOT_NAME = "Shared Folders";
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://weave/log4moz.js");
-Cu.import("resource://weave/dav.js");
 Cu.import("resource://weave/util.js");
 Cu.import("resource://weave/crypto.js");
 Cu.import("resource://weave/async.js");
 Cu.import("resource://weave/engines.js");
 Cu.import("resource://weave/syncCores.js");
 Cu.import("resource://weave/stores.js");
 Cu.import("resource://weave/trackers.js");
 Cu.import("resource://weave/identity.js");
 Cu.import("resource://weave/xmpp/xmppClient.js");
 Cu.import("resource://weave/notifications.js");
 Cu.import("resource://weave/sharing.js");
-Cu.import("resource://weave/remote.js");
+Cu.import("resource://weave/resource.js");
 
 Function.prototype.async = Async.sugar;
 
 function BookmarksSharingManager(engine) {
   this._init(engine);
 }
 BookmarksSharingManager.prototype = {
   __annoSvc: null,
@@ -95,17 +94,17 @@ BookmarksSharingManager.prototype = {
   get _myUsername() {
     if (!this.__myUsername)
       this.__myUsername = ID.get('WeaveID').username;
     return this.__myUsername;
   },
 
   _init: function SharingManager__init(engine) {
     this._engine = engine;
-    this._log = Log4Moz.Service.getLogger("Bookmark Share");
+    this._log = Log4Moz.repository.getLogger("Bookmark Share");
     if ( Utils.prefs.getBoolPref( "xmpp.enabled" ) ) {
       this._log.info( "Starting XMPP client for bookmark engine..." );
       this._startXmppClient.async(this);
     }
   },
 
   _startXmppClient: function BmkSharing__startXmppClient() {
     // To be called asynchronously.
@@ -296,18 +295,18 @@ BookmarksSharingManager.prototype = {
      duplicates, but annoys the user by showing notification of ALL
      shares on EVERY sync :(
   */
   getNewShares: function BmkSharing_getNewShares(onComplete) {
     this._getNewShares.async(this, onComplete);
   },
   _getNewShares: function BmkSharing__getNewShares() {
     let self = yield;
-
-    let sharingApi = new Sharing.Api( DAV );
+// FIXME
+//    let sharingApi = new Sharing.Api( DAV );
     let result = yield sharingApi.getShares(self.cb);
 
 		this._log.info("Got Shares: " + result);
 		let shares = result.split(',');
 		if (shares.length > 1) {
 		  this._log.info('Found shares');
 		  for (var i = 0; i < shares.length - 1; i++) {
 		    let share = shares[i].split(':');
@@ -435,17 +434,18 @@ BookmarksSharingManager.prototype = {
 		     + " with " + username);
 
     /* Generate a new GUID to use as the new directory name on the server
        in which we'll store the shared data. */
     let folderGuid = Utils.makeGUID();
 
     /* Create the directory on the server if it does not exist already. */
     let serverPath = "share/" + folderGuid;
-    let ret = yield DAV.MKCOL(serverPath, self.cb);
+// FIXME
+//    let ret = yield DAV.MKCOL(serverPath, self.cb);
 
     if (!ret) {
       this._log.error("Can't create remote folder for outgoing share.");
       self.done(false);
     }
     // TODO more error handling
 
     /* Store the path to the server directory in an annotation on the shared
@@ -458,17 +458,18 @@ BookmarksSharingManager.prototype = {
 
     let encryptionTurnedOn = true;
     if (encryptionTurnedOn) {
       yield this._createKeyChain.async(this, self.cb, serverPath,
 				       this._myUsername, username);
     }
 
     // Call Atul's js api for setting htaccess:
-    let sharingApi = new Sharing.Api( DAV );
+// FIXME
+//    let sharingApi = new Sharing.Api( DAV );
     let result = yield sharingApi.shareWithUsers( serverPath,
 						  [username], folderName,
 						  self.cb );
 		this._log.info(result.errorText);
     // return the server path:
     self.done( serverPath );
   },
 
@@ -1409,17 +1410,17 @@ BookmarksTracker.prototype = {
     this._score += 4;
   },
   /* Changes are worth 2 points? */
   onItemChanged: function BMT_onItemChanged() {
     this._score += 2;
   },
 
   _init: function BMT__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
     this._score = 0;
 
     Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
     getService(Ci.nsINavBookmarksService).
     addObserver(this, false);
   }
 }
 BookmarksTracker.prototype.__proto__ = new Tracker();
--- a/services/sync/modules/faultTolerance.js
+++ b/services/sync/modules/faultTolerance.js
@@ -45,19 +45,19 @@ FaultTolerance = {
   get Service() {
     if (!this._Service)
       this._Service = new FTService();
     return this._Service;
   }
 };
 
 function FTService() {
-  this._log = Log4Moz.Service.getLogger("FaultTolerance");
+  this._log = Log4Moz.repository.getLogger("FaultTolerance");
   this._appender = new FTAppender(this);
-  Log4Moz.Service.rootLogger.addAppender(this._appender);
+  Log4Moz.repository.rootLogger.addAppender(this._appender);
 }
 FTService.prototype = {
   get lastException() this._lastException,
   onMessage: function FTS_onMessage(message) {
     // FIXME: we get all log messages here, and could use them to keep track of
     // our current state
   },
   onException: function FTS_onException(exception) {
--- a/services/sync/modules/notifications.js
+++ b/services/sync/modules/notifications.js
@@ -124,17 +124,17 @@ Notification.prototype.buttons = [];
 /**
  * A button to display in a notification.
  */
 function NotificationButton(label, accessKey, callback) {
   function callbackWrapper() {
     try {
       callback.apply(this, arguments);
     } catch (e) {
-      let logger = Log4Moz.Service.getLogger("Notifications");
+      let logger = Log4Moz.repository.getLogger("Notifications");
       logger.error("An exception occurred: " + Utils.exceptionStr(e));
       logger.info(Utils.stackTrace(e));
       throw e;
     }
   }
 
   this.label = label;
   this.accessKey = accessKey;
--- a/services/sync/modules/oauth.js
+++ b/services/sync/modules/oauth.js
@@ -66,17 +66,17 @@ OAuthSvc.prototype = {
   _cback: null,
   _uid: null,
   _pwd: null,
   _pas: null,
   _cb1: null,
   _cb2: null,
   
   _init: function OAuth__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
     this._log.level = "Debug";
     this._log.info("OAuth Module Initialized");
   },
 
   setToken: function OAuth_setToken(token, cback) {
     this._token = token;
     this._cback = cback;
   },
--- a/services/sync/modules/stores.js
+++ b/services/sync/modules/stores.js
@@ -77,17 +77,17 @@ Store.prototype = {
   get _json() {
     if (!this.__json)
       this.__json = Cc["@mozilla.org/dom/json;1"].
         createInstance(Ci.nsIJSON);
     return this.__json;
   },
 
   _init: function Store__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
   },
 
   applyCommands: function Store_applyCommands(commandList) {
     let self = yield;
 
     for (var i = 0; i < commandList.length; i++) {
       if (this._yieldDuringApply) {
         Utils.makeTimerForCall(self.cb);
@@ -175,17 +175,17 @@ SnapshotStore.prototype = {
     return this._GUID;
   },
   set GUID(GUID) {
     this._GUID = GUID;
   },
 
   _init: function SStore__init(name) {
     this.filename = name;
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
   },
 
   _createCommand: function SStore__createCommand(command) {
     this._data[command.GUID] = Utils.deepCopy(command.data);
   },
 
   _removeCommand: function SStore__removeCommand(command) {
     delete this._data[command.GUID];
--- a/services/sync/modules/syncCores.js
+++ b/services/sync/modules/syncCores.js
@@ -62,17 +62,17 @@ function SyncCore() {
 }
 SyncCore.prototype = {
   _logName: "Sync",
 
   // Set this property in child objects!
   _store: null,
 
   _init: function SC__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
   },
 
   // FIXME: this won't work for deep objects, or objects with optional
   // properties
   _getEdits: function SC__getEdits(a, b) {
     let ret = {numProps: 0, props: {}};
     for (prop in a) {
       if (!Utils.deepEquals(a[prop], b[prop])) {
--- a/services/sync/modules/trackers.js
+++ b/services/sync/modules/trackers.js
@@ -66,17 +66,17 @@ Function.prototype.async = Async.sugar;
 function Tracker() {
   this._init();
 }
 Tracker.prototype = {
   _logName: "Tracker",
   _score: 0,
 
   _init: function T__init() {
-    this._log = Log4Moz.Service.getLogger("Service." + this._logName);
+    this._log = Log4Moz.repository.getLogger("Service." + this._logName);
     this._score = 0;
   },
 
   /* Should be called by service periodically
    * before deciding which engines to sync
    */
   get score() {
     if (this._score >= 100)
--- a/services/sync/modules/xmpp/transportLayer.js
+++ b/services/sync/modules/xmpp/transportLayer.js
@@ -193,17 +193,17 @@ SocketClient.prototype = {
  * identify session by always using set-cookie header with cookie named ID
  * first request sets this to 0 to indicate new session.
  */
 function HTTPPollingTransport( serverUrl, useKeys, interval ) {
   this._init( serverUrl, useKeys, interval );
 }
 HTTPPollingTransport.prototype = {
   _init: function( serverUrl, useKeys, interval ) {
-    this._log = Log4Moz.Service.getLogger("Service.XmppTransportLayer");
+    this._log = Log4Moz.repository.getLogger("Service.XmppTransportLayer");
     this._log.info("Initializing transport: serverUrl=" + serverUrl + ", useKeys=" + useKeys + ", interval=" + interval);
     this._serverUrl = serverUrl
     this._n = 0;
     this._key = this._makeSeed();
     this._latestCookie = "";
     this._connectionId = 0;
     this._callbackObject = null;
     this._useKeys = useKeys;
--- a/services/sync/modules/xmpp/xmppClient.js
+++ b/services/sync/modules/xmpp/xmppClient.js
@@ -66,17 +66,17 @@ XmppClient.prototype = {
   FAILED: -1,
 
   // IQ stanza status codes:
   IQ_WAIT: 0,
   IQ_OK: 1,
   IQ_ERROR: -1,
 
   _init: function( clientName, realm, clientPassword, transport, authenticator ) {
-    this._log = Log4Moz.Service.getLogger("Service.XmppClient");
+    this._log = Log4Moz.repository.getLogger("Service.XmppClient");
     this._myName = clientName;
     this._realm = realm;
     this._fullName = clientName + "@" + realm;
     this._myPassword = clientPassword;
     this._connectionStatus = this.NOT_CONNECTED;
     this._error = null;
     this._streamOpen = false;
     this._transportLayer = transport;