Bug 1415567 - Port bug 1414096 to TB: Remove {get,set}ComplexValue use of nsISupportsString (script-generated patch). r=jorgk

This commit is contained in:
Florian Queze 2017-11-08 16:11:03 +01:00
Родитель 8ff8ab1d73
Коммит a14ef4ff2c
19 изменённых файлов: 39 добавлений и 106 удалений

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

@ -129,17 +129,12 @@ function imAccount(aKey, aName, aPrplId)
if (aName) {
this.name = aName;
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = aName;
this.prefBranch.setComplexValue(kPrefAccountName, Ci.nsISupportsString,
str);
this.prefBranch.setStringPref(kPrefAccountName, aName);
this.firstConnectionState = Ci.imIAccount.FIRST_CONNECTION_UNKNOWN;
}
else {
this.name = this.prefBranch.getComplexValue(kPrefAccountName,
Ci.nsISupportsString).data;
this.name = this.prefBranch.getStringPref(kPrefAccountName);
}
let prplId = aPrplId;
@ -176,8 +171,7 @@ function imAccount(aKey, aName, aPrplId)
// we don't want to display several of theses prompts at startup.
if (gConvertingOldPasswords && !this.protocol.noPassword) {
try {
let password = this.prefBranch.getComplexValue(kPrefAccountPassword,
Ci.nsISupportsString).data;
let password = this.prefBranch.getStringPref(kPrefAccountPassword);
if (password && !this.password)
this.password = password;
} catch (e) { /* No password saved in the prefs for this account. */ }
@ -238,8 +232,7 @@ imAccount.prototype = {
if (this.canJoinChat &&
this.prefBranch.prefHasUserValue(kPrefAccountAutoJoin)) {
let autojoin = this.prefBranch.getComplexValue(
kPrefAccountAutoJoin, Ci.nsISupportsString).data;
let autojoin = this.prefBranch.getStringPref(kPrefAccountAutoJoin);
if (autojoin) {
for (let room of autojoin.trim().split(/,\s*/)) {
if (room)
@ -480,11 +473,7 @@ imAccount.prototype = {
set alias(val) {
if (val) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = val;
this.prefBranch.setComplexValue(kPrefAccountAlias, Ci.nsISupportsString,
str);
this.prefBranch.setStringPref(kPrefAccountAlias, val);
}
else
this.prefBranch.deleteBranch(kPrefAccountAlias);
@ -492,8 +481,7 @@ imAccount.prototype = {
},
get alias() {
try {
return this.prefBranch.getComplexValue(kPrefAccountAlias,
Ci.nsISupportsString).data;
return this.prefBranch.getStringPref(kPrefAccountAlias);
} catch (e) {
return "";
}
@ -803,11 +791,7 @@ imAccount.prototype = {
SavePrefTimer.initTimer();
},
setString: function(aName, aVal) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = aVal;
this.prefBranch.setComplexValue(kAccountOptionPrefPrefix + aName,
Ci.nsISupportsString, str);
this.prefBranch.setStringPref(kAccountOptionPrefPrefix + aName, aVal);
this._connectionInfoChanged();
if (this.prplAccount)
this.prplAccount.setString(aName, aVal);

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

@ -214,15 +214,10 @@ UserStatus.prototype = {
},
get displayName() {
return Services.prefs.getComplexValue(kPrefUserDisplayname,
Ci.nsISupportsString).data;
return Services.prefs.getStringPref(kPrefUserDisplayname);
},
set displayName(aDisplayName) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = aDisplayName;
Services.prefs.setComplexValue(kPrefUserDisplayname, Ci.nsISupportsString,
str);
Services.prefs.setStringPref(kPrefUserDisplayname, aDisplayName);
this._notifyObservers("user-display-name-changed", aDisplayName);
},

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

@ -219,7 +219,7 @@ var GenericAccountPrototype = {
getBool: function(aName) { return this.getPref(aName, "Bool"); },
getString: function(aName) {
return this.prefs.prefHasUserValue(aName) ?
this.prefs.getComplexValue(aName, Ci.nsISupportsString).data :
this.prefs.getStringPref(aName) :
this.protocol._getOptionDefault(aName);
},

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

@ -1322,10 +1322,7 @@ var XMPPAccountPrototype = {
// If there is a resource in the account name (inherited from libpurple),
// migrate it to the pref so it appears correctly in the advanced account
// options next time.
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = this._jid.resource;
this.prefs.setComplexValue("resource", Ci.nsISupportsString, str);
this.prefs.setStringPref("resource", this._jid.resource);
}
this._connection =

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

@ -2325,8 +2325,7 @@ function EditorSetDefaultPrefsAndDoctype()
let authorFound = domdoc.querySelector('meta[name="author"]');
try
{
prefAuthorString = Services.prefs.getComplexValue("editor.author",
Components.interfaces.nsISupportsString).data;
prefAuthorString = Services.prefs.getStringPref("editor.author");
}
catch (ex) {}
if (prefAuthorString && prefAuthorString != 0 && !authorFound && headelement)

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

@ -395,7 +395,7 @@ function GetFileProtocolHandler()
function GetStringPref(name)
{
try {
return Services.prefs.getComplexValue(name, Components.interfaces.nsISupportsString).data;
return Services.prefs.getStringPref(name);
} catch (e) {}
return "";
}
@ -403,10 +403,7 @@ function GetStringPref(name)
function SetStringPref(aPrefName, aPrefValue)
{
try {
let str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefValue;
Services.prefs.setComplexValue(aPrefName, Components.interfaces.nsISupportsString, str);
Services.prefs.setStringPref(aPrefName, aPrefValue);
}
catch(e) {}
}

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

@ -723,7 +723,7 @@ function GetPublishStringPref(prefBranch, name)
if (prefBranch && name)
{
try {
return prefBranch.getComplexValue(name, Components.interfaces.nsISupportsString).data;
return prefBranch.getStringPref(name);
} catch (e) {}
}
return "";
@ -734,10 +734,7 @@ function SetPublishStringPref(prefBranch, name, value)
if (prefBranch && name)
{
try {
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = value;
prefBranch.setComplexValue(name, Components.interfaces.nsISupportsString, str);
prefBranch.setStringPref(name, value);
} catch (e) {}
}
}

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

@ -39,7 +39,7 @@ var account = {
this.account.id + ".");
if (branch.prefHasUserValue(autoJoinPref)) {
document.getElementById("autojoin").value =
branch.getComplexValue(autoJoinPref, Ci.nsISupportsString).data;
branch.getStringPref(autoJoinPref);
}
}
@ -131,7 +131,7 @@ var account = {
getString: function account_getString(aOpt) {
if (this.prefs.prefHasUserValue(aOpt.name))
return this.prefs.getComplexValue(aOpt.name, Ci.nsISupportsString).data;
return this.prefs.getStringPref(aOpt.name);
return aOpt.getString();
},
@ -176,10 +176,7 @@ var account = {
this.account.id + ".");
var autojoin = this.getValue("autojoin");
if (autojoin || branch.prefHasUserValue(autoJoinPref)) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = autojoin;
branch.setComplexValue(autoJoinPref, Ci.nsISupportsString, str);
branch.setStringPref(autoJoinPref, autojoin);
}
}

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

@ -130,17 +130,14 @@ var joinChat = {
let autojoin = [];
if (prefBranch.prefHasUserValue(autoJoinPref)) {
let prefValue =
prefBranch.getComplexValue(autoJoinPref, Ci.nsISupportsString).data;
prefBranch.getStringPref(autoJoinPref);
if (prefValue)
autojoin = prefValue.split(",");
}
if (!autojoin.includes(name)) {
autojoin.push(name);
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = autojoin.join(",");
prefBranch.setComplexValue(autoJoinPref, Ci.nsISupportsString, str);
prefBranch.setStringPref(autoJoinPref, autojoin.join(","));
}
}

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

@ -5660,8 +5660,7 @@ function getMailToolbox()
function getPref(aPrefName, aIsComplex) {
const Ci = Components.interfaces;
if (aIsComplex) {
return Services.prefs
.getComplexValue(aPrefName, Ci.nsISupportsString).data;
return Services.prefs.getStringPref(aPrefName);
}
switch (Services.prefs.getPrefType(aPrefName)) {
case Ci.nsIPrefBranch.PREF_BOOL:

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

@ -139,17 +139,14 @@ var joinChat = {
let autojoin = [];
if (prefBranch.prefHasUserValue(autoJoinPref)) {
let prefValue =
prefBranch.getComplexValue(autoJoinPref, Ci.nsISupportsString).data;
prefBranch.getStringPref(autoJoinPref);
if (prefValue)
autojoin = prefValue.split(",");
}
if (!autojoin.includes(name)) {
autojoin.push(name);
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = autojoin.join(",");
prefBranch.setComplexValue(autoJoinPref, Ci.nsISupportsString, str);
prefBranch.setStringPref(autoJoinPref, autojoin.join(","));
}
}

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

@ -100,17 +100,14 @@ imIncomingServer.prototype = {
get autojoin() {
try {
let prefName = "messenger.account." + this.imAccount.id + ".autoJoin";
return Services.prefs.getComplexValue(prefName, Ci.nsISupportsString).data;
return Services.prefs.getStringPref(prefName);
} catch (e) {
return "";
}
},
set autojoin(aAutoJoin) {
let prefName = "messenger.account." + this.imAccount.id + ".autoJoin";
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = aAutoJoin;
Services.prefs.setComplexValue(prefName, Ci.nsISupportsString, str);
Services.prefs.setStringPref(prefName, aAutoJoin);
},
// This is used for user-visible advanced preferences.
@ -135,8 +132,7 @@ imIncomingServer.prototype = {
try {
let prefName =
"messenger.account." + this.imAccount.id + ".options." + aPrefName;
return Services.prefs.getComplexValue(prefName,
Ci.nsISupportsString).data;
return Services.prefs.getStringPref(prefName);
} catch (x) {
return this._getDefault(aPrefName);
}

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

@ -77,10 +77,7 @@ var gAttachmentReminderOptionsDialog = {
keywordList += ",";
}
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = keywordList;
Services.prefs.setComplexValue("mail.compose.attachment_reminder_keywords",
Components.interfaces.nsISupportsString, str);
Services.prefs.setStringPref("mail.compose.attachment_reminder_keywords",
keywordList);
}
};

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

@ -45,7 +45,7 @@ function search()
{
// get the login to authenticate as, if there is one
try {
gLogin = Services.prefs.getComplexValue(gDirectoryPref + ".auth.dn", Components.interfaces.nsISupportsString).data;
gLogin = Services.prefs.getStringPref(gDirectoryPref + ".auth.dn");
} catch (ex) {
// if we don't have this pref, no big deal
}

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

@ -86,8 +86,7 @@ function getHomePageGroup()
for (var i = 1; i < count; ++i) {
try {
homePage += '\n' + Services.prefs.getComplexValue("browser.startup.homepage." + i,
nsISupportsString).data;
homePage += '\n' + Services.prefs.getStringPref("browser.startup.homepage." + i);
} catch (e) {
}
}
@ -151,8 +150,7 @@ function getURLToLoad()
return getHomePageGroup();
case 2:
return Services.prefs.getComplexValue("browser.history.last_page_visited",
nsISupportsString).data;
return Services.prefs.getStringPref("browser.history.last_page_visited");
}
} catch (e) {
}

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

@ -142,18 +142,14 @@ function SetStringPref(aPref, aValue)
{
const nsISupportsString = Components.interfaces.nsISupportsString;
try {
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(nsISupportsString);
str.data = aValue;
Services.prefs.setComplexValue(aPref, nsISupportsString, str);
Services.prefs.setStringPref(aPref, aValue);
} catch (e) {}
}
function GetStringPref(name)
{
try {
return Services.prefs.getComplexValue(name,
Components.interfaces.nsISupportsString).data;
return Services.prefs.getStringPref(name);
} catch (e) {}
return "";
}

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

@ -765,8 +765,7 @@ FeedWriter.prototype = {
switch (handler) {
case "web":
if (this._handlersMenuList) {
var url = Services.prefs.getComplexValue(getPrefWebForType(feedType),
Components.interfaces.nsISupportsString).data;
var url = Services.prefs.getStringPref(getPrefWebForType(feedType));
var handlers = this._handlersMenuList.getElementsByAttribute("webhandlerurl", url);
if (handlers.length == 0) {
LOG("FeedWriter._setSelectedHandler: selected web handler isn't in the menulist");
@ -1119,11 +1118,7 @@ FeedWriter.prototype = {
var webURI = selectedItem.getAttribute("webhandlerurl");
Services.prefs.setCharPref(getPrefReaderForType(feedType), "web");
var supportsString = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
supportsString.data = webURI;
Services.prefs.setComplexValue(getPrefWebForType(feedType), Components.interfaces.nsISupportsString,
supportsString);
Services.prefs.setStringPref(getPrefWebForType(feedType), webURI);
var wccr = Components.classes["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"]
.getService(Components.interfaces.nsIWebContentConverterService);

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

@ -641,11 +641,7 @@ WebContentConverterRegistrar.prototype = {
// and make sure the preview page is shown the next time a feed is visited
Services.prefs.setCharPref(PREF_SELECTED_READER, "web");
var supportsString = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
supportsString.data = uri;
Services.prefs.setComplexValue(PREF_SELECTED_WEB, Components.interfaces.nsISupportsString,
supportsString);
Services.prefs.setStringPref(PREF_SELECTED_WEB, uri);
Services.prefs.setCharPref(PREF_SELECTED_ACTION, "ask");
this._setAutoHandler(TYPE_MAYBE_FEED, null);
}

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

@ -124,17 +124,13 @@ var sanTests = {
}
// Open location dialog.
var supStr = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
supStr.data = "Sanitizer!";
Services.prefs.setComplexValue("general.open_location.last_url",
Components.interfaces.nsISupportsString, supStr);
Services.prefs.setStringPref("general.open_location.last_url", "Sanitizer!");
},
check: function(aShouldBeCleared) {
let locData;
try {
locData = Services.prefs.getComplexValue("general.open_location.last_url", Components.interfaces.nsISupportsString).data;
locData = Services.prefs.getStringPref("general.open_location.last_url");
} catch(ex) {}
do_check_eq(locData == "Sanitizer!", !aShouldBeCleared);