#include <osso-mem.h>
#include "hildon2/modest-hildon2-details-dialog.h"
#include "hildon2/modest-hildon2-window-mgr.h"
+#ifdef MODEST_USE_PROFILE
#include <keys_nokia.h>
#include <libprofile.h>
+#endif
#include <canberra.h>
#include <modest-datetime-formatter.h>
#include "modest-header-window.h"
#define URI_ACTION_COPY "copy:"
#define MODEST_NOTIFICATION_CATEGORY "email-message"
#define MODEST_NEW_MAIL_LIGHTING_PATTERN "PatternCommunicationEmail"
+#ifdef MODEST_USE_PROFILE
#define PROFILE_MAIL_TONE PROFILEKEY_EMAIL_ALERT_TONE
#define PROFILE_MAIL_VOLUME PROFILEKEY_EMAIL_ALERT_VOLUME
+#else
+#define MAIL_TONE "message-new-email"
+#endif
#define COMMON_FOLDER_DIALOG_ENTRY "entry"
#define COMMON_FOLDER_DIALOG_ACCOUNT_PICKER "account-picker"
g_mutex_unlock (data->mutex);
frees:
- if (data) {
- if (g_signal_handler_is_connected (account, data->handler))
- g_signal_handler_disconnect (account, data->handler);
- g_mutex_free (data->mutex);
- g_main_loop_unref (data->wait_loop);
- g_slice_free (ConnectAndWaitData, data);
- }
+ if (g_signal_handler_is_connected (account, data->handler))
+ g_signal_handler_disconnect (account, data->handler);
+ g_mutex_free (data->mutex);
+ g_main_loop_unref (data->wait_loop);
+ g_slice_free (ConnectAndWaitData, data);
conn_status = tny_account_get_connection_status (account);
return (conn_status == TNY_CONNECTION_STATUS_CONNECTED) ? TRUE: FALSE;
/* Notify. We need to do this in an idle because this function
could be called from a thread */
- notify_notification_show (NOTIFY_NOTIFICATION (notification), NULL);
+ if (!notify_notification_show (NOTIFY_NOTIFICATION (notification), NULL)) {
+ g_warning ("Failed to send notification");
+ }
/* Save id in the list */
g_object_get(G_OBJECT(notification), "id", ¬if_id, NULL);
account = TNY_ACCOUNT (g_object_ref (folder_store));
}
- if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
+ if (account && (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE)) {
if (!modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account))) {
/* No need to connect a local account */
if (callback)
static void
_modest_platform_play_email_tone (void)
{
- gchar *active_profile;
gchar *mail_tone;
- gchar *mail_volume;
gint mail_volume_int;
int ret;
ca_context *ca_con = NULL;
ca_proplist *pl = NULL;
+#ifdef MODEST_USE_PROFILE
+ gchar *active_profile;
+ gchar *mail_volume;
+
active_profile = profile_get_profile ();
mail_tone = profile_get_value (active_profile, PROFILE_MAIL_TONE);
mail_volume = profile_get_value (active_profile, PROFILE_MAIL_VOLUME);
mail_volume_int = profile_parse_int (mail_volume);
+ g_free (mail_volume);
+ g_free (active_profile);
+#else
+ mail_tone = MAIL_TONE;
+ mail_volume_int = 100;
+#endif
if (mail_tone && !strstr (mail_tone, "/")) {
gchar *tmp;
ca_context_destroy(ca_con);
}
- g_free (mail_volume);
g_free (mail_tone);
- g_free (active_profile);
}
#define MOVE_TO_DIALOG_FOLDER_VIEW "folder-view"
gtk_widget_set_sensitive (back_button, FALSE);
gtk_widget_set_sensitive (action_button, FALSE);
+ /* Need to set this here, otherwise callbacks called because
+ of filtering won't perform correctly */
+ g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS, GINT_TO_POINTER (FALSE));
+
gtk_label_set_text (GTK_LABEL (selection_label), "");
+ modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (folder_view), NULL);
modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (folder_view), TRUE);
modest_folder_view_set_style (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_FOLDERS);
hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (pannable), 0, 0);
g_object_set (G_OBJECT (folder_view),
"hildon-ui-mode", HILDON_UI_MODE_NORMAL,
NULL);
-
- g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS, GINT_TO_POINTER (FALSE));
}
static void
gtk_widget_set_sensitive (back_button, TRUE);
gtk_widget_set_sensitive (action_button, FALSE);
- g_object_set (G_OBJECT (folder_view),
- "hildon-ui-mode", HILDON_UI_MODE_EDIT,
+ /* Need to set this here, otherwise callbacks called because
+ of filtering won't perform correctly */
+ g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS, GINT_TO_POINTER (TRUE));
+
+ g_object_set (G_OBJECT (folder_view),
+ "hildon-ui-mode", HILDON_UI_MODE_EDIT,
NULL);
account = TNY_ACCOUNT (folder_store);
modest_folder_view_set_style (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_FOLDERS);
hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (pannable), 0, 0);
-
- g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS, GINT_TO_POINTER (TRUE));
}
static void
gpointer userdata)
{
GtkWidget *dialog = (GtkWidget *) userdata;
- ModestFolderView *folder_view;
-
- /* Revert the effect of show_folders filters */
- folder_view = MODEST_FOLDER_VIEW (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
- modest_folder_view_set_account_id_of_visible_server_account (folder_view, NULL);
- modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (folder_view), TRUE);
- modest_folder_view_unset_filter (folder_view, MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
- modest_folder_view_unset_filter (folder_view, MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
/* Back to show accounts */
move_to_dialog_show_accounts (dialog);
dialog = (GtkWidget *) user_data;
showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS));
- if (showing_folders) {
- move_to_dialog_set_selected_folder (dialog, selected);
- } else {
+ if (!showing_folders) {
+
folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
if (selected) {
- move_to_dialog_show_folders (dialog, selected);
+ gboolean valid;
+
+ valid = TRUE;
+ if (TNY_IS_ACCOUNT (selected) &&
+ modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (selected))) {
+ ModestProtocolType protocol_type;
+
+ protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (selected));
+ valid = !modest_protocol_registry_protocol_type_has_tag
+ (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD);
+ }
+ if (valid)
+ move_to_dialog_show_folders (dialog, selected);
}
}
}
+static void
+on_move_to_dialog_selection_changed (GtkTreeSelection *selection,
+ gpointer user_data)
+{
+ gboolean showing_folders;
+ GtkWidget *dialog;
+
+ dialog = (GtkWidget *) user_data;
+ showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS));
+ if (showing_folders) {
+ TnyFolderStore *selected;
+ GtkWidget *folder_view;
+
+ folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+ if (selected) {
+ move_to_dialog_set_selected_folder (dialog, selected);
+ g_object_unref (selected);
+ }
+ }
+}
+
+static void
+on_move_to_dialog_action_clicked (GtkButton *selection,
+ gpointer user_data)
+{
+ TnyFolderStore *selected;
+ GtkWidget *dialog;
+ GtkWidget *folder_view;
+ gboolean showing_folders;
+
+ dialog = (GtkWidget *) user_data;
+ showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS));
+ if (showing_folders) {
+ folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+ if (selected)
+ gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ }
+}
+
GtkWidget *
modest_platform_create_move_to_dialog (GtkWindow *parent_window,
GtkWidget **folder_view)
GdkPixbuf *back_pixbuf;
GtkWidget *top_vbox;
GtkWidget *action_button;
+ GtkTreeSelection *selection;
/* Create dialog. We cannot use a touch selector because we
need to use here the folder view widget directly */
gtk_widget_show (selection_label);
gtk_widget_show (action_button);
gtk_widget_show (buttons_hbox);
+ gtk_widget_show (dialog);
g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW, *folder_view);
g_object_set_data (G_OBJECT (dialog), MOVE_TO_DIALOG_BACK_BUTTON, back_button);
G_CALLBACK (on_move_to_dialog_folder_activated),
dialog);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (*folder_view));
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (on_move_to_dialog_selection_changed),
+ dialog);
+
+ g_signal_connect (action_button, "clicked",
+ G_CALLBACK (on_move_to_dialog_action_clicked),
+ dialog);
+
g_signal_connect (back_button, "clicked",
G_CALLBACK (on_move_to_dialog_back_clicked),
dialog);