(mm-codepage-setup): New helper function.
[gnus] / lisp / nnwarchive.el
index 1abc4dd..a543c8e 100644 (file)
@@ -1,5 +1,7 @@
 ;;; nnwarchive.el --- interfacing with web archives
-;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: news egroups mail-archive
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 ;; Note: You need to have `url' (w3 0.46) or greater version
-;; installed for this backend to work.
+;; installed for some functions of this backend to work.
 
 ;; Todo:
 ;; 1. To support more web archives.
 (require 'gnus-bcklg)
 (require 'nnmail)
 (require 'mm-util)
-(require 'mail-source)
-(eval-when-compile
-  (ignore-errors
-    (require 'w3)
-    (require 'url)
-    (require 'w3-forms)
-    (require 'nnweb)))
-;; Report failure to find w3 at load time if appropriate.
-(eval '(progn
-        (require 'w3)
-        (require 'url)
-        (require 'w3-forms)
-        (require 'nnweb)))
+(require 'mm-url)
 
 (nnoo-declare nnwarchive)
 
                 user-mail-address)))
     (setq nnwarchive-passwd
          (or nnwarchive-passwd
-             (mail-source-read-passwd
+             (read-passwd
               (format "Password for %s at %s: "
                       nnwarchive-login server)))))
   (unless nnwarchive-groups
             (format " *nnwarchive %s %s*" nnwarchive-type server)))))
   (nnwarchive-set-default nnwarchive-type))
 
-(defun nnwarchive-encode-www-form-urlencoded (pairs)
-  "Return PAIRS encoded for forms."
-  (mapconcat
-   (function
-    (lambda (data)
-      (concat (w3-form-encode-xwfu (car data)) "="
-             (w3-form-encode-xwfu (cdr data)))))
-   pairs "&"))
-
-(defun nnwarchive-fetch-form (url pairs)
-  (let ((url-request-data (nnwarchive-encode-www-form-urlencoded pairs))
-       (url-request-method "POST")
-       (url-request-extra-headers
-        '(("Content-type" . "application/x-www-form-urlencoded"))))
-    (nnweb-insert url))
-  t)
-
 (defun nnwarchive-eval (expr)
   (cond
    ((consp expr)
 
 (defun nnwarchive-url (xurl)
   (mm-with-unibyte-current-buffer
-    (let ((url-confirmation-func 'identity)
+    (let ((url-confirmation-func 'identity) ;; Some hacks.
          (url-cookie-multiple-line nil))
       (cond
        ((eq (car xurl) 'post)
        (pop xurl)
-       (nnwarchive-fetch-form (car xurl) (nnwarchive-eval (cdr xurl))))
+       (mm-url-fetch-form (car xurl) (nnwarchive-eval (cdr xurl))))
        (t
-       (nnweb-insert (apply 'format (nnwarchive-eval xurl))))))))
+       (mm-url-insert (apply 'format (nnwarchive-eval xurl))))))))
 
 (defun nnwarchive-generate-active ()
   (save-excursion
               article
               (make-full-mail-header
                article
-               (nnweb-decode-entities-string subject)
-               (nnweb-decode-entities-string from)
+               (mm-url-decode-entities-string subject)
+               (mm-url-decode-entities-string from)
                date
                (concat "<" group "%"
                        (number-to-string article)
   (goto-char (point-min))
   (while (re-search-forward "<a[^>]+>\\([^<]+\\)</a>" nil t)
     (replace-match "\\1"))
-  (nnweb-decode-entities)
+  (mm-url-decode-entities)
   (buffer-string))
 
 (defun nnwarchive-egroups-xover-files (group articles)
            subject (match-string 2))
       (forward-line 1)
       (unless (assq article nnwarchive-headers)
-       (if (looking-at "<UL><LI><EM>From</EM>:\\([^&]+\\)<\\([^&]+\\)>")
+       (if (looking-at "<UL><LI><EM>From</EM>: *\\([^<]*[^< ]\\) *&lt;\\([^&]+\\)&gt;")
            (progn
              (setq from (match-string 1)
                    date (identity (match-string 2))))
               article
               (make-full-mail-header
                article
-               (nnweb-decode-entities-string subject)
-               (nnweb-decode-entities-string from)
+               (mm-url-decode-entities-string subject)
+               (mm-url-decode-entities-string from)
                date
                (format "<%05d%%%s>\n" (1- article) group)
                ""
   (let (p refs url mime e
          from subject date id
          done
-         (case-fold-serch t))
+         (case-fold-search t))
     (save-restriction
       (goto-char (point-min))
       (when (search-forward "X-Head-End" nil t)
        (beginning-of-line)
        (narrow-to-region (point-min) (point))
-       (nnweb-decode-entities)
+       (mm-url-decode-entities)
        (goto-char (point-min))
        (while (search-forward "<!--X-" nil t)
          (replace-match ""))
        (search-forward "</ul>" nil t)
        (end-of-line)
        (narrow-to-region (point-min) (point))
-       (nnweb-remove-markup)
-       (nnweb-decode-entities)
+       (mm-url-remove-markup)
+       (mm-url-decode-entities)
        (goto-char (point-min))
        (delete-blank-lines)
        (when from
                (delete-region (match-beginning 0) (match-end 0))
                (save-restriction
                  (narrow-to-region p (point))
-                 (nnweb-remove-markup)
-                 (nnweb-decode-entities)
+                 (mm-url-remove-markup)
+                 (mm-url-decode-entities)
                  (goto-char (point-max)))))
             ((looking-at "<P><A HREF=\"\\([^\"]+\\)")
              (setq url (match-string 1))
 
 (provide 'nnwarchive)
 
+;;; arch-tag: 1ab7a15c-777a-40e0-95c0-0c41b3963578
 ;;; nnwarchive.el ends here