1 ;; read-passwd.el.el --- Read password function for Pterodactyl Gnus.
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc. , Tatsuya Ichikawa
3 ;; Author: Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
5 ;; Keywords: mail , gnus , pop3 , password
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; This file is part of Semi-gnus.
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)
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.
28 (require 'mail-source)
29 (provide 'read-passwd)
31 (defun read-pw-read-passwd (prompt)
32 (read-pw-read-noecho prompt t))
34 (defmacro read-pw-read-char-exclusive ()
35 (cond ((featurep 'xemacs)
36 '(let ((table (quote ((backspace . ?\C-h) (delete . ?\C-?)
41 (key-press-event-p (setq event (next-command-event)))
42 (setq key (or (event-to-character event)
43 (cdr (assq (event-key event) table)))))))
45 ((fboundp 'read-char-exclusive)
46 '(read-char-exclusive))
50 (defun read-pw-read-noecho (prompt &optional stars)
51 "Read a single line of text from user without echoing, and return it.
56 (cursor-in-echo-area t)
57 (log-message-max-size 0)
58 message-log-max done msg truncate)
60 (if (or (not stars) (string-equal "" ans))
62 (setq msg (concat prompt (make-string (length ans) ?*)))
64 (1+ (- (length msg) (window-width (minibuffer-window)))))
66 (setq msg (concat "$" (substring msg (1+ truncate))))))
68 (setq c (read-pw-read-char-exclusive))
72 ((memq c '(?\r ?\n ?\e))
76 ((and (/= ?\b c) (/= ?\177 c))
77 (setq ans (concat ans (char-to-string c))))
79 (setq ans (substring ans 0 -1)))))
89 (defun read-pw-set-mail-source-passwd-cache ()
90 (if (not mail-source-password-cache)
93 (when (eq 'pop (car x))
94 (mail-source-bind (pop x)
95 (let ((from (format "%s:%s:%s" server user port))
97 (format "pop:%s@%s" user server)))
98 (setq pw (read-pw-return-passwd-string user server))
99 (unless (assoc user mail-source-password-cache)
100 (set-alist 'mail-source-password-cache
101 (format "%s:%s:%s" server user port)
103 (cdr (assoc from mail-source-password-cache))))))
108 (defun read-pw-return-passwd-string (user server)
109 (setq passwd (read-pw-read-passwd
110 (message "POP Password for %s at %s : " user server)))
113 ;; read-passwd.el ends here.