modules/libpref/public/nsIPrefService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libpref/public/nsIPrefService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +#include "nsIPrefBranch.idl"
    1.11 +
    1.12 +%{C++
    1.13 +struct PrefTuple;
    1.14 +#include "nsTArrayForwardDeclare.h"
    1.15 +%}
    1.16 +
    1.17 +[ptr] native nsPreferencesArrayPtr(nsTArray<PrefTuple>);
    1.18 +[ptr] native nsPreferencePtr(PrefTuple);
    1.19 +[ptr] native nsPreferencePtrConst(const PrefTuple);
    1.20 +
    1.21 +interface nsIFile;
    1.22 +
    1.23 +/**
    1.24 + * The nsIPrefService interface is the main entry point into the back end
    1.25 + * preferences management library. The preference service is directly
    1.26 + * responsible for the management of the preferences files and also facilitates
    1.27 + * access to the preference branch object which allows the direct manipulation
    1.28 + * of the preferences themselves.
    1.29 + *
    1.30 + * @see nsIPrefBranch
    1.31 + */
    1.32 +
    1.33 +[scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)]
    1.34 +interface nsIPrefService : nsISupports
    1.35 +{
    1.36 +  /**
    1.37 +   * Called to read in the preferences specified in a user preference file.
    1.38 +   *
    1.39 +   * @param aFile The file to be read.
    1.40 +   *
    1.41 +   * @note
    1.42 +   * If nullptr is passed in for the aFile parameter the default preferences
    1.43 +   * file(s) [prefs.js, user.js] will be read and processed.
    1.44 +   *
    1.45 +   * @throws Error File failed to read or contained invalid data.
    1.46 +   *
    1.47 +   * @see savePrefFile
    1.48 +   * @see nsIFile
    1.49 +   */
    1.50 +  void readUserPrefs(in nsIFile aFile);
    1.51 +
    1.52 +  /**
    1.53 +   * Called to completely flush and re-initialize the preferences system.
    1.54 +   *
    1.55 +   * @throws Error The preference service failed to restart correctly.
    1.56 +   */
    1.57 +  void resetPrefs();
    1.58 +
    1.59 +  /**
    1.60 +   * Called to reset all preferences with user set values back to the
    1.61 +   * application default values.
    1.62 +   */
    1.63 +  void resetUserPrefs();
    1.64 +
    1.65 +  /**
    1.66 +   * Called to write current preferences state to a file.
    1.67 +   *
    1.68 +   * @param aFile The file to be written.
    1.69 +   *
    1.70 +   * @note
    1.71 +   * If nullptr is passed in for the aFile parameter the preference data is
    1.72 +   * written out to the current preferences file (usually prefs.js.)
    1.73 +   *
    1.74 +   * @throws Error File failed to write.
    1.75 +   *
    1.76 +   * @see readUserPrefs
    1.77 +   * @see nsIFile
    1.78 +   */
    1.79 +  void savePrefFile(in nsIFile aFile);
    1.80 +
    1.81 +  /**
    1.82 +   * Call to get a Preferences "Branch" which accesses user preference data.
    1.83 +   * Using a Set method on this object will always create or set a user
    1.84 +   * preference value. When using a Get method a user set value will be
    1.85 +   * returned if one exists, otherwise a default value will be returned.
    1.86 +   *
    1.87 +   * @param aPrefRoot The preference "root" on which to base this "branch".
    1.88 +   *                  For example, if the root "browser.startup." is used, the
    1.89 +   *                  branch will be able to easily access the preferences
    1.90 +   *                  "browser.startup.page", "browser.startup.homepage", or
    1.91 +   *                  "browser.startup.homepage_override" by simply requesting
    1.92 +   *                  "page", "homepage", or "homepage_override". nullptr or "" 
    1.93 +   *                  may be used to access to the entire preference "tree".
    1.94 +   *
    1.95 +   * @return nsIPrefBranch The object representing the requested branch.
    1.96 +   *
    1.97 +   * @see getDefaultBranch
    1.98 +   */
    1.99 +  nsIPrefBranch getBranch(in string aPrefRoot);
   1.100 +
   1.101 +  /**
   1.102 +   * Call to get a Preferences "Branch" which accesses only the default 
   1.103 +   * preference data. Using a Set method on this object will always create or
   1.104 +   * set a default preference value. When using a Get method a default value
   1.105 +   * will always be returned.
   1.106 +   *
   1.107 +   * @param aPrefRoot The preference "root" on which to base this "branch".
   1.108 +   *                  For example, if the root "browser.startup." is used, the
   1.109 +   *                  branch will be able to easily access the preferences
   1.110 +   *                  "browser.startup.page", "browser.startup.homepage", or
   1.111 +   *                  "browser.startup.homepage_override" by simply requesting
   1.112 +   *                  "page", "homepage", or "homepage_override". nullptr or "" 
   1.113 +   *                  may be used to access to the entire preference "tree".
   1.114 +   *
   1.115 +   * @note
   1.116 +   * Few consumers will want to create default branch objects. Many of the
   1.117 +   * branch methods do nothing on a default branch because the operations only
   1.118 +   * make sense when applied to user set preferences.
   1.119 +   *
   1.120 +   * @return nsIPrefBranch The object representing the requested default branch.
   1.121 +   *
   1.122 +   * @see getBranch
   1.123 +   */
   1.124 +  nsIPrefBranch getDefaultBranch(in string aPrefRoot);
   1.125 +
   1.126 +};
   1.127 +
   1.128 +%{C++
   1.129 +
   1.130 +#define NS_PREFSERVICE_CID                             \
   1.131 +  { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */       \
   1.132 +    0x91ca2441,                                        \
   1.133 +    0x050f,                                            \
   1.134 +    0x4f7c,                                            \
   1.135 +    { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \
   1.136 +  }
   1.137 +
   1.138 +#define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1"
   1.139 +
   1.140 +/**
   1.141 + * Notification sent before reading the default user preferences files.
   1.142 + */
   1.143 +#define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs"
   1.144 +
   1.145 +/**
   1.146 + * Notification sent when resetPrefs has been called, but before the actual
   1.147 + * reset process occurs.
   1.148 + */
   1.149 +#define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset"
   1.150 +
   1.151 +/**
   1.152 + * Notification sent when after reading app-provided default
   1.153 + * preferences, but before user profile override defaults or extension
   1.154 + * defaults are loaded.
   1.155 + */
   1.156 +#define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults"
   1.157 +
   1.158 +%}

mercurial