Index: tracker-email-evolution.c =================================================================== --- tracker-email-evolution.c (revision 1095) +++ tracker-email-evolution.c (working copy) @@ -148,6 +148,7 @@ */ static gchar * get_account_name_in_imap_path (const gchar *path); +static gchar * get_account_name_from_imap_uri (const gchar *imap_uri); typedef gboolean (* LoadSummaryFileMetaHeaderFct) (SummaryFile *summary, SummaryFileHeader *header); typedef gboolean (* LoadMailMessageFct) (SummaryFile *summary, MailMessage **mail_msg); @@ -683,6 +684,49 @@ } +static gchar* get_account_name_from_imap_uri(const gchar* imap_uri) +{ + /* Assume url schema is: + imap://foo imap free fr/;etc + + also can contain foo;auth=DIGEST-MD5 imap bar com + + We try to get "foo imap free fr". + */ + + // check for embedded @ and then look for first colon after that + + const char *start = imap_uri + 7; + const char *at = strchr (start, '@'); + const char *semic = strchr(start, ';'); + + gchar* user_name = NULL; + gchar* at_host_name = NULL; + gchar *account_name = NULL; + + + if (semic < at) { // then we have a ";auth=FOO host" schema + // Set semic to the next semicolon, which ends the hostname. + user_name = g_strndup(start, (semic-start)); + semic = strchr(at,';'); + } else { + user_name = g_strndup(start, (at-start)); + } + + at_host_name = g_strndup(at, (semic - 1) - at); + + if (user_name && at_host_name) { + account_name = g_strconcat(user_name,at_host_name,NULL); + g_free(user_name); + g_free(at_host_name); + return account_name; + } else { + g_free(user_name); + g_free(at_host_name); + return NULL; + } +} + static gboolean load_evolution_config (EvolutionConfig **conf) { @@ -723,23 +767,9 @@ } case EVOLUTION_MAIL_PROTOCOL_IMAP: { - gchar *account_name = NULL; - /* Assume url schema is: - imap://foo imap free fr/;etc + gchar* account_name = get_account_name_from_imap_uri(evo_acc->source_url); - also can contain foo;auth=DIGEST-MD5 imap bar com - - We try to get "foo imap free fr". - */ - - // check for embedded @ and then look for first colon after that - - const char *at = strchr (evo_acc->source_url + 7, '@'); - - account_name = g_strndup (evo_acc->source_url + 7, - (strchr (at, ';') - 1) - (evo_acc->source_url + 7)); - if (account_name) { tracker_log ("Found imap account %s", account_name); @@ -1509,12 +1539,17 @@ tracker_debug ("Account name for summary file is %s and path is %s", account_name, (*summary)->path); - if (strstr (evo_acc->source_url, account_name)) { + gchar* source_account_name = get_account_name_from_imap_uri(evo_acc->source_url); + + if (source_account_name != NULL) + if (!strcmp(source_account_name, account_name)) { (*summary)->associated_account = evo_acc; g_free (account_name); + g_free (source_account_name); goto loop_exit; } g_free (account_name); + g_free (source_account_name); break; }