From 3a9dd1597959a351cdc0dac7a5b72d1695d3c952 Mon Sep 17 00:00:00 2001 From: Reiner Steib Date: Thu, 5 Feb 2004 21:46:23 +0000 Subject: [PATCH] (spam-report-process-queue): New function. Process requests from `spam-report-requests-file'. --- lisp/ChangeLog | 5 +++++ lisp/spam-report.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 433475e71..0043d7c76 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2004-02-05 Reiner Steib + + * spam-report.el (spam-report-process-queue): New function. + Process requests from `spam-report-requests-file'. + 2004-02-05 Teodor Zlatanov * spam.el (spam-register-routine) diff --git a/lisp/spam-report.el b/lisp/spam-report.el index 2307cc827..b4ed75be0 100644 --- a/lisp/spam-report.el +++ b/lisp/spam-report.el @@ -125,6 +125,48 @@ the function specified by `spam-report-url-ping-function'." (format "GET %s HTTP/1.1\nUser-Agent: %s (spam-report.el)\nHost: %s\n\n" report (gnus-emacs-version) host))))) +(defun spam-report-process-queue (&optional file keep) + "Report all queued requests from `spam-report-requests-file'. + +If KEEP is t, leave old requests in the file. If KEEP is +the symbol `ask', query before flushing the queue file." + (interactive + (list (read-file-name + "File: " + (file-name-directory spam-report-requests-file) + spam-report-requests-file + nil + (file-name-nondirectory spam-report-requests-file) + spam-report-requests-file) + current-prefix-arg)) + (if (eq spam-report-url-ping-function 'spam-report-url-to-file) + (error (concat "Cannot process requests when " + "`spam-report-url-ping-function' is " + "`spam-report-url-to-file'")) + (gnus-message 7 "Processing requests using `%s'." + spam-report-url-ping-function)) + (or file (setq file spam-report-requests-file)) + (save-excursion + (set-buffer (find-file-noselect file)) + (goto-char (point-min)) + (while (and (not (eobp)) + (re-search-forward + "http://\\([^/]+\\)\\(/.*\\) *$" (point-at-eol) t)) + (funcall spam-report-url-ping-function (match-string 1) (match-string 2)) + (forward-line 1)) + (if (or (eq keep nil) + (and (eq keep 'ask) + (y-or-n-p + (format + "Flush requests from `%s'? " (current-buffer))))) + (progn + (gnus-message 7 "Flushing request file `%s'" + spam-report-requests-file) + (erase-buffer) + (save-buffer) + (kill-buffer (current-buffer))) + (gnus-message 7 "Keeping requests in `%s'" spam-report-requests-file)))) + (defun spam-report-url-ping-mm-url (host report) "Ping a host through HTTP, addressing a specific GET resource. Use the external program specified in `mm-url-program' to connect to -- 2.34.1