Patch: Don't add attachment icon quite as often



OK, I'll try again - balsa crashed during spellchecking when I just tried
to send a message to the list ;-(

What I wanted to do was to submit a patch that should fix a problem with
the attachment column that somebody complained about a few days ago (I
can't find the original message right now - a search function would be
nice...) - far too many messages would be marked as having attachments,
notably everything with HTML content.

The patch introduces the distinction between a multipart message and a
"message with attachments", which I think is important to keep. It is
obvious that "multipart" does not mean the same as "having attachments",
since there is something called "multipart/alternative"

--
Toralf Lund <toralf@kscanners.com>  +47 66 85 51 22
Kongsberg Scanners AS               +47 66 85 51 00 (switchboard)
http://www.kscanners.no/~toralf     +47 66 85 51 01 (fax)
Index: src/main-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/main-window.c,v
retrieving revision 1.410
diff -u -r1.410 main-window.c
--- src/main-window.c	2001/08/20 14:07:20	1.410
+++ src/main-window.c	2001/08/22 12:15:41
@@ -921,7 +921,7 @@
     }
 
     /* Handle items which require multiple parts to the mail */
-    if (message && !libbalsa_message_has_attachment(message)) {
+    if (message && !libbalsa_message_is_multipart) {
 	gtk_widget_set_sensitive(message_menu[MENU_MESSAGE_NEXT_PART_POS].widget, FALSE);
 	gtk_widget_set_sensitive(message_menu[MENU_MESSAGE_PREVIOUS_PART_POS].widget, FALSE);
     } else {
Index: libbalsa/message.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.c,v
retrieving revision 1.61
diff -u -r1.61 message.c
--- libbalsa/message.c	2001/07/12 11:53:01	1.61
+++ libbalsa/message.c	2001/08/22 12:15:42
@@ -892,6 +892,25 @@
 }
 
 gboolean
+libbalsa_message_is_multipart(LibBalsaMessage * message)
+{
+    HEADER *msg_header;
+
+    g_return_val_if_fail(LIBBALSA_IS_MESSAGE(message), FALSE);
+    g_return_val_if_fail(message->mailbox, FALSE);
+    g_return_val_if_fail(CLIENT_CONTEXT(message->mailbox)->hdrs, FALSE);
+
+    msg_header = CLIENT_CONTEXT(message->mailbox)->hdrs[message->msgno];
+
+    /* FIXME: Can be simplified into 1 if */
+    if (msg_header->content->type == TYPEMULTIPART) {
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+gboolean
 libbalsa_message_has_attachment(LibBalsaMessage * message)
 {
     gboolean ret;
@@ -903,18 +922,20 @@
 
     msg_header = CLIENT_CONTEXT(message->mailbox)->hdrs[message->msgno];
 
-    /* FIXME: Can be simplified into 1 if */
-    if (msg_header->content->type != TYPETEXT) {
+    switch(msg_header->content->type) {
+    case TYPEMULTIPART:
+	ret = (g_strcasecmp("alternative", msg_header->content->subtype)!=0);
+	break;
+    case TYPETEXT:		/* *** Or always return FALSE  */
+	ret = (g_strcasecmp("plain", msg_header->content->subtype) != 0 &&
+	       g_strcasecmp("html", msg_header->content->subtype) != 0);
+	break;
+    default:
 	ret = TRUE;
-    } else {
-	if (g_strcasecmp("plain", msg_header->content->subtype) == 0)
-	    ret = FALSE;
-	else
-	    ret = TRUE;
     }
-
     return ret;
 }
+
 
 gchar *
 libbalsa_message_date_to_gchar(LibBalsaMessage * message,
Index: libbalsa/message.h
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.h,v
retrieving revision 1.28
diff -u -r1.28 message.h
--- libbalsa/message.h	2001/07/12 11:53:01	1.28
+++ libbalsa/message.h	2001/08/22 12:15:42
@@ -209,6 +209,7 @@
 
 const gchar *libbalsa_message_pathname(LibBalsaMessage * message);
 const gchar *libbalsa_message_charset(LibBalsaMessage * message);
+gboolean libbalsa_message_is_multipart(LibBalsaMessage * message);
 gboolean libbalsa_message_has_attachment(LibBalsaMessage * message);
 
 GList *libbalsa_message_user_hdrs(LibBalsaMessage * message);


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