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_display_name (ModestAccountMgr *self,
63 return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_DISPLAY_NAME, FALSE);
68 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
69 gboolean* use_signature)
73 modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE, FALSE);
76 return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
80 ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name)
82 ModestTransportStoreProtocol result = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default */
84 gchar *server_account_name = modest_account_mgr_get_string (self, name,
85 MODEST_ACCOUNT_STORE_ACCOUNT,
87 if (server_account_name) {
88 ModestServerAccountData* server_data =
89 modest_account_mgr_get_server_account_data (self, server_account_name);
90 result = server_data->proto;
92 modest_account_mgr_free_server_account_data (self, server_data);
94 g_free (server_account_name);
100 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
101 const gchar* connection_name, const gchar* server_account_name)
103 modest_account_mgr_remove_connection_specific_smtp (self, connection_name);
105 ModestConf *conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
107 gboolean result = TRUE;
109 GSList *list = modest_conf_get_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
110 MODEST_CONF_VALUE_STRING, &err);
112 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
117 /* The server account is in the item after the connection name: */
118 GSList *list_connection = g_slist_append (list, (gpointer)connection_name);
119 list_connection = g_slist_append (list_connection, (gpointer)server_account_name);
121 /* Reset the changed list: */
122 modest_conf_set_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list_connection,
123 MODEST_CONF_VALUE_STRING, &err);
125 g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
131 /* TODO: Should we free the items too, or just the list? */
138 * modest_account_mgr_remove_connection_specific_smtp
139 * @self: a ModestAccountMgr instance
140 * @name: the account name
141 * @connection_name: A libconic IAP connection name
143 * Disassacoiate a server account to use with the specific connection for this account.
145 * Returns: TRUE if it worked, FALSE otherwise
147 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self,
148 const gchar* connection_name)
150 ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
152 gboolean result = TRUE;
154 GSList *list = modest_conf_get_list (priv->modest_conf,
155 MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
156 MODEST_CONF_VALUE_STRING, &err);
158 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
167 /* The server account is in the item after the connection name: */
168 GSList *list_connection = g_slist_find_custom (list, connection_name, (GCompareFunc)strcmp);
169 if (list_connection) {
170 /* remove both items: */
171 GSList *temp = g_slist_delete_link(list_connection, list_connection);
172 temp = g_slist_delete_link(temp, g_slist_next(temp));
175 /* Reset the changed list: */
176 modest_conf_set_list (priv->modest_conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list,
177 MODEST_CONF_VALUE_STRING, &err);
179 g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
184 /* TODO: Should we free the items too, or just the list? */
191 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name)
193 return modest_account_mgr_get_bool (self, account_name,
194 MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP, FALSE);
197 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name,
200 return modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP,
205 * modest_account_mgr_get_connection_specific_smtp
206 * @self: a ModestAccountMgr instance
207 * @connection_name: A libconic IAP connection name
209 * Retrieve a server account to use with this specific connection for this account.
211 * Returns: a server account name to use for this connection, or NULL if none is specified.
213 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* connection_name)
215 gchar *result = NULL;
217 ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
220 GSList *list = modest_conf_get_list (priv->modest_conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
221 MODEST_CONF_VALUE_STRING, &err);
223 g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
231 /* The server account is in the item after the connection name: */
234 const gchar* this_connection_name = (const gchar*)(iter->data);
235 if (strcmp (this_connection_name, connection_name) == 0) {
236 iter = g_slist_next (iter);
239 const gchar* account_name = (const gchar*)(iter->data);
241 result = g_strdup (account_name);
247 /* Skip 2 to go to the next connection in the list: */
248 iter = g_slist_next (iter);
250 iter = g_slist_next (iter);
255 printf (" debug: no server found for connection_name=%s.\n", connection_name);
259 /* TODO: Should we free the items too, or just the list? */
266 modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name)
268 return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_USERNAME,
269 TRUE /* server account */);
273 modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name,
274 const gchar* username)
276 /* Note that this won't work properly as long as the gconf cache is broken
278 gchar *existing_username = modest_server_account_get_username(self,
281 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
282 username, TRUE /* server account */);
284 /* We don't know anything about new usernames: */
285 if (strcmp (existing_username, username) != 0)
286 modest_server_account_set_username_has_succeeded (self,
287 account_name, FALSE);
289 g_free (existing_username);
293 modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name)
295 return modest_account_mgr_get_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
296 TRUE /* server account */);
300 modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
303 modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
304 succeeded, TRUE /* server account */);
308 modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name,
309 const gchar* password)
311 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
312 password, TRUE /* server account */);
317 modest_server_account_get_password (ModestAccountMgr *self, const gchar* account_name)
319 return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
320 TRUE /* server account */);
324 modest_server_account_get_has_password (ModestAccountMgr *self, const gchar* account_name)
326 gboolean result = FALSE;
327 gchar *password = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
328 TRUE /* server account */);
329 if (password && strlen (password)) {
339 modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name)
341 return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_HOSTNAME,
342 TRUE /* server account */);
346 static ModestAuthProtocol
347 get_secure_auth_for_conf_string(const gchar* value)
349 ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
351 if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE) == 0)
352 result = MODEST_PROTOCOL_AUTH_NONE;
353 else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD) == 0)
354 result = MODEST_PROTOCOL_AUTH_PASSWORD;
355 else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5) == 0)
356 result = MODEST_PROTOCOL_AUTH_CRAMMD5;
363 modest_server_account_get_secure_auth (ModestAccountMgr *self,
364 const gchar* account_name)
366 ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
367 gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
368 TRUE /* server account */);
370 result = get_secure_auth_for_conf_string (value);
380 modest_server_account_set_secure_auth (ModestAccountMgr *self,
381 const gchar* account_name, ModestAuthProtocol secure_auth)
383 /* Get the conf string for the enum value: */
384 const gchar* str_value = NULL;
385 if (secure_auth == MODEST_PROTOCOL_AUTH_NONE)
386 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE;
387 else if (secure_auth == MODEST_PROTOCOL_AUTH_PASSWORD)
388 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD;
389 else if (secure_auth == MODEST_PROTOCOL_AUTH_CRAMMD5)
390 str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5;
392 /* Set it in the configuration: */
393 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
396 static ModestConnectionProtocol
397 get_security_for_conf_string(const gchar* value)
399 ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
401 if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
402 result = MODEST_PROTOCOL_CONNECTION_NORMAL;
403 else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0) {
404 /* The UI has "Normal (TLS)": */
405 result = MODEST_PROTOCOL_CONNECTION_TLS;
406 } else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
407 result = MODEST_PROTOCOL_CONNECTION_SSL;
413 ModestConnectionProtocol
414 modest_server_account_get_security (ModestAccountMgr *self,
415 const gchar* account_name)
417 ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
418 gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
419 TRUE /* server account */);
421 result = get_security_for_conf_string (value);
430 modest_server_account_set_security (ModestAccountMgr *self,
431 const gchar* account_name, ModestConnectionProtocol security)
433 /* Get the conf string for the enum value: */
434 const gchar* str_value = NULL;
435 if (security == MODEST_PROTOCOL_CONNECTION_NORMAL)
436 str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
437 else if (security == MODEST_PROTOCOL_CONNECTION_TLS) {
438 /* The UI has "Normal (TLS)": */
439 str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
440 } else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
441 str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
443 /* Set it in the configuration: */
444 modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY, str_value, TRUE);
447 ModestServerAccountData*
448 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name)
450 ModestServerAccountData *data;
453 g_return_val_if_fail (modest_account_mgr_account_exists (self, name, TRUE), NULL);
454 data = g_slice_new0 (ModestServerAccountData);
456 data->account_name = g_strdup (name);
457 data->hostname = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_HOSTNAME,TRUE);
458 data->username = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_USERNAME,TRUE);
459 proto = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
460 data->proto = modest_protocol_info_get_transport_store_protocol (proto);
463 data->port = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE);
465 gchar *secure_auth_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
466 data->secure_auth = get_secure_auth_for_conf_string(secure_auth_str);
467 g_free (secure_auth_str);
469 gchar *security_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SECURITY, TRUE);
470 data->security = get_security_for_conf_string(security_str);
471 g_free (security_str);
473 data->last_updated = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_LAST_UPDATED,TRUE);
475 data->password = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PASSWORD, TRUE);
482 modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
483 ModestServerAccountData* data)
485 g_return_if_fail (self);
488 return; /* not an error */
490 g_free (data->account_name);
491 data->account_name = NULL;
493 g_free (data->hostname);
494 data->hostname = NULL;
496 g_free (data->username);
497 data->username = NULL;
499 g_free (data->password);
500 data->password = NULL;
502 g_slice_free (ModestServerAccountData, data);
505 /** You must use modest_account_mgr_free_account_data() on the result.
508 modest_account_mgr_get_account_data (ModestAccountMgr *self, const gchar* name)
510 ModestAccountData *data;
511 gchar *server_account;
512 gchar *default_account;
514 g_return_val_if_fail (self, NULL);
515 g_return_val_if_fail (name, NULL);
517 if (!modest_account_mgr_account_exists (self, name, FALSE)) {
518 /* For instance, maybe you are mistakenly checking for a server account name? */
519 g_warning ("%s: Account %s does not exist.", __FUNCTION__, name);
523 data = g_slice_new0 (ModestAccountData);
525 data->account_name = g_strdup (name);
527 data->display_name = modest_account_mgr_get_string (self, name,
528 MODEST_ACCOUNT_DISPLAY_NAME,
530 data->fullname = modest_account_mgr_get_string (self, name,
531 MODEST_ACCOUNT_FULLNAME,
533 data->email = modest_account_mgr_get_string (self, name,
534 MODEST_ACCOUNT_EMAIL,
536 data->is_enabled = modest_account_mgr_get_enabled (self, name);
538 default_account = modest_account_mgr_get_default_account (self);
539 data->is_default = (default_account && strcmp (default_account, name) == 0);
540 g_free (default_account);
543 server_account = modest_account_mgr_get_string (self, name,
544 MODEST_ACCOUNT_STORE_ACCOUNT,
546 if (server_account) {
547 data->store_account =
548 modest_account_mgr_get_server_account_data (self, server_account);
549 g_free (server_account);
553 server_account = modest_account_mgr_get_string (self, name,
554 MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
556 if (server_account) {
557 data->transport_account =
558 modest_account_mgr_get_server_account_data (self, server_account);
559 g_free (server_account);
567 modest_account_mgr_free_account_data (ModestAccountMgr *self, ModestAccountData *data)
569 g_return_if_fail (self);
571 if (!data) /* not an error */
574 g_free (data->account_name);
575 g_free (data->display_name);
576 g_free (data->fullname);
577 g_free (data->email);
579 modest_account_mgr_free_server_account_data (self, data->store_account);
580 modest_account_mgr_free_server_account_data (self, data->transport_account);
582 g_slice_free (ModestAccountData, data);
587 modest_account_mgr_get_default_account (ModestAccountMgr *self)
593 g_return_val_if_fail (self, NULL);
595 conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
596 account = modest_conf_get_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, &err);
599 g_printerr ("modest: failed to get '%s': %s\n",
600 MODEST_CONF_DEFAULT_ACCOUNT, err->message);
607 if (account && !modest_account_mgr_account_exists (self, account, FALSE)) {
608 g_printerr ("modest: default account does not exist\n");
618 modest_account_mgr_set_default_account (ModestAccountMgr *self, const gchar* account)
622 g_return_val_if_fail (self, FALSE);
623 g_return_val_if_fail (account, FALSE);
624 g_return_val_if_fail (modest_account_mgr_account_exists (self, account, FALSE),
627 conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
629 return modest_conf_set_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, account, NULL);
633 modest_account_mgr_unset_default_account (ModestAccountMgr *self)
637 g_return_val_if_fail (self, FALSE);
639 conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
641 return modest_conf_remove_key (conf, MODEST_CONF_DEFAULT_ACCOUNT, NULL /* err */);
645 gint on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
647 return g_utf8_collate((const gchar*)a, (const gchar*)b);
650 /** Get the first one, alphabetically, by title. */
652 modest_account_mgr_get_first_account_name (ModestAccountMgr *self)
654 const gchar* account_name = NULL;
655 GSList *account_names = modest_account_mgr_account_names (self, TRUE /* only enabled */);
657 /* Return TRUE if there is no account */
661 /* Get the first one, alphabetically, by title: */
662 /* gchar *old_default = modest_account_mgr_get_default_account (self); */
663 GSList* list_sorted = g_slist_sort (account_names, on_accounts_list_sort_by_title);
665 GSList* iter = list_sorted;
666 gboolean found = FALSE;
667 while (iter && !found) {
668 account_name = (const gchar*)list_sorted->data;
674 iter = g_slist_next (iter);
677 gchar* result = NULL;
679 result = g_strdup (account_name);
681 modest_account_mgr_free_account_names (account_names);
682 account_names = NULL;
688 modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self)
690 gboolean result = FALSE;
692 gchar* account_name = modest_account_mgr_get_first_account_name(self);
694 result = modest_account_mgr_set_default_account (self, account_name);
695 g_free (account_name);
698 result = TRUE; /* If there are no accounts then it's not a failure. */
704 modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name)
706 gchar *fullname, *email, *from;
708 g_return_val_if_fail (self, NULL);
709 g_return_val_if_fail (name, NULL);
711 fullname = modest_account_mgr_get_string (self, name,MODEST_ACCOUNT_FULLNAME,
713 email = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_EMAIL,
715 from = g_strdup_printf ("%s <%s>",
716 fullname ? fullname : "",
724 /* Add a number to the end of the text, or increment a number that is already there.
727 util_increment_name (const gchar* text)
729 /* Get the end character,
730 * also doing a UTF-8 validation which is required for using g_utf8_prev_char().
732 const gchar* end = NULL;
733 if (!g_utf8_validate (text, -1, &end))
739 --end; /* Go to before the null-termination. */
741 /* Look at each UTF-8 characer, starting at the end: */
742 const gchar* p = end;
743 const gchar* alpha_end = NULL;
746 /* Stop when we reach the first character that is not a numeric digit: */
747 const gunichar ch = g_utf8_get_char (p);
748 if (!g_unichar_isdigit (ch)) {
753 p = g_utf8_prev_char (p);
757 /* The text must consist completely of numeric digits. */
763 /* Intepret and increment the number, if any: */
764 gint num = atol (alpha_end);
767 /* Get the name part: */
768 gint name_len = alpha_end - text;
769 gchar *name_without_number = g_malloc(name_len + 1);
770 memcpy (name_without_number, text, name_len);
771 name_without_number[name_len] = 0;\
773 /* Concatenate the text part and the new number: */
774 gchar *result = g_strdup_printf("%s%d", name_without_number, num);
775 g_free (name_without_number);
781 modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, const gchar* starting_name,
782 gboolean server_account)
784 gchar *account_name = g_strdup (starting_name);
786 while (modest_account_mgr_account_exists (self,
787 account_name, server_account /* server_account */)) {
789 gchar * account_name2 = util_increment_name (account_name);
790 g_free (account_name);
791 account_name = account_name2;
798 modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, const gchar* starting_name)
800 gchar *account_name = g_strdup (starting_name);
802 while (modest_account_mgr_account_with_display_name_exists (self, account_name)) {
804 gchar * account_name2 = util_increment_name (account_name);
805 g_free (account_name);
806 account_name = account_name2;