* this adds modest_account_server_(get|set)_(string|bool|int) so we don't
[modest] / src / modest-account-mgr.h
1 /* modest-account-mgr.h */
2 /* insert (c)/licensing information) */
3
4 #ifndef __MODEST_ACCOUNT_MGR_H__
5 #define __MODEST_ACCOUNT_MGR_H__
6
7 #include <glib-object.h>
8 #include "modest-conf.h"
9 #include "modest-account-keys.h"
10 #include "modest-proto.h"
11
12 G_BEGIN_DECLS
13
14 /* convenience macros */
15 #define MODEST_TYPE_ACCOUNT_MGR             (modest_account_mgr_get_type())
16 #define MODEST_ACCOUNT_MGR(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgr))
17 #define MODEST_ACCOUNT_MGR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_MGR,GObject))
18 #define MODEST_IS_ACCOUNT_MGR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_MGR))
19 #define MODEST_IS_ACCOUNT_MGR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_MGR))
20 #define MODEST_ACCOUNT_MGR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgrClass))
21
22 typedef struct _ModestAccountMgr      ModestAccountMgr;
23 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
24
25
26
27 struct _ModestAccountMgr {
28          GObject parent;
29         /* insert public members, if any */
30 };
31
32 struct _ModestAccountMgrClass {
33         GObjectClass parent_class;
34         /* insert signal callback declarations, eg. */
35         /* void (* my_event) (ModestAccountMgr* obj); */
36 };
37
38
39 /**
40  * modest_ui_get_type:
41  * 
42  * get the GType for ModestAccountMgr
43  *  
44  * Returns: the GType
45  */
46 GType           modest_account_mgr_get_type       (void) G_GNUC_CONST;
47
48
49 /**
50  * modest_account_mgr_new:
51  * @modest_conf: a ModestConf instance 
52  *  
53  * Returns: a new ModestAccountMgr, or NULL in case of error
54  */
55 GObject*        modest_account_mgr_new            (ModestConf *modest_conf);
56
57
58
59 /**
60  * modest_account_mgr_add_account:
61  * @self: a ModestAccountMgr instance
62  * @name: the name of the account to create
63  * @store: the store account (ie. POP/IMAP)
64  * @transport: the transport account (ie. sendmail/SMTP)
65  * @err: a GError ptr, or NULL to ignore.
66  * 
67  * create a new account. the account with @name should not already exist
68  *
69  * Returns: TRUE if the creation succeeded, FALSE otherwise,
70  * @err gives details in case of error
71  */
72 gboolean        modest_account_mgr_add_account    (ModestAccountMgr *self,
73                                                    const gchar* name,
74                                                    const gchar* store_name,
75                                                    const gchar* transport_name,
76                                                    GError **err);
77 /**
78  * modest_account_mgr_remove_account:
79  * @self: a ModestAccountMgr instance
80  * @name: the name of the account to remove
81  * @err: a GError ptr, or NULL to ignore.
82  * 
83  * remove an existing account. the account with @name should already exist
84  *
85  * Returns: TRUE if the creation succeeded, FALSE otherwise,
86  * @err gives details in case of error
87  */
88 gboolean        modest_account_mgr_remove_account         (ModestAccountMgr *self, const gchar* name,
89                                                            GError **err);
90
91
92
93 /**
94  * modest_account_mgr_add_server_account:
95  * @self: a ModestAccountMgr instance
96  * @hostname: the hostname
97  * @username: the username
98  * @password: the password
99  * @proto:    the prototype
100  * @err: a GError ptr, or NULL to ignore.
101  * 
102  * add a server account to the configuration
103  * the server account with @name should not already exist
104  *
105  * Returns: TRUE if  succeeded, FALSE otherwise,
106  * @err gives details in case of error
107  */
108 gboolean modest_account_mgr_add_server_account    (ModestAccountMgr *self,
109                                                    const gchar *name,
110                                                    const gchar *hostname,
111                                                    const gchar *username,
112                                                    const gchar *password,
113                                                    const gchar *proto);  
114
115 /**
116  * modest_account_mgr_remove_server_account:
117  * @self: a ModestAccountMgr instance
118  * @name: the name for the server account
119  * @err: a GError ptr, or NULL to ignore.
120  * 
121  * remove a server account from the configuration
122  * the server account with @name should exist
123  *
124  * Returns: TRUE if the removal succeeded, FALSE otherwise,
125  * @err gives details in case of error
126  */
127 gboolean        modest_account_mgr_remove_server_account    (ModestAccountMgr *self,
128                                                              const gchar *name,
129                                                              GError **err);
130
131
132 /**
133  * modest_account_mgr_account_names:
134  * @self: a ModestAccountMgr instance
135  * @err: a GError ptr, or NULL to ignore.
136  * 
137  * list all account names
138  *
139  * Returns: a newly allocated list of account names, or NULL in case of error or
140  * if there are no accounts. The caller must free the returned GSList
141  * @err gives details in case of error
142  */
143 GSList*         modest_account_mgr_account_names    (ModestAccountMgr *self, GError **err);
144
145
146 /**
147  * modest_account_mgr_server_account_names:
148  * @self: a ModestAccountMgr instance
149  * @account_name: get only server accounts for @account_name, or NULL for any
150  * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
151  * @proto: get only server account with protocol @proto, or NULL for any
152  * @only_enable: get only enable server account if TRUE
153  * 
154  * list all the server account names
155  *
156  * Returns: a newly allocated list of server account names, or NULL in case of
157  * error or if there are no server accounts. The caller must free the returned GSList
158  */
159 GSList*  modest_account_mgr_server_account_names   (ModestAccountMgr *self,
160                                                     const gchar*    account_name,
161                                                     ModestProtoType type,
162                                                     const gchar*    proto,
163                                                     gboolean only_enabled);
164
165 /**
166  * modest_account_mgr_account_exists:
167  * @self: a ModestAccountMgr instance
168  * @err: a GError ptr, or NULL to ignore.
169  * 
170  * check whether account @name exists
171  *
172  * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
173  * @err gives details in case of error
174  */
175 gboolean        modest_account_mgr_account_exists         (ModestAccountMgr *self,
176                                                            const gchar *name,
177                                                            GError **err);
178 gboolean        modest_account_mgr_server_account_exists          (ModestAccountMgr *self,
179                                                                    const gchar *name,
180                                                                    GError **err);
181
182
183 /* account specific functions */
184
185
186
187 /**
188  * modest_account_mgr_get_account_string:
189  * @self: self a ModestAccountMgr instance
190  * @name: the name of the account
191  * @key: the key of the value to retrieve
192  * @err: a GError ptr, or NULL to ignore.
193  * 
194  * get a config string from some account
195  *
196  * Returns: a newly allocated string with the value for the key,
197  * or NULL in case of error. @err gives details in case of error
198  */
199 gchar*          modest_account_mgr_get_account_string     (ModestAccountMgr *self,
200                                                            const gchar *name,
201                                                            const gchar *key, GError **err);
202
203 gchar*          modest_account_mgr_get_server_account_string     (ModestAccountMgr *self,
204                                                            const gchar *name,
205                                                            const gchar *key, GError **err);
206
207
208 /**
209  * modest_account_mgr_get_account_int:
210  * @self: self a ModestAccountMgr instance
211  * @name: the name of the account
212  * @key: the key of the value to retrieve
213  * @err: a GError ptr, or NULL to ignore.
214  * 
215  * get a config int from some account
216  *
217  * Returns: an integer with the value for the key, or -1 in case of
218  * error (but of course -1 does not necessarily imply an error)
219  * @err gives details in case of error
220  */
221 gint            modest_account_mgr_get_account_int        (ModestAccountMgr *self,
222                                                            const gchar *name,
223                                                            const gchar *key, GError **err);
224 gint            modest_account_mgr_get_server_account_int        (ModestAccountMgr *self,
225                                                            const gchar *name,
226                                                            const gchar *key, GError **err);
227
228
229 /**
230  * modest_account_mgr_get_account_bool:
231  * @self: self a ModestAccountMgr instance
232  * @name: the name of the account
233  * @key: the key of the value to retrieve
234  * @err: a GError ptr, or NULL to ignore.
235  * 
236  * get a config boolean from some account
237  *
238  * Returns: an boolean with the value for the key, or FALSE in case of
239  * error (but of course FALSE does not necessarily imply an error)
240  * @err gives details in case of error
241  */
242 gboolean        modest_account_mgr_get_account_bool       (ModestAccountMgr *self,
243                                                            const gchar *name,
244                                                            const gchar *key, GError **err);
245
246 gboolean        modest_account_mgr_get_server_account_bool       (ModestAccountMgr *self,
247                                                                   const gchar *name,
248                                                                   const gchar *key, GError **err);
249
250 /**
251  * modest_account_mgr_set_account_string:
252  * @self: self a ModestAccountMgr instance
253  * @name: the name of the account
254  * @key: the key of the value to set
255  * @val: the value to set
256  * @err: a GError ptr, or NULL to ignore.
257  * 
258  * set a config string for some account
259  *
260  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
261  * @err gives details in case of error
262  */
263 gboolean        modest_account_mgr_set_account_string     (ModestAccountMgr *self,
264                                                            const gchar *name,
265                                                            const gchar *key, const gchar* val,
266                                                            GError **err);
267
268 gboolean        modest_account_mgr_set_server_account_string     (ModestAccountMgr *self,
269                                                            const gchar *name,
270                                                            const gchar *key, const gchar* val,
271                                                            GError **err);
272
273
274 /**
275  * modest_account_mgr_set_account_int:
276  * @self: self a ModestAccountMgr instance
277  * @name: the name of the account
278  * @key: the key of the value to set
279  * @val: the value to set
280  * @err: a GError ptr, or NULL to ignore.
281  * 
282  * set a config int for some account
283  *
284  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
285  * @err gives details in case of error
286  */
287 gboolean        modest_account_mgr_set_account_int        (ModestAccountMgr *self,
288                                                            const gchar *name,
289                                                            const gchar *key, gint val,
290                                                            GError **err);
291 gboolean        modest_account_mgr_set_server_account_int        (ModestAccountMgr *self,
292                                                                   const gchar *name,
293                                                                   const gchar *key, gint val,
294                                                                   GError **err);
295
296
297
298 /**
299  * modest_account_mgr_set_account_bool:
300  * @self: self a ModestAccountMgr instance
301  * @name: the name of the account
302  * @key: the key of the value to set
303  * @val: the value to set
304  * @err: a GError ptr, or NULL to ignore.
305  * 
306  * set a config bool for some account
307  *
308  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
309  * @err gives details in case of error
310  */
311 gboolean        modest_account_mgr_set_account_bool       (ModestAccountMgr *self,
312                                                            const gchar *name,
313                                                            const gchar *key, gboolean val,
314                                                            GError **err);
315 gboolean        modest_account_mgr_set_server_account_bool       (ModestAccountMgr *self,
316                                                                   const gchar *name,
317                                                                   const gchar *key, gboolean val,
318                                                                   GError **err);
319
320
321 G_END_DECLS
322
323 #endif /* __MODEST_ACCOUNT_MGR_H__ */
324