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 /* modest-account-mgr.h */
33 #ifndef __MODEST_ACCOUNT_MGR_H__
34 #define __MODEST_ACCOUNT_MGR_H__
36 #include <glib-object.h>
37 #include "modest-conf.h"
38 #include "modest-account-keys.h"
39 #include "modest-proto.h"
43 /* convenience macros */
44 #define MODEST_TYPE_ACCOUNT_MGR (modest_account_mgr_get_type())
45 #define MODEST_ACCOUNT_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgr))
46 #define MODEST_ACCOUNT_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_MGR,GObject))
47 #define MODEST_IS_ACCOUNT_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_MGR))
48 #define MODEST_IS_ACCOUNT_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_MGR))
49 #define MODEST_ACCOUNT_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_MGR,ModestAccountMgrClass))
51 typedef struct _ModestAccountMgr ModestAccountMgr;
52 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
56 struct _ModestAccountMgr {
58 /* insert public members, if any */
61 struct _ModestAccountMgrClass {
62 GObjectClass parent_class;
63 /* insert signal callback declarations, eg. */
64 /* void (* my_event) (ModestAccountMgr* obj); */
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 GObject* modest_account_mgr_new (ModestConf *modest_conf);
89 * modest_account_mgr_add_account:
90 * @self: a ModestAccountMgr instance
91 * @name: the name of the account to create
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,
107 * modest_account_mgr_remove_account:
108 * @self: a ModestAccountMgr instance
109 * @name: the name of the account to remove
110 * @err: a GError ptr, or NULL to ignore.
112 * remove an existing account. the account with @name should already exist
114 * Returns: TRUE if the creation succeeded, FALSE otherwise,
115 * @err gives details in case of error
117 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
123 * modest_account_mgr_add_server_account:
124 * @self: a ModestAccountMgr instance
125 * @name: name (id) of the account
126 * @hostname: the hostname
127 * @username: the username
128 * @password: the password
129 * @proto: the protocol (imap, smtp, ...) used for this account
131 * add a server account to the configuration.
132 * the server account with @name should not already exist
134 * Returns: TRUE if succeeded, FALSE otherwise,
136 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
138 const gchar *hostname,
139 const gchar *username,
140 const gchar *password,
144 * modest_account_mgr_remove_server_account:
145 * @self: a ModestAccountMgr instance
146 * @name: the name for the server account to remove
147 * @err: a GError ptr, or NULL to ignore.
149 * remove a server account from the configuration
150 * the server account with @name should exist
152 * Returns: TRUE if the removal succeeded, FALSE otherwise,
153 * @err gives details in case of error
155 gboolean modest_account_mgr_remove_server_account (ModestAccountMgr *self,
160 * modest_account_mgr_account_names:
161 * @self: a ModestAccountMgr instance
162 * @err: a GError ptr, or NULL to ignore.
164 * list all account names
166 * Returns: a newly allocated list of account names, or NULL in case of error or
167 * if there are no accounts. The caller must free the returned GSList
168 * @err gives details in case of error
170 GSList* modest_account_mgr_account_names (ModestAccountMgr *self, GError **err);
174 * modest_account_mgr_server_account_names:
175 * @self: a ModestAccountMgr instance
176 * @account_name: get only server accounts for @account_name, or NULL for any
177 * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
178 * @proto: get only server account with protocol @proto, or NULL for any
179 * @only_enabled: get only enabled server accounts if TRUE
181 * list all the server account names
183 * Returns: a newly allocated list of server account names, or NULL in case of
184 * error or if there are no server accounts. The caller must free the returned GSList
186 GSList* modest_account_mgr_server_account_names (ModestAccountMgr *self,
187 const gchar* account_name,
188 ModestProtoType type,
190 gboolean only_enabled);
193 * modest_account_mgr_account_exists:
194 * @self: a ModestAccountMgr instance
195 * @name: the account name to check
196 * @err: a GError ptr, or NULL to ignore.
198 * check whether account @name exists
200 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
201 * @err gives details in case of error
203 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
207 gboolean modest_account_mgr_server_account_exists (ModestAccountMgr *self,
213 /* account specific functions */
216 * modest_account_mgr_get_account_string:
217 * @self: self a ModestAccountMgr instance
218 * @name: the name of the account
219 * @key: the key of the value to retrieve
220 * @err: a GError ptr, or NULL to ignore.
222 * get a config string from an account
224 * Returns: a newly allocated string with the value for the key,
225 * or NULL in case of error. @err gives details in case of error
227 gchar* modest_account_mgr_get_account_string (ModestAccountMgr *self,
229 const gchar *key, GError **err);
231 gchar* modest_account_mgr_get_server_account_string (ModestAccountMgr *self,
233 const gchar *key, GError **err);
236 * modest_account_mgr_get_account_int:
237 * @self: a ModestAccountMgr instance
238 * @name: the name of the account
239 * @key: the key of the value to retrieve
240 * @err: a GError ptr, or NULL to ignore.
242 * get a config int from an account
244 * Returns: an integer with the value for the key, or -1 in case of
245 * error (but of course -1 does not necessarily imply an error)
246 * @err gives details in case of error
248 gint modest_account_mgr_get_account_int (ModestAccountMgr *self,
250 const gchar *key, GError **err);
252 gint modest_account_mgr_get_server_account_int (ModestAccountMgr *self,
254 const gchar *key, GError **err);
258 * modest_account_mgr_get_account_bool:
259 * @self: a ModestAccountMgr instance
260 * @name: the name of the account
261 * @key: the key of the value to retrieve
262 * @err: a GError ptr, or NULL to ignore.
264 * get a config boolean from an account
266 * Returns: an boolean with the value for the key, or FALSE in case of
267 * error (but of course FALSE does not necessarily imply an error)
268 * @err gives details in case of error
270 gboolean modest_account_mgr_get_account_bool (ModestAccountMgr *self,
272 const gchar *key, GError **err);
274 gboolean modest_account_mgr_get_server_account_bool (ModestAccountMgr *self,
276 const gchar *key, GError **err);
279 * modest_account_mgr_set_account_string:
280 * @self: a ModestAccountMgr instance
281 * @name: the name of the account
282 * @key: the key of the value to set
283 * @val: the value to set
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_account_string (ModestAccountMgr *self,
293 const gchar *key, const gchar* val,
296 gboolean modest_account_mgr_set_server_account_string (ModestAccountMgr *self,
298 const gchar *key, const gchar* val,
303 * modest_account_mgr_set_account_int:
304 * @self: a ModestAccountMgr instance
305 * @name: the name of the account
306 * @key: the key of the value to set
307 * @val: the value to set
308 * @err: a GError ptr, or NULL to ignore.
310 * set a config int for an account
312 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
313 * @err gives details in case of error
315 gboolean modest_account_mgr_set_account_int (ModestAccountMgr *self,
317 const gchar *key, gint val,
320 gboolean modest_account_mgr_set_server_account_int (ModestAccountMgr *self,
322 const gchar *key, gint val,
327 * modest_account_mgr_set_account_bool:
328 * @self: a ModestAccountMgr instance
329 * @name: the name of the account
330 * @key: the key of the value to set
331 * @val: the value to set
332 * @err: a GError ptr, or NULL to ignore.
334 * set a config bool for an account
336 * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
337 * @err gives details in case of error
339 gboolean modest_account_mgr_set_account_bool (ModestAccountMgr *self,
341 const gchar *key, gboolean val,
344 gboolean modest_account_mgr_set_server_account_bool (ModestAccountMgr *self,
346 const gchar *key, gboolean val,
352 #endif /* __MODEST_ACCOUNT_MGR_H__ */