Fixed g_strconcat() bug in cache dirname creation (forgot trailing NULL).
[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
179 /* account specific functions */
180
181
182
183 /**
184  * modest_account_mgr_get_account_string:
185  * @self: self a ModestAccountMgr instance
186  * @name: the name of the account
187  * @key: the key of the value to retrieve
188  * @err: a GError ptr, or NULL to ignore.
189  * 
190  * get a config string from some account
191  *
192  * Returns: a newly allocated string with the value for the key,
193  * or NULL in case of error. @err gives details in case of error
194  */
195 gchar*          modest_account_mgr_get_account_string     (ModestAccountMgr *self,
196                                                            const gchar *name,
197                                                            const gchar *key, GError **err);
198 /**
199  * modest_account_mgr_get_account_int:
200  * @self: self a ModestAccountMgr instance
201  * @name: the name of the account
202  * @key: the key of the value to retrieve
203  * @err: a GError ptr, or NULL to ignore.
204  * 
205  * get a config int from some account
206  *
207  * Returns: an integer with the value for the key, or -1 in case of
208  * error (but of course -1 does not necessarily imply an error)
209  * @err gives details in case of error
210  */
211 gint            modest_account_mgr_get_account_int        (ModestAccountMgr *self,
212                                                            const gchar *name,
213                                                            const gchar *key, GError **err);
214
215
216 /**
217  * modest_account_mgr_get_account_bool:
218  * @self: self a ModestAccountMgr instance
219  * @name: the name of the account
220  * @key: the key of the value to retrieve
221  * @err: a GError ptr, or NULL to ignore.
222  * 
223  * get a config boolean from some account
224  *
225  * Returns: an boolean with the value for the key, or FALSE in case of
226  * error (but of course FALSE does not necessarily imply an error)
227  * @err gives details in case of error
228  */
229 gboolean        modest_account_mgr_get_account_bool       (ModestAccountMgr *self,
230                                                            const gchar *name,
231                                                            const gchar *key, GError **err);
232
233
234 /**
235  * modest_account_mgr_set_account_string:
236  * @self: self a ModestAccountMgr instance
237  * @name: the name of the account
238  * @key: the key of the value to set
239  * @val: the value to set
240  * @err: a GError ptr, or NULL to ignore.
241  * 
242  * set a config string for some account
243  *
244  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
245  * @err gives details in case of error
246  */
247 gboolean        modest_account_mgr_set_account_string     (ModestAccountMgr *self,
248                                                            const gchar *name,
249                                                            const gchar *key, const gchar* val,
250                                                            GError **err);
251 /**
252  * modest_account_mgr_set_account_int:
253  * @self: self a ModestAccountMgr instance
254  * @name: the name of the account
255  * @key: the key of the value to set
256  * @val: the value to set
257  * @err: a GError ptr, or NULL to ignore.
258  * 
259  * set a config int for some account
260  *
261  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
262  * @err gives details in case of error
263  */
264 gboolean        modest_account_mgr_set_account_int        (ModestAccountMgr *self,
265                                                            const gchar *name,
266                                                            const gchar *key, gint val,
267                                                            GError **err);
268
269 /**
270  * modest_account_mgr_set_account_bool:
271  * @self: self a ModestAccountMgr instance
272  * @name: the name of the account
273  * @key: the key of the value to set
274  * @val: the value to set
275  * @err: a GError ptr, or NULL to ignore.
276  * 
277  * set a config bool for some account
278  *
279  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
280  * @err gives details in case of error
281  */
282 gboolean        modest_account_mgr_set_account_bool       (ModestAccountMgr *self,
283                                                            const gchar *name,
284                                                            const gchar *key, gboolean val,
285                                                            GError **err);
286 G_END_DECLS
287
288 #endif /* __MODEST_ACCOUNT_MGR_H__ */
289