-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.js
More file actions
55 lines (49 loc) · 2.06 KB
/
bootstrap.js
File metadata and controls
55 lines (49 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const self = this;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
const gSession = Cc["@mozilla.org/messenger/services/session;1"].getService(Ci.nsIMsgMailSession);
const FolderListenr = Ci.nsIFolderListener;
const window_name = "notifier:notify";
const CHROME_URL = "chrome://notifier/content/alert.xul";
function once(e, name, callback, capture) {
capture = !!capture;
function callback1(evt) {
e.removeEventListener(name, callback1, capture);
return callback.call(this, evt);
}
e.addEventListener(name, callback1, capture);
}
var listener = {
OnItemAdded: function (parent, item) {
if (item instanceof Ci.nsIMsgDBHdr && !item.isRead) {
var win = Services.wm.getMostRecentWindow(window_name);
if (win) {
win.addMessage(item);
} else {
const features = "chrome,dialog=yes,titlebar=no,popup=yes";
//const features = "chrome,dialog=yes,titlebar=no,popup=yes,alwaysRaised";
win = Services.ww.openWindow(null, "chrome://notifier/content/alert.xul", window_name, features, null);
win.screenX = 0x7fff;
win.screenY = 0x7fff;
once(win, "load", function () win.addMessage(item), true);
}
}
},
};
function startup(data, reason) {
var resHandler = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
//resHandler.setSubstitution("notifier", Services.io.newURI("components/", null, data.resourceURI));
Components.manager.addBootstrappedManifestLocation(data.installPath);
gSession.AddFolderListener(listener, FolderListenr.added);
}
function shutdown(data, reason) {
gSession.RemoveFolderListener(listener);
var win = Services.wm.getMostRecentWindow(window_name);
win && win.close();
}
function install(data, reason) {
}
function uninstall(data, reason) {
}