507aa8c9df6099c55584e246446243c423711a97
[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 "gsettingsbackendinternal.h"
25 #include "giomodule.h"
26 #include "gsimplepermission.h"
27
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 G_DEFINE_TYPE_WITH_CODE (GNullSettingsBackend,
39                          g_null_settings_backend,
40                          G_TYPE_SETTINGS_BACKEND,
41                          g_io_extension_point_implement (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME,
42                                                          g_define_type_id, "null", 10))
43
44 static GVariant *
45 g_null_settings_backend_read (GSettingsBackend   *backend,
46                               const gchar        *key,
47                               const GVariantType *expected_type,
48                               gboolean            default_value)
49 {
50   return NULL;
51 }
52
53 static gboolean
54 g_null_settings_backend_write (GSettingsBackend *backend,
55                                const gchar      *key,
56                                GVariant         *value,
57                                gpointer          origin_tag)
58 {
59   return FALSE;
60 }
61
62 static gboolean
63 g_null_settings_backend_write_tree (GSettingsBackend *backend,
64                                     GTree            *tree,
65                                     gpointer          origin_tag)
66 {
67   return FALSE;
68 }
69
70 static void
71 g_null_settings_backend_reset (GSettingsBackend *backend,
72                                const gchar      *key,
73                                gpointer          origin_tag)
74 {
75 }
76
77 static gboolean
78 g_null_settings_backend_get_writable (GSettingsBackend *backend,
79                                       const gchar      *name)
80 {
81   return FALSE;
82 }
83
84 static GPermission *
85 g_null_settings_backend_get_permission (GSettingsBackend *backend,
86                                         const gchar      *path)
87 {
88   return g_simple_permission_new (FALSE);
89 }
90
91 static void
92 g_null_settings_backend_init (GNullSettingsBackend *memory)
93 {
94 }
95
96 static void
97 g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
98 {
99   GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
100
101   backend_class->read = g_null_settings_backend_read;
102   backend_class->write = g_null_settings_backend_write;
103   backend_class->write_tree = g_null_settings_backend_write_tree;
104   backend_class->reset = g_null_settings_backend_reset;
105   backend_class->get_writable = g_null_settings_backend_get_writable;
106   backend_class->get_permission = g_null_settings_backend_get_permission;
107 }
108
109 GSettingsBackend *
110 g_null_settings_backend_new (void)
111 {
112   return g_object_new (G_TYPE_NULL_SETTINGS_BACKEND, NULL);
113 }