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_name: the store account (ie. POP/IMAP)
64 * @transport_name: 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,
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 to remove
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_enabled: get only enabled server accounts 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 * @name: the account name to check
167 * @err: a GError ptr, or NULL to ignore.
169 * check whether account @name exists
171 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
172 * @err gives details in case of error
174 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
178 gboolean modest_account_mgr_server_account_exists (ModestAccountMgr *self,
184 /* account specific functions */
187 * modest_account_mgr_get_account_string:
188 * @self: self a ModestAccountMgr instance
189 * @name: the name of the account
190 * @key: the key of the value to retrieve
191 * @err: a GError ptr, or NULL to ignore.
193 * get a config string from an account
195 * Returns: a newly allocated string with the value for the key,
196 * or NULL in case of error. @err gives details in case of error
198 gchar* modest_account_mgr_get_account_string (ModestAccountMgr *self,
200 const gchar *key, GError **err);
202 gchar* modest_account_mgr_get_server_account_string (ModestAccountMgr *self,
204 const gchar *key, GError **err);
207 * modest_account_mgr_get_account_int:
208 * @self: a ModestAccountMgr instance
209 * @name: the name of the account
210 * @key: the key of the value to retrieve
211 * @err: a GError ptr, or NULL to ignore.
213 * get a config int from an account
215 * Returns: an integer with the value for the key, or -1 in case of
216 * error (but of course -1 does not necessarily imply an error)
217 * @err gives details in case of error
219 gint modest_account_mgr_get_account_int (ModestAccountMgr *self,
221 const gchar *key, GError **err);
223 gint modest_account_mgr_get_server_account_int (ModestAccountMgr *self,
225 const gchar *key, GError **err);
229 * modest_account_mgr_get_account_bool:
230 * @self: a ModestAccountMgr instance
231 * @name: the name of the account
232 * @key: the key of the value to retrieve
233 * @err: a GError ptr, or NULL to ignore.
235 * get a config boolean from an account
237 * Returns: an boolean with the value for the key, or FALSE in case of
238 * error (but of course FALSE does not necessarily imply an error)
239 * @err gives details in case of error
241 gboolean modest_account_mgr_get_account_bool (ModestAccountMgr *self,
243 const gchar *key, GError **err);
245 gboolean modest_account_mgr_get_server_account_bool (ModestAccountMgr *self,
247 const gchar *key, GError **err);
250 * modest_account_mgr_set_account_string:
251 * @self: a ModestAccountMgr instance
252 * @name: the name of the account
253 * @key: the key of the value to set
254 * @val: the value to set
255 * @err: a GError ptr, or NULL to ignore.
257 * set a config string for an account
259 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
260 * @err gives details in case of error
262 gboolean modest_account_mgr_set_account_string (ModestAccountMgr *self,
264 const gchar *key, const gchar* val,
267 gboolean modest_account_mgr_set_server_account_string (ModestAccountMgr *self,
269 const gchar *key, const gchar* val,
274 * modest_account_mgr_set_account_int:
275 * @self: a ModestAccountMgr instance
276 * @name: the name of the account
277 * @key: the key of the value to set
278 * @val: the value to set
279 * @err: a GError ptr, or NULL to ignore.
281 * set a config int for an account
283 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
284 * @err gives details in case of error
286 gboolean modest_account_mgr_set_account_int (ModestAccountMgr *self,
288 const gchar *key, gint val,
291 gboolean modest_account_mgr_set_server_account_int (ModestAccountMgr *self,
293 const gchar *key, gint val,
298 * modest_account_mgr_set_account_bool:
299 * @self: a ModestAccountMgr instance
300 * @name: the name of the account
301 * @key: the key of the value to set
302 * @val: the value to set
303 * @err: a GError ptr, or NULL to ignore.
305 * set a config bool for an account
307 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
308 * @err gives details in case of error
310 gboolean modest_account_mgr_set_account_bool (ModestAccountMgr *self,
312 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__ */