#include <sys/wait.h>
#include <glib.h>
+#include <glib/gi18n.h>
#if HAVE_LOCALE_H
# include <locale.h>
#include "folder.h"
#include "prefs.h"
#include "prefs_gtk.h"
-#include "intl.h"
#include "libspamc.h"
#include "spamassassin.h"
static guint hook_id;
static int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK | SPAMC_CHECK_ONLY;
static gchar *username = NULL;
+static MessageCallback message_callback;
static SpamAssassinConfig config;
return FALSE;
debug_print("Filtering message %d\n", msginfo->msgnum);
+ if (message_callback != NULL)
+ message_callback(_("SpamAssassin: filtering message..."));
if ((fp = procmsg_open_message(msginfo)) == NULL) {
debug_print("failed to open message file\n");
running |= CHILD_RUNNING;
- g_timeout_add(1000, timeout_func, &running);
+ g_timeout_add(50, timeout_func, &running);
running |= TIMEOUT_RUNNING;
while(running & CHILD_RUNNING) {
- waitpid(pid, &status, WNOHANG);
- if (WIFEXITED(status)) {
+ int ret;
+
+ ret = waitpid(pid, &status, WNOHANG);
+ if (ret == pid) {
+ if (WIFEXITED(status)) {
+ running &= ~CHILD_RUNNING;
+ is_spam = WEXITSTATUS(status) == 1 ? TRUE : FALSE;
+ }
+ } if (ret < 0) {
running &= ~CHILD_RUNNING;
- }
+ } /* ret == 0 continue */
g_main_iteration(TRUE);
}
while (running & TIMEOUT_RUNNING)
g_main_iteration(TRUE);
}
- is_spam = WEXITSTATUS(status) == 1 ? TRUE : FALSE;
fclose(fp);
prefs_file_close(pfile);
}
+void spamassassin_set_message_callback(MessageCallback callback)
+{
+ message_callback = callback;
+}
+
gint plugin_init(gchar **error)
{
+ gchar *rcpath;
+
if ((sylpheed_get_version() > VERSION_NUMERIC)) {
*error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
return -1;
username = g_get_user_name();
if (username == NULL) {
+ hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
*error = g_strdup("Failed to get username");
return -1;
}
prefs_set_default(param);
- prefs_read_config(param, "SpamAssassin", COMMON_RC);
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+ prefs_read_config(param, "SpamAssassin", rcpath, NULL);
+ g_free(rcpath);
debug_print("Spamassassin plugin loaded\n");