1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __MODEST_ACCOUNT_MGR_H__
32 #define __MODEST_ACCOUNT_MGR_H__
34 #include <glib-object.h>
35 #include <modest-conf.h>
36 #include <modest-defs.h>
37 #include <modest-protocol-info.h>
41 /* convenience macros */
42 #define MODEST_TYPE_ACCOUNT_MGR (modest_account_mgr_get_type())
43 #define MODEST_ACCOUNT_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgr))
44 #define MODEST_ACCOUNT_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgrClass))
45 #define MODEST_IS_ACCOUNT_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_MGR))
46 #define MODEST_IS_ACCOUNT_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_MGR))
47 #define MODEST_ACCOUNT_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgrClass))
49 typedef struct _ModestAccountMgr ModestAccountMgr;
50 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
53 struct _ModestAccountMgr {
57 struct _ModestAccountMgrClass {
58 GObjectClass parent_class;
60 void (* account_removed) (ModestAccountMgr *obj, const gchar* account,
61 gboolean server_account, gpointer user_data);
62 void (* account_changed) (ModestAccountMgr *obj, const gchar* account,
63 const gchar* key, gboolean server_account,
68 * modest_account_mgr_get_type:
70 * get the GType for ModestAccountMgr
74 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
78 * modest_account_mgr_new:
79 * @modest_conf: a ModestConf instance
81 * Returns: a new ModestAccountMgr, or NULL in case of error
83 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
88 * modest_account_mgr_add_account:
89 * @self: a ModestAccountMgr instance
90 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
91 * @store_name: the store account (ie. POP/IMAP)
92 * @transport_name: the transport account (ie. sendmail/SMTP)
93 * @err: a GError ptr, or NULL to ignore.
95 * create a new account. the account with @name should not already exist
97 * Returns: TRUE if the creation succeeded, FALSE otherwise,
98 * @err gives details in case of error
100 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
102 const gchar* store_name,
103 const gchar* transport_name);
106 * modest_account_mgr_add_server_account:
107 * @self: a ModestAccountMgr instance
108 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
109 * @hostname: the hostname
110 * @username: the username
111 * @password: the password
112 * @proto: the protocol (imap, smtp, ...) used for this account
113 * @security: the security options, (SSL, TLS ...) used to access the server
114 * @auth: the authentication method (password, none ...) used to access the server
116 * add a server account to the configuration.
117 * the server account with @name should not already exist
119 * Returns: TRUE if succeeded, FALSE otherwise,
121 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
123 const gchar *hostname,
124 const gchar *username,
125 const gchar *password,
126 ModestProtocol proto,
127 ModestProtocol security,
128 ModestProtocol auth);
132 * modest_account_mgr_add_server_account_uri:
133 * @self: a ModestAccountMgr instance
134 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
135 * @proto: the protocol (imap, smtp, ...) used for this account
138 * add a server account to the configuration, based on the account-URI
140 * Returns: TRUE if succeeded, FALSE otherwise,
142 gboolean modest_account_mgr_add_server_account_uri (ModestAccountMgr *self,
144 ModestProtocol proto,
148 * modest_account_mgr_remove_account:
149 * @self: a ModestAccountMgr instance
150 * @name: the name of the account to remove
151 * @server_account: TRUE if the account to remove is a server account
152 * @err: a #GError ptr, or NULL to ignore.
154 * remove an existing account. the account with @name should already exist
156 * Returns: TRUE if the creation succeeded, FALSE otherwise,
157 * @err gives details in case of error
159 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
161 gboolean server_account);
165 * modest_account_mgr_account_names:
166 * @self: a ModestAccountMgr instance
168 * list all account names
170 * Returns: a newly allocated list of account names, or NULL in case of error or
171 * if there are no accounts. The caller must free the returned GSList
173 GSList* modest_account_mgr_account_names (ModestAccountMgr *self);
177 * modest_account_mgr_server_account_names:
178 * @self: a ModestAccountMgr instance
179 * @account_name: get only server accounts for @account_name, or NULL for any
180 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
181 * @proto: get only server account with protocol @proto, or NULL for any
182 * @only_enabled: get only enabled server accounts if TRUE
184 * list all the server account names
186 * Returns: a newly allocated list of server account names, or NULL in case of
187 * error or if there are no server accounts. The caller must free the returned GSList
189 GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
190 const gchar* account_name,
191 ModestProtocolType type,
192 ModestProtocol proto);
195 * modest_account_mgr_account_exists:
196 * @self: a ModestAccountMgr instance
197 * @name: the account name to check
198 * @server_account: if TRUE, this is a server account
200 * check whether account @name exists
202 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
204 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
206 gboolean server_account);
210 * modest_account_mgr_get_string:
211 * @self: self a ModestAccountMgr instance
212 * @name: the name of the account
213 * @key: the key of the value to retrieve
214 * @server_account: if TRUE, this is a server account
216 * get a config string from an account
218 * Returns: a newly allocated string with the value for the key,
219 * or NULL in case of error.
221 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
224 gboolean server_account);
228 * modest_account_mgr_get_password:
229 * @self: self a ModestAccountMgr instance
230 * @name: the name of the account
231 * @key: the key of the value to retrieve
232 * @server_account: if TRUE, this is a server account
234 * get a password from an account
236 * Returns: a newly allocated string with the value for the key,
237 * or NULL in case of error.
239 gchar* modest_account_mgr_get_password (ModestAccountMgr *self,
242 gboolean server_account);
245 * modest_account_mgr_get_int:
246 * @self: a ModestAccountMgr instance
247 * @name: the name of the account
248 * @key: the key of the value to retrieve
249 * @server_account: if TRUE, this is a server account
251 * get a config int from an account
253 * Returns: an integer with the value for the key, or -1 in case of
254 * error (but of course -1 does not necessarily imply an error)
256 gint modest_account_mgr_get_int (ModestAccountMgr *self,
259 gboolean server_account);
262 * modest_account_mgr_get_bool:
263 * @self: a ModestAccountMgr instance
264 * @name: the name of the account
265 * @key: the key of the value to retrieve
266 * @server_account: if TRUE, this is a server account
268 * get a config boolean from an account
270 * Returns: an boolean with the value for the key, or FALSE in case of
271 * error (but of course FALSE does not necessarily imply an error)
273 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
276 gboolean server_account);
279 * modest_account_mgr_get_list:
280 * @self: a ModestAccountMgr instance
281 * @name: the name of the account
282 * @key: the key of the value to get
283 * @list_type: the type of the members of the list
284 * @server_account: if TRUE, this is a server account
286 * get a config list of values of type @list_type of an account
288 * Returns: a newly allocated list of elements
290 GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
293 ModestConfValueType list_type,
294 gboolean server_account);
297 * modest_account_mgr_set_string:
298 * @self: a ModestAccountMgr instance
299 * @name: the name of the account
300 * @key: the key of the value to set
301 * @val: the value to set
302 * @server_account: if TRUE, this is a server account
304 * set a config string for an account.
306 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
308 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
310 const gchar *key, const gchar* val,
311 gboolean server_account);
315 * modest_account_mgr_set_password:
316 * @self: a ModestAccountMgr instance
317 * @name: the name of the account
318 * @key: the key of the value to set
319 * @val: the value to set
320 * @server_account: if TRUE, this is a server account
322 * set a password for an account.
324 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
325 * @err gives details in case of error
327 gboolean modest_account_mgr_set_password (ModestAccountMgr *self,
329 const gchar *key, const gchar* val,
330 gboolean server_account);
333 * modest_account_mgr_set_int:
334 * @self: a ModestAccountMgr instance
335 * @name: the name of the account
336 * @key: the key of the value to set
337 * @val: the value to set
338 * @server_account: if TRUE, this is a server account
340 * set a config int for an account
342 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
344 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
346 const gchar *key, gint val,
347 gboolean server_account);
350 * modest_account_mgr_set_bool:
351 * @self: a ModestAccountMgr instance
352 * @name: the name of the account
353 * @key: the key of the value to set
354 * @val: the value to set
355 * @server_account: if TRUE, this is a server account
357 * set a config bool for an account
359 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
361 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
363 const gchar *key, gboolean val,
364 gboolean server_account);
367 * modest_account_mgr_set_list:
368 * @self: a ModestAccountMgr instance
369 * @name: the name of the account
370 * @key: the key of the value to set
371 * @val: the list with the values to set
372 * @list_type: the type of the members of the list
373 * @server_account: if TRUE, this is a server account
375 * * set a config list of values of type @list_type of an account
377 * returns TRUE if this succeeded, FALSE otherwise
379 gboolean modest_account_mgr_set_list (ModestAccountMgr *self,
383 ModestConfValueType list_type,
384 gboolean server_account);
387 * modest_account_mgr_unset:
388 * @self: a ModestAccountMgr instance
389 * @name: the name of the account
390 * @key: the key of the value to unset
391 * @server_account: if TRUE, this is a server account
392 * @err: a GError ptr, or NULL to ignore.
394 * unsets the config value of an account and all their children keys
396 * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
397 * @err gives details in case of error
399 gboolean modest_account_mgr_unset (ModestAccountMgr *self,
402 gboolean server_account);
406 #endif /* __MODEST_ACCOUNT_MGR_H__ */