* (quote) utf8 actually works now
[modest] / src / modest-conf.h
1 /*
2  * modest-conf.h
3  */
4
5 #ifndef __MODEST_CONF_H__
6 #define __MODEST_CONF_H__
7
8 #include <glib-object.h>
9 #include "modest-conf-keys.h"
10
11 G_BEGIN_DECLS
12
13 /* convenience macros */
14 #define MODEST_TYPE_CONF             (modest_conf_get_type())
15 #define MODEST_CONF(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_CONF,ModestConf))
16 #define MODEST_CONF_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_CONF,GObject))
17 #define MODEST_IS_CONF(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_CONF))
18 #define MODEST_IS_CONF_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_CONF))
19 #define MODEST_CONF_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_CONF,ModestConfClass))
20
21 typedef struct _ModestConf      ModestConf;
22 typedef struct _ModestConfClass ModestConfClass;
23
24 struct _ModestConf {
25          GObject parent;
26 };
27
28 struct _ModestConfClass {
29         GObjectClass parent_class;
30         /* insert signal callback declarations, eg. */
31         /* void (* my_event) (ModestConf* obj); */
32 };
33
34
35 /**
36  * modest_conf_get_type:
37  * 
38  * get the GType for ModestConf
39  *  
40  * Returns: the GType
41  */
42 GType        modest_conf_get_type    (void) G_GNUC_CONST;
43
44
45 /**
46  * modest_conf_new:
47  * 
48  * create a new modest ModestConf object. 
49  * 
50  * Returns: a new ModestConf instance, or NULL in case
51  * of any error
52  */
53 GObject*     modest_conf_new         (void);
54
55
56 /**
57  * modest_conf_get_string:
58  * @self: self a ModestConf instance
59  * @key: the key of the value to retrieve
60  * @err: a GError ptr, or NULL to ignore.
61  * 
62  * get a string from the configuration system
63  *
64  * Returns: a newly allocated string with the value for the key,
65  * or NULL in case of error. @err gives details in case of error
66  */
67 gchar*       modest_conf_get_string  (ModestConf* self, const gchar* key, GError **err);
68
69
70 /** 
71  * modest_conf_get_int:
72  * @self: self a ModestConf instance
73  * @key: the key of the value to retrieve
74  * @err: a GError ptr, or NULL to ignore.
75  * 
76  * get an integer from the configuration system
77  *  
78  * Returns: an integer with the value for the key, or -1 in case of error
79  * (of course, -1 can also be returned in non-error cases).
80  * @err gives details in case of error
81  */
82 int          modest_conf_get_int     (ModestConf* self, const gchar* key, GError **err);
83
84
85 /** 
86  * modest_conf_get_bool:
87  * @self: self a ModestConf instance
88  * @key: the key of the value to retrieve
89  * @err: a GError ptr, or NULL to ignore.
90  * 
91  * get a boolean value from the configuration system
92  *  
93  * Returns: a boolean value with the value for the key, or -1 in case of error
94  * (of course, -1 can also be returned in non-error cases).
95  * @err gives details in case of error
96  */
97 gboolean     modest_conf_get_bool    (ModestConf* self, const gchar* key, GError **err);
98
99
100 /**
101  * modest_conf_set_string:
102  * @self: a ModestConf instance
103  * @key: the key of the value to set
104  * @val: the value to set
105  * @err: a GError ptr, or NULL if not interested.
106  *
107  * store a string value in the configuration system
108  * 
109  * Returns: TRUE if succeeded or FALSE in case of error.
110  * @err gives details in case of error
111  */
112 gboolean     modest_conf_set_string (ModestConf* self, const gchar* key, const gchar *val,
113                                      GError **err);
114
115 /**
116  * modest_conf_set_int:
117  * @self: a ModestConf instance
118  * @key: the key of the value to set
119  * @val: the value to set
120  * @err: a GError ptr, or NULL if not interested.
121  *
122  * store an integer value in the configuration system
123  * 
124  * Returns: TRUE if succeeded or FALSE in case of error.
125  * @err gives details in case of error
126  */
127 gboolean     modest_conf_set_int    (ModestConf* self, const gchar* key, int val,
128                                      GError **err);
129
130 /**
131  * modest_conf_set_bool:
132  * @self: a ModestConf instance
133  * @key: the key of the value to set
134  * @val: the value to set
135  * @err: a GError ptr, or NULL if not interested.
136  *
137  * store a boolean value in the configuration system
138  * 
139  * Returns: TRUE if succeeded or FALSE in case of error.
140  * @err gives details in case of error
141  */
142 gboolean     modest_conf_set_bool    (ModestConf* self, const gchar* key, gboolean val,
143                                       GError **err);
144
145
146 /**
147  * modest_conf_list_subkeys:
148  * @self: a ModestConf instance
149  * @key: the key whose subkeys will be listed
150  * @err: a GError ptr, or NULL if not interested.
151  *
152  * list all the subkeys for a given key
153  * 
154  * Returns: a newly allocated list or NULL in case of error
155  * the returned GSList must be freed by the caller
156  * @err gives details in case of error
157  */
158 GSList*     modest_conf_list_subkeys    (ModestConf* self, const gchar* key,
159                                         GError **err);
160
161
162 /**
163  * modest_conf_remove_key:
164  * @self: a ModestConf instance
165  * @key: the key to remove
166  * @err: a GError ptr, or NULL if not interested.
167  *
168  * attempts to remove @key and all its subkeys
169  * 
170  * Returns: TRUE if succeeded or FALSE in case of error.
171  * @err gives details in case of error
172  */
173 gboolean   modest_conf_remove_key    (ModestConf* self, const gchar* key, GError **err);
174
175
176 /**
177  * modest_conf_key_exists:
178  * @self: a ModestConf instance
179  * @key: the key to remove
180  * @err: a GError ptr, or NULL if not interested.
181  *
182  * checks if the given key exists in the configuration system
183  * 
184  * Returns: TRUE if exists, FALSE otherwise.
185  * @err gives details in case of error
186  */
187 gboolean   modest_conf_key_exists   (ModestConf* self, const gchar* key, GError **err);
188
189
190 G_END_DECLS
191
192 #endif /* __MODEST_CONF_H__ */
193