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-protocol-mgr.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 * some convenience structs to get bulk data about an account
70 struct _ModestServerAccountData {
77 typedef struct _ModestServerAccountData ModestServerAccountData;
79 struct _ModestAccountData {
85 ModestServerAccountData *transport_account;
86 ModestServerAccountData *store_account;
88 typedef struct _ModestAccountData ModestAccountData;
95 * get the GType for ModestAccountMgr
99 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
103 * modest_account_mgr_new:
104 * @modest_conf: a ModestConf instance
106 * Returns: a new ModestAccountMgr, or NULL in case of error
108 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
113 * modest_account_mgr_add_account:
114 * @self: a ModestAccountMgr instance
115 * @name: the name of the account to create
116 * @store_name: the store account (ie. POP/IMAP)
117 * @transport_name: the transport account (ie. sendmail/SMTP)
118 * @err: a GError ptr, or NULL to ignore.
120 * create a new account. the account with @name should not already exist
122 * Returns: TRUE if the creation succeeded, FALSE otherwise,
123 * @err gives details in case of error
125 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
127 const gchar* store_name,
128 const gchar* transport_name,
133 * modest_account_mgr_add_server_account:
134 * @self: a ModestAccountMgr instance
135 * @name: name (id) of the account
136 * @hostname: the hostname
137 * @username: the username
138 * @password: the password
139 * @proto: the protocol (imap, smtp, ...) used for this account
141 * add a server account to the configuration.
142 * the server account with @name should not already exist
144 * Returns: TRUE if succeeded, FALSE otherwise,
146 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
148 const gchar *hostname,
149 const gchar *username,
150 const gchar *password,
154 * modest_account_mgr_remove_account:
155 * @self: a ModestAccountMgr instance
156 * @name: the name of the account to remove
157 * @err: a GError ptr, or NULL to ignore.
159 * remove an existing account. the account with @name should already exist
161 * Returns: TRUE if the creation succeeded, FALSE otherwise,
162 * @err gives details in case of error
164 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
166 gboolean server_account,
171 * modest_account_mgr_account_names:
172 * @self: a ModestAccountMgr instance
173 * @err: a GError ptr, or NULL to ignore.
175 * list all account names
177 * Returns: a newly allocated list of account names, or NULL in case of error or
178 * if there are no accounts. The caller must free the returned GSList
179 * @err gives details in case of error
181 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
185 * modest_account_mgr_server_account_names:
186 * @self: a ModestAccountMgr instance
187 * @account_name: get only server accounts for @account_name, or NULL for any
188 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
189 * @proto: get only server account with protocol @proto, or NULL for any
190 * @only_enabled: get only enabled server accounts if TRUE
192 * list all the server account names
194 * Returns: a newly allocated list of server account names, or NULL in case of
195 * error or if there are no server accounts. The caller must free the returned GSList
197 GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
198 const gchar* account_name,
199 ModestProtocolType type,
203 * modest_account_mgr_account_exists:
204 * @self: a ModestAccountMgr instance
205 * @name: the account name to check
206 * @server_account: if TRUE, this is a server account
207 * @err: a GError ptr, or NULL to ignore.
209 * check whether account @name exists
211 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
212 * @err gives details in case of error
214 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
216 gboolean server_account,
220 * modest_account_mgr_get_account_data:
221 * @self: a ModestAccountMgr instance
222 * @name: the name of the account
224 * get information about an account
226 * Returns: a ModestAccountData structure with information about the account.
227 * the data should not be changed, and be freed with modest_account_mgr_free_account_data
229 ModestAccountData *modest_account_mgr_get_account_data (ModestAccountMgr *self,
234 * modest_account_mgr_free_account_data:
235 * @self: a ModestAccountMgr instance
236 * @data: a ModestAccountData instance
238 * free the account data structure
240 void modest_account_mgr_free_account_data (ModestAccountMgr *self,
241 ModestAccountData *data);
244 * modest_account_mgr_account_set_enabled
245 * @self: a ModestAccountMgr instance
246 * @name: the account name
247 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
249 * enable/disabled an account
251 * Returns: TRUE if it worked, FALSE otherwise
253 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
258 * modest_account_mgr_account_get_enabled:
259 * @self: a ModestAccountMgr instance
260 * @name: the account name to check
262 * check whether a certain account is enabled
264 * Returns: TRUE if it is enabled, FALSE otherwise
266 gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name);
270 * modest_account_mgr_get_account_string:
271 * @self: self a ModestAccountMgr instance
272 * @name: the name of the account
273 * @key: the key of the value to retrieve
274 * @server_account: if TRUE, this is a server account
275 * @err: a GError ptr, or NULL to ignore.
277 * get a config string from an account
279 * Returns: a newly allocated string with the value for the key,
280 * or NULL in case of error. @err gives details in case of error
282 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
285 gboolean server_account,
290 * modest_account_mgr_get_account_int:
291 * @self: a ModestAccountMgr instance
292 * @name: the name of the account
293 * @key: the key of the value to retrieve
294 * @server_account: if TRUE, this is a server account
295 * @err: a GError ptr, or NULL to ignore.
297 * get a config int from an account
299 * Returns: an integer with the value for the key, or -1 in case of
300 * error (but of course -1 does not necessarily imply an error)
301 * @err gives details in case of error
303 gint modest_account_mgr_get_int (ModestAccountMgr *self,
306 gboolean server_account,
310 * modest_account_mgr_get_account_bool:
311 * @self: a ModestAccountMgr instance
312 * @name: the name of the account
313 * @key: the key of the value to retrieve
314 * @server_account: if TRUE, this is a server account
315 * @err: a GError ptr, or NULL to ignore.
317 * get a config boolean from an account
319 * Returns: an boolean with the value for the key, or FALSE in case of
320 * error (but of course FALSE does not necessarily imply an error)
321 * @err gives details in case of error
323 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
326 gboolean server_account,
330 * modest_account_mgr_set_account_string:
331 * @self: a ModestAccountMgr instance
332 * @name: the name of the account
333 * @key: the key of the value to set
334 * @val: the value to set
335 * @server_account: if TRUE, this is a server account
336 * @err: a GError ptr, or NULL to ignore.
338 * set a config string for an account
340 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
341 * @err gives details in case of error
343 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
345 const gchar *key, const gchar* val,
346 gboolean server_account,
350 * modest_account_mgr_set_account_int:
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
356 * @err: a GError ptr, or NULL to ignore.
358 * set a config int for an account
360 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
361 * @err gives details in case of error
363 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
365 const gchar *key, gint val,
366 gboolean server_account,
371 * modest_account_mgr_set_account_bool:
372 * @self: a ModestAccountMgr instance
373 * @name: the name of the account
374 * @key: the key of the value to set
375 * @val: the value to set
376 * @server_account: if TRUE, this is a server account
377 * @err: a GError ptr, or NULL to ignore.
379 * set a config bool for an account
381 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
382 * @err gives details in case of error
384 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
386 const gchar *key, gboolean val,
387 gboolean server_account,
391 #endif /* __MODEST_ACCOUNT_MGR_H__ */