~ubuntu-branches/ubuntu/oneiric/gconf/oneiric-proposed

« back to all changes in this revision

Viewing changes to gconf/gconf-backend.h

  • Committer: Bazaar Package Importer
  • Author(s): Takuo KITAME
  • Date: 2002-03-17 01:51:39 UTC
  • Revision ID: james.westby@ubuntu.com-20020317015139-z4f8fdg1hoe049g0
Tags: upstream-1.0.9
ImportĀ upstreamĀ versionĀ 1.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* GConf
 
3
 * Copyright (C) 1999, 2000 Red Hat Inc.
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Library General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Library General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Library General Public
 
16
 * License along with this library; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#ifndef GCONF_GCONFBACKEND_H
 
22
#define GCONF_GCONFBACKEND_H
 
23
 
 
24
#include <gconf/gconf-internals.h>
 
25
#include <gmodule.h>
 
26
#include <gconf/gconf-sources.h>
 
27
 
 
28
/*
 
29
 * This vtable is more complicated than strictly necessary, hoping
 
30
 * that backends can be smart and optimize some calls
 
31
 */
 
32
 
 
33
typedef struct _GConfBackendVTable GConfBackendVTable;
 
34
 
 
35
struct _GConfBackendVTable {
 
36
  void                (* shutdown)        (GError** err);
 
37
 
 
38
  GConfSource*        (* resolve_address) (const gchar* address,
 
39
                                           GError** err);
 
40
 
 
41
  /* Thread locks. If the backend is thread-safe, then these
 
42
   * can be NULL. If per-source locks are needed, then these
 
43
   * calls should lock a mutex stored in the GConfSource.
 
44
   * If a per-backend lock is needed, then the calls can ignore
 
45
   * their source argument and lock the whole backend.
 
46
   */
 
47
  void                (* lock)            (GConfSource* source,
 
48
                                           GError** err);
 
49
 
 
50
  void                (* unlock)          (GConfSource* source,
 
51
                                           GError** err);
 
52
 
 
53
  /* Report whether a given key (and its subkeys) can be read/written.
 
54
   * Sources may not permit reading/writing from/to /foo but forbid
 
55
   * writing to /foo/bar; if a key can be read or written then its
 
56
   * subkeys may also be read/written.
 
57
   *
 
58
   * This field allows backends to be configured so that they only
 
59
   * store certain kinds of data in certain sections of the GConf
 
60
   * namespace.
 
61
   *
 
62
   * If these functions return an error, they MUST return FALSE as
 
63
   * well.
 
64
   */
 
65
 
 
66
  gboolean           (* readable)         (GConfSource* source,
 
67
                                           const gchar* key,
 
68
                                           GError** err);
 
69
 
 
70
  gboolean           (* writable)        (GConfSource* source,
 
71
                                           const gchar* key,
 
72
                                           GError** err);
 
73
  
 
74
  /* schema_name filled if NULL or GCONF_VALUE_IGNORE_SUBSEQUENT returned.
 
75
     if schema_name is NULL, it isn't filled */
 
76
  GConfValue*         (* query_value)     (GConfSource* source, 
 
77
                                           const gchar* key,
 
78
                                           const gchar** locales,
 
79
                                           gchar** schema_name,
 
80
                                           GError** err);
 
81
  
 
82
  GConfMetaInfo*      (* query_metainfo)  (GConfSource* source,
 
83
                                           const gchar* key,
 
84
                                           GError** err);
 
85
  
 
86
  void                (* set_value)       (GConfSource* source, 
 
87
                                           const gchar* key, 
 
88
                                           GConfValue* value,
 
89
                                           GError** err);
 
90
 
 
91
  /* Returns list of GConfEntry with key set to a relative
 
92
   * pathname. In the public client-side API the key
 
93
   * is always absolute though.
 
94
   */
 
95
  GSList*             (* all_entries)     (GConfSource* source,
 
96
                                           const gchar* dir,
 
97
                                           const gchar** locales,
 
98
                                           GError** err);
 
99
 
 
100
  /* Returns list of allocated strings, relative names */
 
101
  GSList*             (* all_subdirs)     (GConfSource* source,
 
102
                                           const gchar* dir,
 
103
                                           GError** err);
 
104
 
 
105
  void                (* unset_value)     (GConfSource* source,
 
106
                                           const gchar* key,
 
107
                                           const gchar* locale,
 
108
                                           GError** err);
 
109
 
 
110
  gboolean            (* dir_exists)      (GConfSource* source,
 
111
                                           const gchar* dir,
 
112
                                           GError** err);
 
113
        
 
114
  void                (* remove_dir)      (GConfSource* source,
 
115
                                           const gchar* dir,
 
116
                                           GError** err);
 
117
  
 
118
  void                (* set_schema)      (GConfSource* source,
 
119
                                           const gchar* key,
 
120
                                           const gchar* schema_key,
 
121
                                           GError** err);
 
122
 
 
123
  gboolean            (* sync_all)        (GConfSource* source,
 
124
                                           GError** err);
 
125
 
 
126
  void                (* destroy_source)  (GConfSource* source);
 
127
 
 
128
  /* This is basically used by the test suite */
 
129
  void                (* clear_cache)     (GConfSource* source);
 
130
};
 
131
 
 
132
struct _GConfBackend {
 
133
  const gchar* name;
 
134
  guint refcount;
 
135
  GConfBackendVTable* vtable;
 
136
  GModule* module;
 
137
};
 
138
 
 
139
/* Address utility stuff */
 
140
 
 
141
/* Get the backend name */
 
142
gchar*        gconf_address_backend(const gchar* address);
 
143
/* Get the resource name understood only by the backend */
 
144
gchar*        gconf_address_resource(const gchar* address);
 
145
/* Get the backend flags */
 
146
gchar**       gconf_address_flags(const gchar* address);
 
147
 
 
148
gchar*        gconf_backend_file(const gchar* address);
 
149
 
 
150
/* Obtain the GConfBackend for this address, based on the first part of the 
 
151
 * address. The refcount is always incremented, and you must unref() later.
 
152
 * The same backend may be returned by multiple calls to this routine,
 
153
 * but you can assume they are different if you do the refcounting
 
154
 * right. Returns NULL if it fails.
 
155
 */
 
156
GConfBackend* gconf_get_backend(const gchar* address, GError** err);
 
157
 
 
158
void          gconf_backend_ref(GConfBackend* backend);
 
159
void          gconf_backend_unref(GConfBackend* backend);
 
160
 
 
161
GConfSource*  gconf_backend_resolve_address (GConfBackend* backend, 
 
162
                                             const gchar* address,
 
163
                                             GError** err);
 
164
 
 
165
#endif
 
166
 
 
167
 
 
168