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 * @hostname: the hostname
97 * @username: the username
98 * @password: the password
99 * @proto: the prototype
100 * @err: a GError ptr, or NULL to ignore.
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,
106 * @err gives details in case of error
108 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
110 const gchar *hostname,
111 const gchar *username,
112 const gchar *password,
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.
121 * remove a server account from the configuration
122 * the server account with @name should exist
124 * Returns: TRUE if the removal succeeded, FALSE otherwise,
125 * @err gives details in case of error
127 gboolean modest_account_mgr_remove_server_account (ModestAccountMgr *self,
133 * modest_account_mgr_account_names:
134 * @self: a ModestAccountMgr instance
135 * @err: a GError ptr, or NULL to ignore.
137 * list all account names
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
143 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
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
154 * list all the server account names
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
159 GSList* modest_account_mgr_server_account_names (ModestAccountMgr *self,
160 const gchar* account_name,
161 ModestProtoType type,
163 gboolean only_enabled);
166 * modest_account_mgr_account_exists:
167 * @self: a ModestAccountMgr instance
168 * @err: a GError ptr, or NULL to ignore.
170 * check whether account @name exists
172 * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
173 * @err gives details in case of error
175 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
178 gboolean modest_account_mgr_server_account_exists (ModestAccountMgr *self,
183 /* account specific functions */
188 * modest_account_mgr_get_account_string:
189 * @self: self a ModestAccountMgr instance
190 * @name: the name of the account
191 * @key: the key of the value to retrieve
192 * @err: a GError ptr, or NULL to ignore.
194 * get a config string from some account
196 * Returns: a newly allocated string with the value for the key,
197 * or NULL in case of error. @err gives details in case of error
199 gchar* modest_account_mgr_get_account_string (ModestAccountMgr *self,
201 const gchar *key, GError **err);
203 gchar* modest_account_mgr_get_server_account_string (ModestAccountMgr *self,
205 const gchar *key, GError **err);
209 * modest_account_mgr_get_account_int:
210 * @self: self a ModestAccountMgr instance
211 * @name: the name of the account
212 * @key: the key of the value to retrieve
213 * @err: a GError ptr, or NULL to ignore.
215 * get a config int from some account
217 * Returns: an integer with the value for the key, or -1 in case of
218 * error (but of course -1 does not necessarily imply an error)
219 * @err gives details in case of error
221 gint modest_account_mgr_get_account_int (ModestAccountMgr *self,
223 const gchar *key, GError **err);
224 gint modest_account_mgr_get_server_account_int (ModestAccountMgr *self,
226 const gchar *key, GError **err);
230 * modest_account_mgr_get_account_bool:
231 * @self: self a ModestAccountMgr instance
232 * @name: the name of the account
233 * @key: the key of the value to retrieve
234 * @err: a GError ptr, or NULL to ignore.
236 * get a config boolean from some account
238 * Returns: an boolean with the value for the key, or FALSE in case of
239 * error (but of course FALSE does not necessarily imply an error)
240 * @err gives details in case of error
242 gboolean modest_account_mgr_get_account_bool (ModestAccountMgr *self,
244 const gchar *key, GError **err);
246 gboolean modest_account_mgr_get_server_account_bool (ModestAccountMgr *self,
248 const gchar *key, GError **err);
251 * modest_account_mgr_set_account_string:
252 * @self: self a ModestAccountMgr instance
253 * @name: the name of the account
254 * @key: the key of the value to set
255 * @val: the value to set
256 * @err: a GError ptr, or NULL to ignore.
258 * set a config string for some account
260 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
261 * @err gives details in case of error
263 gboolean modest_account_mgr_set_account_string (ModestAccountMgr *self,
265 const gchar *key, const gchar* val,
268 gboolean modest_account_mgr_set_server_account_string (ModestAccountMgr *self,
270 const gchar *key, const gchar* val,
275 * modest_account_mgr_set_account_int:
276 * @self: self a ModestAccountMgr instance
277 * @name: the name of the account
278 * @key: the key of the value to set
279 * @val: the value to set
280 * @err: a GError ptr, or NULL to ignore.
282 * set a config int for some account
284 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
285 * @err gives details in case of error
287 gboolean modest_account_mgr_set_account_int (ModestAccountMgr *self,
289 const gchar *key, gint val,
291 gboolean modest_account_mgr_set_server_account_int (ModestAccountMgr *self,
293 const gchar *key, gint val,
299 * modest_account_mgr_set_account_bool:
300 * @self: self a ModestAccountMgr instance
301 * @name: the name of the account
302 * @key: the key of the value to set
303 * @val: the value to set
304 * @err: a GError ptr, or NULL to ignore.
306 * set a config bool for some account
308 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
309 * @err gives details in case of error
311 gboolean modest_account_mgr_set_account_bool (ModestAccountMgr *self,
313 const gchar *key, gboolean val,
315 gboolean modest_account_mgr_set_server_account_bool (ModestAccountMgr *self,
317 const gchar *key, gboolean val,
323 #endif /* __MODEST_ACCOUNT_MGR_H__ */