From: Sergio Villar Senin Date: Tue, 4 Aug 2009 11:38:17 +0000 (+0200) Subject: Fixes NB#128553, incorrect logical id when saving attachments in mass storage mode X-Git-Tag: 3.0.17-rc28~3 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=def18d95098bb627d13083011140685fa3e2385b Fixes NB#128553, incorrect logical id when saving attachments in mass storage mode --- diff --git a/src/hildon2/modest-maemo-utils.c b/src/hildon2/modest-maemo-utils.c index 9b63184..51c25fc 100644 --- a/src/hildon2/modest-maemo-utils.c +++ b/src/hildon2/modest-maemo-utils.c @@ -57,6 +57,9 @@ /* Label child of a captioned */ #define CAPTIONED_LABEL_CHILD "captioned-label" +#ifdef MODEST_PLATFORM_MAEMO +#define INTERNAL_MMC_USB_MODE "/system/osso/af/internal-mmc-used-over-usb" +#endif static osso_context_t *__osso_context = NULL; /* urgh global */ @@ -567,3 +570,11 @@ modest_maemo_utils_select_attachments (GtkWindow *window, TnyList *att_list, gbo return result; } + +#ifdef MODEST_PLATFORM_MAEMO +gboolean +modest_maemo_utils_in_usb_mode () +{ + return modest_conf_get_bool (modest_runtime_get_conf (), INTERNAL_MMC_USB_MODE, NULL); +} +#endif diff --git a/src/hildon2/modest-maemo-utils.h b/src/hildon2/modest-maemo-utils.h index 061ef6c..959227f 100644 --- a/src/hildon2/modest-maemo-utils.h +++ b/src/hildon2/modest-maemo-utils.h @@ -146,4 +146,16 @@ GtkWidget *modest_maemo_utils_create_group_box (const gchar *label, GtkWidget *c gboolean modest_maemo_utils_select_attachments (GtkWindow *window, TnyList *att_list, gboolean include_msgs); +#ifdef MODEST_PLATFORM_MAEMO +/** + * modest_maemo_utils_in_usb_mode: + * + * Check if the device is working in mass storage mode + * + * Returns: returns TRUE if the internal memory of the device is + * working in mass storage mode + **/ +gboolean modest_maemo_utils_in_usb_mode (); +#endif + #endif /*__MODEST_MAEMO_UTILS_H__*/ diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index d141571..e390414 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -2936,9 +2936,9 @@ save_attachments_response (GtkDialog *dialog, chooser_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); current_folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)); - if (current_folder && current_folder != '\0') { + if (current_folder && *current_folder != '\0') { GError *err = NULL; - modest_conf_set_string (modest_runtime_get_conf (), MODEST_CONF_LATEST_SAVE_ATTACHMENT_PATH, + modest_conf_set_string (modest_runtime_get_conf (), MODEST_CONF_LATEST_SAVE_ATTACHMENT_PATH, current_folder,&err); if (err != NULL) { g_debug ("Error storing latest used folder: %s", err->message); @@ -2948,8 +2948,18 @@ save_attachments_response (GtkDialog *dialog, g_free (current_folder); if (!modest_utils_folder_writable (chooser_uri)) { - hildon_banner_show_information - (NULL, NULL, _FM("sfil_ib_readonly_location")); + const gchar *err_msg; + +#ifdef MODEST_PLATFORM_MAEMO + if (modest_maemo_utils_in_usb_mode ()) { + err_msg = dgettext ("hildon-status-bar-usb", "usbh_ib_mmc_usb_connected"); + } else { + err_msg = _FM("sfil_ib_readonly_location"); + } +#else + err_msg = _FM("sfil_ib_readonly_location"); +#endif + hildon_banner_show_information (NULL, NULL, err_msg); } else { TnyIterator *iter; @@ -3004,6 +3014,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, gchar *conf_folder = NULL; gchar *filename = NULL; gchar *save_multiple_str = NULL; + const gchar *root_folder = "file:///"; g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); @@ -3056,8 +3067,15 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, save_dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_SAVE); - /* set folder */ + /* Get last used folder */ conf_folder = modest_conf_get_string (modest_runtime_get_conf (), MODEST_CONF_LATEST_SAVE_ATTACHMENT_PATH, NULL); + + /* File chooser stops working if we select "file:///" as current folder */ + if (conf_folder && g_ascii_strcasecmp (root_folder, conf_folder) != 0) { + g_free (conf_folder); + conf_folder = NULL; + } + if (conf_folder && conf_folder[0] != '\0') { gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (save_dialog), conf_folder); } else {