# HG changeset patch # User Ian Neal # Date 1619127377 -3600 # Parent bd0f381a5beb55bbef1d48610c03d4be7eeb3bbe Bug 1707111 - Remove host app checks from chatZilla. r=frg a=frg diff --git a/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties b/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties --- a/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties +++ b/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties @@ -75,23 +75,16 @@ msg.confirm = Confirm # # All localised strings may contain certain entities for branding purposes. # The three standard brand entities (brandShortName, brandFullName, vendorName) # can all be used like this: # foo.bar = Some text used in &brandFullName;! # ### End of notes ### -cmd.add-ons.label = Add-ons -cmd.add-ons.help = -cmd.jsconsole.label = JavaScript Console -cmd.jsconsole.help = -cmd.about-config.label = Advanced Configuration -cmd.about-config.help = - cmd.about.label = About ChatZilla cmd.about.help = Display information about this version of ChatZilla. cmd.alias.params = [ []] cmd.alias.help = Defines as an alias for the semicolon (';') delimited list of commands specified by . If is a minus ('-') character, the alias will be removed; if omitted, the alias will be displayed. If is not provided, all aliases will be listed. cmd.attach.params = cmd.attach.help = Attaches to the IRC URL specified by . If you are already attached, the view for is made current. If that view has been deleted, it is recreated. You may omit the irc:// portion of the . Examples are; /attach freenode, /attach freenode/firefox and /attach irc.freenode.net/SeaMonkey,isnick. @@ -772,17 +765,16 @@ msg.err.no.default = Please do not ju msg.err.no.match = No match for ``%S''. msg.err.no.socket = Error creating socket. msg.err.no.secure = The network ``%S'' has no secure servers defined. msg.err.cancelled = Connection process canceled. msg.err.offline = &brandShortName; is in ``offline mode''. No network connections can be made in this mode. msg.err.badalias = Malformed alias: %S" msg.err.no.ctcp.cmd = %S is not a valid CTCP function for this client msg.err.no.ctcp.help = %S does not have any help information -msg.err.unknown.host = The host application UID "%S" is not recognised. Please report what application you are running ChatZilla in, and the UID given. msg.err.unable.to.print = The current view does not support printing. msg.err.unsupported.command = The server does not support the ``%S'' command. msg.err.invalid.mode = The mode string you entered (``%S'') is invalid. A valid mode string consists of one or more sequences of a + or - followed by one or more alphabetical characters. msg.err.away.save = Saving the list of away messages failed (%S). msg.err.inputhistory.not.writable = Unable to save input history to ``%S''. msg.err.urls.not.writable = Unable to save URL log to ``%S''. msg.err.invalid.url = ``%S'' is not a valid url nor an alias for a url, and therefore could not be loaded. msg.err.no.channel = When running the ``%S'' command, you should either provide a channel name, or run the command in the context of a channel. 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 @@ -217,20 +217,16 @@ function initCommands() ["motif-dark", "motif dark", 0], ["motif-light", "motif light", 0], ["sync-output", "evalsilent syncOutputFrame(this)", 0], ["userlist", "toggle-ui userlist", CMD_CONSOLE], ["tabstrip", "toggle-ui tabstrip", CMD_CONSOLE], ["statusbar", "toggle-ui status", CMD_CONSOLE], ["header", "toggle-ui header", CMD_CONSOLE], - ["add-ons", cmdAddons, 0], - ["jsconsole", cmdJSConsole, 0], - ["about-config", cmdAboutConfig, 0], - // text-direction aliases ["rtl", "text-direction rtl", CMD_CONSOLE], ["ltr", "text-direction ltr", CMD_CONSOLE], ["toggle-text-dir", "text-direction toggle", 0], ["irtl", "input-text-direction rtl", CMD_CONSOLE], ["iltr", "input-text-direction ltr", CMD_CONSOLE], // Services aliases ["cs", "quote cs", 0], @@ -2196,17 +2192,17 @@ function cmdGotoURL(e) dispatch(e.command.name + " " + getMsg(localeURLKey) + hash); else display(getMsg(MSG_ERR_INVALID_URL, e.url), MT_ERROR); dispatch("focus-input"); return; } - if ((e.command.name == "goto-url-external") || (client.host == "XULRunner")) + if ((e.command.name == "goto-url-external")) { const extProtoSvc = getService(EXT_PROTO_SVC, "nsIExternalProtocolService"); extProtoSvc.loadUrl(uri); dispatch("focus-input"); return; } @@ -2247,22 +2243,17 @@ function cmdGotoURL(e) dd(formatException(ex)); } } if (action == "goto-url-newtab") { try { - if (typeof browserWin.openUILinkIn == "function") - browserWin.openUILinkIn(e.url, "tab"); - else if (client.host == "Mozilla") - browserWin.openNewTabWith(e.url, false, false); - else - browserWin.openNewTabWith(e.url, null, null, null, null); + browserWin.openUILinkIn(e.url, "tab"); } catch (ex) { dd(formatException(ex)); } dispatch("focus-input"); return; } @@ -4638,25 +4629,8 @@ function cmdWebSearch(e) } else { searchText = encodeURIComponent(searchText).replace(/%20/g, "+"); searchURL = "https://www.google.com/search?q=" + searchText; } dispatch(client.prefs["messages.click"], {url: searchURL}); } - -function cmdAddons(e) -{ - toOpenWindowByType("Addons:Manager", - "chrome://mozapps/content/extensions/extensions.xul"); -} - -function cmdJSConsole(e) -{ - toOpenWindowByType("global:console", "chrome://global/content/console.xul"); -} - -function cmdAboutConfig(e) -{ - toOpenWindowByType("Preferences:ConfigManager", - "chrome://global/content/config.xul"); -} diff --git a/suite/extensions/irc/xul/content/handlers.js b/suite/extensions/irc/xul/content/handlers.js --- a/suite/extensions/irc/xul/content/handlers.js +++ b/suite/extensions/irc/xul/content/handlers.js @@ -573,17 +573,16 @@ function onWindowKeyPress(e) var userList = document.getElementById("user-list"); var elemFocused = document.commandDispatcher.focusedElement; const isMac = client.platform == "Mac"; const isLinux = client.platform == "Linux"; const isWindows = client.platform == "Windows"; const isOS2 = client.platform == "OS/2"; const isUnknown = !(isMac || isLinux || isWindows || isOS2); - const isSuite = client.host == "Mozilla"; switch (code) { case 9: /* Tab */ // Control-Tab => next tab (all platforms) // Control-Shift-Tab => previous tab (all platforms) if (e.ctrlKey && !e.altKey && !e.metaKey) { @@ -694,23 +693,17 @@ function onWindowKeyPress(e) var modifier = (e.altKey ? 0x1 : 0) | (e.ctrlKey ? 0x2 : 0) | (e.shiftKey ? 0x4 : 0) | (e.metaKey ? 0x8 : 0); var modifierMask; if (client.prefs["tabGotoKeyModifiers"]) modifierMask = client.prefs["tabGotoKeyModifiers"]; - else if (!isSuite && isMac) - modifierMask = 0x8; // meta - else if (!isSuite && (isLinux || isOS2)) - modifierMask = 0x1; // alt - else if (!isSuite && (isWindows || isUnknown)) - modifierMask = 0x2; // control - else if (isSuite) + else modifierMask = 0x1; // alt if ((modifier & modifierMask) == modifierMask) { // Pressing 1-8 takes you to that tab, while pressing 9 takes you // to the last tab always. if (idx == 8) idx = client.viewsArray.length - 1; diff --git a/suite/extensions/irc/xul/content/menus.js b/suite/extensions/irc/xul/content/menus.js --- a/suite/extensions/irc/xul/content/menus.js +++ b/suite/extensions/irc/xul/content/menus.js @@ -71,28 +71,16 @@ function initMenus() // OS values var Win = "(client.platform == 'Windows')"; var NotWin = "(client.platform != 'Windows')"; var Linux = "(client.platform == 'Linux')"; var NotLinux = "(client.platform != 'Linux')"; var Mac = "(client.platform == 'Mac')"; var NotMac = "(client.platform != 'Mac')"; - // Platform values - var Mozilla = "(client.host == 'Mozilla')"; - var NotMozilla = "(client.host != 'Mozilla')"; - var Toolkit = NotMozilla; - var XULRunner = "(client.host == 'XULRunner')"; - - // Useful combinations - var ToolkitOnLinux = "(" + Toolkit + " and " + Linux + ")"; - var ToolkitNotOnLinux = "(" + Toolkit + " and " + NotLinux + ")"; - var ToolkitOnMac = "(" + Toolkit + " and " + Mac + ")"; - var ToolkitNotOnMac = "(" + Toolkit + " and " + NotMac + ")"; - // IRC specific values var ViewClient = "(cx.TYPE == 'IRCClient')"; var ViewNetwork = "(cx.TYPE == 'IRCNetwork')"; var ViewChannel = "(cx.TYPE == 'IRCChannel')"; var ViewUser = "(cx.TYPE == 'IRCUser')"; var ViewDCC = "(cx.TYPE.substr(0, 6) == 'IRCDCC')"; // IRC specific combinations @@ -109,20 +97,16 @@ function initMenus() items: [ ["cmd-prefs"], ["install-plugin"], ["goto-startup"], ["-"], ["print"], ["save"], - ["-", {visibleif: XULRunner}], - ["add-ons", {visibleif: XULRunner}], - ["jsconsole", {visibleif: XULRunner}], - ["about-config", {visibleif: XULRunner}], ["-", {visibleif: NotMac}], ["exit", {visibleif: Win}], ["quit", {visibleif: NotMac + " and " + NotWin}] ] }; client.menuSpecs["mainmenu:irc"] = { label: MSG_MNU_IRC, @@ -182,21 +166,18 @@ function initMenus() ["cmd-copy", {enabledif: "getCommandEnabled('cmd_copy')"}], ["cmd-paste", {enabledif: "getCommandEnabled('cmd_paste')"}], ["cmd-delete", {enabledif: "getCommandEnabled('cmd_delete')"}], ["-"], ["cmd-selectall", {enabledif: "getCommandEnabled('cmd_selectAll')"}], ["-"], ["find"], ["find-again", {enabledif: "canFindAgainInPage()"}], - // Mozilla (suite) gets : separator, Mozilla Prefs, ChatZilla prefs. - // Toolkit Linux apps get: separator, ChatZilla prefs. - // Toolkit Mac apps get : ChatZilla prefs (special Mac ID). - ["-", {visibleif: Mozilla}], - ["cmd-mozilla-prefs", {visibleif: Mozilla}] + ["-"], + ["cmd-mozilla-prefs"] ] }; client.menuSpecs["popup:motifs"] = { label: MSG_MNU_MOTIFS, accesskey: getAccessKeyForMenu('MSG_MNU_MOTIFS'), items: [ @@ -246,17 +227,17 @@ function initMenus() /* Mac expects a help menu with this ID, and there is nothing we can do * about it. */ client.menuSpecs["mainmenu:help"] = { label: MSG_MNU_HELP, accesskey: getAccessKeyForMenu('MSG_MNU_HELP'), domID: "menu_Help", items: [ - ["-", {visibleif: Mozilla}], + ["-"], ["homepage"], ["faq"], ["-"], ["about", {id: "aboutName"}] ] }; client.menuSpecs["popup:fonts"] = { @@ -363,18 +344,18 @@ function initMenus() var urlexternal = "has('url') && cx.url.search(/^ircs?:/i) == -1"; var textselected = "getCommandEnabled('cmd_copy')"; client.menuSpecs["context:messages"] = { getContext: getMessagesContext, items: [ ["goto-url", {visibleif: urlenabled}], - ["goto-url-newwin", {visibleif: urlexternal + " && !" + XULRunner}], - ["goto-url-newtab", {visibleif: urlexternal + " && !" + XULRunner}], + ["goto-url-newwin", {visibleif: urlexternal}], + ["goto-url-newtab", {visibleif: urlexternal}], ["cmd-copy-link-url", {visibleif: urlenabled}], ["cmd-copy", {visibleif: "!" + urlenabled, enabledif: textselected }], ["cmd-selectall", {visibleif: "!" + urlenabled }], ["websearch", {visibleif: textselected}], ["-", {visibleif: "cx.nickname"}], ["label-user", {visibleif: "cx.nickname", header: true}], [">popup:opcommands", {visibleif: "cx.channel && cx.nickname", enabledif: isopish + "cx.user"}], @@ -471,36 +452,17 @@ function initMenus() } function createMenus() { client.menuManager.createMenus(document, "mainmenu"); client.menuManager.createContextMenus(document); - // The menus and the component bar need to be hidden on some hosts. - var winMenu = document.getElementById("windowMenu"); - var tasksMenu = document.getElementById("tasksMenu"); - var comBar = document.getElementById("component-bar"); - - if (client.host != "Mozilla") { - tasksMenu.parentNode.removeChild(tasksMenu); - winMenu.parentNode.removeChild(winMenu); - } else { - comBar.collapsed = false; - } - - if (client.host == "XULRunner") - { - // This is a hack to work around Gecko bug 98997, which means that - // :empty causes menus to be hidden until we force a reflow. - var menuBar = document.getElementById("mainmenu"); - menuBar.hidden = true; - menuBar.hidden = false; - } + document.getElementById("component-bar").collapsed = false; } function getCommandContext (id, event) { var cx = { originalEvent: event }; if (id in client.menuSpecs) { diff --git a/suite/extensions/irc/xul/content/prefs.js b/suite/extensions/irc/xul/content/prefs.js --- a/suite/extensions/irc/xul/content/prefs.js +++ b/suite/extensions/irc/xul/content/prefs.js @@ -48,21 +48,16 @@ function initPrefs() if (!downloadsPath.exists()) mkdir(downloadsPath); var logDefault = client.prefManager.logPath.clone(); logDefault.append(escapeFileName("client.log")); var gotos = ["goto-url-newtab", "goto-url-newwin", "goto-url-newtab", "goto-url-newtab"]; - if (client.host == "XULRunner") - { - gotos = ["goto-url-external", "goto-url-external", - "goto-url-external", "goto-url-external"]; - } // Set up default nickname, if possible. var defaultNick = DEFAULT_NICK; var en = getService("@mozilla.org/process/environment;1", "nsIEnvironment"); if (en) { /* Get the enviroment variables used by various OSes: * USER - Linux, Mac OSX and other *nix-types. 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 @@ -3,17 +3,16 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ ChromeUtils.import("resource://gre/modules/Services.jsm"); const __cz_version = "0.9.96"; const __cz_condition = "green"; -const __cz_suffix = ""; const __cz_guid = "59c81df5-4b7a-477b-912d-4e0fdf64e5f2"; const __cz_locale = "0.9.92"; var warn; var ASSERT; var TEST; if (DEBUG) @@ -116,18 +115,16 @@ function init() client.eventPump.addHook([{type: "poll", set:/^(server|dcc-chat)$/}, {type: "event-end"}], event_tracer, "event-tracer", true /* negate */, false /* disable */); } initApplicationCompatibility(); initMessages(); - if (client.host == "") - showErrorDlg(getMsg(MSG_ERR_UNKNOWN_HOST, client.unknownUID)); initCommands(); initPrefs(); initMunger(); initNetworks(); initMenus(); initStatic(); initHandlers(); @@ -410,131 +407,44 @@ function initStatic() client.defaultCompletion = client.COMMAND_CHAR + "help "; client.deck = document.getElementById('output-deck'); } function getVersionInfo() { var version = new Object(); - version.cz = __cz_version + (__cz_suffix ? "-" + __cz_suffix : ""); - version.ua = navigator.userAgent; - - var app = getService("@mozilla.org/xre/app-info;1", "nsIXULAppInfo"); - if (app) - { - // Use the XUL host app info, and Gecko build ID. - if (app.ID == "{" + __cz_guid + "}") - { - /* We ARE the app, in other words, we're running in XULrunner. - * Because of this, we must disregard app.(name|vendor|version). - */ - - // "XULRunner 1.7+" - version.hostName = "XULRunner"; - version.hostVersion = app.platformVersion; - version.host = version.hostName + " " + version.hostVersion; - - // "XULRunner 1.7+/2005071506" - version.ua = version.host + "/" + app.platformBuildID; - version.hostBuildID = app.platformBuildID; - } - else - { - // "Mozilla Firefox 1.0+" - version.hostName = app.vendor + " " + app.name; - version.hostVersion = app.version; - version.host = version.hostName + " " + version.hostVersion; - - // "Firefox 1.0+/2005071506" - if ("platformBuildID" in app) // 1.1 and up - version.hostBuildID = app.platformBuildID; - else if ("geckoBuildID" in app) // 1.0 - 1.1 trunk only - version.hostBuildID = app.geckoBuildID; - else // Uh oh! - version.hostBuildID = "??????????"; - version.ua = app.name + " " + app.version + "/" + - version.hostBuildID; - } - } - else - { - // Extract the revision number, and Gecko build ID. - var ary = navigator.userAgent.match(/(rv:[^;)\s]+).*?Gecko\/(\d+)/); - if (ary) - { - if (navigator.vendor) - version.ua = navigator.vendor + " " + navigator.vendorSub; // FF 1.0 - else - version.ua = client.entities.brandShortName + " " + ary[1]; // Suite - version.ua += "/" + ary[2]; - version.hostBuildID = ary[2]; - } - version.hostName = client.entities.brandShortName; - version.hostVersion = ""; - version.host = version.hostName; - } - - version.host += ", " + client.platform; + version.cz = __cz_version; + + var app = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); + version.hostName = app.vendor + " " + app.name; + version.hostVersion = app.version; + version.host = version.hostName + " " + version.hostVersion + ", " + + client.platform; + version.hostBuildID = app.platformBuildID; + version.ua = app.name + " " + app.version + "/" + version.hostBuildID; return version; } function initApplicationCompatibility() { - // This function does nothing more than tweak the UI based on the host - // application. - - // Set up simple host and platform information. - client.host = "Unknown"; - - var app = getService("@mozilla.org/xre/app-info;1", "nsIXULAppInfo"); - // nsIXULAppInfo wasn't implemented before 1.8... - if (app) - { - // Use the XULAppInfo.ID to find out what host we run on. - switch (app.ID) - { - case "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": - client.host = "Firefox"; - break; - case "{" + __cz_guid + "}": - // We ARE the app, in other words, we're running in XULRunner. - client.host = "XULRunner"; - break; - case "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": // SeaMonkey - client.host = "Mozilla"; - break; - case "{a463f10c-3994-11da-9945-000d60ca027b}": // Flock - client.host = "Flock"; - break; - case "{3db10fab-e461-4c80-8b97-957ad5f8ea47}": // Netscape - client.host = "Netscape"; - break; - default: - client.unknownUID = app.ID; - client.host = ""; // Unknown host, show an error later. - } - } - else - { - client.host = ""; // We don't know this host. Show an error later. - } + // This function does nothing more than tweak the UI based on the platform. + + // Set up simple platform information. client.platform = "Unknown"; if (navigator.platform.search(/mac/i) > -1) client.platform = "Mac"; if (navigator.platform.search(/win/i) > -1) client.platform = "Windows"; if (navigator.platform.search(/linux/i) > -1) client.platform = "Linux"; - if (navigator.platform.search(/os\/2/i) > -1) - client.platform = "OS/2"; - - client.hostPlatform = client.host + client.platform; + + client.hostPlatform = "Mozilla" + client.platform; CIRCServer.prototype.OS_RPLY = navigator.oscpu + " (" + navigator.platform + ")"; // Windows likes \r\n line endings, as wussy-notepad can't cope with just // \n logs. if (client.platform == "Windows") client.lineEnd = "\r\n"; @@ -2153,18 +2063,16 @@ function initOfflineIcon() } catch (ex) { dd("Turning off managed offline status failed!\n" + ex); } // Actually change the offline state. client.iosvc.offline = !client.iosvc.offline; - // Update the pref: - this.updatePrefFromOffline(); }, canGoOffline: function offline_check() { try { var os = getService(OS_CID, "nsIObserverService"); var canGoOffline = newObject(PRBool_CID, "nsISupportsPRBool"); os.notifyObservers(canGoOffline, "offline-requested", null); @@ -2172,64 +2080,16 @@ function initOfflineIcon() if (canGoOffline.data) return false; } catch (ex) { dd("Exception when trying to ask if we could go offline:" + ex); } return true; - }, - updateOfflineFromPref: function offline_syncFromPref() - { - // On toolkit, we might have smart management of offline mode. - // Don't interfere. - var ioSvc2 = this._getNewIOSvc(); - if (ioSvc2 && ioSvc2.manageOfflineStatus) - return; - - // This is app-managed, or should be, on startup: - if (client.host == "Mozilla") - return; - - var isOffline = false; - var prefSvc = getService("@mozilla.org/preferences-service;1", - "nsIPrefBranch"); - // Let the app-specific hacks begin: - try { - if (client.host == "XULRunner") - isOffline = !prefSvc.getBoolPref("network.online"); - else // Toolkit based, but not standalone - isOffline = prefSvc.getBoolPref("browser.offline"); - } - catch (ex) { /* Whatever. */ } - - // Actually do it: - client.iosvc.offline = isOffline; - }, - updatePrefFromOffline: function offline_syncToPref() - { - // This is app-managed, or should be. - if (client.host == "Mozilla") - return; - - var isOffline = client.iosvc.offline; - var prefSvc = getService("@mozilla.org/preferences-service;1", - "nsIPrefBranch"); - // Let the app-specific hacks begin: - try { - if (client.host == "XULRunner") - prefSvc.setBoolPref("network.online", !isOffline); - else // Toolkit based, but not standalone - prefSvc.setBoolPref("browser.offline", isOffline); - } - catch (ex) - { - dd("Couldn't set offline pref! Error:" + ex); - } } }; try { var os = getService(OS_CID, "nsIObserverService"); os.addObserver(client.offlineObserver, "offline-requested", false); os.addObserver(client.offlineObserver, @@ -2237,17 +2097,16 @@ function initOfflineIcon() } catch (ex) { dd("Exception when trying to register offline observers: " + ex); } var elem = client.offlineObserver._element; elem.setAttribute("onclick", "client.offlineObserver.toggleOffline()"); - client.offlineObserver.updateOfflineFromPref(); client.offlineObserver.updateOfflineUI(); // Don't leak: delete os; delete elem; } function uninitOfflineIcon()