From 8125ec9d64e509b2238ff58a8cd905791f717c3e Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 25 Jul 2007 16:03:50 +0000 Subject: [PATCH] * make the memory card Archive folder a localized one, make sure the folder rules understand it's a special folder pmo-trunk-r2795 --- src/dbus_api/modest-dbus-callbacks.c | 4 +++- src/maemo/modest-main-window.c | 2 +- src/maemo/modest-msg-edit-window.c | 2 +- src/modest-init.c | 3 ++- src/modest-local-folder-info.c | 8 +++++--- src/modest-tny-account.c | 2 +- src/modest-tny-folder.c | 21 ++++++++++----------- src/modest-tny-folder.h | 2 +- src/modest-tny-local-folders-account.c | 2 +- src/modest-ui-actions.c | 2 +- src/widgets/modest-details-dialog.c | 2 +- src/widgets/modest-folder-view.c | 11 ++++++----- 12 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index f913111..6d5f4fe 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -545,9 +545,11 @@ on_idle_open_message (gpointer user_data) folder = tny_msg_get_folder (msg); /* Drafts will be opened in the editor, instead of the viewer, as per the UI spec: */ + /* FIXME: same should happen for Outbox; not enabling that, as the handling + * of edited messages is not clear in that case */ gboolean is_draft = FALSE; if (folder && modest_tny_folder_is_local_folder (folder) && - (modest_tny_folder_get_local_folder_type (folder) == TNY_FOLDER_TYPE_DRAFTS)) { + (modest_tny_folder_get_local_or_mmc_folder_type (folder) == TNY_FOLDER_TYPE_DRAFTS)) { is_draft = TRUE; } diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 2768c51..4f6d391 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -2261,7 +2261,7 @@ modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, show_reply = show_forward = show_cancel_send = show_clipboard = show_delete = FALSE; } else if (TNY_IS_FOLDER (folder_store)) { if (modest_tny_folder_is_local_folder (TNY_FOLDER (folder_store))) { - TnyFolderType folder_type = modest_tny_folder_get_local_folder_type ( + TnyFolderType folder_type = modest_tny_folder_get_local_or_mmc_folder_type ( TNY_FOLDER (folder_store)); switch (folder_type) { case TNY_FOLDER_TYPE_DRAFTS: diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index b2625f6..8de04e3 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -671,7 +671,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg) msg_folder = tny_msg_get_folder (msg); if (msg_folder) { if (modest_tny_folder_is_local_folder (msg_folder) && - modest_tny_folder_get_local_folder_type (msg_folder) == TNY_FOLDER_TYPE_DRAFTS) + modest_tny_folder_get_local_or_mmc_folder_type (msg_folder) == TNY_FOLDER_TYPE_DRAFTS) priv->draft_msg = g_object_ref(msg); g_object_unref (msg_folder); } diff --git a/src/modest-init.c b/src/modest-init.c index 5ef1a0f..f13483f 100644 --- a/src/modest-init.c +++ b/src/modest-init.c @@ -441,7 +441,8 @@ modest_init_local_folders (const gchar* location_filepath) */ gchar *dir = g_build_filename (maildir_path, - "Archive", NULL); + modest_local_folder_info_get_type_name(TNY_FOLDER_TYPE_ARCHIVE), + NULL); const gboolean created = modest_init_one_local_folder (dir); g_free(dir); diff --git a/src/modest-local-folder-info.c b/src/modest-local-folder-info.c index 60bf668..bda1474 100644 --- a/src/modest-local-folder-info.c +++ b/src/modest-local-folder-info.c @@ -54,7 +54,7 @@ const ModestLocalFolder ModestLocalFolderMap[] = { * { TNY_FOLDER_TYPE_OUTBOX, "contacts", N_("Contacts")}, { TNY_FOLDER_TYPE_OUTBOX, "calendar", N_("Calendar")}, */ - { TNY_FOLDER_TYPE_ARCHIVE, "archive", N_("Archive")} + { TNY_FOLDER_TYPE_ARCHIVE, "archive", N_("mcen_me_folder_archive")} }; @@ -114,7 +114,8 @@ modest_local_folder_info_get_maildir_path (const gchar* location_filepath) NULL); } -gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name) +gchar* +modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name) { /* This directory should contain an "outbox" child directory: */ return g_build_filename (g_get_home_dir(), @@ -124,7 +125,8 @@ gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar NULL); } -gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name) +gchar* +modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name) { gchar *path_to_account_folder = modest_per_account_local_outbox_folder_info_get_maildir_path(account_name); diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 4bc365c..070f3a2 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -130,7 +130,7 @@ modest_tny_account_get_special_folder (TnyAccount *account, TnyFolder *folder = TNY_FOLDER (tny_iterator_get_current (iter)); if (folder) { - if (modest_tny_folder_get_local_folder_type (folder) == special_type) { + if (modest_tny_folder_get_local_or_mmc_folder_type (folder) == special_type) { special_folder = folder; break; /* Leaving a ref for the special_folder return value. */ } diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index 588c1f0..f82a5c8 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -90,7 +90,7 @@ modest_tny_folder_guess_folder_type (const TnyFolder *folder) g_return_val_if_fail (TNY_IS_FOLDER(folder), TNY_FOLDER_TYPE_UNKNOWN); if (modest_tny_folder_is_local_folder ((TnyFolder*)folder)) - type = modest_tny_folder_get_local_folder_type ((TnyFolder*)folder); + type = modest_tny_folder_get_local_or_mmc_folder_type ((TnyFolder*)folder); else type = tny_folder_get_folder_type (TNY_FOLDER (folder)); @@ -116,7 +116,7 @@ modest_tny_folder_get_rules (TnyFolder *folder) if (modest_tny_folder_is_local_folder (folder) || modest_tny_folder_is_memory_card_folder (folder)) { - type = modest_tny_folder_get_local_folder_type (folder); + type = modest_tny_folder_get_local_or_mmc_folder_type (folder); switch (type) { case TNY_FOLDER_TYPE_OUTBOX: @@ -193,7 +193,7 @@ modest_tny_folder_is_local_folder (TnyFolder *folder) TnyAccount* account = tny_folder_get_account ((TnyFolder*)folder); if (!account) return FALSE; - + /* Outbox is a special case, using a derived TnyAccount: */ if (MODEST_IS_TNY_OUTBOX_ACCOUNT (account)) { g_object_unref (G_OBJECT(account)); @@ -237,10 +237,13 @@ modest_tny_folder_is_memory_card_folder (TnyFolder *folder) TnyFolderType -modest_tny_folder_get_local_folder_type (TnyFolder *folder) +modest_tny_folder_get_local_or_mmc_folder_type (TnyFolder *folder) { g_return_val_if_fail (folder, TNY_FOLDER_TYPE_UNKNOWN); - + g_return_val_if_fail (modest_tny_folder_is_local_folder(folder)|| + modest_tny_folder_is_memory_card_folder(folder), + TNY_FOLDER_TYPE_UNKNOWN); + /* The merge folder is a special case, * used to merge the per-account local outbox folders. * and can have no get_account() implementation. @@ -261,11 +264,7 @@ modest_tny_folder_get_local_folder_type (TnyFolder *folder) g_object_unref (parent_account); parent_account = NULL; } - - - g_return_val_if_fail (modest_tny_folder_is_local_folder(folder), - TNY_FOLDER_TYPE_UNKNOWN); - + /* we need to use the camel functions, because we want the * _full name_, that is, the full path name of the folder, * to distinguish between 'Outbox' and 'myfunkyfolder/Outbox' @@ -290,7 +289,7 @@ modest_tny_folder_is_outbox_for_account (TnyFolder *folder, TnyAccount *account) g_return_val_if_fail(folder, FALSE); g_return_val_if_fail(account, FALSE); - if (modest_tny_folder_get_local_folder_type (folder) != TNY_FOLDER_TYPE_OUTBOX) + if (modest_tny_folder_get_local_or_mmc_folder_type (folder) != TNY_FOLDER_TYPE_OUTBOX) return FALSE; return TRUE; diff --git a/src/modest-tny-folder.h b/src/modest-tny-folder.h index d084390..46df467 100644 --- a/src/modest-tny-folder.h +++ b/src/modest-tny-folder.h @@ -114,7 +114,7 @@ modest_tny_folder_is_memory_card_folder (TnyFolder *folder); * * Returns: TRUE if it's a local folder, FALSE otherwise */ -TnyFolderType modest_tny_folder_get_local_folder_type (TnyFolder *folder); +TnyFolderType modest_tny_folder_get_local_or_mmc_folder_type (TnyFolder *folder); /** diff --git a/src/modest-tny-local-folders-account.c b/src/modest-tny-local-folders-account.c index 093e156..2efb499 100644 --- a/src/modest-tny-local-folders-account.c +++ b/src/modest-tny-local-folders-account.c @@ -242,7 +242,7 @@ add_account_folders_to_merged_folder (TnyAccount *account, TnyMergeFolder* merge * because these are just left-over from earlier Modest versions * that put the outbox there: */ if (is_actual_local_folders_account) { - const TnyFolderType type = modest_tny_folder_get_local_folder_type (folder); + const TnyFolderType type = modest_tny_folder_get_local_or_mmc_folder_type (folder); if (type == TNY_FOLDER_TYPE_OUTBOX) { add = FALSE; } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index d17f3a3..46e99ef 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -742,7 +742,7 @@ open_msg_cb (ModestMailOperation *mail_op, /* Gets folder type (OUTBOX headers will be opened in edit window */ if (modest_tny_folder_is_local_folder (folder)) - folder_type = modest_tny_folder_get_local_folder_type (folder); + folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder); /* If the header is in the drafts folder then open the editor, else the message view window */ diff --git a/src/widgets/modest-details-dialog.c b/src/widgets/modest-details-dialog.c index 05288a3..a12e759 100644 --- a/src/widgets/modest-details-dialog.c +++ b/src/widgets/modest-details-dialog.c @@ -302,7 +302,7 @@ modest_details_dialog_set_folder_default (ModestDetailsDialog *self, /* Different names for the local folders */ if (modest_tny_folder_is_local_folder (folder)) { - gint type = modest_tny_folder_get_local_folder_type (folder); + gint type = modest_tny_folder_get_local_or_mmc_folder_type (folder); if (type != TNY_FOLDER_TYPE_UNKNOWN) name = g_strdup(modest_local_folder_info_get_type_display_name (type)); } diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index e026ccb..f334bf0 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -319,7 +319,7 @@ static void on_get_mmc_account_name (TnyStoreAccount* account, gpointer user_dat /* printf ("DEBU1G: %s: account name=%s\n", __FUNCTION__, tny_account_get_name (TNY_ACCOUNT(account))); */ GetMmcAccountNameData *data = (GetMmcAccountNameData*)user_data; - + if (!strings_are_equal ( tny_account_get_name(TNY_ACCOUNT(account)), data->previous_name)) { @@ -377,8 +377,9 @@ text_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer, if (type != TNY_FOLDER_TYPE_ROOT) { gint number = 0; - if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance))) { - type = modest_tny_folder_get_local_folder_type (TNY_FOLDER (instance)); + if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) || + modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance))) { + type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (instance)); if (type != TNY_FOLDER_TYPE_UNKNOWN) { g_free (fname); fname = g_strdup(modest_local_folder_info_get_type_display_name (type)); @@ -1326,8 +1327,8 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2, if ((parent_type == TNY_FOLDER_TYPE_ROOT) && TNY_IS_ACCOUNT (parent_folder) && modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) { - cmp1 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_folder_type (TNY_FOLDER (folder1))); - cmp2 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_folder_type (TNY_FOLDER (folder2))); + cmp1 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (folder1))); + cmp2 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (folder2))); } g_object_unref (parent_folder); } -- 1.7.9.5