424
account_name_and_uid_from_source (ESource *source,
428
ESourceExtension *extension;
429
const gchar *protocol;
431
if (!e_source_get_removable(source) || !e_source_get_enabled(source))
434
extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
435
protocol = e_source_backend_dup_backend_name (E_SOURCE_BACKEND (extension));
437
if (g_str_has_prefix (protocol, "pop"))
438
*name = g_strdup (g_dgettext (EVO_I18N_DOMAIN, "Inbox"));
440
*name = e_source_dup_display_name (source);
442
*uid = e_source_dup_uid (source);
448
update_accounts (void)
450
ESourceRegistry * registry = NULL;
451
GError *error = NULL;
425
mail_source_from_uid (const gchar *uid)
427
ESourceRegistry *registry;
428
GError *error = NULL;
431
ESource *source = NULL;
453
433
registry = e_source_registry_new_sync (NULL, &error);
455
if (!registry || error)
457
g_warning ("Failed to get access to source registry: %s\n"
458
"defaulting number of account to '1'",
459
error ? error->message : "unknown");
461
g_error_free (error);
465
GList *list_sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
468
g_slist_free_full (accounts, (GDestroyNotify) unref_account);
470
for (a = list_sources; a; a = a->next)
472
ESource *source = E_SOURCE (a->data);
476
if (account_name_and_uid_from_source (source, &name, &uid))
478
MessagingMailAccount *account;
480
account = g_new(MessagingMailAccount, 1);
481
account->name = g_strdup(name);
482
account->uid = g_strdup(uid);
483
account->n_count = 0;
484
accounts = g_slist_append (accounts, account);
485
g_debug ("EI: New account: %s (%s)", name, uid);
492
g_list_free_full (list_sources, g_object_unref);
436
g_warning ("Failed to get access to source registry: %s\n", error->message);
437
g_error_free (error);
441
sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
442
for (it = sources; it; it = it->next)
444
if (g_str_equal (uid, e_source_get_uid (it->data)))
446
source = g_object_ref (it->data);
451
g_list_free_full (sources, g_object_unref);
452
g_object_unref (registry);
456
static MessagingMailAccount *
457
ensure_account_for_uid (const gchar *uid)
459
MessagingMailAccount *account;
462
if ((account = find_account_for_uid (accounts, uid)))
465
if ((source = mail_source_from_uid (uid)))
467
if (e_source_get_removable(source) && e_source_get_enabled(source))
469
ESourceExtension *extension;
470
const gchar *protocol;
472
extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
473
protocol = e_source_backend_get_backend_name (E_SOURCE_BACKEND (extension));
475
account = g_new(MessagingMailAccount, 1);
476
account->uid = g_strdup (uid);
477
account->n_count = 0;
479
if (g_str_has_prefix (protocol, "pop"))
480
account->name = g_strdup (g_dgettext (EVO_I18N_DOMAIN, "Inbox"));
482
account->name = e_source_dup_display_name (source);
484
accounts = g_slist_append (accounts, account);
485
g_debug ("EI: New account: %s (%s)", account->name, account->uid);
488
g_object_unref (source);
496
494
#define EVO_CONTACTS_CMD "evolution -c contacts"