* elmo-spam.el (elmo-spam-scheme): Add 'bsfilter' as a candidate.
authorhmurata <hmurata>
Sun, 11 Jan 2004 15:21:33 +0000 (15:21 +0000)
committerhmurata <hmurata>
Sun, 11 Jan 2004 15:21:33 +0000 (15:21 +0000)
* elsp-bsfilter.el: New file.

* WL-ELS (ELMO-MODULES): Added elsp-bsfilter.

ChangeLog
WL-ELS
elmo/ChangeLog
elmo/elmo-spam.el
elmo/elsp-bsfilter.el [new file with mode: 0644]

index 4062161..dd2abc8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-01-11  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * WL-ELS (ELMO-MODULES): Added elsp-bsfilter.
+
 2004-01-11  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * WL-ELS (ELMO-MODULES): Added elsp-sa.
diff --git a/WL-ELS b/WL-ELS
index 3966b15..e334285 100644 (file)
--- a/WL-ELS
+++ b/WL-ELS
@@ -23,7 +23,7 @@
    elmo-archive elmo-pipe elmo-cache
    elmo-internal elmo-flag elmo-sendlog
    elmo-dop elmo-nmz elmo-split
-   elmo-spam elsp-bogofilter elsp-sa
+   elmo-spam elsp-bogofilter elsp-sa elsp-bsfilter
    modb modb-entity modb-legacy modb-standard
    ))
 
index e9ab7c9..d08e41d 100644 (file)
@@ -1,5 +1,9 @@
 2004-01-11  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
+       * elmo-spam.el (elmo-spam-scheme): Add 'bsfilter' as a candidate.
+
+       * elsp-bsfilter.el: New file.
+
        * elmo-pipe.el (elmo-folder-list-unreads,
        elmo-folder-list-answereds,
        elmo-folder-list-importants,
index 48ba52e..63bd6f4 100644 (file)
@@ -45,7 +45,8 @@
   :type '(choice (const :tag "none" nil)
                 (const :tag "Bogofilter" bogofilter)
                 (const :tag "Spamfilter" spamfilter)
-                (const :tag "SpamAssassin" sa))
+                (const :tag "SpamAssassin" sa)
+                (const :tag "Bsfilter" bsfilter))
   :group 'elmo-spam)
 
 (eval-and-compile
diff --git a/elmo/elsp-bsfilter.el b/elmo/elsp-bsfilter.el
new file mode 100644 (file)
index 0000000..8444c9c
--- /dev/null
@@ -0,0 +1,112 @@
+;;; elsp-bsfilter.el --- Bsfilter support for elmo-spam.
+
+;; Copyright (C) 2004 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+;; Copyright (C) 2004 Yuuichi Teranishi <teranisi@gohome.org>
+
+;; Author: Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+;; Keywords: mail, net news, spam
+
+;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+;;
+
+;;; Commentary:
+;;
+
+;;; Code:
+;;
+(require 'elmo-spam)
+(require 'luna)
+
+(defgroup elmo-spam-bsfilter nil
+  "Spam bsfilter configuration."
+  :group 'elmo-spam)
+
+(defcustom elmo-spam-bsfilter-shell-program (or explicit-shell-file-name
+                                               shell-file-name)
+  "*"
+  :type 'string
+  :group 'elmo-spam-bsfilter)
+
+(defcustom elmo-spam-bsfilter-shell-switch shell-command-switch
+  "*"
+  :type 'string
+  :group 'elmo-spam-bsfilter)
+
+(defcustom elmo-spam-bsfilter-program "bsfilter"
+  "*Program name of the Bsfilter."
+  :type '(string :tag "Program name of the bsfilter")
+  :group 'elmo-spam-bsfilter)
+
+(defcustom elmo-spam-bsfilter-args nil
+  "*Argument list for bsfilter."
+  :type '(repeat string)
+  :group 'elmo-spam-bsfilter)
+
+(defcustom elmo-spam-bsfilter-update-switch "--synchronous-auto-update"
+  "*The switch that Bsfilter uses to update database with classify."
+  :type 'string
+  :group 'elmo-spam-bsfilter)
+
+(defcustom elmo-spam-bsfilter-database-directory nil
+  "*Directory path of the Bsfilter databases."
+  :type '(choice (directory :tag "Location of the Bsfilter database directory")
+                (const :tag "Use the default"))
+  :group 'elmo-spam-bsfilter)
+
+(eval-and-compile
+  (luna-define-class elsp-bsfilter (elsp-generic)))
+
+(defsubst elsp-bsfilter-call-bsfilter (&rest args)
+  (apply #'call-process-region
+        (point-min) (point-max)
+        elmo-spam-bsfilter-shell-program
+        nil nil nil
+        (append (list elmo-spam-bsfilter-shell-switch
+                      elmo-spam-bsfilter-program)
+                elmo-spam-bsfilter-args
+                (delq nil (elmo-flatten args)))))
+
+(luna-define-method elmo-spam-buffer-spam-p ((processor elsp-bsfilter)
+                                            buffer &optional register)
+  (with-current-buffer buffer
+    (= 0 (elsp-bsfilter-call-bsfilter
+         (if register elmo-spam-bsfilter-update-switch)
+         (if elmo-spam-bsfilter-database-directory
+             (list "--homedir" elmo-spam-bsfilter-database-directory))))))
+
+(defsubst elsp-bsfilter-register-buffer (buffer spam restore)
+  (with-current-buffer buffer
+    (elsp-bsfilter-call-bsfilter
+     "--update"
+     (if elmo-spam-bsfilter-database-directory
+        (list "--homedir" elmo-spam-bsfilter-database-directory))
+     (if restore (if spam "--sub-clean" "--sub-spam"))
+     (if spam "--add-spam" "--add-clean"))))
+
+(luna-define-method elmo-spam-register-spam-buffer ((processor elsp-bsfilter)
+                                                   buffer &optional restore)
+  (elsp-bsfilter-register-buffer buffer t restore))
+
+(luna-define-method elmo-spam-register-good-buffer ((processor elsp-bsfilter)
+                                                   buffer &optional restore)
+  (elsp-bsfilter-register-buffer buffer nil restore))
+
+(require 'product)
+(product-provide (provide 'elsp-bsfilter) (require 'elmo-version))
+
+;;; elsp-bsfilter.el ends here