* Fixes NB#86822, added some extra heuristic to properly detect the inbox folder...
authorSergio Villar Senin <svillar@igalia.com>
Tue, 15 Jul 2008 17:34:13 +0000 (17:34 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 15 Jul 2008 17:34:13 +0000 (17:34 +0000)
pmo-trunk-r5010

src/modest-local-folder-info.c
src/modest-tny-folder.c
src/widgets/modest-folder-view.c

index bda1474..c818cca 100644 (file)
@@ -41,8 +41,6 @@ typedef struct {
 const ModestLocalFolder ModestLocalFolderMap[] = {
        { TNY_FOLDER_TYPE_UNKNOWN,  "<unknown>",  N_("<Unknown>")},
        { TNY_FOLDER_TYPE_NORMAL,   "<normal>",   N_("<Normal>")},
-       /* 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,     "<root>",     N_("<root>")},
        { 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")}
 };
 
index 915c787..01763ec 100644 (file)
@@ -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 =
index 018c44d..9f27641 100644 (file)
@@ -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));