* moved identity-related functionality from modest-account-mgr to the new modest...
[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 /**
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_enable: get only enable server account 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  * @err: a GError ptr, or NULL to ignore.
167  * 
168  * check whether account @name exists
169  *
170  * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
171  * @err gives details in case of error
172  */
173 gboolean        modest_account_mgr_account_exists         (ModestAccountMgr *self,
174                                                            const gchar *name,
175                                                            GError **err);
176 gboolean        modest_account_mgr_server_account_exists          (ModestAccountMgr *self,
177                                                                    const gchar *name,
178                                                                    GError **err);
179
180
181 /* account specific functions */
182
183
184
185 /**
186  * modest_account_mgr_get_account_string:
187  * @self: self a ModestAccountMgr instance
188  * @name: the name of the account
189  * @key: the key of the value to retrieve
190  * @err: a GError ptr, or NULL to ignore.
191  * 
192  * get a config string from some account
193  *
194  * Returns: a newly allocated string with the value for the key,
195  * or NULL in case of error. @err gives details in case of error
196  */
197 gchar*          modest_account_mgr_get_account_string     (ModestAccountMgr *self,
198                                                            const gchar *name,
199                                                            const gchar *key, GError **err);
200
201 gchar*          modest_account_mgr_get_server_account_string     (ModestAccountMgr *self,
202                                                            const gchar *name,
203                                                            const gchar *key, GError **err);
204
205 /**
206  * modest_account_mgr_get_account_int:
207  * @self: self a ModestAccountMgr instance
208  * @name: the name of the account
209  * @key: the key of the value to retrieve
210  * @err: a GError ptr, or NULL to ignore.
211  * 
212  * get a config int from some account
213  *
214  * Returns: an integer with the value for the key, or -1 in case of
215  * error (but of course -1 does not necessarily imply an error)
216  * @err gives details in case of error
217  */
218 gint            modest_account_mgr_get_account_int        (ModestAccountMgr *self,
219                                                            const gchar *name,
220                                                            const gchar *key, GError **err);
221 gint            modest_account_mgr_get_server_account_int        (ModestAccountMgr *self,
222                                                            const gchar *name,
223                                                            const gchar *key, GError **err);
224
225
226 /**
227  * modest_account_mgr_get_account_bool:
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 boolean from some account
234  *
235  * Returns: an boolean with the value for the key, or FALSE in case of
236  * error (but of course FALSE does not necessarily imply an error)
237  * @err gives details in case of error
238  */
239 gboolean        modest_account_mgr_get_account_bool       (ModestAccountMgr *self,
240                                                            const gchar *name,
241                                                            const gchar *key, GError **err);
242
243 gboolean        modest_account_mgr_get_server_account_bool       (ModestAccountMgr *self,
244                                                                   const gchar *name,
245                                                                   const gchar *key, GError **err);
246
247 /**
248  * modest_account_mgr_set_account_string:
249  * @self: self a ModestAccountMgr instance
250  * @name: the name of the account
251  * @key: the key of the value to set
252  * @val: the value to set
253  * @err: a GError ptr, or NULL to ignore.
254  * 
255  * set a config string for some account
256  *
257  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
258  * @err gives details in case of error
259  */
260 gboolean        modest_account_mgr_set_account_string     (ModestAccountMgr *self,
261                                                            const gchar *name,
262                                                            const gchar *key, const gchar* val,
263                                                            GError **err);
264
265 gboolean        modest_account_mgr_set_server_account_string     (ModestAccountMgr *self,
266                                                            const gchar *name,
267                                                            const gchar *key, const gchar* val,
268                                                            GError **err);
269
270
271 /**
272  * modest_account_mgr_set_account_int:
273  * @self: self a ModestAccountMgr instance
274  * @name: the name of the account
275  * @key: the key of the value to set
276  * @val: the value to set
277  * @err: a GError ptr, or NULL to ignore.
278  * 
279  * set a config int for some account
280  *
281  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
282  * @err gives details in case of error
283  */
284 gboolean        modest_account_mgr_set_account_int        (ModestAccountMgr *self,
285                                                            const gchar *name,
286                                                            const gchar *key, gint val,
287                                                            GError **err);
288 gboolean        modest_account_mgr_set_server_account_int        (ModestAccountMgr *self,
289                                                                   const gchar *name,
290                                                                   const gchar *key, gint val,
291                                                                   GError **err);
292
293
294
295 /**
296  * modest_account_mgr_set_account_bool:
297  * @self: self a ModestAccountMgr instance
298  * @name: the name of the account
299  * @key: the key of the value to set
300  * @val: the value to set
301  * @err: a GError ptr, or NULL to ignore.
302  * 
303  * set a config bool for some account
304  *
305  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
306  * @err gives details in case of error
307  */
308 gboolean        modest_account_mgr_set_account_bool       (ModestAccountMgr *self,
309                                                            const gchar *name,
310                                                            const gchar *key, gboolean val,
311                                                            GError **err);
312 gboolean        modest_account_mgr_set_server_account_bool       (ModestAccountMgr *self,
313                                                                   const gchar *name,
314                                                                   const gchar *key, gboolean val,
315                                                                   GError **err);
316
317
318 G_END_DECLS
319
320 #endif /* __MODEST_ACCOUNT_MGR_H__ */