diff options
| author | Miles Bader | 2005-04-25 04:36:12 +0000 |
|---|---|---|
| committer | Miles Bader | 2005-04-25 04:36:12 +0000 |
| commit | 61b397cdc2019424c47f1fc5571fc127e2ed747d (patch) | |
| tree | 87bf56be9e80132ed680648868f2af166383e43e | |
| parent | 901ae597141d825a65cecb812049a84982682606 (diff) | |
| download | emacs-61b397cdc2019424c47f1fc5571fc127e2ed747d.tar.gz emacs-61b397cdc2019424c47f1fc5571fc127e2ed747d.zip | |
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-277
Merge from gnus--rel--5.10
Patches applied:
* gnus--rel--5.10 (patch 67)
- Update from CVS
2005-04-24 Teodor Zlatanov <tzz@lifelogs.com>
* lisp/gnus/spam-report.el (spam-report-unplug-agent)
(spam-report-plug-agent, spam-report-deagentize)
(spam-report-agentize, spam-report-url-ping-temp-agent-function):
support for the Agent in spam-report: when unplugged, report to a
file; when plugged, submit all the requests.
[Added missing offline functionality from trunk.]
2005-04-24 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/spam-report.el (spam-report-url-to-file)
(spam-report-requests-file): New function and variable for offline
reporting.
(spam-report-url-ping-function): Add `spam-report-url-to-file'
and user defined function.
(spam-report-process-queue): New function.
Process requests from `spam-report-requests-file'.
(spam-report-url-ping-mm-url): Autoload.
[Added missing offline functionality from trunk.]
| -rw-r--r-- | lisp/gnus/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/gnus/spam-report.el | 132 |
2 files changed, 146 insertions, 7 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index f08f21fadb7..a5c403f0d7d 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2005-04-24 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * spam-report.el (spam-report-unplug-agent) | ||
| 4 | (spam-report-plug-agent, spam-report-deagentize) | ||
| 5 | (spam-report-agentize, spam-report-url-ping-temp-agent-function): | ||
| 6 | support for the Agent in spam-report: when unplugged, report to a | ||
| 7 | file; when plugged, submit all the requests. | ||
| 8 | [Added missing offline functionality from trunk.] | ||
| 9 | |||
| 10 | 2005-04-24 Reiner Steib <Reiner.Steib@gmx.de> | ||
| 11 | |||
| 12 | * spam-report.el (spam-report-url-to-file) | ||
| 13 | (spam-report-requests-file): New function and variable for offline | ||
| 14 | reporting. | ||
| 15 | (spam-report-url-ping-function): Add `spam-report-url-to-file' | ||
| 16 | and user defined function. | ||
| 17 | (spam-report-process-queue): New function. | ||
| 18 | Process requests from `spam-report-requests-file'. | ||
| 19 | (spam-report-url-ping-mm-url): Autoload. | ||
| 20 | [Added missing offline functionality from trunk.] | ||
| 21 | |||
| 1 | 2005-04-18 Katsumi Yamaoka <yamaoka@jpl.org> | 22 | 2005-04-18 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 23 | ||
| 3 | * qp.el (quoted-printable-encode-region): Save excursion. | 24 | * qp.el (quoted-printable-encode-region): Save excursion. |
diff --git a/lisp/gnus/spam-report.el b/lisp/gnus/spam-report.el index 80d422b06ab..b8283ffaaa8 100644 --- a/lisp/gnus/spam-report.el +++ b/lisp/gnus/spam-report.el | |||
| @@ -59,14 +59,32 @@ instead." | |||
| 59 | 59 | ||
| 60 | (defcustom spam-report-url-ping-function | 60 | (defcustom spam-report-url-ping-function |
| 61 | 'spam-report-url-ping-plain | 61 | 'spam-report-url-ping-plain |
| 62 | "Function to use for url ping spam reporting." | 62 | "Function to use for url ping spam reporting. |
| 63 | The function must accept the arguments `host' and `report'." | ||
| 63 | :type '(choice | 64 | :type '(choice |
| 64 | (const :tag "Connect directly" | 65 | (const :tag "Connect directly" |
| 65 | spam-report-url-ping-plain) | 66 | spam-report-url-ping-plain) |
| 66 | (const :tag "Use the external program specified in `mm-url-program'" | 67 | (const :tag "Use the external program specified in `mm-url-program'" |
| 67 | spam-report-url-ping-mm-url)) | 68 | spam-report-url-ping-mm-url) |
| 69 | (const :tag "Store request URLs in `spam-report-requests-file'" | ||
| 70 | spam-report-url-to-file) | ||
| 71 | (function :tag "User defined function" nil)) | ||
| 68 | :group 'spam-report) | 72 | :group 'spam-report) |
| 69 | 73 | ||
| 74 | (defcustom spam-report-requests-file | ||
| 75 | (nnheader-concat gnus-directory "spam/" "spam-report-requests.url") | ||
| 76 | ;; Is there a convention for the extension of such a file? | ||
| 77 | ;; Should we use `spam-directory'? | ||
| 78 | "File where spam report request are stored." | ||
| 79 | :type 'file | ||
| 80 | :group 'spam-report) | ||
| 81 | |||
| 82 | (defvar spam-report-url-ping-temp-agent-function nil | ||
| 83 | "Internal variable for `spam-report-agentize' and `spam-report-deagentize'. | ||
| 84 | This variable will store the value of `spam-report-url-ping-function' from | ||
| 85 | before `spam-report-agentize' was run, so that `spam-report-deagentize' can | ||
| 86 | undo that change.") | ||
| 87 | |||
| 70 | (defun spam-report-gmane (&rest articles) | 88 | (defun spam-report-gmane (&rest articles) |
| 71 | "Report an article as spam through Gmane" | 89 | "Report an article as spam through Gmane" |
| 72 | (dolist (article articles) | 90 | (dolist (article articles) |
| @@ -75,10 +93,11 @@ instead." | |||
| 75 | (string-match spam-report-gmane-regex gnus-newsgroup-name))) | 93 | (string-match spam-report-gmane-regex gnus-newsgroup-name))) |
| 76 | (gnus-message 6 "Reporting spam article %d to spam.gmane.org..." article) | 94 | (gnus-message 6 "Reporting spam article %d to spam.gmane.org..." article) |
| 77 | (if spam-report-gmane-use-article-number | 95 | (if spam-report-gmane-use-article-number |
| 78 | (spam-report-url-ping "spam.gmane.org" | 96 | (spam-report-url-ping |
| 79 | (format "/%s:%d" | 97 | "spam.gmane.org" |
| 80 | (gnus-group-real-name gnus-newsgroup-name) | 98 | (format "/%s:%d" |
| 81 | article)) | 99 | (gnus-group-real-name gnus-newsgroup-name) |
| 100 | article)) | ||
| 82 | (with-current-buffer nntp-server-buffer | 101 | (with-current-buffer nntp-server-buffer |
| 83 | (gnus-request-head article gnus-newsgroup-name) | 102 | (gnus-request-head article gnus-newsgroup-name) |
| 84 | (goto-char (point-min)) | 103 | (goto-char (point-min)) |
| @@ -113,14 +132,113 @@ the function specified by `spam-report-url-ping-function'." | |||
| 113 | (format "GET %s HTTP/1.1\nUser-Agent: %s (spam-report.el)\nHost: %s\n\n" | 132 | (format "GET %s HTTP/1.1\nUser-Agent: %s (spam-report.el)\nHost: %s\n\n" |
| 114 | report (gnus-emacs-version) host))))) | 133 | report (gnus-emacs-version) host))))) |
| 115 | 134 | ||
| 135 | ;;;###autoload | ||
| 136 | (defun spam-report-process-queue (&optional file keep) | ||
| 137 | "Report all queued requests from `spam-report-requests-file'. | ||
| 138 | |||
| 139 | If FILE is given, use it instead of `spam-report-requests-file'. | ||
| 140 | If KEEP is t, leave old requests in the file. If KEEP is the | ||
| 141 | symbol `ask', query before flushing the queue file." | ||
| 142 | (interactive | ||
| 143 | (list (read-file-name | ||
| 144 | "File: " | ||
| 145 | (file-name-directory spam-report-requests-file) | ||
| 146 | spam-report-requests-file | ||
| 147 | nil | ||
| 148 | (file-name-nondirectory spam-report-requests-file)) | ||
| 149 | current-prefix-arg)) | ||
| 150 | (if (eq spam-report-url-ping-function 'spam-report-url-to-file) | ||
| 151 | (error (concat "Cannot process requests when " | ||
| 152 | "`spam-report-url-ping-function' is " | ||
| 153 | "`spam-report-url-to-file'.")) | ||
| 154 | (gnus-message 7 "Processing requests using `%s'." | ||
| 155 | spam-report-url-ping-function)) | ||
| 156 | (or file (setq file spam-report-requests-file)) | ||
| 157 | (save-excursion | ||
| 158 | (set-buffer (find-file-noselect file)) | ||
| 159 | (goto-char (point-min)) | ||
| 160 | (while (and (not (eobp)) | ||
| 161 | (re-search-forward | ||
| 162 | "http://\\([^/]+\\)\\(/.*\\) *$" (point-at-eol) t)) | ||
| 163 | (funcall spam-report-url-ping-function (match-string 1) (match-string 2)) | ||
| 164 | (forward-line 1)) | ||
| 165 | (if (or (eq keep nil) | ||
| 166 | (and (eq keep 'ask) | ||
| 167 | (y-or-n-p | ||
| 168 | (format | ||
| 169 | "Flush requests from `%s'? " (current-buffer))))) | ||
| 170 | (progn | ||
| 171 | (gnus-message 7 "Flushing request file `%s'" | ||
| 172 | spam-report-requests-file) | ||
| 173 | (erase-buffer) | ||
| 174 | (save-buffer) | ||
| 175 | (kill-buffer (current-buffer))) | ||
| 176 | (gnus-message 7 "Keeping requests in `%s'" spam-report-requests-file)))) | ||
| 177 | |||
| 178 | ;;;###autoload | ||
| 116 | (defun spam-report-url-ping-mm-url (host report) | 179 | (defun spam-report-url-ping-mm-url (host report) |
| 117 | "Ping a host through HTTP, addressing a specific GET resource. Use | 180 | "Ping a host through HTTP, addressing a specific GET resource. Use |
| 118 | the external program specified in `mm-url-program' to connect to | 181 | the external program specified in `mm-url-program' to connect to |
| 119 | server." | 182 | server." |
| 120 | (with-temp-buffer | 183 | (with-temp-buffer |
| 121 | (let ((url (concat "http://" host "/" report))) | 184 | (let ((url (concat "http://" host report))) |
| 122 | (mm-url-insert url t)))) | 185 | (mm-url-insert url t)))) |
| 123 | 186 | ||
| 187 | ;;;###autoload | ||
| 188 | (defun spam-report-url-to-file (host report) | ||
| 189 | "Collect spam report requests in `spam-report-requests-file'. | ||
| 190 | Customize `spam-report-url-ping-function' to use this function." | ||
| 191 | (let ((url (concat "http://" host report)) | ||
| 192 | (file spam-report-requests-file)) | ||
| 193 | (gnus-make-directory (file-name-directory file)) | ||
| 194 | (gnus-message 9 "Writing URL `%s' to file `%s'" url file) | ||
| 195 | (with-temp-buffer | ||
| 196 | (insert url) | ||
| 197 | (newline) | ||
| 198 | (append-to-file (point-min) (point-max) file)))) | ||
| 199 | |||
| 200 | ;;;###autoload | ||
| 201 | (defun spam-report-agentize () | ||
| 202 | "Add spam-report support to the Agent. | ||
| 203 | Spam reports will be queued with \\[spam-report-url-to-file] when | ||
| 204 | the Agent is unplugged, and will be submitted in a batch when the | ||
| 205 | Agent is plugged." | ||
| 206 | (interactive) | ||
| 207 | (add-hook 'gnus-agent-plugged-hook 'spam-report-plug-agent) | ||
| 208 | (add-hook 'gnus-agent-unplugged-hook 'spam-report-unplug-agent)) | ||
| 209 | |||
| 210 | ;;;###autoload | ||
| 211 | (defun spam-report-deagentize () | ||
| 212 | "Remove spam-report support from the Agent. | ||
| 213 | Spam reports will be queued with the method used when | ||
| 214 | \\[spam-report-agentize] was run." | ||
| 215 | (interactive) | ||
| 216 | (remove-hook 'gnus-agent-plugged-hook 'spam-report-plug-agent) | ||
| 217 | (remove-hook 'gnus-agent-unplugged-hook 'spam-report-unplug-agent)) | ||
| 218 | |||
| 219 | (defun spam-report-plug-agent () | ||
| 220 | "Adjust spam report settings for plugged state. | ||
| 221 | Process queued spam reports." | ||
| 222 | ;; Process the queue, unless the user only wanted to report to a file | ||
| 223 | ;; anyway. | ||
| 224 | (unless (equal spam-report-url-ping-temp-agent-function | ||
| 225 | 'spam-report-url-to-file) | ||
| 226 | (spam-report-process-queue)) | ||
| 227 | ;; Set the reporting function, if we have memorized something otherwise, | ||
| 228 | ;; stick with plain URL reporting. | ||
| 229 | (setq spam-report-url-ping-function | ||
| 230 | (or spam-report-url-ping-temp-agent-function | ||
| 231 | 'spam-report-url-ping-plain))) | ||
| 232 | |||
| 233 | (defun spam-report-unplug-agent () | ||
| 234 | "Restore spam report settings for unplugged state." | ||
| 235 | ;; save the old value | ||
| 236 | (setq spam-report-url-ping-temp-agent-function | ||
| 237 | spam-report-url-ping-function) | ||
| 238 | ;; store all reports to file | ||
| 239 | (setq spam-report-url-ping-function | ||
| 240 | 'spam-report-url-to-file)) | ||
| 241 | |||
| 124 | (provide 'spam-report) | 242 | (provide 'spam-report) |
| 125 | 243 | ||
| 126 | ;;; arch-tag: f6683295-ec89-4ab5-8803-8cc842293022 | 244 | ;;; arch-tag: f6683295-ec89-4ab5-8803-8cc842293022 |