1 ;;; elmo-spam.el --- Spam filtering interface to processor.
3 ;; Copyright (C) 2003 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
4 ;; Copyright (C) 2003 Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Author: Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
7 ;; Keywords: mail, net news, spam
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
33 (eval-when-compile (require 'cl))
39 (defgroup elmo-spam nil
40 "Spam configuration for wanderlust."
43 (defcustom elmo-spam-scheme nil
44 "*Scheme of spam processor implementation. "
45 :type '(choice (const :tag "none" nil)
46 (const :tag "Bogofilter" bogofilter)
47 (const :tag "Spamfilter" spamfilter)
48 (const :tag "SpamAssassin" sa)
49 (const :tag "Bsfilter" bsfilter))
53 (luna-define-class elsp-generic ()))
56 (luna-define-generic elmo-spam-buffer-spam-p (processor buffer
58 "Return non-nil if contents of BUFFER is spam.
59 PROCESSOR is spam processor structure.
60 If optional augument REGISTER is non-nil,
61 register according to the classification.")
63 (luna-define-generic elmo-spam-register-spam-buffer (processor
66 "Register contents of BUFFER as spam.
67 PROCESSOR is spam processor structure.
68 If optional argument RESTORE is non-nil, unregister from non-spam list.")
70 (luna-define-generic elmo-spam-register-good-buffer (processor
73 "Register contents of BUFFER as non-spam.
74 PROCESSOR is spam processor structure.
75 If optional argument RESTORE is non-nil, unregister from spam list.")
78 (luna-define-generic elmo-spam-modified-p (processor)
79 "Return non-nil if status of PROCESSOR is modified.")
81 (luna-define-generic elmo-spam-save-status (processor)
82 "Save status of the PROCESSOR.")
84 (luna-define-generic elmo-spam-message-spam-p (processor folder number
86 "Return non-nil if the message in the FOLDER with NUMBER is spam.
87 PROCESSOR is spam processor structure.
88 If optional augument REGISTER is non-nil,
89 register according to the classification.")
91 (luna-define-generic elmo-spam-list-spam-messages (processor
92 folder &optional numbers)
93 "Return a list of message numbers which is gussed spam.
94 PROCESSOR is spam processor structure.
95 FOLDER is the ELMO folder structure.
96 If optional argument NUMBERS is specified and is a list of message numbers,
97 messages are searched from the list.")
99 (luna-define-generic elmo-spam-register-spam-messages (processor
103 "Register contents of messages as spam.
104 PROCESSOR is spam processor structure.
105 FOLDER is the ELMO folder structure.
106 If optional argument NUMBERS is specified and is a list of message numbers,
107 messages are searched from the list.
108 If optional argument RESTORE is non-nil, unregister from non-spam list.")
110 (luna-define-generic elmo-spam-register-good-messages (processor
114 "Register contents of messages as non spam.
115 PROCESSOR is spam processor structure.
116 FOLDER is the ELMO folder structure.
117 If optional argument NUMBERS is specified and is a list of message numbers,
118 messages are searched from the list.
119 If optional argument RESTORE is non-nil, unregister from spam list.")
122 (defun elmo-spam-message-fetch (folder number)
123 (let (elmo-message-fetch-threshold)
126 (elmo-find-fetch-strategy folder
127 (elmo-message-entity folder number))
128 nil (current-buffer) 'unread)))
131 (luna-define-method elmo-spam-message-spam-p ((processor elsp-generic)
132 folder number &optional register)
134 (elmo-spam-message-fetch folder number)
135 (elmo-spam-buffer-spam-p processor (current-buffer) register)))
137 (luna-define-method elmo-spam-list-spam-messages ((processor elsp-generic)
138 folder &optional numbers)
139 (let ((numbers (or numbers (elmo-folder-list-messages folder t t)))
141 (dolist (number numbers)
142 (when (elmo-spam-message-spam-p processor folder number)
143 (setq spam-list (cons number spam-list)))
144 (elmo-progress-notify 'elmo-spam-check-spam))
145 (nreverse spam-list)))
147 (luna-define-method elmo-spam-register-spam-messages ((processor elsp-generic)
151 (let ((numbers (or numbers (elmo-folder-list-messages folder t t))))
153 (buffer-disable-undo (current-buffer))
154 (dolist (number numbers)
156 (elmo-spam-message-fetch folder number)
157 (elmo-spam-register-spam-buffer processor (current-buffer) restore)
158 (elmo-progress-notify 'elmo-spam-register)))))
160 (luna-define-method elmo-spam-register-good-messages ((processor elsp-generic)
164 (let ((numbers (or numbers (elmo-folder-list-messages folder t t))))
166 (buffer-disable-undo (current-buffer))
167 (dolist (number numbers)
169 (elmo-spam-message-fetch folder number)
170 (elmo-spam-register-good-buffer processor (current-buffer) restore)
171 (elmo-progress-notify 'elmo-spam-register)))))
173 (provide 'elsp-generic)
175 (defvar elmo-spam-processor-internal nil)
177 (defun elmo-spam-processor (&optional if-exists)
178 (or elmo-spam-processor-internal
180 (let* ((scheme (or elmo-spam-scheme 'generic))
181 (class (intern (format "elsp-%s" scheme))))
183 (setq elmo-spam-processor-internal
184 (luna-make-entity class))))))
187 (product-provide (provide 'elmo-spam) (require 'elmo-version))
189 ;;; elmo-spam.el ends here