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,
108 * modest_account_mgr_add_server_account:
109 * @self: a ModestAccountMgr instance
110 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
111 * @hostname: the hostname
112 * @username: the username
113 * @password: the password
114 * @proto: the protocol (imap, smtp, ...) used for this account
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);
129 * modest_account_mgr_remove_account:
130 * @self: a ModestAccountMgr instance
131 * @name: the name of the account to remove
132 * @server_account: TRUE if the account to remove is a server account
133 * @err: a #GError ptr, or NULL to ignore.
135 * remove an existing account. the account with @name should already exist
137 * Returns: TRUE if the creation succeeded, FALSE otherwise,
138 * @err gives details in case of error
140 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
142 gboolean server_account,
147 * modest_account_mgr_account_names:
148 * @self: a ModestAccountMgr instance
149 * @err: a GError ptr, or NULL to ignore.
151 * list all account names
153 * Returns: a newly allocated list of account names, or NULL in case of error or
154 * if there are no accounts. The caller must free the returned GSList
155 * @err gives details in case of error
157 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
161 * modest_account_mgr_server_account_names:
162 * @self: a ModestAccountMgr instance
163 * @account_name: get only server accounts for @account_name, or NULL for any
164 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
165 * @proto: get only server account with protocol @proto, or NULL for any
166 * @only_enabled: get only enabled server accounts if TRUE
168 * list all the server account names
170 * Returns: a newly allocated list of server account names, or NULL in case of
171 * error or if there are no server accounts. The caller must free the returned GSList
173 GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
174 const gchar* account_name,
175 ModestProtocolType type,
176 ModestProtocol proto);
179 * modest_account_mgr_account_exists:
180 * @self: a ModestAccountMgr instance
181 * @name: the account name to check
182 * @server_account: if TRUE, this is a server account
183 * @err: a GError ptr, or NULL to ignore.
185 * check whether account @name exists
187 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
188 * @err gives details in case of error
190 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
192 gboolean server_account,
197 * modest_account_mgr_get_account_string:
198 * @self: self a ModestAccountMgr instance
199 * @name: the name of the account
200 * @key: the key of the value to retrieve
201 * @server_account: if TRUE, this is a server account
202 * @err: a GError ptr, or NULL to ignore.
204 * get a config string from an account
206 * Returns: a newly allocated string with the value for the key,
207 * or NULL in case of error. @err gives details in case of error
209 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
212 gboolean server_account,
216 * modest_account_mgr_get_account_int:
217 * @self: a ModestAccountMgr instance
218 * @name: the name of the account
219 * @key: the key of the value to retrieve
220 * @server_account: if TRUE, this is a server account
221 * @err: a GError ptr, or NULL to ignore.
223 * get a config int from an account
225 * Returns: an integer with the value for the key, or -1 in case of
226 * error (but of course -1 does not necessarily imply an error)
227 * @err gives details in case of error
229 gint modest_account_mgr_get_int (ModestAccountMgr *self,
232 gboolean server_account,
236 * modest_account_mgr_get_account_bool:
237 * @self: a ModestAccountMgr instance
238 * @name: the name of the account
239 * @key: the key of the value to retrieve
240 * @server_account: if TRUE, this is a server account
241 * @err: a GError ptr, or NULL to ignore.
243 * get a config boolean from an account
245 * Returns: an boolean with the value for the key, or FALSE in case of
246 * error (but of course FALSE does not necessarily imply an error)
247 * @err gives details in case of error
249 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
252 gboolean server_account,
256 * modest_account_mgr_get_list:
257 * @self: a ModestAccountMgr instance
258 * @name: the name of the account
259 * @key: the key of the value to get
260 * @list_type: the type of the members of the list
261 * @server_account: if TRUE, this is a server account
262 * @err: a GError ptr, or NULL to ignore.
264 * get a config list of values of type @list_type of an account
266 * Returns: a newly allocated list of elements
267 * @err gives details in case of error
269 GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
272 ModestConfValueType list_type,
273 gboolean server_account,
277 * modest_account_mgr_set_account_string:
278 * @self: a ModestAccountMgr instance
279 * @name: the name of the account
280 * @key: the key of the value to set
281 * @val: the value to set
282 * @server_account: if TRUE, this is a server account
283 * @err: a GError ptr, or NULL to ignore.
285 * set a config string for an account.
287 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
288 * @err gives details in case of error
290 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
292 const gchar *key, const gchar* val,
293 gboolean server_account,
297 * modest_account_mgr_set_account_int:
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
303 * @err: a GError ptr, or NULL to ignore.
305 * set a config int for an account
307 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
308 * @err gives details in case of error
310 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
312 const gchar *key, gint val,
313 gboolean server_account,
318 * modest_account_mgr_set_account_bool:
319 * @self: a ModestAccountMgr instance
320 * @name: the name of the account
321 * @key: the key of the value to set
322 * @val: the value to set
323 * @server_account: if TRUE, this is a server account
324 * @err: a GError ptr, or NULL to ignore.
326 * set a config bool for an account
328 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
329 * @err gives details in case of error
331 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
333 const gchar *key, gboolean val,
334 gboolean server_account,
338 * modest_account_mgr_set_list:
339 * @self: a ModestAccountMgr instance
340 * @name: the name of the account
341 * @key: the key of the value to set
342 * @val: the list with the values to set
343 * @list_type: the type of the members of the list
344 * @server_account: if TRUE, this is a server account
345 * @err: a GError ptr, or NULL to ignore.
347 * set a config list of values of type @list_type of an account
348 * @err gives details in case of error
350 void modest_account_mgr_set_list (ModestAccountMgr *self,
354 ModestConfValueType list_type,
355 gboolean server_account,
359 * modest_account_mgr_unset:
360 * @self: a ModestAccountMgr instance
361 * @name: the name of the account
362 * @key: the key of the value to unset
363 * @server_account: if TRUE, this is a server account
364 * @err: a GError ptr, or NULL to ignore.
366 * unsets the config value of an account and all their children keys
368 * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
369 * @err gives details in case of error
371 gboolean modest_account_mgr_unset (ModestAccountMgr *self,
374 gboolean server_account,
379 #endif /* __MODEST_ACCOUNT_MGR_H__ */