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);
129 gchar *modest_account_mgr_get_signature_from_recipient (ModestAccountMgr *self, const gchar *recipient,
130 gboolean *use_signature);
131 gboolean modest_account_mgr_account_is_multimailbox (ModestAccountMgr *mgr,
132 const gchar *account_name,
133 ModestProtocol **mmb_protocol);
136 * modest_account_mgr_get_store_protocol:
137 * @self: a ModestAccountMgr instance
138 * @name: the account name
140 * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
142 * Returns: The protocol type.
144 ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
147 * modest_account_mgr_set_connection_specific_smtp
148 * @self: a ModestAccountMgr instance
149 * @connection_id: A libconic IAP connection name
150 * @server_account_name: a server account name to use for this connection.
152 * Specify a server account to use with the specific connection for this account.
154 * Returns: TRUE if it worked, FALSE otherwise
156 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
157 const gchar* connection_id, const gchar* server_account_name);
160 * modest_account_mgr_remove_connection_specific_smtp
161 * @self: a ModestAccountMgr instance
162 * @connection_id: A libconic IAP connection name
164 * Disassociate a server account to use with the specific connection for this account.
166 * Returns: TRUE if it worked, FALSE otherwise
168 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
169 const gchar* connection_id);
172 * modest_account_mgr_get_use_connection_specific_smtp
173 * @self: a ModestAccountMgr instance
174 * @account_name: the account name
175 * @result: Whether this account should use connection-specific smtp server accounts.
177 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
180 * modest_account_mgr_set_use_connection_specific_smtp
181 * @self: a ModestAccountMgr instance
182 * @account_name: the account name
183 * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
184 * @result: TRUE if it succeeded, FALSE otherwise
186 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self,
187 const gchar* account_name,
191 * modest_account_mgr_get_connection_specific_smtp
192 * @self: a ModestAccountMgr instance
193 * @connection_id: A libconic IAP connection id
195 * Retrieve a server account to use with this specific connection for this account.
197 * Returns: a server account name to use for this connection, or NULL if none is specified.
199 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
200 const gchar* connection_id);
204 * modest_account_mgr_get_server_account_username:
205 * @self: a ModestAccountMgr instance
206 * @account_name: The name of a server account.
208 * Gets the username this server account.
210 * Returns: The username.
212 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self,
213 const gchar* account_name);
216 * modest_account_mgr_set_server_account_username:
217 * @self: a ModestAccountMgr instance
218 * @account_name: The name of a server account.
219 * @username: The new username.
221 * Sets the username this server account.
223 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self,
224 const gchar* account_name,
225 const gchar* username);
228 * modest_account_mgr_get_server_account_username_has_succeeded:
229 * @self: a ModestAccountMgr instance
230 * @account_name: The name of a server account.
232 * Whether a connection has ever been successfully made to this account with
233 * the current username. This can be used to avoid asking again for the username
234 * when asking a second time for a non-stored password.
236 * Returns: TRUE if the username is known to be correct.
238 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self,
239 const gchar* account_name);
242 * modest_account_mgr_set_server_account_username_has_succeeded:
243 * @self: a ModestAccountMgr instance
244 * @account_name: The name of a server account.
245 * @succeeded: Whether the username has succeeded
247 * Sets whether the username is known to be correct.
249 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
250 const gchar* account_name,
254 * modest_account_mgr_set_server_account_password:
255 * @self: a ModestAccountMgr instance
256 * @account_name: The name of a server account.
257 * @password: The new password.
259 * Sets the password for this server account.
261 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self,
262 const gchar* account_name,
263 const gchar* password);
266 * modest_account_mgr_get_server_account_password:
267 * @self: a ModestAccountMgr instance
268 * @account_name: The name of a server account.
270 * Gets the password for this server account from the account settings.
272 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self,
273 const gchar* account_name);
276 * modest_account_mgr_get_server_account_has_password:
277 * @self: a ModestAccountMgr instance
278 * @account_name: The name of a server account.
280 * Gets whether a password has been set for this server account in the account settings.
282 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self,
283 const gchar* account_name);
286 * modest_server_account_modest_account_mgr_get_server_account_hostname:
287 * @self: a ModestAccountMgr instance
288 * @account_name: The name of a server account.
290 * Gets the hostname this server account.
292 * Returns: The hostname.
294 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
295 const gchar* account_name);
298 * modest_server_account_modest_account_mgr_set_server_account_hostname:
299 * @self: a ModestAccountMgr instance
300 * @account_name: The name of a server account.
301 * @hostname: The new hostname
303 * Sets the hostname this server account.
305 void modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
306 const gchar* account_name,
307 const gchar *hostname);
310 * modest_account_mgr_get_server_account_secure_auth:
311 * @self: a ModestAccountMgr instance
312 * @account_name: The name of a server account.
314 * Gets the secure authentication method for this server account.
316 * Returns: The secure authentication enum value.
318 ModestProtocolType modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
319 const gchar* account_name);
322 * modest_server_account_data_get_secure_auth:
323 * @self: a ModestAccountMgr instance
324 * @account_name: The name of a server account.
325 * @secure_auth: The secure authentication enum value.
327 * Gets the secure authentication method for this server account.
329 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
330 const gchar* account_name,
331 ModestProtocolType secure_auth);
334 * modest_server_account_data_get_security:
335 * @self: a ModestAccountMgr instance
336 * @account_name: The name of a server account.
338 * Gets the security method for this server account.
340 * Returns: The security connection protocol.
342 ModestProtocolType modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
343 const gchar* account_name);
346 * modest_account_mgr_set_server_account_security:
347 * @self: a ModestAccountMgr instance
348 * @secure_auth: The security enum value.
350 * Gets the security method for this server account.
352 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
353 const gchar* account_name,
354 ModestProtocolType security);
356 gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
357 ModestServerAccountSettings *settings);
359 ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
360 const gchar *account_name,
361 gboolean is_transport_not_store);
364 * modest_account_mgr_get_from_string
365 * @self: a #ModestAccountMgr instance
366 * @name: the account name
367 * @mailbox: the mailbox
369 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
371 * Returns: the newly allocated from-string, or NULL in case of error
373 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name, const gchar *mailbox);
377 * modest_account_mgr_get_unused_account_name
378 * @self: a #ModestAccountMgr instance
379 * @name: The initial account name
381 * get an unused account name, based on a starting string.
383 * Returns: the newly allocated name.
385 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self,
386 const gchar* starting_name,
387 gboolean server_account);
390 * modest_account_mgr_get_unused_account_display name
391 * @self: a #ModestAccountMgr instance
392 * @name: The initial account display name
394 * get an unused account display name, based on a starting string.
396 * Returns: the newly allocated name.
398 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self,
399 const gchar* starting_name);
402 * modest_account_mgr_set_server_account_security:
403 * @self: a ModestAccountMgr instance
404 * @secure_auth: The security enum value.
406 * Gets the security method for this server account.
408 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
409 const gchar* account_name,
410 gboolean leave_on_server);
412 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
413 const gchar* account_name);
415 gint modest_account_mgr_get_last_updated (ModestAccountMgr *self,
416 const gchar* account_name);
418 void modest_account_mgr_set_last_updated (ModestAccountMgr *self,
419 const gchar* account_name,
422 gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
423 const gchar* account_name);
425 void modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
426 const gchar* account_name,
427 gint limit_retrieve);
429 gint modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
430 const gchar* account_name);
432 void modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
433 const gchar *account_name,
436 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
437 const gchar *account_name,
438 TnyAccountType account_type);
440 ModestAccountRetrieveType modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
441 const gchar *account_name);
443 void modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
444 const gchar *account_name,
445 ModestAccountRetrieveType retrieve_type);
447 void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
448 const gchar *account_name,
449 const gchar *fullname);
451 void modest_account_mgr_set_user_email (ModestAccountMgr *self,
452 const gchar *account_name,
457 #endif /* __MODEST_ACCOUNT_MGR_H__ */