TextView: move header extraction to textview_process_headers()
Allow to extract headers from MULTIPART messages too
This commit is contained in:
parent
40734845db
commit
f3f7e7ad45
|
@ -636,6 +636,39 @@ void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
|
|||
END_TIMING();
|
||||
}
|
||||
|
||||
static gboolean textview_process_headers(TextView *textview, MimeInfo *mimeinfo,
|
||||
gint charcount, GtkTextBuffer *buffer, GtkTextIter iter)
|
||||
{
|
||||
GPtrArray *headers = NULL;
|
||||
FILE *fp;
|
||||
if (mimeinfo->content == MIMECONTENT_MEM)
|
||||
fp = str_open_as_stream(mimeinfo->data.mem);
|
||||
else
|
||||
fp = claws_fopen(mimeinfo->data.filename, "rb");
|
||||
if (!fp) {
|
||||
FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
|
||||
return FALSE;
|
||||
}
|
||||
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
|
||||
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
|
||||
claws_fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
headers = textview_scan_header(textview, fp);
|
||||
if (headers) {
|
||||
if (charcount > 0)
|
||||
gtk_text_buffer_insert(buffer, &iter, "\n", 1);
|
||||
|
||||
if (procmime_mimeinfo_parent(mimeinfo) == NULL &&
|
||||
!prefs_common.display_header_pane)
|
||||
textview_show_tags(textview);
|
||||
textview_show_header(textview, headers);
|
||||
procheader_header_array_destroy(headers);
|
||||
}
|
||||
claws_fclose(fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
|
@ -643,7 +676,6 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
|
|||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter, start_iter;
|
||||
gchar buf[BUFFSIZE];
|
||||
GPtrArray *headers = NULL;
|
||||
const gchar *name;
|
||||
gchar *content_type;
|
||||
gint charcount;
|
||||
|
@ -660,6 +692,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
|
|||
return;
|
||||
}
|
||||
if (mimeinfo->type == MIMETYPE_MULTIPART) {
|
||||
textview_process_headers(textview, mimeinfo, charcount, buffer, iter);
|
||||
END_TIMING();
|
||||
return;
|
||||
}
|
||||
|
@ -667,34 +700,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
|
|||
textview->prev_quote_level = -1;
|
||||
|
||||
if ((mimeinfo->type == MIMETYPE_MESSAGE) && !g_ascii_strcasecmp(mimeinfo->subtype, "rfc822")) {
|
||||
FILE *fp;
|
||||
if (mimeinfo->content == MIMECONTENT_MEM)
|
||||
fp = str_open_as_stream(mimeinfo->data.mem);
|
||||
else
|
||||
fp = claws_fopen(mimeinfo->data.filename, "rb");
|
||||
if (!fp) {
|
||||
FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
|
||||
END_TIMING();
|
||||
return;
|
||||
}
|
||||
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
|
||||
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
|
||||
claws_fclose(fp);
|
||||
END_TIMING();
|
||||
return;
|
||||
}
|
||||
headers = textview_scan_header(textview, fp);
|
||||
if (headers) {
|
||||
if (charcount > 0)
|
||||
gtk_text_buffer_insert(buffer, &iter, "\n", 1);
|
||||
|
||||
if (procmime_mimeinfo_parent(mimeinfo) == NULL &&
|
||||
!prefs_common.display_header_pane)
|
||||
textview_show_tags(textview);
|
||||
textview_show_header(textview, headers);
|
||||
procheader_header_array_destroy(headers);
|
||||
}
|
||||
claws_fclose(fp);
|
||||
textview_process_headers(textview, mimeinfo, charcount, buffer, iter);
|
||||
END_TIMING();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue