#include <modest-mail-operation-queue.h>
#include <modest-runtime.h>
#include <modest-count-stream.h>
+#include <modest-ui-constants.h>
#define GET_SIZE_BUFFER_SIZE 128
gchar *header_content_type;
header_content_type = modest_tny_mime_part_get_content_type (mime_part);
if ((g_str_has_prefix (header_content_type, "message/rfc822") ||
- g_str_has_prefix (header_content_type, "multipart/") ||
- g_str_has_prefix (header_content_type, "text/"))) {
+ g_str_has_prefix (header_content_type, "multipart/"))) {
+ file_icon_name =
+ modest_platform_get_file_icon_name (
+ NULL, "message/rfc822", NULL);
+ } else if (g_str_has_prefix (header_content_type, "text/")) {
file_icon_name =
modest_platform_get_file_icon_name (
NULL, tny_mime_part_get_content_type (mime_part), NULL);
g_object_unref (header);
}
} else {
+ gboolean is_other_body = FALSE;
filename = g_strdup (tny_mime_part_get_filename (mime_part));
+ if (filename == NULL) {
+ gchar *description;
+ description = modest_tny_mime_part_get_header_value (mime_part, "Content-Description");
+ if (description) {
+ g_strstrip (description);
+ filename = description;
+ }
+ if (!filename || filename[0] == '\0') {
+ g_free (filename);
+ filename = g_strdup (_("mail_va_no_subject"));
+ }
+ is_other_body = TRUE;
+ }
if (priv->is_purged) {
file_icon_name = modest_platform_get_file_icon_name (NULL, NULL, NULL);
} else {
- file_icon_name = modest_platform_get_file_icon_name (
- filename, modest_tny_mime_part_get_content_type (mime_part), NULL);
- show_size = TRUE;
+ if (is_other_body) {
+ file_icon_name = modest_platform_get_file_icon_name (NULL, "message/rfc822", NULL);
+ } else {
+ file_icon_name = modest_platform_get_file_icon_name (
+ filename, modest_tny_mime_part_get_content_type (mime_part), NULL);
+ show_size = TRUE;
+ }
}
}
gtk_label_set_text (GTK_LABEL (priv->size_view), "");
if (show_size && priv->detect_size) {
+ gchar *disposition;
+
+ disposition = modest_tny_mime_part_get_header_value (mime_part, "Content-Disposition");
+ if (disposition) {
+ const gchar *size_tmp;
+ size_tmp = strstr (disposition, "size=");
+ if (size_tmp) size_tmp += strlen("size=");
+ if (size_tmp) {
+ gchar *disposition_value;
+ const gchar *size_end;
+ size_end = strstr (size_tmp, ";");
+ if (size_end == NULL) {
+ disposition_value = g_strdup (size_tmp);
+ } else {
+ disposition_value = g_strndup (size_tmp, size_end - size_tmp);
+ }
+ if (disposition_value && disposition_value[0] != '\0') {
+ priv->size = atoll (disposition_value);
+ if (priv->size != 0) {
+ show_size = FALSE;
+ update_size_label (MODEST_ATTACHMENT_VIEW (self));
+ }
+ }
+ g_free (disposition_value);
+ }
+
+ g_free (disposition);
+ }
+ }
+
+ if (show_size && priv->detect_size) {
g_object_ref (self);
if (!priv->get_size_stream)
priv->get_size_stream = modest_count_stream_new ();
ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (instance);
PangoContext *context;
GtkWidget *box = NULL;
+ GtkWidget *icon_alignment = NULL;
#ifdef MODEST_TOOLKIT_HILDON2
PangoAttrList *attr_list;
#endif
priv->mime_part = NULL;
+ icon_alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (icon_alignment), 0, 0, 0, MODEST_MARGIN_DEFAULT);
priv->icon = gtk_image_new ();
priv->filename_view = gtk_label_new ("");
gtk_label_set_line_wrap (GTK_LABEL (priv->filename_view), FALSE);
priv->detect_size = TRUE;
box = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), priv->icon, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (icon_alignment), priv->icon);
+ gtk_box_pack_start (GTK_BOX (box), icon_alignment, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), priv->filename_view, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box), priv->size_view, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (instance), box);