michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsIPrefBranch.idl" michael@0: michael@0: %{C++ michael@0: struct PrefTuple; michael@0: #include "nsTArrayForwardDeclare.h" michael@0: %} michael@0: michael@0: [ptr] native nsPreferencesArrayPtr(nsTArray); michael@0: [ptr] native nsPreferencePtr(PrefTuple); michael@0: [ptr] native nsPreferencePtrConst(const PrefTuple); michael@0: michael@0: interface nsIFile; michael@0: michael@0: /** michael@0: * The nsIPrefService interface is the main entry point into the back end michael@0: * preferences management library. The preference service is directly michael@0: * responsible for the management of the preferences files and also facilitates michael@0: * access to the preference branch object which allows the direct manipulation michael@0: * of the preferences themselves. michael@0: * michael@0: * @see nsIPrefBranch michael@0: */ michael@0: michael@0: [scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)] michael@0: interface nsIPrefService : nsISupports michael@0: { michael@0: /** michael@0: * Called to read in the preferences specified in a user preference file. michael@0: * michael@0: * @param aFile The file to be read. michael@0: * michael@0: * @note michael@0: * If nullptr is passed in for the aFile parameter the default preferences michael@0: * file(s) [prefs.js, user.js] will be read and processed. michael@0: * michael@0: * @throws Error File failed to read or contained invalid data. michael@0: * michael@0: * @see savePrefFile michael@0: * @see nsIFile michael@0: */ michael@0: void readUserPrefs(in nsIFile aFile); michael@0: michael@0: /** michael@0: * Called to completely flush and re-initialize the preferences system. michael@0: * michael@0: * @throws Error The preference service failed to restart correctly. michael@0: */ michael@0: void resetPrefs(); michael@0: michael@0: /** michael@0: * Called to reset all preferences with user set values back to the michael@0: * application default values. michael@0: */ michael@0: void resetUserPrefs(); michael@0: michael@0: /** michael@0: * Called to write current preferences state to a file. michael@0: * michael@0: * @param aFile The file to be written. michael@0: * michael@0: * @note michael@0: * If nullptr is passed in for the aFile parameter the preference data is michael@0: * written out to the current preferences file (usually prefs.js.) michael@0: * michael@0: * @throws Error File failed to write. michael@0: * michael@0: * @see readUserPrefs michael@0: * @see nsIFile michael@0: */ michael@0: void savePrefFile(in nsIFile aFile); michael@0: michael@0: /** michael@0: * Call to get a Preferences "Branch" which accesses user preference data. michael@0: * Using a Set method on this object will always create or set a user michael@0: * preference value. When using a Get method a user set value will be michael@0: * returned if one exists, otherwise a default value will be returned. michael@0: * michael@0: * @param aPrefRoot The preference "root" on which to base this "branch". michael@0: * For example, if the root "browser.startup." is used, the michael@0: * branch will be able to easily access the preferences michael@0: * "browser.startup.page", "browser.startup.homepage", or michael@0: * "browser.startup.homepage_override" by simply requesting michael@0: * "page", "homepage", or "homepage_override". nullptr or "" michael@0: * may be used to access to the entire preference "tree". michael@0: * michael@0: * @return nsIPrefBranch The object representing the requested branch. michael@0: * michael@0: * @see getDefaultBranch michael@0: */ michael@0: nsIPrefBranch getBranch(in string aPrefRoot); michael@0: michael@0: /** michael@0: * Call to get a Preferences "Branch" which accesses only the default michael@0: * preference data. Using a Set method on this object will always create or michael@0: * set a default preference value. When using a Get method a default value michael@0: * will always be returned. michael@0: * michael@0: * @param aPrefRoot The preference "root" on which to base this "branch". michael@0: * For example, if the root "browser.startup." is used, the michael@0: * branch will be able to easily access the preferences michael@0: * "browser.startup.page", "browser.startup.homepage", or michael@0: * "browser.startup.homepage_override" by simply requesting michael@0: * "page", "homepage", or "homepage_override". nullptr or "" michael@0: * may be used to access to the entire preference "tree". michael@0: * michael@0: * @note michael@0: * Few consumers will want to create default branch objects. Many of the michael@0: * branch methods do nothing on a default branch because the operations only michael@0: * make sense when applied to user set preferences. michael@0: * michael@0: * @return nsIPrefBranch The object representing the requested default branch. michael@0: * michael@0: * @see getBranch michael@0: */ michael@0: nsIPrefBranch getDefaultBranch(in string aPrefRoot); michael@0: michael@0: }; michael@0: michael@0: %{C++ michael@0: michael@0: #define NS_PREFSERVICE_CID \ michael@0: { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \ michael@0: 0x91ca2441, \ michael@0: 0x050f, \ michael@0: 0x4f7c, \ michael@0: { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \ michael@0: } michael@0: michael@0: #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1" michael@0: michael@0: /** michael@0: * Notification sent before reading the default user preferences files. michael@0: */ michael@0: #define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs" michael@0: michael@0: /** michael@0: * Notification sent when resetPrefs has been called, but before the actual michael@0: * reset process occurs. michael@0: */ michael@0: #define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset" michael@0: michael@0: /** michael@0: * Notification sent when after reading app-provided default michael@0: * preferences, but before user profile override defaults or extension michael@0: * defaults are loaded. michael@0: */ michael@0: #define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults" michael@0: michael@0: %}