Add www.netaddress.com for webmail.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 23 Nov 1999 22:29:10 +0000 (22:29 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 23 Nov 1999 22:29:10 +0000 (22:29 +0000)
lisp/ChangeLog
lisp/webmail.el
texi/ChangeLog
texi/gnus.texi

index e7af66c..30f11c3 100644 (file)
@@ -1,3 +1,7 @@
+1999-11-23 17:21:05  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * webmail.el: Support www.netaddress.com, i.e. usa.net.
+
 1999-11-23  Hrvoje Niksic  <hniksic@iskon.hr>
 
        * mml.el (mml-quote-region): Insert ! after the hash.
@@ -872,7 +876,7 @@ Mon Sep 27 15:18:05 1999  Lars Magne Ingebrigtsen  <larsi@menja.ifi.uio.no>
 
        * gnus-art.el (gnus-treat-predicate): Work for (not 5).
 
-1999-08-27  Peter von der Ah\e-A\ ei\ f  <pahe@daimi.au.dk>
+1999-08-27  Peter von der Ah\e-Aé  <pahe@daimi.au.dk>\e$)A
 
        * message.el (message-send): More helpful error message if sending
        fails
@@ -1074,7 +1078,7 @@ Fri Aug 27 13:17:48 1999  Lars Magne Ingebrigtsen  <larsi@menja.ifi.uio.no>
        * gnus-agent.el (gnus-agent-get-undownloaded-list): Don't
        mark cached articles as `undownloaded'.
 
-Tue Jul 20 02:39:56 1999  Peter von der Ah\e-A\ ei\ f  <peter@ahe.dk>
+Tue Jul 20 02:39:56 1999  Peter von der Ah\e-Aé  <peter@ahe.dk>\e$)A
 
        * gnus-sum.el (gnus-summary-exit): Allow gnus-use-adaptive-scoring
        to have buffer local values.
@@ -3626,7 +3630,7 @@ Mon Nov 30 23:38:02 1998  Shenghuo ZHU  <zsh@cs.rochester.edu>
 
        * mm-uu.el (mm-uu-dissect): Use mm-make-handle.
 
-1998-12-01 01:53:49  Fran\e-A\ eg\ fois Pinard  <pinard@iro.umontreal.ca>
+1998-12-01 01:53:49  Fran\e-Açois Pinard  <pinard@iro.umontreal.ca>\e$)A
 
        * nndoc.el (nndoc-mime-parts-type-p): Do related.
 
@@ -5372,7 +5376,7 @@ Mon Sep 14 18:55:38 1998  Lars Magne Ingebrigtsen  <larsi@menja.ifi.uio.no>
 
        * rfc2047.el (rfc2047-q-encode-region): Would bug out.
 
-1998-09-13  Fran\e-A\ eg\ fois Pinard  <pinard@iro.umontreal.ca>
+1998-09-13  Fran\e-Açois Pinard  <pinard@iro.umontreal.ca>\e$)A
 
        * nndoc.el: Make nndoc-dissection-alist simpler for MIME, adjust all
           related functions.  Handle message/rfc822 parts.  Display subject on
index 135713d..c9dfaef 100644 (file)
@@ -26,7 +26,7 @@
 ;; Note: You need to have `url' and `w3' installed for this backend to
 ;; work.
 
-;; Todo: To support more web mail.
+;; Todo: To support more web mail servers.
 
 ;; Known bugs: 
 ;; 1. In w3, there are two copies of url-maybe-relative.
 ;; 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'.
 
 ;; Warning:
-;; webmail is an experimental function, which means NO WARRANTY.
+;; Webmail is an experimental function, which means NO WARRANTY.
 
 ;;; Code:
 
      (article-snarf . webmail-yahoo-article)
      (trash-url 
       "%s/ym/us/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2="
-      webmail-aux id))))
+      webmail-aux id))
+    (netaddress
+     (paranoid cookie post)
+     (address . "www.netaddress.com")
+     (open-url "http://www.netaddress.com")
+     (open-snarf . webmail-netaddress-open)
+     (login-url ;; yahoo will not accept GET
+      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" 
+      user password)
+     (login-snarf . webmail-netaddress-login)
+     (list-url 
+      "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
+      webmail-session)
+     (list-snarf . webmail-netaddress-list)
+     (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))))
 
 (defvar webmail-variables
   '(address article-snarf article-url list-snarf list-url 
 (defvar webmail-address nil)
 (defvar webmail-paranoid nil)
 (defvar webmail-aux nil)
+(defvar webmail-session nil)
 (defvar webmail-article-snarf nil)
 (defvar webmail-article-url nil)
 (defvar webmail-list-snarf nil)
     t)
    (t (error prompt))))
 
+(defun webmail-refresh-redirect ()
+  "Redirect refresh url in META."
+  (goto-char (point-min))
+  (while (re-search-forward "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
+                          nil t)
+    (let ((url (match-string 1)))
+      (erase-buffer)
+      (nnweb-insert url))
+    (goto-char (point-min))))
 
 (defun webmail-fetch (file subtype user password)
   (save-excursion
          url-cookie-confirmation
          item id (n 0))
       (webmail-init)
+      (setq webmail-articles nil)
       (when webmail-open-url 
        (erase-buffer)
        (webmail-url webmail-open-url))
 
 (defun webmail-yahoo-article (file id)
   (let (p attachment)
-       (save-restriction
-         (goto-char (point-min))
-         (if (not (search-forward "value=\"Done\"" nil t))
-             (error "Can't find start label (article@1)"))
-         (if (not (search-forward "<table" nil t))
-             (error "Can't find start label (article@2)"))
-         (delete-region (point-min) (match-beginning 0)) 
-         (if (not (search-forward "</table>" nil t))
-             (error "Can't find start label (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)
-         (goto-char (point-min))
-         (delete-blank-lines)
-         (goto-char (point-max))
-         (widen)
-         (insert "\n")
-         (setq p (point))
-         (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
+    (save-restriction
+      (goto-char (point-min))
+      (if (not (search-forward "value=\"Done\"" nil t))
+         (error "Can't find start label (article@1)"))
+      (if (not (search-forward "<table" nil t))
+         (error "Can't find start label (article@2)"))
+      (delete-region (point-min) (match-beginning 0)) 
+      (if (not (search-forward "</table>" nil t))
+         (error "Can't find start label (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)
+      (goto-char (point-min))
+      (delete-blank-lines)
+      (goto-char (point-max))
+      (widen)
+      (insert "\n")
+      (setq p (point))
+      (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
        (setq attachment (match-string 0))
        (let (bufname ct ctl cd description)
          (if (not (search-forward "<table" nil t))
          (insert ">"))))
     (mm-append-to-file (point-min) (point-max) file)))
 
+;;; netaddress
+
+(defun webmail-netaddress-open ()
+  (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)")))
+
+(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)")))
+
+(defun webmail-netaddress-list ()
+  (let (item id)
+    (goto-char (point-min))
+    (when (re-search-forward 
+          "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t) 
+      (message "Found %s mail(s), %s unread" 
+              (match-string 2) (match-string 1)))
+    (goto-char (point-min))
+    (while (re-search-forward 
+           "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
+      (if (setq id (match-string 2))
+         (setq item 
+               (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)))
+       (if (or (not webmail-newmail-only)
+               (equal (match-string 1) "True"))
+           (push item webmail-articles))))))
+
+(defun webmail-netaddress-single-part ()
+  (goto-char (point-min))
+  (cond 
+   ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
+    ;; text/plain
+    (replace-match "")
+    (while (re-search-forward "[\t\040\r\n]+" nil t)
+      (replace-match " "))
+    (goto-char (point-min))
+    (while (re-search-forward "<br>" nil t)
+       (replace-match "\n"))
+    (webmail-remove-markup)
+    (webmail-decode-entities) 
+    nil)
+   (t
+    (insert "<#part type=\"text/html\" disposition=inline>")
+    (goto-char (point-max))
+    (insert "<#/part>")
+    t)))
+
+(defun webmail-netaddress-article (file id)
+  (let (p p1 attachment count mime type)
+    (save-restriction
+      (goto-char (point-min))
+      (if (not (search-forward "Trash" nil t))
+         (error "Can't find start label (article@1)"))
+      (if (not (search-forward "<form>" nil t))
+         (error "Can't find start label (article@2)"))
+      (delete-region (point-min) (match-beginning 0)) 
+      (if (not (search-forward "</form>" nil t))
+         (error "Can't find start label (article@3)"))
+      (narrow-to-region (point-min) (match-end 0))
+      (goto-char (point-min))
+      (while (re-search-forward "[\040\t\r\n]+" nil t)
+       (replace-match " "))
+      (goto-char (point-min))
+      (while (search-forward "<b>" nil t)
+       (replace-match "\n"))
+      (webmail-remove-markup)
+      (webmail-decode-entities)
+      (goto-char (point-min))
+      (delete-blank-lines)
+      (goto-char (point-min))
+      (while (re-search-forward "^\040+\\|\040+$" nil t)
+       (replace-match ""))
+      (goto-char (point-min))
+      (while (re-search-forward "\040+" nil t)
+       (replace-match " "))
+      (goto-char (point-max))
+      (widen)
+      (insert "\n\n")
+      (setq p (point))
+      (unless (search-forward "<!-- Data -->" nil t)
+       (error "Can't find start label (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)"))
+      (delete-region (point) (point-max))
+      (goto-char p)
+      (while (search-forward
+             "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
+             nil t 2)
+       (setq mime t)
+       (unless (search-forward "</TABLE>" nil t)
+         (error "Can't find end label (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)"))
+             (setq attachment (match-string 1))
+             (setq type (match-string 2))
+             (unless (search-forward "</TABLE>" nil t)
+               (error "Can't find end label (article@8)"))
+             (delete-region p (point))
+             (let (bufname) ;; Attachment
+               (save-excursion
+                 (set-buffer (generate-new-buffer " *webmail-att*"))
+                 (nnweb-insert (concat (car webmail-open-url) attachment))
+                 (push (current-buffer) webmail-buffer-list)
+                 (setq bufname (buffer-name)))
+               (insert "<#part type=" type)
+               (insert " buffer=\"" bufname "\"")
+               (insert " disposition=\"inline\"")
+               (insert "><#/part>\n")
+               (setq p (point))))
+         (delete-region p p1)
+         (narrow-to-region 
+          p
+          (if (search-forward 
+               "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
+               nil t)
+              (match-beginning 0)
+            (point-max)))
+         (webmail-netaddress-single-part)
+         (goto-char (point-max))
+         (setq p (point))
+         (widen)))
+      (unless mime
+         (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"))
+      (unless (looking-at "$") 
+       (search-forward "\n\n" nil t)
+       (forward-line -1))
+      (when mime
+       (narrow-to-region (point-min) (point))
+       (goto-char (point-min))
+       (while (not (eobp))
+         (if (looking-at "MIME-Version\\|Content-Type")
+             (delete-region (point) 
+                            (progn
+                              (forward-line 1)
+                              (if (re-search-forward "^[^ \t]" nil t)
+                                  (goto-char (match-beginning 0))
+                                (point-max))))
+           (forward-line 1)))
+       (goto-char (point-max))
+       (widen)
+       (narrow-to-region (point) (point-max))
+       (insert "MIME-Version: 1.0\n"
+               (prog1
+                   (mml-generate-mime)
+                 (delete-region (point-min) (point-max))))
+       (goto-char (point-min))
+       (widen))
+      (let (case-fold-search)
+       (while (re-search-forward "^From " nil t)
+         (beginning-of-line)
+         (insert ">"))))
+    (mm-append-to-file (point-min) (point-max) file)))
+
 (provide 'webmail)
 
 ;;; webmail.el ends here
index 2afe9b9..f66f871 100644 (file)
@@ -1,3 +1,7 @@
+1999-11-23 17:23:37  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * gnus.texi (Mail Source Specifiers): Update.
+
 1999-11-23 05:07:59  Shenghuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus.texi (Web Archive): Add nnwarchive.
index e0b5bfa..a6d85c2 100644 (file)
@@ -10548,15 +10548,17 @@ An example IMAP mail source:
 @end lisp
 
 @item webmail
-Get mail from a webmail server, such as www.hotmail.com and
-mail.yahoo.com.
+Get mail from a webmail server, such as www.hotmail.com, 
+mail.yahoo.com, and www.netaddress.com. 
+
+WARNING: Mails may lost. NO WARRANTY.
 
 Keywords:
 
 @table @code
 @item :subtype
 The type of the webmail server.  The default is @code{hotmail}. The
-alternative is @code{yahoo}.
+alternatives are @code{yahoo}, @code{netaddress}.
 
 @item :user
 The user name to give to the webmail server.  The default is the login