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.
30 #include <modest-account-mgr-helpers.h>
31 #include <modest-account-mgr-priv.h>
32 #include <tny-simple-list.h>
33 #include <modest-runtime.h>
37 modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
40 return modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_ENABLED, enabled,FALSE);
45 modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name)
47 return modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_ENABLED, FALSE);
50 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
51 const gchar* signature, gboolean use_signature)
53 gboolean result = modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE,
54 use_signature, FALSE);
55 result = result && modest_account_mgr_set_string (self, name, MODEST_ACCOUNT_SIGNATURE,
60 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
61 gboolean* use_signature)
65 modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE, FALSE);
68 return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
72 ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name)
74 ModestTransportStoreProtocol result = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default */
76 gchar *server_account_name = modest_account_mgr_get_string (self, name,
77 MODEST_ACCOUNT_STORE_ACCOUNT,
79 if (server_account_name) {
80 ModestServerAccountData* server_data =
81 modest_account_mgr_get_server_account_data (self, server_account_name);
82 result = server_data->proto;
84 modest_account_mgr_free_server_account_data (self, server_data);
86 g_free (server_account_name);
92 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
93 const gchar* connection_name, const gchar* server_account_name)
95 modest_account_mgr_remove_connection_specific_smtp (self, connection_name);
97 ModestConf *conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
99 gboolean result = TRUE;
101 GSList *list = modest_conf_get_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
102 MODEST_CONF_VALUE_STRING, &err);
104 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
109 /* The server account is in the item after the connection name: */
110 GSList *list_connection = g_slist_append (list, (gpointer)connection_name);
111 list_connection = g_slist_append (list_connection, (gpointer)server_account_name);
113 /* Reset the changed list: */
114 modest_conf_set_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list_connection,
115 MODEST_CONF_VALUE_STRING, &err);
117 g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
123 /* TODO: Should we free the items too, or just the list? */
130 * modest_account_mgr_remove_connection_specific_smtp
131 * @self: a ModestAccountMgr instance
132 * @name: the account name
133 * @connection_name: A libconic IAP connection name
135 * Disassacoiate a server account to use with the specific connection for this account.
137 * Returns: TRUE if it worked, FALSE otherwise
139 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
140 const gchar* connection_name)
142 ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
144 gboolean result = TRUE;
146 GSList *list = modest_conf_get_list (priv->modest_conf,
147 MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
148 MODEST_CONF_VALUE_STRING, &err);
150 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
159 /* The server account is in the item after the connection name: */
160 GSList *list_connection = g_slist_find_custom (list, connection_name, (GCompareFunc)strcmp);
161 if (list_connection) {
162 /* remove both items: */
163 GSList *temp = g_slist_delete_link(list_connection, list_connection);
164 temp = g_slist_delete_link(temp, g_slist_next(temp));
167 /* Reset the changed list: */
168 modest_conf_set_list (priv->modest_conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list,
169 MODEST_CONF_VALUE_STRING, &err);
171 g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
176 /* TODO: Should we free the items too, or just the list? */
183 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name)
185 return modest_account_mgr_get_bool (self, account_name,
186 MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP, FALSE);
189 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name,
192 return modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP,
197 * modest_account_mgr_get_connection_specific_smtp
198 * @self: a ModestAccountMgr instance
199 * @connection_name: A libconic IAP connection name
201 * Retrieve a server account to use with this specific connection for this account.
203 * Returns: a server account name to use for this connection, or NULL if none is specified.
205 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* connection_name)
207 gchar *result = NULL;
209 ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
212 GSList *list = modest_conf_get_list (priv->modest_conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
213 MODEST_CONF_VALUE_STRING, &err);
215 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
223 /* The server account is in the item after the connection name: */
226 const gchar* this_connection_name = (const gchar*)(iter->data);
227 if (strcmp (this_connection_name, connection_name) == 0) {
228 iter = g_slist_next (iter);
231 const gchar* account_name = (const gchar*)(iter->data);
233 result = g_strdup (account_name);
239 /* Skip 2 to go to the next connection in the list: */
240 iter = g_slist_next (iter);
242 iter = g_slist_next (iter);
247 printf (" debug: no server found for connection_name=%s.\n", connection_name);
251 /* TODO: Should we free the items too, or just the list? */
258 modest_account_mgr_get_server_account_username (ModestAccountMgr *self, const gchar* account_name)
260 return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_USERNAME,
261 TRUE /* server account */);
265 modest_account_mgr_set_server_account_username (ModestAccountMgr *self, const gchar* account_name,
266 const gchar* username)
268 /* Note that this won't work properly as long as the gconf cache is broken
270 gchar *existing_username = modest_account_mgr_get_server_account_username(self,
273 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
274 username, TRUE /* server account */);
276 /* We don't know anything about new usernames: */
277 if (strcmp (existing_username, username) != 0)
278 modest_account_mgr_get_server_account_username_has_succeeded (self, account_name);
280 g_free (existing_username);
284 modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name)
286 return modest_account_mgr_get_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
287 TRUE /* server account */);
291 modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
292 const gchar* account_name,
295 modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
296 succeeded, TRUE /* server account */);
300 modest_account_mgr_set_server_account_password (ModestAccountMgr *self, const gchar* account_name,
301 const gchar* password)
303 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
304 password, TRUE /* server account */);
309 modest_account_mgr_get_server_account_password (ModestAccountMgr *self, const gchar* account_name)
311 return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
312 TRUE /* server account */);
316 modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self, const gchar* account_name)
318 gboolean result = FALSE;
319 gchar *password = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
320 TRUE /* server account */);
321 if (password && strlen (password)) {
331 modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
332 const gchar* account_name)
334 return modest_account_mgr_get_string (self,
336 MODEST_ACCOUNT_HOSTNAME,
337 TRUE /* server account */);
341 modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
342 const gchar *server_account_name,
343 const gchar *hostname)
345 modest_account_mgr_set_string (self,
347 MODEST_ACCOUNT_HOSTNAME,
349 TRUE /* server account */);
353 static ModestAuthProtocol
354 get_secure_auth_for_conf_string(const gchar* value)
356 ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
358 if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE) == 0)
359 result = MODEST_PROTOCOL_AUTH_NONE;
360 else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD) == 0)
361 result = MODEST_PROTOCOL_AUTH_PASSWORD;
362 else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5) == 0)
363 result = MODEST_PROTOCOL_AUTH_CRAMMD5;
370 modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
371 const gchar* account_name)
373 ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
374 gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
375 TRUE /* server account */);
377 result = get_secure_auth_for_conf_string (value);
387 modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
388 const gchar* account_name, ModestAuthProtocol secure_auth)
390 /* Get the conf string for the enum value: */
391 const gchar* str_value = NULL;
392 if (secure_auth == MODEST_PROTOCOL_AUTH_NONE)
393 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE;
394 else if (secure_auth == MODEST_PROTOCOL_AUTH_PASSWORD)
395 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD;
396 else if (secure_auth == MODEST_PROTOCOL_AUTH_CRAMMD5)
397 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5;
399 /* Set it in the configuration: */
400 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
403 static ModestConnectionProtocol
404 get_security_for_conf_string(const gchar* value)
406 ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
408 if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
409 result = MODEST_PROTOCOL_CONNECTION_NORMAL;
410 else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0) {
411 /* The UI has "Normal (TLS)": */
412 result = MODEST_PROTOCOL_CONNECTION_TLS;
413 } else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
414 result = MODEST_PROTOCOL_CONNECTION_SSL;
420 ModestConnectionProtocol
421 modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
422 const gchar* account_name)
424 ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
425 gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
426 TRUE /* server account */);
428 result = get_security_for_conf_string (value);
437 modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
438 const gchar* account_name, ModestConnectionProtocol security)
440 /* Get the conf string for the enum value: */
441 const gchar* str_value = NULL;
442 if (security == MODEST_PROTOCOL_CONNECTION_NORMAL)
443 str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
444 else if (security == MODEST_PROTOCOL_CONNECTION_TLS) {
445 /* The UI has "Normal (TLS)": */
446 str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
447 } else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
448 str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
450 /* Set it in the configuration: */
451 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY, str_value, TRUE);
454 ModestServerAccountData*
455 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name)
457 ModestServerAccountData *data;
460 g_return_val_if_fail (modest_account_mgr_account_exists (self, name, TRUE), NULL);
461 data = g_slice_new0 (ModestServerAccountData);
463 data->account_name = g_strdup (name);
464 data->hostname = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_HOSTNAME,TRUE);
465 data->username = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_USERNAME,TRUE);
466 proto = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
467 data->proto = modest_protocol_info_get_transport_store_protocol (proto);
470 data->port = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE);
472 gchar *secure_auth_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
473 data->secure_auth = get_secure_auth_for_conf_string(secure_auth_str);
474 g_free (secure_auth_str);
476 gchar *security_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SECURITY, TRUE);
477 data->security = get_security_for_conf_string(security_str);
478 g_free (security_str);
480 data->last_updated = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_LAST_UPDATED,TRUE);
482 data->password = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PASSWORD, TRUE);
489 modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
490 ModestServerAccountData* data)
492 g_return_if_fail (self);
495 return; /* not an error */
497 g_free (data->account_name);
498 data->account_name = NULL;
500 g_free (data->hostname);
501 data->hostname = NULL;
503 g_free (data->username);
504 data->username = NULL;
506 g_free (data->password);
507 data->password = NULL;
509 g_slice_free (ModestServerAccountData, data);
512 /** You must use modest_account_mgr_free_account_data() on the result.
515 modest_account_mgr_get_account_data (ModestAccountMgr *self, const gchar* name)
517 ModestAccountData *data;
518 gchar *server_account;
519 gchar *default_account;
521 g_return_val_if_fail (self, NULL);
522 g_return_val_if_fail (name, NULL);
524 if (!modest_account_mgr_account_exists (self, name, FALSE)) {
525 /* For instance, maybe you are mistakenly checking for a server account name? */
526 g_warning ("%s: Account %s does not exist.", __FUNCTION__, name);
530 data = g_slice_new0 (ModestAccountData);
532 data->account_name = g_strdup (name);
534 data->display_name = modest_account_mgr_get_string (self, name,
535 MODEST_ACCOUNT_DISPLAY_NAME,
537 data->fullname = modest_account_mgr_get_string (self, name,
538 MODEST_ACCOUNT_FULLNAME,
540 data->email = modest_account_mgr_get_string (self, name,
541 MODEST_ACCOUNT_EMAIL,
543 data->is_enabled = modest_account_mgr_get_enabled (self, name);
545 default_account = modest_account_mgr_get_default_account (self);
546 data->is_default = (default_account && strcmp (default_account, name) == 0);
547 g_free (default_account);
550 server_account = modest_account_mgr_get_string (self, name,
551 MODEST_ACCOUNT_STORE_ACCOUNT,
553 if (server_account) {
554 data->store_account =
555 modest_account_mgr_get_server_account_data (self, server_account);
556 g_free (server_account);
560 server_account = modest_account_mgr_get_string (self, name,
561 MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
563 if (server_account) {
564 data->transport_account =
565 modest_account_mgr_get_server_account_data (self, server_account);
566 g_free (server_account);
574 modest_account_mgr_free_account_data (ModestAccountMgr *self, ModestAccountData *data)
576 g_return_if_fail (self);
578 if (!data) /* not an error */
581 g_free (data->account_name);
582 g_free (data->display_name);
583 g_free (data->fullname);
584 g_free (data->email);
586 modest_account_mgr_free_server_account_data (self, data->store_account);
587 modest_account_mgr_free_server_account_data (self, data->transport_account);
589 g_slice_free (ModestAccountData, data);
593 on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
595 return g_utf8_collate((const gchar*)a, (const gchar*)b);
598 /** Get the first one, alphabetically, by title. */
600 modest_account_mgr_get_first_account_name (ModestAccountMgr *self)
602 const gchar* account_name = NULL;
603 GSList *account_names = modest_account_mgr_account_names (self, TRUE /* only enabled */);
605 /* Return TRUE if there is no account */
609 /* Get the first one, alphabetically, by title: */
610 /* gchar *old_default = modest_account_mgr_get_default_account (self); */
611 GSList* list_sorted = g_slist_sort (account_names, on_accounts_list_sort_by_title);
613 GSList* iter = list_sorted;
614 gboolean found = FALSE;
615 while (iter && !found) {
616 account_name = (const gchar*)list_sorted->data;
622 iter = g_slist_next (iter);
625 gchar* result = NULL;
627 result = g_strdup (account_name);
629 modest_account_mgr_free_account_names (account_names);
630 account_names = NULL;
636 modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self)
638 gboolean result = FALSE;
640 gchar* account_name = modest_account_mgr_get_first_account_name(self);
642 result = modest_account_mgr_set_default_account (self, account_name);
643 g_free (account_name);
646 result = TRUE; /* If there are no accounts then it's not a failure. */
652 modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name)
654 gchar *fullname, *email, *from;
656 g_return_val_if_fail (self, NULL);
657 g_return_val_if_fail (name, NULL);
659 fullname = modest_account_mgr_get_string (self, name,MODEST_ACCOUNT_FULLNAME,
661 email = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_EMAIL,
663 from = g_strdup_printf ("%s <%s>",
664 fullname ? fullname : "",
672 /* Add a number to the end of the text, or increment a number that is already there.
675 util_increment_name (const gchar* text)
677 /* Get the end character,
678 * also doing a UTF-8 validation which is required for using g_utf8_prev_char().
680 const gchar* end = NULL;
681 if (!g_utf8_validate (text, -1, &end))
687 --end; /* Go to before the null-termination. */
689 /* Look at each UTF-8 characer, starting at the end: */
690 const gchar* p = end;
691 const gchar* alpha_end = NULL;
694 /* Stop when we reach the first character that is not a numeric digit: */
695 const gunichar ch = g_utf8_get_char (p);
696 if (!g_unichar_isdigit (ch)) {
701 p = g_utf8_prev_char (p);
705 /* The text must consist completely of numeric digits. */
711 /* Intepret and increment the number, if any: */
712 gint num = atol (alpha_end);
715 /* Get the name part: */
716 gint name_len = alpha_end - text;
717 gchar *name_without_number = g_malloc(name_len + 1);
718 memcpy (name_without_number, text, name_len);
719 name_without_number[name_len] = 0;\
721 /* Concatenate the text part and the new number: */
722 gchar *result = g_strdup_printf("%s%d", name_without_number, num);
723 g_free (name_without_number);
729 modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, const gchar* starting_name,
730 gboolean server_account)
732 gchar *account_name = g_strdup (starting_name);
734 while (modest_account_mgr_account_exists (self,
735 account_name, server_account /* server_account */)) {
737 gchar * account_name2 = util_increment_name (account_name);
738 g_free (account_name);
739 account_name = account_name2;
746 modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, const gchar* starting_name)
748 gchar *account_name = g_strdup (starting_name);
750 while (modest_account_mgr_account_with_display_name_exists (self, account_name)) {
752 gchar * account_name2 = util_increment_name (account_name);
753 g_free (account_name);
754 account_name = account_name2;
761 modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
762 const gchar *account_name,
763 gboolean leave_on_server)
765 modest_account_mgr_set_bool (self,
767 MODEST_ACCOUNT_LEAVE_ON_SERVER,
773 modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
774 const gchar* account_name)
776 return modest_account_mgr_get_bool (self,
778 MODEST_ACCOUNT_LEAVE_ON_SERVER,
783 modest_account_mgr_get_last_updated (ModestAccountMgr *self,
784 const gchar* account_name)
786 return modest_account_mgr_get_int (modest_runtime_get_account_mgr (),
788 MODEST_ACCOUNT_LAST_UPDATED,
793 modest_account_mgr_set_last_updated (ModestAccountMgr *self,
794 const gchar* account_name,
797 modest_account_mgr_set_int (self,
799 MODEST_ACCOUNT_LAST_UPDATED,
803 /* TODO: notify about changes */
807 modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
808 const gchar* account_name)
810 return modest_account_mgr_get_int (self,
812 MODEST_ACCOUNT_LIMIT_RETRIEVE,
817 modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
818 const gchar* account_name,
821 modest_account_mgr_set_int (self,
823 MODEST_ACCOUNT_LIMIT_RETRIEVE,
825 FALSE /* not server account */);
829 modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
830 const gchar* account_name)
832 return modest_account_mgr_get_int (self,
839 modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
840 const gchar *account_name,
843 modest_account_mgr_set_int (self,
846 port_num, TRUE /* server account */);
850 modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
851 const gchar *account_name,
852 TnyAccountType account_type)
854 return modest_account_mgr_get_string (self,
856 (account_type == TNY_ACCOUNT_TYPE_STORE) ?
857 MODEST_ACCOUNT_STORE_ACCOUNT :
858 MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
863 modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
864 const gchar *account_name)
866 return modest_account_mgr_get_string (self,
868 MODEST_ACCOUNT_RETRIEVE,
869 FALSE /* not server account */);
873 modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
874 const gchar *account_name,
875 const gchar *retrieve_type)
877 modest_account_mgr_set_string (self,
879 MODEST_ACCOUNT_RETRIEVE,
881 FALSE /* not server account */);
886 modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self,
887 const gchar *account_name,
888 const gchar *fullname)
890 modest_account_mgr_set_string (self,
892 MODEST_ACCOUNT_FULLNAME,
894 FALSE /* not server account */);
898 modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self,
899 const gchar *account_name,
902 modest_account_mgr_set_string (self,
904 MODEST_ACCOUNT_EMAIL,
906 FALSE /* not server account */);