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 LIMIT
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_set_first_account_as_default:
86 * @self: a ModestAccountMgr instance
88 * Guarantees that at least one account, if there are any accounts, is the default,
89 * so that modest_account_mgr_get_default_account() will return non-NULL if there
92 * Returns: TRUE if succeeded, FALSE otherwise
95 modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self);
97 /** Get the first one, alphabetically, by title. */
99 modest_account_mgr_get_first_account_name (ModestAccountMgr *self);
102 * modest_account_mgr_free_account_data:
103 * @self: a ModestAccountMgr instance
104 * @data: a ModestAccountData instance
106 * free the account data structure
108 void modest_account_mgr_free_account_data (ModestAccountMgr *self,
109 ModestAccountData *data);
112 * modest_account_mgr_set_enabled
113 * @self: a ModestAccountMgr instance
114 * @name: the account name
115 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
117 * enable/disabled an account
119 * Returns: TRUE if it worked, FALSE otherwise
121 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
125 * modest_account_mgr_get_enabled:
126 * @self: a ModestAccountMgr instance
127 * @name: the account name to check
129 * check whether a certain account is enabled
131 * Returns: TRUE if it is enabled, FALSE otherwise
133 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
136 * modest_account_mgr_set_signature
137 * @self: a ModestAccountMgr instance
138 * @name: the account name to check
139 * @signature: the signature text
140 * @use_signature: Whether the signature should be used.
142 * Sets the signature text for the account.
144 * Returns: TRUE if it worked, FALSE otherwise
146 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
147 const gchar* signature, gboolean use_signature);
150 * modest_account_mgr_get_signature:
151 * @self: a ModestAccountMgr instance
152 * @name: the account name
153 * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
155 * Gets the signature text for this account.
157 * Returns: The signature text, which should be freed with g_free().
159 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
160 gboolean* use_signature);
163 * modest_account_mgr_get_store_protocol:
164 * @self: a ModestAccountMgr instance
165 * @name: the account name
167 * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
169 * Returns: The protocol type.
171 ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
174 * modest_account_mgr_set_connection_specific_smtp
175 * @self: a ModestAccountMgr instance
176 * @connection_name: A libconic IAP connection name
177 * @server_account_name: a server account name to use for this connection.
179 * Specify a server account to use with the specific connection for this account.
181 * Returns: TRUE if it worked, FALSE otherwise
183 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
184 const gchar* connection_name, const gchar* server_account_name);
187 * modest_account_mgr_remove_connection_specific_smtp
188 * @self: a ModestAccountMgr instance
189 * @connection_name: A libconic IAP connection name
191 * Disassociate a server account to use with the specific connection for this account.
193 * Returns: TRUE if it worked, FALSE otherwise
195 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
196 const gchar* connection_name);
199 * modest_account_mgr_get_use_connection_specific_smtp
200 * @self: a ModestAccountMgr instance
201 * @account_name: the account name
202 * @result: Whether this account should use connection-specific smtp server accounts.
204 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
207 * modest_account_mgr_set_use_connection_specific_smtp
208 * @self: a ModestAccountMgr instance
209 * @account_name: the account name
210 * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
211 * @result: TRUE if it succeeded, FALSE otherwise
213 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self,
214 const gchar* account_name,
218 * modest_account_mgr_get_connection_specific_smtp
219 * @self: a ModestAccountMgr instance
220 * @connection_name: A libconic IAP connection name
222 * Retrieve a server account to use with this specific connection for this account.
224 * Returns: a server account name to use for this connection, or NULL if none is specified.
226 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
227 const gchar* connection_name);
231 * modest_account_mgr_get_server_account_username:
232 * @self: a ModestAccountMgr instance
233 * @account_name: The name of a server account.
235 * Gets the username this server account.
237 * Returns: The username.
239 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self,
240 const gchar* account_name);
243 * modest_account_mgr_set_server_account_username:
244 * @self: a ModestAccountMgr instance
245 * @account_name: The name of a server account.
246 * @username: The new username.
248 * Sets the username this server account.
250 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self,
251 const gchar* account_name,
252 const gchar* username);
255 * modest_account_mgr_get_server_account_username_has_succeeded:
256 * @self: a ModestAccountMgr instance
257 * @account_name: The name of a server account.
259 * Whether a connection has ever been successfully made to this account with
260 * the current username. This can be used to avoid asking again for the username
261 * when asking a second time for a non-stored password.
263 * Returns: TRUE if the username is known to be correct.
265 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self,
266 const gchar* account_name);
269 * modest_account_mgr_set_server_account_username_has_succeeded:
270 * @self: a ModestAccountMgr instance
271 * @account_name: The name of a server account.
272 * @succeeded: Whether the username has succeeded
274 * Sets whether the username is known to be correct.
276 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
277 const gchar* account_name,
281 * modest_account_mgr_set_server_account_password:
282 * @self: a ModestAccountMgr instance
283 * @account_name: The name of a server account.
284 * @password: The new password.
286 * Sets the password for this server account.
288 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self,
289 const gchar* account_name,
290 const gchar* password);
293 * modest_account_mgr_get_server_account_password:
294 * @self: a ModestAccountMgr instance
295 * @account_name: The name of a server account.
297 * Gets the password for this server account from the account settings.
299 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self,
300 const gchar* account_name);
303 * modest_account_mgr_get_server_account_has_password:
304 * @self: a ModestAccountMgr instance
305 * @account_name: The name of a server account.
307 * Gets whether a password has been set for this server account in the account settings.
309 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self,
310 const gchar* account_name);
313 * modest_server_account_modest_account_mgr_get_server_account_hostname:
314 * @self: a ModestAccountMgr instance
315 * @account_name: The name of a server account.
317 * Gets the hostname this server account.
319 * Returns: The hostname.
321 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
322 const gchar* account_name);
325 * modest_server_account_modest_account_mgr_set_server_account_hostname:
326 * @self: a ModestAccountMgr instance
327 * @account_name: The name of a server account.
328 * @hostname: The new hostname
330 * Sets the hostname this server account.
332 void modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
333 const gchar* account_name,
334 const gchar *hostname);
337 * modest_account_mgr_get_server_account_secure_auth:
338 * @self: a ModestAccountMgr instance
339 * @account_name: The name of a server account.
341 * Gets the secure authentication method for this server account.
343 * Returns: The secure authentication enum value.
345 ModestAuthProtocol modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
346 const gchar* account_name);
349 * modest_server_account_data_get_secure_auth:
350 * @self: a ModestAccountMgr instance
351 * @account_name: The name of a server account.
352 * @secure_auth: The secure authentication enum value.
354 * Gets the secure authentication method for this server account.
356 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
357 const gchar* account_name,
358 ModestAuthProtocol secure_auth);
361 * modest_server_account_data_get_security:
362 * @self: a ModestAccountMgr instance
363 * @account_name: The name of a server account.
365 * Gets the security method for this server account.
367 * Returns: The security enum value.
369 ModestConnectionProtocol modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
370 const gchar* account_name);
373 * modest_account_mgr_set_server_account_security:
374 * @self: a ModestAccountMgr instance
375 * @secure_auth: The security enum value.
377 * Gets the security method for this server account.
379 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
380 const gchar* account_name,
381 ModestConnectionProtocol security);
383 ModestServerAccountData* modest_account_mgr_get_server_account_data (ModestAccountMgr *self,
386 void modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
387 ModestServerAccountData* data);
390 * modest_account_mgr_get_from_string
391 * @self: a #ModestAccountMgr instance
392 * @name: the account name
394 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
396 * Returns: the newly allocated from-string, or NULL in case of error
398 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
402 * modest_account_mgr_get_unused_account_name
403 * @self: a #ModestAccountMgr instance
404 * @name: The initial account name
406 * get an unused account name, based on a starting string.
408 * Returns: the newly allocated name.
410 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self,
411 const gchar* starting_name,
412 gboolean server_account);
415 * modest_account_mgr_get_unused_account_display name
416 * @self: a #ModestAccountMgr instance
417 * @name: The initial account display name
419 * get an unused account display name, based on a starting string.
421 * Returns: the newly allocated name.
423 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self,
424 const gchar* starting_name);
427 * modest_account_mgr_set_server_account_security:
428 * @self: a ModestAccountMgr instance
429 * @secure_auth: The security enum value.
431 * Gets the security method for this server account.
433 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
434 const gchar* account_name,
435 gboolean leave_on_server);
437 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
438 const gchar* account_name);
440 gint modest_account_mgr_get_last_updated (ModestAccountMgr *self,
441 const gchar* account_name);
443 void modest_account_mgr_set_last_updated (ModestAccountMgr *self,
444 const gchar* account_name,
447 gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
448 const gchar* account_name);
450 void modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
451 const gchar* account_name,
452 gint limit_retrieve);
454 gint modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
455 const gchar* account_name);
457 void modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
458 const gchar *account_name,
461 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
462 const gchar *account_name,
463 TnyAccountType account_type);
465 gchar* modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
466 const gchar *account_name);
468 void modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
469 const gchar *account_name,
470 const gchar *retrieve_type);
472 void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
473 const gchar *account_name,
474 const gchar *fullname);
476 void modest_account_mgr_set_user_email (ModestAccountMgr *self,
477 const gchar *account_name,
482 #endif /* __MODEST_ACCOUNT_MGR_H__ */