gkdbus: Fix underflow and unreachable code bug
[platform/upstream/glib.git] / gio / gsettingsbackend.h
1 /*
2  * Copyright © 2009, 2010 Codethink Limited
3  * Copyright © 2010 Red Hat, Inc.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  *
20  * Authors: Ryan Lortie <desrt@desrt.ca>
21  *          Matthias Clasen <mclasen@redhat.com>
22  */
23
24 #ifndef __G_SETTINGS_BACKEND_H__
25 #define __G_SETTINGS_BACKEND_H__
26
27 #if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
28 #error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
29 #endif
30
31 #define __GIO_GIO_H_INSIDE__
32 #include <gio/giotypes.h>
33 #undef __GIO_GIO_H_INSIDE__
34
35 G_BEGIN_DECLS
36
37 #define G_TYPE_SETTINGS_BACKEND                             (g_settings_backend_get_type ())
38 #define G_SETTINGS_BACKEND(inst)                            (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
39                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackend))
40 #define G_SETTINGS_BACKEND_CLASS(class)                     (G_TYPE_CHECK_CLASS_CAST ((class),                       \
41                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
42 #define G_IS_SETTINGS_BACKEND(inst)                         (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
43                                                              G_TYPE_SETTINGS_BACKEND))
44 #define G_IS_SETTINGS_BACKEND_CLASS(class)                  (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
45                                                              G_TYPE_SETTINGS_BACKEND))
46 #define G_SETTINGS_BACKEND_GET_CLASS(inst)                  (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
47                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
48
49 /**
50  * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
51  *
52  * Extension point for #GSettingsBackend functionality.
53  **/
54 #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
55
56 /**
57  * GSettingsBackend:
58  *
59  * An implementation of a settings storage repository.
60  **/
61 typedef struct _GSettingsBackendPrivate                     GSettingsBackendPrivate;
62 typedef struct _GSettingsBackendClass                       GSettingsBackendClass;
63
64 /**
65  * GSettingsBackendClass:
66  * @read: virtual method to read a key's value
67  * @get_writable: virtual method to get if a key is writable
68  * @write: virtual method to change key's value
69  * @write_tree: virtual method to change a tree of keys
70  * @reset: virtual method to reset state
71  * @subscribe: virtual method to subscribe to key changes
72  * @unsubscribe: virtual method to unsubscribe to key changes
73  * @sync: virtual method to sync state
74  * @get_permission: virtual method to get permission of a key
75  * @read_user_value: virtual method to read user's key value
76  *
77  * Class structure for #GSettingsBackend.
78  */
79 struct _GSettingsBackendClass
80 {
81   GObjectClass parent_class;
82
83   GVariant *    (*read)             (GSettingsBackend    *backend,
84                                      const gchar         *key,
85                                      const GVariantType  *expected_type,
86                                      gboolean             default_value);
87
88   gboolean      (*get_writable)     (GSettingsBackend    *backend,
89                                      const gchar         *key);
90
91   gboolean      (*write)            (GSettingsBackend    *backend,
92                                      const gchar         *key,
93                                      GVariant            *value,
94                                      gpointer             origin_tag);
95   gboolean      (*write_tree)       (GSettingsBackend    *backend,
96                                      GTree               *tree,
97                                      gpointer             origin_tag);
98   void          (*reset)            (GSettingsBackend    *backend,
99                                      const gchar         *key,
100                                      gpointer             origin_tag);
101
102   void          (*subscribe)        (GSettingsBackend    *backend,
103                                      const gchar         *name);
104   void          (*unsubscribe)      (GSettingsBackend    *backend,
105                                      const gchar         *name);
106   void          (*sync)             (GSettingsBackend    *backend);
107
108   GPermission * (*get_permission)   (GSettingsBackend    *backend,
109                                      const gchar         *path);
110
111   GVariant *    (*read_user_value)  (GSettingsBackend    *backend,
112                                      const gchar         *key,
113                                      const GVariantType  *expected_type);
114
115   /*< private >*/
116   gpointer padding[23];
117 };
118
119 struct _GSettingsBackend
120 {
121   GObject parent_instance;
122
123   /*< private >*/
124   GSettingsBackendPrivate *priv;
125 };
126
127 GIO_AVAILABLE_IN_ALL
128 GType                   g_settings_backend_get_type                     (void);
129
130 GIO_AVAILABLE_IN_ALL
131 void                    g_settings_backend_changed                      (GSettingsBackend    *backend,
132                                                                          const gchar         *key,
133                                                                          gpointer             origin_tag);
134 GIO_AVAILABLE_IN_ALL
135 void                    g_settings_backend_path_changed                 (GSettingsBackend    *backend,
136                                                                          const gchar         *path,
137                                                                          gpointer             origin_tag);
138 GIO_AVAILABLE_IN_ALL
139 void                    g_settings_backend_flatten_tree                 (GTree               *tree,
140                                                                          gchar              **path,
141                                                                          const gchar       ***keys,
142                                                                          GVariant          ***values);
143 GIO_AVAILABLE_IN_ALL
144 void                    g_settings_backend_keys_changed                 (GSettingsBackend    *backend,
145                                                                          const gchar         *path,
146                                                                          gchar const * const *items,
147                                                                          gpointer             origin_tag);
148
149 GIO_AVAILABLE_IN_ALL
150 void                    g_settings_backend_path_writable_changed        (GSettingsBackend    *backend,
151                                                                          const gchar         *path);
152 GIO_AVAILABLE_IN_ALL
153 void                    g_settings_backend_writable_changed             (GSettingsBackend    *backend,
154                                                                          const gchar         *key);
155 GIO_AVAILABLE_IN_ALL
156 void                    g_settings_backend_changed_tree                 (GSettingsBackend    *backend,
157                                                                          GTree               *tree,
158                                                                          gpointer             origin_tag);
159
160 GIO_AVAILABLE_IN_ALL
161 GSettingsBackend *      g_settings_backend_get_default                  (void);
162
163 GIO_AVAILABLE_IN_ALL
164 GSettingsBackend *      g_keyfile_settings_backend_new                  (const gchar         *filename,
165                                                                          const gchar         *root_path,
166                                                                          const gchar         *root_group);
167
168 GIO_AVAILABLE_IN_ALL
169 GSettingsBackend *      g_null_settings_backend_new                     (void);
170
171 GIO_AVAILABLE_IN_ALL
172 GSettingsBackend *      g_memory_settings_backend_new                   (void);
173
174 G_END_DECLS
175
176 #endif /* __G_SETTINGS_BACKEND_H__ */