598a2fe7edbc0f9d89cd01bcf6eda6a5ea32340c
[gnus] / lisp / mail-source.el
1 ;;; mail-source.el --- functions for fetching mail
2
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news, mail
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31   (require 'cl)
32   (require 'imap)
33   (eval-when-compile (defvar display-time-mail-function)))
34 (eval-and-compile
35   (autoload 'pop3-movemail "pop3")
36   (autoload 'pop3-get-message-count "pop3")
37   (autoload 'nnheader-cancel-timer "nnheader"))
38 (require 'format-spec)
39 (require 'mm-util)
40 (require 'message) ;; for `message-directory'
41
42 (defgroup mail-source nil
43   "The mail-fetching library."
44   :version "21.1"
45   :group 'gnus)
46
47 ;; Define these at compile time to avoid dragging in imap always.
48 (defconst mail-source-imap-authenticators
49   (eval-when-compile
50     (mapcar (lambda (a)
51               (list 'const (car a)))
52      imap-authenticator-alist)))
53 (defconst mail-source-imap-streams
54   (eval-when-compile
55     (mapcar (lambda (a)
56               (list 'const (car a)))
57      imap-stream-alist)))
58
59 (defcustom mail-sources nil
60   "*Where the mail backends will look for incoming mail.
61 This variable is a list of mail source specifiers.
62 See Info node `(gnus)Mail Source Specifiers'."
63   :group 'mail-source
64   :link '(custom-manual "(gnus)Mail Source Specifiers")
65   :type `(repeat
66           (choice :format "%[Value Menu%] %v"
67                   :value (file)
68                   (cons :tag "Spool file"
69                         (const :format "" file)
70                         (checklist :tag "Options" :greedy t
71                                    (group :inline t
72                                           (const :format "" :value :path)
73                                           file)))
74                   (cons :tag "Several files in a directory"
75                         (const :format "" directory)
76                         (checklist :tag "Options" :greedy t
77                                    (group :inline t
78                                           (const :format "" :value :path)
79                                           (directory :tag "Path"))
80                                    (group :inline t
81                                           (const :format "" :value :suffix)
82                                           (string :tag "Suffix"))
83                                    (group :inline t
84                                           (const :format "" :value :predicate)
85                                           (function :tag "Predicate"))
86                                    (group :inline t
87                                           (const :format "" :value :prescript)
88                                           (choice :tag "Prescript"
89                                                   :value nil
90                                                   (string :format "%v")
91                                                   (function :format "%v")))
92                                    (group :inline t
93                                           (const :format "" :value :postscript)
94                                           (choice :tag "Postscript"
95                                                   :value nil
96                                                   (string :format "%v")
97                                                   (function :format "%v")))
98                                    (group :inline t
99                                           (const :format "" :value :plugged)
100                                           (boolean :tag "Plugged"))))
101                   (cons :tag "POP3 server"
102                         (const :format "" pop)
103                         (checklist :tag "Options" :greedy t
104                                    (group :inline t
105                                           (const :format "" :value :server)
106                                           (string :tag "Server"))
107                                    (group :inline t
108                                           (const :format "" :value :port)
109                                           (choice :tag "Port"
110                                                   :value "pop3"
111                                                   (integer :format "%v")
112                                                   (string :format "%v")))
113                                    (group :inline t
114                                           (const :format "" :value :user)
115                                           (string :tag "User"))
116                                    (group :inline t
117                                           (const :format "" :value :password)
118                                           (string :tag "Password"))
119                                    (group :inline t
120                                           (const :format "" :value :program)
121                                           (string :tag "Program"))
122                                    (group :inline t
123                                           (const :format "" :value :prescript)
124                                           (choice :tag "Prescript"
125                                                   :value nil
126                                                   (string :format "%v")
127                                                   (function :format "%v")
128                                                   (const :tag "None" nil)))
129                                    (group :inline t
130                                           (const :format "" :value :postscript)
131                                           (choice :tag "Postscript"
132                                                   :value nil
133                                                   (string :format "%v")
134                                                   (function :format "%v")
135                                                   (const :tag "None" nil)))
136                                    (group :inline t
137                                           (const :format "" :value :function)
138                                           (function :tag "Function"))
139                                    (group :inline t
140                                           (const :format ""
141                                                  :value :authentication)
142                                           (choice :tag "Authentication"
143                                                   :value apop
144                                                   (const password)
145                                                   (const apop)))
146                                    (group :inline t
147                                           (const :format "" :value :plugged)
148                                           (boolean :tag "Plugged"))
149                                    (group :inline t
150                                           (const :format "" :value :stream)
151                                           (choice :tag "Stream"
152                                                   :value nil
153                                                   (const :tag "Clear" nil)
154                                                   (const starttls)
155                                                   (const :tag "SSL/TLS" ssl)))))
156                   (cons :tag "Maildir (qmail, postfix...)"
157                         (const :format "" maildir)
158                         (checklist :tag "Options" :greedy t
159                                    (group :inline t
160                                           (const :format "" :value :path)
161                                           (directory :tag "Path"))
162                                    (group :inline t
163                                           (const :format "" :value :plugged)
164                                           (boolean :tag "Plugged"))))
165                   (cons :tag "IMAP server"
166                         (const :format "" imap)
167                         (checklist :tag "Options" :greedy t
168                                    (group :inline t
169                                           (const :format "" :value :server)
170                                           (string :tag "Server"))
171                                    (group :inline t
172                                           (const :format "" :value :port)
173                                           (choice :tag "Port"
174                                                   :value 143
175                                                   integer string))
176                                    (group :inline t
177                                           (const :format "" :value :user)
178                                           (string :tag "User"))
179                                    (group :inline t
180                                           (const :format "" :value :password)
181                                           (string :tag "Password"))
182                                    (group :inline t
183                                           (const :format "" :value :stream)
184                                           (choice :tag "Stream"