fc3e46ff6723c3a61063f04df623ec6f99670839
[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  * @name: name (id) of the account
97  * @hostname: the hostname
98  * @username: the username
99  * @password: the password
100  * @proto:    the protocol (imap, smtp, ...) used for this account
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  */
107 gboolean modest_account_mgr_add_server_account    (ModestAccountMgr *self,
108                                                    const gchar *name,
109                                                    const gchar *hostname,
110                                                    const gchar *username,
111                                                    const gchar *password,
112                                                    const gchar *proto);  
113
114 /**
115  * modest_account_mgr_remove_server_account:
116  * @self: a ModestAccountMgr instance
117  * @name: the name for the server account
118  * @err: a GError ptr, or NULL to ignore.
119  * 
120  * remove a server account from the configuration
121  * the server account with @name should exist
122  *
123  * Returns: TRUE if the removal succeeded, FALSE otherwise,
124  * @err gives details in case of error
125  */
126 gboolean        modest_account_mgr_remove_server_account    (ModestAccountMgr *self,
127                                                              const gchar *name,
128                                                              GError **err);
129                                                                  /**
130  * modest_account_mgr_remove_identity:
131  * @self: a ModestAccountMgr instance
132  * @name: the name for the identity
133  * @err: a GError ptr, or NULL to ignore.
134  * 
135  * remove aidentity from the configuration
136  * the identity with @name should exist
137  *
138  * Returns: TRUE if the removal succeeded, FALSE otherwise,
139  * @err gives details in case of error
140  */
141 gboolean        modest_account_mgr_remove_identity (ModestAccountMgr *self,
142                                                              const gchar *name,
143                                                              GError **err);
144
145 /**
146  * modest_account_mgr_add_identity:
147  * @self: a ModestAccountMgr instance
148  * @name: the name (id) for the identity
149  * @email: the user's email address
150  * @replyto: default replyto address
151  * @signature: the signature for this identity
152  * @use_signature: whether to use this signature instead of the default one
153  * @id_via: the transport to send emails for this identity via
154  * @use_id_via: whether to use this via insteda of the default one
155  * 
156  * add a user identity to the configuration
157  * 
158  * Returns: TRUE if  succeeded, FALSE otherwise,
159  */
160
161 gboolean
162 modest_account_mgr_add_identity (ModestAccountMgr *self,
163                       const gchar *name,
164                                           const gchar *email,
165                                           const gchar *replyto,
166                                           const gchar *signature,
167                       const gboolean use_signature,
168                       const gchar *id_via,
169                       const gboolean use_id_via);
170
171 /**
172  * modest_account_mgr_account_names:
173  * @self: a ModestAccountMgr instance
174  * @err: a GError ptr, or NULL to ignore.
175  * 
176  * list all account names
177  *
178  * Returns: a newly allocated list of account names, or NULL in case of error or
179  * if there are no accounts. The caller must free the returned GSList
180  * @err gives details in case of error
181  */
182 GSList*         modest_account_mgr_account_names    (ModestAccountMgr *self, GError **err);
183
184
185 /**
186  * modest_account_mgr_server_account_names:
187  * @self: a ModestAccountMgr instance
188  * @account_name: get only server accounts for @account_name, or NULL for any
189  * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
190  * @proto: get only server account with protocol @proto, or NULL for any
191  * @only_enable: get only enable server account if TRUE
192  * 
193  * list all the server account names
194  *
195  * Returns: a newly allocated list of server account names, or NULL in case of
196  * error or if there are no server accounts. The caller must free the returned GSList
197  */
198 GSList*  modest_account_mgr_server_account_names   (ModestAccountMgr *self,
199                                                     const gchar*    account_name,
200                                                     ModestProtoType type,
201                                                     const gchar*    proto,
202                                                     gboolean only_enabled);
203
204 /**
205  * modest_account_mgr_account_exists:
206  * @self: a ModestAccountMgr instance
207  * @err: a GError ptr, or NULL to ignore.
208  * 
209  * check whether account @name exists
210  *
211  * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
212  * @err gives details in case of error
213  */
214 gboolean        modest_account_mgr_account_exists         (ModestAccountMgr *self,
215                                                            const gchar *name,
216                                                            GError **err);
217 gboolean        modest_account_mgr_server_account_exists          (ModestAccountMgr *self,
218                                                                    const gchar *name,
219                                                                    GError **err);
220
221
222 /* account specific functions */
223
224
225
226 /**
227  * modest_account_mgr_get_account_string:
228  * @self: self a ModestAccountMgr instance
229  * @name: the name of the account
230  * @key: the key of the value to retrieve
231  * @err: a GError ptr, or NULL to ignore.
232  * 
233  * get a config string from some account
234  *
235  * Returns: a newly allocated string with the value for the key,
236  * or NULL in case of error. @err gives details in case of error
237  */
238 gchar*          modest_account_mgr_get_account_string     (ModestAccountMgr *self,
239                                                            const gchar *name,
240                                                            const gchar *key, GError **err);
241
242 gchar*          modest_account_mgr_get_server_account_string     (ModestAccountMgr *self,
243                                                            const gchar *name,
244                                                            const gchar *key, GError **err);
245 gchar*          modest_account_mgr_get_identity_string     (ModestAccountMgr *self,
246                                                            const gchar *name,
247                                                            const gchar *key, GError **err);
248
249
250 /**
251  * modest_account_mgr_get_account_int:
252  * @self: self a ModestAccountMgr instance
253  * @name: the name of the account
254  * @key: the key of the value to retrieve
255  * @err: a GError ptr, or NULL to ignore.
256  * 
257  * get a config int from some account
258  *
259  * Returns: an integer with the value for the key, or -1 in case of
260  * error (but of course -1 does not necessarily imply an error)
261  * @err gives details in case of error
262  */
263 gint            modest_account_mgr_get_account_int        (ModestAccountMgr *self,
264                                                            const gchar *name,
265                                                            const gchar *key, GError **err);
266 gint            modest_account_mgr_get_server_account_int        (ModestAccountMgr *self,
267                                                            const gchar *name,
268                                                            const gchar *key, GError **err);
269
270
271 /**
272  * modest_account_mgr_get_account_bool:
273  * @self: self a ModestAccountMgr instance
274  * @name: the name of the account
275  * @key: the key of the value to retrieve
276  * @err: a GError ptr, or NULL to ignore.
277  * 
278  * get a config boolean from some account
279  *
280  * Returns: an boolean with the value for the key, or FALSE in case of
281  * error (but of course FALSE does not necessarily imply an error)
282  * @err gives details in case of error
283  */
284 gboolean        modest_account_mgr_get_account_bool       (ModestAccountMgr *self,
285                                                            const gchar *name,
286                                                            const gchar *key, GError **err);
287
288 gboolean        modest_account_mgr_get_server_account_bool       (ModestAccountMgr *self,
289                                                                   const gchar *name,
290                                                                   const gchar *key, GError **err);
291
292 /**
293  * modest_account_mgr_set_account_string:
294  * @self: self a ModestAccountMgr instance
295  * @name: the name of the account
296  * @key: the key of the value to set
297  * @val: the value to set
298  * @err: a GError ptr, or NULL to ignore.
299  * 
300  * set a config string for some account
301  *
302  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
303  * @err gives details in case of error
304  */
305 gboolean        modest_account_mgr_set_account_string     (ModestAccountMgr *self,
306                                                            const gchar *name,
307                                                            const gchar *key, const gchar* val,
308                                                            GError **err);
309
310 gboolean        modest_account_mgr_set_server_account_string     (ModestAccountMgr *self,
311                                                            const gchar *name,
312                                                            const gchar *key, const gchar* val,
313                                                            GError **err);
314
315
316 /**
317  * modest_account_mgr_set_account_int:
318  * @self: self a ModestAccountMgr instance
319  * @name: the name of the account
320  * @key: the key of the value to set
321  * @val: the value to set
322  * @err: a GError ptr, or NULL to ignore.
323  * 
324  * set a config int for some account
325  *
326  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
327  * @err gives details in case of error
328  */
329 gboolean        modest_account_mgr_set_account_int        (ModestAccountMgr *self,
330                                                            const gchar *name,
331                                                            const gchar *key, gint val,
332                                                            GError **err);
333 gboolean        modest_account_mgr_set_server_account_int        (ModestAccountMgr *self,
334                                                                   const gchar *name,
335                                                                   const gchar *key, gint val,
336                                                                   GError **err);
337
338
339
340 /**
341  * modest_account_mgr_set_account_bool:
342  * @self: self a ModestAccountMgr instance
343  * @name: the name of the account
344  * @key: the key of the value to set
345  * @val: the value to set
346  * @err: a GError ptr, or NULL to ignore.
347  * 
348  * set a config bool for some account
349  *
350  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
351  * @err gives details in case of error
352  */
353 gboolean        modest_account_mgr_set_account_bool       (ModestAccountMgr *self,
354                                                            const gchar *name,
355                                                            const gchar *key, gboolean val,
356                                                            GError **err);
357 gboolean        modest_account_mgr_set_server_account_bool       (ModestAccountMgr *self,
358                                                                   const gchar *name,
359                                                                   const gchar *key, gboolean val,
360                                                                   GError **err);
361
362
363 G_END_DECLS
364
365 #endif /* __MODEST_ACCOUNT_MGR_H__ */