From efe61a449c4cece03b7afe5e9674cddea3a7f76e Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 16 Mar 2006 18:13:25 +0000 Subject: [PATCH] 2006-03-16 [colin] 2.0.0cvs141 * src/procmsg.h * src/procmsg.c * src/folder.c Fix POSTPROCESSING hook Patch by H. Merijn Brand * src/procmime.c * src/procmime.h Parse Content-Location * src/toolbar.c * src/messageview.c * src/messageview.h Don't crash when a top-level MessageView has been closed on us. Same problematic than yesterday's quicksearch issue. --- ChangeLog | 19 +++++++++++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/folder.c | 5 +++++ src/messageview.c | 11 ++++++++++- src/messageview.h | 2 ++ src/procmime.c | 34 ++++++++++++++++++++++++++++++---- src/procmime.h | 3 +++ src/procmsg.c | 3 --- src/procmsg.h | 2 ++ src/toolbar.c | 18 +++++++++++++++++- 11 files changed, 90 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71ace855a..b652410ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2006-03-16 [colin] 2.0.0cvs141 + + * src/procmsg.h + * src/procmsg.c + * src/folder.c + Fix POSTPROCESSING hook + Patch by H. Merijn Brand + + * src/procmime.c + * src/procmime.h + Parse Content-Location + + * src/toolbar.c + * src/messageview.c + * src/messageview.h + Don't crash when a top-level MessageView has + been closed on us. Same problematic than + yesterday's quicksearch issue. + 2006-03-15 [colin] 2.0.0cvs140 * src/gtk/quicksearch.c diff --git a/PATCHSETS b/PATCHSETS index 96e115b15..45092a2b8 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1326,3 +1326,4 @@ ( cvs diff -u -r 1.5.2.20 -r 1.5.2.21 src/prefs_spelling.c; ) > 2.0.0cvs138.patchset ( cvs diff -u -r 1.17.2.21 -r 1.17.2.22 src/alertpanel.c; ) > 2.0.0cvs139.patchset ( cvs diff -u -r 1.1.2.34 -r 1.1.2.35 src/gtk/quicksearch.c; cvs diff -u -r 1.395.2.181 -r 1.395.2.182 src/summaryview.c; ) > 2.0.0cvs140.patchset +( cvs diff -u -r 1.150.2.57 -r 1.150.2.58 src/procmsg.c; cvs diff -u -r 1.60.2.26 -r 1.60.2.27 src/procmsg.h; cvs diff -u -r 1.213.2.85 -r 1.213.2.86 src/folder.c; cvs diff -u -r 1.49.2.74 -r 1.49.2.75 src/procmime.c; cvs diff -u -r 1.17.2.14 -r 1.17.2.15 src/procmime.h; cvs diff -u -r 1.43.2.41 -r 1.43.2.42 src/toolbar.c; cvs diff -u -r 1.94.2.80 -r 1.94.2.81 src/messageview.c; cvs diff -u -r 1.19.2.7 -r 1.19.2.8 src/messageview.h; ) > 2.0.0cvs141.patchset diff --git a/configure.ac b/configure.ac index 9a0d1fcaf..831101b2b 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=140 +EXTRA_VERSION=141 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/folder.c b/src/folder.c index eb6905e20..47985fc48 100644 --- a/src/folder.c +++ b/src/folder.c @@ -2894,6 +2894,11 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour == POP3_PARTIAL_DLOAD_DLOAD) { partial_mark_for_download(newmsginfo); } + if (!MSG_IS_POSTFILTERED (msginfo->flags)) { + procmsg_msginfo_set_flags ( msginfo, MSG_POSTFILTERED, 0); + procmsg_msginfo_set_flags (newmsginfo, MSG_POSTFILTERED, 0); + hooks_invoke (MAIL_POSTFILTERING_HOOKLIST, newmsginfo); + } procmsg_msginfo_free(newmsginfo); diff --git a/src/messageview.c b/src/messageview.c index ce9296d74..4f3145684 100644 --- a/src/messageview.c +++ b/src/messageview.c @@ -874,8 +874,17 @@ void messageview_destroy(MessageView *messageview) debug_print("destroy messageview\n"); messageview_list = g_list_remove(messageview_list, messageview); - hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, + if (!messageview->deferred_destroy) { + hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, messageview->msginfo_update_callback_id); + } + + if (messageview->updating) { + debug_print("uh oh, better not touch that now\n"); + messageview->deferred_destroy = TRUE; + gtk_widget_hide(messageview->window); + return; + } headerview_destroy(messageview->headerview); mimeview_destroy(messageview->mimeview); diff --git a/src/messageview.h b/src/messageview.h index ebf7a2745..109995bcf 100644 --- a/src/messageview.h +++ b/src/messageview.h @@ -68,6 +68,8 @@ struct _MessageView gboolean all_headers; gint msginfo_update_callback_id; + gboolean updating; + gboolean deferred_destroy; }; MessageView *messageview_create (MainWindow *mainwin); diff --git a/src/procmime.c b/src/procmime.c index e7d058bcb..72602898d 100644 --- a/src/procmime.c +++ b/src/procmime.c @@ -118,6 +118,7 @@ static gboolean free_func(GNode *node, gpointer data) g_free(mimeinfo->subtype); g_free(mimeinfo->description); g_free(mimeinfo->id); + g_free(mimeinfo->location); g_hash_table_foreach_remove(mimeinfo->typeparameters, procmime_mimeinfo_parameters_destroy, NULL); @@ -1270,12 +1271,13 @@ gchar *procmime_get_content_type_str(MimeMediaType type, return g_strdup_printf("%s/%s", type_str, subtype); } -int procmime_parse_mimepart(MimeInfo *parent, +static int procmime_parse_mimepart(MimeInfo *parent, gchar *content_type, gchar *content_encoding, gchar *content_description, gchar *content_id, gchar *content_disposition, + gchar *content_location, const gchar *filename, guint offset, guint length); @@ -1291,6 +1293,8 @@ void procmime_parse_message_rfc822(MimeInfo *mimeinfo) NULL, TRUE}, {"Content-Disposition:", NULL, TRUE}, + {"Content-Location:", + NULL, TRUE}, {"MIME-Version:", NULL, TRUE}, {NULL, NULL, FALSE}}; @@ -1322,13 +1326,18 @@ void procmime_parse_message_rfc822(MimeInfo *mimeinfo) g_free(hentry[4].body); hentry[4].body = tmp; } + if (hentry[5].body != NULL) { + tmp = conv_unmime_header(hentry[5].body, NULL); + g_free(hentry[5].body); + hentry[5].body = tmp; + } content_start = ftell(fp); fclose(fp); procmime_parse_mimepart(mimeinfo, hentry[0].body, hentry[1].body, hentry[2].body, hentry[3].body, - hentry[4].body, + hentry[4].body, hentry[5].body, mimeinfo->data.filename, content_start, mimeinfo->length - (content_start - mimeinfo->offset)); @@ -1349,6 +1358,8 @@ void procmime_parse_multipart(MimeInfo *mimeinfo) NULL, TRUE}, {"Content-Disposition:", NULL, TRUE}, + {"Content-Location:", + NULL, TRUE}, {NULL, NULL, FALSE}}; gchar *p, *tmp; gchar *boundary; @@ -1379,7 +1390,7 @@ void procmime_parse_multipart(MimeInfo *mimeinfo) result = procmime_parse_mimepart(mimeinfo, hentry[0].body, hentry[1].body, hentry[2].body, hentry[3].body, - hentry[4].body, + hentry[4].body, hentry[5].body, mimeinfo->data.filename, lastoffset, (ftell(fp) - strlen(buf)) - lastoffset - 1); } @@ -1408,6 +1419,11 @@ void procmime_parse_multipart(MimeInfo *mimeinfo) g_free(hentry[4].body); hentry[4].body = tmp; } + if (hentry[5].body != NULL) { + tmp = conv_unmime_header(hentry[5].body, NULL); + g_free(hentry[5].body); + hentry[5].body = tmp; + } lastoffset = ftell(fp); } } @@ -1660,12 +1676,13 @@ static void procmime_parse_content_encoding(const gchar *content_encoding, MimeI return; } -int procmime_parse_mimepart(MimeInfo *parent, +static int procmime_parse_mimepart(MimeInfo *parent, gchar *content_type, gchar *content_encoding, gchar *content_description, gchar *content_id, gchar *content_disposition, + gchar *content_location, const gchar *filename, guint offset, guint length) @@ -1720,6 +1737,11 @@ int procmime_parse_mimepart(MimeInfo *parent, else mimeinfo->id = NULL; + if (content_location != NULL) + mimeinfo->location = g_strdup(content_location); + else + mimeinfo->location = NULL; + if (content_disposition != NULL) procmime_parse_content_disposition(content_disposition, mimeinfo); else @@ -1974,6 +1996,9 @@ void procmime_write_mime_header(MimeInfo *mimeinfo, FILE *fp) if (mimeinfo->id != NULL) fprintf(fp, "Content-ID: %s\n", mimeinfo->id); + if (mimeinfo->location != NULL) + fprintf(fp, "Content-Location: %s\n", mimeinfo->location); + if (mimeinfo->disposition != DISPOSITIONTYPE_UNKNOWN) { ParametersData *pdata = g_new0(ParametersData, 1); gchar *buf = NULL; @@ -2027,6 +2052,7 @@ gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp) g_ascii_strncasecmp(buf, "Content-Transfer-Encoding:", 26) == 0 || g_ascii_strncasecmp(buf, "Content-Description:", 20) == 0 || g_ascii_strncasecmp(buf, "Content-ID:", 11) == 0 || + g_ascii_strncasecmp(buf, "Content-Location:", 17) == 0 || g_ascii_strncasecmp(buf, "Content-Disposition:", 20) == 0) { skip = TRUE; continue; diff --git a/src/procmime.h b/src/procmime.h index 374b66408..ba90995fa 100644 --- a/src/procmime.h +++ b/src/procmime.h @@ -130,6 +130,9 @@ struct _MimeInfo /* Content-ID */ gchar *id; + /* Content-Location */ + gchar *location; + guint offset; guint length; diff --git a/src/procmsg.c b/src/procmsg.c index 7b1a5f906..cd247811a 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -1983,18 +1983,15 @@ gboolean procmsg_msginfo_filter(MsgInfo *msginfo) mail_filtering_data.msginfo = msginfo; if (hooks_invoke(MAIL_FILTERING_HOOKLIST, &mail_filtering_data)) { - hooks_invoke(MAIL_POSTFILTERING_HOOKLIST, msginfo); return TRUE; } /* filter if enabled in prefs or move to inbox if not */ if((filtering_rules != NULL) && filter_message_by_msginfo(filtering_rules, msginfo)) { - hooks_invoke(MAIL_POSTFILTERING_HOOKLIST, msginfo); return TRUE; } - hooks_invoke(MAIL_POSTFILTERING_HOOKLIST, msginfo); return FALSE; } diff --git a/src/procmsg.h b/src/procmsg.h index 3a7ee872c..5efb49942 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -45,6 +45,7 @@ typedef GSList MsgNumberList; #define MSG_DELETED (1U << 3) #define MSG_REPLIED (1U << 4) #define MSG_FORWARDED (1U << 5) +#define MSG_POSTFILTERED (1U << 14) #define MSG_CLABEL_SBIT (7) /* start bit of color label */ #define MAKE_MSG_CLABEL(h, m, l) (((h) << (MSG_CLABEL_SBIT + 2)) | \ @@ -115,6 +116,7 @@ typedef guint32 MsgTmpFlags; #define MSG_IS_REPLIED(msg) (((msg).perm_flags & MSG_REPLIED) != 0) #define MSG_IS_LOCKED(msg) (((msg).perm_flags & MSG_LOCKED) != 0) #define MSG_IS_FORWARDED(msg) (((msg).perm_flags & MSG_FORWARDED) != 0) +#define MSG_IS_POSTFILTERED(msg) (((msg).perm_flags & MSG_POSTFILTERED) != 0) #define MSG_GET_COLORLABEL(msg) (((msg).perm_flags & MSG_CLABEL_FLAG_MASK)) #define MSG_GET_COLORLABEL_VALUE(msg) (MSG_GET_COLORLABEL(msg) >> MSG_CLABEL_SBIT) diff --git a/src/toolbar.c b/src/toolbar.c index 045f455b7..36e76fe75 100644 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -1128,7 +1128,15 @@ static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data) case TOOLBAR_MSGVIEW: msgview = (MessageView*)toolbar_item->parent; + msgview->updating = TRUE; summary_select_prev_unread(msgview->mainwin->summaryview); + msgview->updating = FALSE; + + if (msgview->deferred_destroy) { + debug_print("messageview got away!\n"); + messageview_destroy(msgview); + return; + } /* Now we need to update the messageview window */ if (msgview->mainwin->summaryview->selected) { @@ -1167,8 +1175,16 @@ static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data) case TOOLBAR_MSGVIEW: msgview = (MessageView*)toolbar_item->parent; + msgview->updating = TRUE; summary_select_next_unread(msgview->mainwin->summaryview); - + msgview->updating = FALSE; + + if (msgview->deferred_destroy) { + debug_print("messageview got away!\n"); + messageview_destroy(msgview); + return; + } + /* Now we need to update the messageview window */ if (msgview->mainwin->summaryview->selected) { GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree); -- 2.25.1