X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-tny-local-folders-account.c;h=12ee27e294af1550c47f27b270cbb22df8af37d8;hb=a018028fe65794265523c1c93b15a43c104e0e2c;hp=078183f312b42ee9dec56646f45ae2f0d3d4f55e;hpb=362784ce756b3f0e31cd451d9ac5e69b909d4053;p=modest diff --git a/src/modest-tny-local-folders-account.c b/src/modest-tny-local-folders-account.c index 078183f..12ee27e 100644 --- a/src/modest-tny-local-folders-account.c +++ b/src/modest-tny-local-folders-account.c @@ -39,6 +39,7 @@ #include #include #include +#include G_DEFINE_TYPE (ModestTnyLocalFoldersAccount, modest_tny_local_folders_account, @@ -103,8 +104,7 @@ modest_tny_local_folders_account_query_passes (TnyFolderStoreQuery *query, TnyFo { gboolean retval = FALSE; - if (query && (tny_list_get_length (tny_folder_store_query_get_items (query)) > 0)) - { + if (query && (tny_list_get_length (tny_folder_store_query_get_items (query)) > 0)) { TnyList *items = tny_folder_store_query_get_items (query); TnyIterator *iterator; iterator = tny_list_create_iterator (items); @@ -114,7 +114,7 @@ modest_tny_local_folders_account_query_passes (TnyFolderStoreQuery *query, TnyFo TnyFolderStoreQueryItem *item = (TnyFolderStoreQueryItem*) tny_iterator_get_current (iterator); if (item) { TnyFolderStoreQueryOption options = tny_folder_store_query_item_get_options (item); - regex_t *regex = tny_folder_store_query_item_get_regex (item); + const regex_t *regex = tny_folder_store_query_item_get_regex (item); if ((options & TNY_FOLDER_STORE_QUERY_OPTION_SUBSCRIBED) && tny_folder_is_subscribed (folder)) @@ -138,7 +138,7 @@ modest_tny_local_folders_account_query_passes (TnyFolderStoreQuery *query, TnyFo tny_iterator_next (iterator); } - g_object_unref (G_OBJECT (iterator)); + g_object_unref (G_OBJECT (iterator)); g_object_unref (G_OBJECT (items)); } else retval = TRUE; @@ -198,16 +198,26 @@ modest_tny_local_folders_account_folder_name_in_use (ModestTnyLocalFoldersAccoun gboolean retval; /* Check that we're not trying to create/rename any folder - with the same name that our OUTBOX */ + with the same name that our OUTBOX, DRAFT, SENT */ priv = TNY_LOCAL_FOLDERS_ACCOUNT_GET_PRIVATE (self); down_name = g_utf8_strdown (name, strlen (name)); type_name = modest_local_folder_info_get_type_name (TNY_FOLDER_TYPE_OUTBOX); - if (!strcmp (type_name, down_name)) + if (!strcmp (type_name, down_name)) { retval = TRUE; - else - retval = FALSE; - + } else { + type_name = modest_local_folder_info_get_type_name (TNY_FOLDER_TYPE_DRAFTS); + if (!strcmp (type_name, down_name)) { + retval = TRUE; + } else { + type_name = modest_local_folder_info_get_type_name (TNY_FOLDER_TYPE_SENT); + if (!strcmp (type_name, down_name)) { + retval = TRUE; + } else { + retval = FALSE; + } + } + } g_free (down_name); return retval; @@ -222,15 +232,11 @@ modest_tny_local_folders_account_add_folder_to_outbox (ModestTnyLocalFoldersAcco g_return_if_fail (MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (self)); g_return_if_fail (TNY_IS_FOLDER (per_account_outbox)); - /* We can not test it yet, because there is no API to set the - type of a folder */ -/* g_return_if_fail (tny_folder_get_folder_type (per_account_outbox) == TNY_FOLDER_TYPE_OUTBOX); */ - priv = TNY_LOCAL_FOLDERS_ACCOUNT_GET_PRIVATE (self); /* Create on-demand */ if (!priv->outbox_folder) { - priv->outbox_folder = TNY_MERGE_FOLDER (tny_merge_folder_new (_("mcen_me_folder_outbox"))); + priv->outbox_folder = TNY_MERGE_FOLDER (tny_merge_folder_new_with_ui_locker (_("mcen_me_folder_outbox"), tny_gtk_lockable_new ())); /* Set type to outbox */ tny_merge_folder_set_folder_type (priv->outbox_folder, TNY_FOLDER_TYPE_OUTBOX); @@ -239,3 +245,28 @@ modest_tny_local_folders_account_add_folder_to_outbox (ModestTnyLocalFoldersAcco /* Add outbox to the global OUTBOX folder */ tny_merge_folder_add_folder (priv->outbox_folder, per_account_outbox); } + +void +modest_tny_local_folders_account_remove_folder_from_outbox (ModestTnyLocalFoldersAccount *self, + TnyFolder *per_account_outbox) +{ + ModestTnyLocalFoldersAccountPrivate *priv; + TnyList *merged_folders = NULL; + + g_return_if_fail (MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (self)); + g_return_if_fail (TNY_IS_FOLDER (per_account_outbox)); + + priv = TNY_LOCAL_FOLDERS_ACCOUNT_GET_PRIVATE (self); + + /* Remove outbox from the global OUTBOX folder */ + tny_merge_folder_remove_folder (priv->outbox_folder, per_account_outbox); + + /* If there is no folder in the outbox the delete it */ + merged_folders = tny_simple_list_new (); + tny_merge_folder_get_folders (priv->outbox_folder, merged_folders); + if (tny_list_get_length (merged_folders) == 0) { + g_object_unref (priv->outbox_folder); + priv->outbox_folder = NULL; + } + g_object_unref (merged_folders); +}