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,
130 * modest_account_mgr_remove_identity:
131 * @self: a ModestAccountMgr instance
132 * @name: the name for the identity
133 * @err: a GError ptr, or NULL to ignore.
135 * remove aidentity from the configuration
136 * the identity with @name should exist
138 * Returns: TRUE if the removal succeeded, FALSE otherwise,
139 * @err gives details in case of error
141 gboolean modest_account_mgr_remove_identity (ModestAccountMgr *self,
146 * modest_account_mgr_add_identity:
147 * @self: a ModestAccountMgr instance
148 * @name: the name (id) for the identity
149 * @email: the user's email address
150 * @replyto: default replyto address
151 * @signature: the signature for this identity
152 * @use_signature: whether to use this signature instead of the default one
153 * @id_via: the transport to send emails for this identity via
154 * @use_id_via: whether to use this via insteda of the default one
156 * add a user identity to the configuration
158 * Returns: TRUE if succeeded, FALSE otherwise,
162 modest_account_mgr_add_identity (ModestAccountMgr *self,
165 const gchar *replyto,
166 const gchar *signature,
167 const gboolean use_signature,
169 const gboolean use_id_via);
172 * modest_account_mgr_account_names:
173 * @self: a ModestAccountMgr instance
174 * @err: a GError ptr, or NULL to ignore.
176 * list all account names
178 * Returns: a newly allocated list of account names, or NULL in case of error or
179 * if there are no accounts. The caller must free the returned GSList
180 * @err gives details in case of error
182 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
186 * modest_account_mgr_server_account_names:
187 * @self: a ModestAccountMgr instance
188 * @account_name: get only server accounts for @account_name, or NULL for any
189 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
190 * @proto: get only server account with protocol @proto, or NULL for any
191 * @only_enable: get only enable server account if TRUE
193 * list all the server account names
195 * Returns: a newly allocated list of server account names, or NULL in case of
196 * error or if there are no server accounts. The caller must free the returned GSList
198 GSList* modest_account_mgr_server_account_names (ModestAccountMgr *self,
199 const gchar* account_name,
200 ModestProtoType type,
202 gboolean only_enabled);
205 * modest_account_mgr_account_exists:
206 * @self: a ModestAccountMgr instance
207 * @err: a GError ptr, or NULL to ignore.
209 * check whether account @name exists
211 * Returns: TRUE if the account exists, FALSE otherwise (or in case of error)
212 * @err gives details in case of error
214 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
217 gboolean modest_account_mgr_server_account_exists (ModestAccountMgr *self,
222 /* account specific functions */
227 * modest_account_mgr_get_account_string:
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 string from some account
235 * Returns: a newly allocated string with the value for the key,
236 * or NULL in case of error. @err gives details in case of error
238 gchar* modest_account_mgr_get_account_string (ModestAccountMgr *self,
240 const gchar *key, GError **err);
242 gchar* modest_account_mgr_get_server_account_string (ModestAccountMgr *self,
244 const gchar *key, GError **err);
245 gchar* modest_account_mgr_get_identity_string (ModestAccountMgr *self,
247 const gchar *key, GError **err);
251 * modest_account_mgr_get_account_int:
252 * @self: self a ModestAccountMgr instance
253 * @name: the name of the account
254 * @key: the key of the value to retrieve
255 * @err: a GError ptr, or NULL to ignore.
257 * get a config int from some account
259 * Returns: an integer with the value for the key, or -1 in case of
260 * error (but of course -1 does not necessarily imply an error)
261 * @err gives details in case of error
263 gint modest_account_mgr_get_account_int (ModestAccountMgr *self,
265 const gchar *key, GError **err);
266 gint modest_account_mgr_get_server_account_int (ModestAccountMgr *self,
268 const gchar *key, GError **err);
272 * modest_account_mgr_get_account_bool:
273 * @self: self a ModestAccountMgr instance
274 * @name: the name of the account
275 * @key: the key of the value to retrieve
276 * @err: a GError ptr, or NULL to ignore.
278 * get a config boolean from some account
280 * Returns: an boolean with the value for the key, or FALSE in case of
281 * error (but of course FALSE does not necessarily imply an error)
282 * @err gives details in case of error
284 gboolean modest_account_mgr_get_account_bool (ModestAccountMgr *self,
286 const gchar *key, GError **err);
288 gboolean modest_account_mgr_get_server_account_bool (ModestAccountMgr *self,
290 const gchar *key, GError **err);
293 * modest_account_mgr_set_account_string:
294 * @self: self a ModestAccountMgr instance
295 * @name: the name of the account
296 * @key: the key of the value to set
297 * @val: the value to set
298 * @err: a GError ptr, or NULL to ignore.
300 * set a config string for some account
302 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
303 * @err gives details in case of error
305 gboolean modest_account_mgr_set_account_string (ModestAccountMgr *self,
307 const gchar *key, const gchar* val,
310 gboolean modest_account_mgr_set_server_account_string (ModestAccountMgr *self,
312 const gchar *key, const gchar* val,
317 * modest_account_mgr_set_account_int:
318 * @self: self a ModestAccountMgr instance
319 * @name: the name of the account
320 * @key: the key of the value to set
321 * @val: the value to set
322 * @err: a GError ptr, or NULL to ignore.
324 * set a config int for some account
326 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
327 * @err gives details in case of error
329 gboolean modest_account_mgr_set_account_int (ModestAccountMgr *self,
331 const gchar *key, gint val,
333 gboolean modest_account_mgr_set_server_account_int (ModestAccountMgr *self,
335 const gchar *key, gint val,
341 * modest_account_mgr_set_account_bool:
342 * @self: self a ModestAccountMgr instance
343 * @name: the name of the account
344 * @key: the key of the value to set
345 * @val: the value to set
346 * @err: a GError ptr, or NULL to ignore.
348 * set a config bool for some account
350 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
351 * @err gives details in case of error
353 gboolean modest_account_mgr_set_account_bool (ModestAccountMgr *self,
355 const gchar *key, gboolean val,
357 gboolean modest_account_mgr_set_server_account_bool (ModestAccountMgr *self,
359 const gchar *key, gboolean val,
365 #endif /* __MODEST_ACCOUNT_MGR_H__ */