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,
69 * modest_account_mgr_get_type:
71 * get the GType for ModestAccountMgr
75 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
79 * modest_account_mgr_new:
80 * @modest_conf: a ModestConf instance
82 * Returns: a new ModestAccountMgr, or NULL in case of error
84 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
89 * modest_account_mgr_add_account:
90 * @self: a ModestAccountMgr instance
91 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
92 * @store_name: the store account (ie. POP/IMAP)
93 * @transport_name: the transport account (ie. sendmail/SMTP)
94 * @err: a GError ptr, or NULL to ignore.
96 * create a new account. the account with @name should not already exist
98 * Returns: TRUE if the creation succeeded, FALSE otherwise,
99 * @err gives details in case of error
101 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
103 const gchar* store_name,
104 const gchar* transport_name,
109 * modest_account_mgr_add_server_account:
110 * @self: a ModestAccountMgr instance
111 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
112 * @hostname: the hostname
113 * @username: the username
114 * @password: the password
115 * @proto: the protocol (imap, smtp, ...) used for this account
117 * add a server account to the configuration.
118 * the server account with @name should not already exist
120 * Returns: TRUE if succeeded, FALSE otherwise,
122 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
124 const gchar *hostname,
125 const gchar *username,
126 const gchar *password,
127 ModestProtocol proto);
130 * modest_account_mgr_remove_account:
131 * @self: a ModestAccountMgr instance
132 * @name: the name of the account to remove
133 * @server_account: TRUE if the account to remove is a server account
134 * @err: a #GError ptr, or NULL to ignore.
136 * remove an existing account. the account with @name should already exist
138 * Returns: TRUE if the creation succeeded, FALSE otherwise,
139 * @err gives details in case of error
141 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
143 gboolean server_account,
148 * modest_account_mgr_account_names:
149 * @self: a ModestAccountMgr instance
150 * @err: a GError ptr, or NULL to ignore.
152 * list all account names
154 * Returns: a newly allocated list of account names, or NULL in case of error or
155 * if there are no accounts. The caller must free the returned GSList
156 * @err gives details in case of error
158 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
162 * modest_account_mgr_server_account_names:
163 * @self: a ModestAccountMgr instance
164 * @account_name: get only server accounts for @account_name, or NULL for any
165 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
166 * @proto: get only server account with protocol @proto, or NULL for any
167 * @only_enabled: get only enabled server accounts if TRUE
169 * list all the server account names
171 * Returns: a newly allocated list of server account names, or NULL in case of
172 * error or if there are no server accounts. The caller must free the returned GSList
174 GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
175 const gchar* account_name,
176 ModestProtocolType type,
177 ModestProtocol proto);
180 * modest_account_mgr_account_exists:
181 * @self: a ModestAccountMgr instance
182 * @name: the account name to check
183 * @server_account: if TRUE, this is a server account
184 * @err: a GError ptr, or NULL to ignore.
186 * check whether account @name exists
188 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
189 * @err gives details in case of error
191 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
193 gboolean server_account,
198 * modest_account_mgr_get_account_string:
199 * @self: self a ModestAccountMgr instance
200 * @name: the name of the account
201 * @key: the key of the value to retrieve
202 * @server_account: if TRUE, this is a server account
203 * @err: a GError ptr, or NULL to ignore.
205 * get a config string from an account
207 * Returns: a newly allocated string with the value for the key,
208 * or NULL in case of error. @err gives details in case of error
210 gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
213 gboolean server_account,
217 * modest_account_mgr_get_account_int:
218 * @self: a ModestAccountMgr instance
219 * @name: the name of the account
220 * @key: the key of the value to retrieve
221 * @server_account: if TRUE, this is a server account
222 * @err: a GError ptr, or NULL to ignore.
224 * get a config int from an account
226 * Returns: an integer with the value for the key, or -1 in case of
227 * error (but of course -1 does not necessarily imply an error)
228 * @err gives details in case of error
230 gint modest_account_mgr_get_int (ModestAccountMgr *self,
233 gboolean server_account,
237 * modest_account_mgr_get_account_bool:
238 * @self: a ModestAccountMgr instance
239 * @name: the name of the account
240 * @key: the key of the value to retrieve
241 * @server_account: if TRUE, this is a server account
242 * @err: a GError ptr, or NULL to ignore.
244 * get a config boolean from an account
246 * Returns: an boolean with the value for the key, or FALSE in case of
247 * error (but of course FALSE does not necessarily imply an error)
248 * @err gives details in case of error
250 gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
253 gboolean server_account,
257 * modest_account_mgr_get_list:
258 * @self: a ModestAccountMgr instance
259 * @name: the name of the account
260 * @key: the key of the value to get
261 * @list_type: the type of the members of the list
262 * @server_account: if TRUE, this is a server account
263 * @err: a GError ptr, or NULL to ignore.
265 * get a config list of values of type @list_type of an account
267 * Returns: a newly allocated list of elements
268 * @err gives details in case of error
270 GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
273 ModestConfValueType list_type,
274 gboolean server_account,
278 * modest_account_mgr_set_account_string:
279 * @self: a ModestAccountMgr instance
280 * @name: the name of the account
281 * @key: the key of the value to set
282 * @val: the value to set
283 * @server_account: if TRUE, this is a server account
284 * @err: a GError ptr, or NULL to ignore.
286 * set a config string for an account.
288 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
289 * @err gives details in case of error
291 gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
293 const gchar *key, const gchar* val,
294 gboolean server_account,
298 * modest_account_mgr_set_account_int:
299 * @self: a ModestAccountMgr instance
300 * @name: the name of the account
301 * @key: the key of the value to set
302 * @val: the value to set
303 * @server_account: if TRUE, this is a server account
304 * @err: a GError ptr, or NULL to ignore.
306 * set a config int for an account
308 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
309 * @err gives details in case of error
311 gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
313 const gchar *key, gint val,
314 gboolean server_account,
319 * modest_account_mgr_set_account_bool:
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
325 * @err: a GError ptr, or NULL to ignore.
327 * set a config bool for an account
329 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
330 * @err gives details in case of error
332 gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
334 const gchar *key, gboolean val,
335 gboolean server_account,
339 * modest_account_mgr_set_list:
340 * @self: a ModestAccountMgr instance
341 * @name: the name of the account
342 * @key: the key of the value to set
343 * @val: the list with the values to set
344 * @list_type: the type of the members of the list
345 * @server_account: if TRUE, this is a server account
346 * @err: a GError ptr, or NULL to ignore.
348 * set a config list of values of type @list_type of an account
349 * @err gives details in case of error
351 void modest_account_mgr_set_list (ModestAccountMgr *self,
355 ModestConfValueType list_type,
356 gboolean server_account,
360 * modest_account_mgr_unset:
361 * @self: a ModestAccountMgr instance
362 * @name: the name of the account
363 * @key: the key of the value to unset
364 * @server_account: if TRUE, this is a server account
365 * @err: a GError ptr, or NULL to ignore.
367 * unsets the config value of an account and all their children keys
369 * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
370 * @err gives details in case of error
372 gboolean modest_account_mgr_unset (ModestAccountMgr *self,
375 gboolean server_account,
380 #endif /* __MODEST_ACCOUNT_MGR_H__ */