1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __MODEST_CONF_H__
34 #define __MODEST_CONF_H__
36 #include <glib-object.h>
37 #include "modest-conf-keys.h"
41 /* convenience macros */
42 #define MODEST_TYPE_CONF (modest_conf_get_type())
43 #define MODEST_CONF(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_CONF,ModestConf))
44 #define MODEST_CONF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_CONF,GObject))
45 #define MODEST_IS_CONF(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_CONF))
46 #define MODEST_IS_CONF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_CONF))
47 #define MODEST_CONF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_CONF,ModestConfClass))
49 typedef struct _ModestConf ModestConf;
50 typedef struct _ModestConfClass ModestConfClass;
56 struct _ModestConfClass {
57 GObjectClass parent_class;
59 void (* key_changed) (ModestConf* self, const gchar *key, const gchar *new_value);
64 * modest_conf_get_type:
66 * get the GType for ModestConf
70 GType modest_conf_get_type (void) G_GNUC_CONST;
76 * create a new modest ModestConf object.
78 * Returns: a new ModestConf instance, or NULL in case
81 GObject* modest_conf_new (void);
85 * modest_conf_get_string:
86 * @self: a ModestConf instance
87 * @key: the key of the value to retrieve
88 * @err: a GError ptr, or NULL to ignore.
90 * get a string from the configuration system
92 * Returns: a newly allocated string with the value for the key,
93 * or NULL in case of error. @err gives details in case of error
95 gchar* modest_conf_get_string (ModestConf* self, const gchar* key, GError **err);
99 * modest_conf_get_int:
100 * @self: a ModestConf instance
101 * @key: the key of the value to retrieve
102 * @err: a GError ptr, or NULL to ignore.
104 * get an integer from the configuration system
106 * Returns: an integer with the value for the key, or -1 in case of error
107 * (of course, -1 can also be returned in non-error cases).
108 * @err gives details in case of error
110 int modest_conf_get_int (ModestConf* self, const gchar* key, GError **err);
114 * modest_conf_get_bool:
115 * @self: a ModestConf instance
116 * @key: the key of the value to retrieve
117 * @err: a GError ptr, or NULL to ignore.
119 * get a boolean value from the configuration system
121 * Returns: a boolean value with the value for the key, or -1 in case of error
122 * (of course, -1 can also be returned in non-error cases).
123 * @err gives details in case of error
125 gboolean modest_conf_get_bool (ModestConf* self, const gchar* key, GError **err);
129 * modest_conf_set_string:
130 * @self: a ModestConf instance
131 * @key: the key of the value to set
132 * @val: the value to set
133 * @err: a GError ptr, or NULL if not interested.
135 * store a string value in the configuration system
137 * Returns: TRUE if succeeded or FALSE in case of error.
138 * @err gives details in case of error
140 gboolean modest_conf_set_string (ModestConf* self, const gchar* key, const gchar *val,
144 * modest_conf_set_int:
145 * @self: a ModestConf instance
146 * @key: the key of the value to set
147 * @val: the value to set
148 * @err: a GError ptr, or NULL if not interested.
150 * store an integer value in the configuration system
152 * Returns: TRUE if succeeded or FALSE in case of error.
153 * @err gives details in case of error
155 gboolean modest_conf_set_int (ModestConf* self, const gchar* key, int val,
159 * modest_conf_set_bool:
160 * @self: a ModestConf instance
161 * @key: the key of the value to set
162 * @val: the value to set
163 * @err: a GError ptr, or NULL if not interested.
165 * store a boolean value in the configuration system
167 * Returns: TRUE if succeeded or FALSE in case of error.
168 * @err gives details in case of error
170 gboolean modest_conf_set_bool (ModestConf* self, const gchar* key, gboolean val,
175 * modest_conf_list_subkeys:
176 * @self: a ModestConf instance
177 * @key: the key whose subkeys will be listed
178 * @err: a GError ptr, or NULL if not interested.
180 * list all the subkeys for a given key
182 * Returns: a newly allocated list or NULL in case of error
183 * the returned GSList must be freed by the caller
184 * @err gives details in case of error
186 GSList* modest_conf_list_subkeys (ModestConf* self, const gchar* key,
191 * modest_conf_remove_key:
192 * @self: a ModestConf instance
193 * @key: the key to remove
194 * @err: a GError ptr, or NULL if not interested.
196 * attempts to remove @key and all its subkeys
198 * Returns: TRUE if succeeded or FALSE in case of error.
199 * @err gives details in case of error
201 gboolean modest_conf_remove_key (ModestConf* self, const gchar* key, GError **err);
205 * modest_conf_key_exists:
206 * @self: a ModestConf instance
207 * @key: the key to remove
208 * @err: a GError ptr, or NULL if not interested.
210 * checks if the given key exists in the configuration system
212 * Returns: TRUE if it exists, FALSE otherwise.
213 * @err gives details in case of error
215 gboolean modest_conf_key_exists (ModestConf* self, const gchar* key, GError **err);
220 #endif /* __MODEST_CONF_H__ */