From: Sergio Villar Senin Date: Tue, 15 Jul 2008 17:34:13 +0000 (+0000) Subject: * Fixes NB#86822, added some extra heuristic to properly detect the inbox folder... X-Git-Tag: git_migration_finished~1270 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=b70734073cfc2ac74c63fa8e299d97cab7df7962 * Fixes NB#86822, added some extra heuristic to properly detect the inbox folder when the server does not tell us that it's indeed the INBOX folder. This heuristic both properly adds the visible name and the icon for the folder pmo-trunk-r5010 --- diff --git a/src/modest-local-folder-info.c b/src/modest-local-folder-info.c index bda1474..c818cca 100644 --- a/src/modest-local-folder-info.c +++ b/src/modest-local-folder-info.c @@ -41,8 +41,6 @@ typedef struct { const ModestLocalFolder ModestLocalFolderMap[] = { { TNY_FOLDER_TYPE_UNKNOWN, "", N_("")}, { TNY_FOLDER_TYPE_NORMAL, "", N_("")}, - /* There is no special Inbox folder for local accounts */ -/* { TNY_FOLDER_TYPE_INBOX, "inbox", N_("mcen_me_folder_inbox")}, */ { TNY_FOLDER_TYPE_OUTBOX, "outbox", N_("mcen_me_folder_outbox")}, { TNY_FOLDER_TYPE_TRASH, "trash", N_("Trash")}, { TNY_FOLDER_TYPE_JUNK, "junk", N_("Junk")}, @@ -50,10 +48,6 @@ const ModestLocalFolder ModestLocalFolderMap[] = { { TNY_FOLDER_TYPE_ROOT, "", N_("")}, { TNY_FOLDER_TYPE_NOTES, "notes", N_("Notes")}, { TNY_FOLDER_TYPE_DRAFTS, "drafts", N_("mcen_me_folder_drafts")}, -/* TODO: Do we want these? If so, they need a type ID: - * { TNY_FOLDER_TYPE_OUTBOX, "contacts", N_("Contacts")}, - { TNY_FOLDER_TYPE_OUTBOX, "calendar", N_("Calendar")}, -*/ { TNY_FOLDER_TYPE_ARCHIVE, "archive", N_("mcen_me_folder_archive")} }; diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index 915c787..01763ec 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -69,6 +69,26 @@ modest_tny_folder_guess_folder_type (TnyFolder *folder) type = modest_tny_folder_get_local_or_mmc_folder_type (folder); else type = tny_folder_get_folder_type (TNY_FOLDER (folder)); + + /* Fallback code, some servers (Dovecot in some versions) + report incorrectly that the INBOX folder is a normal + folder. Really ugly code but... */ + if (type == TNY_FOLDER_TYPE_NORMAL) { + TnyFolderStore *parent = tny_folder_get_folder_store (folder); + if (parent) { + if (TNY_IS_ACCOUNT (parent)) { + gchar *downcase = + g_ascii_strdown (tny_camel_folder_get_full_name (TNY_CAMEL_FOLDER (folder)), + -1); + + if ((strlen (downcase) == 5) && + !strncmp (downcase, "inbox", 5)) + type = TNY_FOLDER_TYPE_INBOX; + g_free (downcase); + } + g_object_unref (parent); + } + } if (type == TNY_FOLDER_TYPE_UNKNOWN) { const gchar *folder_name = diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index 018c44d..9f27641 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -402,6 +402,13 @@ text_cell_data (GtkTreeViewColumn *column, g_free (fname); fname = g_strdup (modest_local_folder_info_get_type_display_name (type)); } + } else { + /* Sometimes an special folder is reported by the server as + NORMAL, like some versions of Dovecot */ + if (type == TNY_FOLDER_TYPE_NORMAL || + type == TNY_FOLDER_TYPE_UNKNOWN) { + type = modest_tny_folder_guess_folder_type (TNY_FOLDER (instance)); + } } /* note: we cannot reliably get the counts from the tree model, we need @@ -574,9 +581,8 @@ get_folder_icons (TnyFolderType type, GObject *instance) ThreePixbufs *retval = NULL; - /* MERGE is not needed anymore as the folder now has the correct type jschmid */ - /* We include the MERGE type here because it's used to create - the local OUTBOX folder */ + /* Sometimes an special folder is reported by the server as + NORMAL, like some versions of Dovecot */ if (type == TNY_FOLDER_TYPE_NORMAL || type == TNY_FOLDER_TYPE_UNKNOWN) { type = modest_tny_folder_guess_folder_type (TNY_FOLDER (instance));