Only show error popup first time an error is found.
authorMichael Rasmussen <mir@datanom.net>
Mon, 21 Apr 2014 22:02:29 +0000 (00:02 +0200)
committerMichael Rasmussen <mir@datanom.net>
Mon, 21 Apr 2014 22:02:29 +0000 (00:02 +0200)
An error popup is shown if an error is found under init
or first time an error found under scanning. Error popup
is suppressed until restarting claws or a scanning is
performed with success.

src/plugins/clamd/clamav_plugin.c
src/plugins/clamd/clamav_plugin.h

index 4f184e365f6d9c5a9829947d1a9fbdb3e7e65091..87a8fb742764fc92ff70b9fcc5020f9ba2562efc 100644 (file)
@@ -103,11 +103,17 @@ static gboolean scan_func(GNode *node, gpointer data)
                                switch (result->status) {
                                        case NO_SOCKET: 
                                                g_warning("[scanning] No socket information");
-                                               alertpanel_error(_("Scanning\nNo socket information.\nAntivirus disabled."));
+                                               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");
-                                               alertpanel_warning(_("Scanning\nClamd does not respond to ping.\nIs clamd running?"));
+                                               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."),
@@ -121,19 +127,27 @@ static gboolean scan_func(GNode *node, gpointer data)
                                                    alertpanel_warning("%s\n", msg);
                                                }
                                                g_free(msg);
+                                               config.alert_ack = TRUE;
                                                break;
                                        case SCAN_ERROR:
                                                debug_print("Error: %s\n", buf.msg);
-                                               alertpanel_error(_("Scanning error:\n%s"), 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 {
-                               debug_print("File: %s. Size (%d) greater than limit (%d)\n",
-                                                       outfile, (int) info.st_size, max);
+                               msg = g_strconcat(_("File: %s. Size (%d) greater than limit (%d)\n"),
+                                       outfile, (int) info.st_size, max);
+                               statusbar_print_all("%s", msg);
+                               debug_print(msg);
+                               g_free(msg);
                        }
                }
                g_unlink(outfile);
@@ -181,7 +195,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        }
        
        procmime_mimeinfo_free_all(mimeinfo);
-       
+
        return (result.status == OK) ? FALSE : TRUE;
 }
 
@@ -272,6 +286,7 @@ gint plugin_init(gchar **error)
 
        if (config.clamav_enable) {
                debug_print("Creating socket\n");
+               config.alert_ack = TRUE;
                Clamd_Stat status = clamd_prepare();
                switch (status) {
                        case NO_SOCKET: 
index e6530af368f4f339ca0e2c35700c5abb2baeec91..8b1c6e4e5ae961433b37a5c60940ff7b73523e3d 100644 (file)
@@ -36,14 +36,15 @@ struct _ClamAvConfig
        gchar           *clamav_save_folder;
        gboolean         clamd_config_type;
        gchar           *clamd_host;
-       int                      clamd_port;
+       int              clamd_port;
        gchar           *clamd_config_folder;
+       gboolean        alert_ack;
 };
 
 ClamAvConfig *clamav_get_config                  (void);
 void         clamav_save_config          (void);
 void         clamav_set_message_callback (MessageCallback callback);
-Clamd_Stat       clamd_prepare(void);
+Clamd_Stat    clamd_prepare(void);
 gint         clamav_gtk_init(void);
 void         clamav_gtk_done(void);