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;
52 struct _ModestAccountMgr {
56 struct _ModestAccountMgrClass {
57 GObjectClass parent_class;
59 void (* account_inserted) (ModestAccountMgr *obj,
63 void (* account_removed) (ModestAccountMgr *obj,
67 void (* account_changed) (ModestAccountMgr *obj,
71 void (* account_busy_changed) (ModestAccountMgr *obj,
76 void (* default_account_changed)(ModestAccountMgr *obj,
79 void (* display_name_changed) (ModestAccountMgr *obj,
83 void (* account_updated) (ModestAccountMgr *obj,
89 * modest_account_mgr_get_type:
91 * get the GType for ModestAccountMgr
95 GType modest_account_mgr_get_type (void) G_GNUC_CONST;
99 * modest_account_mgr_new:
100 * @modest_conf: a ModestConf instance
102 * Returns: a new ModestAccountMgr, or NULL in case of error
104 ModestAccountMgr* modest_account_mgr_new (ModestConf *modest_conf);
109 * modest_account_mgr_add_account:
110 * @self: a ModestAccountMgr instance
111 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
112 * @store_name: the store account (ie. POP/IMAP)
113 * @transport_name: the transport account (ie. sendmail/SMTP)
114 * @enabled: Whether the account should be enabled initially.
116 * Create a new account. The account with @name should not already exist. The @name will
117 * be used as the initial display name of the new account.
119 * Returns: TRUE if the creation succeeded, FALSE otherwise,
121 gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
123 const gchar *display_name,
124 const gchar *user_fullname,
125 const gchar *user_email,
126 const gchar *retrieve_type,
127 const gchar* store_name,
128 const gchar* transport_name,
132 * modest_account_mgr_add_server_account:
133 * @self: a ModestAccountMgr instance
134 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
135 * @hostname: the hostname
136 * @portnumber: the portnumber, or 0 for default
137 * @username: the username
138 * @password: the password
139 * @proto: the protocol (imap, smtp, ...) used for this account
140 * @security: the security options, (SSL, TLS ...) used to access the server
141 * @auth: the authentication method (password, none ...) used to access the server
143 * add a server account to the configuration.
144 * the server account with @name should not already exist
146 * Returns: TRUE if succeeded, FALSE otherwise,
148 gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self,
150 const gchar *hostname,
151 const guint portnumber,
152 const gchar *username,
153 const gchar *password,
154 ModestTransportStoreProtocol proto,
155 ModestConnectionProtocol security,
156 ModestAuthProtocol auth);
160 * modest_account_mgr_add_server_account_uri:
161 * @self: a ModestAccountMgr instance
162 * @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
163 * @proto: the protocol (imap, smtp, ...) used for this account
166 * add a server account to the configuration, based on the account-URI
168 * Returns: TRUE if succeeded, FALSE otherwise,
170 gboolean modest_account_mgr_add_server_account_uri (ModestAccountMgr *self,
172 ModestTransportStoreProtocol proto,
176 * modest_account_mgr_remove_account:
177 * @self: a ModestAccountMgr instance
178 * @name: the name of the account to remove
179 * @err: a #GError ptr, or NULL to ignore.
181 * remove an existing account. the account with @name should already exist; note
182 * that when deleting an account, also the corresponding server accounts will
185 * Returns: TRUE if the creation succeeded, FALSE otherwise,
186 * @err gives details in case of error
188 gboolean modest_account_mgr_remove_account (ModestAccountMgr *self,
192 * modest_account_mgr_account_names:
193 * @self: a ModestAccountMgr instance
194 * @only_enabled: Whether only enabled accounts should be returned.
196 * list all account names
198 * Returns: a newly allocated list of account names, or NULL in case of error or
199 * if there are no accounts. The caller must free the returned GSList.
202 GSList* modest_account_mgr_account_names (ModestAccountMgr *self,
203 gboolean only_enabled);
206 * modest_account_mgr_free_account_names:
207 * @account_name: a gslist of account names
209 * list all account names
211 * free the list of account names
213 void modest_account_mgr_free_account_names (GSList *account_names);
217 * modest_account_mgr_account_exists:
218 * @self: a ModestAccountMgr instance
219 * @name: the account name to check
220 * @server_account: if TRUE, this is a server account
222 * check whether account @name exists. Note that this does not check the display name.
224 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
226 gboolean modest_account_mgr_account_exists (ModestAccountMgr *self,
228 gboolean server_account);
231 * modest_account_mgr_account_exists:
232 * @self: a ModestAccountMgr instance
233 * @name: the account name to check
235 * check whether a non-server account with the @display_name exists.
237 * Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
239 gboolean modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self,
240 const gchar *display_name);
243 * modest_account_mgr_unset:
244 * @self: a ModestAccountMgr instance
245 * @name: the name of the account
246 * @key: the key of the value to unset
247 * @server_account: if TRUE, this is a server account
248 * @err: a GError ptr, or NULL to ignore.
250 * unsets the config value of an account and all their children keys
252 * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
253 * @err gives details in case of error
255 gboolean modest_account_mgr_unset (ModestAccountMgr *self,
258 gboolean server_account);
261 * modest_account_mgr_has_accounts:
262 * @self: a ModestAccountMgr instance
263 * @enabled: TRUE to search for enabled accounts only
265 * Checks if any accounts exist
267 * Returns: TRUE if accounts exist, FALSE otherwise
270 gboolean modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled);
273 * modest_account_mgr_set_account_busy
274 * @self: a ModestAccountMgr instance
275 * @account_name: name of the account
276 * @busy: whether to set busy or not busy
278 * Changes the busy flag of an account
282 void modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name,
286 * modest_account_mgr_account_is_busy
287 * @self: a ModestAccountMgr instance
288 * @account_name: name of the account
290 * Returns: If the account is currently busy or not
293 gboolean modest_account_mgr_account_is_busy (ModestAccountMgr* self,
294 const gchar* account_name);
297 void modest_account_mgr_notify_account_update (ModestAccountMgr* self,
298 const gchar *server_account_name);
301 * modest_account_mgr_set_default_account:
302 * @self: a ModestAccountMgr instance
303 * @account: the name of an existing account
305 * set the default account name (which must be valid account)
307 * Returns: TRUE if succeeded, FALSE otherwise
309 gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
310 const gchar* account);
313 * modest_account_mgr_get_default_account:
314 * @self: a ModestAccountMgr instance
316 * get the default account name, or NULL if none is found
318 * Returns: the default account name (as newly allocated string, which
319 * must be g_free'd), or NULL
321 gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
324 * modest_account_mgr_get_display_name:
325 * @self: a ModestAccountMgr instance
326 * @name: the account name to check
328 * Return the human-readable account title for this account, or NULL.
330 gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self,
333 void modest_account_mgr_set_display_name (ModestAccountMgr *self,
334 const gchar *account_name,
335 const gchar *display_name);
340 #endif /* __MODEST_ACCOUNT_MGR_H__ */