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.8 (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="#id2863130" class="shortcut">Top</a>
26
<a href="#id2871219" 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="id2863130"></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>;
48
href="../glib/glib-Basic-Types.html#gchar"
49
>gchar</a>* <a class="link" href="gconf-gconf-backend.html#gconf-address-backend">gconf_address_backend</a> (const <a
50
href="../glib/glib-Basic-Types.html#gchar"
53
href="../glib/glib-Basic-Types.html#gchar"
54
>gchar</a>* <a class="link" href="gconf-gconf-backend.html#gconf-address-resource">gconf_address_resource</a> (const <a
55
href="../glib/glib-Basic-Types.html#gchar"
58
href="../glib/glib-Basic-Types.html#gchar"
59
>gchar</a>* <a class="link" href="gconf-gconf-backend.html#gconf-backend-file">gconf_backend_file</a> (const <a
60
href="../glib/glib-Basic-Types.html#gchar"
62
<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 <a
63
href="../glib/glib-Basic-Types.html#gchar"
66
href="../glib/glib-Error-Reporting.html#GError"
68
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);
69
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);
70
<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,
72
href="../glib/glib-Basic-Types.html#gchar"
75
href="../glib/glib-Error-Reporting.html#GError"
79
<div class="refsect1" lang="en">
80
<a name="id2871219"></a><h2>Description</h2>
85
<div class="refsect1" lang="en">
86
<a name="id2871234"></a><h2>Details</h2>
87
<div class="refsect2" lang="en">
88
<a name="id2871245"></a><h3>
89
<a name="GConfBackendVTable"></a>GConfBackendVTable</h3>
90
<a class="indexterm" name="id2865318"></a><pre class="programlisting">typedef struct {
91
/* Set to sizeof (GConfBackendVTable) - used for future proofing */
94
void (* shutdown) (GError** err);
96
GConfSource* (* resolve_address) (const gchar* address,
99
/* Thread locks. If the backend is thread-safe, then these
100
* can be NULL. If per-source locks are needed, then these
101
* calls should lock a mutex stored in the GConfSource.
102
* If a per-backend lock is needed, then the calls can ignore
103
* their source argument and lock the whole backend.
105
void (* lock) (GConfSource* source,
108
void (* unlock) (GConfSource* source,
111
/* Report whether a given key (and its subkeys) can be read/written.
112
* Sources may not permit reading/writing from/to /foo but forbid
113
* writing to /foo/bar; if a key can be read or written then its
114
* subkeys may also be read/written.
116
* This field allows backends to be configured so that they only
117
* store certain kinds of data in certain sections of the GConf
120
* If these functions return an error, they MUST return FALSE as
124
gboolean (* readable) (GConfSource* source,
128
gboolean (* writable) (GConfSource* source,
132
/* schema_name filled if NULL or GCONF_VALUE_IGNORE_SUBSEQUENT returned.
133
if schema_name is NULL, it isn't filled */
134
GConfValue* (* query_value) (GConfSource* source,
136
const gchar** locales,
140
GConfMetaInfo* (* query_metainfo) (GConfSource* source,
144
void (* set_value) (GConfSource* source,
146
const GConfValue* value,
149
/* Returns list of GConfEntry with key set to a relative
150
* pathname. In the public client-side API the key
151
* is always absolute though.
153
GSList* (* all_entries) (GConfSource* source,
155
const gchar** locales,
158
/* Returns list of allocated strings, relative names */
159
GSList* (* all_subdirs) (GConfSource* source,
163
void (* unset_value) (GConfSource* source,
168
gboolean (* dir_exists) (GConfSource* source,
172
void (* remove_dir) (GConfSource* source,
176
void (* set_schema) (GConfSource* source,
178
const gchar* schema_key,
181
gboolean (* sync_all) (GConfSource* source,
184
void (* destroy_source) (GConfSource* source);
186
/* This is basically used by the test suite */
187
void (* clear_cache) (GConfSource* source);
189
/* used by gconf-sanity-check */
190
void (* blow_away_locks) (const char *address);
192
void (* set_notify_func) (GConfSource *source,
193
GConfSourceNotifyFunc notify_func,
196
void (* add_listener) (GConfSource *source,
198
const gchar *namespace_section);
200
void (* remove_listener) (GConfSource *source,
202
} GConfBackendVTable;
205
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
206
implement. The dynamically loaded library module should export a function
207
called <code class="function">gconf_backend_get_vtable()</code> that returns a pointer to a
208
<a class="link" href="gconf-gconf-backend.html#GConfBackendVTable"><span class="type">GConfBackendVTable</span></a>.
211
Here is the specification of the vtable members:
214
<div class="informaltable"><table width="100%" border="0">
221
<td><em class="parameter"><code>vtable_size</code></em></td>
223
The size of the vtable structure. This is used by the daemon to ensure that
224
a mismatch between the version of GConf the backend was compiled against and
225
the version the daemon was compiled against can be handled gracefully. Set
226
this field to sizeof (GConfBackendVtable).
230
<td><em class="parameter"><code>shutdown</code></em></td>
231
<td>Called prior to unloading the dynamic
232
module. Should ensure that no functions or static/global variables from the
233
module will ever be accessed again. Should free any memory that the backend
238
<td><em class="parameter"><code>resolve_address</code></em></td>
240
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
241
<code class="literal">GCONF_SOURCE_ALL_READABLE</code> and <code class="literal">GCONF_SOURCE_ALL_WRITEABLE</code> flags if
242
appropriate. If these are not set, the backend must implement the <em class="parameter"><code>writable</code></em> and
243
<em class="parameter"><code>readable</code></em> methods. If <span class="symbol">NULL</span> is returned, then the error should
248
<td><em class="parameter"><code>lock</code></em></td>
249
<td>If the backend is thread safe (does its own locking or whatever), then
250
<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
251
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
252
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>
253
should ignore their arguments and lock the entire backend.
257
<td><em class="parameter"><code>unlock</code></em></td>
258
<td>See description of <em class="parameter"><code>lock</code></em>.</td>
261
<td><em class="parameter"><code>readable</code></em></td>
263
If the <code class="literal">GCONF_SOURCE_ALL_READABLE</code> flag is set, this method is never called and
264
may be <span class="symbol">NULL</span>. If <code class="literal">GCONF_SOURCE_ALL_READABLE</code> is unset, and this
265
method is <span class="symbol">NULL</span>, then the source is write-only. If this method
266
is implemented, it should return <span class="symbol">TRUE</span> if the given key could be
267
read from the given source. <span class="symbol">TRUE</span> should be returned even if the
268
key is unset; this function returns something similar to permissions, it is not
269
asking whether the key exists. <span class="emphasis"><em>If an error is set, then
270
<span class="symbol">FALSE</span> must be returned.</em></span>
274
<td><em class="parameter"><code>writable</code></em></td>
275
<td>Analagous to <em class="parameter"><code>readable</code></em>, but for writing.</td>
278
<td><em class="parameter"><code>query_value</code></em></td>
279
<td>This method must be implemented if the source is readable. It returns the
280
value of a key. The "locales" argument is a <span class="symbol">NULL</span>-terminated
281
vector of locale names, where the first locale in the vector is the preferred
282
locale, the next is the second choice, etc. if the "schema_name" argument is
283
non-<span class="symbol">NULL</span>, then it should be filled with an allocated string
284
giving the name of the schema attached to the key, if and only if
285
<span class="symbol">NULL</span> is returned. This is an optimization to avoid looking up
286
the same key again in the database if it's unset and we need to ask for its
287
default value from the schema. If <span class="symbol">NULL</span> is returned, indicating
288
that the key is unset, then schema_name should not be filled in. If this method
289
sets an error, <span class="symbol">NULL</span> must be returned. It may not set an error
290
while also returning a value. The returned value will be destroyed by the
291
caller, so should be a copy of the backend's internal data.
295
<td><em class="parameter"><code>query_metainfo</code></em></td>
296
<td>This method must be implemented. If any metainfo is
297
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
298
none is available, <span class="symbol">NULL</span> is returned. <span class="symbol">NULL</span>
299
should also be returned if an error is set.
303
<td><em class="parameter"><code>set_value</code></em></td>
304
<td>This method must be implemented if the source is
305
writable. It sets the value of a key. If the key is already set, its value
306
should be replaced. Setting a value should update the modification time of the
311
<td><em class="parameter"><code>all_entries</code></em></td>
312
<td>This method must be implemented. It returns a list of all keys in the
313
given directory for which some information is available (metainfo or
314
values). The returned list should contain <a class="link" href="gconf-gconf-value.html#GConfEntry"><span class="type">GConfEntry</span></a> objects. On error,
315
<span class="symbol">NULL</span> should be returned and the error set. Subdirectories
316
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>
317
objects will be freed by the caller.
321
<td><em class="parameter"><code>all_subdirs</code></em></td>
322
<td>This method must be implemented. It returns a list of all the subdirectories in a given
323
directory. It should return the subdirectories as relative paths, i.e. there
324
should not be any slashes in the subdirectory name. Each subdirectory in the list
325
should be an allocated string; the list and the strings will be freed by the caller.
329
<td><em class="parameter"><code>unset_value</code></em></td>
330
<td>If the given key has a value, then this method should unset the value.
331
If a value is unset, subsequent calls to <em class="parameter"><code>query_value</code></em> should return
332
<span class="symbol">NULL</span>. If the locale string passed in to <em class="parameter"><code>unset_value</code></em> is
333
non-<span class="symbol">NULL</span>, then only the value for that locale should be
334
unset. If <span class="symbol">NULL</span>, the value should be globally unset for all
339
<td><em class="parameter"><code>dir_exists</code></em></td>
341
Determines whether a directory exists. Should return
342
<span class="symbol">TRUE</span> if there is a directory with the given name.
346
<td><em class="parameter"><code>remove_dir</code></em></td>
348
Should remove a directory, recursively: including all its subdirectories and
349
all the values and keys inside the directory.
353
<td><em class="parameter"><code>set_schema</code></em></td>
354
<td>Should associate a schema name with a key.
358
<td><em class="parameter"><code>sync_all</code></em></td>
360
Should ensure that all data is stored on permanent media, or whatever makes
361
sense for the backend. Called periodically by the GConf daemon.
365
<td><em class="parameter"><code>destroy_source</code></em></td>
367
Should destroy a source obtained with <em class="parameter"><code>resolve_address</code></em>.
371
<td><em class="parameter"><code>clear_cache</code></em></td>
373
Discard any cached data after saving the data to permanent storage.
377
<td><em class="parameter"><code>blow_away_locks</code></em></td>
379
Unconditionally discard any locks whether they are stale or otherwise in
380
order to force the backend to be able to obtain access to its data store.
384
<td><em class="parameter"><code>set_notify_func</code></em></td>
386
If the backend wishes to notify the daemon of changes in the value of
387
keys it must implement this method. In order to notify the daemon
388
of a change, the backend should invoke the supplied <em class="parameter"><code>notify_func</code></em> with
389
<em class="parameter"><code>user_data</code></em>. Backends must not notify the daemon of changes which the
390
daemon has not expressed interest in by adding a listener with
391
<em class="parameter"><code>add_listener</code></em>. Also, the backend must make every effort to minimise the
392
number of notifications it emits. For example, if the daemon has added
393
a listener for /apps and another for /apps/foo and the value of
394
/apps/foo/bar changes, the backend should only emit a single notification.
398
<td><em class="parameter"><code>add_listener</code></em></td>
400
If it is possible for entries to be changed concurrently by another
401
daemon, the backend may support notifying the daemon (and any listening
402
clients) of such changes. This function should add a listener to a
403
section of the tree and when any of the following events occur, the
404
backend should invoke the notify function with the key that has changed:
405
<div class="itemizedlist"><ul type="bullet">
406
<li style="list-style-type: disc"><p>If the entry is set or unset</p></li>
407
<li style="list-style-type: disc"><p>If the entry's value changes</p></li>
408
<li style="list-style-type: disc"><p>If the entry's schema name changes</p></li>
409
<li style="list-style-type: disc"><p>
410
If the entry is a schema and its value in <span class="emphasis"><em>any</em></span>
414
Note, the backend should <span class="emphasis"><em>not</em></span> notify the daemon of
415
any changes that originated from the daemon itself.
419
<td><em class="parameter"><code>remove_listener</code></em></td>
421
Remove a listener added with <em class="parameter"><code>add_listener</code></em>. The listener is identified
422
by the integer supplied.
431
<div class="refsect2" lang="en">
432
<a name="id2856876"></a><h3>
433
<a name="GConfBackend"></a>GConfBackend</h3>
434
<a class="indexterm" name="id2856888"></a><pre class="programlisting">typedef struct {
437
GConfBackendVTable vtable;
446
<div class="refsect2" lang="en">
447
<a name="id2856906"></a><h3>
448
<a name="gconf-address-backend"></a>gconf_address_backend ()</h3>
449
<a class="indexterm" name="id2856917"></a><pre class="programlisting"><a
450
href="../glib/glib-Basic-Types.html#gchar"
451
>gchar</a>* gconf_address_backend (const <a
452
href="../glib/glib-Basic-Types.html#gchar"
453
>gchar</a> *address);</pre>
457
<div class="variablelist"><table border="0">
458
<col align="left" valign="top">
461
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
466
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
476
<div class="refsect2" lang="en">
477
<a name="id2856974"></a><h3>
478
<a name="gconf-address-resource"></a>gconf_address_resource ()</h3>
479
<a class="indexterm" name="id2856985"></a><pre class="programlisting"><a
480
href="../glib/glib-Basic-Types.html#gchar"
481
>gchar</a>* gconf_address_resource (const <a
482
href="../glib/glib-Basic-Types.html#gchar"
483
>gchar</a> *address);</pre>
487
<div class="variablelist"><table border="0">
488
<col align="left" valign="top">
491
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
496
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
506
<div class="refsect2" lang="en">
507
<a name="id2857041"></a><h3>
508
<a name="gconf-backend-file"></a>gconf_backend_file ()</h3>
509
<a class="indexterm" name="id2857054"></a><pre class="programlisting"><a
510
href="../glib/glib-Basic-Types.html#gchar"
511
>gchar</a>* gconf_backend_file (const <a
512
href="../glib/glib-Basic-Types.html#gchar"
513
>gchar</a> *address);</pre>
517
<div class="variablelist"><table border="0">
518
<col align="left" valign="top">
521
<td><p><span class="term"><em class="parameter"><code>address</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="id2857110"></a><h3>
538
<a name="gconf-get-backend"></a>gconf_get_backend ()</h3>
539
<a class="indexterm" name="id2857122"></a><pre class="programlisting"><a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a>* gconf_get_backend (const <a
540
href="../glib/glib-Basic-Types.html#gchar"
543
href="../glib/glib-Error-Reporting.html#GError"
544
>GError</a> **err);</pre>
548
<div class="variablelist"><table border="0">
549
<col align="left" valign="top">
552
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
557
<td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
562
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
572
<div class="refsect2" lang="en">
573
<a name="id2857200"></a><h3>
574
<a name="gconf-backend-ref"></a>gconf_backend_ref ()</h3>
575
<a class="indexterm" name="id2857213"></a><pre class="programlisting">void gconf_backend_ref (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);</pre>
579
<div class="variablelist"><table border="0">
580
<col align="left" valign="top">
582
<td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
591
<div class="refsect2" lang="en">
592
<a name="id2857259"></a><h3>
593
<a name="gconf-backend-unref"></a>gconf_backend_unref ()</h3>
594
<a class="indexterm" name="id2857271"></a><pre class="programlisting">void gconf_backend_unref (<a class="link" href="gconf-gconf-backend.html#GConfBackend">GConfBackend</a> *backend);</pre>
598
<div class="variablelist"><table border="0">
599
<col align="left" valign="top">
601
<td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
610
<div class="refsect2" lang="en">
611
<a name="id2857317"></a><h3>
612
<a name="gconf-backend-resolve-address"></a>gconf_backend_resolve_address ()</h3>
613
<a class="indexterm" name="id2857329"></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,
615
href="../glib/glib-Basic-Types.html#gchar"
618
href="../glib/glib-Error-Reporting.html#GError"
619
>GError</a> **err);</pre>
623
<div class="variablelist"><table border="0">
624
<col align="left" valign="top">
627
<td><p><span class="term"><em class="parameter"><code>backend</code></em> :</span></p></td>
632
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
637
<td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
642
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>