+(defun webmail-netscape-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))
+ (webmail-error "article@1"))
+ (if (not (search-forward "<form>" nil t))
+ (webmail-error "article@2"))
+ (delete-region (point-min) (match-beginning 0))
+ (if (not (search-forward "</form>" nil t))
+ (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)
+ (replace-match " "))
+ (goto-char (point-min))
+ (while (re-search-forward "<a href=[^>]*>[^<]*</a>" nil t)
+ (replace-match ""))
+ (goto-char (point-min))
+ (while (search-forward "<b>" nil t)
+ (replace-match "\n"))
+ (mm-url-remove-markup)
+ (mm-url-decode-entities-nbsp)
+ (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)
+ (webmail-error "article@4"))
+ (forward-line 14)
+ (delete-region p (point))
+ (goto-char (point-max))
+ (unless (re-search-backward
+ "<form name=\"Transfer2\"" p t)
+ (webmail-error "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)
+ (webmail-error "article@6"))
+ (setq p1 (point))
+ (if (search-backward "<IMG " p t)
+ (progn
+ (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
+ (webmail-error "article@7"))
+ (setq attachment (match-string 1))
+ (setq type (match-string 2))
+ (unless (search-forward "</TABLE>" nil t)
+ (webmail-error "article@8"))
+ (delete-region p (point))
+ (let (bufname);; Attachment
+ (save-excursion
+ (set-buffer (generate-new-buffer " *webmail-att*"))
+ (mm-url-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")
+ (insert "X-Gnus-Webmail: " (symbol-value 'user)
+ "@" (symbol-name webmail-type) "\n")
+ (if id
+ (insert (format "X-Message-ID: <%s@%s>\n" id webmail-address)))
+ (unless (looking-at "$")
+ (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))
+ (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)))
+
+;;; my-deja
+
+(defun webmail-my-deja-open ()
+ (webmail-refresh-redirect)
+ (goto-char (point-min))
+ (if (re-search-forward "action=\"\\([^\"]+maillogin\\.py[^\"]*\\)\""
+ nil t)
+ (setq webmail-aux (match-string 1))
+ (webmail-error "open@1")))
+
+(defun webmail-my-deja-list ()
+ (let (item id newp base)
+ (goto-char (point-min))
+ (when (re-search-forward "href=\"\\(\\([^\"]*\\)/mailnf\\.[^\"]*\\)\""
+ nil t)
+ (let ((url (match-string 1)))
+ (setq base (match-string 2))
+ (erase-buffer)
+ (mm-url-insert url)))
+ (goto-char (point-min))
+ (when (re-search-forward
+ "(\\([0-9]+\\) Message.?-[^>]*\\([0-9]+\\) New"
+ nil t)
+ (message "Found %s mail(s), %s unread"
+ (match-string 1) (match-string 2)))
+ (goto-char (point-min))
+ (while (re-search-forward
+ "newmail\\.gif\\|href=\"[^\"]*\\(mailnf\\.[^\"]+act=view[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\""
+ nil t)
+ (if (setq id (match-string 2))
+ (when (and (or newp (not webmail-newmail-only))
+ (not (assoc id webmail-articles)))
+ (push (cons id (setq webmail-aux
+ (concat base "/" (match-string 1))))
+ webmail-articles)
+ (setq newp nil))
+ (setq newp t)))
+ (setq webmail-articles (nreverse webmail-articles))))
+
+(defun webmail-my-deja-article-part (base)
+ (let (p)
+ (cond
+ ((looking-at "[\t\040\r\n]*<!--[^>]*>")
+ (replace-match ""))
+ ((looking-at "[\t\040\r\n]*</PRE>")
+ (replace-match ""))
+ ((looking-at "[\t\040\r\n]*<PRE>")
+ ;; text/plain
+ (replace-match "")
+ (save-restriction
+ (narrow-to-region (point)
+ (if (re-search-forward "</?PRE>" nil t)
+ (match-beginning 0)
+ (point-max)))
+ (goto-char (point-min))
+ (mm-url-remove-markup)
+ (mm-url-decode-entities-nbsp)
+ (goto-char (point-max))))
+ ((looking-at "[\t\040\r\n]*<TABLE")
+ (save-restriction
+ (narrow-to-region (point)
+ (if (search-forward "</TABLE>" nil t 2)
+ (point)
+ (point-max)))
+ (goto-char (point-min))
+ (let (name type url bufname)
+ (if (and (search-forward "File Name:" nil t)
+ (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t))
+ (setq name (match-string 1)))
+ (if (and (search-forward "File Type:" nil t)
+ (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t))
+ (setq type (match-string 1)))
+ (unless (re-search-forward "action=\"getattach\\.cgi/\\([^\"]+\\)"
+ nil t)
+ (webmail-error "article@5"))
+ (setq url (concat base "/getattach.cgi/" (match-string 1)
+ "?sm=Download"))
+ (while (re-search-forward
+ "type=hidden name=\"\\([^\"]+\\)\" value=\"\\([^\"]+\\)"
+ nil t)
+ (setq url (concat url "&" (match-string 1) "="
+ (match-string 2))))
+ (delete-region (point-min) (point-max))
+ (save-excursion
+ (set-buffer (generate-new-buffer " *webmail-att*"))
+ (mm-url-insert url)
+ (push (current-buffer) webmail-buffer-list)
+ (setq bufname (buffer-name)))
+ (insert "<#part type=\"" type "\"")
+ (if name (insert " filename=\"" name "\""))
+ (insert " buffer=\"" bufname "\"")
+ (insert " disposition=inline><#/part>"))))
+ (t
+ (insert "<#part type=\"text/html\" disposition=inline>")
+ (goto-char (point-max))
+ (insert "<#/part>")))))
+
+(defun webmail-my-deja-article (file id)
+ (let (base)
+ (goto-char (point-min))
+ (unless (string-match "\\([^\"]+\\)/mail" webmail-aux)
+ (webmail-error "article@0"))
+ (setq base (match-string 1 webmail-aux))
+ (when (re-search-forward
+ "href=\"[^\"]*\\(mailnf\\.[^\"]+act=move[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\""
+ nil t)
+ (setq webmail-aux (concat base "/" (match-string 1)))
+ (string-match "mid=[^\"&]+" webmail-aux)
+ (setq webmail-aux (replace-match "mid=%s" nil nil webmail-aux)))
+ (unless (search-forward "<HR noshade>" nil t)
+ (webmail-error "article@1"))
+ (delete-region (point-min) (point))
+ (unless (search-forward "<HR noshade>" nil t)
+ (webmail-error "article@2"))
+ (save-restriction
+ (narrow-to-region (point-min) (point))
+ (while (search-forward "\r\n" nil t)
+ (replace-match "\n"))
+ (mm-url-remove-markup)
+ (mm-url-decode-entities-nbsp)
+ (goto-char (point-min))
+ (while (re-search-forward "\n\n+" nil t)
+ (replace-match "\n"))
+ (goto-char (point-max)))
+ (save-restriction
+ (narrow-to-region (point) (point-max))
+ (goto-char (point-max))
+ (unless (search-backward "<HR noshade>" nil t)
+ (webmail-error "article@3"))
+ (unless (search-backward "</TT>" nil t)
+ (webmail-error "article@4"))
+ (delete-region (point) (point-max))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (webmail-my-deja-article-part base))
+ (insert "MIME-Version: 1.0\n"
+ (prog1
+ (mml-generate-mime)
+ (delete-region (point-min) (point-max)))))
+ (goto-char (point-min))
+ (insert "\n\nFrom nobody " (current-time-string) "\n")
+ (insert "X-Gnus-Webmail: " (symbol-value 'user)
+ "@" (symbol-name webmail-type) "\n")
+ (if (eq (char-after) ?\n)
+ (delete-char 1))
+ (mm-append-to-file (point-min) (point-max) file)))
+