X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-folder.c;h=57e865aca0c7cea4aef4420b50f8dc66c17802b6;hp=e8d37daa11a0cdc834e81688a734e48b8549fa84;hb=9d1b442e15c3234388ac93a5b08d5904f3ca54c9;hpb=a0fe83361800a65d99c68d7352f49eed748a930e diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index e8d37da..57e865a 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -31,11 +31,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -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 = @@ -148,17 +168,20 @@ modest_tny_folder_get_rules (TnyFolder *folder) break; } } else { - ModestTransportStoreProtocol proto; + ModestProtocolRegistry *protocol_registry; + ModestProtocolType protocol_type; TnyFolderType folder_type; TnyAccount *account; + protocol_registry = modest_runtime_get_protocol_registry (); + account = modest_tny_folder_get_account ((TnyFolder*)folder); if (!account) return -1; /* no account: nothing is allowed */ - proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account)); + protocol_type = modest_tny_account_get_protocol_type (account); - if (proto == MODEST_PROTOCOL_STORE_IMAP) { + if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS)) { rules = 0; } else { /* pop, nntp, ... */ @@ -245,10 +268,12 @@ modest_tny_folder_is_memory_card_folder (TnyFolder *folder) return FALSE; const gchar* account_id = tny_account_get_id (account); - if (!account_id) + if (!account_id) { + g_object_unref (account); return FALSE; + } - g_object_unref (G_OBJECT(account)); + g_object_unref (account); return (strcmp (account_id, MODEST_MMC_ACCOUNT_ID) == 0); } @@ -328,7 +353,7 @@ modest_tny_folder_get_header_unique_id (TnyHeader *header) { TnyFolder *folder; gchar *url, *retval; - const gchar *uid; + gchar *uid; g_return_val_if_fail (TNY_IS_HEADER (header), NULL); @@ -337,9 +362,10 @@ modest_tny_folder_get_header_unique_id (TnyHeader *header) return NULL; url = tny_folder_get_url_string (folder); - uid = tny_header_get_uid (header); + uid = tny_header_dup_uid (header); retval = g_strjoin ("/", url, uid, NULL); + g_free (uid); g_free (url); g_object_unref (folder);