зеркало из https://github.com/mozilla/pjs.git
code clean up for buddy icon in ab card pane. r/sr=bienvenu
This commit is contained in:
Родитель
a9ba9825e1
Коммит
7d7004b3b1
|
@ -30,12 +30,9 @@
|
|||
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
gPrefs = gPrefs.getService();
|
||||
gPrefs = gPrefs.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
var gProfile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal);
|
||||
|
||||
var gProfileDirURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
gProfileDirURL.file = gProfile.getProfileDir(gProfile.currentProfile);
|
||||
var gIconFileURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
var gProfileDirURL;
|
||||
var gIconFileURL;
|
||||
|
||||
var gMapItURLFormat = gPrefs.getComplexValue("mail.addr_book.mapit_url.format",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
|
@ -339,11 +336,22 @@ function setBuddyIcon(card, buddyIcon)
|
|||
try {
|
||||
var myScreenName = gPrefs.getCharPref("aim.session.screenname");
|
||||
if (myScreenName && card.primaryEmail) {
|
||||
if (!gProfileDirURL) {
|
||||
// lazily create these file urls, and keep them around
|
||||
gProfileDirURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
gIconFileURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal);
|
||||
gProfileDirURL.file = profile.getProfileDir(profile.currentProfile);
|
||||
}
|
||||
|
||||
// if we did have a buddy icon on disk for this screenname, this would be the file url spec for it
|
||||
var iconURLStr = gProfileDirURL.spec + "/NIM/" + myScreenName + "/picture/" + card.aimScreenName + ".gif";
|
||||
|
||||
// check if the file exists
|
||||
gIconFileURL.spec = iconURLStr;
|
||||
|
||||
// check if the file exists
|
||||
// is this a perf hit? (how expensive is stat()?)
|
||||
if (gIconFileURL.file.exists()) {
|
||||
buddyIcon.setAttribute("src", iconURLStr);
|
||||
return true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче