1
0
mirror of https://github.com/moparisthebest/FireTray synced 2025-01-07 19:48:03 -05:00

move linux-ish FiretrayChat.jsm to linux/.

We'll probably create a FiretrayChat.prototype when/if we support chat in
winnt.
This commit is contained in:
foudfou 2014-02-08 16:34:19 +01:00
parent 408116489e
commit 70a362a9e4
5 changed files with 46 additions and 57 deletions

View File

@ -36,11 +36,12 @@ var firetrayUIOptions = {
this.hidePrefPane("pref-pane-mail");
}
if (firetray.Handler.isChatProvided()) {
Cu.import("resource://firetray/FiretrayChat.jsm");
if (firetray.Handler.isChatProvided() &&
FIRETRAY_CHAT_SUPPORTED_OS.indexOf(firetray.Handler.runtimeOS) > -1) {
Cu.import("resource://firetray/"+firetray.Handler.runtimeOS+"/FiretrayChat.jsm");
this.initChatControls();
} else
this.hidePrefPane("pref-pane-chat");
this.hidePrefPane("pref-pane-chat");
this.updateWindowAndIconOptions();
this.updateScrollOptions();

View File

@ -53,7 +53,7 @@ firetray.Handler = {
appName: (function(){return Services.appinfo.name;})(),
xulVer: (function(){return Services.appinfo.platformVersion;})(), // Services.vc.compare(xulVer,"2.0a")>=0
runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(),
runtimeOS: (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin"
runtimeOS: (function(){return Services.appinfo.OS.toLowerCase();})(), // "WINNT", "Linux", "Darwin"
addonRootDir: (function(){
let uri = Services.io.newURI(Components.stack.filename, null, null);
if (uri instanceof Ci.nsIFileURL) {
@ -69,26 +69,15 @@ firetray.Handler = {
// version checked during install, so we shouldn't need to care
log.info("OS=" + this.runtimeOS + ", ABI=" + this.runtimeABI + ", XULrunner=" + this.xulVer);
switch (this.runtimeOS) {
case "Linux":
Cu.import("resource://firetray/linux/FiretrayStatusIcon.jsm");
log.debug('FiretrayStatusIcon Linux imported');
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
log.debug('FiretrayWindow Linux imported');
break;
case "WINNT":
Cu.import("resource://firetray/winnt/FiretrayWin32.jsm");
log.debug('FiretrayWin32 imported');
Cu.import("resource://firetray/winnt/FiretrayStatusIcon.jsm");
log.debug('FiretrayStatusIcon WINNT imported');
Cu.import("resource://firetray/winnt/FiretrayWindow.jsm");
log.debug('FiretrayWindow WINNT imported');
break;
default:
log.error("Only Linux and WINNT platforms supported at this"
+ "time. Firetray not loaded");
if (FIRETRAY_SUPPORTED_OS.indexOf(this.runtimeOS) < 0) {
let platforms = FIRETRAY_SUPPORTED_OS.join(", ");
log.error("Only "+platforms+" platform(s) supported at this time. Firetray not loaded");
return false;
}
Cu.import("resource://firetray/"+this.runtimeOS+"/FiretrayStatusIcon.jsm");
log.debug("FiretrayStatusIcon "+this.runtimeOS+" imported");
Cu.import("resource://firetray/"+this.runtimeOS+"/FiretrayWindow.jsm");
log.debug("FiretrayWindow "+this.runtimeOS+" imported");
if (this.appId === FIRETRAY_APP_DB['thunderbird']['id'] ||
this.appId === FIRETRAY_APP_DB['seamonkey']['id'])
@ -124,13 +113,18 @@ firetray.Handler = {
let chatIsProvided = this.isChatProvided();
log.info('isChatProvided='+chatIsProvided);
if (chatIsProvided) {
Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
Cu.import("resource://firetray/FiretrayChat.jsm");
firetray.Utils.addObservers(firetray.Handler, [
"account-added", "account-removed"]);
if (firetray.Utils.prefService.getBoolPref("chat_icon_enable") &&
this.existsChatAccount())
firetray.Chat.init();
if (FIRETRAY_CHAT_SUPPORTED_OS.indexOf(this.runtimeOS) > -1) {
Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
Cu.import("resource://firetray/"+this.runtimeOS+"/FiretrayChat.jsm");
firetray.Utils.addObservers(firetray.Handler, [
"account-added", "account-removed"]);
if (firetray.Utils.prefService.getBoolPref("chat_icon_enable") &&
this.existsChatAccount())
firetray.Chat.init();
} else {
let platforms = FIRETRAY_CHAT_SUPPORTED_OS.join(", ");
log.error("Only "+platforms+" platform(s) supported at this time. Firetray not loaded");
}
}
firetray.Utils.addObservers(firetray.Handler,
@ -570,13 +564,14 @@ firetray.MailChatPrefListener = new PrefListener(
case 'enabled':
let enableChatCond =
(firetray.Handler.appHasChat &&
firetray.Utils.prefService.getBoolPref("chat_icon_enable"));
firetray.Utils.prefService.getBoolPref("chat_icon_enable") &&
FIRETRAY_CHAT_SUPPORTED_OS.indexOf(this.runtimeOS) > -1);
if (!enableChatCond) return;
if (Services.prefs.getBoolPref("mail.chat.enabled")) {
if (!firetray.Chat) {
Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
Cu.import("resource://firetray/FiretrayChat.jsm");
Cu.import("resource://firetray/linux/FiretrayChat.jsm");
firetray.Utils.addObservers(firetray.Handler, [
"account-added", "account-removed"]);
}

View File

@ -3,20 +3,18 @@
/* for now, logging facilities (imported from logging.jsm) and Services are
automatically provided by this module */
var EXPORTED_SYMBOLS =
[ "firetray", "FIRETRAY_ID", "FIRETRAY_VERSION", "FIRETRAY_PREF_BRANCH",
[ "firetray", "FIRETRAY_VERSION", "FIRETRAY_SUPPORTED_OS",
"FIRETRAY_CHAT_SUPPORTED_OS", "FIRETRAY_ID", "FIRETRAY_PREF_BRANCH",
"FIRETRAY_SPLASH_PAGE", "FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
"FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
"FIRETRAY_NOTIFICATION_MESSAGE_COUNT",
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
"FIRETRAY_IM_STATUS_AVAILABLE", "FIRETRAY_IM_STATUS_AWAY",
"FIRETRAY_IM_STATUS_BUSY", "FIRETRAY_IM_STATUS_OFFLINE",
"FIRETRAY_ACCOUNT_SERVER_TYPE_IM",
"FIRETRAY_DELAY_STARTUP_MILLISECONDS",
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS",
"FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD", "FIRETRAY_MESSAGE_COUNT_TYPE_NEW",
"FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE",
"FIRETRAY_APP_DB" ];
"FIRETRAY_ACCOUNT_SERVER_TYPE_IM", "FIRETRAY_DELAY_STARTUP_MILLISECONDS",
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW", "FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE", "FIRETRAY_APP_DB" ];
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -25,10 +23,12 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://firetray/logging.jsm");
const FIRETRAY_VERSION = "0.4.99"; // needed for sync call of onVersionChange() :(
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
const FIRETRAY_PREF_BRANCH = "extensions.firetray.";
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
const FIRETRAY_VERSION = "0.4.99"; // needed for sync call of onVersionChange() :(
const FIRETRAY_SUPPORTED_OS = ['linux', 'winnt']; // install.rdf sync :(
const FIRETRAY_CHAT_SUPPORTED_OS = ['linux'];
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
const FIRETRAY_PREF_BRANCH = "extensions.firetray.";
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
const FIRETRAY_APPLICATION_ICON_TYPE_THEMED = 0;
const FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM = 1;
@ -144,11 +144,13 @@ firetray.Utils = {
getArrayPref: function(prefStr) {
let arrayPref = this.getObjPref(prefStr);
if (!firetray.js.isArray(arrayPref)) throw new TypeError();
if (!firetray.js.isArray(arrayPref))
throw new TypeError("'"+prefStr+"' preference is not array.");
return arrayPref;
},
setArrayPref: function(prefStr, aArray) {
if (!firetray.js.isArray(aArray)) throw new TypeError();
if (!firetray.js.isArray(aArray))
throw new TypeError("'"+aArray+"' is not array.");
this.setObjPref(prefStr, aArray);
},

View File

@ -8,6 +8,8 @@ const Cu = Components.utils;
Cu.import("resource:///modules/imServices.jsm");
Cu.import("resource://firetray/commons.js");
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
let log = firetray.Logging.getLogger("firetray.Chat");
@ -26,17 +28,6 @@ firetray.Chat = {
}
log.debug("Enabling Chat");
switch (firetray.Handler.runtimeOS) {
case "Linux":
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
break;
default:
log.error("Only Linux platforms supported at this time. " +
"Chat not loaded");
return false;
}
firetray.Utils.addObservers(firetray.Chat, [
// "*", // debugging
"account-connected", "account-disconnected", "idle-time-changed",

View File

@ -71,7 +71,7 @@ firetray.Window.init = function() {
log.error("gtk_check_version="+gtkVersionCheck.readString());
if (firetray.Handler.isChatEnabled()) {
Cu.import("resource://firetray/FiretrayChat.jsm");
Cu.import("resource://firetray/linux/FiretrayChat.jsm");
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
}