message_to_write_data_free: Don't unref data->message if it is NULL
[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
28 #define G_TYPE_NULL_SETTINGS_BACKEND    (g_null_settings_backend_get_type ())
29 #define G_NULL_SETTINGS_BACKEND(inst)   (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
30                                          G_TYPE_NULL_SETTINGS_BACKEND,       \
31                                          GNullSettingsBackend))
32
33
34 typedef GSettingsBackendClass GNullSettingsBackendClass;
35 typedef GSettingsBackend      GNullSettingsBackend;
36
37 static GType g_null_settings_backend_get_type (void);
38 G_DEFINE_TYPE (GNullSettingsBackend,
39                g_null_settings_backend,
40                G_TYPE_SETTINGS_BACKEND)
41
42 static GVariant *
43 g_null_settings_backend_read (GSettingsBackend   *backend,
44                               const gchar        *key,
45                               const GVariantType *expected_type,
46                               gboolean            default_value)
47 {
48   return NULL;
49 }
50
51 static gboolean
52 g_null_settings_backend_write (GSettingsBackend *backend,
53                                const gchar      *key,
54                                GVariant         *value,
55                                gpointer          origin_tag)
56 {
57   return FALSE;
58 }
59
60 static gboolean
61 g_null_settings_backend_write_tree (GSettingsBackend *backend,
62                                     GTree            *tree,
63                                     gpointer          origin_tag)
64 {
65   return FALSE;
66 }
67
68 static void
69 g_null_settings_backend_reset (GSettingsBackend *backend,
70                                const gchar      *key,
71                                gpointer          origin_tag)
72 {
73 }
74
75 static gboolean
76 g_null_settings_backend_get_writable (GSettingsBackend *backend,
77                                       const gchar      *name)
78 {
79   return FALSE;
80 }
81
82 static GPermission *
83 g_null_settings_backend_get_permission (GSettingsBackend *backend,
84                                         const gchar      *path)
85 {
86   return g_simple_permission_new (FALSE);
87 }
88
89 static void
90 g_null_settings_backend_init (GNullSettingsBackend *memory)
91 {
92 }
93
94 static void
95 g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
96 {
97   GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
98
99   backend_class->read = g_null_settings_backend_read;
100   backend_class->write = g_null_settings_backend_write;
101   backend_class->write_tree = g_null_settings_backend_write_tree;
102   backend_class->reset = g_null_settings_backend_reset;
103   backend_class->get_writable = g_null_settings_backend_get_writable;
104   backend_class->get_permission = g_null_settings_backend_get_permission;
105 }
106
107 GSettingsBackend *
108 g_null_settings_backend_new (void)
109 {
110   return g_object_new (G_TYPE_NULL_SETTINGS_BACKEND, NULL);
111 }