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>
40 #include <modest-server-account-settings.h>
45 * modest_account_mgr_load_account_settings:
46 * @self: a ModestAccountMgr instance
47 * @name: the name of the account
49 * get information about an account
51 * Returns: a ModestAccountSettings instance with information about the account,
52 * or NULL if the account is not valid or does not exist.
54 ModestAccountSettings *modest_account_mgr_load_account_settings (ModestAccountMgr *self,
57 void modest_account_mgr_save_account_settings (ModestAccountMgr *self,
58 ModestAccountSettings *settings);
61 * modest_account_mgr_set_first_account_as_default:
62 * @self: a ModestAccountMgr instance
64 * Guarantees that at least one account, if there are any accounts, is the default,
65 * so that modest_account_mgr_get_default_account() will return non-NULL if there
68 * Returns: TRUE if succeeded, FALSE otherwise
71 modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self);
73 /** Get the first one, alphabetically, by title. */
75 modest_account_mgr_get_first_account_name (ModestAccountMgr *self);
79 * modest_account_mgr_set_enabled
80 * @self: a ModestAccountMgr instance
81 * @name: the account name
82 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
84 * enable/disabled an account
86 * Returns: TRUE if it worked, FALSE otherwise
88 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
92 * modest_account_mgr_get_enabled:
93 * @self: a ModestAccountMgr instance
94 * @name: the account name to check
96 * check whether a certain account is enabled
98 * Returns: TRUE if it is enabled, FALSE otherwise
100 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
103 * modest_account_mgr_set_signature
104 * @self: a ModestAccountMgr instance
105 * @name: the account name to check
106 * @signature: the signature text
107 * @use_signature: Whether the signature should be used.
109 * Sets the signature text for the account.
111 * Returns: TRUE if it worked, FALSE otherwise
113 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
114 const gchar* signature, gboolean use_signature);
117 * modest_account_mgr_get_signature:
118 * @self: a ModestAccountMgr instance
119 * @name: the account name
120 * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
122 * Gets the signature text for this account.
124 * Returns: The signature text, which should be freed with g_free().
126 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
127 gboolean* use_signature);
130 * modest_account_mgr_get_store_protocol:
131 * @self: a ModestAccountMgr instance
132 * @name: the account name
134 * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
136 * Returns: The protocol type.
138 ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
141 * modest_account_mgr_set_connection_specific_smtp
142 * @self: a ModestAccountMgr instance
143 * @connection_id: A libconic IAP connection name
144 * @server_account_name: a server account name to use for this connection.
146 * Specify a server account to use with the specific connection for this account.
148 * Returns: TRUE if it worked, FALSE otherwise
150 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
151 const gchar* connection_id, const gchar* server_account_name);
154 * modest_account_mgr_remove_connection_specific_smtp
155 * @self: a ModestAccountMgr instance
156 * @connection_id: A libconic IAP connection name
158 * Disassociate a server account to use with the specific connection for this account.
160 * Returns: TRUE if it worked, FALSE otherwise
162 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
163 const gchar* connection_id);
166 * modest_account_mgr_get_use_connection_specific_smtp
167 * @self: a ModestAccountMgr instance
168 * @account_name: the account name
169 * @result: Whether this account should use connection-specific smtp server accounts.
171 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
174 * modest_account_mgr_set_use_connection_specific_smtp
175 * @self: a ModestAccountMgr instance
176 * @account_name: the account name
177 * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
178 * @result: TRUE if it succeeded, FALSE otherwise
180 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self,
181 const gchar* account_name,
185 * modest_account_mgr_get_connection_specific_smtp
186 * @self: a ModestAccountMgr instance
187 * @connection_id: A libconic IAP connection id
189 * Retrieve a server account to use with this specific connection for this account.
191 * Returns: a server account name to use for this connection, or NULL if none is specified.
193 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
194 const gchar* connection_id);
198 * modest_account_mgr_get_server_account_username:
199 * @self: a ModestAccountMgr instance
200 * @account_name: The name of a server account.
202 * Gets the username this server account.
204 * Returns: The username.
206 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self,
207 const gchar* account_name);
210 * modest_account_mgr_set_server_account_username:
211 * @self: a ModestAccountMgr instance
212 * @account_name: The name of a server account.
213 * @username: The new username.
215 * Sets the username this server account.
217 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self,
218 const gchar* account_name,
219 const gchar* username);
222 * modest_account_mgr_get_server_account_username_has_succeeded:
223 * @self: a ModestAccountMgr instance
224 * @account_name: The name of a server account.
226 * Whether a connection has ever been successfully made to this account with
227 * the current username. This can be used to avoid asking again for the username
228 * when asking a second time for a non-stored password.
230 * Returns: TRUE if the username is known to be correct.
232 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self,
233 const gchar* account_name);
236 * modest_account_mgr_set_server_account_username_has_succeeded:
237 * @self: a ModestAccountMgr instance
238 * @account_name: The name of a server account.
239 * @succeeded: Whether the username has succeeded
241 * Sets whether the username is known to be correct.
243 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
244 const gchar* account_name,
248 * modest_account_mgr_set_server_account_password:
249 * @self: a ModestAccountMgr instance
250 * @account_name: The name of a server account.
251 * @password: The new password.
253 * Sets the password for this server account.
255 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self,
256 const gchar* account_name,
257 const gchar* password);
260 * modest_account_mgr_get_server_account_password:
261 * @self: a ModestAccountMgr instance
262 * @account_name: The name of a server account.
264 * Gets the password for this server account from the account settings.
266 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self,
267 const gchar* account_name);
270 * modest_account_mgr_get_server_account_has_password:
271 * @self: a ModestAccountMgr instance
272 * @account_name: The name of a server account.
274 * Gets whether a password has been set for this server account in the account settings.
276 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self,
277 const gchar* account_name);
280 * modest_server_account_modest_account_mgr_get_server_account_hostname:
281 * @self: a ModestAccountMgr instance
282 * @account_name: The name of a server account.
284 * Gets the hostname this server account.
286 * Returns: The hostname.
288 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
289 const gchar* account_name);
292 * modest_server_account_modest_account_mgr_set_server_account_hostname:
293 * @self: a ModestAccountMgr instance
294 * @account_name: The name of a server account.
295 * @hostname: The new hostname
297 * Sets the hostname this server account.
299 void modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
300 const gchar* account_name,
301 const gchar *hostname);
304 * modest_account_mgr_get_server_account_secure_auth:
305 * @self: a ModestAccountMgr instance
306 * @account_name: The name of a server account.
308 * Gets the secure authentication method for this server account.
310 * Returns: The secure authentication enum value.
312 ModestProtocolType modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
313 const gchar* account_name);
316 * modest_server_account_data_get_secure_auth:
317 * @self: a ModestAccountMgr instance
318 * @account_name: The name of a server account.
319 * @secure_auth: The secure authentication enum value.
321 * Gets the secure authentication method for this server account.
323 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
324 const gchar* account_name,
325 ModestProtocolType secure_auth);
328 * modest_server_account_data_get_security:
329 * @self: a ModestAccountMgr instance
330 * @account_name: The name of a server account.
332 * Gets the security method for this server account.
334 * Returns: The security connection protocol.
336 ModestProtocolType modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
337 const gchar* account_name);
340 * modest_account_mgr_set_server_account_security:
341 * @self: a ModestAccountMgr instance
342 * @secure_auth: The security enum value.
344 * Gets the security method for this server account.
346 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
347 const gchar* account_name,
348 ModestProtocolType security);
350 gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
351 ModestServerAccountSettings *settings);
353 ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
354 const gchar *account_name,
355 gboolean is_transport_not_store);
358 * modest_account_mgr_get_from_string
359 * @self: a #ModestAccountMgr instance
360 * @name: the account name
362 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
364 * Returns: the newly allocated from-string, or NULL in case of error
366 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
370 * modest_account_mgr_get_unused_account_name
371 * @self: a #ModestAccountMgr instance
372 * @name: The initial account name
374 * get an unused account name, based on a starting string.
376 * Returns: the newly allocated name.
378 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self,
379 const gchar* starting_name,
380 gboolean server_account);
383 * modest_account_mgr_get_unused_account_display name
384 * @self: a #ModestAccountMgr instance
385 * @name: The initial account display name
387 * get an unused account display name, based on a starting string.
389 * Returns: the newly allocated name.
391 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self,
392 const gchar* starting_name);
395 * modest_account_mgr_set_server_account_security:
396 * @self: a ModestAccountMgr instance
397 * @secure_auth: The security enum value.
399 * Gets the security method for this server account.
401 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
402 const gchar* account_name,
403 gboolean leave_on_server);
405 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
406 const gchar* account_name);
408 gint modest_account_mgr_get_last_updated (ModestAccountMgr *self,
409 const gchar* account_name);
411 void modest_account_mgr_set_last_updated (ModestAccountMgr *self,
412 const gchar* account_name,
415 gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
416 const gchar* account_name);
418 void modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
419 const gchar* account_name,
420 gint limit_retrieve);
422 gint modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
423 const gchar* account_name);
425 void modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
426 const gchar *account_name,
429 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
430 const gchar *account_name,
431 TnyAccountType account_type);
433 ModestAccountRetrieveType modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
434 const gchar *account_name);
436 void modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
437 const gchar *account_name,
438 ModestAccountRetrieveType retrieve_type);
440 void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
441 const gchar *account_name,
442 const gchar *fullname);
444 void modest_account_mgr_set_user_email (ModestAccountMgr *self,
445 const gchar *account_name,
450 #endif /* __MODEST_ACCOUNT_MGR_H__ */