fix bug where multipart/alternative messages would slip through without being scanned
[claws.git] / src / plugins / clamav / clamav_plugin.c
index 8da381d1a301541c4081dbcb56c85bd7a5caf208..c6ee1d5c7e224f9fc17045d5a718b41defbd63a7 100644 (file)
@@ -26,8 +26,9 @@
 #include <glib.h>
 #include <clamav.h>
 
-#include "common/plugin.h"
-#include "common/utils.h"
+#include "intl.h"
+#include "plugin.h"
+#include "utils.h"
 #include "hooks.h"
 #include "inc.h"
 #include "mimeview.h"
@@ -56,16 +57,6 @@ static PrefParam param[] = {
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
-#define IS_FIRST_PART_TEXT(info) \
-       ((info->mime_type == MIME_TEXT || info->mime_type == MIME_TEXT_HTML || \
-         info->mime_type == MIME_TEXT_ENRICHED) || \
-        (info->mime_type == MIME_MULTIPART && info->content_type && \
-         !strcasecmp(info->content_type, "multipart/alternative") && \
-         (info->children && \
-          (info->children->mime_type == MIME_TEXT || \
-           info->children->mime_type == MIME_TEXT_HTML || \
-           info->children->mime_type == MIME_TEXT_ENRICHED))))
-
 static gboolean mail_filtering_hook(gpointer source, gpointer data)
 {
        MailFilteringData *mail_filtering_data = (MailFilteringData *) source;
@@ -80,7 +71,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
 
        int ret, no;
        unsigned long int size;
-       long double kb;
        char *virname;
        struct cl_node *root = NULL;
        struct cl_limits limits;
@@ -97,16 +87,13 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        if (!mimeinfo) return FALSE;
 
        child = mimeinfo->children;
-       if (!child || IS_FIRST_PART_TEXT(mimeinfo)) {
+       if (!child) {
                procmime_mimeinfo_free_all(mimeinfo);
                return FALSE;
        }
 
        debug_print("Scanning message %d for viruses\n", msginfo->msgnum);
 
-       if (IS_FIRST_PART_TEXT(child))
-               child = child->next;
-
        infile = procmsg_get_message_file_path(msginfo);
 
 
@@ -153,9 +140,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                                        debug_print("Error: %s\n", cl_perror(ret));
                        }
 
-                       kb = size * (CL_COUNT_PRECISION / 1024);
-                       debug_print("Data scanned: %2.2Lf Kb\n", kb);
-    
                        unlink(outfile);
 
                        if (is_infected) break;
@@ -164,7 +148,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        }
 
        if (is_infected) {
-               debug_print("message part(s) infected with %s\n", virname);
                if (config.clamav_recv_infected) {
                        FolderItem *clamav_save_folder;
 
@@ -187,14 +170,12 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        return is_infected;
 }
 
-#undef IS_FIRST_PART_TEXT
-
-ClamAvConfig *clamav_get_config()
+ClamAvConfig *clamav_get_config(void)
 {
        return &config;
 }
 
-void clamav_save_config()
+void clamav_save_config(void)
 {
        PrefFile *pfile;
        gchar *rcpath;
@@ -234,7 +215,7 @@ gint plugin_init(gchar **error)
        
 }
 
-void plugin_done()
+void plugin_done(void)
 {
        hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
        g_free(config.clamav_save_folder);
@@ -242,14 +223,14 @@ void plugin_done()
        debug_print("ClamAV plugin unloaded\n");
 }
 
-const gchar *plugin_name()
+const gchar *plugin_name(void)
 {
-       return "Clam AntiVirus";
+       return _("Clam AntiVirus");
 }
 
-const gchar *plugin_desc()
+const gchar *plugin_desc(void)
 {
-       return "This plugin uses Clam AntiVirus to scan all message attachments "
+       return _("This plugin uses Clam AntiVirus to scan all message attachments "
               "that are received from a POP account.\n"
               "\n"
               "When a message attachment is found to contain a virus it can be "
@@ -258,10 +239,10 @@ const gchar *plugin_desc()
               "This plugin only contains the actual function for scanning "
               "and deleting or moving the message. You probably want to load "
               "the Gtk+ User Interface plugin too, otherwise you will have to "
-              "manually write the plugin configuration.\n";
+              "manually write the plugin configuration.\n");
 }
 
-const gchar *plugin_type()
+const gchar *plugin_type(void)
 {
        return "Common";
 }