Bug 562878 - Override for machine name [r=mconnor]

Allow setting of the computer name during Firefox account setup and from prefs. Also allow setting device name from Fennec prefs. Fix up strings for Fennec.
This commit is contained in:
Edward Lee 2010-06-11 11:36:51 -07:00
Родитель 67eff5457d
Коммит 9529fb34fa
2 изменённых файлов: 10 добавлений и 19 удалений

Просмотреть файл

@ -1,5 +1,5 @@
# %1: the user name (Ed), %2: the app name (Firefox), %3: the hostname (Comp)
client.name = %1$S's %2$S on %3$S
# %1: the user name (Ed), %2: the app name (Firefox), %3: the operating system (Android)
client.name2 = %1$S's %2$S on %3$S
# %S is the date and time at which the last sync successfully completed
lastSync.label = Last Update: %S

Просмотреть файл

@ -40,6 +40,7 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://weave/ext/StringBundle.js");
Cu.import("resource://weave/constants.js");
Cu.import("resource://weave/util.js");
Cu.import("resource://weave/engines.js");
@ -127,24 +128,14 @@ ClientEngine.prototype = {
return localName;
// Generate a client name if we don't have a useful one yet
let user = Svc.Env.get("USER") || Svc.Env.get("USERNAME");
let app = Svc.AppInfo.name;
let host = Svc.SysInfo.get("host");
let user = Svc.Env.get("USER") || Svc.Env.get("USERNAME") ||
Svc.Prefs.get("username");
let brand = new StringBundle("chrome://branding/locale/brand.properties");
let app = brand.get("brandShortName");
let os = Cc["@mozilla.org/network/protocol;1?name=http"].
getService(Ci.nsIHttpProtocolHandler).oscpu;
// Try figuring out the name of the current profile
let prof = Svc.Directory.get("ProfD", Components.interfaces.nsIFile).path;
let profiles = Svc.Profiles.profiles;
while (profiles.hasMoreElements()) {
let profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile);
if (prof == profile.rootDir.path) {
// Only bother adding the profile name if it's not "default"
if (profile.name != "default")
host = profile.name + "-" + host;
break;
}
}
return this.localName = Str.sync.get("client.name", [user, app, host]);
return this.localName = Str.sync.get("client.name2", [user, app, os]);
},
set localName(value) Svc.Prefs.set("client.name", value),