/[emacs]/emacs/lisp/gnus/spam.el
ViewVC logotype

Diff of /emacs/lisp/gnus/spam.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by rms, Thu Nov 4 10:07:27 2004 UTC revision 1.7 by miles, Tue Dec 7 21:56:39 2004 UTC
# Line 295  All unmarked article in such group recei Line 295  All unmarked article in such group recei
295    
296  (defcustom spam-blackhole-good-server-regex nil  (defcustom spam-blackhole-good-server-regex nil
297    "String matching IP addresses that should not be checked in the blackholes."    "String matching IP addresses that should not be checked in the blackholes."
298    :type '(radio (const nil)    :type '(radio (const nil) regexp)
                 (regexp :format "%t: %v\n" :size 0))  
299    :group 'spam)    :group 'spam)
300    
301  (defcustom spam-face 'gnus-splash-face  (defcustom spam-face 'gnus-splash-face
# Line 1257  functions") Line 1256  functions")
1256    
1257  ;;;; Hashcash.  ;;;; Hashcash.
1258    
1259    (eval-when-compile
1260      (autoload 'mail-check-payment "hashcash"))
1261    
1262  (condition-case nil  (condition-case nil
1263      (progn      (progn
1264        (require 'hashcash)        (require 'hashcash)
# Line 1265  functions") Line 1267  functions")
1267          "Check the headers for hashcash payments."          "Check the headers for hashcash payments."
1268          (mail-check-payment)))   ;mail-check-payment returns a boolean          (mail-check-payment)))   ;mail-check-payment returns a boolean
1269    
1270    (file-error (progn    (file-error))
                 (defalias 'mail-check-payment 'ignore)  
                 (defalias 'spam-check-hashcash 'ignore))))  
1271    
1272  ;;;; BBDB  ;;;; BBDB
1273    
# Line 1276  functions") Line 1276  functions")
1276    
1277  ;; all this is done inside a condition-case to trap errors  ;; all this is done inside a condition-case to trap errors
1278    
1279  (condition-case nil  (eval-when-compile
1280      (progn    (autoload 'bbdb-buffer "bbdb")
1281        (require 'bbdb)    (autoload 'bbdb-create-internal "bbdb")
1282        (require 'bbdb-com)    (autoload 'bbdb-search-simple "bbdb"))
1283    
1284    (eval-and-compile
1285      (when (condition-case nil
1286                (progn
1287                  (require 'bbdb)
1288                  (require 'bbdb-com))
1289              (file-error
1290               (defalias 'spam-BBDB-register-routine 'ignore)
1291               (defalias 'spam-enter-ham-BBDB 'ignore)
1292               nil))
1293    
1294        (defun spam-enter-ham-BBDB (addresses &optional remove)
1295          "Enter an address into the BBDB; implies ham (non-spam) sender"
1296          (dolist (from addresses)
1297            (when (stringp from)
1298              (let* ((parsed-address (gnus-extract-address-components from))
1299                     (name (or (nth 0 parsed-address) "Ham Sender"))
1300                     (remove-function (if remove
1301                                          'bbdb-delete-record-internal
1302                                        'ignore))
1303                     (net-address (nth 1 parsed-address))
1304                     (record (and net-address
1305                                  (bbdb-search-simple nil net-address))))
1306                (when net-address
1307                  (gnus-message 5 "%s address %s %s BBDB"
1308                                (if remove "Deleting" "Adding")
1309                                from
1310                                (if remove "from" "to"))
1311                  (if record
1312                      (funcall remove-function record)
1313                    (bbdb-create-internal name nil net-address nil nil
1314                                          "ham sender added by spam.el")))))))
1315    
1316        (defun spam-enter-ham-BBDB (addresses &optional remove)      (defun spam-BBDB-register-routine (articles &optional unregister)
1317          "Enter an address into the BBDB; implies ham (non-spam) sender"        (let (addresses)
1318          (dolist (from addresses)          (dolist (article articles)
1319            (when (stringp from)            (when (stringp (spam-fetch-field-from-fast article))
1320              (let* ((parsed-address (gnus-extract-address-components from))              (push (spam-fetch-field-from-fast article) addresses)))
1321                     (name (or (nth 0 parsed-address) "Ham Sender"))          ;; now do the register/unregister action
1322                     (remove-function (if remove          (spam-enter-ham-BBDB addresses unregister)))
1323                                          'bbdb-delete-record-internal  
1324                                        'ignore))      (defun spam-BBDB-unregister-routine (articles)
1325                     (net-address (nth 1 parsed-address))        (spam-BBDB-register-routine articles t))
1326                     (record (and net-address  
1327                                  (bbdb-search-simple nil net-address))))      (defun spam-check-BBDB ()
1328                (when net-address        "Mail from people in the BBDB is classified as ham or non-spam"
1329                  (gnus-message 5 "%s address %s %s BBDB"        (let ((who (nnmail-fetch-field "from"))
1330                                (if remove "Deleting" "Adding")              (spam-split-group (if spam-split-symbolic-return
1331                                from                                    'spam
1332                                (if remove "from" "to"))                                  spam-split-group)))
1333                  (if record          (when who
1334                      (funcall remove-function record)            (setq who (nth 1 (gnus-extract-address-components who)))
1335                    (bbdb-create-internal name nil net-address nil nil            (if (bbdb-search-simple nil who)
1336                                          "ham sender added by spam.el")))))))                t
1337                (if spam-use-BBDB-exclusive
1338        (defun spam-BBDB-register-routine (articles &optional unregister)                  spam-split-group
1339          (let (addresses)                nil)))))))
           (dolist (article articles)  
             (when (stringp (spam-fetch-field-from-fast article))  
               (push (spam-fetch-field-from-fast article) addresses)))  
           ;; now do the register/unregister action  
           (spam-enter-ham-BBDB addresses unregister)))  
   
       (defun spam-BBDB-unregister-routine (articles)  
         (spam-BBDB-register-routine articles t))  
   
       (defun spam-check-BBDB ()  
         "Mail from people in the BBDB is classified as ham or non-spam"  
         (let ((who (nnmail-fetch-field "from"))  
               (spam-split-group (if spam-split-symbolic-return  
                                     'spam  
                                   spam-split-group)))  
           (when who  
             (setq who (nth 1 (gnus-extract-address-components who)))  
             (if (bbdb-search-simple nil who)  
                 t  
               (if spam-use-BBDB-exclusive  
                   spam-split-group  
                 nil))))))  
   
   (file-error (progn  
                 (defalias 'bbdb-search-simple 'ignore)  
                 (defalias 'spam-check-BBDB 'ignore)  
                 (defalias 'spam-BBDB-register-routine 'ignore)  
                 (defalias 'spam-enter-ham-BBDB 'ignore)  
                 (defalias 'bbdb-create-internal 'ignore)  
                 (defalias 'bbdb-delete-record-internal 'ignore)  
                 (defalias 'bbdb-records 'ignore))))  
1340    
1341    
1342  ;;;; ifile  ;;;; ifile
# Line 1411  Uses `gnus-newsgroup-name' if category i Line 1412  Uses `gnus-newsgroup-name' if category i
1412    
1413  ;;;; spam-stat  ;;;; spam-stat
1414    
1415  (condition-case nil  (eval-when-compile
1416      (progn    (autoload 'spam-stat-buffer-change-to-non-spam "spam-stat")
1417        (let ((spam-stat-install-hooks nil))    (autoload 'spam-stat-buffer-change-to-spam "spam-stat")
1418          (require 'spam-stat))    (autoload 'spam-stat-buffer-is-non-spam "spam-stat")
1419      (autoload 'spam-stat-buffer-is-spam "spam-stat")
1420      (autoload 'spam-stat-load "spam-stat")
1421      (autoload 'spam-stat-save "spam-stat")
1422      (autoload 'spam-stat-split-fancy "spam-stat"))
1423    
1424        (defun spam-check-stat ()  (eval-and-compile
1425          "Check the spam-stat backend for the classification of this message"    (when (condition-case nil
1426          (let ((spam-split-group (if spam-split-symbolic-return              (let ((spam-stat-install-hooks nil))
1427                                      'spam                (require 'spam-stat))
1428                                    spam-split-group))            (file-error
1429                (spam-stat-split-fancy-spam-group spam-split-group) ; override             (defalias 'spam-stat-register-ham-routine 'ignore)
1430                (spam-stat-buffer (buffer-name)) ; stat the current buffer             (defalias 'spam-stat-register-spam-routine 'ignore)
1431                category return)             nil))
1432            (spam-stat-split-fancy)))  
1433        (defun spam-check-stat ()
1434          "Check the spam-stat backend for the classification of this message"
1435          (let ((spam-split-group (if spam-split-symbolic-return
1436                                      'spam
1437                                    spam-split-group))
1438                (spam-stat-split-fancy-spam-group spam-split-group) ; override
1439                (spam-stat-buffer (buffer-name)) ; stat the current buffer
1440                category return)
1441            (spam-stat-split-fancy)))
1442    
1443        (defun spam-stat-register-spam-routine (articles &optional unregister)      (defun spam-stat-register-spam-routine (articles &optional unregister)
1444          (dolist (article articles)        (dolist (article articles)
1445            (let ((article-string (spam-get-article-as-string article)))          (let ((article-string (spam-get-article-as-string article)))
1446              (with-temp-buffer            (with-temp-buffer
1447                (insert article-string)              (insert article-string)
1448                (if unregister              (if unregister
1449                    (spam-stat-buffer-change-to-non-spam)                  (spam-stat-buffer-change-to-non-spam)
1450                (spam-stat-buffer-is-spam))))))                (spam-stat-buffer-is-spam))))))
1451    
1452        (defun spam-stat-unregister-spam-routine (articles)      (defun spam-stat-unregister-spam-routine (articles)
1453          (spam-stat-register-spam-routine articles t))        (spam-stat-register-spam-routine articles t))
1454    
1455        (defun spam-stat-register-ham-routine (articles &optional unregister)      (defun spam-stat-register-ham-routine (articles &optional unregister)
1456          (dolist (article articles)        (dolist (article articles)
1457            (let ((article-string (spam-get-article-as-string article)))          (let ((article-string (spam-get-article-as-string article)))
1458              (with-temp-buffer            (with-temp-buffer
1459                (insert article-string)              (insert article-string)
1460                (if unregister              (if unregister
1461                    (spam-stat-buffer-change-to-spam)                  (spam-stat-buffer-change-to-spam)
1462                (spam-stat-buffer-is-non-spam))))))                (spam-stat-buffer-is-non-spam))))))
1463    
1464        (defun spam-stat-unregister-ham-routine (articles)      (defun spam-stat-unregister-ham-routine (articles)
1465          (spam-stat-register-ham-routine articles t))        (spam-stat-register-ham-routine articles t))
   
       (defun spam-maybe-spam-stat-load ()  
         (when spam-use-stat (spam-stat-load)))  
1466    
1467        (defun spam-maybe-spam-stat-save ()      (defun spam-maybe-spam-stat-load ()
1468          (when spam-use-stat (spam-stat-save))))        (when spam-use-stat (spam-stat-load)))
1469    
1470    (file-error (progn      (defun spam-maybe-spam-stat-save ()
1471                  (defalias 'spam-stat-load 'ignore)        (when spam-use-stat (spam-stat-save)))))
                 (defalias 'spam-stat-save 'ignore)  
                 (defalias 'spam-maybe-spam-stat-load 'ignore)  
                 (defalias 'spam-maybe-spam-stat-save 'ignore)  
                 (defalias 'spam-stat-register-ham-routine 'ignore)  
                 (defalias 'spam-stat-unregister-ham-routine 'ignore)  
                 (defalias 'spam-stat-register-spam-routine 'ignore)  
                 (defalias 'spam-stat-unregister-spam-routine 'ignore)  
                 (defalias 'spam-stat-buffer-is-spam 'ignore)  
                 (defalias 'spam-stat-buffer-change-to-spam 'ignore)  
                 (defalias 'spam-stat-buffer-is-non-spam 'ignore)  
                 (defalias 'spam-stat-buffer-change-to-non-spam 'ignore)  
                 (defalias 'spam-stat-split-fancy 'ignore)  
                 (defalias 'spam-check-stat 'ignore))))  
1472    
1473    
1474    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26