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;
52 struct _ModestAccountMgr {
56 struct _ModestAccountMgrClass {
57 GObjectClass parent_class;
59 void (* account_inserted) (ModestAccountMgr *obj,
63 void (* account_removed) (ModestAccountMgr *obj,
67 void (* account_changed) (ModestAccountMgr *obj,
71 void (* account_busy_changed) (ModestAccountMgr *obj,
76 void (* default_account_changed)(ModestAccountMgr *obj,
81 * modest_account_mgr_get_type:
83 * get the GType for ModestAccountMgr
87 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
91 * modest_account_mgr_new:
92 * @modest_conf: a ModestConf instance
94 * Returns: a new ModestAccountMgr, or NULL in case of error
96 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
101 * modest_account_mgr_add_account:
102 * @self: a ModestAccountMgr instance
103 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
104 * @store_name: the store account (ie. POP/IMAP)
105 * @transport_name: the transport account (ie. sendmail/SMTP)
106 * @enabled: Whether the account should be enabled initially.
108 * Create a new account. The account with @name should not already exist. The @name will
109 * be used as the initial display name of the new account.
111 * Returns: TRUE if the creation succeeded, FALSE otherwise,
113 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
115 const gchar* store_name,
116 const gchar* transport_name,
120 * modest_account_mgr_add_server_account:
121 * @self: a ModestAccountMgr instance
122 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
123 * @hostname: the hostname
124 * @portnumber: the portnumber, or 0 for default
125 * @username: the username
126 * @password: the password
127 * @proto: the protocol (imap, smtp, ...) used for this account
128 * @security: the security options, (SSL, TLS ...) used to access the server
129 * @auth: the authentication method (password, none ...) used to access the server
131 * add a server account to the configuration.
132 * the server account with @name should not already exist
134 * Returns: TRUE if succeeded, FALSE otherwise,
136 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
138 const gchar *hostname,
139 const guint portnumber,
140 const gchar *username,
141 const gchar *password,
142 ModestTransportStoreProtocol proto,
143 ModestConnectionProtocol security,
144 ModestAuthProtocol auth);
148 * modest_account_mgr_add_server_account_uri:
149 * @self: a ModestAccountMgr instance
150 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
151 * @proto: the protocol (imap, smtp, ...) used for this account
154 * add a server account to the configuration, based on the account-URI
156 * Returns: TRUE if succeeded, FALSE otherwise,
158 gboolean modest_account_mgr_add_server_account_uri (ModestAccountMgr *self,
160 ModestTransportStoreProtocol proto,
164 * modest_account_mgr_remove_account:
165 * @self: a ModestAccountMgr instance
166 * @name: the name of the account to remove
167 * @err: a #GError ptr, or NULL to ignore.
169 * remove an existing account. the account with @name should already exist; note
170 * that when deleting an account, also the corresponding server accounts will
173 * Returns: TRUE if the creation succeeded, FALSE otherwise,
174 * @err gives details in case of error
176 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
180 * modest_account_mgr_account_names:
181 * @self: a ModestAccountMgr instance
182 * @only_enabled: Whether only enabled accounts should be returned.
184 * list all account names
186 * Returns: a newly allocated list of account names, or NULL in case of error or
187 * if there are no accounts. The caller must free the returned GSList.
190 GSList* modest_account_mgr_account_names (ModestAccountMgr *self,
191 gboolean only_enabled);
194 * modest_account_mgr_free_account_names:
195 * @account_name: a gslist of account names
197 * list all account names
199 * free the list of account names
201 void modest_account_mgr_free_account_names (GSList *account_names);
205 * modest_account_mgr_account_exists:
206 * @self: a ModestAccountMgr instance
207 * @name: the account name to check
208 * @server_account: if TRUE, this is a server account
210 * check whether account @name exists. Note that this does not check the display name.
212 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
214 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
216 gboolean server_account);
219 * modest_account_mgr_account_exists:
220 * @self: a ModestAccountMgr instance
221 * @name: the account name to check
223 * check whether a non-server account with the @display_name exists.
225 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
227 gboolean modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self,
228 const gchar *display_name);
232 * modest_account_mgr_get_string:
233 * @self: self a ModestAccountMgr instance
234 * @name: the name of the account
235 * @key: the key of the value to retrieve
236 * @server_account: if TRUE, this is a server account
238 * get a config string from an account
240 * Returns: a newly allocated string with the value for the key,
241 * or NULL in case of error.
243 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
246 gboolean server_account);
250 * modest_account_mgr_get_password:
251 * @self: self a ModestAccountMgr instance
252 * @name: the name of the account
253 * @key: the key of the value to retrieve
254 * @server_account: if TRUE, this is a server account
256 * get a password from an account
258 * Returns: a newly allocated string with the value for the key,
259 * or NULL in case of error.
261 gchar* modest_account_mgr_get_password (ModestAccountMgr *self,
264 gboolean server_account);
267 * modest_account_mgr_get_int:
268 * @self: a ModestAccountMgr instance
269 * @name: the name of the account
270 * @key: the key of the value to retrieve
271 * @server_account: if TRUE, this is a server account
273 * get a config int from an account
275 * Returns: an integer with the value for the key, or -1 in case of
276 * error (but of course -1 does not necessarily imply an error)
278 gint modest_account_mgr_get_int (ModestAccountMgr *self,
281 gboolean server_account);
284 * modest_account_mgr_get_bool:
285 * @self: a ModestAccountMgr instance
286 * @name: the name of the account
287 * @key: the key of the value to retrieve
288 * @server_account: if TRUE, this is a server account
290 * get a config boolean from an account
292 * Returns: an boolean with the value for the key, or FALSE in case of
293 * error (but of course FALSE does not necessarily imply an error)
295 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
298 gboolean server_account);
301 * modest_account_mgr_get_list:
302 * @self: a ModestAccountMgr instance
303 * @name: the name of the account
304 * @key: the key of the value to get
305 * @list_type: the type of the members of the list
306 * @server_account: if TRUE, this is a server account
308 * get a config list of values of type @list_type of an account
310 * Returns: a newly allocated list of elements
312 GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
315 ModestConfValueType list_type,
316 gboolean server_account);
319 * modest_account_mgr_set_string:
320 * @self: a ModestAccountMgr instance
321 * @name: the name of the account
322 * @key: the key of the value to set
323 * @val: the value to set
324 * @server_account: if TRUE, this is a server account
326 * set a config string for an account.
328 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
330 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
332 const gchar *key, const gchar* val,
333 gboolean server_account);
337 * modest_account_mgr_set_password:
338 * @self: a ModestAccountMgr instance
339 * @name: the name of the account
340 * @key: the key of the value to set
341 * @val: the value to set
342 * @server_account: if TRUE, this is a server account
344 * set a password for an account.
346 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
347 * @err gives details in case of error
349 gboolean modest_account_mgr_set_password (ModestAccountMgr *self,
351 const gchar *key, const gchar* val,
352 gboolean server_account);
355 * modest_account_mgr_set_int:
356 * @self: a ModestAccountMgr instance
357 * @name: the name of the account
358 * @key: the key of the value to set
359 * @val: the value to set
360 * @server_account: if TRUE, this is a server account
362 * set a config int for an account
364 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
366 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
368 const gchar *key, gint val,
369 gboolean server_account);
372 * modest_account_mgr_set_bool:
373 * @self: a ModestAccountMgr instance
374 * @name: the name of the account
375 * @key: the key of the value to set
376 * @val: the value to set
377 * @server_account: if TRUE, this is a server account
379 * set a config bool for an account
381 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
383 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
385 const gchar *key, gboolean val,
386 gboolean server_account);
389 * modest_account_mgr_set_list:
390 * @self: a ModestAccountMgr instance
391 * @name: the name of the account
392 * @key: the key of the value to set
393 * @val: the list with the values to set
394 * @list_type: the type of the members of the list
395 * @server_account: if TRUE, this is a server account
397 * * set a config list of values of type @list_type of an account
399 * returns TRUE if this succeeded, FALSE otherwise
401 gboolean modest_account_mgr_set_list (ModestAccountMgr *self,
405 ModestConfValueType list_type,
406 gboolean server_account);
409 * modest_account_mgr_unset:
410 * @self: a ModestAccountMgr instance
411 * @name: the name of the account
412 * @key: the key of the value to unset
413 * @server_account: if TRUE, this is a server account
414 * @err: a GError ptr, or NULL to ignore.
416 * unsets the config value of an account and all their children keys
418 * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
419 * @err gives details in case of error
421 gboolean modest_account_mgr_unset (ModestAccountMgr *self,
424 gboolean server_account);
427 * modest_account_mgr_has_accounts:
428 * @self: a ModestAccountMgr instance
429 * @enabled: TRUE to search for enabled accounts only
431 * Checks if any accounts exist
433 * Returns: TRUE if accounts exist, FALSE otherwise
436 gboolean modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled);
439 * modest_account_mgr_set_account_busy
440 * @self: a ModestAccountMgr instance
441 * @account_name: name of the account
442 * @busy: whether to set busy or not busy
444 * Changes the busy flag of an account
448 void modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name,
452 * modest_account_mgr_account_is_busy
453 * @self: a ModestAccountMgr instance
454 * @account_name: name of the account
456 * Returns: If the account is currently busy or not
460 modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name);
465 #endif /* __MODEST_ACCOUNT_MGR_H__ */