Mercurial > emacs
annotate lisp/gnus/webmail.el @ 33296:acb605e6da0e
(mm-insert-inline): Autoload.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 08 Nov 2000 15:23:02 +0000 |
parents | ddc33cf6b78c |
children | 53eebdb81828 |
rev | line source |
---|---|
31717 | 1 ;;; webmail.el --- interfacing with web mail |
2 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | |
5 ;; Keywords: hotmail netaddress my-deja netscape | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published | |
11 ;; by the Free Software Foundation; either version 2, or (at your | |
12 ;; option) any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, but | |
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 ;; General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; Note: Now mail.yahoo.com provides POP3 service, the webmail | |
27 ;; fetching is not going to be supported. | |
28 | |
29 ;; Note: You need to have `url' and `w3' installed for this backend to | |
30 ;; work. `w3' must be 4.0pre46+one-line-cookie patch or standalone | |
31 ;; `url'. | |
32 | |
33 ;; Todo: To support more web mail servers. | |
34 | |
35 ;; Known bugs: | |
36 ;; 1. Net@ddress may corrupt `X-Face'. | |
37 | |
38 ;; Warning: | |
39 ;; Webmail is an experimental function, which means NO WARRANTY. | |
40 | |
41 ;;; Code: | |
42 | |
43 (eval-when-compile (require 'cl)) | |
44 | |
45 (require 'nnoo) | |
46 (require 'message) | |
47 (require 'gnus-util) | |
48 (require 'gnus) | |
49 (require 'nnmail) | |
50 (require 'mm-util) | |
51 (require 'mml) | |
52 (eval-when-compile | |
53 (ignore-errors | |
54 (require 'w3) | |
55 (require 'url) | |
56 (require 'url-cookie) | |
57 (require 'w3-forms) | |
58 (require 'nnweb))) | |
59 ;; Report failure to find w3 at load time if appropriate. | |
60 (eval '(progn | |
61 (require 'w3) | |
62 (require 'url) | |
63 (require 'url-cookie) | |
64 (require 'w3-forms) | |
65 (require 'nnweb))) | |
66 | |
67 ;;; | |
68 | |
69 (defvar webmail-type-definition | |
70 '((hotmail | |
71 ;; Hotmail hate other HTTP user agents and use one line cookie | |
72 (paranoid agent cookie post) | |
73 (address . "www.hotmail.com") | |
74 (open-url "http://www.hotmail.com/") | |
75 (open-snarf . webmail-hotmail-open) | |
76 ;; W3 hate redirect POST | |
77 (login-url | |
78 "http://%s/cgi-bin/dologin?login=%s&passwd=%s&enter=Sign+in&sec=no&curmbox=ACTIVE&_lang=&js=yes&id=2&tw=-10000&beta=" | |
79 webmail-aux user password) | |
80 ;;(login-snarf . webmail-hotmail-login) | |
81 ;;(list-url "%s" webmail-aux) | |
82 (list-snarf . webmail-hotmail-list) | |
83 (article-snarf . webmail-hotmail-article) | |
84 (trash-url | |
85 "%s&login=%s&f=33792&curmbox=ACTIVE&_lang=&foo=inbox&js=&page=&%s=on&_HMaction=MoveTo&tobox=trAsH&nullbox=" | |
86 webmail-aux user id)) | |
87 (yahoo | |
88 (paranoid agent cookie post) | |
89 (address . "mail.yahoo.com") | |
90 (open-url "http://mail.yahoo.com/") | |
91 (open-snarf . webmail-yahoo-open) | |
92 (login-url;; yahoo will not accept GET | |
93 content | |
94 ("%s" webmail-aux) | |
95 ".tries=&.src=ym&.last=&promo=&.intl=&.bypass=&.partner=&.chkP=Y&.done=&login=%s&passwd=%s" | |
96 user password) | |
97 (login-snarf . webmail-yahoo-login) | |
98 (list-url "%s&rb=Inbox&YN=1" webmail-aux) | |
99 (list-snarf . webmail-yahoo-list) | |
100 (article-snarf . webmail-yahoo-article) | |
101 (trash-url | |
102 "%s/ym/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2=" | |
103 webmail-aux id)) | |
104 (netaddress | |
105 (paranoid cookie post) | |
106 (address . "www.netaddress.com") | |
107 (open-url "http://www.netaddress.com/") | |
108 (open-snarf . webmail-netaddress-open) | |
109 (login-url | |
110 content | |
111 ("%s" webmail-aux) | |
112 "LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s" | |
113 user password) | |
114 (login-snarf . webmail-netaddress-login) | |
115 (list-url | |
116 "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True" | |
117 webmail-session) | |
118 (list-snarf . webmail-netaddress-list) | |
119 (article-url "http://www.netaddress.com/") | |
120 (article-snarf . webmail-netaddress-article) | |
121 (trash-url | |
122 "http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1" | |
123 webmail-session id)) | |
124 (netscape | |
125 (paranoid cookie post agent) | |
126 (address . "webmail.netscape.com") | |
127 (open-url "http://ureg.netscape.com/iiop/UReg2/login/login?U2_LA=en&U2_BACK_FROM_CJ=true&U2_CS=iso-8859-1&U2_ENDURL=http://webmail.netscape.com/tpl/Subscribe/Step1&U2_NEW_ENDURL=http://webmail.netscape.com/tpl/Subscribe/Step1&U2_EXITURL=http://home.netscape.com/&U2_SOURCE=Webmail") | |
128 (open-snarf . webmail-netscape-open) | |
129 (login-url | |
130 content | |
131 ("http://ureg.netscape.com/iiop/UReg2/login/loginform") | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
132 "U2_USERNAME=%s&U2_PASSWORD=%s%s" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
133 user password webmail-aux) |
31717 | 134 (login-snarf . webmail-netaddress-login) |
135 (list-url | |
136 "http://webmail.netscape.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True" | |
137 webmail-session) | |
138 (list-snarf . webmail-netaddress-list) | |
139 (article-url "http://webmail.netscape.com/") | |
140 (article-snarf . webmail-netscape-article) | |
141 (trash-url | |
142 "http://webmail.netscape.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1" | |
143 webmail-session id)) | |
144 (my-deja | |
145 (paranoid cookie post) | |
146 (address . "www.my-deja.com") | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
147 (open-url "http://www.deja.com/my/pr.xp") |
31717 | 148 (open-snarf . webmail-my-deja-open) |
149 (login-url | |
150 content | |
151 ("%s" webmail-aux) | |
152 "member_name=%s&pw=%s&go=&priv_opt_MyDeja99=" | |
153 user password) | |
154 (list-url "http://www.deja.com/rg_gotomail.xp") | |
155 (list-snarf . webmail-my-deja-list) | |
156 (article-snarf . webmail-my-deja-article) | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
157 (trash-url webmail-aux id)))) |
31717 | 158 |
159 (defvar webmail-variables | |
160 '(address article-snarf article-url list-snarf list-url | |
161 login-url login-snarf open-url open-snarf site articles | |
162 post-process paranoid trash-url)) | |
163 | |
164 (defconst webmail-version "webmail 1.0") | |
165 | |
166 (defvar webmail-newmail-only nil | |
167 "Only fetch new mails.") | |
168 | |
169 (defvar webmail-move-to-trash-can t | |
170 "Move mail to trash can after fetch it.") | |
171 | |
172 ;;; Internal variables | |
173 | |
174 (defvar webmail-address nil) | |
175 (defvar webmail-paranoid nil) | |
176 (defvar webmail-aux nil) | |
177 (defvar webmail-session nil) | |
178 (defvar webmail-article-snarf nil) | |
179 (defvar webmail-article-url nil) | |
180 (defvar webmail-list-snarf nil) | |
181 (defvar webmail-list-url nil) | |
182 (defvar webmail-login-url nil) | |
183 (defvar webmail-login-snarf nil) | |
184 (defvar webmail-open-snarf nil) | |
185 (defvar webmail-open-url nil) | |
186 (defvar webmail-trash-url nil) | |
187 (defvar webmail-articles nil) | |
188 (defvar webmail-post-process nil) | |
189 | |
190 (defvar webmail-buffer nil) | |
191 (defvar webmail-buffer-list nil) | |
192 | |
193 (defvar webmail-type nil) | |
194 | |
195 (defvar webmail-error-function nil) | |
196 | |
197 (defvar webmail-debug-file "~/.emacs-webmail-debug") | |
198 | |
199 ;;; Interface functions | |
200 | |
201 (defun webmail-debug (str) | |
202 (with-temp-buffer | |
203 (insert "\n---------------- A bug at " str " ------------------\n") | |
204 (mapcar #'(lambda (sym) | |
205 (if (boundp sym) | |
206 (pp `(setq ,sym ',(eval sym)) (current-buffer)))) | |
207 '(webmail-type user)) | |
208 (insert "---------------- webmail buffer ------------------\n\n") | |
209 (insert-buffer-substring webmail-buffer) | |
210 (insert "\n---------------- end of buffer ------------------\n\n") | |
211 (append-to-file (point-min) (point-max) webmail-debug-file))) | |
212 | |
213 (defun webmail-error (str) | |
214 (if webmail-error-function | |
215 (funcall webmail-error-function str)) | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
216 (message "%s HTML has changed or your w3 package is too old.(%s)" |
31717 | 217 webmail-type str) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
218 (error "%s HTML has changed or your w3 package is too old.(%s)" |
31717 | 219 webmail-type str)) |
220 | |
221 (defun webmail-setdefault (type) | |
222 (let ((type-def (cdr (assq type webmail-type-definition))) | |
223 (vars webmail-variables) | |
224 pair) | |
225 (setq webmail-type type) | |
226 (dolist (var vars) | |
227 (if (setq pair (assq var type-def)) | |
228 (set (intern (concat "webmail-" (symbol-name var))) (cdr pair)) | |
229 (set (intern (concat "webmail-" (symbol-name var))) nil))))) | |
230 | |
231 (defun webmail-encode-www-form-urlencoded (pairs) | |
232 "Return PAIRS encoded for forms." | |
233 (mapconcat | |
234 (function | |
235 (lambda (data) | |
236 (concat (w3-form-encode-xwfu (car data)) "=" | |
237 (w3-form-encode-xwfu (cdr data))))) | |
238 pairs "&")) | |
239 | |
240 (defun webmail-fetch-simple (url content) | |
241 (let ((url-request-data content) | |
242 (url-request-method "POST") | |
243 (url-request-extra-headers | |
244 '(("Content-type" . "application/x-www-form-urlencoded")))) | |
245 (nnweb-insert url)) | |
246 t) | |
247 | |
248 (defun webmail-fetch-form (url pairs) | |
249 (let ((url-request-data (webmail-encode-www-form-urlencoded pairs)) | |
250 (url-request-method "POST") | |
251 (url-request-extra-headers | |
252 '(("Content-type" . "application/x-www-form-urlencoded")))) | |
253 (nnweb-insert url)) | |
254 t) | |
255 | |
256 (defun webmail-eval (expr) | |
257 (cond | |
258 ((consp expr) | |
259 (cons (webmail-eval (car expr)) (webmail-eval (cdr expr)))) | |
260 ((symbolp expr) | |
261 (eval expr)) | |
262 (t | |
263 expr))) | |
264 | |
265 (defun webmail-url (xurl) | |
266 (mm-with-unibyte-current-buffer | |
267 (cond | |
268 ((eq (car xurl) 'content) | |
269 (pop xurl) | |
270 (webmail-fetch-simple (if (stringp (car xurl)) | |
271 (car xurl) | |
272 (apply 'format (webmail-eval (car xurl)))) | |
273 (apply 'format (webmail-eval (cdr xurl))))) | |
274 ((eq (car xurl) 'post) | |
275 (pop xurl) | |
276 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl)))) | |
277 (t | |
278 (nnweb-insert (apply 'format (webmail-eval xurl))))))) | |
279 | |
280 (defun webmail-init () | |
281 "Initialize buffers and such." | |
282 (if (gnus-buffer-live-p webmail-buffer) | |
283 (set-buffer webmail-buffer) | |
284 (setq webmail-buffer | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
285 (nnheader-set-temp-buffer " *webmail*")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
286 (mm-disable-multibyte))) |
31717 | 287 |
288 (defvar url-package-name) | |
289 (defvar url-package-version) | |
290 (defvar url-cookie-multiple-line) | |
291 (defvar url-confirmation-func) | |
292 | |
293 ;; Hack W3 POST redirect. See `url-parse-mime-headers'. | |
294 ;; | |
295 ;; Netscape uses "GET" as redirect method when orignal method is POST | |
296 ;; and status is 302, .i.e no security risks by default without | |
297 ;; confirmation. | |
298 ;; | |
299 ;; Some web servers (at least Apache used by yahoo) return status 302 | |
300 ;; instead of 303, though they mean 303. | |
301 | |
302 (defun webmail-url-confirmation-func (prompt) | |
303 (cond | |
304 ((equal prompt (concat "Honor redirection with non-GET method " | |
305 "(possible security risks)? ")) | |
306 nil) | |
307 ((equal prompt "Continue (with method of GET)? ") | |
308 t) | |
309 (t (error prompt)))) | |
310 | |
311 (defun webmail-refresh-redirect () | |
312 "Redirect refresh url in META." | |
313 (goto-char (point-min)) | |
314 (while (re-search-forward | |
315 "<meta[ \t\r\n]*http-equiv=\"Refresh\"[^>]*URL=\\([^\"]+\\)\"" | |
316 nil t) | |
317 (let ((url (match-string 1))) | |
318 (erase-buffer) | |
319 (mm-with-unibyte-current-buffer | |
320 (nnweb-insert url))) | |
321 (goto-char (point-min)))) | |
322 | |
323 (defun webmail-fetch (file subtype user password) | |
324 (save-excursion | |
325 (webmail-setdefault subtype) | |
326 (let ((url-package-name (if (memq 'agent webmail-paranoid) | |
327 "Mozilla" | |
328 url-package-name)) | |
329 (url-package-version (if (memq 'agent webmail-paranoid) | |
330 "4.0" | |
331 url-package-version)) | |
332 (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid) | |
333 nil | |
334 url-cookie-multiple-line)) | |
335 (url-confirmation-func (if (memq 'post webmail-paranoid) | |
336 'webmail-url-confirmation-func | |
337 url-confirmation-func)) | |
338 (url-http-silence-on-insecure-redirection t) | |
339 url-cookie-storage url-cookie-secure-storage | |
340 url-cookie-confirmation | |
341 item id (n 0)) | |
342 (webmail-init) | |
343 (setq webmail-articles nil) | |
344 (when webmail-open-url | |
345 (erase-buffer) | |
346 (webmail-url webmail-open-url)) | |
347 (if webmail-open-snarf (funcall webmail-open-snarf)) | |
348 (when webmail-login-url | |
349 (erase-buffer) | |
350 (webmail-url webmail-login-url)) | |
351 (if webmail-login-snarf | |
352 (funcall webmail-login-snarf)) | |
353 (when webmail-list-url | |
354 (erase-buffer) | |
355 (webmail-url webmail-list-url)) | |
356 (if webmail-list-snarf | |
357 (funcall webmail-list-snarf)) | |
358 (while (setq item (pop webmail-articles)) | |
359 (message "Fetching mail #%d..." (setq n (1+ n))) | |
360 (erase-buffer) | |
361 (mm-with-unibyte-current-buffer | |
362 (nnweb-insert (cdr item))) | |
363 (setq id (car item)) | |
364 (if webmail-article-snarf | |
365 (funcall webmail-article-snarf file id)) | |
366 (when (and webmail-trash-url webmail-move-to-trash-can) | |
367 (message "Move mail #%d to trash can..." n) | |
368 (condition-case err | |
369 (progn | |
370 (webmail-url webmail-trash-url) | |
371 (let (buf) | |
372 (while (setq buf (pop webmail-buffer-list)) | |
373 (kill-buffer buf)))) | |
374 (error | |
375 (let (buf) | |
376 (while (setq buf (pop webmail-buffer-list)) | |
377 (kill-buffer buf))) | |
378 (error err)))))) | |
379 (if webmail-post-process | |
380 (funcall webmail-post-process)))) | |
381 | |
382 (defun webmail-encode-8bit () | |
383 (goto-char (point-min)) | |
384 (skip-chars-forward "^\200-\377") | |
385 (while (not (eobp)) | |
386 (insert (format "&%d;" (mm-char-int (char-after)))) | |
387 (delete-char 1) | |
388 (skip-chars-forward "^\200-\377"))) | |
389 | |
390 ;;; hotmail | |
391 | |
392 (defun webmail-hotmail-open () | |
393 (goto-char (point-min)) | |
394 (if (re-search-forward | |
395 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t) | |
396 (setq webmail-aux (match-string 1)) | |
397 (webmail-error "open@1"))) | |
398 | |
399 (defun webmail-hotmail-login () | |
400 (let (site) | |
401 (goto-char (point-min)) | |
402 (if (re-search-forward | |
403 "https?://\\([^/]+hotmail\\.msn\\.com\\)/cgi-bin/" nil t) | |
404 (setq site (match-string 1)) | |
405 (webmail-error "login@1")) | |
406 (goto-char (point-min)) | |
407 (if (re-search-forward | |
408 "\\(/cgi-bin/HoTMaiL\\?[^\"]*a=b[^\"]*\\)" nil t) | |
409 (setq webmail-aux (concat "http://" site (match-string 1))) | |
410 (webmail-error "login@2")))) | |
411 | |
412 (defun webmail-hotmail-list () | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
413 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
414 (skip-chars-forward " \t\n\r") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
415 (let (site url newp (total "0")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
416 (if (eobp) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
417 (setq total "0") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
418 (if (re-search-forward "\\([0-9]+\\) *<b>(\\([0-9]+\\) new)" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
419 (message "Found %s (%s new)" (setq total (match-string 1)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
420 (match-string 2)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
421 (if (re-search-forward "\\([0-9]+\\) new" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
422 (message "Found %s new" (setq total (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
423 (webmail-error "list@0")))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
424 (unless (equal total "0") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
425 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
426 (if (re-search-forward |
31717 | 427 "https?://\\([^/]+hotmail\\.msn\\.com\\)/cgi-bin/" nil t) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
428 (setq site (match-string 1)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
429 (webmail-error "list@1")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
430 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
431 (if (re-search-forward "disk=\\([^&]*\\)&" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
432 (setq webmail-aux |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
433 (concat "http://" site "/cgi-bin/HoTMaiL?disk=" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
434 (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
435 (webmail-error "list@2")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
436 (goto-char (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
437 (while (re-search-backward |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
438 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\"" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
439 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
440 (if (setq url (match-string 1)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
441 (progn |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
442 (if (or newp (not webmail-newmail-only)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
443 (let (id) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
444 (if (string-match "msg=\\([^&]+\\)" url) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
445 (setq id (match-string 1 url))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
446 (push (cons id (concat "http://" site url "&raw=0")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
447 webmail-articles))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
448 (setq newp nil)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
449 (setq newp t)))))) |
31717 | 450 |
451 ;; Thank victor@idaccr.org (Victor S. Miller) for raw=0 | |
452 | |
453 (defun webmail-hotmail-article (file id) | |
454 (goto-char (point-min)) | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
455 (skip-chars-forward " \t\n\r") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
456 (unless (eobp) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
457 (if (not (search-forward "<pre>" nil t)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
458 (webmail-error "article@3")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
459 (skip-chars-forward "\n\r\t ") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
460 (delete-region (point-min) (point)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
461 (if (not (search-forward "</pre>" nil t)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
462 (webmail-error "article@3.1")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
463 (delete-region (match-beginning 0) (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
464 (nnweb-remove-markup) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
465 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
466 (nnweb-decode-entities)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
467 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
468 (while (re-search-forward "\r\n?" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
469 (replace-match "\n")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
470 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
471 (insert "\n\n") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
472 (if (not (looking-at "\n*From ")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
473 (insert "From nobody " (current-time-string) "\n") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
474 (forward-line)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
475 (insert "X-Gnus-Webmail: " (symbol-value 'user) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
476 "@" (symbol-name webmail-type) "\n") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
477 (mm-append-to-file (point-min) (point-max) file))) |
31717 | 478 |
479 (defun webmail-hotmail-article-old (file id) | |
480 (let (p attachment count mime hotmail-direct) | |
481 (save-restriction | |
482 (webmail-encode-8bit) | |
483 (goto-char (point-min)) | |
484 (if (not (search-forward "<DIV>" nil t)) | |
485 (if (not (search-forward "Reply All" nil t)) | |
486 (webmail-error "article@1") | |
487 (setq hotmail-direct t)) | |
488 (goto-char (match-beginning 0))) | |
489 (narrow-to-region (point-min) (point)) | |
490 (if (not (search-backward "<table" nil t 2)) | |
491 (webmail-error "article@1.1")) | |
492 (delete-region (point-min) (match-beginning 0)) | |
493 (while (search-forward "<a href=" nil t) | |
494 (setq p (match-beginning 0)) | |
495 (search-forward "</a>" nil t) | |
496 (delete-region p (match-end 0))) | |
497 (nnweb-remove-markup) | |
498 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
499 (nnweb-decode-entities)) | |
500 (goto-char (point-min)) | |
501 (delete-blank-lines) | |
502 (goto-char (point-min)) | |
503 (when (search-forward "\n\n" nil t) | |
504 (backward-char) | |
505 (delete-region (point) (point-max))) | |
506 (goto-char (point-max)) | |
507 (widen) | |
508 (insert "\n") | |
509 (setq p (point)) | |
510 (while (re-search-forward | |
511 "<tt>\\|<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" | |
512 nil t) | |
513 (if (setq attachment (match-string 1)) | |
514 (let ((filename (match-string 2)) | |
515 bufname);; Attachment | |
516 (delete-region p (match-end 0)) | |
517 (save-excursion | |
518 (set-buffer (generate-new-buffer " *webmail-att*")) | |
519 (nnweb-insert attachment) | |
520 (push (current-buffer) webmail-buffer-list) | |
521 (setq bufname (buffer-name))) | |
522 (setq mime t) | |
523 (insert "<#part type=" | |
524 (or (and filename | |
525 (string-match "\\.[^\\.]+$" filename) | |
526 (mailcap-extension-to-mime | |
527 (match-string 0 filename))) | |
528 "application/octet-stream")) | |
529 (insert " buffer=\"" bufname "\"") | |
530 (insert " filename=\"" filename "\"") | |
531 (insert " disposition=\"inline\"") | |
532 (insert "><#/part>\n") | |
533 (setq p (point))) | |
534 (delete-region p (match-end 0)) | |
535 (if hotmail-direct | |
536 (if (not (search-forward "</tt>" nil t)) | |
537 (webmail-error "article@1.2") | |
538 (delete-region (match-beginning 0) (match-end 0))) | |
539 (setq count 1) | |
540 (while (and (> count 0) | |
541 (re-search-forward "</div>\\|\\(<div>\\)" nil t)) | |
542 (if (match-string 1) | |
543 (setq count (1+ count)) | |
544 (if (= (setq count (1- count)) 0) | |
545 (delete-region (match-beginning 0) | |
546 (match-end 0)))))) | |
547 (narrow-to-region p (point)) | |
548 (goto-char (point-min)) | |
549 (cond | |
550 ((looking-at "<pre>") | |
551 (goto-char (match-end 0)) | |
552 (if (looking-at "$") (forward-char)) | |
553 (delete-region (point-min) (point)) | |
554 (nnweb-remove-markup) | |
555 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
556 (nnweb-decode-entities)) | |
557 nil) | |
558 (t | |
559 (setq mime t) | |
560 (insert "<#part type=\"text/html\" disposition=inline>") | |
561 (goto-char (point-max)) | |
562 (insert "<#/part>"))) | |
563 (goto-char (point-max)) | |
564 (setq p (point)) | |
565 (widen))) | |
566 (delete-region p (point-max)) | |
567 (goto-char (point-min)) | |
568 ;; Some blank line to seperate mails. | |
569 (insert "\n\nFrom nobody " (current-time-string) "\n") | |
570 (insert "X-Gnus-Webmail: " (symbol-value 'user) | |
571 "@" (symbol-name webmail-type) "\n") | |
572 (if id | |
573 (insert (format "X-Message-ID: <%s@hotmail.com>\n" id))) | |
574 (unless (looking-at "$") | |
575 (if (search-forward "\n\n" nil t) | |
576 (forward-line -1) | |
577 (webmail-error "article@2"))) | |
578 (narrow-to-region (point) (point-max)) | |
579 (if mime | |
580 (insert "MIME-Version: 1.0\n" | |
581 (prog1 | |
582 (mml-generate-mime) | |
583 (delete-region (point-min) (point-max))))) | |
584 (goto-char (point-min)) | |
585 (widen) | |
586 (let (case-fold-search) | |
587 (while (re-search-forward "^From " nil t) | |
588 (beginning-of-line) | |
589 (insert ">")))) | |
590 (mm-append-to-file (point-min) (point-max) file))) | |
591 | |
592 ;;; yahoo | |
593 | |
594 (defun webmail-yahoo-open () | |
595 (goto-char (point-min)) | |
596 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t) | |
597 (setq webmail-aux (match-string 1)) | |
598 (webmail-error "open@1"))) | |
599 | |
600 (defun webmail-yahoo-login () | |
601 (goto-char (point-min)) | |
602 (if (re-search-forward "http://[^/]+[0-9]\\.mail\\.yahoo\\.com/" nil t) | |
603 (setq webmail-aux (match-string 0)) | |
604 (webmail-error "login@1")) | |
605 (if (re-search-forward "YY=[0-9]+" nil t) | |
606 (setq webmail-aux (concat webmail-aux "ym/ShowFolder?" | |
607 (match-string 0))) | |
608 (webmail-error "login@2"))) | |
609 | |
610 (defun webmail-yahoo-list () | |
611 (let (url (newp t) (tofetch 0)) | |
612 (goto-char (point-min)) | |
613 (when (re-search-forward | |
614 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t) | |
615 ;;(setq listed (match-string 1)) | |
616 (message "Found %s mail(s)" (match-string 2))) | |
617 (if (string-match "http://[^/]+" webmail-aux) | |
618 (setq webmail-aux (match-string 0 webmail-aux)) | |
619 (webmail-error "list@1")) | |
620 (goto-char (point-min)) | |
621 (while (re-search-forward | |
622 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\"" | |
623 nil t) | |
624 (if (setq url (match-string 1)) | |
625 (progn | |
626 (when (or newp (not webmail-newmail-only)) | |
627 (push (cons (match-string 2) (concat webmail-aux url "&toc=1")) | |
628 webmail-articles) | |
629 (setq tofetch (1+ tofetch))) | |
630 (setq newp t)) | |
631 (setq newp nil))) | |
632 (setq webmail-articles (nreverse webmail-articles)) | |
633 (message "Fetching %d mail(s)" tofetch))) | |
634 | |
635 (defun webmail-yahoo-article (file id) | |
636 (let (p attachment) | |
637 (save-restriction | |
638 (goto-char (point-min)) | |
639 (if (not (search-forward "value=\"Done\"" nil t)) | |
640 (webmail-error "article@1")) | |
641 (if (not (search-forward "<table" nil t)) | |
642 (webmail-error "article@2")) | |
643 (delete-region (point-min) (match-beginning 0)) | |
644 (if (not (search-forward "</table>" nil t)) | |
645 (webmail-error "article@3")) | |
646 (narrow-to-region (point-min) (match-end 0)) | |
647 (while (search-forward "<a href=" nil t) | |
648 (setq p (match-beginning 0)) | |
649 (search-forward "</a>" nil t) | |
650 (delete-region p (match-end 0))) | |
651 (nnweb-remove-markup) | |
652 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
653 (nnweb-decode-entities)) | |
654 (goto-char (point-min)) | |
655 (delete-blank-lines) | |
656 (goto-char (point-max)) | |
657 (widen) | |
658 (insert "\n") | |
659 (setq p (point)) | |
660 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t) | |
661 (setq attachment (match-string 0)) | |
662 (let (bufname ct ctl cd description) | |
663 (if (not (search-forward "<table" nil t)) | |
664 (webmail-error "article@4")) | |
665 (delete-region p (match-beginning 0)) | |
666 (if (not (search-forward "</table>" nil t)) | |
667 (webmail-error "article@5")) | |
668 (narrow-to-region p (match-end 0)) | |
669 (nnweb-remove-markup) | |
670 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
671 (nnweb-decode-entities)) | |
672 (goto-char (point-min)) | |
673 (delete-blank-lines) | |
674 (setq ct (mail-fetch-field "content-type") | |
675 ctl (ignore-errors (mail-header-parse-content-type ct)) | |
676 ;;cte (mail-fetch-field "content-transfer-encoding") | |
677 cd (mail-fetch-field "content-disposition") | |
678 description (mail-fetch-field "content-description") | |
679 id (mail-fetch-field "content-id")) | |
680 (delete-region (point-min) (point-max)) | |
681 (widen) | |
682 (save-excursion | |
683 (set-buffer (generate-new-buffer " *webmail-att*")) | |
684 (nnweb-insert (concat webmail-aux attachment)) | |
685 (push (current-buffer) webmail-buffer-list) | |
686 (setq bufname (buffer-name))) | |
687 (insert "<#part") | |
688 (if (and ctl (not (equal (car ctl) "text/"))) | |
689 (insert " type=\"" (car ctl) "\"")) | |
690 (insert " buffer=\"" bufname "\"") | |
691 (if cd | |
692 (insert " disposition=\"" cd "\"")) | |
693 (if description | |
694 (insert " description=\"" description "\"")) | |
695 (insert "><#/part>\n") | |
696 (setq p (point)))) | |
697 (delete-region p (point-max)) | |
698 (goto-char (point-min)) | |
699 ;; Some blank line to seperate mails. | |
700 (insert "\n\nFrom nobody " (current-time-string) "\n") | |
701 (insert "X-Gnus-Webmail: " (symbol-value 'user) | |
702 "@" (symbol-name webmail-type) "\n") | |
703 (if id | |
704 (insert (format "X-Message-ID: <%s@yahoo.com>\n" id))) | |
705 (unless (looking-at "$") | |
706 (if (search-forward "\n\n" nil t) | |
707 (forward-line -1) | |
708 (webmail-error "article@2"))) | |
709 (narrow-to-region (point) (point-max)) | |
710 (insert "MIME-Version: 1.0\n" | |
711 (prog1 | |
712 (mml-generate-mime) | |
713 (delete-region (point-min) (point-max)))) | |
714 (goto-char (point-min)) | |
715 (widen) | |
716 (let (case-fold-search) | |
717 (while (re-search-forward "^From " nil t) | |
718 (beginning-of-line) | |
719 (insert ">")))) | |
720 (mm-append-to-file (point-min) (point-max) file))) | |
721 | |
722 ;;; netaddress | |
723 | |
724 (defun webmail-netscape-open () | |
725 (goto-char (point-min)) | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
726 (setq webmail-aux "") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
727 (while (re-search-forward |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
728 "TYPE=hidden *NAME=\\([^ ]+\\) *VALUE=\"\\([^\"]+\\)" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
729 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
730 (setq webmail-aux (concat webmail-aux "&" (match-string 1) "=" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
731 (match-string 2))))) |
31717 | 732 |
733 (defun webmail-netaddress-open () | |
734 (goto-char (point-min)) | |
735 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t) | |
736 (setq webmail-aux (concat (car webmail-open-url) (match-string 1))) | |
737 (webmail-error "open@1"))) | |
738 | |
739 (defun webmail-netaddress-login () | |
740 (webmail-refresh-redirect) | |
741 (goto-char (point-min)) | |
742 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t) | |
743 (setq webmail-session (match-string 1)) | |
744 (webmail-error "login@1"))) | |
745 | |
746 (defun webmail-netaddress-list () | |
747 (webmail-refresh-redirect) | |
748 (let (item id) | |
749 (goto-char (point-min)) | |
750 (when (re-search-forward | |
751 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t) | |
752 (message "Found %s mail(s), %s unread" | |
753 (match-string 2) (match-string 1))) | |
754 (goto-char (point-min)) | |
755 (while (re-search-forward | |
756 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t) | |
757 (if (setq id (match-string 2)) | |
758 (setq item | |
759 (cons id | |
760 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True" | |
761 (car webmail-article-url) | |
762 webmail-session id))) | |
763 (if (or (not webmail-newmail-only) | |
764 (equal (match-string 1) "True")) | |
765 (push item webmail-articles)))) | |
766 (setq webmail-articles (nreverse webmail-articles)))) | |
767 | |
768 (defun webmail-netaddress-single-part () | |
769 (goto-char (point-min)) | |
770 (cond | |
771 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*") | |
772 ;; text/plain | |
773 (replace-match "") | |
774 (while (re-search-forward "[\t\040\r\n]+" nil t) | |
775 (replace-match " ")) | |
776 (goto-char (point-min)) | |
777 (while (re-search-forward "<br>" nil t) | |
778 (replace-match "\n")) | |
779 (nnweb-remove-markup) | |
780 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
781 (nnweb-decode-entities)) | |
782 nil) | |
783 (t | |
784 (insert "<#part type=\"text/html\" disposition=inline>") | |
785 (goto-char (point-max)) | |
786 (insert "<#/part>") | |
787 t))) | |
788 | |
789 (defun webmail-netaddress-article (file id) | |
790 (webmail-refresh-redirect) | |
791 (let (p p1 attachment count mime type) | |
792 (save-restriction | |
793 (webmail-encode-8bit) | |
794 (goto-char (point-min)) | |
795 (if (not (search-forward "Trash" nil t)) | |
796 (webmail-error "article@1")) | |
797 (if (not (search-forward "<form>" nil t)) | |
798 (webmail-error "article@2")) | |
799 (delete-region (point-min) (match-beginning 0)) | |
800 (if (not (search-forward "</form>" nil t)) | |
801 (webmail-error "article@3")) | |
802 (narrow-to-region (point-min) (match-end 0)) | |
803 (goto-char (point-min)) | |
804 (while (re-search-forward "[\040\t\r\n]+" nil t) | |
805 (replace-match " ")) | |
806 (goto-char (point-min)) | |
807 (while (search-forward "<b>" nil t) | |
808 (replace-match "\n")) | |
809 (nnweb-remove-markup) | |
810 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
811 (nnweb-decode-entities)) | |
812 (goto-char (point-min)) | |
813 (delete-blank-lines) | |
814 (goto-char (point-min)) | |
815 (while (re-search-forward "^\040+\\|\040+$" nil t) | |
816 (replace-match "")) | |
817 (goto-char (point-min)) | |
818 (while (re-search-forward "\040+" nil t) | |
819 (replace-match " ")) | |
820 (goto-char (point-max)) | |
821 (widen) | |
822 (insert "\n\n") | |
823 (setq p (point)) | |
824 (unless (search-forward "<!-- Data -->" nil t) | |
825 (webmail-error "article@4")) | |
826 (forward-line 14) | |
827 (delete-region p (point)) | |
828 (goto-char (point-max)) | |
829 (unless (re-search-backward | |
830 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t) | |
831 (webmail-error "article@5")) | |
832 (delete-region (point) (point-max)) | |
833 (goto-char p) | |
834 (while (search-forward | |
835 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>" | |
836 nil t 2) | |
837 (setq mime t) | |
838 (unless (search-forward "</TABLE>" nil t) | |
839 (webmail-error "article@6")) | |
840 (setq p1 (point)) | |
841 (if (search-backward "<IMG " p t) | |
842 (progn | |
843 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t) | |
844 (webmail-error "article@7")) | |
845 (setq attachment (match-string 1)) | |
846 (setq type (match-string 2)) | |
847 (unless (search-forward "</TABLE>" nil t) | |
848 (webmail-error "article@8")) | |
849 (delete-region p (point)) | |
850 (let (bufname);; Attachment | |
851 (save-excursion | |
852 (set-buffer (generate-new-buffer " *webmail-att*")) | |
853 (nnweb-insert (concat (car webmail-open-url) attachment)) | |
854 (push (current-buffer) webmail-buffer-list) | |
855 (setq bufname (buffer-name))) | |
856 (insert "<#part type=" type) | |
857 (insert " buffer=\"" bufname "\"") | |
858 (insert " disposition=\"inline\"") | |
859 (insert "><#/part>\n") | |
860 (setq p (point)))) | |
861 (delete-region p p1) | |
862 (narrow-to-region | |
863 p | |
864 (if (search-forward | |
865 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>" | |
866 nil t) | |
867 (match-beginning 0) | |
868 (point-max))) | |
869 (webmail-netaddress-single-part) | |
870 (goto-char (point-max)) | |
871 (setq p (point)) | |
872 (widen))) | |
873 (unless mime | |
874 (narrow-to-region p (point-max)) | |
875 (setq mime (webmail-netaddress-single-part)) | |
876 (widen)) | |
877 (goto-char (point-min)) | |
878 ;; Some blank line to seperate mails. | |
879 (insert "\n\nFrom nobody " (current-time-string) "\n") | |
880 (insert "X-Gnus-Webmail: " (symbol-value 'user) | |
881 "@" (symbol-name webmail-type) "\n") | |
882 (if id | |
883 (insert (format "X-Message-ID: <%s@%s>\n" id webmail-address))) | |
884 (unless (looking-at "$") | |
885 (if (search-forward "\n\n" nil t) | |
886 (forward-line -1) | |
887 (webmail-error "article@2"))) | |
888 (when mime | |
889 (narrow-to-region (point-min) (point)) | |
890 (goto-char (point-min)) | |
891 (while (not (eobp)) | |
892 (if (looking-at "MIME-Version\\|Content-Type") | |
893 (delete-region (point) | |
894 (progn | |
895 (forward-line 1) | |
896 (if (re-search-forward "^[^ \t]" nil t) | |
897 (goto-char (match-beginning 0)) | |
898 (point-max)))) | |
899 (forward-line 1))) | |
900 (goto-char (point-max)) | |
901 (widen) | |
902 (narrow-to-region (point) (point-max)) | |
903 (insert "MIME-Version: 1.0\n" | |
904 (prog1 | |
905 (mml-generate-mime) | |
906 (delete-region (point-min) (point-max)))) | |
907 (goto-char (point-min)) | |
908 (widen)) | |
909 (let (case-fold-search) | |
910 (while (re-search-forward "^From " nil t) | |
911 (beginning-of-line) | |
912 (insert ">")))) | |
913 (mm-append-to-file (point-min) (point-max) file))) | |
914 | |
915 (defun webmail-netscape-article (file id) | |
916 (let (p p1 attachment count mime type) | |
917 (save-restriction | |
918 (webmail-encode-8bit) | |
919 (goto-char (point-min)) | |
920 (if (not (search-forward "Trash" nil t)) | |
921 (webmail-error "article@1")) | |
922 (if (not (search-forward "<form>" nil t)) | |
923 (webmail-error "article@2")) | |
924 (delete-region (point-min) (match-beginning 0)) | |
925 (if (not (search-forward "</form>" nil t)) | |
926 (webmail-error "article@3")) | |
927 (narrow-to-region (point-min) (match-end 0)) | |
928 (goto-char (point-min)) | |
929 (while (re-search-forward "[\040\t\r\n]+" nil t) | |
930 (replace-match " ")) | |
931 (goto-char (point-min)) | |
932 (while (re-search-forward "<a href=[^>]*>[^<]*</a>" nil t) | |
933 (replace-match "")) | |
934 (goto-char (point-min)) | |
935 (while (search-forward "<b>" nil t) | |
936 (replace-match "\n")) | |
937 (nnweb-remove-markup) | |
938 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) | |
939 (nnweb-decode-entities)) | |
940 (goto-char (point-min)) | |
941 (delete-blank-lines) | |
942 (goto-char (point-min)) | |
943 (while (re-search-forward "^\040+\\|\040+$" nil t) | |
944 (replace-match "")) | |
945 (goto-char (point-min)) | |
946 (while (re-search-forward "\040+" nil t) | |
947 (replace-match " ")) | |
948 (goto-char (point-max)) | |
949 (widen) | |
950 (insert "\n\n") | |
951 (setq p (point)) | |
952 (unless (search-forward "<!-- Data -->" nil t) | |
953 (webmail-error "article@4")) | |
954 (forward-line 14) | |
955 (delete-region p (point)) | |
956 (goto-char (point-max)) | |
957 (unless (re-search-backward | |
958 "<form name=\"Transfer2\"" p t) | |
959 (webmail-error "article@5")) | |
960 (delete-region (point) (point-max)) | |
961 (goto-char p) | |
962 (while (search-forward | |
963 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>" | |
964 nil t 2) | |
965 (setq mime t) | |
966 (unless (search-forward "</TABLE>" nil t) | |
967 (webmail-error "article@6")) | |
968 (setq p1 (point)) | |
969 (if (search-backward "<IMG " p t) | |
970 (progn | |
971 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t) | |
972 (webmail-error "article@7")) | |
973 (setq attachment (match-string 1)) | |
974 (setq type (match-string 2)) | |
975 (unless (search-forward "</TABLE>" nil t) | |
976 (webmail-error "article@8")) | |
977 (delete-region p (point)) | |
978 (let (bufname);; Attachment | |
979 (save-excursion | |
980 (set-buffer (generate-new-buffer " *webmail-att*")) | |
981 (nnweb-insert (concat (car webmail-open-url) attachment)) | |
982 (push (current-buffer) webmail-buffer-list) | |
983 (setq bufname (buffer-name))) | |
984 (insert "<#part type=" type) | |
985 (insert " buffer=\"" bufname "\"") | |
986 (insert " disposition=\"inline\"") | |
987 (insert "><#/part>\n") | |
988 (setq p (point)))) | |
989 (delete-region p p1) | |
990 (narrow-to-region | |
991 p | |
992 (if (search-forward | |
993 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>" | |
994 nil t) | |
995 (match-beginning 0) | |
996 (point-max))) | |
997 (webmail-netaddress-single-part) | |
998 (goto-char (point-max)) | |
999 (setq p (point)) | |
1000 (widen))) | |
1001 (unless mime | |
1002 (narrow-to-region p (point-max)) | |
1003 (setq mime (webmail-netaddress-single-part)) | |
1004 (widen)) | |
1005 (goto-char (point-min)) | |
1006 ;; Some blank line to seperate mails. | |
1007 (insert "\n\nFrom nobody " (current-time-string) "\n") | |
1008 (insert "X-Gnus-Webmail: " (symbol-value 'user) | |
1009 "@" (symbol-name webmail-type) "\n") | |
1010 (if id | |
1011 (insert (format "X-Message-ID: <%s@%s>\n" id webmail-address))) | |
1012 (unless (looking-at "$") | |
1013 (if (search-forward "\n\n" nil t) | |
1014 (forward-line -1) | |
1015 (webmail-error "article@2"))) | |
1016 (when mime | |
1017 (narrow-to-region (point-min) (point)) | |
1018 (goto-char (point-min)) | |
1019 (while (not (eobp)) | |
1020 (if (looking-at "MIME-Version\\|Content-Type") | |
1021 (delete-region (point) | |
1022 (progn | |
1023 (forward-line 1) | |
1024 (if (re-search-forward "^[^ \t]" nil t) | |
1025 (goto-char (match-beginning 0)) | |
1026 (point-max)))) | |
1027 (forward-line 1))) | |
1028 (goto-char (point-max)) | |
1029 (widen) | |
1030 (narrow-to-region (point) (point-max)) | |
1031 (insert "MIME-Version: 1.0\n" | |
1032 (prog1 | |
1033 (mml-generate-mime) | |
1034 (delete-region (point-min) (point-max)))) | |
1035 (goto-char (point-min)) | |
1036 (widen)) | |
1037 (let (case-fold-search) | |
1038 (while (re-search-forward "^From " nil t) | |
1039 (beginning-of-line) | |
1040 (insert ">")))) | |
1041 (mm-append-to-file (point-min) (point-max) file))) | |
1042 | |
1043 ;;; my-deja | |
1044 | |
1045 (defun webmail-my-deja-open () | |
1046 (webmail-refresh-redirect) | |
1047 (goto-char (point-min)) | |
1048 (if (re-search-forward "action=\"\\([^\"]+login_confirm\\.xp[^\"]*\\)\"" | |
1049 nil t) | |
1050 (setq webmail-aux (match-string 1)) | |
1051 (webmail-error "open@1"))) | |
1052 | |
1053 (defun webmail-my-deja-list () | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1054 (let (item id newp base) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1055 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1056 (when (re-search-forward "href=\"\\(\\([^\"]*\\)/mailnf\\.[^\"]*\\)\"" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1057 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1058 (let ((url (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1059 (setq base (match-string 2)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1060 (erase-buffer) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1061 (nnweb-insert url))) |
31717 | 1062 (goto-char (point-min)) |
1063 (when (re-search-forward | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1064 "(\\([0-9]+\\) Message.?-[^>]*\\([0-9]+\\) New" |
31717 | 1065 nil t) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1066 (message "Found %s mail(s), %s unread" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1067 (match-string 1) (match-string 2))) |
31717 | 1068 (goto-char (point-min)) |
1069 (while (re-search-forward | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1070 "newmail\\.gif\\|href=\"[^\"]*\\(mailnf\\.[^\"]+act=view[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\"" |
31717 | 1071 nil t) |
1072 (if (setq id (match-string 2)) | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1073 (when (and (or newp (not webmail-newmail-only)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1074 (not (assoc id webmail-articles))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1075 (push (cons id (setq webmail-aux |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1076 (concat base "/" (match-string 1)))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1077 webmail-articles) |
31717 | 1078 (setq newp nil)) |
1079 (setq newp t))) | |
1080 (setq webmail-articles (nreverse webmail-articles)))) | |
1081 | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1082 (defun webmail-my-deja-article-part (base) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1083 (let (p) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1084 (cond |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1085 ((looking-at "[\t\040\r\n]*<!--[^>]*>") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1086 (replace-match "")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1087 ((looking-at "[\t\040\r\n]*</PRE>") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1088 (replace-match "")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1089 ((looking-at "[\t\040\r\n]*<PRE>") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1090 ;; text/plain |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1091 (replace-match "") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1092 (save-restriction |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1093 (narrow-to-region (point) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1094 (if (re-search-forward "</?PRE>" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1095 (match-beginning 0) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1096 (point-max))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1097 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1098 (nnweb-remove-markup) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1099 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1100 (nnweb-decode-entities)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1101 (goto-char (point-max)))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1102 ((looking-at "[\t\040\r\n]*<TABLE") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1103 (save-restriction |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1104 (narrow-to-region (point) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1105 (if (search-forward "</TABLE>" nil t 2) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1106 (point) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1107 (point-max))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1108 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1109 (let (name type url bufname) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1110 (if (and (search-forward "File Name:" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1111 (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1112 (setq name (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1113 (if (and (search-forward "File Type:" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1114 (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1115 (setq type (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1116 (unless (re-search-forward "action=\"getattach\\.cgi/\\([^\"]+\\)" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1117 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1118 (webmail-error "article@5")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1119 (setq url (concat base "/getattach.cgi/" (match-string 1) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1120 "?sm=Download")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1121 (while (re-search-forward |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1122 "type=hidden name=\"\\([^\"]+\\)\" value=\"\\([^\"]+\\)" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1123 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1124 (setq url (concat url "&" (match-string 1) "=" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1125 (match-string 2)))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1126 (delete-region (point-min) (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1127 (save-excursion |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1128 (set-buffer (generate-new-buffer " *webmail-att*")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1129 (nnweb-insert url) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1130 (push (current-buffer) webmail-buffer-list) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1131 (setq bufname (buffer-name))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1132 (insert "<#part type=\"" type "\"") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1133 (if name (insert " filename=\"" name "\"")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1134 (insert " buffer=\"" bufname "\"") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1135 (insert " disposition=inline><#/part>")))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1136 (t |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1137 (insert "<#part type=\"text/html\" disposition=inline>") |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1138 (goto-char (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1139 (insert "<#/part>"))))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1140 |
31717 | 1141 (defun webmail-my-deja-article (file id) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1142 (let (base) |
31717 | 1143 (goto-char (point-min)) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1144 (unless (string-match "\\([^\"]+\\)/mail" webmail-aux) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1145 (webmail-error "article@0")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1146 (setq base (match-string 1 webmail-aux)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1147 (when (re-search-forward |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1148 "href=\"[^\"]*\\(mailnf\\.[^\"]+act=move[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\"" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1149 nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1150 (setq webmail-aux (concat base "/" (match-string 1))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1151 (string-match "mid=[^\"&]+" webmail-aux) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1152 (setq webmail-aux (replace-match "mid=%s" nil nil webmail-aux))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1153 (unless (search-forward "<HR noshade>" nil t) |
31717 | 1154 (webmail-error "article@1")) |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1155 (delete-region (point-min) (point)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1156 (unless (search-forward "<HR noshade>" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1157 (webmail-error "article@2")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1158 (save-restriction |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1159 (narrow-to-region (point-min) (point)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1160 (while (search-forward "\r\n" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1161 (replace-match "\n")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1162 (nnweb-remove-markup) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1163 (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1164 (nnweb-decode-entities)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1165 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1166 (while (re-search-forward "\n\n+" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1167 (replace-match "\n")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1168 (goto-char (point-max))) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1169 (save-restriction |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1170 (narrow-to-region (point) (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1171 (goto-char (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1172 (unless (search-backward "<HR noshade>" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1173 (webmail-error "article@3")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1174 (unless (search-backward "</TT>" nil t) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1175 (webmail-error "article@4")) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1176 (delete-region (point) (point-max)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1177 (goto-char (point-min)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1178 (while (not (eobp)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1179 (webmail-my-deja-article-part base)) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1180 (insert "MIME-Version: 1.0\n" |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1181 (prog1 |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1182 (mml-generate-mime) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1183 (delete-region (point-min) (point-max))))) |
31717 | 1184 (goto-char (point-min)) |
1185 (insert "\n\nFrom nobody " (current-time-string) "\n") | |
1186 (insert "X-Gnus-Webmail: " (symbol-value 'user) | |
1187 "@" (symbol-name webmail-type) "\n") | |
32979
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1188 (if (eq (char-after) ?\n) |
ddc33cf6b78c
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
1189 (delete-char 1)) |
31717 | 1190 (mm-append-to-file (point-min) (point-max) file))) |
1191 | |
1192 (provide 'webmail) | |
1193 | |
1194 ;;; webmail.el ends here |