nsIPrefBranch.idl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Netscape Public License
  6. * Version 1.1 (the "License"); you may not use this file except in
  7. * compliance with the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/NPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Mozilla Communicator client code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Alec Flett <[email protected]>
  24. * Brian Nesse <[email protected]>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the NPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the NPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "nsISupports.idl"
  40. /**
  41. * The nsIPrefBranch interface is used to manipulate the preferences data. This
  42. * object may be obtained from the preferences service (nsIPrefService) and
  43. * used to get and set default and/or user preferences across the application.
  44. *
  45. * This object is created with a "root" value which describes the base point in
  46. * the preferences "tree" from which this "branch" stems. Preferences are
  47. * accessed off of this root by using just the final portion of the preference.
  48. * For example, if this object is created with the root "browser.startup.",
  49. * the preferences "browser.startup.page", "browser.startup.homepage",
  50. * and "browser.startup.homepage_override" can be accessed by simply passing
  51. * "page", "homepage", or "homepage_override" to the various Get/Set methods.
  52. *
  53. * @see nsIPrefService
  54. *
  55. * @status FROZEN
  56. */
  57. [scriptable, uuid(56c35506-f14b-11d3-99d3-ddbfac2ccf65)]
  58. interface nsIPrefBranch : nsISupports
  59. {
  60. /**
  61. * Values describing the basic preference types.
  62. *
  63. * @see getPrefType
  64. */
  65. const long PREF_INVALID = 0;
  66. const long PREF_STRING = 32;
  67. const long PREF_INT = 64;
  68. const long PREF_BOOL = 128;
  69. /**
  70. * Called to get the root on which this branch is based, such as
  71. * "browser.startup."
  72. */
  73. readonly attribute string root;
  74. /**
  75. * Called to determine the type of a specific preference.
  76. *
  77. * @param aPrefName The preference to get the type of.
  78. *
  79. * @return long A value representing the type of the preference. This
  80. * value will be PREF_STRING, PREF_INT, or PREF_BOOL.
  81. */
  82. long getPrefType(in string aPrefName);
  83. /**
  84. * Called to get the state of an individual boolean preference.
  85. *
  86. * @param aPrefName The boolean preference to get the state of.
  87. *
  88. * @return boolean The value of the requested boolean preference.
  89. *
  90. * @see setBoolPref
  91. */
  92. boolean getBoolPref(in string aPrefName);
  93. /**
  94. * Called to set the state of an individual boolean preference.
  95. *
  96. * @param aPrefName The boolean preference to set the state of.
  97. * @param aValue The boolean value to set the preference to.
  98. *
  99. * @return NS_OK The value was successfully set.
  100. * @return Other The value was not set or is the wrong type.
  101. *
  102. * @see getBoolPref
  103. */
  104. void setBoolPref(in string aPrefName, in long aValue);
  105. /**
  106. * Called to get the state of an individual string preference.
  107. *
  108. * @param aPrefName The string preference to retrieve.
  109. *
  110. * @return string The value of the requested string preference.
  111. *
  112. * @see setCharPref
  113. */
  114. string getCharPref(in string aPrefName);
  115. /**
  116. * Called to set the state of an individual string preference.
  117. *
  118. * @param aPrefName The string preference to set.
  119. * @param aValue The string value to set the preference to.
  120. *
  121. * @return NS_OK The value was successfully set.
  122. * @return Other The value was not set or is the wrong type.
  123. *
  124. * @see getCharPref
  125. */
  126. void setCharPref(in string aPrefName, in string aValue);
  127. /**
  128. * Called to get the state of an individual integer preference.
  129. *
  130. * @param aPrefName The integer preference to get the value of.
  131. *
  132. * @return long The value of the requested integer preference.
  133. *
  134. * @see setIntPref
  135. */
  136. long getIntPref(in string aPrefName);
  137. /**
  138. * Called to set the state of an individual integer preference.
  139. *
  140. * @param aPrefName The integer preference to set the value of.
  141. * @param aValue The integer value to set the preference to.
  142. *
  143. * @return NS_OK The value was successfully set.
  144. * @return Other The value was not set or is the wrong type.
  145. *
  146. * @see getIntPref
  147. */
  148. void setIntPref(in string aPrefName, in long aValue);
  149. /**
  150. * Called to get the state of an individual complex preference. A complex
  151. * preference is a preference which represents an XPCOM object that can not
  152. * be easily represented using a standard boolean, integer or string value.
  153. *
  154. * @param aPrefName The complex preference to get the value of.
  155. * @param aType The XPCOM interface that this complex preference
  156. * represents. Interfaces currently supported are:
  157. * - nsILocalFile
  158. * - nsISupportsString (UniChar)
  159. * - nsIPrefLocalizedString (Localized UniChar)
  160. * - nsIFileSpec (deprecated - to be removed eventually)
  161. * @param aValue The XPCOM object into which to the complex preference
  162. * value should be retrieved.
  163. *
  164. * @return NS_OK The value was successfully retrieved.
  165. * @return Other The value does not exist or is the wrong type.
  166. *
  167. * @see setComplexValue
  168. */
  169. void getComplexValue(in string aPrefName, in nsIIDRef aType,
  170. [iid_is(aType), retval] out nsQIResult aValue);
  171. /**
  172. * Called to set the state of an individual complex preference. A complex
  173. * preference is a preference which represents an XPCOM object that can not
  174. * be easily represented using a standard boolean, integer or string value.
  175. *
  176. * @param aPrefName The complex preference to set the value of.
  177. * @param aType The XPCOM interface that this complex preference
  178. * represents. Interfaces currently supported are:
  179. * - nsILocalFile
  180. * - nsISupportsString (UniChar)
  181. * - nsIPrefLocalizedString (Localized UniChar)
  182. * - nsIFileSpec (deprecated - to be removed eventually)
  183. * @param aValue The XPCOM object from which to set the complex preference
  184. * value.
  185. *
  186. * @return NS_OK The value was successfully set.
  187. * @return Other The value was not set or is the wrong type.
  188. *
  189. * @see getComplexValue
  190. */
  191. void setComplexValue(in string aPrefName, in nsIIDRef aType, in nsISupports aValue);
  192. /**
  193. * Called to clear a user set value from a specific preference. This will, in
  194. * effect, reset the value to the default value. If no default value exists
  195. * the preference will cease to exist.
  196. *
  197. * @param aPrefName The preference to be cleared.
  198. *
  199. * @note
  200. * This method does nothing if this object is a default branch.
  201. *
  202. * @return NS_OK The user preference was successfully cleared.
  203. * @return Other The preference does not exist or have a user set value.
  204. */
  205. void clearUserPref(in string aPrefName);
  206. /**
  207. * Called to lock a specific preference. Locking a preference will cause the
  208. * preference service to always return the default value regardless of
  209. * whether there is a user set value or not.
  210. *
  211. * @param aPrefName The preference to be locked.
  212. *
  213. * @note
  214. * This method can be called on either a default or user branch but, in
  215. * effect, always operates on the default branch.
  216. *
  217. * @return NS_OK The preference was successfully locked.
  218. * @return Other The preference does not exist or an error occurred.
  219. *
  220. * @see unlockPref
  221. */
  222. void lockPref(in string aPrefName);
  223. /**
  224. * Called to check if a specific preference has a user value associated to
  225. * it.
  226. *
  227. * @param aPrefName The preference to be tested.
  228. *
  229. * @note
  230. * This method can be called on either a default or user branch but, in
  231. * effect, always operates on the user branch.
  232. *
  233. * @return boolean true The preference has a user set value.
  234. * false The preference only has a default value.
  235. */
  236. boolean prefHasUserValue(in string aPrefName);
  237. /**
  238. * Called to check if a specific preference is locked. If a preference is
  239. * locked calling its Get method will always return the default value.
  240. *
  241. * @param aPrefName The preference to be tested.
  242. *
  243. * @note
  244. * This method can be called on either a default or user branch but, in
  245. * effect, always operates on the default branch.
  246. *
  247. * @return boolean true The preference is locked.
  248. * false The preference is not locked.
  249. *
  250. * @see lockPref
  251. * @see unlockPref
  252. */
  253. boolean prefIsLocked(in string aPrefName);
  254. /**
  255. * Called to unlock a specific preference. Unlocking a previously locked
  256. * preference allows the preference service to once again return the user set
  257. * value of the preference.
  258. *
  259. * @param aPrefName The preference to be unlocked.
  260. *
  261. * @note
  262. * This method can be called on either a default or user branch but, in
  263. * effect, always operates on the default branch.
  264. *
  265. * @return NS_OK The preference was successfully unlocked.
  266. * @return Other The preference does not exist or an error occurred.
  267. *
  268. * @see lockPref
  269. */
  270. void unlockPref(in string aPrefName);
  271. /**
  272. * Called to remove all of the preferences referenced by this branch.
  273. *
  274. * @param aStartingAt The point on the branch at which to start the deleting
  275. * preferences. Pass in "" to remove all preferences
  276. * referenced by this branch.
  277. *
  278. * @note
  279. * This method can be called on either a default or user branch but, in
  280. * effect, always operates on both.
  281. *
  282. * @return NS_OK The preference(s) were successfully removed.
  283. * @return Other The preference(s) do not exist or an error occurred.
  284. */
  285. void deleteBranch(in string aStartingAt);
  286. /**
  287. * Returns an array of strings representing the child preferences of the
  288. * root of this branch.
  289. *
  290. * @param aStartingAt The point on the branch at which to start enumerating
  291. * the child preferences. Pass in "" to enumerate all
  292. * preferences referenced by this branch.
  293. * @param aCount Receives the number of elements in the array.
  294. * @param aChildArray Receives the array of child preferences.
  295. *
  296. * @note
  297. * This method can be called on either a default or user branch but, in
  298. * effect, always operates on both.
  299. *
  300. * @return NS_OK The preference list was successfully retrieved.
  301. * @return Other The preference(s) do not exist or an error occurred.
  302. */
  303. void getChildList(in string aStartingAt, out unsigned long aCount,
  304. [array, size_is(aCount), retval] out string aChildArray);
  305. /**
  306. * Called to reset all of the preferences referenced by this branch to their
  307. * default values.
  308. *
  309. * @param aStartingAt The point on the branch at which to start the resetting
  310. * preferences to their default values. Pass in "" to
  311. * reset all preferences referenced by this branch.
  312. *
  313. * @note
  314. * This method can be called on either a default or user branch but, in
  315. * effect, always operates on the user branch.
  316. *
  317. * @return NS_OK The preference(s) were successfully reset.
  318. * @return Other The preference(s) do not exist or an error occurred.
  319. */
  320. void resetBranch(in string aStartingAt);
  321. };
  322. %{C++
  323. #define NS_PREFBRANCH_CONTRACTID "@mozilla.org/preferencesbranch;1"
  324. #define NS_PREFBRANCH_CLASSNAME "Preferences Branch"
  325. %}