;; Copyright (C) 1999 Free Software Foundation, Inc.
;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
-;; Keywords: hotmail
+;; Keywords: hotmail yahoo netaddress my-deja
;; This file is part of GNU Emacs.
;;; Commentary:
;; Note: You need to have `url' and `w3' installed for this backend to
-;; work.
+;; work. `w3' must be 4.0pre46+one-line-cookie patch or standalone
+;; `url'.
;; Todo: To support more web mail servers.
;; Known bugs:
-;; 1. In w3, there are two copies of url-maybe-relative.
-;; If it is loaded from w3.el, (load-library "url").
-;; Fixed in w3 4.0pre46.
-;; 2. Hotmail only accept one line cookie, while w3 breaks cookies
-;; into lines.
-;; Maybe fixed in w3 4.0pre47+?.
-;; 3. Net@ddress may corrupt `X-Face'.
+;; 1. Net@ddress may corrupt `X-Face'.
;; Warning:
;; Webmail is an experimental function, which means NO WARRANTY.
(ignore-errors
(require 'w3)
(require 'url)
+ (require 'url-cookie)
(require 'w3-forms)
(require 'nnweb)))
;; Report failure to find w3 at load time if appropriate.
(eval '(progn
(require 'w3)
(require 'url)
+ (require 'url-cookie)
(require 'w3-forms)
(require 'nnweb)))
;; Hotmail hate other HTTP user agents and use one line cookie
(paranoid agent cookie post)
(address . "www.hotmail.com")
- (open-url "http://www.hotmail.com")
+ (open-url "http://www.hotmail.com/")
(open-snarf . webmail-hotmail-open)
;; W3 hate redirect POST
(login-url
"http://%s/cgi-bin/dologin?login=%s&passwd=%s&enter=Sign+in&sec=no&curmbox=ACTIVE&_lang=&js=yes&id=2&tw=-10000&beta="
- webmail-aux user password)
+ webmail-aux user password)
(list-snarf . webmail-hotmail-list)
(article-snarf . webmail-hotmail-article)
(trash-url
(yahoo
(paranoid cookie post)
(address . "mail.yahoo.com")
- (open-url "http://mail.yahoo.com")
+ (open-url "http://mail.yahoo.com/")
(open-snarf . webmail-yahoo-open)
- (login-url ;; yahoo will not accept GET
+ (login-url;; yahoo will not accept GET
content
("%s" webmail-aux)
".tries=1&.src=ym&.last=&promo=&lg=us&.intl=us&.bypass=&.chkP=Y&.done=http%%253a%%2F%%2Fedit.yahoo.com%%2Fconfig%%2Fmail%%253f.intl%%3D&login=%s&passwd=%s"
(netaddress
(paranoid cookie post)
(address . "www.netaddress.com")
- (open-url "http://www.netaddress.com")
+ (open-url "http://www.netaddress.com/")
(open-snarf . webmail-netaddress-open)
- (login-url ;; yahoo will not accept GET
+ (login-url
content
("%s" webmail-aux)
"LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s"
(article-snarf . webmail-netaddress-article)
(trash-url
"http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
- webmail-session id))))
+ webmail-session id))
+ (my-deja
+ (paranoid cookie post)
+ (address . "www.my-deja.com")
+ (open-url "http://www.my-deja.com/")
+ (open-snarf . webmail-my-deja-open)
+ (login-url
+ content
+ ("%s" webmail-aux)
+ "user=%s&pw=%s&autologout=60&go="
+ user password)
+ (list-url "http://www.deja.com/rg_gotomail.xp")
+ (list-snarf . webmail-my-deja-list)
+ (article-snarf . webmail-my-deja-article)
+ (trash-url
+ "%s/gmm_multiplex.femail?%%2Fgmm_domovemesg_top.femail=Move+to%%3A&folder_top=%s%%3Azzz%%3A%%7E6trash%%3AF%%3A0&docid=%s"
+ webmail-aux user id))))
(defvar webmail-variables
'(address article-snarf article-url list-snarf list-url
(defvar webmail-buffer nil)
(defvar webmail-buffer-list nil)
+
+(defvar webmail-type nil)
+
;;; Interface functions
+(defun webmail-error (str)
+ (message "%s HTML has changed; please get a new version of webmail (%s)"
+ webmail-type str)
+ (error "%s HTML has changed; please get a new version of webmail (%s)"
+ webmail-type str))
+
(defun webmail-setdefault (type)
(let ((type-def (cdr (assq type webmail-type-definition)))
(vars webmail-variables)
pair)
+ (setq webmail-type type)
(dolist (var vars)
(if (setq pair (assq var type-def))
(set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
expr)))
(defun webmail-url (xurl)
- (cond
- ((eq (car xurl) 'content)
- (pop xurl)
- (webmail-fetch-simple (if (stringp (car xurl))
- (car xurl)
- (apply 'format (webmail-eval (car xurl))))
- (apply 'format (webmail-eval (cdr xurl)))))
- ((eq (car xurl) 'post)
- (pop xurl)
- (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
- (t
- (nnweb-insert (apply 'format (webmail-eval xurl))))))
-
-(defun webmail-decode-entities ()
- (goto-char (point-min))
- (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
- (replace-match (char-to-string
- (if (eq (aref (match-string 1) 0) ?\#)
- (string-to-number (substring (match-string 1) 1))
- (or (cdr (assq (intern (match-string 1))
- w3-html-entities))
- ?#)))
- t t)))
-
-(defun webmail-decode-entities-string (str)
- (with-temp-buffer
- (insert str)
- (webmail-decode-entities)
- (buffer-substring (point-min) (point-max))))
-
-(defun webmail-remove-markup ()
- (goto-char (point-min))
- (while (search-forward "<!--" nil t)
- (delete-region (match-beginning 0)
- (or (search-forward "-->" nil t)
- (point-max))))
- (goto-char (point-min))
- (while (re-search-forward "<[^>]+>" nil t)
- (replace-match "" t t)))
-
+ (mm-with-unibyte-current-buffer
+ (cond
+ ((eq (car xurl) 'content)
+ (pop xurl)
+ (webmail-fetch-simple (if (stringp (car xurl))
+ (car xurl)
+ (apply 'format (webmail-eval (car xurl))))
+ (apply 'format (webmail-eval (cdr xurl)))))
+ ((eq (car xurl) 'post)
+ (pop xurl)
+ (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
+ (t
+ (nnweb-insert (apply 'format (webmail-eval xurl)))))))
+
(defun webmail-init ()
"Initialize buffers and such."
(if (gnus-buffer-live-p webmail-buffer)
(set-buffer webmail-buffer)
(setq webmail-buffer
- (nnheader-set-temp-buffer " *webmail*"))))
+ (mm-with-unibyte
+ (nnheader-set-temp-buffer " *webmail*")))))
(defvar url-package-name)
(defvar url-package-version)
(defvar url-cookie-multiple-line)
(defvar url-confirmation-func)
-;; Hack W3 POST redirect. See `url-parse-mime-headers'.
+;; Hack W3 POST redirect. See `url-parse-mime-headers'.
;;
;; Netscape uses "GET" as redirect method when orignal method is POST
;; and status is 302, .i.e no security risks by default without
(defun webmail-url-confirmation-func (prompt)
(cond
((equal prompt (concat "Honor redirection with non-GET method "
- "(possible security risks)? "))
+ "(possible security risks)? "))
nil)
((equal prompt "Continue (with method of GET)? ")
t)
(defun webmail-refresh-redirect ()
"Redirect refresh url in META."
(goto-char (point-min))
- (while (re-search-forward "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
- nil t)
+ (while (re-search-forward
+ "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
+ nil t)
(let ((url (match-string 1)))
(erase-buffer)
- (nnweb-insert url))
+ (mm-with-unibyte-current-buffer
+ (nnweb-insert url)))
(goto-char (point-min))))
(defun webmail-fetch (file subtype user password)
(if webmail-list-snarf
(funcall webmail-list-snarf))
(while (setq item (pop webmail-articles))
- (message "Fetching mail #%d..." (setq n (1+ n)))
- (erase-buffer)
- (nnweb-insert (cdr item))
- (setq id (car item))
- (if webmail-article-snarf
- (funcall webmail-article-snarf file id))
- (when (and webmail-trash-url webmail-move-to-trash-can)
- (message "Move mail #%d to trash can..." n)
- (condition-case err
- (progn
- (webmail-url webmail-trash-url)
- (let (buf)
- (while (setq buf (pop webmail-buffer-list))
- (kill-buffer buf))))
- (error
- (let (buf)
- (while (setq buf (pop webmail-buffer-list))
- (kill-buffer buf)))
- (error err))))))
+ (message "Fetching mail #%d..." (setq n (1+ n)))
+ (erase-buffer)
+ (mm-with-unibyte-current-buffer
+ (nnweb-insert (cdr item)))
+ (setq id (car item))
+ (if webmail-article-snarf
+ (funcall webmail-article-snarf file id))
+ (when (and webmail-trash-url webmail-move-to-trash-can)
+ (message "Move mail #%d to trash can..." n)
+ (condition-case err
+ (progn
+ (webmail-url webmail-trash-url)
+ (let (buf)
+ (while (setq buf (pop webmail-buffer-list))
+ (kill-buffer buf))))
+ (error
+ (let (buf)
+ (while (setq buf (pop webmail-buffer-list))
+ (kill-buffer buf)))
+ (error err))))))
(if webmail-post-process
(funcall webmail-post-process))))
+(defun webmail-encode-8bit ()
+ (goto-char (point-min))
+ (skip-chars-forward "^\200-\377")
+ (while (not (eobp))
+ (insert (format "&%d;" (mm-char-int (char-after))))
+ (delete-char 1)
+ (skip-chars-forward "^\200-\377")))
+
;;; hotmail
(defun webmail-hotmail-open ()
(if (re-search-forward
"action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
(setq webmail-aux (match-string 1))
- (error "Can't find login url (open@1)")))
+ (webmail-error "open@1")))
(defun webmail-hotmail-list ()
(let (site url newp)
(goto-char (point-min))
- (if (re-search-forward "[0-9]+ messages, [0-9]+ new")
- (message "Found %s" (match-string 0)))
+ (if (re-search-forward "[0-9]+ messages, [0-9]+ new" nil t)
+ (message "Found %s" (match-string 0))
+ (webmail-error "maybe your w3 version is too old"))
(goto-char (point-min))
(if (re-search-forward
"action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
(setq site (match-string 1))
- (error "Can't find server url (list@1)"))
+ (webmail-error "list@1"))
(goto-char (point-min))
(if (re-search-forward "disk=\\([^&]+\\)&" nil t)
(setq webmail-aux
(concat "http://" site "/cgi-bin/HoTMaiL?disk="
(match-string 1)))
- (error "Can't find disk (list@2)"))
+ (webmail-error "list@2"))
(goto-char (point-max))
(while (re-search-backward
"newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
(let (id)
(if (string-match "msg=\\([^&]+\\)" url)
(setq id (match-string 1 url)))
- (push (cons id (concat "http://" site url))
+ (push (cons id (concat "http://" site url "&raw=0"))
webmail-articles)))
(setq newp nil))
(setq newp t)))))
+;; Thank victor@idaccr.org (Victor S. Miller) for raw=0
+
(defun webmail-hotmail-article (file id)
- (let (p attachment count mime)
+ (goto-char (point-min))
+ (if (not (search-forward "<pre>" nil t))
+ (webmail-error "article@3"))
+ (skip-chars-forward "\n\r\t ")
+ (delete-region (point-min) (point))
+ (if (not (search-forward "</pre>" nil t))
+ (webmail-error "article@3.1"))
+ (delete-region (match-beginning 0) (point-max))
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
+ (goto-char (point-min))
+ (while (re-search-forward "\r\n?" nil t)
+ (replace-match "\n"))
+ (goto-char (point-min))
+ (insert "\n\n")
+ (if (not (looking-at "\n*From "))
+ (insert "From nobody " (current-time-string) "\n"))
+ (mm-append-to-file (point-min) (point-max) file))
+
+(defun webmail-hotmail-article-old (file id)
+ (let (p attachment count mime hotmail-direct)
(save-restriction
+ (webmail-encode-8bit)
(goto-char (point-min))
(if (not (search-forward "<DIV>" nil t))
- (error "Can't find start label (article@1)"))
- (narrow-to-region (point-min) (match-beginning 0))
+ (if (not (search-forward "Reply All" nil t))
+ (webmail-error "article@1")
+ (setq hotmail-direct t))
+ (goto-char (match-beginning 0)))
+ (narrow-to-region (point-min) (point))
(if (not (search-backward "<table" nil t 2))
- (error "Can't find start label (article@1.1)"))
+ (webmail-error "article@1.1"))
(delete-region (point-min) (match-beginning 0))
(while (search-forward "<a href=" nil t)
(setq p (match-beginning 0))
(search-forward "</a>" nil t)
(delete-region p (match-end 0)))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
(goto-char (point-min))
(delete-blank-lines)
(goto-char (point-min))
(widen)
(insert "\n")
(setq p (point))
- (while (re-search-forward "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" nil t)
+ (while (re-search-forward
+ "<tt>\\|<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\""
+ nil t)
(if (setq attachment (match-string 1))
(let ((filename (match-string 2))
- bufname) ;; Attachment
+ bufname);; Attachment
(delete-region p (match-end 0))
(save-excursion
(set-buffer (generate-new-buffer " *webmail-att*"))
(insert "><#/part>\n")
(setq p (point)))
(delete-region p (match-end 0))
- (setq count 1)
- (while (and (> count 0)
- (re-search-forward "</div>\\|\\(<div>\\)" nil t))
- (if (match-string 1)
- (setq count (1+ count))
- (if (= (setq count (1- count)) 0)
- (delete-region (match-beginning 0)
- (match-end 0)))))
+ (if hotmail-direct
+ (if (not (search-forward "</tt>" nil t))
+ (webmail-error "article@1.2")
+ (delete-region (match-beginning 0) (match-end 0)))
+ (setq count 1)
+ (while (and (> count 0)
+ (re-search-forward "</div>\\|\\(<div>\\)" nil t))
+ (if (match-string 1)
+ (setq count (1+ count))
+ (if (= (setq count (1- count)) 0)
+ (delete-region (match-beginning 0)
+ (match-end 0))))))
(narrow-to-region p (point))
(goto-char (point-min))
(cond
(goto-char (match-end 0))
(if (looking-at "$") (forward-char))
(delete-region (point-min) (point))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
nil)
(t
(setq mime t)
;; Some blank line to seperate mails.
(insert "\n\nFrom nobody " (current-time-string) "\n")
(if id
- (insert "Message-ID: <" id "@hotmail.com>\n"))
+ (insert (format "Message-ID: <%s@hotmail.com>\n" id)))
(unless (looking-at "$")
- (search-forward "\n\n" nil t)
- (forward-line -1))
+ (if (search-forward "\n\n" nil t)
+ (forward-line -1)
+ (webmail-error "article@2")))
(narrow-to-region (point) (point-max))
(if mime
(insert "MIME-Version: 1.0\n"
(goto-char (point-min))
(if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
(setq webmail-aux (match-string 1))
- (error "Can't find login url (open@1)")))
+ (webmail-error "open@1")))
(defun webmail-yahoo-login ()
(goto-char (point-min))
(if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
(setq webmail-aux (match-string 0))
- (error "Can't find login url (login@1)"))
+ (webmail-error "login@1"))
(if (re-search-forward "YY=[0-9]+" nil t)
(setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
(match-string 0)))
- (error "Can't find login url (login@2)")))
+ (webmail-error "login@2")))
(defun webmail-yahoo-list ()
(let (url (newp t) (tofetch 0))
(goto-char (point-min))
(when (re-search-forward
"showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
- ;(setq listed (match-string 1))
+ ;;(setq listed (match-string 1))
(message "Found %s mail(s)" (match-string 2)))
(if (string-match "http://[^/]+" webmail-aux)
(setq webmail-aux (match-string 0 webmail-aux))
- (error "Can't find server url (list@1)"))
+ (webmail-error "list@1"))
(goto-char (point-min))
(while (re-search-forward
"bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
(setq tofetch (1+ tofetch)))
(setq newp t))
(setq newp nil)))
+ (setq webmail-articles (nreverse webmail-articles))
(message "Fetching %d mail(s)" tofetch)))
(defun webmail-yahoo-article (file id)
(save-restriction
(goto-char (point-min))
(if (not (search-forward "value=\"Done\"" nil t))
- (error "Can't find start label (article@1)"))
+ (webmail-error "article@1"))
(if (not (search-forward "<table" nil t))
- (error "Can't find start label (article@2)"))
+ (webmail-error "article@2"))
(delete-region (point-min) (match-beginning 0))
(if (not (search-forward "</table>" nil t))
- (error "Can't find start label (article@3)"))
+ (webmail-error "article@3"))
(narrow-to-region (point-min) (match-end 0))
(while (search-forward "<a href=" nil t)
(setq p (match-beginning 0))
(search-forward "</a>" nil t)
(delete-region p (match-end 0)))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
(goto-char (point-min))
(delete-blank-lines)
(goto-char (point-max))
(setq attachment (match-string 0))
(let (bufname ct ctl cd description)
(if (not (search-forward "<table" nil t))
- (error "Can't find start label (article@4)"))
+ (webmail-error "article@4"))
(delete-region p (match-beginning 0))
(if (not (search-forward "</table>" nil t))
- (error "Can't find start label (article@5)"))
+ (webmail-error "article@5"))
(narrow-to-region p (match-end 0))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
(goto-char (point-min))
(delete-blank-lines)
(setq ct (mail-fetch-field "content-type")
;; Some blank line to seperate mails.
(insert "\n\nFrom nobody " (current-time-string) "\n")
(if id
- (insert "Message-ID: <" id "@yahoo.com>\n"))
+ (insert (format "Message-ID: <%s@yahoo.com>\n" id)))
(unless (looking-at "$")
- (search-forward "\n\n" nil t)
- (forward-line -1))
+ (if (search-forward "\n\n" nil t)
+ (forward-line -1)
+ (webmail-error "article@2")))
(narrow-to-region (point) (point-max))
(insert "MIME-Version: 1.0\n"
(prog1
(goto-char (point-min))
(if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
(setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
- (error "Can't find login url (open@1)")))
+ (webmail-error "open@1")))
(defun webmail-netaddress-login ()
(webmail-refresh-redirect)
(goto-char (point-min))
(if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
(setq webmail-session (match-string 1))
- (error "Can't find login url (login@1)")))
+ (webmail-error "login@1")))
(defun webmail-netaddress-list ()
(let (item id)
(cons id
(format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
(car webmail-open-url)
- webmail-session id)))
+ webmail-session id)))
(if (or (not webmail-newmail-only)
(equal (match-string 1) "True"))
- (push item webmail-articles))))))
+ (push item webmail-articles))))
+ (setq webmail-articles (nreverse webmail-articles))))
(defun webmail-netaddress-single-part ()
(goto-char (point-min))
(replace-match " "))
(goto-char (point-min))
(while (re-search-forward "<br>" nil t)
- (replace-match "\n"))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (replace-match "\n"))
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
nil)
(t
(insert "<#part type=\"text/html\" disposition=inline>")
(defun webmail-netaddress-article (file id)
(let (p p1 attachment count mime type)
(save-restriction
+ (webmail-encode-8bit)
(goto-char (point-min))
(if (not (search-forward "Trash" nil t))
- (error "Can't find start label (article@1)"))
+ (webmail-error "article@1"))
(if (not (search-forward "<form>" nil t))
- (error "Can't find start label (article@2)"))
+ (webmail-error "article@2"))
(delete-region (point-min) (match-beginning 0))
(if (not (search-forward "</form>" nil t))
- (error "Can't find start label (article@3)"))
+ (webmail-error "article@3"))
(narrow-to-region (point-min) (match-end 0))
(goto-char (point-min))
(while (re-search-forward "[\040\t\r\n]+" nil t)
(goto-char (point-min))
(while (search-forward "<b>" nil t)
(replace-match "\n"))
- (webmail-remove-markup)
- (webmail-decode-entities)
+ (nnweb-remove-markup)
+ (nnweb-decode-entities)
(goto-char (point-min))
(delete-blank-lines)
(goto-char (point-min))
(insert "\n\n")
(setq p (point))
(unless (search-forward "<!-- Data -->" nil t)
- (error "Can't find start label (article@4)"))
+ (webmail-error "article@4"))
(forward-line 14)
(delete-region p (point))
(goto-char (point-max))
(unless (re-search-backward
"[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
- (error "Can't find end label (article@5)"))
+ (webmail-error "article@5"))
(delete-region (point) (point-max))
(goto-char p)
(while (search-forward
nil t 2)
(setq mime t)
(unless (search-forward "</TABLE>" nil t)
- (error "Can't find end label (article@6)"))
+ (webmail-error "article@6"))
(setq p1 (point))
(if (search-backward "<IMG " p t)
(progn
(unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
- (error "Can't find tag (article@7)"))
+ (webmail-error "article@7"))
(setq attachment (match-string 1))
(setq type (match-string 2))
(unless (search-forward "</TABLE>" nil t)
- (error "Can't find end label (article@8)"))
+ (webmail-error "article@8"))
(delete-region p (point))
- (let (bufname) ;; Attachment
+ (let (bufname);; Attachment
(save-excursion
(set-buffer (generate-new-buffer " *webmail-att*"))
(nnweb-insert (concat (car webmail-open-url) attachment))
(setq p (point))
(widen)))
(unless mime
- (narrow-to-region p (point-max))
- (setq mime (webmail-netaddress-single-part))
- (widen))
+ (narrow-to-region p (point-max))
+ (setq mime (webmail-netaddress-single-part))
+ (widen))
(goto-char (point-min))
;; Some blank line to seperate mails.
(insert "\n\nFrom nobody " (current-time-string) "\n")
(if id
- (insert "Message-ID: <" id "@usa.net>\n"))
+ (insert (format "Message-ID: <%s@usa.net>\n" id)))
(unless (looking-at "$")
- (search-forward "\n\n" nil t)
- (forward-line -1))
+ (if (search-forward "\n\n" nil t)
+ (forward-line -1)
+ (webmail-error "article@2")))
(when mime
(narrow-to-region (point-min) (point))
(goto-char (point-min))
(insert ">"))))
(mm-append-to-file (point-min) (point-max) file)))
+;;; my-deja
+
+(defun webmail-my-deja-open ()
+ (webmail-refresh-redirect)
+ (goto-char (point-min))
+ (if (re-search-forward "action=\"\\([^\"]+login_confirm\\.xp[^\"]+\\)\""
+ nil t)
+ (setq webmail-aux (match-string 1))
+ (webmail-error "open@1")))
+
+(defun webmail-my-deja-list ()
+ (let (item id newp)
+ (goto-char (point-min))
+ (when (re-search-forward
+ "(\\([0-9]+\\) message(s), \\([0-9]+\\) new, \\([0-9]+\\) k )"
+ nil t)
+ (message "Found %s mail(s), %s unread, total size %s K"
+ (match-string 1) (match-string 2) (match-string 3)))
+ (goto-char (point-min))
+ (while (re-search-forward
+ "• \\|\\(http:[^\"]+\\)/display_seemesg\\.femail\\?docid=\\([^&\"]+\\)"
+ nil t)
+ (if (setq id (match-string 2))
+ (when (or newp (not webmail-newmail-only))
+ (push
+ (cons id (format "%s/gmm_multiplex.femail?docid=%s&femail_page_name=display_page&bool_next_on_disp_pg=true&bool_prev_on_disp_pg=false&display_all_headers=false&%%2Fgmm_save.femail=Download&femail_page_name=display_page&bool_next_on_disp_pg=true&bool_prev_on_disp_pg=false&display_all_headers=false"
+ (match-string 1) id))
+ webmail-articles)
+ (setq webmail-aux (match-string 1))
+ (setq newp nil))
+ (setq newp t)))
+ (setq webmail-articles (nreverse webmail-articles))))
+
+(defun webmail-my-deja-article (file id)
+ (let (url)
+ (goto-char (point-min))
+ (unless (re-search-forward "\\(http:[^\"]+/attachment/entire_message.txt[^\"]+\\)" nil t)
+ (webmail-error "article@1"))
+ (setq url (match-string 1))
+ (erase-buffer)
+ (mm-with-unibyte-current-buffer
+ (nnweb-insert url))
+ (goto-char (point-min))
+ (while (search-forward "\r\n" nil t)
+ (replace-match "\n"))
+ (goto-char (point-min))
+ (insert "\n\nFrom nobody " (current-time-string) "\n")
+ (mm-append-to-file (point-min) (point-max) file)))
+
(provide 'webmail)
;;; webmail.el ends here