1 /* modest-account-mgr.h */
2 /* insert (c)/licensing information) */
4 #ifndef __MODEST_ACCOUNT_MGR_H__
5 #define __MODEST_ACCOUNT_MGR_H__
7 #include <glib-object.h>
8 #include "modest-conf.h"
9 #include "modest-account-keys.h"
10 #include "modest-proto.h"
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))
22 typedef struct _ModestAccountMgr ModestAccountMgr;
23 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
27 struct _ModestAccountMgr {
29 /* insert public members, if any */
32 struct _ModestAccountMgrClass {
33 GObjectClass parent_class;
34 /* insert signal callback declarations, eg. */
35 /* void (* my_event) (ModestAccountMgr* obj); */
42 * get the GType for ModestAccountMgr
46 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
50 * modest_account_mgr_new:
51 * @modest_conf: a ModestConf instance
53 * Returns: a new ModestAccountMgr, or NULL in case of error
55 GObject* modest_account_mgr_new (ModestConf *modest_conf);
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.
67 * create a new account. the account with @name should not already exist
69 * Returns: TRUE if the creation succeeded, FALSE otherwise,
70 * @err gives details in case of error
72 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
74 const gchar* store_name,
75 const gchar* transport_name,
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.
83 * remove an existing account. the account with @name should already exist
85 * Returns: TRUE if the creation succeeded, FALSE otherwise,
86 * @err gives details in case of error
88 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self, const gchar* name,
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
102 * add a server account to the configuration.
103 * the server account with @name should not already exist
105 * Returns: TRUE if succeeded, FALSE otherwise,
107 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
109 const gchar *hostname,
110 const gchar *username,
111 const gchar *password,
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.
120 * remove a server account from the configuration
121 * the server account with @name should exist
123 * Returns: TRUE if the removal succeeded, FALSE otherwise,
124 * @err gives details in case of error
126 gboolean modest_account_mgr_remove_server_account (ModestAccountMgr *self,
131 * modest_account_mgr_account_names:
132 * @self: a ModestAccountMgr instance
133 * @err: a GError ptr, or NULL to ignore.
135 * list all account names
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
141 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
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
152 * list all the server account names
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
157 GSList* modest_account_mgr_server_account_names (ModestAccountMgr *self,
158 const gchar* account_name,
159 ModestProtoType type,
161 gboolean only_enabled);
164 * modest_account_mgr_account_exists:
165 * @self: a ModestAccountMgr instance
166 * @err: a GError ptr, or NULL to ignore.
168 * check whether account @name exists
170 * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
171 * @err gives details in case of error
173 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
176 gboolean modest_account_mgr_server_account_exists (ModestAccountMgr *self,
181 /* account specific functions */
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.
192 * get a config string from some account
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
197 gchar* modest_account_mgr_get_account_string (ModestAccountMgr *self,
199 const gchar *key, GError **err);
201 gchar* modest_account_mgr_get_server_account_string (ModestAccountMgr *self,
203 const gchar *key, GError **err);
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.
212 * get a config int from some account
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
218 gint modest_account_mgr_get_account_int (ModestAccountMgr *self,
220 const gchar *key, GError **err);
221 gint modest_account_mgr_get_server_account_int (ModestAccountMgr *self,
223 const gchar *key, GError **err);
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.
233 * get a config boolean from some account
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
239 gboolean modest_account_mgr_get_account_bool (ModestAccountMgr *self,
241 const gchar *key, GError **err);
243 gboolean modest_account_mgr_get_server_account_bool (ModestAccountMgr *self,
245 const gchar *key, GError **err);
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.
255 * set a config string for some account
257 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
258 * @err gives details in case of error
260 gboolean modest_account_mgr_set_account_string (ModestAccountMgr *self,
262 const gchar *key, const gchar* val,
265 gboolean modest_account_mgr_set_server_account_string (ModestAccountMgr *self,
267 const gchar *key, const gchar* val,
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.
279 * set a config int for some account
281 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
282 * @err gives details in case of error
284 gboolean modest_account_mgr_set_account_int (ModestAccountMgr *self,
286 const gchar *key, gint val,
288 gboolean modest_account_mgr_set_server_account_int (ModestAccountMgr *self,
290 const gchar *key, gint val,
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.
303 * set a config bool for some account
305 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
306 * @err gives details in case of error
308 gboolean modest_account_mgr_set_account_bool (ModestAccountMgr *self,
310 const gchar *key, gboolean val,
312 gboolean modest_account_mgr_set_server_account_bool (ModestAccountMgr *self,
314 const gchar *key, gboolean val,
320 #endif /* __MODEST_ACCOUNT_MGR_H__ */