From 37f6cf4d7e222321207b955789af655573a471aa Mon Sep 17 00:00:00 2001 From: "silver%warwickcompsoc.co.uk" Date: Mon, 15 Jun 2009 13:30:40 +0000 Subject: [PATCH] Bug 478462 - Add selected locale (for global and chatzilla), timezone and host app name/version/build details to CEIP log. ChatZilla only. r=gijs git-svn-id: svn://10.0.0.236/trunk@257495 18797224-902f-48f8-a5cc-f745e15eee43 --- .../extensions/irc/xul/content/ceip/ceip.js | 52 ++++++++++++++++++- mozilla/extensions/irc/xul/content/static.js | 24 ++++++--- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/mozilla/extensions/irc/xul/content/ceip/ceip.js b/mozilla/extensions/irc/xul/content/ceip/ceip.js index c10eeea0a5d..076e0675fbb 100644 --- a/mozilla/extensions/irc/xul/content/ceip/ceip.js +++ b/mozilla/extensions/irc/xul/content/ceip/ceip.js @@ -92,13 +92,21 @@ CEIP.prototype.startLog = function ceip_startlog() { dd("CEIP: LOGGING START"); + var version = getVersionInfo(); this.enabled = true; this.logEvent({ type: "logger", event: "start", userid: client.prefs["ceip.userid"], clientVersion: __cz_version, - clientVersionSuffix: __cz_suffix + clientVersionSuffix: __cz_suffix, + clientLocale: this.getSelectedLocale("chatzilla"), + hostName: version.hostName, + hostVersion: version.hostVersion, + hostBuildID: version.hostBuildID, + hostLocale: this.getSelectedLocale("global"), + tz: this.getWinterTimezoneOffset(), + tzNow: (new Date()).getTimezoneOffset() }); var self = this; @@ -365,6 +373,48 @@ function ceip_geteventviewtype(e) return MSG_UNKNOWN; } +/** + * Gets the currently selected locale for a given package. + * + * @param packageName A package to get the selected locale of, e.g. "global", + * "chatzilla". + * @returns An IETF language tag (e.g. "en-US") for the locale. + */ +CEIP.prototype.getSelectedLocale = +function ceip_getselectedlocale(packageName) +{ + var selectedLocale = ""; + try + { + var chromeReg = getService("@mozilla.org/chrome/chrome-registry;1", + "nsIXULChromeRegistry"); + selectedLocale = chromeReg.getSelectedLocale(packageName); + } + catch (ex) {} + return selectedLocale; +} + +/** + * Gets a date-independent timezone offset for the user. + * + * The calculation takes the two solstices, using approximate dates 21st June + * and 21st December, and chooses the most "behind" timezone offset of them as + * the winter timezone offset. + * + * @returns A value which is constant throughout the year for a given timezone. + */ +CEIP.prototype.getWinterTimezoneOffset = +function ceip_getwintertimezoneoffset() +{ + var d1 = new Date(); + d1.setMonth(5); + d1.setDate(21); + var d2 = new Date(); + d2.setMonth(11); + d2.setDate(21); + return Math.max(d1.getTimezoneOffset(), d2.getTimezoneOffset()); +} + CEIP.prototype.isCommandIgnored = function ceip_iscommandignored(e) { diff --git a/mozilla/extensions/irc/xul/content/static.js b/mozilla/extensions/irc/xul/content/static.js index 6ccc58d0bdf..ffcf3e35f33 100644 --- a/mozilla/extensions/irc/xul/content/static.js +++ b/mozilla/extensions/irc/xul/content/static.js @@ -407,7 +407,6 @@ function getVersionInfo() var version = new Object(); version.cz = __cz_version + (__cz_suffix ? "-" + __cz_suffix : ""); version.ua = navigator.userAgent; - version.host = "Unknown"; var app = getService("@mozilla.org/xre/app-info;1", "nsIXULAppInfo"); if (app) @@ -420,24 +419,30 @@ function getVersionInfo() */ // "XULRunner 1.7+" - version.host = "XULRunner " + app.platformVersion; + 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.host = app.vendor + " " + app.name + " " + app.version; + version.hostName = app.vendor + " " + app.name; + version.hostVersion = app.version; + version.host = version.hostName + " " + version.hostVersion; // "Firefox 1.0+/2005071506" - version.ua = app.name + " " + app.version + "/"; if ("platformBuildID" in app) // 1.1 and up - version.ua += app.platformBuildID; + version.hostBuildID = app.platformBuildID; else if ("geckoBuildID" in app) // 1.0 - 1.1 trunk only - version.ua += app.geckoBuildID; + version.hostBuildID = app.geckoBuildID; else // Uh oh! - version.ua += "??????????"; + version.hostBuildID = "??????????"; + version.ua = app.name + " " + app.version + "/" + + version.hostBuildID; } } else @@ -451,8 +456,11 @@ function getVersionInfo() else version.ua = client.entities.brandShortName + " " + ary[1]; // Suite version.ua += "/" + ary[2]; + version.hostBuildID = ary[2]; } - version.host = client.entities.brandShortName; + version.hostName = client.entities.brandShortName; + version.hostVersion = ""; + version.host = version.hostName; } version.host += ", " + client.platform;