2011-07-03 14:05:40 -04:00
|
|
|
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* should contain our business logic in JSM, available through service objects,
|
|
|
|
* and keep chrome scripts limited to handle presentation logic.
|
|
|
|
* http://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management.html
|
|
|
|
*/
|
|
|
|
|
2011-07-05 20:14:17 -04:00
|
|
|
var EXPORTED_SYMBOLS = [ "mozt" ];
|
2011-07-03 14:05:40 -04:00
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
|
|
|
/**
|
2011-07-05 20:14:17 -04:00
|
|
|
* mozt namespace.
|
2011-07-03 14:05:40 -04:00
|
|
|
*/
|
2011-07-05 20:14:17 -04:00
|
|
|
if ("undefined" == typeof(mozt)) {
|
|
|
|
var mozt = {
|
2011-07-03 14:05:40 -04:00
|
|
|
DEBUG_MODE: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2011-07-05 20:14:17 -04:00
|
|
|
mozt.Debug = {
|
|
|
|
_initialized: false,
|
2011-07-03 14:05:40 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Object constructor.
|
|
|
|
*/
|
|
|
|
init: function() {
|
2011-07-05 20:14:17 -04:00
|
|
|
if (this._initialized) return;
|
|
|
|
this._consoleService = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
|
2011-07-05 05:46:55 -04:00
|
|
|
this.dump("Moztray Debug initialized");
|
2011-07-05 20:14:17 -04:00
|
|
|
this._initialized = true;
|
2011-07-03 14:05:40 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Console logging functions */
|
|
|
|
/* NOTE: Web Console inappropriates: doesn't catch all messages */
|
|
|
|
/*
|
|
|
|
* CAUTION: dump() dumpObj() may be stripped from .js files during xpi build.
|
|
|
|
* IT'S IMPORTANT THAT DEBUG CALLS ARE WRITTEN ON A SINGLE LINE !
|
|
|
|
*/
|
|
|
|
dump: function(message) { // Debuging function -- prints to javascript console
|
2011-07-05 20:14:17 -04:00
|
|
|
if(!mozt.DEBUG_MODE) return;
|
|
|
|
this._consoleService.logStringMessage(message);
|
2011-07-03 14:05:40 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
dumpObj: function(obj) {
|
2011-07-05 20:14:17 -04:00
|
|
|
if(!mozt.DEBUG_MODE) return;
|
2011-07-03 14:05:40 -04:00
|
|
|
var str = "";
|
|
|
|
for(i in obj) {
|
|
|
|
try {
|
|
|
|
str += "obj["+i+"]: " + obj[i] + "\n";
|
|
|
|
} catch(e) {
|
|
|
|
str += "obj["+i+"]: Unavailable\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.dump(str);
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
// build it !
|
2011-07-05 20:14:17 -04:00
|
|
|
mozt.Debug.init();
|
2011-07-03 14:05:40 -04:00
|
|
|
|
|
|
|
|
2011-07-05 20:14:17 -04:00
|
|
|
mozt.Utils = {
|
2011-07-03 14:05:40 -04:00
|
|
|
|
|
|
|
prefService: Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
2011-07-05 19:32:36 -04:00
|
|
|
.getBranch("extensions.moztray."),
|
2011-07-03 14:05:40 -04:00
|
|
|
|
|
|
|
};
|