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-account-keys.h"
37 #include "modest-proto.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, gboolean server_account, gpointer user_data);
61 void (* account_changed) (ModestAccountMgr *obj, const gchar* account, const gchar* key, gboolean server_account,
69 * get the GType for ModestAccountMgr
73 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
77 * modest_account_mgr_new:
78 * @modest_conf: a ModestConf instance
80 * Returns: a new ModestAccountMgr, or NULL in case of error
82 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
87 * modest_account_mgr_add_account:
88 * @self: a ModestAccountMgr instance
89 * @name: the name of the account to create
90 * @store_name: the store account (ie. POP/IMAP)
91 * @transport_name: the transport account (ie. sendmail/SMTP)
92 * @err: a GError ptr, or NULL to ignore.
94 * create a new account. the account with @name should not already exist
96 * Returns: TRUE if the creation succeeded, FALSE otherwise,
97 * @err gives details in case of error
99 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
101 const gchar* store_name,
102 const gchar* transport_name,
107 * modest_account_mgr_add_server_account:
108 * @self: a ModestAccountMgr instance
109 * @name: name (id) of the account
110 * @hostname: the hostname
111 * @username: the username
112 * @password: the password
113 * @proto: the protocol (imap, smtp, ...) used for this account
115 * add a server account to the configuration.
116 * the server account with @name should not already exist
118 * Returns: TRUE if succeeded, FALSE otherwise,
120 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
122 const gchar *hostname,
123 const gchar *username,
124 const gchar *password,
128 * modest_account_mgr_remove_account:
129 * @self: a ModestAccountMgr instance
130 * @name: the name of the account to remove
131 * @err: a GError ptr, or NULL to ignore.
133 * remove an existing account. the account with @name should already exist
135 * Returns: TRUE if the creation succeeded, FALSE otherwise,
136 * @err gives details in case of error
138 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
140 gboolean server_account,
145 * modest_account_mgr_account_names:
146 * @self: a ModestAccountMgr instance
147 * @err: a GError ptr, or NULL to ignore.
149 * list all account names
151 * Returns: a newly allocated list of account names, or NULL in case of error or
152 * if there are no accounts. The caller must free the returned GSList
153 * @err gives details in case of error
155 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
159 * modest_account_mgr_server_account_names:
160 * @self: a ModestAccountMgr instance
161 * @account_name: get only server accounts for @account_name, or NULL for any
162 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
163 * @proto: get only server account with protocol @proto, or NULL for any
164 * @only_enabled: get only enabled server accounts if TRUE
166 * list all the server account names
168 * Returns: a newly allocated list of server account names, or NULL in case of
169 * error or if there are no server accounts. The caller must free the returned GSList
171 GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
172 const gchar* account_name,
173 ModestProtoType type,
177 * modest_account_mgr_account_exists:
178 * @self: a ModestAccountMgr instance
179 * @name: the account name to check
180 * @server_account: if TRUE, this is a server account
181 * @err: a GError ptr, or NULL to ignore.
183 * check whether account @name exists
185 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
186 * @err gives details in case of error
188 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
190 gboolean server_account,
195 * modest_account_mgr_account_set_enabled
196 * @self: a ModestAccountMgr instance
197 * @name: the account name
198 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
200 * enable/disabled an account
202 * Returns: TRUE if it worked, FALSE otherwise
204 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
209 * modest_account_mgr_account_get_enabled:
210 * @self: a ModestAccountMgr instance
211 * @name: the account name to check
213 * check whether a certain account is enabled
215 * Returns: TRUE if it is enabled, FALSE otherwise
217 gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name);
221 * modest_account_mgr_get_account_string:
222 * @self: self a ModestAccountMgr instance
223 * @name: the name of the account
224 * @key: the key of the value to retrieve
225 * @server_account: if TRUE, this is a server account
226 * @err: a GError ptr, or NULL to ignore.
228 * get a config string from an account
230 * Returns: a newly allocated string with the value for the key,
231 * or NULL in case of error. @err gives details in case of error
233 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
236 gboolean server_account,
241 * modest_account_mgr_get_account_int:
242 * @self: a ModestAccountMgr instance
243 * @name: the name of the account
244 * @key: the key of the value to retrieve
245 * @server_account: if TRUE, this is a server account
246 * @err: a GError ptr, or NULL to ignore.
248 * get a config int from an account
250 * Returns: an integer with the value for the key, or -1 in case of
251 * error (but of course -1 does not necessarily imply an error)
252 * @err gives details in case of error
254 gint modest_account_mgr_get_int (ModestAccountMgr *self,
257 gboolean server_account,
261 * modest_account_mgr_get_account_bool:
262 * @self: a ModestAccountMgr instance
263 * @name: the name of the account
264 * @key: the key of the value to retrieve
265 * @server_account: if TRUE, this is a server account
266 * @err: a GError ptr, or NULL to ignore.
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)
272 * @err gives details in case of error
274 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
277 gboolean server_account,
281 * modest_account_mgr_set_account_string:
282 * @self: a ModestAccountMgr instance
283 * @name: the name of the account
284 * @key: the key of the value to set
285 * @val: the value to set
286 * @server_account: if TRUE, this is a server account
287 * @err: a GError ptr, or NULL to ignore.
289 * set a config string for an account
291 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
292 * @err gives details in case of error
294 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
296 const gchar *key, const gchar* val,
297 gboolean server_account,
301 * modest_account_mgr_set_account_int:
302 * @self: a ModestAccountMgr instance
303 * @name: the name of the account
304 * @key: the key of the value to set
305 * @val: the value to set
306 * @server_account: if TRUE, this is a server account
307 * @err: a GError ptr, or NULL to ignore.
309 * set a config int for an account
311 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
312 * @err gives details in case of error
314 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
316 const gchar *key, gint val,
317 gboolean server_account,
322 * modest_account_mgr_set_account_bool:
323 * @self: a ModestAccountMgr instance
324 * @name: the name of the account
325 * @key: the key of the value to set
326 * @val: the value to set
327 * @server_account: if TRUE, this is a server account
328 * @err: a GError ptr, or NULL to ignore.
330 * set a config bool for an account
332 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
333 * @err gives details in case of error
335 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
337 const gchar *key, gboolean val,
338 gboolean server_account,
343 #endif /* __MODEST_ACCOUNT_MGR_H__ */