1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>gconf-backend</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7 <link rel="start" href="index.html" title="GConf Reference Manual">
8 <link rel="up" href="ch01.html" title="Using the GConf library">
9 <link rel="prev" href="gconf-GConfClient.html" title="GConfClient">
10 <link rel="next" href="gconf-gconf-engine.html" title="GConfEngine">
11 <meta name="generator" content="GTK-Doc V1.10 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="ch01.html" title="Using the GConf library">
15 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
16 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
18 <td><a accesskey="p" href="gconf-GConfClient.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
19 <td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
20 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
21 <th width="100%" align="center">GConf Reference Manual</th>
22 <td><a accesskey="n" href="gconf-gconf-engine.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
24 <tr><td colspan="5" class="shortcuts"><nobr><a href="#id2598997" class="shortcut">Top</a>
26 <a href="#id2582576" class="shortcut">Description</a></nobr></td></tr>
28 <div class="refentry" lang="en">
29 <a name="gconf-gconf-backend"></a><div class="titlepage"></div>
30 <div class="refnamediv"><table width="100%"><tr>
33 <a name="id2598997"></a><span class="refentrytitle">gconf-backend</span>
37 <td valign="top" align="right"></td>
39 <div class="refsynopsisdiv">
41 <pre class="synopsis">
45 <a class="link" href="gconf-gconf-backend.html#GConfBackendVTable">GConfBackendVTable</a>;
46 <a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a>;
47 gchar* <a class="link" href="gconf-gconf-backend.html#gconf-address-backend">gconf_address_backend</a> (const gchar *address);
48 gchar* <a class="link" href="gconf-gconf-backend.html#gconf-address-resource">gconf_address_resource</a> (const gchar *address);
49 gchar* <a class="link" href="gconf-gconf-backend.html#gconf-backend-file">gconf_backend_file</a> (const gchar *address);
50 <a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a>* <a class="link" href="gconf-gconf-backend.html#gconf-get-backend">gconf_get_backend</a> (const gchar *address,
52 void <a class="link" href="gconf-gconf-backend.html#gconf-backend-ref">gconf_backend_ref</a> (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);
53 void <a class="link" href="gconf-gconf-backend.html#gconf-backend-unref">gconf_backend_unref</a> (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);
54 <a class="link" href="gconf-gconf-sources.html#GConfSource">GConfSource</a>* <a class="link" href="gconf-gconf-backend.html#gconf-backend-resolve-address">gconf_backend_resolve_address</a> (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend,
59 <div class="refsect1" lang="en">
60 <a name="id2582576"></a><h2>Description</h2>
65 <div class="refsect1" lang="en">
66 <a name="id2582592"></a><h2>Details</h2>
67 <div class="refsect2" lang="en">
68 <a name="id2582603"></a><h3>
69 <a name="GConfBackendVTable"></a>GConfBackendVTable</h3>
70 <a class="indexterm" name="id2621151"></a><pre class="programlisting">typedef struct {
71 /* Set to sizeof (GConfBackendVTable) - used for future proofing */
74 void (* shutdown) (GError** err);
76 GConfSource* (* resolve_address) (const gchar* address,
79 /* Thread locks. If the backend is thread-safe, then these
80 * can be NULL. If per-source locks are needed, then these
81 * calls should lock a mutex stored in the GConfSource.
82 * If a per-backend lock is needed, then the calls can ignore
83 * their source argument and lock the whole backend.
85 void (* lock) (GConfSource* source,
88 void (* unlock) (GConfSource* source,
91 /* Report whether a given key (and its subkeys) can be read/written.
92 * Sources may not permit reading/writing from/to /foo but forbid
93 * writing to /foo/bar; if a key can be read or written then its
94 * subkeys may also be read/written.
96 * This field allows backends to be configured so that they only
97 * store certain kinds of data in certain sections of the GConf
100 * If these functions return an error, they MUST return FALSE as
104 gboolean (* readable) (GConfSource* source,
108 gboolean (* writable) (GConfSource* source,
112 /* schema_name filled if NULL or GCONF_VALUE_IGNORE_SUBSEQUENT returned.
113 if schema_name is NULL, it isn't filled */
114 GConfValue* (* query_value) (GConfSource* source,
116 const gchar** locales,
120 GConfMetaInfo* (* query_metainfo) (GConfSource* source,
124 void (* set_value) (GConfSource* source,
126 const GConfValue* value,
129 /* Returns list of GConfEntry with key set to a relative
130 * pathname. In the public client-side API the key
131 * is always absolute though.
133 GSList* (* all_entries) (GConfSource* source,
135 const gchar** locales,
138 /* Returns list of allocated strings, relative names */
139 GSList* (* all_subdirs) (GConfSource* source,
143 void (* unset_value) (GConfSource* source,
148 gboolean (* dir_exists) (GConfSource* source,
152 void (* remove_dir) (GConfSource* source,
156 void (* set_schema) (GConfSource* source,
158 const gchar* schema_key,
161 gboolean (* sync_all) (GConfSource* source,
164 void (* destroy_source) (GConfSource* source);
166 /* This is basically used by the test suite */
167 void (* clear_cache) (GConfSource* source);
169 /* used by gconf-sanity-check */
170 void (* blow_away_locks) (const char *address);
172 void (* set_notify_func) (GConfSource *source,
173 GConfSourceNotifyFunc notify_func,
176 void (* add_listener) (GConfSource *source,
178 const gchar *namespace_section);
180 void (* remove_listener) (GConfSource *source,
182 } GConfBackendVTable;
185 The <a class="link" href="gconf-gconf-backend.html#GConfBackendVTable"><span class="type">GConfBackendVTable</span></a> is a table of methods that any GConf backend must
186 implement. The dynamically loaded library module should export a function
187 called <code class="function">gconf_backend_get_vtable()</code> that returns a pointer to a
188 <a class="link" href="gconf-gconf-backend.html#GConfBackendVTable"><span class="type">GConfBackendVTable</span></a>.
191 Here is the specification of the vtable members:
194 <div class="informaltable"><table width="100%" border="0">
201 <td><em class="parameter"><code>vtable_size</code></em></td>
203 The size of the vtable structure. This is used by the daemon to ensure that
204 a mismatch between the version of GConf the backend was compiled against and
205 the version the daemon was compiled against can be handled gracefully. Set
206 this field to sizeof (GConfBackendVtable).
210 <td><em class="parameter"><code>shutdown</code></em></td>
211 <td>Called prior to unloading the dynamic
212 module. Should ensure that no functions or static/global variables from the
213 module will ever be accessed again. Should free any memory that the backend
218 <td><em class="parameter"><code>resolve_address</code></em></td>
220 Should create a <a class="link" href="gconf-gconf-sources.html#GConfSource"><span class="type">GConfSource</span></a> for accessing the supplied address. Should set the
221 <code class="literal">GCONF_SOURCE_ALL_READABLE</code> and <code class="literal">GCONF_SOURCE_ALL_WRITEABLE</code> flags if
222 appropriate. If these are not set, the backend must implement the <em class="parameter"><code>writable</code></em> and
223 <em class="parameter"><code>readable</code></em> methods. If <span class="symbol">NULL</span> is returned, then the error should
228 <td><em class="parameter"><code>lock</code></em></td>
229 <td>If the backend is thread safe (does its own locking or whatever), then
230 <em class="parameter"><code>lock</code></em> and <em class="parameter"><code>unlock</code></em> can be <span class="symbol">NULL</span>. If the backend requires a lock
231 for each source, then <em class="parameter"><code>lock</code></em> and <em class="parameter"><code>unlock</code></em> should lock/unlock that lock. If the
232 backend has a global lock for all uses of the backend, then <em class="parameter"><code>lock</code></em> and <em class="parameter"><code>unlock</code></em>
233 should ignore their arguments and lock the entire backend.
237 <td><em class="parameter"><code>unlock</code></em></td>
238 <td>See description of <em class="parameter"><code>lock</code></em>.</td>
241 <td><em class="parameter"><code>readable</code></em></td>
243 If the <code class="literal">GCONF_SOURCE_ALL_READABLE</code> flag is set, this method is never called and
244 may be <span class="symbol">NULL</span>. If <code class="literal">GCONF_SOURCE_ALL_READABLE</code> is unset, and this
245 method is <span class="symbol">NULL</span>, then the source is write-only. If this method
246 is implemented, it should return <span class="symbol">TRUE</span> if the given key could be
247 read from the given source. <span class="symbol">TRUE</span> should be returned even if the
248 key is unset; this function returns something similar to permissions, it is not
249 asking whether the key exists. <span class="emphasis"><em>If an error is set, then
250 <span class="symbol">FALSE</span> must be returned.</em></span>
254 <td><em class="parameter"><code>writable</code></em></td>
255 <td>Analagous to <em class="parameter"><code>readable</code></em>, but for writing.</td>
258 <td><em class="parameter"><code>query_value</code></em></td>
259 <td>This method must be implemented if the source is readable. It returns the
260 value of a key. The "locales" argument is a <span class="symbol">NULL</span>-terminated
261 vector of locale names, where the first locale in the vector is the preferred
262 locale, the next is the second choice, etc. if the "schema_name" argument is
263 non-<span class="symbol">NULL</span>, then it should be filled with an allocated string
264 giving the name of the schema attached to the key, if and only if
265 <span class="symbol">NULL</span> is returned. This is an optimization to avoid looking up
266 the same key again in the database if it's unset and we need to ask for its
267 default value from the schema. If <span class="symbol">NULL</span> is returned, indicating
268 that the key is unset, then schema_name should not be filled in. If this method
269 sets an error, <span class="symbol">NULL</span> must be returned. It may not set an error
270 while also returning a value. The returned value will be destroyed by the
271 caller, so should be a copy of the backend's internal data.
275 <td><em class="parameter"><code>query_metainfo</code></em></td>
276 <td>This method must be implemented. If any metainfo is
277 available about a key, it returns a <a class="link" href="gconf-gconf-value.html#GConfMetaInfo"><span class="type">GConfMetaInfo</span></a> with that metainfo set. If
278 none is available, <span class="symbol">NULL</span> is returned. <span class="symbol">NULL</span>
279 should also be returned if an error is set.
283 <td><em class="parameter"><code>set_value</code></em></td>
284 <td>This method must be implemented if the source is
285 writable. It sets the value of a key. If the key is already set, its value
286 should be replaced. Setting a value should update the modification time of the
291 <td><em class="parameter"><code>all_entries</code></em></td>
292 <td>This method must be implemented. It returns a list of all keys in the
293 given directory for which some information is available (metainfo or
294 values). The returned list should contain <a class="link" href="gconf-gconf-value.html#GConfEntry"><span class="type">GConfEntry</span></a> objects. On error,
295 <span class="symbol">NULL</span> should be returned and the error set. Subdirectories
296 should not be included in the returned list. The list and the <a class="link" href="gconf-gconf-value.html#GConfEntry"><span class="type">GConfEntry</span></a>
297 objects will be freed by the caller.
301 <td><em class="parameter"><code>all_subdirs</code></em></td>
302 <td>This method must be implemented. It returns a list of all the subdirectories in a given
303 directory. It should return the subdirectories as relative paths, i.e. there
304 should not be any slashes in the subdirectory name. Each subdirectory in the list
305 should be an allocated string; the list and the strings will be freed by the caller.
309 <td><em class="parameter"><code>unset_value</code></em></td>
310 <td>If the given key has a value, then this method should unset the value.
311 If a value is unset, subsequent calls to <em class="parameter"><code>query_value</code></em> should return
312 <span class="symbol">NULL</span>. If the locale string passed in to <em class="parameter"><code>unset_value</code></em> is
313 non-<span class="symbol">NULL</span>, then only the value for that locale should be
314 unset. If <span class="symbol">NULL</span>, the value should be globally unset for all
319 <td><em class="parameter"><code>dir_exists</code></em></td>
321 Determines whether a directory exists. Should return
322 <span class="symbol">TRUE</span> if there is a directory with the given name.
326 <td><em class="parameter"><code>remove_dir</code></em></td>
328 Should remove a directory, recursively: including all its subdirectories and
329 all the values and keys inside the directory.
333 <td><em class="parameter"><code>set_schema</code></em></td>
334 <td>Should associate a schema name with a key.
338 <td><em class="parameter"><code>sync_all</code></em></td>
340 Should ensure that all data is stored on permanent media, or whatever makes
341 sense for the backend. Called periodically by the GConf daemon.
345 <td><em class="parameter"><code>destroy_source</code></em></td>
347 Should destroy a source obtained with <em class="parameter"><code>resolve_address</code></em>.
351 <td><em class="parameter"><code>clear_cache</code></em></td>
353 Discard any cached data after saving the data to permanent storage.
357 <td><em class="parameter"><code>blow_away_locks</code></em></td>
359 Unconditionally discard any locks whether they are stale or otherwise in
360 order to force the backend to be able to obtain access to its data store.
364 <td><em class="parameter"><code>set_notify_func</code></em></td>
366 If the backend wishes to notify the daemon of changes in the value of
367 keys it must implement this method. In order to notify the daemon
368 of a change, the backend should invoke the supplied <em class="parameter"><code>notify_func</code></em> with
369 <em class="parameter"><code>user_data</code></em>. Backends must not notify the daemon of changes which the
370 daemon has not expressed interest in by adding a listener with
371 <em class="parameter"><code>add_listener</code></em>. Also, the backend must make every effort to minimise the
372 number of notifications it emits. For example, if the daemon has added
373 a listener for /apps and another for /apps/foo and the value of
374 /apps/foo/bar changes, the backend should only emit a single notification.
378 <td><em class="parameter"><code>add_listener</code></em></td>
380 If it is possible for entries to be changed concurrently by another
381 daemon, the backend may support notifying the daemon (and any listening
382 clients) of such changes. This function should add a listener to a
383 section of the tree and when any of the following events occur, the
384 backend should invoke the notify function with the key that has changed:
385 <div class="itemizedlist"><ul type="bullet">
386 <li style="list-style-type: disc"><p>If the entry is set or unset</p></li>
387 <li style="list-style-type: disc"><p>If the entry's value changes</p></li>
388 <li style="list-style-type: disc"><p>If the entry's schema name changes</p></li>
389 <li style="list-style-type: disc"><p>
390 If the entry is a schema and its value in <span class="emphasis"><em>any</em></span>
394 Note, the backend should <span class="emphasis"><em>not</em></span> notify the daemon of
395 any changes that originated from the daemon itself.
399 <td><em class="parameter"><code>remove_listener</code></em></td>
401 Remove a listener added with <em class="parameter"><code>add_listener</code></em>. The listener is identified
402 by the integer supplied.
411 <div class="refsect2" lang="en">
412 <a name="id2622707"></a><h3>
413 <a name="GConfBackend"></a>GConfBackend</h3>
414 <a class="indexterm" name="id2622720"></a><pre class="programlisting">typedef struct {
417 GConfBackendVTable vtable;
426 <div class="refsect2" lang="en">
427 <a name="id2622737"></a><h3>
428 <a name="gconf-address-backend"></a>gconf_address_backend ()</h3>
429 <a class="indexterm" name="id2622748"></a><pre class="programlisting">gchar* gconf_address_backend (const gchar *address);</pre>
433 <div class="variablelist"><table border="0">
434 <col align="left" valign="top">
437 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
442 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
452 <div class="refsect2" lang="en">
453 <a name="id2622805"></a><h3>
454 <a name="gconf-address-resource"></a>gconf_address_resource ()</h3>
455 <a class="indexterm" name="id2622816"></a><pre class="programlisting">gchar* gconf_address_resource (const gchar *address);</pre>
459 <div class="variablelist"><table border="0">
460 <col align="left" valign="top">
463 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
468 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
478 <div class="refsect2" lang="en">
479 <a name="id2622872"></a><h3>
480 <a name="gconf-backend-file"></a>gconf_backend_file ()</h3>
481 <a class="indexterm" name="id2622885"></a><pre class="programlisting">gchar* gconf_backend_file (const gchar *address);</pre>
485 <div class="variablelist"><table border="0">
486 <col align="left" valign="top">
489 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
494 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
504 <div class="refsect2" lang="en">
505 <a name="id2622941"></a><h3>
506 <a name="gconf-get-backend"></a>gconf_get_backend ()</h3>
507 <a class="indexterm" name="id2622954"></a><pre class="programlisting"><a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a>* gconf_get_backend (const gchar *address,
512 <div class="variablelist"><table border="0">
513 <col align="left" valign="top">
516 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
521 <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
526 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
536 <div class="refsect2" lang="en">
537 <a name="id2623032"></a><h3>
538 <a name="gconf-backend-ref"></a>gconf_backend_ref ()</h3>
539 <a class="indexterm" name="id2623044"></a><pre class="programlisting">void gconf_backend_ref (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);</pre>
543 <div class="variablelist"><table border="0">
544 <col align="left" valign="top">
546 <td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
555 <div class="refsect2" lang="en">
556 <a name="id2623090"></a><h3>
557 <a name="gconf-backend-unref"></a>gconf_backend_unref ()</h3>
558 <a class="indexterm" name="id2623102"></a><pre class="programlisting">void gconf_backend_unref (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);</pre>
562 <div class="variablelist"><table border="0">
563 <col align="left" valign="top">
565 <td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
574 <div class="refsect2" lang="en">
575 <a name="id2623148"></a><h3>
576 <a name="gconf-backend-resolve-address"></a>gconf_backend_resolve_address ()</h3>
577 <a class="indexterm" name="id2623160"></a><pre class="programlisting"><a class="link" href="gconf-gconf-sources.html#GConfSource">GConfSource</a>* gconf_backend_resolve_address (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend,
578 const gchar *address,
583 <div class="variablelist"><table border="0">
584 <col align="left" valign="top">
587 <td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
592 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
597 <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
602 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
612 <div class="refsect1" lang="en">
613 <a name="id2623260"></a><div class="refsect2" lang="en"><a name="id2623261"></a></div>
615 <div class="refsect2" lang="en"><a name="id2623262"></a></div>