[evolution-data-server] Unset attachment icon if no attachment found



commit 3562520ff7584fb78616bb2d9523ea0d7043286c
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 27 11:42:48 2009 +0200

    Unset attachment icon if no attachment found
    
    	** Fix for bug #478239
---
 camel/ChangeLog                              |    9 ++++++
 camel/camel-mime-message.c                   |   41 ++++++++++++++++++++++++++
 camel/camel-mime-message.h                   |    2 +
 camel/providers/imap/ChangeLog               |    7 ++++
 camel/providers/imap/camel-imap-folder.c     |    8 +++++
 camel/providers/local/ChangeLog              |    9 ++++++
 camel/providers/local/camel-maildir-folder.c |    5 ++-
 camel/providers/local/camel-mbox-folder.c    |    3 ++
 camel/providers/local/camel-mh-folder.c      |    5 ++-
 9 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/camel/ChangeLog b/camel/ChangeLog
index fe422ed..17b9be8 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-27  Milan Crha  <mcrha redhat com>
+
+	** Part of fix for bug #478239
+
+	* camel-mime-message.h: (camel_mime_message_has_attachment):
+	* camel-mime-message.c: (camel_mime_message_has_attachment),
+	(find_attachment): New helper function to check whether
+	message contains any 'attachment' part.
+
 2009-04-24  Milan Crha  <mcrha redhat com>
 
 	** Part of fix for bug #563954
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 8cb0de2..ff30515 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -1169,6 +1169,47 @@ camel_mime_message_build_mbox_from (CamelMimeMessage *message)
 	return ret;
 }
 
+static gboolean
+find_attachment (CamelMimeMessage *msg, CamelMimePart *part, void *data)
+{
+	const char *disp;
+	gboolean *found = (gboolean *)data;
+
+	g_return_val_if_fail (part != NULL, FALSE);
+
+	disp = camel_mime_part_get_disposition (part);
+
+	if (disp) {
+		CamelContentDisposition *cd = camel_content_disposition_decode (disp);
+
+		if (cd) {
+			*found = (cd->disposition && g_ascii_strcasecmp (cd->disposition, "attachment") == 0);
+
+			camel_content_disposition_unref (cd);
+		}
+	}
+
+	return ! (*found);
+}
+
+/**
+ * camel_mime_message_has_attachment:
+ * @message: a #CamelMimeMessage object
+ *
+ * Returns whether message contains at least one attachment part.
+ **/
+gboolean
+camel_mime_message_has_attachment (CamelMimeMessage *message)
+{
+	gboolean found = FALSE;
+
+	g_return_val_if_fail (message != NULL, FALSE);
+
+	camel_mime_message_foreach_part (message, find_attachment, &found);
+
+	return found;
+}
+
 static void
 cmm_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int body, int depth)
 {
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index 65a4223..bb910da 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -128,6 +128,8 @@ CamelMimePart              *camel_mime_message_get_part_by_content_id (CamelMime
 
 char                       *camel_mime_message_build_mbox_from    (CamelMimeMessage           *message);
 
+gboolean		    camel_mime_message_has_attachment     (CamelMimeMessage           *message);
+
 void camel_mime_message_dump(CamelMimeMessage *msg, int body);
 
 G_END_DECLS
diff --git a/camel/providers/imap/ChangeLog b/camel/providers/imap/ChangeLog
index 84c0080..266ef69 100644
--- a/camel/providers/imap/ChangeLog
+++ b/camel/providers/imap/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-27  Milan Crha  <mcrha redhat com>
+
+	** Part of fix for bug #478239
+
+	* camel-imap-folder.c: (imap_get_message):
+	Check whether message has really attachment part when claiming so.
+
 2009-03-09  Matthew Barnes  <mbarnes redhat com>
 
 	* camel-imap-summary.c (camel_imap_summary_new):
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index e068933..f219be4 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -3007,6 +3007,14 @@ done:
 					camel_folder_summary_touch (mi->info.summary);
 			}
 		}
+
+		if ((mi->info.flags & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (msg)) {
+			mi->info.flags = mi->info.flags & ~CAMEL_MESSAGE_ATTACHMENTS;
+			mi->info.dirty = TRUE;
+
+			if (mi->info.summary)
+				camel_folder_summary_touch (mi->info.summary);
+		}
 	}
 fail:
 	camel_message_info_free(&mi->info);
diff --git a/camel/providers/local/ChangeLog b/camel/providers/local/ChangeLog
index fdec3d9..7629efc 100644
--- a/camel/providers/local/ChangeLog
+++ b/camel/providers/local/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-27  Milan Crha  <mcrha redhat com>
+
+	** Part of fix for bug #478239
+
+	* camel-mbox-folder.c: (mbox_append_message):
+	* camel-maildir-folder.c: (maildir_append_message):
+	* camel-mh-folder.c: (mh_append_message):
+	Check whether message has really attachment part when claiming so.
+
 2009-04-24  Milan Crha  <mcrha redhat com>
 
 	** Part of fix for bug #563954
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index a290227..1af6bae 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -180,7 +180,10 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
 		return;
-	
+
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	mdi = (CamelMaildirMessageInfo *)mi;
 
 	d(printf("Appending message: uid is %s filename is %s\n", camel_message_info_uid(mi), mdi->filename));
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 005844e..efd19b4 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -218,6 +218,9 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
 
 	d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
 
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	output_stream = camel_stream_fs_new_with_name(lf->folder_path, O_WRONLY | O_APPEND | O_LARGEFILE, 0666);
 	if (output_stream == NULL) {
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index 289d5a0..ecc6ada 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -140,7 +140,10 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
 		return;
-	
+
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
 	
 	/* write it out, use the uid we got from the summary */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]