Bug 826357 - Generate Metro-aware Sync client name. r=rnewman

This commit is contained in:
Jim Mathies 2013-05-07 15:55:49 -05:00
parent ab8e1f633a
commit 561c9eed72
2 changed files with 20 additions and 7 deletions

View File

@ -2,7 +2,10 @@
# 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/.
# Mobile Sync
# LOCALIZATION NOTE: Used in the default os description when a new account
# is being set up. Should be unique to Metro, so that it does not conflict
# with Desktop. See /services/sync/modules/engines/clients.js locaName.
sync.defaultAccountApplication=Metro %S
# %S is the date and time at which the last sync successfully completed
lastSync2.label=Last sync: %S

View File

@ -86,15 +86,25 @@ ClientEngine.prototype = {
.getService(Ci.nsIEnvironment);
let user = env.get("USER") || env.get("USERNAME") ||
Svc.Prefs.get("account") || Svc.Prefs.get("username");
let appName;
let brand = new StringBundle("chrome://branding/locale/brand.properties");
let app = brand.get("brandShortName");
let brandName = brand.get("brandShortName");
try {
let syncStrings = new StringBundle("chrome://browser/locale/sync.properties");
appName = syncStrings.getFormattedString("sync.defaultAccountApplication", [brandName]);
} catch (ex) {}
appName = appName || brandName;
let system = Cc["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2).get("device") ||
Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler).oscpu;
let system =
// 'device' is defined on unix systems
Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("device") ||
// hostname of the system, usually assigned by the user or admin
Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("host") ||
// fall back on ua info string
Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;
return this.localName = Str.sync.get("client.name2", [user, app, system]);
return this.localName = Str.sync.get("client.name2", [user, appName, system]);
},
set localName(value) Svc.Prefs.set("client.name", value),