|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 #include "nsIPrefBranch.idl" |
|
8 |
|
9 %{C++ |
|
10 struct PrefTuple; |
|
11 #include "nsTArrayForwardDeclare.h" |
|
12 %} |
|
13 |
|
14 [ptr] native nsPreferencesArrayPtr(nsTArray<PrefTuple>); |
|
15 [ptr] native nsPreferencePtr(PrefTuple); |
|
16 [ptr] native nsPreferencePtrConst(const PrefTuple); |
|
17 |
|
18 interface nsIFile; |
|
19 |
|
20 /** |
|
21 * The nsIPrefService interface is the main entry point into the back end |
|
22 * preferences management library. The preference service is directly |
|
23 * responsible for the management of the preferences files and also facilitates |
|
24 * access to the preference branch object which allows the direct manipulation |
|
25 * of the preferences themselves. |
|
26 * |
|
27 * @see nsIPrefBranch |
|
28 */ |
|
29 |
|
30 [scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)] |
|
31 interface nsIPrefService : nsISupports |
|
32 { |
|
33 /** |
|
34 * Called to read in the preferences specified in a user preference file. |
|
35 * |
|
36 * @param aFile The file to be read. |
|
37 * |
|
38 * @note |
|
39 * If nullptr is passed in for the aFile parameter the default preferences |
|
40 * file(s) [prefs.js, user.js] will be read and processed. |
|
41 * |
|
42 * @throws Error File failed to read or contained invalid data. |
|
43 * |
|
44 * @see savePrefFile |
|
45 * @see nsIFile |
|
46 */ |
|
47 void readUserPrefs(in nsIFile aFile); |
|
48 |
|
49 /** |
|
50 * Called to completely flush and re-initialize the preferences system. |
|
51 * |
|
52 * @throws Error The preference service failed to restart correctly. |
|
53 */ |
|
54 void resetPrefs(); |
|
55 |
|
56 /** |
|
57 * Called to reset all preferences with user set values back to the |
|
58 * application default values. |
|
59 */ |
|
60 void resetUserPrefs(); |
|
61 |
|
62 /** |
|
63 * Called to write current preferences state to a file. |
|
64 * |
|
65 * @param aFile The file to be written. |
|
66 * |
|
67 * @note |
|
68 * If nullptr is passed in for the aFile parameter the preference data is |
|
69 * written out to the current preferences file (usually prefs.js.) |
|
70 * |
|
71 * @throws Error File failed to write. |
|
72 * |
|
73 * @see readUserPrefs |
|
74 * @see nsIFile |
|
75 */ |
|
76 void savePrefFile(in nsIFile aFile); |
|
77 |
|
78 /** |
|
79 * Call to get a Preferences "Branch" which accesses user preference data. |
|
80 * Using a Set method on this object will always create or set a user |
|
81 * preference value. When using a Get method a user set value will be |
|
82 * returned if one exists, otherwise a default value will be returned. |
|
83 * |
|
84 * @param aPrefRoot The preference "root" on which to base this "branch". |
|
85 * For example, if the root "browser.startup." is used, the |
|
86 * branch will be able to easily access the preferences |
|
87 * "browser.startup.page", "browser.startup.homepage", or |
|
88 * "browser.startup.homepage_override" by simply requesting |
|
89 * "page", "homepage", or "homepage_override". nullptr or "" |
|
90 * may be used to access to the entire preference "tree". |
|
91 * |
|
92 * @return nsIPrefBranch The object representing the requested branch. |
|
93 * |
|
94 * @see getDefaultBranch |
|
95 */ |
|
96 nsIPrefBranch getBranch(in string aPrefRoot); |
|
97 |
|
98 /** |
|
99 * Call to get a Preferences "Branch" which accesses only the default |
|
100 * preference data. Using a Set method on this object will always create or |
|
101 * set a default preference value. When using a Get method a default value |
|
102 * will always be returned. |
|
103 * |
|
104 * @param aPrefRoot The preference "root" on which to base this "branch". |
|
105 * For example, if the root "browser.startup." is used, the |
|
106 * branch will be able to easily access the preferences |
|
107 * "browser.startup.page", "browser.startup.homepage", or |
|
108 * "browser.startup.homepage_override" by simply requesting |
|
109 * "page", "homepage", or "homepage_override". nullptr or "" |
|
110 * may be used to access to the entire preference "tree". |
|
111 * |
|
112 * @note |
|
113 * Few consumers will want to create default branch objects. Many of the |
|
114 * branch methods do nothing on a default branch because the operations only |
|
115 * make sense when applied to user set preferences. |
|
116 * |
|
117 * @return nsIPrefBranch The object representing the requested default branch. |
|
118 * |
|
119 * @see getBranch |
|
120 */ |
|
121 nsIPrefBranch getDefaultBranch(in string aPrefRoot); |
|
122 |
|
123 }; |
|
124 |
|
125 %{C++ |
|
126 |
|
127 #define NS_PREFSERVICE_CID \ |
|
128 { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \ |
|
129 0x91ca2441, \ |
|
130 0x050f, \ |
|
131 0x4f7c, \ |
|
132 { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \ |
|
133 } |
|
134 |
|
135 #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1" |
|
136 |
|
137 /** |
|
138 * Notification sent before reading the default user preferences files. |
|
139 */ |
|
140 #define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs" |
|
141 |
|
142 /** |
|
143 * Notification sent when resetPrefs has been called, but before the actual |
|
144 * reset process occurs. |
|
145 */ |
|
146 #define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset" |
|
147 |
|
148 /** |
|
149 * Notification sent when after reading app-provided default |
|
150 * preferences, but before user profile override defaults or extension |
|
151 * defaults are loaded. |
|
152 */ |
|
153 #define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults" |
|
154 |
|
155 %} |