void mimeview_print_part(MimeView *mimeview, MimeInfo *partinfo) { g_return_if_fail(partinfo != NULL); if (!mimeview->messageview->file) return; if (partinfo->mime_type == MIME_MESSAGE_RFC822) { gchar *filename; MsgInfo *msginfo; MsgFlags flags = {0, 0}; filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) { alertpanel_error (_("Can't save the part of multipart message.")); g_free(filename); return; } msginfo = procheader_parse_file(filename, flags, TRUE); msginfo->file_path = filename; filename = NULL; printing_print_message (msginfo, mimeview->textview->show_all_headers); procmsg_msginfo_free(msginfo); } else if (partinfo->mime_type == MIME_TEXT || partinfo->mime_type == MIME_TEXT_HTML) { printing_print_message_part(mimeview->messageview->msginfo, partinfo); } }
static void mimeview_launch(MimeView *mimeview) { MimeInfo *partinfo; gchar *filename; if (!mimeview->opened) return; if (!mimeview->file) return; partinfo = mimeview_get_selected_part(mimeview); if (!partinfo) { partinfo = (MimeInfo *) gtk_object_get_data (GTK_OBJECT(mimeview->popupmenu), "pop_partinfo"); gtk_object_set_data(GTK_OBJECT(mimeview->popupmenu), "pop_partinfo", NULL); } g_return_if_fail(partinfo != NULL); filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, partinfo) < 0) alertpanel_error (_("Can't save the part of multipart message.")); else mimeview_view_file(filename, partinfo, NULL); g_free(filename); }
gchar *get_part_as_string(MimeInfo *mimeinfo) { gchar *textdata = NULL; gchar *filename = NULL; FILE *fp; cm_return_val_if_fail(mimeinfo != NULL, 0); procmime_decode_content(mimeinfo); if (mimeinfo->content == MIMECONTENT_MEM) textdata = g_strdup(mimeinfo->data.mem); else { filename = procmime_get_tmp_file_name(mimeinfo); if (procmime_get_part(filename, mimeinfo) < 0) { g_warning("error dumping temporary file '%s'", filename); g_free(filename); return NULL; } fp = claws_fopen(filename,"rb"); if (!fp) { g_warning("error opening temporary file '%s'", filename); g_free(filename); return NULL; } textdata = fp_read_noconv(fp); claws_fclose(fp); g_unlink(filename); g_free(filename); } if (!g_utf8_validate(textdata, -1, NULL)) { gchar *tmp = NULL; codeconv_set_strict(TRUE); if (procmime_mimeinfo_get_parameter(mimeinfo, "charset")) { tmp = conv_codeset_strdup(textdata, procmime_mimeinfo_get_parameter(mimeinfo, "charset"), CS_UTF_8); } if (!tmp) { tmp = conv_codeset_strdup(textdata, conv_get_locale_charset_str_no_utf8(), CS_UTF_8); } codeconv_set_strict(FALSE); if (!tmp) { tmp = conv_codeset_strdup(textdata, conv_get_locale_charset_str_no_utf8(), CS_UTF_8); } if (tmp) { g_free(textdata); textdata = tmp; } } return textdata; }
static void mimeview_open_with(MimeView *mimeview) { MimeInfo *partinfo; gchar *filename; gchar *cmd; if (!mimeview->opened) return; if (!mimeview->file) return; partinfo = mimeview_get_selected_part(mimeview); if (!partinfo) { partinfo = (MimeInfo *) gtk_object_get_data (GTK_OBJECT(mimeview->popupmenu), "pop_partinfo"); gtk_object_set_data(GTK_OBJECT(mimeview->popupmenu), "pop_partinfo", NULL); } g_return_if_fail(partinfo != NULL); filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, partinfo) < 0) { alertpanel_error (_("Can't save the part of multipart message.")); g_free(filename); return; } if (!prefs_common.mime_open_cmd_history) prefs_common.mime_open_cmd_history = add_history(NULL, prefs_common.mime_open_cmd); cmd = input_dialog_combo (_("Open with"), _("Enter the command line to open file:\n" "(`%s' will be replaced with file name)"), prefs_common.mime_open_cmd, prefs_common.mime_open_cmd_history, TRUE); if (cmd) { mimeview_view_file(filename, partinfo, cmd); g_free(prefs_common.mime_open_cmd); prefs_common.mime_open_cmd = cmd; prefs_common.mime_open_cmd_history = add_history(prefs_common.mime_open_cmd_history, cmd); } g_free(filename); }
void mimeview_launch_part(MimeView *mimeview, MimeInfo *partinfo) { gchar *filename; g_return_if_fail(partinfo != NULL); if (!mimeview->messageview->file) return; filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) alertpanel_error (_("Can't save the part of multipart message.")); else mimeview_view_file(filename, partinfo, NULL); g_free(filename); }
static void mimeview_show_image_part(MimeView *mimeview, MimeInfo *partinfo) { gchar *filename; if (!partinfo) return; filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) alertpanel_error (_("Can't get the part of multipart message.")); else { mimeview_change_view_type(mimeview, MIMEVIEW_IMAGE); imageview_show_image(mimeview->imageview, partinfo, filename, prefs_common.resize_image); g_unlink(filename); } g_free(filename); }
static void mathml_show_mimepart(MimeViewer *_viewer, const gchar *infile, MimeInfo *partinfo) { MathMLViewer *viewer = (MathMLViewer *) _viewer; debug_print("mathml_show_mimepart\n"); if (viewer->filename != NULL) { unlink(viewer->filename); g_free(viewer->filename); } viewer->filename = procmime_get_tmp_file_name(partinfo); if (!(procmime_get_part(viewer->filename, partinfo) < 0)) { gchar *uri; uri = g_strconcat("file://", viewer->filename, NULL); gtk_math_view_load_uri(GTK_MATH_VIEW(viewer->mathview), uri); g_free(uri); } }
static void mimeview_reply(MimeView *mimeview, guint action) { MimeInfo *partinfo; gchar *filename; MsgInfo *msginfo; MsgFlags flags = {0, 0}; ComposeMode mode = action; if (!mimeview->opened) return; if (!mimeview->messageview->file) return; partinfo = mimeview_get_selected_part(mimeview); g_return_if_fail(partinfo != NULL); if (partinfo->mime_type != MIME_MESSAGE_RFC822) return; filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) { alertpanel_error (_("Can't save the part of multipart message.")); g_free(filename); return; } msginfo = procheader_parse_file(filename, flags, TRUE); msginfo->file_path = filename; filename = NULL; if (prefs_common.reply_with_quote) mode |= COMPOSE_WITH_QUOTE; if (mimeview->messageview->mainwin) compose_reply(msginfo, mimeview->messageview->mainwin->summaryview->folder_item, mode, NULL); else compose_reply(msginfo, NULL, mode, NULL); g_unlink(msginfo->file_path); procmsg_msginfo_free(msginfo); }
void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo) { gchar *filename; gchar *cmd; g_return_if_fail(partinfo != NULL); if (!mimeview->messageview->file) return; filename = procmime_get_tmp_file_name(partinfo); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) { alertpanel_error (_("Can't save the part of multipart message.")); g_free(filename); return; } if (!prefs_common.mime_open_cmd_history) prefs_common.mime_open_cmd_history = add_history(NULL, prefs_common.mime_open_cmd); cmd = input_dialog_combo (_("Open with"), _("Enter the command line to open file:\n" "(`%s' will be replaced with file name)"), prefs_common.mime_open_cmd, prefs_common.mime_open_cmd_history, TRUE); if (cmd) { mimeview_view_file(filename, partinfo, cmd); g_free(prefs_common.mime_open_cmd); prefs_common.mime_open_cmd = cmd; prefs_common.mime_open_cmd_history = add_history(prefs_common.mime_open_cmd_history, cmd); } g_free(filename); }
static void mimeview_drag_begin(GtkWidget *widget, GdkDragContext *drag_context, MimeView *mimeview) { gchar *filename; gchar *bname = NULL; MimeInfo *partinfo; if (!mimeview->opened) return; if (!mimeview->messageview->file) return; partinfo = mimeview_get_selected_part(mimeview); if (!partinfo) return; filename = partinfo->filename ? partinfo->filename : partinfo->name; if (filename) { const gchar *bname_; bname_ = g_basename(filename); bname = conv_filename_from_utf8(bname_); subst_for_filename(bname); } if (!bname || *bname == '\0') filename = procmime_get_tmp_file_name(partinfo); else filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S, bname, NULL); if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) { g_warning(_("Can't save the part of multipart message.")); } else mimeview->drag_file = encode_uri(filename); g_free(filename); gtk_drag_set_icon_default(drag_context); }
static gboolean scan_func(GNode *node, gpointer data) { struct clamd_result *result = (struct clamd_result *) data; MimeInfo *mimeinfo = (MimeInfo *) node->data; gchar *outfile; response buf; int max; GStatBuf info; gchar* msg; outfile = procmime_get_tmp_file_name(mimeinfo); if (procmime_get_part(outfile, mimeinfo) < 0) g_warning("Can't get the part of multipart message."); else { max = config.clamav_max_size * 1048576; /* maximum file size */ if (g_stat(outfile, &info) == -1) g_warning("Can't determine file size"); else { if (info.st_size <= max) { debug_print("Scanning %s\n", outfile); result->status = clamd_verify_email(outfile, &buf); debug_print("status: %d\n", result->status); switch (result->status) { case NO_SOCKET: g_warning("[scanning] No socket information"); if (config.alert_ack) { alertpanel_error(_("Scanning\nNo socket information.\nAntivirus disabled.")); config.alert_ack = FALSE; } break; case NO_CONNECTION: g_warning("[scanning] Clamd does not respond to ping"); if (config.alert_ack) { alertpanel_warning(_("Scanning\nClamd does not respond to ping.\nIs clamd running?")); config.alert_ack = FALSE; } break; case VIRUS: msg = g_strconcat(_("Detected %s virus."), clamd_get_virus_name(buf.msg), NULL); g_warning("%s\n", msg); debug_print("no_recv: %d\n", prefs_common_get_prefs()->no_recv_err_panel); if (prefs_common_get_prefs()->no_recv_err_panel) { statusbar_print_all("%s", msg); } else { alertpanel_warning("%s\n", msg); } g_free(msg); config.alert_ack = TRUE; break; case SCAN_ERROR: debug_print("Error: %s\n", buf.msg); if (config.alert_ack) { alertpanel_error(_("Scanning error:\n%s"), buf.msg); config.alert_ack = FALSE; } break; case OK: debug_print("No virus detected.\n"); config.alert_ack = TRUE; break; } } else { msg = g_strdup_printf(_("File: %s. Size (%d) greater than limit (%d)\n"), outfile, (int) info.st_size, max); statusbar_print_all("%s", msg); debug_print("%s", msg); g_free(msg); } } g_unlink(outfile); } return (result->status == OK) ? FALSE : TRUE; }