aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/gnus/auth-source.el
diff options
context:
space:
mode:
authorMiles Bader2008-04-26 04:29:42 +0000
committerMiles Bader2008-04-26 04:29:42 +0000
commit58a67d68bfc2eafe0cd029aa33693228f21f4e51 (patch)
tree009923ba472fb824796a3cd59f91925c17ee8c5b /lisp/gnus/auth-source.el
parent1ea193a2b6414ac6186de0840e5b734c7d82a810 (diff)
downloademacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.tar.gz
emacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.zip
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1128
Diffstat (limited to 'lisp/gnus/auth-source.el')
-rw-r--r--lisp/gnus/auth-source.el45
1 files changed, 18 insertions, 27 deletions
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 9883eb64acc..a2a4dcf24cc 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -86,11 +86,6 @@ Each entry is the authentication type with optional properties."
86 (list :tag "Source definition" 86 (list :tag "Source definition"
87 (const :format "" :value :source) 87 (const :format "" :value :source)
88 (string :tag "Authentication Source") 88 (string :tag "Authentication Source")
89 (const :format "" :value :server)
90 (choice :tag "Server (logical name) choice"
91 (const :tag "Any" t)
92 (regexp :tag "Server regular expression (TODO)")
93 (const :tag "Fallback" nil))
94 (const :format "" :value :host) 89 (const :format "" :value :host)
95 (choice :tag "Host (machine) choice" 90 (choice :tag "Host (machine) choice"
96 (const :tag "Any" t) 91 (const :tag "Any" t)
@@ -118,20 +113,16 @@ Each entry is the authentication type with optional properties."
118;; (auth-source-user-or-password-imap "password" "imap.myhost.com") 113;; (auth-source-user-or-password-imap "password" "imap.myhost.com")
119;; (auth-source-protocol-defaults 'imap) 114;; (auth-source-protocol-defaults 'imap)
120 115
121(defun auth-source-pick (server host protocol &optional fallback) 116(defun auth-source-pick (host protocol &optional fallback)
122 "Parse `auth-sources' for SERVER, HOST, and PROTOCOL matches. 117 "Parse `auth-sources' for HOST, and PROTOCOL matches.
123 118
124Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK t." 119Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
125 (interactive "sHost: \nsProtocol: \n") ;for testing 120 (interactive "sHost: \nsProtocol: \n") ;for testing
126 (let (choices) 121 (let (choices)
127 (dolist (choice auth-sources) 122 (dolist (choice auth-sources)
128 (let ((s (plist-get choice :server)) 123 (let ((h (plist-get choice :host))
129 (h (plist-get choice :host))
130 (p (plist-get choice :protocol))) 124 (p (plist-get choice :protocol)))
131 (when (and 125 (when (and
132 (or (equal t s)
133 (and (stringp s) (string-match s server))
134 (and fallback (equal s nil)))
135 (or (equal t h) 126 (or (equal t h)
136 (and (stringp h) (string-match h host)) 127 (and (stringp h) (string-match h host))
137 (and fallback (equal h nil))) 128 (and fallback (equal h nil)))
@@ -142,12 +133,12 @@ Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK
142 (if choices 133 (if choices
143 choices 134 choices
144 (unless fallback 135 (unless fallback
145 (auth-source-pick server host protocol t))))) 136 (auth-source-pick host protocol t)))))
146 137
147(defun auth-source-user-or-password (mode server host protocol) 138(defun auth-source-user-or-password (mode host protocol)
148 "Find user or password (from the string MODE) matching SERVER, HOST, and PROTOCOL." 139 "Find user or password (from the string MODE) matching HOST and PROTOCOL."
149 (let (found) 140 (let (found)
150 (dolist (choice (auth-source-pick server host protocol)) 141 (dolist (choice (auth-source-pick host protocol))
151 (setq found (netrc-machine-user-or-password 142 (setq found (netrc-machine-user-or-password
152 mode 143 mode
153 (plist-get choice :source) 144 (plist-get choice :source)
@@ -161,20 +152,20 @@ Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK
161 "Return a list of default ports and names for PROTOCOL." 152 "Return a list of default ports and names for PROTOCOL."
162 (cdr-safe (assoc protocol auth-source-protocols))) 153 (cdr-safe (assoc protocol auth-source-protocols)))
163 154
164(defun auth-source-user-or-password-imap (mode server host) 155(defun auth-source-user-or-password-imap (mode host)
165 (auth-source-user-or-password mode server host 'imap)) 156 (auth-source-user-or-password mode host 'imap))
166 157
167(defun auth-source-user-or-password-pop3 (mode server host) 158(defun auth-source-user-or-password-pop3 (mode host)
168 (auth-source-user-or-password mode server host 'pop3)) 159 (auth-source-user-or-password mode host 'pop3))
169 160
170(defun auth-source-user-or-password-ssh (mode server host) 161(defun auth-source-user-or-password-ssh (mode host)
171 (auth-source-user-or-password mode server host 'ssh)) 162 (auth-source-user-or-password mode host 'ssh))
172 163
173(defun auth-source-user-or-password-sftp (mode server host) 164(defun auth-source-user-or-password-sftp (mode host)
174 (auth-source-user-or-password mode server host 'sftp)) 165 (auth-source-user-or-password mode host 'sftp))
175 166
176(defun auth-source-user-or-password-smtp (mode server host) 167(defun auth-source-user-or-password-smtp (mode host)
177 (auth-source-user-or-password mode server host 'smtp)) 168 (auth-source-user-or-password mode host 'smtp))
178 169
179(provide 'auth-source) 170(provide 'auth-source)
180 171