Merge remote branch 'gvdb/master'
[platform/upstream/glib.git] / gio / gnullsettingsbackend.c
1 /*
2  * Copyright © 2010 Codethink Limited
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the licence, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #include "config.h"
23
24 #include "gnullsettingsbackend.h"
25 #include "gsimplepermission.h"
26
27 #include "gioalias.h"
28
29 #define G_TYPE_NULL_SETTINGS_BACKEND    (g_null_settings_backend_get_type ())
30 #define G_NULL_SETTINGS_BACKEND(inst)   (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
31                                          G_TYPE_NULL_SETTINGS_BACKEND,       \
32                                          GNullSettingsBackend))
33
34
35 typedef GSettingsBackendClass GNullSettingsBackendClass;
36 typedef GSettingsBackend      GNullSettingsBackend;
37
38 static GType g_null_settings_backend_get_type (void);
39 G_DEFINE_TYPE (GNullSettingsBackend,
40                g_null_settings_backend,
41                G_TYPE_SETTINGS_BACKEND)
42
43 static GVariant *
44 g_null_settings_backend_read (GSettingsBackend   *backend,
45                               const gchar        *key,
46                               const GVariantType *expected_type,
47                               gboolean            default_value)
48 {
49   return NULL;
50 }
51
52 static gboolean
53 g_null_settings_backend_write (GSettingsBackend *backend,
54                                const gchar      *key,
55                                GVariant         *value,
56                                gpointer          origin_tag)
57 {
58   return FALSE;
59 }
60
61 static gboolean
62 g_null_settings_backend_write_keys (GSettingsBackend *backend,
63                                     GTree            *tree,
64                                     gpointer          origin_tag)
65 {
66   return FALSE;
67 }
68
69 static void
70 g_null_settings_backend_reset (GSettingsBackend *backend,
71                                const gchar      *key,
72                                gpointer          origin_tag)
73 {
74 }
75
76 static void
77 g_null_settings_backend_reset_path (GSettingsBackend *backend,
78                                     const gchar      *path,
79                                     gpointer          origin_tag)
80 {
81 }
82
83 static gboolean
84 g_null_settings_backend_get_writable (GSettingsBackend *backend,
85                                       const gchar      *name)
86 {
87   return FALSE;
88 }
89
90 static GPermission *
91 g_null_settings_backend_get_permission (GSettingsBackend *backend,
92                                         const gchar      *path)
93 {
94   return g_simple_permission_new (FALSE);
95 }
96
97 static void
98 g_null_settings_backend_init (GNullSettingsBackend *memory)
99 {
100 }
101
102 static void
103 g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
104 {
105   GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
106
107   backend_class->read = g_null_settings_backend_read;
108   backend_class->write = g_null_settings_backend_write;
109   backend_class->write_keys = g_null_settings_backend_write_keys;
110   backend_class->reset = g_null_settings_backend_reset;
111   backend_class->reset_path = g_null_settings_backend_reset_path;
112   backend_class->get_writable = g_null_settings_backend_get_writable;
113   backend_class->get_permission = g_null_settings_backend_get_permission;
114 }
115
116 GSettingsBackend *
117 g_null_settings_backend_new (void)
118 {
119   return g_object_new (G_TYPE_NULL_SETTINGS_BACKEND, NULL);
120 }