X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-platform.c;h=c0690cf0903ed4bd8674dec0d472a69b4d165763;hp=aeacf424d5fca71eff598dadee8939b296b92e7f;hb=83cfbd96aa351d1ffc91d409cacb26ad1ec7df2d;hpb=d75d9dd5ca834f0212b11ad190bda939a44e1345 diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index aeacf42..c0690cf 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -42,7 +42,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -91,6 +94,9 @@ #define COMMON_FOLDER_DIALOG_ENTRY "entry" #define COMMON_FOLDER_DIALOG_ACCOUNT_PICKER "account-picker" +#define FOLDER_PICKER_CURRENT_FOLDER "current-folder" +#define MODEST_ALARMD_APPID PACKAGE_NAME + static void _modest_platform_play_email_tone (void); @@ -459,7 +465,7 @@ modest_platform_show_uri_popup (const gchar *uri) GSList *node; popup_info->actions = actions_list; popup_info->uri = g_strdup (uri); - + for (node = actions_list; node != NULL; node = g_slist_next (node)) { GtkWidget *menu_item; const gchar *action_name; @@ -471,7 +477,7 @@ modest_platform_show_uri_popup (const gchar *uri) g_object_set_data (G_OBJECT(menu_item), HILDON_OSSO_URI_ACTION, (gpointer)action_name); /* hack */ g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (activate_uri_popup_item), popup_info); - + if (hildon_uri_is_default_action (action, NULL)) { gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); } else { @@ -481,25 +487,15 @@ modest_platform_show_uri_popup (const gchar *uri) } } - /* always add the copy item */ - GtkWidget* menu_item = gtk_menu_item_new_with_label (dgettext("osso-uri", - "uri_link_copy_link_location")); - g_object_set_data_full (G_OBJECT(menu_item), HILDON_OSSO_URI_ACTION, - g_strconcat (URI_ACTION_COPY, uri, NULL), - g_free); - g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (activate_uri_popup_item),NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); - /* and what to do when the link is deleted */ g_signal_connect (G_OBJECT (menu), "delete-event", G_CALLBACK (delete_uri_popup), popup_info); gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time ()); - + } else { hildon_banner_show_information (NULL, NULL, _("mcen_ib_unsupported_link")); } - + return TRUE; } @@ -518,7 +514,7 @@ modest_platform_get_icon (const gchar *name, guint icon_size) */ if (!name || strlen(name) == 0) return NULL; - + current_theme = gtk_icon_theme_get_default (); pixbuf = gtk_icon_theme_load_icon (current_theme, name, icon_size, GTK_ICON_LOOKUP_NO_SVG, @@ -568,10 +564,18 @@ entry_insert_text (GtkEditable *editable, g_free (msg); g_free (tmp); } else { + gint insert_length; + + insert_length = g_utf8_strlen (text, -1); + + if (insert_length + chars_length >= 20) { + hildon_banner_show_information (gtk_widget_get_parent (GTK_WIDGET (data)), NULL, + _CS("ckdg_ib_maximum_characters_reached")); + } /* Write the text in the entry if it's valid */ g_signal_handlers_block_by_func (editable, (gpointer) entry_insert_text, data); - gtk_editable_insert_text (editable, text, length, position); + gtk_editable_insert_text (editable, text, MIN (chars_length + insert_length, 20), position); g_signal_handlers_unblock_by_func (editable, (gpointer) entry_insert_text, data); } @@ -595,11 +599,11 @@ entry_changed (GtkEditable *editable, g_return_if_fail (chars != NULL); - if (g_utf8_strlen (chars,-1) >= 20) + if (g_utf8_strlen (chars,-1) >= 20) { hildon_banner_show_information (gtk_widget_get_parent (GTK_WIDGET (user_data)), NULL, _CS("ckdg_ib_maximum_characters_reached")); - else - gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars)); + } + gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars)); /* Free */ g_list_free (buttons); @@ -630,16 +634,10 @@ on_response (GtkDialog *dialog, exists = FALSE; if (picker != NULL) { - const gchar *active_id; - active_id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (picker)); - parent = TNY_FOLDER_STORE ( - modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), - active_id, - TNY_ACCOUNT_TYPE_STORE)); - } else { - g_object_ref (parent); + parent = g_object_get_data (G_OBJECT (picker), FOLDER_PICKER_CURRENT_FOLDER); } + /* Look for another folder with the same name */ if (modest_tny_folder_has_subfolder_with_name (parent, new_name, @@ -668,93 +666,179 @@ on_response (GtkDialog *dialog, g_signal_stop_emission_by_name (dialog, "response"); } - g_object_unref (parent); } -static gint -order_by_acc_name (gconstpointer a, - gconstpointer b) +typedef struct _FolderChooserData { + TnyFolderStore *store; + GtkWidget *dialog; +} FolderChooserData; + +static void +folder_chooser_activated (ModestFolderView *folder_view, + TnyFolderStore *folder, + FolderChooserData *userdata) { - ModestPair *pair_a, *pair_b; + userdata->store = folder; + gtk_dialog_response (GTK_DIALOG (userdata->dialog), GTK_RESPONSE_OK); +} + +static TnyFolderStore * +folder_chooser_dialog_run (ModestFolderView *original) +{ + GtkWidget *folder_view; + FolderChooserData userdata = {NULL, NULL}; + GtkWidget *pannable; + const gchar *visible_id = NULL; + + userdata.dialog = hildon_dialog_new (); + pannable = hildon_pannable_area_new (); + folder_view = modest_platform_create_folder_view (NULL); + modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view), + MODEST_FOLDER_VIEW_FILTER_CAN_HAVE_FOLDERS); + + modest_folder_view_copy_model (MODEST_FOLDER_VIEW (original), + MODEST_FOLDER_VIEW (folder_view)); + + visible_id = + modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(original)); + modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(folder_view), + visible_id); - pair_a = (ModestPair *) a; - pair_b = (ModestPair *) b; + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (userdata.dialog)->vbox), pannable); + gtk_container_add (GTK_CONTAINER (pannable), folder_view); + gtk_widget_set_size_request (pannable, -1, 320); - if (pair_a->second && pair_b->second) { - gint compare = g_utf8_collate ((gchar *) pair_a->second, - (gchar *) pair_b->second); - if (compare > 0) - compare = -1; - else if (compare < 0) - compare = 1; + gtk_widget_show (folder_view); + gtk_widget_show (pannable); + gtk_widget_show (userdata.dialog); + g_signal_connect (G_OBJECT (folder_view), "folder-activated", + G_CALLBACK (folder_chooser_activated), + (gpointer) &userdata); - return compare; + gtk_dialog_run (GTK_DIALOG (userdata.dialog)); + gtk_widget_destroy (userdata.dialog); + + return userdata.store; +} + +static gchar * +folder_store_get_display_name (TnyFolderStore *store) +{ + if (TNY_IS_ACCOUNT (store)) { + return g_strdup (tny_account_get_name (TNY_ACCOUNT (store))); } else { - return 0; + gchar *fname; + TnyFolderType type = TNY_FOLDER_TYPE_UNKNOWN; + + fname = g_strdup (tny_folder_get_name (TNY_FOLDER (store))); + type = tny_folder_get_folder_type (TNY_FOLDER (store)); + if (modest_tny_folder_is_local_folder (TNY_FOLDER (store)) || + modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store))) { + type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (store)); + if (type != TNY_FOLDER_TYPE_UNKNOWN) { + 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 (store)); + } + } + + if (type == TNY_FOLDER_TYPE_INBOX) { + g_free (fname); + fname = g_strdup (_("mcen_me_folder_inbox")); + } + return fname; } } -static ModestPairList * -get_folders_accounts_list (void) +static void +folder_picker_set_store (GtkButton *button, TnyFolderStore *store) { - GSList *list = NULL; - GSList *cursor, *account_names; - ModestAccountMgr *account_mgr; - ModestPair *pair; - - account_mgr = modest_runtime_get_account_mgr (); + gchar *name; - cursor = account_names = modest_account_mgr_account_names (account_mgr, TRUE /*only enabled*/); - while (cursor) { - gchar *account_name; - ModestAccountSettings *settings; - ModestServerAccountSettings *store_settings; + if (store == NULL) { + g_object_set_data (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, NULL); + } else { + GdkPixbuf *pixbuf; + const gchar *icon_name = NULL; + + g_object_ref (store); + g_object_set_data_full (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, + store, (GDestroyNotify) g_object_unref); + name = folder_store_get_display_name (store); + hildon_button_set_value (HILDON_BUTTON (button), name); + g_free (name); + + /* Select icon */ + if (TNY_IS_ACCOUNT (store)) { + if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (store))) + icon_name = MODEST_FOLDER_ICON_LOCAL_FOLDERS; + else if (modest_tny_account_is_memory_card_account (TNY_ACCOUNT (store))) + icon_name = MODEST_FOLDER_ICON_MMC; + else + icon_name = MODEST_FOLDER_ICON_ACCOUNT; + } else { + if (modest_tny_folder_is_remote_folder (TNY_FOLDER (store))) { + TnyFolderType type = modest_tny_folder_guess_folder_type (TNY_FOLDER (store)); + switch (type) { + case TNY_FOLDER_TYPE_INBOX: + icon_name = MODEST_FOLDER_ICON_INBOX; + break; + default: + icon_name = MODEST_FOLDER_ICON_ACCOUNT; + } + } else if (modest_tny_folder_is_local_folder (TNY_FOLDER (store))) + icon_name = MODEST_FOLDER_ICON_NORMAL; + else if (modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store))) + icon_name = MODEST_FOLDER_ICON_MMC_FOLDER; + } - account_name = (gchar*)cursor->data; + /* Set icon */ + pixbuf = modest_platform_get_icon (icon_name, MODEST_ICON_SIZE_SMALL); - settings = modest_account_mgr_load_account_settings (account_mgr, account_name); - if (!settings) { - g_printerr ("modest: failed to get account data for %s\n", account_name); - continue; - } - store_settings = modest_account_settings_get_store_settings (settings); - - /* don't display accounts not able to show folders */ - if (modest_server_account_settings_get_account_name (store_settings) != NULL) { - ModestProtocolType protocol_type; - - protocol_type = modest_server_account_settings_get_protocol (store_settings); - /* we cannot create folders on accounts without folders */ - if (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (), - protocol_type, - MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS)) { - if (modest_account_settings_get_enabled (settings)) { - - pair = modest_pair_new ( - g_strdup (account_name), - g_strdup (modest_account_settings_get_display_name (settings)), - FALSE); - list = g_slist_insert_sorted (list, pair, order_by_acc_name); - } - } + if (pixbuf) { + hildon_button_set_image (HILDON_BUTTON (button), + gtk_image_new_from_pixbuf (pixbuf)); + g_object_unref (pixbuf); } + } +} + +static void +folder_picker_clicked (GtkButton *button, + ModestFolderView *folder_view) +{ + TnyFolderStore *store; - g_object_unref (store_settings); - g_object_unref (settings); - cursor = cursor->next; + store = folder_chooser_dialog_run (folder_view); + if (store) { + folder_picker_set_store (GTK_BUTTON (button), store); } +} - /* Create also entries for local account and mmc */ - pair = modest_pair_new (g_strdup (MODEST_LOCAL_FOLDERS_ACCOUNT_ID), - g_strdup (MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME), - FALSE); - list = g_slist_insert_sorted (list, pair, order_by_acc_name); +static GtkWidget * +folder_picker_new (ModestFolderView *folder_view, TnyFolderStore *suggested) +{ + GtkWidget *button; - /* TODO: add mmc account */ + button = hildon_button_new (MODEST_EDITABLE_SIZE, + HILDON_BUTTON_ARRANGEMENT_HORIZONTAL); - return (ModestPairList *) g_slist_reverse (list); -} + hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 1.0); + if (suggested) { + folder_picker_set_store (GTK_BUTTON (button), suggested); + } + + g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (folder_picker_clicked), folder_view); + + return button; +} static gint @@ -769,12 +853,20 @@ modest_platform_run_folder_common_dialog (GtkWindow *parent_window, TnyFolderStore **parent) { GtkWidget *accept_btn = NULL; - GtkWidget *dialog, *entry, *label_entry, *label_location, *hbox; - GtkWidget *account_picker; + GtkWidget *dialog, *entry = NULL, *label_entry = NULL, *label_location = NULL, *hbox; + GtkWidget *account_picker = NULL; GList *buttons = NULL; gint result; - GSList *accounts_list; GtkSizeGroup *sizegroup; + ModestFolderView *folder_view; + ModestWindow *folder_window; + ModestHildon2WindowMgr *window_mgr; + + window_mgr = (ModestHildon2WindowMgr *) modest_runtime_get_window_mgr (); + folder_window = modest_hildon2_window_mgr_get_folder_window (window_mgr); + g_return_val_if_fail (MODEST_IS_FOLDER_WINDOW (folder_window), GTK_RESPONSE_NONE); + + folder_view = modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (folder_window)); /* Ask the user for the folder name */ dialog = gtk_dialog_new_with_buttons (dialog_title, @@ -809,23 +901,13 @@ modest_platform_run_folder_common_dialog (GtkWindow *parent_window, } if (show_parent) { - GdkPixbuf *pixbuf; label_location = gtk_label_new (_FM("ckdg_fi_new_folder_location")); gtk_misc_set_alignment (GTK_MISC (label_location), 0.0, 0.5); gtk_size_group_add_widget (sizegroup, label_location); - accounts_list = get_folders_accounts_list (); - account_picker = modest_selector_picker_new (MODEST_EDITABLE_SIZE, - HILDON_BUTTON_ARRANGEMENT_HORIZONTAL, - accounts_list, - g_str_equal); - pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_NORMAL, - MODEST_ICON_SIZE_SMALL); - hildon_button_set_image (HILDON_BUTTON (account_picker), - gtk_image_new_from_pixbuf (pixbuf)); - hildon_button_set_alignment (HILDON_BUTTON (account_picker), 0.0, 0.5, 1.0, 1.0); + account_picker = folder_picker_new (folder_view, suggested_parent); } g_object_unref (sizegroup); @@ -879,28 +961,20 @@ modest_platform_run_folder_common_dialog (GtkWindow *parent_window, modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), parent_window); gtk_widget_show_all (GTK_WIDGET(dialog)); - + result = gtk_dialog_run (GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { if (show_name) *folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); if (show_parent) { - const gchar *active_id; - - active_id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (account_picker)); - *parent = TNY_FOLDER_STORE ( - modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), - active_id, - TNY_ACCOUNT_TYPE_STORE)); + *parent = g_object_get_data (G_OBJECT (account_picker), FOLDER_PICKER_CURRENT_FOLDER); + if (*parent) + g_object_ref (*parent); } } gtk_widget_destroy (dialog); - if (show_parent) { - modest_pair_list_free (accounts_list); - } - while (gtk_events_pending ()) gtk_main_iteration (); @@ -916,6 +990,8 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window, { gchar *real_suggested_name = NULL, *tmp = NULL; gint result; + ModestTnyAccountStore *acc_store; + TnyAccount *account; if(suggested_name == NULL) { @@ -950,6 +1026,22 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window, real_suggested_name = suggested_name; } + /* In hildon 2.2 we always suggest the archive folder as parent */ + acc_store = modest_runtime_get_account_store (); + account = modest_tny_account_store_get_mmc_folders_account (acc_store); + if (account) { + suggested_folder = (TnyFolderStore *) + modest_tny_account_get_special_folder (account, + TNY_FOLDER_TYPE_ARCHIVE); + g_object_unref (account); + account = NULL; + } + + /* If there is not archive folder then fallback to local folders account */ + if (!suggested_folder) + suggested_folder = (TnyFolderStore *) + modest_tny_account_store_get_local_folders_account (acc_store); + tmp = g_strconcat (_("mcen_fi_new_folder_name"), ":", NULL); result = modest_platform_run_folder_common_dialog (parent_window, suggested_folder, @@ -1266,7 +1358,7 @@ modest_platform_set_update_interval (guint minutes) /* Delete any existing alarm, * because we will replace it: */ if (alarm_cookie) { - if (alarmd_event_del(alarm_cookie) != 1) + if (alarmd_event_del(alarm_cookie) != 0) g_warning ("%s: alarm %d was not on the queue", __FUNCTION__, (int)alarm_cookie); alarm_cookie = 0; modest_conf_set_int (conf, MODEST_CONF_ALARM_ID, 0, NULL); @@ -1283,6 +1375,7 @@ modest_platform_set_update_interval (guint minutes) alarm_event_t *event = alarm_event_create (); alarm_event_add_actions (event, 1); alarm_action_t *action = alarm_event_get_action (event, 0); + alarm_event_set_alarm_appid (event, MODEST_ALARMD_APPID); event->alarm_time = minutes * 60; /* seconds */ /* Set recurrence every few minutes: */ @@ -1296,7 +1389,7 @@ modest_platform_set_update_interval (guint minutes) action->dbus_interface = g_strdup (MODEST_DBUS_IFACE); action->dbus_service = g_strdup (MODEST_DBUS_SERVICE); action->dbus_name = g_strdup (MODEST_DBUS_METHOD_SEND_RECEIVE); - action->flags = ALARM_ACTION_TYPE_DBUS | ALARM_ACTION_DBUS_USE_ACTIVATION; + action->flags = ALARM_ACTION_WHEN_TRIGGERED | ALARM_ACTION_TYPE_DBUS | ALARM_ACTION_DBUS_USE_ACTIVATION; /* Use ALARM_EVENT_NO_DIALOG: Otherwise, a dialog will be shown if * exec_name or dbus_path is NULL, even though we have specified no dialog text. @@ -1329,11 +1422,13 @@ modest_platform_set_update_interval (guint minutes) void modest_platform_push_email_notification(void) { - gboolean screen_on = TRUE, app_in_foreground; + gboolean screen_on, app_in_foreground; /* Get the window status */ app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ()); + screen_on = modest_window_mgr_screen_is_on (modest_runtime_get_window_mgr ()); + /* If the screen is on and the app is in the foreground we don't show anything */ if (!(screen_on && app_in_foreground)) { @@ -1829,7 +1924,7 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name, gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"), server_name); - + /* We use GTK_RESPONSE_APPLY because we want the button in the middle of OK and CANCEL the same as the browser does for example. With GTK_RESPONSE_HELP the view button is aligned @@ -1841,52 +1936,53 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name, _HL("wdgt_bd_view"), GTK_RESPONSE_APPLY, /* abusing this... */ _HL("wdgt_bd_no"), GTK_RESPONSE_CANCEL, NULL, NULL); - + g_signal_connect (G_OBJECT(note), "response", G_CALLBACK(on_cert_dialog_response), (gpointer) certificate); - + response = gtk_dialog_run(GTK_DIALOG(note)); on_destroy_dialog (note); g_free (question); - + return response == GTK_RESPONSE_OK; } gboolean -modest_platform_run_alert_dialog (const gchar* prompt, +modest_platform_run_alert_dialog (const gchar* prompt, gboolean is_question) -{ - ModestWindow *main_win; +{ + ModestWindow *top_win; + HildonWindowStack *stack; - if (!modest_window_mgr_main_window_exists (modest_runtime_get_window_mgr())) { - g_warning ("%s:\n'%s'\ndon't show dialogs if there's no main window;" - " assuming 'Cancel' for questions, 'Ok' otherwise", prompt, __FUNCTION__); - return is_question ? FALSE : TRUE; + stack = hildon_window_stack_get_default (); + top_win = MODEST_WINDOW (hildon_window_stack_peek (stack)); + + if (!top_win) { + g_warning ("%s: don't show dialogs if there's no window shown; assuming 'Cancel'", + __FUNCTION__); + return FALSE; } - main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); - g_return_val_if_fail (main_win, FALSE); /* should not happen */ - gboolean retval = TRUE; if (is_question) { - /* The Tinymail documentation says that we should show Yes and No buttons, + /* The Tinymail documentation says that we should show Yes and No buttons, * when it is a question. * Obviously, we need tinymail to use more specific error codes instead, * so we know what buttons to show. */ - GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (main_win), + GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (top_win), prompt)); modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), - GTK_WINDOW (dialog), GTK_WINDOW (main_win)); - + GTK_WINDOW (dialog), GTK_WINDOW (top_win)); + const int response = gtk_dialog_run (GTK_DIALOG (dialog)); retval = (response == GTK_RESPONSE_YES) || (response == GTK_RESPONSE_OK); - - on_destroy_dialog (dialog); + + on_destroy_dialog (dialog); } else { /* Just show the error text and use the default response: */ - modest_platform_run_information_dialog (GTK_WINDOW (main_win), + modest_platform_run_information_dialog (GTK_WINDOW (top_win), prompt, FALSE); } return retval; @@ -2112,12 +2208,19 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, gpointer user_data) { TnyAccount *account = NULL; - - if (!folder_store) { + + if (!folder_store || + (TNY_IS_MERGE_FOLDER (folder_store) && + (tny_folder_get_folder_type (TNY_FOLDER(folder_store)) == TNY_FOLDER_TYPE_OUTBOX))) { + /* We promise to instantly perform the callback, so ... */ if (callback) { - callback (FALSE, NULL, parent_window, NULL, user_data); - } + GError *error = NULL; + g_set_error (&error, TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_UNKNOWN, + "Unable to move or not found folder"); + callback (FALSE, error, parent_window, NULL, user_data); + g_error_free (error); + } return; } else if (TNY_IS_FOLDER (folder_store)) { @@ -2239,7 +2342,7 @@ modest_platform_check_memory_low (ModestWindow *win, if (win && lowmem && visuals) modest_platform_run_information_dialog ( GTK_WINDOW(win), - dgettext("ke-recv","memr_ib_operation_disabled"), + _KR("memr_ib_operation_disabled"), TRUE); if (lowmem) @@ -2373,6 +2476,9 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, G_CALLBACK (on_move_to_dialog_folder_activated), dialog); + tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (*folder_view), + (TnyAccountStore *) modest_runtime_get_account_store ()); + /* Create pannable and add it to the dialog */ folder_view_container = hildon_pannable_area_new (); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container); @@ -2390,16 +2496,16 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, TnyList * modest_platform_get_list_to_move (ModestWindow *window) { + TnyList *list = NULL; + if (MODEST_IS_HEADER_WINDOW (window)) { ModestHeaderView *header_view; header_view = modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window)); - - return modest_header_view_get_selected_headers (header_view); + list = modest_header_view_get_selected_headers (header_view); } else if (MODEST_IS_FOLDER_WINDOW (window)) { ModestFolderView *folder_view; TnyFolderStore *selected_folder; - TnyList *list; list = TNY_LIST (tny_simple_list_new ()); folder_view = modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window)); @@ -2409,7 +2515,18 @@ modest_platform_get_list_to_move (ModestWindow *window) g_object_unref (selected_folder); } return list; + } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) { + TnyHeader *header; + + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (window)); + if (header) { + list = TNY_LIST (tny_simple_list_new ()); + tny_list_prepend (list, G_OBJECT (header)); + g_object_unref (header); + } } else { - return NULL; + g_return_val_if_reached (NULL); } + + return list; }