nsIPrefService.idl 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #include "nsIPrefBranch.idl"
  41. interface nsIFile;
  42. /**
  43. * The nsIPrefService interface is the main entry point into the back end
  44. * preferences management library. The preference service is directly
  45. * responsible for the management of the preferences files and also facilitates
  46. * access to the preference branch object which allows the direct manipulation
  47. * of the preferences themselves.
  48. *
  49. * @see nsIPrefBranch
  50. *
  51. * @status FROZEN
  52. */
  53. [scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)]
  54. interface nsIPrefService : nsISupports
  55. {
  56. /**
  57. * Called to read in the preferences specified in a user preference file.
  58. *
  59. * @param aFile The file to be read.
  60. *
  61. * @note
  62. * If nsnull is passed in for the aFile parameter the default preferences
  63. * file(s) [prefs.js, user.js] will be read and processed.
  64. *
  65. * @return NS_OK File was read and processed.
  66. * @return Other File failed to read or contained invalid data.
  67. *
  68. * @see savePrefFile
  69. * @see nsIFile
  70. */
  71. void readUserPrefs(in nsIFile aFile);
  72. /**
  73. * Called to completely flush and re-initialize the preferences system.
  74. *
  75. * @return NS_OK The preference service was re-initialized correctly.
  76. * @return Other The preference service failed to restart correctly.
  77. */
  78. void resetPrefs();
  79. /**
  80. * Called to reset all preferences with user set values back to the
  81. * application default values.
  82. *
  83. * @return NS_OK Always.
  84. */
  85. void resetUserPrefs();
  86. /**
  87. * Called to write current preferences state to a file.
  88. *
  89. * @param aFile The file to be written.
  90. *
  91. * @note
  92. * If nsnull is passed in for the aFile parameter the preference data is
  93. * written out to the current preferences file (usually prefs.js.)
  94. *
  95. * @return NS_OK File was written.
  96. * @return Other File failed to write.
  97. *
  98. * @see readUserPrefs
  99. * @see nsIFile
  100. */
  101. void savePrefFile(in nsIFile aFile);
  102. /**
  103. * Call to get a Preferences "Branch" which accesses user preference data.
  104. * Using a Set method on this object will always create or set a user
  105. * preference value. When using a Get method a user set value will be
  106. * returned if one exists, otherwise a default value will be returned.
  107. *
  108. * @param aPrefRoot The preference "root" on which to base this "branch".
  109. * For example, if the root "browser.startup." is used, the
  110. * branch will be able to easily access the preferences
  111. * "browser.startup.page", "browser.startup.homepage", or
  112. * "browser.startup.homepage_override" by simply requesting
  113. * "page", "homepage", or "homepage_override". nsnull or ""
  114. * may be used to access to the entire preference "tree".
  115. *
  116. * @return nsIPrefBranch The object representing the requested branch.
  117. *
  118. * @see getDefaultBranch
  119. */
  120. nsIPrefBranch getBranch(in string aPrefRoot);
  121. /**
  122. * Call to get a Preferences "Branch" which accesses only the default
  123. * preference data. Using a Set method on this object will always create or
  124. * set a default preference value. When using a Get method a default value
  125. * will always be returned.
  126. *
  127. * @param aPrefRoot The preference "root" on which to base this "branch".
  128. * For example, if the root "browser.startup." is used, the
  129. * branch will be able to easily access the preferences
  130. * "browser.startup.page", "browser.startup.homepage", or
  131. * "browser.startup.homepage_override" by simply requesting
  132. * "page", "homepage", or "homepage_override". nsnull or ""
  133. * may be used to access to the entire preference "tree".
  134. *
  135. * @note
  136. * Few consumers will want to create default branch objects. Many of the
  137. * branch methods do nothing on a default branch because the operations only
  138. * make sense when applied to user set preferences.
  139. *
  140. * @return nsIPrefBranch The object representing the requested default branch.
  141. *
  142. * @see getBranch
  143. */
  144. nsIPrefBranch getDefaultBranch(in string aPrefRoot);
  145. };
  146. %{C++
  147. #define NS_PREFSERVICE_CID \
  148. { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \
  149. 0x1cd91b88, \
  150. 0x1dd2, \
  151. 0x11b2, \
  152. { 0x92, 0xe1, 0xed, 0x22, 0xed, 0x29, 0x80, 0x00 } \
  153. }
  154. #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1"
  155. #define NS_PREFSERVICE_CLASSNAME "Preferences Server"
  156. /**
  157. * Notification sent before reading the default user preferences files.
  158. */
  159. #define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs"
  160. /**
  161. * Notification sent when resetPrefs has been called, but before the actual
  162. * reset process occurs.
  163. */
  164. #define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset"
  165. %}