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);
132 void modest_account_mgr_get_branding_from_recipient (ModestAccountMgr *mgr,
133 const gchar *current_recipient,
134 gchar **service_name,
135 const GdkPixbuf **service_icon,
138 gboolean modest_account_mgr_account_is_multimailbox (ModestAccountMgr *mgr,
139 const gchar *account_name,
140 ModestProtocol **mmb_protocol);
143 * modest_account_mgr_get_store_protocol:
144 * @self: a ModestAccountMgr instance
145 * @name: the account name
147 * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
149 * Returns: The protocol type.
151 ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
154 * modest_account_mgr_set_connection_specific_smtp
155 * @self: a ModestAccountMgr instance
156 * @connection_id: A libconic IAP connection name
157 * @server_account_name: a server account name to use for this connection.
159 * Specify a server account to use with the specific connection for this account.
161 * Returns: TRUE if it worked, FALSE otherwise
163 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
164 const gchar* connection_id, const gchar* server_account_name);
167 * modest_account_mgr_remove_connection_specific_smtp
168 * @self: a ModestAccountMgr instance
169 * @connection_id: A libconic IAP connection name
171 * Disassociate a server account to use with the specific connection for this account.
173 * Returns: TRUE if it worked, FALSE otherwise
175 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
176 const gchar* connection_id);
179 * modest_account_mgr_get_use_connection_specific_smtp
180 * @self: a ModestAccountMgr instance
181 * @account_name: the account name
182 * @result: Whether this account should use connection-specific smtp server accounts.
184 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
187 * modest_account_mgr_set_use_connection_specific_smtp
188 * @self: a ModestAccountMgr instance
189 * @account_name: the account name
190 * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
191 * @result: TRUE if it succeeded, FALSE otherwise
193 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self,
194 const gchar* account_name,
198 * modest_account_mgr_get_connection_specific_smtp
199 * @self: a ModestAccountMgr instance
200 * @connection_id: A libconic IAP connection id
202 * Retrieve a server account to use with this specific connection for this account.
204 * Returns: a server account name to use for this connection, or NULL if none is specified.
206 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
207 const gchar* connection_id);
211 * modest_account_mgr_get_server_account_username:
212 * @self: a ModestAccountMgr instance
213 * @account_name: The name of a server account.
215 * Gets the username this server account.
217 * Returns: The username.
219 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self,
220 const gchar* account_name);
223 * modest_account_mgr_set_server_account_username:
224 * @self: a ModestAccountMgr instance
225 * @account_name: The name of a server account.
226 * @username: The new username.
228 * Sets the username this server account.
230 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self,
231 const gchar* account_name,
232 const gchar* username);
235 * modest_account_mgr_get_server_account_username_has_succeeded:
236 * @self: a ModestAccountMgr instance
237 * @account_name: The name of a server account.
239 * Whether a connection has ever been successfully made to this account with
240 * the current username. This can be used to avoid asking again for the username
241 * when asking a second time for a non-stored password.
243 * Returns: TRUE if the username is known to be correct.
245 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self,
246 const gchar* account_name);
249 * modest_account_mgr_set_server_account_username_has_succeeded:
250 * @self: a ModestAccountMgr instance
251 * @account_name: The name of a server account.
252 * @succeeded: Whether the username has succeeded
254 * Sets whether the username is known to be correct.
256 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
257 const gchar* account_name,
261 * modest_account_mgr_set_server_account_password:
262 * @self: a ModestAccountMgr instance
263 * @account_name: The name of a server account.
264 * @password: The new password.
266 * Sets the password for this server account.
268 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self,
269 const gchar* account_name,
270 const gchar* password);
273 * modest_account_mgr_get_server_account_password:
274 * @self: a ModestAccountMgr instance
275 * @account_name: The name of a server account.
277 * Gets the password for this server account from the account settings.
279 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self,
280 const gchar* account_name);
283 * modest_account_mgr_get_server_account_has_password:
284 * @self: a ModestAccountMgr instance
285 * @account_name: The name of a server account.
287 * Gets whether a password has been set for this server account in the account settings.
289 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self,
290 const gchar* account_name);
293 * modest_server_account_modest_account_mgr_get_server_account_hostname:
294 * @self: a ModestAccountMgr instance
295 * @account_name: The name of a server account.
297 * Gets the hostname this server account.
299 * Returns: The hostname.
301 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
302 const gchar* account_name);
305 * modest_server_account_modest_account_mgr_set_server_account_hostname:
306 * @self: a ModestAccountMgr instance
307 * @account_name: The name of a server account.
308 * @hostname: The new hostname
310 * Sets the hostname this server account.
312 void modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
313 const gchar* account_name,
314 const gchar *hostname);
317 * modest_account_mgr_get_server_account_secure_auth:
318 * @self: a ModestAccountMgr instance
319 * @account_name: The name of a server account.
321 * Gets the secure authentication method for this server account.
323 * Returns: The secure authentication enum value.
325 ModestProtocolType modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
326 const gchar* account_name);
329 * modest_server_account_data_get_secure_auth:
330 * @self: a ModestAccountMgr instance
331 * @account_name: The name of a server account.
332 * @secure_auth: The secure authentication enum value.
334 * Gets the secure authentication method for this server account.
336 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
337 const gchar* account_name,
338 ModestProtocolType secure_auth);
341 * modest_server_account_data_get_security:
342 * @self: a ModestAccountMgr instance
343 * @account_name: The name of a server account.
345 * Gets the security method for this server account.
347 * Returns: The security connection protocol.
349 ModestProtocolType modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
350 const gchar* account_name);
353 * modest_account_mgr_set_server_account_security:
354 * @self: a ModestAccountMgr instance
355 * @secure_auth: The security enum value.
357 * Gets the security method for this server account.
359 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
360 const gchar* account_name,
361 ModestProtocolType security);
363 gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
364 ModestServerAccountSettings *settings);
366 ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
367 const gchar *account_name,
368 gboolean is_transport_not_store);
371 * modest_account_mgr_get_from_string
372 * @self: a #ModestAccountMgr instance
373 * @name: the account name
374 * @mailbox: the mailbox
376 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
378 * Returns: the newly allocated from-string, or NULL in case of error
380 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name, const gchar *mailbox);
384 * modest_account_mgr_get_unused_account_name
385 * @self: a #ModestAccountMgr instance
386 * @name: The initial account name
388 * get an unused account name, based on a starting string.
390 * Returns: the newly allocated name.
392 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self,
393 const gchar* starting_name,
394 gboolean server_account);
397 * modest_account_mgr_get_unused_account_display name
398 * @self: a #ModestAccountMgr instance
399 * @name: The initial account display name
401 * get an unused account display name, based on a starting string.
403 * Returns: the newly allocated name.
405 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self,
406 const gchar* starting_name);
409 * modest_account_mgr_set_server_account_security:
410 * @self: a ModestAccountMgr instance
411 * @secure_auth: The security enum value.
413 * Gets the security method for this server account.
415 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
416 const gchar* account_name,
417 gboolean leave_on_server);
419 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
420 const gchar* account_name);
422 gint modest_account_mgr_get_last_updated (ModestAccountMgr *self,
423 const gchar* account_name);
425 void modest_account_mgr_set_last_updated (ModestAccountMgr *self,
426 const gchar* account_name,
429 gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
430 const gchar* account_name);
432 void modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
433 const gchar* account_name,
434 gint limit_retrieve);
436 gint modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
437 const gchar* account_name);
439 void modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
440 const gchar *account_name,
443 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
444 const gchar *account_name,
445 TnyAccountType account_type);
447 ModestAccountRetrieveType modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
448 const gchar *account_name);
450 void modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
451 const gchar *account_name,
452 ModestAccountRetrieveType retrieve_type);
454 void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
455 const gchar *account_name,
456 const gchar *fullname);
458 void modest_account_mgr_set_user_email (ModestAccountMgr *self,
459 const gchar *account_name,
464 #endif /* __MODEST_ACCOUNT_MGR_H__ */