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,
175 gboolean only_enabled);
178 * modest_account_mgr_account_exists:
179 * @self: a ModestAccountMgr instance
180 * @name: the account name to check
181 * @server_account: if TRUE, this is a server account
182 * @err: a GError ptr, or NULL to ignore.
184 * check whether account @name exists
186 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
187 * @err gives details in case of error
189 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
191 gboolean server_account,
196 * modest_account_mgr_enable_account:
197 * @self: a ModestAccountMgr instance
198 * @name: the account name to disable
199 * @server_account: if TRUE, this is a server account
201 * enable an account that has been disabled with 'modest_account_mgr_disable_account'
203 * Returns: TRUE if it worked, FALSE otherwise
205 gboolean modest_account_mgr_enable_account (ModestAccountMgr *self, const gchar* name,
206 gboolean is_server_account);
211 * modest_account_mgr_disable_account:
212 * @self: a ModestAccountMgr instance
213 * @name: the account name to disable
214 * @server_account: if TRUE, this is a server account
216 * disable an account. this will also stop change notification until
217 * modest_account_mgr_enable_account is called. However, in case of removal, the
218 * appropriate signal will still be emitted.
220 * Returns: TRUE if it worked, FALSE otherwise
222 gboolean modest_account_mgr_disable_account (ModestAccountMgr *self, const gchar* name,
223 gboolean is_server_account);
228 * modest_account_mgr_account_is_enabled:
229 * @self: a ModestAccountMgr instance
230 * @name: the account name to check
231 * @server_account: if TRUE, this is a server account
233 * check whether a certain account is enabled
235 * Returns: TRUE if it is enabled, FALSE otherwise
237 gboolean modest_account_mgr_account_is_enabled (ModestAccountMgr *self, const gchar* name,
238 gboolean is_server_account);
244 * modest_account_mgr_get_account_string:
245 * @self: self a ModestAccountMgr instance
246 * @name: the name of the account
247 * @key: the key of the value to retrieve
248 * @server_account: if TRUE, this is a server account
249 * @err: a GError ptr, or NULL to ignore.
251 * get a config string from an account
253 * Returns: a newly allocated string with the value for the key,
254 * or NULL in case of error. @err gives details in case of error
256 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
259 gboolean server_account,
264 * modest_account_mgr_get_account_int:
265 * @self: a ModestAccountMgr instance
266 * @name: the name of the account
267 * @key: the key of the value to retrieve
268 * @server_account: if TRUE, this is a server account
269 * @err: a GError ptr, or NULL to ignore.
271 * get a config int from an account
273 * Returns: an integer with the value for the key, or -1 in case of
274 * error (but of course -1 does not necessarily imply an error)
275 * @err gives details in case of error
277 gint modest_account_mgr_get_int (ModestAccountMgr *self,
280 gboolean server_account,
284 * modest_account_mgr_get_account_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
289 * @err: a GError ptr, or NULL to ignore.
291 * get a config boolean from an account
293 * Returns: an boolean with the value for the key, or FALSE in case of
294 * error (but of course FALSE does not necessarily imply an error)
295 * @err gives details in case of error
297 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
300 gboolean server_account,
304 * modest_account_mgr_set_account_string:
305 * @self: a ModestAccountMgr instance
306 * @name: the name of the account
307 * @key: the key of the value to set
308 * @val: the value to set
309 * @server_account: if TRUE, this is a server account
310 * @err: a GError ptr, or NULL to ignore.
312 * set a config string for an account
314 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
315 * @err gives details in case of error
317 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
319 const gchar *key, const gchar* val,
320 gboolean server_account,
324 * modest_account_mgr_set_account_int:
325 * @self: a ModestAccountMgr instance
326 * @name: the name of the account
327 * @key: the key of the value to set
328 * @val: the value to set
329 * @server_account: if TRUE, this is a server account
330 * @err: a GError ptr, or NULL to ignore.
332 * set a config int for an account
334 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
335 * @err gives details in case of error
337 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
339 const gchar *key, gint val,
340 gboolean server_account,
345 * modest_account_mgr_set_account_bool:
346 * @self: a ModestAccountMgr instance
347 * @name: the name of the account
348 * @key: the key of the value to set
349 * @val: the value to set
350 * @server_account: if TRUE, this is a server account
351 * @err: a GError ptr, or NULL to ignore.
353 * set a config bool for an account
355 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
356 * @err gives details in case of error
358 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
360 const gchar *key, gboolean val,
361 gboolean server_account,
366 #endif /* __MODEST_ACCOUNT_MGR_H__ */