Closed Bug 353812 Opened 18 years ago Closed 7 years ago

Add GetStringPref function to nsIPrefBranch

Categories

(Core :: Preferences: Backend, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1345294

People

(Reporter: jshin1987, Unassigned)

Details

(Keywords: intl)

We don't have |uniCharPref| in nsIPrefBranch. Instead, to retrieve/set a non-ASCII string pref. value, we need to use {Get|Set}ComplexValue with nsISupportsString (for localized string pref, nsIPrefLocalized), but that's quite roundabout way. As a result, there are at least three utility functions for getting a string pref-value in UTF-16 http://lxr.mozilla.org/seamonkey/source/mailnews/base/util/nsMsgIdentity.cpp#166 http://lxr.mozilla.org/seamonkey/source/mailnews/base/util/nsMsgUtils.cpp#1074 http://lxr.mozilla.org/seamonkey/source/editor/ui/composer/content/editorUtilities.js#545 For javascript, this doesn't help much... In addition, there are many misuses of |GetCharPref| where |GetUnicharPref|-equivalent (with GetComplexValue) should be used. (especially in javascript code). Below is an example. Editor for view-source can have a path with non-ascii characters. http://lxr.mozilla.org/seamonkey/source/toolkit/components/viewsource/content/viewSourceUtils.js#154 152 var prefs = Components.classes["@mozilla.org/preferences-service;1"] 153 .getService(Components.interfaces.nsIPrefBranch); 154 var prefPath = prefs.getCharPref("view_source.editor.path");
well the editor should actually be stored as a complex nsIFile...
OS: Linux → All
Hardware: PC → All
nsMsgTagService also has its own complex->unichar routines: http://lxr.mozilla.org/mozilla/source/mailnews/base/src/nsMsgTagService.cpp#425
QA Contact: preferences-backend
The editor is now stored as nsIFile, see bug 789852.
I think that nsIPrefBranch.getUnicharPref() should work as nsIPrefBranch.getComplexValue() with nsIPrefLocalizedString. If we would separate getUnicharPref() and getLocalizedUnicharPref(), it would cause similar bug in the future. If we would have performance issue, we could improve it with checking whether the pref value indicated proeprties file or not. nsIPrefBranch.getFilePref() must also be useful. However, I think that we don't need nsIPrefBranch.getRelativeFile() or something for nsIRelativeFilePref since there is no user of this. http://mxr.mozilla.org/mozilla-central/search?string=nsIRelativeFilePref&filter=[Nn]sIRelativeFilePref
GetStringPref seems like a better name.
Assignee: jshin1987 → nobody
Summary: Add a helper function (GetUnicharPref) and fix misuse of |GetCharPref| → Add GetStringPref function to nsIPrefBranch
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.