/modules/libpref/public/nsIPrefService.idl

http://github.com/zpao/v8monkey · IDL · 197 lines · 36 code · 19 blank · 142 comment · 0 complexity · 39500cf2becdaa4b6710cbb1fa7a4e61 MD5 · raw file

  1. /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  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 <alecf@netscape.com>
  24. * Brian Nesse <bnesse@netscape.com>
  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 MPL, 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 MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "nsISupports.idl"
  40. #include "nsIPrefBranch.idl"
  41. %{C++
  42. struct PrefTuple;
  43. template<class E, class A> class nsTArray;
  44. struct nsTArrayInfallibleAllocator;
  45. %}
  46. [ptr] native nsPreferencesArrayPtr(nsTArray<PrefTuple, nsTArrayInfallibleAllocator>);
  47. [ptr] native nsPreferencePtr(PrefTuple);
  48. [ptr] native nsPreferencePtrConst(const PrefTuple);
  49. interface nsIFile;
  50. interface nsILocalFile;
  51. /**
  52. * The nsIPrefService interface is the main entry point into the back end
  53. * preferences management library. The preference service is directly
  54. * responsible for the management of the preferences files and also facilitates
  55. * access to the preference branch object which allows the direct manipulation
  56. * of the preferences themselves.
  57. *
  58. * @see nsIPrefBranch
  59. */
  60. [scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)]
  61. interface nsIPrefService : nsISupports
  62. {
  63. /**
  64. * Called to read in the preferences specified in a user preference file.
  65. *
  66. * @param aFile The file to be read.
  67. *
  68. * @note
  69. * If nsnull is passed in for the aFile parameter the default preferences
  70. * file(s) [prefs.js, user.js] will be read and processed.
  71. *
  72. * @return NS_OK File was read and processed.
  73. * @return Other File failed to read or contained invalid data.
  74. *
  75. * @see savePrefFile
  76. * @see nsIFile
  77. */
  78. void readUserPrefs(in nsIFile aFile);
  79. /**
  80. * Called to completely flush and re-initialize the preferences system.
  81. *
  82. * @return NS_OK The preference service was re-initialized correctly.
  83. * @return Other The preference service failed to restart correctly.
  84. */
  85. void resetPrefs();
  86. /**
  87. * Called to reset all preferences with user set values back to the
  88. * application default values.
  89. *
  90. * @return NS_OK Always.
  91. */
  92. void resetUserPrefs();
  93. /**
  94. * Called to write current preferences state to a file.
  95. *
  96. * @param aFile The file to be written.
  97. *
  98. * @note
  99. * If nsnull is passed in for the aFile parameter the preference data is
  100. * written out to the current preferences file (usually prefs.js.)
  101. *
  102. * @return NS_OK File was written.
  103. * @return Other File failed to write.
  104. *
  105. * @see readUserPrefs
  106. * @see nsIFile
  107. */
  108. void savePrefFile(in nsIFile aFile);
  109. /**
  110. * Call to get a Preferences "Branch" which accesses user preference data.
  111. * Using a Set method on this object will always create or set a user
  112. * preference value. When using a Get method a user set value will be
  113. * returned if one exists, otherwise a default value will be returned.
  114. *
  115. * @param aPrefRoot The preference "root" on which to base this "branch".
  116. * For example, if the root "browser.startup." is used, the
  117. * branch will be able to easily access the preferences
  118. * "browser.startup.page", "browser.startup.homepage", or
  119. * "browser.startup.homepage_override" by simply requesting
  120. * "page", "homepage", or "homepage_override". nsnull or ""
  121. * may be used to access to the entire preference "tree".
  122. *
  123. * @return nsIPrefBranch The object representing the requested branch.
  124. *
  125. * @see getDefaultBranch
  126. */
  127. nsIPrefBranch getBranch(in string aPrefRoot);
  128. /**
  129. * Call to get a Preferences "Branch" which accesses only the default
  130. * preference data. Using a Set method on this object will always create or
  131. * set a default preference value. When using a Get method a default value
  132. * will always be returned.
  133. *
  134. * @param aPrefRoot The preference "root" on which to base this "branch".
  135. * For example, if the root "browser.startup." is used, the
  136. * branch will be able to easily access the preferences
  137. * "browser.startup.page", "browser.startup.homepage", or
  138. * "browser.startup.homepage_override" by simply requesting
  139. * "page", "homepage", or "homepage_override". nsnull or ""
  140. * may be used to access to the entire preference "tree".
  141. *
  142. * @note
  143. * Few consumers will want to create default branch objects. Many of the
  144. * branch methods do nothing on a default branch because the operations only
  145. * make sense when applied to user set preferences.
  146. *
  147. * @return nsIPrefBranch The object representing the requested default branch.
  148. *
  149. * @see getBranch
  150. */
  151. nsIPrefBranch getDefaultBranch(in string aPrefRoot);
  152. };
  153. %{C++
  154. #define NS_PREFSERVICE_CID \
  155. { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \
  156. 0x91ca2441, \
  157. 0x050f, \
  158. 0x4f7c, \
  159. { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \
  160. }
  161. #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1"
  162. #define NS_PREFSERVICE_CLASSNAME "Preferences Server"
  163. /**
  164. * Notification sent before reading the default user preferences files.
  165. */
  166. #define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs"
  167. /**
  168. * Notification sent when resetPrefs has been called, but before the actual
  169. * reset process occurs.
  170. */
  171. #define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset"
  172. /**
  173. * Notification sent when after reading app-provided default
  174. * preferences, but before user profile override defaults or extension
  175. * defaults are loaded.
  176. */
  177. #define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults"
  178. %}