Browse Source

Handle arguments of newmailalert.xhtml/xul generically so it also works in TB 91 (bug 1715713).

master
Jörg Knobloch 11 months ago
parent
commit
159ac4b9c7
2 changed files with 41 additions and 25 deletions
  1. +39
    -23
      addon/content/pEpForThunderbird.js
  2. +2
    -2
      addon/experiments.js

+ 39
- 23
addon/content/pEpForThunderbird.js View File

@ -64,7 +64,7 @@ class pEpForThunderbird extends pEp {
this.clientID = null;
this.protectSubjects = true;
this.isControllerAlert = false;
this.alertFolder = null;
this.alertArguments = null;
this.passphrasePromptActive = false;
this.pEpFolderCleanupTimer = null;
@ -528,30 +528,46 @@ class pEpForThunderbird extends pEp {
}
this.msgQueueProcessing = false;
this.log.debug(`Done processing queue, length is ${this.msgQueue.length}`);
if (hasEntries && this.isControllerAlert && this.alertFolder) {
if (hasEntries && this.isControllerAlert && this.alertArguments) {
this.log.info("Launching alert window");
if (this.MOZ_APP_VERSION >= 88) {
Services.ww.openWindow(
null,
"chrome://messenger/content/newmailalert.xhtml",
"_blank",
"chrome,dialog=yes,titlebar=no,popup=yes",
this.alertFolder,
);
} else {
let folderArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
folderArray.appendElement(this.alertFolder);
Services.ww.openWindow(
null,
this.MOZ_APP_VERSION >= 73
? "chrome://messenger/content/newmailalert.xhtml"
: "chrome://messenger/content/newmailalert.xul",
"_blank",
"chrome,dialog=yes,titlebar=no,popup=yes",
folderArray, null, false, 0,
);
// Copy the arguments to a new array in a generic fashion so we don't have to adjust every time
// Thunderbird changes this. Last change in https://bugzilla.mozilla.org/show_bug.cgi?id=1715713.
let args = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
for (let i = 0; i < this.alertArguments.length; i++) {
let v;
switch (this.alertArguments[i].constructor.name) {
case "Object":
args.appendElement(this.alertArguments[i]);
break;
case "Number":
v = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32);
v.data = this.alertArguments[i];
args.appendElement(v);
break;
case "Boolean":
v = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
v.data = this.alertArguments[i];
args.appendElement(v);
break;
case "String":
v = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
v.data = this.alertArguments[i];
args.appendElement(v);
break;
default:
}
}
this.alertFolder = null; // Done with this folder.
Services.ww.openWindow(
null,
this.MOZ_APP_VERSION >= 73
? "chrome://messenger/content/newmailalert.xhtml"
: "chrome://messenger/content/newmailalert.xul",
"_blank",
"chrome,dialog=yes,titlebar=no,popup=yes",
args,
);
this.alertArguments = null; // Done with these.
}
});
}


+ 2
- 2
addon/experiments.js View File

@ -297,10 +297,10 @@ function paint(win) {
pEpController.log.info(`Alert window was ${pEpController.isControllerAlert ? "" : "NOT "}lauched by the controller`);
if (pEpController.isControllerAlert) {
pEpController.isControllerAlert = false;
pEpController.alertFolder = null;
pEpController.alertArguments = null;
} else {
pEpController.isControllerAlert = true;
pEpController.alertFolder = win.arguments[0];
pEpController.alertArguments = win.arguments;
win.onAlertLoad = () => null;
win.close();
}


Loading…
Cancel
Save