1 ;;; url-imap.el --- IMAP retrieval routines
2 ;; Author: Simon Josefsson <jas@pdc.kth.se>
3 ;; Created: $Date: 2004/04/04 01:21:46 $
4 ;; Version: $Revision: 1.1.1.1 $
5 ;; Keywords: comm, data, processes
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1999 Free Software Foundation, Inc.
10 ;;; This file is part of GNU Emacs.
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2, or (at your option)
15 ;;; any later version.
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;;; Boston, MA 02111-1307, USA.
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ; Anyway, here's a teaser. It's quite broken in lots of regards, but at
29 ; least it seem to work. At least a little. At least when called
30 ; manually like this (I've no idea how it's supposed to be called):
32 ; (url-imap (url-generic-parse-url "imap://cyrus.andrew.cmu.edu/archive.c-client;UID=1021"))
34 (eval-when-compile (require 'cl
))
40 (defconst url-imap-default-port
143 "Default IMAP port")
42 (defun url-imap-open-host (host port user pass
)
43 ;; xxx use user and password
44 (if (fboundp 'nnheader-init-server-buffer
)
45 (nnheader-init-server-buffer))
46 (let ((imap-username user
)
48 (authenticator (if user
'login
'anonymous
)))
50 (setq port
(string-to-int port
)))
51 (nnimap-open-server host
52 `((nnimap-server-port ,port
)
53 (nnimap-stream 'network
)
54 (nnimap-authenticator ,authenticator
)))))
57 (check-type url vector
"Need a pre-parsed URL.")
59 (set-buffer (generate-new-buffer " *url-imap*"))
60 (mm-disable-multibyte)
61 (let* ((host (url-host url
))
63 ;; xxx decode mailbox (see rfc2192)
64 (mailbox (url-filename url
))
65 (coding-system-for-read 'binary
))
66 (and (eq (string-to-char mailbox
) ?
/)
67 (setq mailbox
(substring mailbox
1)))
68 (url-imap-open-host host port
(url-user url
) (url-password url
))
69 (cond ((assoc "TYPE" (url-attributes url
))
70 ;; xxx list mailboxes (start gnus?)
72 ((assoc "UID" (url-attributes url
))
74 ;; xxx handle partial fetches
75 (insert "Content-type: message/rfc822\n\n")
76 (nnimap-request-article (cdr (assoc "UID" (url-attributes url
)))
77 mailbox host
(current-buffer)))
79 ;; xxx list messages in mailbox (start gnus?)
83 ;;; arch-tag: 034991ff-5425-48ea-b911-c96c90e6f47d