|
@@ -0,0 +1,242 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Ian Neal <iann_cvs@blueyonder.co.uk>
|
|
|
+# Date 1728778539 -3600
|
|
|
+# Parent 281c55ff6f461b24107590e74a018dd6af4ec609
|
|
|
+Bug 1924338 - Inline newObject function in cZ. r=frg a=frg
|
|
|
+
|
|
|
+diff --git a/suite/extensions/irc/js/lib/utils.js b/suite/extensions/irc/js/lib/utils.js
|
|
|
+--- a/suite/extensions/irc/js/lib/utils.js
|
|
|
++++ b/suite/extensions/irc/js/lib/utils.js
|
|
|
+@@ -504,47 +504,16 @@ function renameProperty (obj, oldname, n
|
|
|
+ if (oldname == newname)
|
|
|
+ return;
|
|
|
+
|
|
|
+ obj[newname] = obj[oldname];
|
|
|
+ delete obj[oldname];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+-function newObject(contractID, iface)
|
|
|
+-{
|
|
|
+- var rv;
|
|
|
+- var cls = Components.classes[contractID];
|
|
|
+-
|
|
|
+- if (!cls)
|
|
|
+- return null;
|
|
|
+-
|
|
|
+- switch (typeof iface)
|
|
|
+- {
|
|
|
+- case "undefined":
|
|
|
+- rv = cls.createInstance();
|
|
|
+- break;
|
|
|
+-
|
|
|
+- case "string":
|
|
|
+- rv = cls.createInstance(Components.interfaces[iface]);
|
|
|
+- break;
|
|
|
+-
|
|
|
+- case "object":
|
|
|
+- rv = cls.createInstance(iface);
|
|
|
+- break;
|
|
|
+-
|
|
|
+- default:
|
|
|
+- rv = null;
|
|
|
+- break;
|
|
|
+- }
|
|
|
+-
|
|
|
+- return rv;
|
|
|
+-
|
|
|
+-}
|
|
|
+-
|
|
|
+ function getService(contractID, iface)
|
|
|
+ {
|
|
|
+ var rv;
|
|
|
+ var cls = Components.classes[contractID];
|
|
|
+
|
|
|
+ if (!cls)
|
|
|
+ return null;
|
|
|
+
|
|
|
+diff --git a/suite/extensions/irc/xul/content/about/about.js b/suite/extensions/irc/xul/content/about/about.js
|
|
|
+--- a/suite/extensions/irc/xul/content/about/about.js
|
|
|
++++ b/suite/extensions/irc/xul/content/about/about.js
|
|
|
+@@ -88,24 +88,25 @@ function onLoad()
|
|
|
+ function onUnload()
|
|
|
+ {
|
|
|
+ if (ownerClient)
|
|
|
+ delete ownerClient.aboutDialog;
|
|
|
+ }
|
|
|
+
|
|
|
+ function copyVersion()
|
|
|
+ {
|
|
|
+- const cbID = Components.interfaces.nsIClipboard.kGlobalClipboard;
|
|
|
+- var cb = getService("@mozilla.org/widget/clipboard;1", "nsIClipboard");
|
|
|
+- var tr = newObject("@mozilla.org/widget/transferable;1", "nsITransferable");
|
|
|
+- var str = newObject("@mozilla.org/supports-string;1", "nsISupportsString");
|
|
|
++ var tr = Cc["@mozilla.org/widget/transferable;1"]
|
|
|
++ .createInstance(Ci.nsITransferable);
|
|
|
++ var str = Cc["@mozilla.org/supports-string;1"]
|
|
|
++ .createInstance(Ci.nsISupportsString);
|
|
|
+
|
|
|
++ tr.addDataFlavor("text/unicode");
|
|
|
+ str.data = client.userAgent;
|
|
|
+ tr.setTransferData("text/unicode", str, str.data.length * 2);
|
|
|
+- cb.setData(tr, null, cbID);
|
|
|
++ Services.clipboard.setData(tr, null, Services.clipboard.kGlobalClipboard);
|
|
|
+ }
|
|
|
+
|
|
|
+ function openHomepage()
|
|
|
+ {
|
|
|
+ if (ownerClient)
|
|
|
+ ownerClient.dispatch("goto-url", {url: MSG_SOURCE_REPLY});
|
|
|
+ else
|
|
|
+ window.opener.open(MSG_SOURCE_REPLY, "_blank");
|
|
|
+diff --git a/suite/extensions/irc/xul/content/commands.js b/suite/extensions/irc/xul/content/commands.js
|
|
|
+--- a/suite/extensions/irc/xul/content/commands.js
|
|
|
++++ b/suite/extensions/irc/xul/content/commands.js
|
|
|
+@@ -3555,39 +3555,39 @@ function cmdSave(e)
|
|
|
+ var OutputProgressListener =
|
|
|
+ {
|
|
|
+ onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
|
|
|
+ {
|
|
|
+ // Use this to access onStateChange flags
|
|
|
+ var requestSpec;
|
|
|
+ try
|
|
|
+ {
|
|
|
+- var channel = aRequest.QueryInterface(nsIChannel);
|
|
|
++ var channel = aRequest.QueryInterface(Ci.nsIChannel);
|
|
|
+ requestSpec = channel.URI.spec;
|
|
|
+ }
|
|
|
+ catch (ex) { }
|
|
|
+
|
|
|
+ // Detect end of file saving of any file:
|
|
|
+- if (aStateFlags & nsIWebProgressListener.STATE_STOP)
|
|
|
++ if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
|
|
|
+ {
|
|
|
+ if (aStatus == kErrorBindingAborted)
|
|
|
+ aStatus = 0;
|
|
|
+
|
|
|
+ // We abort saving for all errors except if image src file is
|
|
|
+ // not found
|
|
|
+ var abortSaving = (aStatus != 0 && aStatus != kFileNotFound);
|
|
|
+ if (abortSaving)
|
|
|
+ {
|
|
|
+ // Cancel saving
|
|
|
+ wbp.cancelSave();
|
|
|
+ display(getMsg(MSG_SAVE_ERR_FAILED, aMessage), MT_ERROR);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+- if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK
|
|
|
++ if (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK
|
|
|
+ && wbp.currentState == nsIWBP.PERSIST_STATE_FINISHED)
|
|
|
+ {
|
|
|
+ // Let the user know:
|
|
|
+ pm = [e.sourceObject.viewName, getURLSpecFromFile(file)];
|
|
|
+ display(getMsg(MSG_SAVE_SUCCESSFUL, pm), MT_INFO);
|
|
|
+ }
|
|
|
+ /* Check if we've finished. WebBrowserPersist screws up when we
|
|
|
+ * don't save additional files. Cope when saving html only or
|
|
|
+@@ -3607,36 +3607,34 @@ function cmdSave(e)
|
|
|
+ aMaxSelfProgress, aCurTotalProgress,
|
|
|
+ aMaxTotalProgress) {},
|
|
|
+ onLocationChange: function(aWebProgress, aRequest, aLocation) {},
|
|
|
+ onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {},
|
|
|
+ onSecurityChange: function(aWebProgress, aRequest, state) {},
|
|
|
+
|
|
|
+ QueryInterface: function(aIID)
|
|
|
+ {
|
|
|
+- if (aIID.equals(Components.interfaces.nsIWebProgressListener)
|
|
|
+- || aIID.equals(Components.interfaces.nsISupports)
|
|
|
+- || aIID.equals(Components.interfaces.nsISupportsWeakReference))
|
|
|
++ if (aIID.equals(Ci.nsIWebProgressListener)
|
|
|
++ || aIID.equals(Ci.nsISupports)
|
|
|
++ || aIID.equals(Ci.nsISupportsWeakReference))
|
|
|
+ {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ throw Components.results.NS_NOINTERFACE;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const kFileNotFound = 2152857618;
|
|
|
+ const kErrorBindingAborted = 2152398850;
|
|
|
+
|
|
|
+- const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
|
|
|
+- const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
|
|
+- const nsIChannel = Components.interfaces.nsIChannel;
|
|
|
+-
|
|
|
+- var wbp = newObject("@mozilla.org/embedding/browser/nsWebBrowserPersist;1",
|
|
|
+- nsIWBP);
|
|
|
++ const nsIWBP = Ci.nsIWebBrowserPersist;
|
|
|
++
|
|
|
++ var wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
|
|
|
++ .createInstance(nsIWBP);
|
|
|
+ wbp.progressListener = OutputProgressListener;
|
|
|
+
|
|
|
+ var file, saveType, saveFolder, docToBeSaved, title;
|
|
|
+ var flags, fileType, charLimit;
|
|
|
+ var dialogTitle, rv, pm;
|
|
|
+
|
|
|
+ // We want proper descriptions and no "All Files" option.
|
|
|
+ const TYPELIST = [[MSG_SAVE_COMPLETEVIEW,"*.htm;*.html"],
|
|
|
+diff --git a/suite/extensions/irc/xul/content/static.js b/suite/extensions/irc/xul/content/static.js
|
|
|
+--- a/suite/extensions/irc/xul/content/static.js
|
|
|
++++ b/suite/extensions/irc/xul/content/static.js
|
|
|
+@@ -2011,36 +2011,32 @@ function updateAlertIcon(aToggle) {
|
|
|
+ let state = alertState ? "on" : "off";
|
|
|
+ let icon = window.document.getElementById("alert-status");
|
|
|
+ icon.setAttribute("alertstate", state);
|
|
|
+ icon.setAttribute("tooltiptext", getMsg("msg.alert.icon." + state));
|
|
|
+ }
|
|
|
+
|
|
|
+ function initOfflineIcon()
|
|
|
+ {
|
|
|
+- const PRBool_CID = "@mozilla.org/supports-PRBool;1";
|
|
|
+- const OS_CID = "@mozilla.org/observer-service;1";
|
|
|
+- const nsISupportsPRBool = Components.interfaces.nsISupportsPRBool;
|
|
|
+-
|
|
|
+ client.offlineObserver = {
|
|
|
+ _element: document.getElementById("offline-status"),
|
|
|
+ state: function offline_state()
|
|
|
+ {
|
|
|
+ return (Services.io.offline ? "offline" : "online");
|
|
|
+ },
|
|
|
+ observe: function offline_observe(subject, topic, state)
|
|
|
+ {
|
|
|
+ if ((topic == "offline-requested") &&
|
|
|
+ (client.getConnectionCount() > 0))
|
|
|
+ {
|
|
|
+ var buttonAry = [MSG_REALLY_GO_OFFLINE, MSG_DONT_GO_OFFLINE];
|
|
|
+ var rv = confirmEx(MSG_GOING_OFFLINE, buttonAry);
|
|
|
+ if (rv == 1) // Don't go offline, please!
|
|
|
+ {
|
|
|
+- subject.QueryInterface(nsISupportsPRBool);
|
|
|
++ subject.QueryInterface(Ci.nsISupportsPRBool);
|
|
|
+ subject.data = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (topic == "network:offline-status-changed")
|
|
|
+ {
|
|
|
+ this.updateOfflineUI();
|
|
|
+ }
|
|
|
+ },
|
|
|
+@@ -2061,17 +2057,18 @@ function initOfflineIcon()
|
|
|
+
|
|
|
+ // Actually change the offline state.
|
|
|
+ Services.io.offline = !Services.io.offline;
|
|
|
+ },
|
|
|
+ canGoOffline: function offline_check()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+- var canGoOffline = newObject(PRBool_CID, "nsISupportsPRBool");
|
|
|
++ var canGoOffline = Cc["@mozilla.org/supports-PRBool;1"]
|
|
|
++ .createInstance(Ci.nsISupportsPRBool);
|
|
|
+ Services.obs.notifyObservers(canGoOffline, "offline-requested");
|
|
|
+ // Someone called for a halt
|
|
|
+ if (canGoOffline.data)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch (ex)
|
|
|
+ {
|
|
|
+ dd("Exception when trying to ask if we could go offline:" + ex);
|