Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Works! Woo!

  • Loading branch information...
commit fac13b28db4250f1c93486aaa000afe54b244f13 1 parent bbe111f
@protz authored
View
148 bootstrap.js
@@ -44,8 +44,10 @@ const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/iteratorUtils.jsm");
+Cu.import("resource:///modules/StringBundle.js"); // for StringBundle
let global = this;
+let Log;
// from wjohnston (cleary for Fennec)
let ResourceRegister = {
@@ -64,33 +66,101 @@ let ResourceRegister = {
.QueryInterface(Ci.nsIResProtocolHandler);
resource.setSubstitution(aName, null);
}
-}
-
-function monkeyPatchWindow(window) {
- // Insert our own global Conversations object
- window.Conversations = {
- // These two belong here, use getMail3Pane().Conversations to access them
- monkeyPatch: null,
- // key: Message-ID
- // value: a list of listeners
- msgListeners: {},
- // key: Gloda Conversation ID
- // value: a list of listeners that have a onDraftChanged method
- draftListeners: {},
-
- // These two are replicated in the case of a conversation tab, so use
- // Conversation._window.Conversations to access the right instance
- currentConversation: null,
- counter: 0,
+};
+
+function monkeyPatchWindow(window, aLater) {
+ let doIt = function () {
+ try {
+ if (window.document.location != "chrome://messenger/content/messenger.xul")
+ return;
+ Log.debug("The window looks like a mail:3pane, monkey-patching...");
+
+ // Insert our own global Conversations object
+ window.Conversations = {
+ // These two belong here, use getMail3Pane().Conversations to access them
+ monkeyPatch: null,
+ // key: Message-ID
+ // value: a list of listeners
+ msgListeners: {},
+ // key: Gloda Conversation ID
+ // value: a list of listeners that have a onDraftChanged method
+ draftListeners: {},
+
+ // These two are replicated in the case of a conversation tab, so use
+ // Conversation._window.Conversations to access the right instance
+ currentConversation: null,
+ counter: 0,
+
+ quickCompose: function () {},
+ };
+
+ // Wow! I love restartless! Now I get to create all the items by hand!
+ let strings = new StringBundle("chrome://conversations/locale/overlay.properties");
+
+ // 1) Get a context menu in the multimessage
+ window.document.getElementById("multimessage").setAttribute("context", "mailContext");
+
+ // 2) View > Conversation View
+ let menuitem = window.document.createElement("menuitem");
+ for each (let [k, v] in Iterator({
+ type: "checkbox",
+ id: "menuConversationsEnabled",
+ label: strings.get("menuConversationsEnabled"),
+ })) menuitem.setAttribute(k, v);
+ let after = window.document.getElementById("viewMessagesMenu");
+ window.document.getElementById("menu_View_Popup").insertBefore(menuitem, after.nextElementSibling);
+
+ // 3) Keyboard shortcut
+ let key = window.document.createElement("key");
+ for each (let [k, v] in Iterator({
+ id: "key_conversationsQuickCompose",
+ key: "n",
+ modifiers: "accel,shift",
+ oncommand: "Conversations.quickCompose();",
+ })) key.setAttribute(k, v);
+ window.document.getElementById("mailKeys").appendChild(key);
+
+ // 4) Tree column
+ let treecol = window.document.createElement("treecol");
+ for each (let [k, v] in Iterator({
+ id: "betweenCol",
+ hidden: "false",
+ flex: "4",
+ label: strings.get("betweenColumnName"),
+ tooltiptext: strings.get("betweenColumnTooltip"),
+ })) treecol.setAttribute(k, v);
+ window.document.getElementById("threadCols").appendChild(treecol);
+ let splitter = window.document.createElement("splitter");
+ splitter.classList.add("tree-splitter");
+ window.document.getElementById("threadCols").appendChild(splitter);
+
+ // We instantiate the Monkey-Patch for the given Conversation object.
+ let monkeyPatch = new MonkeyPatch(window, Conversation);
+ // And then we seize the window and insert our code into it
+ monkeyPatch.apply();
+
+ // Used by the in-stub.html detachTab function
+ window.Conversations.monkeyPatch = monkeyPatch;
+
+ window.Conversations.quickCompose = function () {
+ window.openDialog("chrome://conversations/content/stub.xhtml?quickCompose=1", "", "chrome,width=800,height=600");
+ }
+
+ // The modules below need to be loaded when a window exists.
+ Cu.import("resource://conversations/modules/plugins/enigmail.js");
+ } catch (e) {
+ Log.error(e);
+ dumpCallStack(e);
+ }
};
- // We instantiate the Monkey-Patch for the given Conversation object.
- let monkeyPatch = new MonkeyPatch(window, Conversation);
- // And then we seize the window and insert our code into it
- monkeyPatch.apply();
-
- // Used by the in-stub.html detachTab function
- Conversations.monkeyPatch = monkeyPatch;
+ if (aLater)
+ window.addEventListener("load", function tmp () {
+ window.removeEventListener("load", tmp, false);
+ doIt();
+ }, false);
+ else
+ doIt();
}
function startup(aData, aReason) {
@@ -102,25 +172,24 @@ function startup(aData, aReason) {
Cu.import("resource://conversations/modules/prefs.js", global);
Cu.import("resource://conversations/modules/log.js", global);
- let Log = setupLogging("Conversations.MonkeyPatch");
+ Log = setupLogging("Conversations.MonkeyPatch");
try {
// Import all required plugins. If you create a new plugin, install it here.
- Cu.import("resource://conversations/plugins/glodaAttrProviders.js");
- Cu.import("resource://conversations/plugins/embeds.js");
- Cu.import("resource://conversations/plugins/enigmail.js");
- Cu.import("resource://conversations/plugins/lightning.js");
+ Cu.import("resource://conversations/modules/plugins/glodaAttrProviders.js");
+ Cu.import("resource://conversations/modules/plugins/embeds.js");
+ Cu.import("resource://conversations/modules/plugins/lightning.js");
// Patch all existing windows
for each (let w in fixIterator(Services.wm.getEnumerator("mail:3pane")))
- monkeyPatchWindow(w);
+ monkeyPatchWindow(w, false);
// Patch all future windows
Services.ww.registerNotification({
- observer: function (aSubject, aTopic, aData) {
+ observe: function (aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
aSubject.QueryInterface(Ci.nsIDOMWindow);
- monkeyPatchWindow(aSubject.window);
+ monkeyPatchWindow(aSubject.window, true);
}
},
});
@@ -132,20 +201,7 @@ function startup(aData, aReason) {
"chrome://conversations/content/assistant/assistant.xhtml",
"",
"chrome,width=800,height=500");
-
- // Feedback.
- let nRuns = Prefs.getInt("conversations.nruns");
- if (nRuns == 20)
- Services.ww.openWindow(
- null,
- "chrome://conversations/content/feedback.xhtml",
- "",
- "chrome,width=320,height=550");
-
- Prefs.setInt("conversations.nruns", nRuns + 1);
} catch (e) {
- dump(e+"\n");
- dump(e.stack+"\n");
Log.error(e);
dumpCallStack(e);
}
View
1  chrome.manifest
@@ -1,6 +1,5 @@
content conversations content/
skin conversations classic/1.0 skin/
-resource conversations ./
#locale conversations cs locale/cs/
#locale conversations da locale/da/
View
1  locale/en-US/message.properties
@@ -83,3 +83,4 @@ bzPlaceholder=Click here to comment on the bug...
foundYouTube=Found a link to a YouTube video.
foundGoogleMaps=Found a link to a Google Map.
+
View
3  locale/en-US/overlay.dtd
@@ -1,3 +0,0 @@
-<!ENTITY betweenColumnName "Between">
-<!ENTITY betweenColumnTooltip "Click to sort by participants">
-<!ENTITY menuConversationsEnabled "Conversation View">
View
3  locale/en-US/overlay.properties
@@ -0,0 +1,3 @@
+betweenColumnName=Between
+betweenColumnTooltip=Click to sort by participants
+menuConversationsEnabled=Conversation View
View
2  modules/monkeypatch.js
@@ -569,8 +569,6 @@ MonkeyPatch.prototype = {
// much.
let originalOnSelectedMessagesChanged =
window.MessageDisplayWidget.prototype.onSelectedMessagesChanged;
- window.document.getElementById("tabmail")
- .tabInfo[0].messageDisplay.onSelectedMessagesChanged =
window.MessageDisplayWidget.prototype.onSelectedMessagesChanged =
function _onSelectedMessagesChanged_patched () {
if (!Prefs.enabled) {
View
40 modules/prefs.js
@@ -5,6 +5,8 @@ const Cc = Components.classes;
const Cu = Components.utils;
const Cr = Components.results;
+Cu.import("resource://gre/modules/Services.jsm");
+
const prefsService = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
.getBranch("conversations.");
@@ -14,7 +16,45 @@ const gPrefBranch = Cc["@mozilla.org/preferences-service;1"]
const kStubUrl = "chrome://conversations/content/stub.xhtml";
+// That's why I'm lovin' restartless.
+function loadDefaultPrefs () {
+ // nsIPrefBranch2 is going away in Gecko 13 (I think)
+ let prefs = Services.prefs.QueryInterface(Ci.nsIPrefBranch2);
+ // All code below hamelessly stolen from the SDK
+ let branch = prefs.getDefaultBranch("");
+ let prefLoaderScope = {
+ pref: function(key, val) {
+ switch (typeof val) {
+ case "boolean":
+ branch.setBoolPref(key, val);
+ break;
+ case "number":
+ branch.setIntPref(key, val);
+ break;
+ case "string":
+ branch.setCharPref(key, val);
+ break;
+ }
+ }
+ };
+
+ let uri = Services.io.newURI(
+ "defaults/preferences/defaults.js",
+ null,
+ Services.io.newURI("resource://conversations/", null, null));
+
+ // if there is a prefs.js file, then import the default prefs
+ if (uri.QueryInterface(Ci.nsIFileURL).file.exists()) {
+ // setup default prefs
+ Services.scriptloader.loadSubScript(uri.spec, prefLoaderScope);
+ } else {
+ dump("No file found at "+uri.spec+"\n");
+ }
+}
+
function PrefManager() {
+ loadDefaultPrefs();
+
this.expand_who = prefsService.getIntPref("expand_who");
this.no_friendly_date = prefsService.getBoolPref("no_friendly_date");
this.logging_enabled = prefsService.getBoolPref("logging_enabled");
Please sign in to comment.
Something went wrong with that request. Please try again.