#include <tny-camel-msg.h>
#include <tny-camel-bs-mime-part.h>
#include <tny-camel-bs-msg.h>
+#include <gdk/gdkx.h>
+#include <X11/Xatom.h>
+#include <X11/XKBlib.h>
+#include <X11/Xdmcp.h>
#define MYDOCS_ENV "MYDOCSDIR"
#define DOCS_FOLDER ".documents"
static void update_branding (ModestMsgViewWindow *self);
static void sync_flags (ModestMsgViewWindow *self);
+static gboolean on_realize (GtkWidget *widget,
+ gpointer userdata);
+
/* list my signals */
enum {
MSG_CHANGED_SIGNAL,
priv->remove_attachment_banner = NULL;
priv->msg_uid = NULL;
priv->other_body = NULL;
-
+
priv->sighandlers = NULL;
-
+
/* Init window */
init_window (MODEST_MSG_VIEW_WINDOW(obj));
-
+
hildon_program_add_window (hildon_program_get_instance(),
HILDON_WINDOW(obj));
+ /* Grab the zoom keys, it will be used for Zoom and not for
+ changing volume */
+ g_signal_connect (G_OBJECT (obj), "realize",
+ G_CALLBACK (on_realize),
+ NULL);
}
static void
TNY_ACCOUNT (account),
(ModestConnectedPerformer) save_mime_part_to_file_connect_handler,
info);
+
+ if (account)
+ g_object_unref (account);
+
return FALSE;
}
if (TNY_IS_CAMEL_BS_MIME_PART (pair->part) &&
!tny_camel_bs_mime_part_is_fetched (TNY_CAMEL_BS_MIME_PART (pair->part))) {
- g_idle_add ((GSourceFunc) save_mime_part_to_file_connect_idle, info);
- return NULL;
+ gboolean check_online = TRUE;
+ ModestMsgViewWindowPrivate *priv = NULL;
+
+ /* Check if we really need to connect to save the mime part */
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (info->window);
+ if (g_str_has_prefix (priv->msg_uid, "merge:")) {
+ check_online = FALSE;
+ } else {
+ TnyAccountStore *acc_store;
+ TnyAccount *account = NULL;
+
+ acc_store = (TnyAccountStore*) modest_runtime_get_account_store ();
+ account = tny_account_store_find_account (acc_store, priv->msg_uid);
+
+ if (account) {
+ if (tny_account_get_connection_status (account) ==
+ TNY_CONNECTION_STATUS_CONNECTED)
+ check_online = FALSE;
+ g_object_unref (account);
+ } else {
+ check_online = !tny_device_is_online (tny_account_store_get_device (acc_store));
+ }
+ }
+
+ if (check_online) {
+ g_idle_add ((GSourceFunc) save_mime_part_to_file_connect_idle, info);
+ return NULL;
+ }
}
info->result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0644);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
+static gboolean
+msg_is_attachment (TnyList *mime_parts)
+{
+ TnyIterator *iter;
+ gboolean retval = FALSE;
+
+ if (tny_list_get_length (mime_parts) > 1)
+ return FALSE;
+
+ iter = tny_list_create_iterator (mime_parts);
+ if (iter) {
+ TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter));
+ if (part) {
+ if (TNY_IS_MSG (part))
+ retval = TRUE;
+ g_object_unref (part);
+ }
+ g_object_unref (iter);
+ }
+ return retval;
+}
+
void
modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
TnyList *mime_parts)
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
if (mime_parts == NULL) {
+ gboolean allow_msgs = FALSE;
+
/* In Hildon 2.2 save and delete operate over all the attachments as there's no
* selection available */
mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
- if (mime_parts && !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) {
+
+ /* Check if the message is composed by an unique MIME
+ part whose content disposition is attachment. There
+ could be messages like this:
+
+ Date: Tue, 12 Jan 2010 20:40:59 +0000
+ From: <sender@example.org>
+ To: <recipient@example.org>
+ Subject: no body
+ Content-Type: image/jpeg
+ Content-Disposition: attachment; filename="bug7718.jpeg"
+
+ whose unique MIME part is the message itself whose
+ content disposition is attachment
+ */
+ if (mime_parts && msg_is_attachment (mime_parts))
+ allow_msgs = TRUE;
+
+ if (mime_parts &&
+ !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, allow_msgs)) {
g_object_unref (mime_parts);
return;
}
g_object_unref (header);
}
}
+
+static gboolean
+on_realize (GtkWidget *widget,
+ gpointer userdata)
+{
+ GdkDisplay *display;
+ Atom atom;
+ unsigned long val = 1;
+
+ display = gdk_drawable_get_display (widget->window);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_ZOOM_KEY_ATOM");
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (widget->window), atom,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &val, 1);
+
+ return FALSE;
+}