Mercurial > emacs
annotate lisp/url/url-imap.el @ 103284:5090c7bf0a02
Eli has checked the msdog chapter.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 24 May 2009 20:08:12 +0000 |
parents | a9dc0e7c3f2b |
children | 328150f0cf76 |
rev | line source |
---|---|
54695 | 1 ;;; url-imap.el --- IMAP retrieval routines |
57612 | 2 |
100908 | 3 ;; Copyright (C) 1999, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
57612 | 4 |
54695 | 5 ;; Author: Simon Josefsson <jas@pdc.kth.se> |
6 ;; Keywords: comm, data, processes | |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
57612 | 11 ;; it under the terms of the GNU General Public License as published by |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
57612 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
54695 | 19 |
57612 | 20 ;; You should have received a copy of the GNU General Public License |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
57612 | 22 |
23 ;;; Commentary: | |
54695 | 24 |
57612 | 25 ;; Anyway, here's a teaser. It's quite broken in lots of regards, but at |
26 ;; least it seem to work. At least a little. At least when called | |
27 ;; manually like this (I've no idea how it's supposed to be called): | |
28 | |
29 ;; (url-imap (url-generic-parse-url "imap://cyrus.andrew.cmu.edu/archive.c-client;UID=1021")) | |
30 | |
31 ;;; Code: | |
54695 | 32 |
33 (require 'url-util) | |
34 (require 'url-parse) | |
35 (require 'nnimap) | |
36 (require 'mm-util) | |
37 | |
96486
7369ded3b436
Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
94668
diff
changeset
|
38 (defconst url-imap-default-port 143 "Default IMAP port.") |
54695 | 39 |
40 (defun url-imap-open-host (host port user pass) | |
41 ;; xxx use user and password | |
42 (if (fboundp 'nnheader-init-server-buffer) | |
43 (nnheader-init-server-buffer)) | |
44 (let ((imap-username user) | |
45 (imap-password pass) | |
46 (authenticator (if user 'login 'anonymous))) | |
47 (nnimap-open-server host | |
48 `((nnimap-server-port ,port) | |
49 (nnimap-stream 'network) | |
50 (nnimap-authenticator ,authenticator))))) | |
51 | |
52 (defun url-imap (url) | |
86950
fed682f20285
(top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
53 (unless (vectorp url) |
fed682f20285
(top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
54 (signal 'wrong-type-error (list "Need a pre-parsed URL." url))) |
54695 | 55 (save-excursion |
56 (set-buffer (generate-new-buffer " *url-imap*")) | |
57 (mm-disable-multibyte) | |
58 (let* ((host (url-host url)) | |
59 (port (url-port url)) | |
60 ;; xxx decode mailbox (see rfc2192) | |
61 (mailbox (url-filename url)) | |
62 (coding-system-for-read 'binary)) | |
63 (and (eq (string-to-char mailbox) ?/) | |
64 (setq mailbox (substring mailbox 1))) | |
65 (url-imap-open-host host port (url-user url) (url-password url)) | |
66 (cond ((assoc "TYPE" (url-attributes url)) | |
67 ;; xxx list mailboxes (start gnus?) | |
68 ) | |
69 ((assoc "UID" (url-attributes url)) | |
70 ;; fetch message part | |
71 ;; xxx handle partial fetches | |
72 (insert "Content-type: message/rfc822\n\n") | |
96486
7369ded3b436
Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
94668
diff
changeset
|
73 (nnimap-request-article (cdr (assoc "UID" (url-attributes url))) |
54695 | 74 mailbox host (current-buffer))) |
75 (t | |
76 ;; xxx list messages in mailbox (start gnus?) | |
77 ))) | |
78 (current-buffer))) | |
54699 | 79 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
80 ;; arch-tag: 034991ff-5425-48ea-b911-c96c90e6f47d |
57612 | 81 ;;; url-imap.el ends here |