1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-11 03:25:07 -05:00

* fix (Chat) imports for Thunderbird

* fix Window.attachWndProc

NOTE: WndProc crashes fixed in TB27+
This commit is contained in:
foudfou 2014-02-07 00:17:17 +01:00
parent 42a8dac1ed
commit 20d137bd28
4 changed files with 33 additions and 17 deletions

View File

@ -21,15 +21,15 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- Firefox -->
<em:minVersion>7.0</em:minVersion>
<em:maxVersion>27.0</em:maxVersion>
<em:maxVersion>30.0</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication> <!-- Thunderbird -->
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>7.0</em:minVersion>
<em:maxVersion>27.0</em:maxVersion>
<em:minVersion>27.0</em:minVersion>
<em:maxVersion>30.0</em:maxVersion>
</Description>
</em:targetApplication>

View File

@ -8,8 +8,6 @@ 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");
@ -24,10 +22,21 @@ firetray.Chat = {
init: function() {
if (this.initialized) {
log.warn("Chat already initialized");
return;
return true;
}
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",
@ -42,10 +51,11 @@ firetray.Chat = {
this.updateIcon();
this.initialized = true;
return true;
},
shutdown: function() {
if (!this.initialized) return;
if (!this.initialized) return false;
log.debug("Disabling Chat");
if (firetray.Chat.convsToAcknowledge.length())
@ -55,6 +65,7 @@ firetray.Chat = {
firetray.Utils.removeAllObservers(firetray.Chat);
this.initialized = false;
return true;
},
// FIXME: the listener should probably attached on the conv entry in the

View File

@ -85,7 +85,7 @@ firetray.Handler = {
log.debug('FiretrayWindow WINNT imported');
break;
default:
log.error("FIRETRAY: only Linux and WINNT platforms supported at this"
log.error("Only Linux and WINNT platforms supported at this"
+ "time. Firetray not loaded");
return false;
}

View File

@ -71,11 +71,11 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow
return user32.CallWindowProcW(procPrev, hWnd, uMsg, wParam, lParam);
};
firetray.Window.attachWndProc = function(wid) {
firetray.Window.attachWndProc = function(wid, hwnd) {
try {
let wndProc = user32.WNDPROC(firetray.Window.wndProc);
log.debug("proc="+wndProc);
this.wndProcs.insert(wid, wndProc);
firetray.Handler.wndProcs.insert(wid, wndProc);
let procPrev = user32.WNDPROC(
user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC,
ctypes.cast(wndProc, win32.LONG_PTR))
@ -83,14 +83,19 @@ firetray.Window.attachWndProc = function(wid) {
log.debug("procPrev="+procPrev+" winLastError="+ctypes.winLastError);
// we can't store WNDPROC callbacks (JS ctypes objects) with SetPropW(), as
// we need long-living refs.
this.wndProcsOrig.insert(wid, procPrev);
firetray.Handler.wndProcsOrig.insert(wid, procPrev);
} catch (x) {
if (x.name === "RangeError") // instanceof not working :-(
win.alert(x+"\n\nYou seem to have more than "+FIRETRAY_WINDOW_COUNT_MAX
if (x.name === "RangeError") { // instanceof not working :-(
let msg = x+"\n\nYou seem to have more than "+FIRETRAY_WINDOW_COUNT_MAX
+" windows open. This breaks FireTray and most probably "
+firetray.Handler.appName+".");
else win.alert(x);
+firetray.Handler.appName+".";
log.error(msg);
Cu.reportError(msg);
}else {
log.error(x);
Cu.reportError(x);
}
}
}
@ -146,7 +151,7 @@ firetray.Handler.registerWindow = function(win) {
log.debug("window "+wid+" registered");
this.attachWndProc(wid);
firetray.Window.attachWndProc(wid, hwnd);
firetray.Win32.acceptAllMessages(hwnd);
@ -163,7 +168,7 @@ firetray.Handler.unregisterWindow = function(win) {
return false;
}
this.detachWndProc(wid);
firetray.Window.detachWndProc(wid);
if (!delete firetray.Handler.windows[wid])
throw new DeleteError();