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_HELPERS_H__
32 #define __MODEST_ACCOUNT_MGR_HELPERS_H__
34 #include <modest-account-mgr.h>
35 #include <modest-tny-account-store.h>
37 #include <tny-account.h>
38 #include <tny-store-account.h>
39 #include <tny-transport-account.h>
47 gchar *uri; /*< Only for mbox and maildir accounts. */
48 ModestTransportStoreProtocol proto; /*< The store or transport. Not ORed. */
51 gint port; /* Or 0, if the default should be used. */
52 ModestAuthProtocol secure_auth;
53 ModestConnectionProtocol security;
54 } ModestServerAccountData;
63 ModestServerAccountData *transport_account;
64 ModestServerAccountData *store_account;
70 * modest_account_mgr_get_account_data:
71 * @self: a ModestAccountMgr instance
72 * @name: the name of the account
74 * get information about an account
76 * Returns: a ModestAccountData structure with information about the account.
77 * the data should not be changed, and be freed with modest_account_mgr_free_account_data
78 * The function does a sanity check, an if it's not returning NULL,
79 * it is a valid account
81 ModestAccountData *modest_account_mgr_get_account_data (ModestAccountMgr *self,
85 * modest_account_mgr_get_default_account:
86 * @self: a ModestAccountMgr instance
88 * get the default account name, or NULL if none is found
90 * Returns: the default account name (as newly allocated string, which
91 * must be g_free'd), or NULL
93 gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
96 * modest_account_mgr_set_default_account:
97 * @self: a ModestAccountMgr instance
98 * @account: the name of an existing account
100 * set the default account name (which must be valid account)
102 * Returns: TRUE if succeeded, FALSE otherwise
104 gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
105 const gchar* account);
108 * modest_account_mgr_unset_default_account:
109 * @self: a ModestAccountMgr instance
110 * @account: the name of an account
112 * Unset the default account name, so that no account is the default.
114 * Returns: TRUE if succeeded, FALSE otherwise
116 gboolean modest_account_mgr_unset_default_account (ModestAccountMgr *self);
119 * modest_account_mgr_set_first_account_as_default:
120 * @self: a ModestAccountMgr instance
122 * Guarantees that at least one account, if there are any accounts, is the default,
123 * so that modest_account_mgr_get_default_account() will return non-NULL if there
126 * Returns: TRUE if succeeded, FALSE otherwise
129 modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self);
132 * modest_account_mgr_free_account_data:
133 * @self: a ModestAccountMgr instance
134 * @data: a ModestAccountData instance
136 * free the account data structure
138 void modest_account_mgr_free_account_data (ModestAccountMgr *self,
139 ModestAccountData *data);
142 * modest_account_mgr_set_enabled
143 * @self: a ModestAccountMgr instance
144 * @name: the account name
145 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
147 * enable/disabled an account
149 * Returns: TRUE if it worked, FALSE otherwise
151 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
155 * modest_account_mgr_get_enabled:
156 * @self: a ModestAccountMgr instance
157 * @name: the account name to check
159 * check whether a certain account is enabled
161 * Returns: TRUE if it is enabled, FALSE otherwise
163 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
166 * modest_account_mgr_get_display_name:
167 * @self: a ModestAccountMgr instance
168 * @name: the account name to check
170 * Return the human-readable account title for this account, or NULL.
172 gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self,
177 * modest_account_mgr_set_signature
178 * @self: a ModestAccountMgr instance
179 * @name: the account name to check
180 * @signature: the signature text
181 * @use_signature: Whether the signature should be used.
183 * Sets the signature text for the account.
185 * Returns: TRUE if it worked, FALSE otherwise
187 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
188 const gchar* signature, gboolean use_signature);
191 * modest_account_mgr_get_signature:
192 * @self: a ModestAccountMgr instance
193 * @name: the account name
194 * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
196 * Gets the signature text for this account.
198 * Returns: The signature text, which should be freed with g_free().
200 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
201 gboolean* use_signature);
204 * modest_account_mgr_set_connection_specific_smtp
205 * @self: a ModestAccountMgr instance
206 * @name: the account name
207 * @connection_name: A libconic IAP connection name
208 * @server_account_name: a server account name to use for this connection.
210 * Specify a server account to use with the specific connection for this account.
212 * Returns: TRUE if it worked, FALSE otherwise
214 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
215 const gchar* connection_name, const gchar* server_account_name);
218 * modest_account_mgr_remove_connection_specific_smtp
219 * @self: a ModestAccountMgr instance
220 * @name: the account name
221 * @connection_name: A libconic IAP connection name
223 * Disassacoiate a server account to use with the specific connection for this account.
225 * Returns: TRUE if it worked, FALSE otherwise
227 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
228 const gchar* connection_name);
231 * modest_account_mgr_get_has_connection_specific_smtp
232 * @self: a ModestAccountMgr instance
233 * @name: the account name
234 * @result: Whether this account uses any connection-specific smtp server accounts.
236 gboolean modest_account_mgr_get_has_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
239 * modest_account_mgr_get_connection_specific_smtp
240 * @self: a ModestAccountMgr instance
241 * @name: the account name
242 * @connection_name: A libconic IAP connection name
244 * Retrieve a server account to use with this specific connection for this account.
246 * Returns: a server account name to use for this connection, or NULL if none is specified.
248 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
249 const gchar* connection_name);
253 * modest_server_account_get_username:
254 * @self: a ModestAccountMgr instance
255 * @account_name: The name of a server account.
257 * Gets the username this server account.
259 * Returns: The username.
262 modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name);
265 * modest_server_account_set_username:
266 * @self: a ModestAccountMgr instance
267 * @account_name: The name of a server account.
268 * @username: The new username.
270 * Sets the username this server account.
273 modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name,
274 const gchar* username);
277 * modest_server_account_get_username_has_succeeded:
278 * @self: a ModestAccountMgr instance
279 * @account_name: The name of a server account.
281 * Whether a connection has ever been successfully made to this account with
282 * the current username. This can be used to avoid asking again for the username
283 * when asking a second time for a non-stored password.
285 * Returns: TRUE if the username is known to be correct.
288 modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name);
291 * modest_server_account_set_username_has_succeeded:
292 * @self: a ModestAccountMgr instance
293 * @account_name: The name of a server account.
294 * @succeeded: Whether the username has succeeded
296 * Sets whether the username is known to be correct.
299 modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
303 * modest_server_account_set_password:
304 * @self: a ModestAccountMgr instance
305 * @account_name: The name of a server account.
306 * @password: The new password.
308 * Sets the password this server account.
311 modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name,
312 const gchar* password);
316 * modest_server_account_modest_server_account_get_hostnameget_username:
317 * @self: a ModestAccountMgr instance
318 * @account_name: The name of a server account.
320 * Gets the hostname this server account.
322 * Returns: The hostname.
325 modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name);
329 * modest_server_account_get_secure_auth:
330 * @self: a ModestAccountMgr instance
331 * @account_name: The name of a server account.
333 * Gets the secure authentication method for this server account.
335 * Returns: The secure authentication enum value.
338 modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name);
341 * modest_server_account_data_get_secure_auth:
342 * @self: a ModestAccountMgr instance
343 * @account_name: The name of a server account.
344 * @secure_auth: The secure authentication enum value.
346 * Gets the secure authentication method for this server account.
349 modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name,
350 ModestAuthProtocol secure_auth);
353 * modest_server_account_data_get_security:
354 * @self: a ModestAccountMgr instance
355 * @account_name: The name of a server account.
357 * Gets the security method for this server account.
359 * Returns: The security enum value.
361 ModestConnectionProtocol
362 modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name);
365 * modest_server_account_set_security:
366 * @self: a ModestAccountMgr instance
367 * @secure_auth: The security enum value.
369 * Gets the security method for this server account.
372 modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name,
373 ModestConnectionProtocol security);
375 ModestServerAccountData*
376 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name);
379 modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
380 ModestServerAccountData* data);
383 * modest_account_mgr_get_from_string
384 * @self: a #ModestAccountMgr instance
385 * @name: the account name
387 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
389 * Returns: the newly allocated from-string, or NULL in case of error
391 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
395 * modest_account_mgr_get_unused_account_name
396 * @self: a #ModestAccountMgr instance
397 * @name: The initial account name
399 * get an unused account name, based on a starting string.
401 * Returns: the newly allocated name.
404 modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, const gchar* starting_name,
405 gboolean server_account);
408 * modest_account_mgr_get_unused_account_display name
409 * @self: a #ModestAccountMgr instance
410 * @name: The initial account display name
412 * get an unused account display name, based on a starting string.
414 * Returns: the newly allocated name.
417 modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, const gchar* starting_name);
421 #endif /* __MODEST_ACCOUNT_MGR_H__ */