From 7b38fcff8316a9efcb83e4b8e93829117399a3cd Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Fri, 6 Feb 2004 17:44:54 +0000 Subject: move to the next message after mark not junk as well 2004-02-06 Radek Doulik * em-folder-view.c (emfv_popup_mark_nojunk): move to the next message after mark not junk as well * em-junk-filter.c (em_junk_sa_test_spamd): split into spamassassin and spamd tests (em_junk_sa_is_available): test spamd only if spamd usage enabled (pipe_to_sa_with_error): extended pipe_to_sa, last added parametr specifies return value if an error occured (em_junk_sa_check_junk): don't use /bin/sh -c when running spamassassin, it's not needed and we need to avoid getting 126,127 exit codes from the shell (em_junk_sa_check_junk): pass 0 rv_err to pipe_to_sa_with_error to avoid false positives in case someone removes/uninstalls SA while evolution runs svn path=/trunk/; revision=24651 --- mail/ChangeLog | 11 +++++++++++ mail/em-folder-view.c | 2 ++ mail/em-junk-filter.c | 40 +++++++++++++++++++++------------------- 3 files changed, 34 insertions(+), 19 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 3c0c219b7d..59a144e955 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,8 +1,19 @@ 2004-02-06 Radek Doulik + * em-folder-view.c (emfv_popup_mark_nojunk): move to the next + message after mark not junk as well + * em-junk-filter.c (em_junk_sa_test_spamd): split into spamassassin and spamd tests (em_junk_sa_is_available): test spamd only if spamd usage enabled + (pipe_to_sa_with_error): extended pipe_to_sa, last added parametr + specifies return value if an error occured + (em_junk_sa_check_junk): don't use /bin/sh -c when running + spamassassin, it's not needed and we need to avoid getting 126,127 + exit codes from the shell + (em_junk_sa_check_junk): pass 0 rv_err to pipe_to_sa_with_error to + avoid false positives in case someone removes/uninstalls SA while + evolution runs 2004-02-06 Not Zed diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 1125f9629c..dfad679d16 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -598,6 +598,8 @@ emfv_popup_mark_nojunk (GtkWidget *w, EMFolderView *emfv) uids = message_list_get_selected(emfv->list); em_folder_view_mark_selected(emfv, CAMEL_MESSAGE_JUNK, 0); + if (uids->len == 1) + message_list_select(emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0, FALSE); mail_mark_junk(emfv->folder, uids, FALSE); } diff --git a/mail/em-junk-filter.c b/mail/em-junk-filter.c index 29e618205f..8c178a0fe9 100644 --- a/mail/em-junk-filter.c +++ b/mail/em-junk-filter.c @@ -95,7 +95,7 @@ em_junk_sa_get_daemon_port () } static int -pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) +pipe_to_sa_with_error (CamelMimeMessage *msg, const char *in, char **argv, int rv_err) { int result, status, errnosav, fds[2]; CamelStream *stream; @@ -116,7 +116,7 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) errnosav = errno; d(printf ("failed to create a pipe (for use with spamassassin: %s\n", strerror (errno))); errno = errnosav; - return -1; + return rv_err; } if (!(pid = fork ())) { @@ -128,7 +128,7 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) if (dup2 (fds[0], STDIN_FILENO) == -1 || dup2 (nullfd, STDOUT_FILENO) == -1 || dup2 (nullfd, STDERR_FILENO) == -1) - _exit (255); + _exit (rv_err & 0377); setsid (); @@ -137,13 +137,13 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) fcntl (fd, F_SETFD, FD_CLOEXEC); execvp (argv[0], argv); - _exit (255); + _exit (rv_err & 0377); } else if (pid < 0) { errnosav = errno; close (fds[0]); close (fds[1]); errno = errnosav; - return -1; + return rv_err; } /* parent process */ @@ -178,7 +178,13 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) if (result != -1 && WIFEXITED (status)) return WEXITSTATUS (status); else - return -1; + return rv_err; +} + +static int +pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv) +{ + return pipe_to_sa_with_error (msg, in, argv, -1); } static int @@ -206,10 +212,9 @@ em_junk_sa_test_spamd_running (int port) static void em_junk_sa_test_spamassassin (void) { - char *argv[4] = { - "/bin/sh", - "-c", - "spamassassin --version", + char *argv [3] = { + "spamassassin", + "--version", NULL, }; @@ -304,7 +309,7 @@ static gboolean em_junk_sa_check_junk (CamelMimeMessage *msg) { char *argv[5], buf[12]; - int i = 0; + int i = 0, rv; d(fprintf (stderr, "em_junk_sa_check_junk\n")); @@ -320,18 +325,15 @@ em_junk_sa_check_junk (CamelMimeMessage *msg) argv[i++] = buf; } } else { - argv[i++] = "/bin/sh"; - argv[i++] = "-c"; - + argv [i++] = "spamassassin"; + argv [i++] = "--exit-code"; if (em_junk_sa_get_local_only ()) - argv[i++] = "spamassassin --exit-code --local"; - else - argv[i++] = "spamassassin --exit-code"; + argv [i++] = "--local"; } argv[i] = NULL; - - return pipe_to_sa (msg, NULL, argv); + + return pipe_to_sa_with_error (msg, NULL, argv, 0) != 0; } static void -- cgit v1.2.3