d4cfaa616df320d82d7655325cf2fb7505221c43
[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_name: the store account (ie. POP/IMAP)
64  * @transport_name: 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,
89                                                            const gchar* name,
90                                                            GError **err);
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 to remove
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 /**
131  * modest_account_mgr_account_names:
132  * @self: a ModestAccountMgr instance
133  * @err: a GError ptr, or NULL to ignore.
134  * 
135  * list all account names
136  *
137  * Returns: a newly allocated list of account names, or NULL in case of error or
138  * if there are no accounts. The caller must free the returned GSList
139  * @err gives details in case of error
140  */
141 GSList*         modest_account_mgr_account_names    (ModestAccountMgr *self, GError **err);
142
143
144 /**
145  * modest_account_mgr_server_account_names:
146  * @self: a ModestAccountMgr instance
147  * @account_name: get only server accounts for @account_name, or NULL for any
148  * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
149  * @proto: get only server account with protocol @proto, or NULL for any
150  * @only_enabled: get only enabled server accounts if TRUE
151  * 
152  * list all the server account names
153  *
154  * Returns: a newly allocated list of server account names, or NULL in case of
155  * error or if there are no server accounts. The caller must free the returned GSList
156  */
157 GSList*  modest_account_mgr_server_account_names   (ModestAccountMgr *self,
158                                                     const gchar*    account_name,
159                                                     ModestProtoType type,
160                                                     const gchar*    proto,
161                                                     gboolean only_enabled);
162
163 /**
164  * modest_account_mgr_account_exists:
165  * @self: a ModestAccountMgr instance
166  * @name: the account name to check
167  * @err: a GError ptr, or NULL to ignore.
168  * 
169  * check whether account @name exists
170  *
171  * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
172  * @err gives details in case of error
173  */
174 gboolean        modest_account_mgr_account_exists         (ModestAccountMgr *self,
175                                                            const gchar *name,
176                                                            GError **err);
177                                                            
178 gboolean        modest_account_mgr_server_account_exists          (ModestAccountMgr *self,
179                                                                    const gchar *name,
180                                                                    GError **err);
181
182
183
184 /* account specific functions */
185
186 /**
187  * modest_account_mgr_get_account_string:
188  * @self: self a ModestAccountMgr instance
189  * @name: the name of the account
190  * @key: the key of the value to retrieve
191  * @err: a GError ptr, or NULL to ignore.
192  * 
193  * get a config string from an account
194  *
195  * Returns: a newly allocated string with the value for the key,
196  * or NULL in case of error. @err gives details in case of error
197  */
198 gchar*          modest_account_mgr_get_account_string     (ModestAccountMgr *self,
199                                                            const gchar *name,
200                                                            const gchar *key, GError **err);
201
202 gchar*          modest_account_mgr_get_server_account_string     (ModestAccountMgr *self,
203                                                            const gchar *name,
204                                                            const gchar *key, GError **err);
205
206 /**
207  * modest_account_mgr_get_account_int:
208  * @self: a ModestAccountMgr instance
209  * @name: the name of the account
210  * @key: the key of the value to retrieve
211  * @err: a GError ptr, or NULL to ignore.
212  * 
213  * get a config int from an account
214  *
215  * Returns: an integer with the value for the key, or -1 in case of
216  * error (but of course -1 does not necessarily imply an error)
217  * @err gives details in case of error
218  */
219 gint            modest_account_mgr_get_account_int        (ModestAccountMgr *self,
220                                                            const gchar *name,
221                                                            const gchar *key, GError **err);
222
223 gint            modest_account_mgr_get_server_account_int        (ModestAccountMgr *self,
224                                                            const gchar *name,
225                                                            const gchar *key, GError **err);
226
227
228 /**
229  * modest_account_mgr_get_account_bool:
230  * @self: a ModestAccountMgr instance
231  * @name: the name of the account
232  * @key: the key of the value to retrieve
233  * @err: a GError ptr, or NULL to ignore.
234  * 
235  * get a config boolean from an account
236  *
237  * Returns: an boolean with the value for the key, or FALSE in case of
238  * error (but of course FALSE does not necessarily imply an error)
239  * @err gives details in case of error
240  */
241 gboolean        modest_account_mgr_get_account_bool       (ModestAccountMgr *self,
242                                                            const gchar *name,
243                                                            const gchar *key, GError **err);
244
245 gboolean        modest_account_mgr_get_server_account_bool       (ModestAccountMgr *self,
246                                                                   const gchar *name,
247                                                                   const gchar *key, GError **err);
248
249 /**
250  * modest_account_mgr_set_account_string:
251  * @self: a ModestAccountMgr instance
252  * @name: the name of the account
253  * @key: the key of the value to set
254  * @val: the value to set
255  * @err: a GError ptr, or NULL to ignore.
256  * 
257  * set a config string for an account
258  *
259  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
260  * @err gives details in case of error
261  */
262 gboolean        modest_account_mgr_set_account_string     (ModestAccountMgr *self,
263                                                            const gchar *name,
264                                                            const gchar *key, const gchar* val,
265                                                            GError **err);
266
267 gboolean        modest_account_mgr_set_server_account_string     (ModestAccountMgr *self,
268                                                            const gchar *name,
269                                                            const gchar *key, const gchar* val,
270                                                            GError **err);
271
272
273 /**
274  * modest_account_mgr_set_account_int:
275  * @self: a ModestAccountMgr instance
276  * @name: the name of the account
277  * @key: the key of the value to set
278  * @val: the value to set
279  * @err: a GError ptr, or NULL to ignore.
280  * 
281  * set a config int for an account
282  *
283  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
284  * @err gives details in case of error
285  */
286 gboolean        modest_account_mgr_set_account_int        (ModestAccountMgr *self,
287                                                            const gchar *name,
288                                                            const gchar *key, gint val,
289                                                            GError **err);
290
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  * modest_account_mgr_set_account_bool:
299  * @self: a ModestAccountMgr instance
300  * @name: the name of the account
301  * @key: the key of the value to set
302  * @val: the value to set
303  * @err: a GError ptr, or NULL to ignore.
304  * 
305  * set a config bool for an account
306  *
307  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
308  * @err gives details in case of error
309  */
310 gboolean        modest_account_mgr_set_account_bool       (ModestAccountMgr *self,
311                                                            const gchar *name,
312                                                            const gchar *key, gboolean val,
313                                                            GError **err);
314
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__ */