2005-12-06 [paul] 1.9.100cvs69
[claws.git] / src / plugins / clamav / clamav_plugin.c
index 488fbaf9c24be1736b698cfc542d17f32f6c01a6..101ec938ae98f4811ff5c0e61c74c4cfdbfbc6c9 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -93,7 +93,7 @@ static gboolean scan_func(GNode *node, gpointer data)
                                debug_print("Error: %s\n", cl_strerror(ret));
                }
 
-               unlink(outfile);
+               g_unlink(outfile);
        }
 
        return params->is_infected;
@@ -123,6 +123,8 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        params.limits.maxfiles = 1000; /* max files */
        params.limits.maxfilesize = config.clamav_max_size * 1048576; /* maximum archived file size */
        params.limits.maxreclevel = 8; /* maximum recursion level */
+       params.limits.maxratio = 200; /* maximal compression ratio */
+       params.limits.archivememlim = 0; /* disable memory limit for bzip2 scanner */
 
        if (config.clamav_enable_arc)
                params.scan_archive = TRUE;
@@ -183,17 +185,21 @@ void clamav_set_message_callback(MessageCallback callback)
        message_callback = callback;
 }
 
+int cl_build(struct cl_node *root);
+void cl_free(struct cl_node *root);
 gint plugin_init(gchar **error)
 {
        gchar *rcpath;
-       int no, ret;
+       int ret;
+       unsigned int no;
+
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
-               *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
+               *error = g_strdup("Your version of Sylpheed-Claws is newer than the version the ClamAV plugin was built with");
                return -1;
        }
 
        if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
-               *error = g_strdup("Your sylpheed version is too old");
+               *error = g_strdup("Your version of Sylpheed-Claws is too old for the ClamAV plugin");
                return -1;
        }
 
@@ -208,14 +214,19 @@ gint plugin_init(gchar **error)
        prefs_read_config(param, "ClamAV", rcpath, NULL);
        g_free(rcpath);
 
-       if ((ret = cl_loaddbdir(cl_retdbdir(), &cl_database, &no)) != 0) {
+       clamav_gtk_init();
+
+       if ((ret = cl_loaddbdir(cl_retdbdir(), &cl_database, &no))) {
                debug_print("cl_loaddbdir: %s\n", cl_strerror(ret));
                return -1;
        }
 
        debug_print("Database loaded (containing in total %d signatures)\n", no);
 
-       cl_buildtrie(cl_database);
+       if((ret = cl_build(cl_database))) {
+               debug_print("Database initialization error: %s\n", cl_strerror(ret));
+               return -1;
+       }
 
        debug_print("ClamAV plugin loaded\n");
 
@@ -227,7 +238,9 @@ void plugin_done(void)
 {
        hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
        g_free(config.clamav_save_folder);
-       cl_freetrie(cl_database);
+       cl_free(cl_database);
+       clamav_gtk_done();
+
        debug_print("ClamAV plugin unloaded\n");
 }
 
@@ -243,14 +256,10 @@ const gchar *plugin_desc(void)
               "\n"
               "When a message attachment is found to contain a virus it can be "
               "deleted or saved in a specially designated folder.\n"
-              "\n"
-              "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");
+              "\n");
 }
 
 const gchar *plugin_type(void)
 {
-       return "Common";
+       return "GTK2";
 }