2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <gdk/gdkkeysyms.h>
28 #include <gtk/gtkscrolledwindow.h>
29 #include <gtk/gtkctree.h>
30 #include <gtk/gtkvbox.h>
31 #include <gtk/gtkvpaned.h>
32 #include <gtk/gtktext.h>
33 #include <gtk/gtksignal.h>
34 #include <gtk/gtkmenu.h>
35 #include <gtk/gtkdnd.h>
36 #include <gtk/gtkselection.h>
45 #include "summaryview.h"
48 #include "alertpanel.h"
49 #include "inputdialog.h"
52 #include "prefs_common.h"
62 #define N_MIMEVIEW_COLS 3
64 static void mimeview_set_multipart_tree (MimeView *mimeview,
66 GtkCTreeNode *parent);
67 static GtkCTreeNode *mimeview_append_part (MimeView *mimeview,
69 GtkCTreeNode *parent);
70 static void mimeview_show_message_part (MimeView *mimeview,
72 static void mimeview_show_image_part (MimeView *mimeview,
74 static void mimeview_change_view_type (MimeView *mimeview,
76 static void mimeview_clear (MimeView *mimeview);
78 static void mimeview_selected (GtkCTree *ctree,
82 static void mimeview_start_drag (GtkWidget *widget,
86 static void mimeview_button_pressed (GtkWidget *widget,
87 GdkEventButton *event,
89 static void mimeview_key_pressed (GtkWidget *widget,
93 static void mimeview_drag_data_get (GtkWidget *widget,
94 GdkDragContext *drag_context,
95 GtkSelectionData *selection_data,
100 static void mimeview_display_as_text (MimeView *mimeview);
101 static void mimeview_save_as (MimeView *mimeview);
102 static void mimeview_launch (MimeView *mimeview);
103 static void mimeview_open_with (MimeView *mimeview);
104 static void mimeview_view_file (const gchar *filename,
106 const gchar *cmdline);
108 static void mimeview_check_signature (MimeView *mimeview);
111 static GtkItemFactoryEntry mimeview_popup_entries[] =
113 {N_("/_Open"), NULL, mimeview_launch, 0, NULL},
114 {N_("/Open _with..."), NULL, mimeview_open_with, 0, NULL},
115 {N_("/_Display as text"), NULL, mimeview_display_as_text, 0, NULL},
116 {N_("/_Save as..."), NULL, mimeview_save_as, 0, NULL}
119 {N_("/_Check signature"), NULL, mimeview_check_signature, 0, NULL}
123 static GtkTargetEntry mimeview_mime_types[] =
125 {"text/uri-list", 0, 0}
128 MimeView *mimeview_create(void)
133 GtkWidget *scrolledwin;
136 GtkWidget *popupmenu;
137 GtkItemFactory *popupfactory;
139 gchar *titles[] = {_("MIME Type"), _("Size"), _("Name")};
143 debug_print(_("Creating MIME view...\n"));
144 mimeview = g_new0(MimeView, 1);
146 scrolledwin = gtk_scrolled_window_new(NULL, NULL);
147 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
148 GTK_POLICY_AUTOMATIC,
150 gtk_widget_set_usize(scrolledwin, -1, 80);
152 ctree = gtk_sctree_new_with_titles(N_MIMEVIEW_COLS, 0, titles);
153 gtk_clist_set_selection_mode(GTK_CLIST(ctree), GTK_SELECTION_BROWSE);
154 gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_NONE);
155 gtk_clist_set_column_justification(GTK_CLIST(ctree), COL_SIZE,
157 gtk_clist_set_column_width(GTK_CLIST(ctree), COL_MIMETYPE, 240);
158 gtk_clist_set_column_width(GTK_CLIST(ctree), COL_SIZE, 64);
159 for (i = 0; i < N_MIMEVIEW_COLS; i++)
160 GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(ctree)->column[i].button,
162 gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
164 gtk_signal_connect(GTK_OBJECT(ctree), "tree_select_row",
165 GTK_SIGNAL_FUNC(mimeview_selected), mimeview);
166 gtk_signal_connect(GTK_OBJECT(ctree), "button_press_event",
167 GTK_SIGNAL_FUNC(mimeview_button_pressed), mimeview);
168 gtk_signal_connect(GTK_OBJECT(ctree), "key_press_event",
169 GTK_SIGNAL_FUNC(mimeview_key_pressed), mimeview);
170 gtk_signal_connect(GTK_OBJECT (ctree),"start_drag",
171 GTK_SIGNAL_FUNC (mimeview_start_drag), mimeview);
172 gtk_signal_connect(GTK_OBJECT(ctree), "drag_data_get",
173 GTK_SIGNAL_FUNC(mimeview_drag_data_get), mimeview);
175 vbox = gtk_vbox_new(FALSE, 0);
177 paned = gtk_vpaned_new();
178 gtk_paned_add1(GTK_PANED(paned), scrolledwin);
179 gtk_paned_add2(GTK_PANED(paned), vbox);
180 gtk_widget_show_all(paned);
182 n_entries = sizeof(mimeview_popup_entries) /
183 sizeof(mimeview_popup_entries[0]);
184 popupmenu = menu_create_items(mimeview_popup_entries, n_entries,
185 "<MimeView>", &popupfactory, mimeview);
187 mimeview->paned = paned;
188 mimeview->scrolledwin = scrolledwin;
189 mimeview->ctree = ctree;
190 mimeview->vbox = vbox;
191 mimeview->popupmenu = popupmenu;
192 mimeview->popupfactory = popupfactory;
197 void mimeview_init(MimeView *mimeview)
202 * Check whether the message is OpenPGP signed
205 static gboolean mimeview_is_signed(MimeView *mimeview)
209 debug_print("mimeview_is signed of %p\n", mimeview);
211 if (!mimeview) return FALSE;
212 if (!mimeview->opened) return FALSE;
214 debug_print("mimeview_is_signed: open\n" );
216 if (!mimeview->file) return FALSE;
218 debug_print("mimeview_is_signed: file\n" );
220 partinfo = gtk_ctree_node_get_row_data
221 (GTK_CTREE(mimeview->ctree), mimeview->opened);
222 g_return_val_if_fail(partinfo != NULL, FALSE);
224 /* walk the tree and see whether there is a signature somewhere */
226 if (rfc2015_has_signature(partinfo))
228 } while ((partinfo = partinfo->parent) != NULL);
230 debug_print("mimeview_is_signed: FALSE\n" );
235 static void set_unchecked_signature(MimeInfo *mimeinfo)
237 MimeInfo *sig_partinfo;
239 sig_partinfo = rfc2015_find_signature(mimeinfo);
240 if (sig_partinfo == NULL) return;
242 g_free(sig_partinfo->sigstatus);
243 sig_partinfo->sigstatus =
244 g_strdup(_("Select \"Check signature\" to check"));
246 g_free(sig_partinfo->sigstatus_full);
247 sig_partinfo->sigstatus_full = NULL;
249 #endif /* USE_GPGME */
251 void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
254 GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
259 mimeview_clear(mimeview);
261 g_return_if_fail(file != NULL);
262 g_return_if_fail(mimeinfo != NULL);
264 mimeview->mimeinfo = mimeinfo;
266 if ((fp = fopen(file, "r")) == NULL) {
267 FILE_OP_ERROR(file, "fopen");
270 mimeview->file = g_strdup(file);
273 if (mimeinfo->mime_type == MIME_MULTIPART) {
274 if (fseek(fp, mimeinfo->fpos, SEEK_SET) < 0)
276 while (fgets(buf, sizeof(buf), fp) != NULL)
277 if (buf[0] == '\r' || buf[0] == '\n') break;
280 procmime_scan_multipart_message(mimeinfo, fp);
282 if (prefs_common.auto_check_signatures)
283 rfc2015_check_signature(mimeinfo, fp);
285 set_unchecked_signature(mimeinfo);
289 gtk_signal_handler_block_by_func(GTK_OBJECT(ctree), mimeview_selected,
292 mimeview_set_multipart_tree(mimeview, mimeinfo, NULL);
294 gtk_signal_handler_unblock_by_func(GTK_OBJECT(ctree),
295 mimeview_selected, mimeview);
297 if ((node = gtk_ctree_node_nth(ctree, 0))) {
298 gtk_ctree_select(ctree, node);
299 gtk_widget_grab_focus(mimeview->ctree);
303 void mimeview_destroy(MimeView *mimeview)
305 procmime_mimeinfo_free_all(mimeview->mimeinfo);
306 g_free(mimeview->file);
310 static void mimeview_set_multipart_tree(MimeView *mimeview,
312 GtkCTreeNode *parent)
314 g_return_if_fail(mimeinfo != NULL);
316 if (!mimeinfo->main && mimeinfo->parent)
317 parent = mimeview_append_part(mimeview, mimeinfo, parent);
319 if (mimeinfo->sub && mimeinfo->sub->children)
320 mimeview_set_multipart_tree(mimeview, mimeinfo->sub, parent);
322 if (mimeinfo->children) {
325 child = mimeinfo->children;
327 mimeview_set_multipart_tree(mimeview, child, parent);
333 static gchar *get_part_name(MimeInfo *partinfo)
336 if (partinfo->sigstatus)
337 return partinfo->sigstatus;
341 return partinfo->name;
342 else if (partinfo->filename)
343 return partinfo->filename;
348 static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
350 GtkCTreeNode *parent)
352 GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
354 gchar *str[N_MIMEVIEW_COLS];
357 partinfo->content_type ? partinfo->content_type : "";
358 str[COL_SIZE] = to_human_readable(partinfo->size);
359 str[COL_NAME] = get_part_name(partinfo);
361 node = gtk_ctree_insert_node(ctree, parent, NULL, str, 0,
362 NULL, NULL, NULL, NULL,
364 gtk_ctree_node_set_row_data(ctree, node, partinfo);
369 static void mimeview_show_message_part(MimeView *mimeview, MimeInfo *partinfo)
377 if (!partinfo) return;
380 for (pi = partinfo; pi && !pi->plaintextfile ; pi = pi->parent)
382 fname = pi ? pi->plaintextfile : mimeview->file;
384 fname = mimeview->file;
385 #endif /* USE_GPGME */
388 if ((fp = fopen(fname, "r")) == NULL) {
389 FILE_OP_ERROR(fname, "fopen");
393 if (fseek(fp, partinfo->fpos, SEEK_SET) < 0) {
394 FILE_OP_ERROR(mimeview->file, "fseek");
399 mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
400 textview_show_part(mimeview->textview, partinfo, fp);
405 static void mimeview_show_image_part(MimeView *mimeview, MimeInfo *partinfo)
409 if (!partinfo) return;
411 filename = procmime_get_tmp_file_name(partinfo);
413 if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
415 (_("Can't get the part of multipart message."));
417 mimeview_change_view_type(mimeview, MIMEVIEW_IMAGE);
418 imageview_show_image(mimeview->imageview, partinfo, filename);
425 static void mimeview_change_view_type(MimeView *mimeview, MimeViewType type)
427 TextView *textview = mimeview->textview;
428 ImageView *imageview = mimeview->imageview;
430 if (mimeview->type == type) return;
434 gtk_container_remove(GTK_CONTAINER(mimeview->vbox),
435 GTK_WIDGET_PTR(textview));
436 gtk_container_add(GTK_CONTAINER(mimeview->vbox),
437 GTK_WIDGET_PTR(imageview));
440 gtk_container_remove(GTK_CONTAINER(mimeview->vbox),
441 GTK_WIDGET_PTR(imageview));
442 gtk_container_add(GTK_CONTAINER(mimeview->vbox),
443 GTK_WIDGET_PTR(textview));
449 mimeview->type = type;
452 static void mimeview_clear(MimeView *mimeview)
454 GtkCList *clist = GTK_CLIST(mimeview->ctree);
456 procmime_mimeinfo_free_all(mimeview->mimeinfo);
457 mimeview->mimeinfo = NULL;
459 gtk_clist_clear(clist);
460 textview_clear(mimeview->textview);
462 mimeview->opened = NULL;
464 g_free(mimeview->file);
465 mimeview->file = NULL;
468 static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
473 if (mimeview->opened == node) return;
474 mimeview->opened = node;
475 gtk_ctree_node_moveto(ctree, node, -1, 0.5, 0);
477 partinfo = gtk_ctree_node_get_row_data(ctree, node);
478 if (!partinfo) return;
480 /* ungrab the mouse event */
481 if (GTK_WIDGET_HAS_GRAB(ctree)) {
482 gtk_grab_remove(GTK_WIDGET(ctree));
483 if (gdk_pointer_is_grabbed())
484 gdk_pointer_ungrab(GDK_CURRENT_TIME);
487 switch (partinfo->mime_type) {
490 case MIME_MESSAGE_RFC822:
492 mimeview_show_message_part(mimeview, partinfo);
494 #if (HAVE_GDK_PIXBUF || HAVE_GDK_IMLIB)
496 mimeview_show_image_part(mimeview, partinfo);
500 mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
502 if (g_strcasecmp(partinfo->content_type,
503 "application/pgp-signature") == 0)
504 textview_show_signature_part(mimeview->textview,
508 textview_show_mime_part(mimeview->textview, partinfo);
513 static void mimeview_start_drag (GtkWidget *widget, gint button,
514 GdkEvent *event, MimeView *mimeview)
517 GdkDragContext *context;
521 g_return_if_fail(mimeview != NULL);
522 ctree = GTK_CTREE(mimeview->ctree);
523 partinfo = gtk_ctree_node_get_row_data(ctree, mimeview->opened);
524 if (partinfo->filename == NULL && partinfo->name == NULL) return;
526 list = gtk_target_list_new(mimeview_mime_types, 1);
527 context = gtk_drag_begin(widget, list,
528 GDK_ACTION_COPY, button, event);
529 gtk_drag_set_icon_default(context);
532 static void mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event,
535 GtkCList *clist = GTK_CLIST(widget);
541 if (event->button == 2 || event->button == 3) {
542 if (!gtk_clist_get_selection_info(clist, event->x, event->y,
545 gtk_clist_unselect_all(clist);
546 gtk_clist_select_row(clist, row, column);
547 gtkut_clist_set_focus_row(clist, row);
550 if (event->button == 2 ||
551 (event->button == 1 && event->type == GDK_2BUTTON_PRESS)) {
552 /* call external program for image, audio or html */
553 mimeview_launch(mimeview);
554 } else if (event->button == 3) {
555 partinfo = gtk_ctree_node_get_row_data
556 (GTK_CTREE(mimeview->ctree), mimeview->opened);
557 if (partinfo && (partinfo->mime_type == MIME_TEXT ||
558 partinfo->mime_type == MIME_TEXT_HTML ||
559 partinfo->mime_type == MIME_MESSAGE_RFC822 ||
560 partinfo->mime_type == MIME_IMAGE ||
561 partinfo->mime_type == MIME_MULTIPART))
562 menu_set_sensitive(mimeview->popupfactory,
563 "/Display as text", FALSE);
565 menu_set_sensitive(mimeview->popupfactory,
566 "/Display as text", TRUE);
568 menu_set_sensitive(mimeview->popupfactory,
570 mimeview_is_signed(mimeview));
573 gtk_menu_popup(GTK_MENU(mimeview->popupmenu),
574 NULL, NULL, NULL, NULL,
575 event->button, event->time);
579 #define BREAK_ON_MODIFIER_KEY() \
580 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
582 static void mimeview_key_pressed(GtkWidget *widget, GdkEventKey *event,
585 SummaryView *summaryview;
586 GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
590 if (!mimeview->opened) return;
592 switch (event->keyval) {
594 if (textview_scroll_page(mimeview->textview, FALSE)) return;
596 node = GTK_CTREE_NODE_NEXT(mimeview->opened);
598 gtk_sctree_unselect_all(GTK_SCTREE(ctree));
599 gtk_sctree_select(GTK_SCTREE(ctree), node);
605 textview_scroll_page(mimeview->textview, TRUE);
608 textview_scroll_one_line(mimeview->textview,
609 (event->state & GDK_MOD1_MASK) != 0);
613 BREAK_ON_MODIFIER_KEY();
614 if (!GTK_CTREE_NODE_NEXT(mimeview->opened)) break;
616 gtk_signal_emit_by_name(GTK_OBJECT(ctree), "scroll_vertical",
617 GTK_SCROLL_STEP_FORWARD, 0.0);
621 BREAK_ON_MODIFIER_KEY();
622 if (!GTK_CTREE_NODE_PREV(mimeview->opened)) break;
624 gtk_signal_emit_by_name(GTK_OBJECT(ctree), "scroll_vertical",
625 GTK_SCROLL_STEP_BACKWARD, 0.0);
628 BREAK_ON_MODIFIER_KEY();
629 mimeview_save_as(mimeview);
632 BREAK_ON_MODIFIER_KEY();
633 mimeview_display_as_text(mimeview);
636 BREAK_ON_MODIFIER_KEY();
637 mimeview_launch(mimeview);
643 if (!mimeview->messageview->mainwin) return;
644 summaryview = mimeview->messageview->mainwin->summaryview;
645 summary_pass_key_press_event(summaryview, event);
648 static void mimeview_drag_data_get(GtkWidget *widget,
649 GdkDragContext *drag_context,
650 GtkSelectionData *selection_data,
655 gchar *filename, *uriname;
658 if (!mimeview->opened) return;
659 if (!mimeview->file) return;
661 partinfo = gtk_ctree_node_get_row_data
662 (GTK_CTREE(mimeview->ctree), mimeview->opened);
663 if (!partinfo) return;
664 if (!partinfo->filename && !partinfo->name) return;
666 filename = partinfo->filename ? partinfo->filename : partinfo->name;
667 filename = g_basename(filename);
668 if (*filename == '\0') return;
670 filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
673 if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
675 (_("Can't save the part of multipart message."));
677 uriname = g_strconcat("file:/", filename, NULL);
678 gtk_selection_data_set(selection_data, selection_data->target, 8,
679 uriname, strlen(uriname));
685 static void mimeview_display_as_text(MimeView *mimeview)
689 if (!mimeview->opened) return;
691 partinfo = gtk_ctree_node_get_row_data
692 (GTK_CTREE(mimeview->ctree), mimeview->opened);
693 mimeview_show_message_part(mimeview, partinfo);
696 static void mimeview_save_as(MimeView *mimeview)
701 if (!mimeview->opened) return;
702 if (!mimeview->file) return;
704 partinfo = gtk_ctree_node_get_row_data
705 (GTK_CTREE(mimeview->ctree), mimeview->opened);
706 g_return_if_fail(partinfo != NULL);
708 filename = filesel_select_file
710 partinfo->filename ? partinfo->filename : partinfo->name);
711 if (!filename) return;
712 if (is_file_exist(filename)) {
715 aval = alertpanel(_("Overwrite"),
716 _("Overwrite existing file?"),
717 _("OK"), _("Cancel"), NULL);
718 if (G_ALERTDEFAULT != aval) return;
721 if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
723 (_("Can't save the part of multipart message."));
726 static void mimeview_launch(MimeView *mimeview)
731 if (!mimeview->opened) return;
732 if (!mimeview->file) return;
734 partinfo = gtk_ctree_node_get_row_data
735 (GTK_CTREE(mimeview->ctree), mimeview->opened);
736 g_return_if_fail(partinfo != NULL);
738 filename = procmime_get_tmp_file_name(partinfo);
740 if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
742 (_("Can't save the part of multipart message."));
744 mimeview_view_file(filename, partinfo, NULL);
749 static void mimeview_open_with(MimeView *mimeview)
754 if (!mimeview->opened) return;
755 if (!mimeview->file) return;
757 partinfo = gtk_ctree_node_get_row_data
758 (GTK_CTREE(mimeview->ctree), mimeview->opened);
759 g_return_if_fail(partinfo != NULL);
761 filename = procmime_get_tmp_file_name(partinfo);
763 if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
765 (_("Can't save the part of multipart message."));
771 _("Enter the command line to open file:\n"
772 "(`%s' will be replaced with file name)"),
775 mimeview_view_file(filename, partinfo, cmd);
783 static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
784 const gchar *cmdline)
786 static gchar *default_image_cmdline = "display '%s'";
787 static gchar *default_audio_cmdline = "play '%s'";
788 static gchar *default_html_cmdline =
789 "netscape -remote 'openURL(%s,raise)'";
790 static gchar *mime_cmdline = "metamail -d -b -c %s '%s'";
794 const gchar *def_cmd;
800 } else if (MIME_APPLICATION_OCTET_STREAM == partinfo->mime_type) {
802 } else if (MIME_IMAGE == partinfo->mime_type) {
803 cmd = prefs_common.mime_image_viewer;
804 def_cmd = default_image_cmdline;
805 } else if (MIME_AUDIO == partinfo->mime_type) {
806 cmd = prefs_common.mime_audio_player;
807 def_cmd = default_audio_cmdline;
808 } else if (MIME_TEXT_HTML == partinfo->mime_type) {
809 cmd = prefs_common.uri_cmd;
810 def_cmd = default_html_cmdline;
812 g_snprintf(m_buf, sizeof(m_buf), mime_cmdline,
813 partinfo->content_type, "%s");
818 if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' &&
820 g_snprintf(buf, sizeof(buf), cmd, filename);
823 g_warning(_("MIME viewer command line is invalid: `%s'"), cmd);
825 g_snprintf(buf, sizeof(buf), def_cmd, filename);
830 execute_command_line(buf);
834 static void update_node_name(GtkCTree *ctree, GtkCTreeNode *node,
840 partinfo = gtk_ctree_node_get_row_data(ctree, node);
841 g_return_if_fail(partinfo != NULL);
843 part_name = get_part_name(partinfo);
844 gtk_ctree_node_set_text(ctree, node, COL_NAME, part_name);
847 static void mimeview_update_names(MimeView *mimeview)
849 GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
851 gtk_ctree_pre_recursive(ctree, NULL, update_node_name, NULL);
854 static void mimeview_update_signature_info(MimeView *mimeview)
858 if (!mimeview) return;
859 if (!mimeview->opened) return;
861 partinfo = gtk_ctree_node_get_row_data
862 (GTK_CTREE(mimeview->ctree), mimeview->opened);
863 if (!partinfo) return;
865 if (g_strcasecmp(partinfo->content_type,
866 "application/pgp-signature") == 0) {
867 mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
868 textview_show_signature_part(mimeview->textview, partinfo);
872 static void mimeview_check_signature(MimeView *mimeview)
878 g_return_if_fail (mimeview_is_signed(mimeview));
880 mimeinfo = gtk_ctree_node_get_row_data
881 (GTK_CTREE(mimeview->ctree), mimeview->opened);
882 g_return_if_fail(mimeinfo != NULL);
883 g_return_if_fail(mimeview->file != NULL);
885 while (mimeinfo->parent)
886 mimeinfo = mimeinfo->parent;
888 if ((fp = fopen(mimeview->file, "r")) == NULL) {
889 FILE_OP_ERROR(mimeview->file, "fopen");
894 if (mimeinfo->mime_type == MIME_MULTIPART) {
895 if (fseek(fp, mimeinfo->fpos, SEEK_SET) < 0)
896 FILE_OP_ERROR(mimeview->file, "fseek");
897 while (fgets(buf, sizeof(buf), fp) != NULL)
898 if (buf[0] == '\r' || buf[0] == '\n') break;
901 procmime_scan_multipart_message(mimeinfo, fp);
902 rfc2015_check_signature(mimeinfo, fp);
905 mimeview_update_names(mimeview);
906 mimeview_update_signature_info(mimeview);
908 #endif /* USE_GPGME */