commit 8b9a9329b104f4b3581fe1f18e7c4b644134be25
parent e31ec07076724b7674db10da03ff959312ff7129
Author: Michael Rasmussen <mir@datanom.net>
Date: Tue, 22 Apr 2014 00:02:29 +0200
Only show error popup first time an error is found.
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.
Diffstat:
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/plugins/clamd/clamav_plugin.c b/src/plugins/clamd/clamav_plugin.c
@@ -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:
diff --git a/src/plugins/clamd/clamav_plugin.h b/src/plugins/clamd/clamav_plugin.h
@@ -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);