Mercurial > emacs
comparison lisp/mail/rmail.el @ 22838:4b3e0d38cdb0
(rmail-insert-inbox-text): Use rmail-have-password,
rmail-get-pop-password and rmail-set-pop-password.
(rmail-have-password, rmail-get-pop-password)
(rmail-set-pop-password): New functions.
(rmail-encode-string): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 27 Jul 1998 08:35:47 +0000 |
parents | 3408cd75e193 |
children | be572a467b59 |
comparison
equal
deleted
inserted
replaced
22837:ab58591421a8 | 22838:4b3e0d38cdb0 |
---|---|
1277 ;; Detect a locked file now, so that we avoid moving mail | 1277 ;; Detect a locked file now, so that we avoid moving mail |
1278 ;; out of the real inbox file. (That could scare people.) | 1278 ;; out of the real inbox file. (That could scare people.) |
1279 (or (memq (file-locked-p buffer-file-name) '(nil t)) | 1279 (or (memq (file-locked-p buffer-file-name) '(nil t)) |
1280 (error "RMAIL file %s is locked" | 1280 (error "RMAIL file %s is locked" |
1281 (file-name-nondirectory buffer-file-name))) | 1281 (file-name-nondirectory buffer-file-name))) |
1282 (let (file tofile delete-files movemail popmail got-password) | 1282 (let (file tofile delete-files movemail popmail got-password password) |
1283 (while files | 1283 (while files |
1284 (setq file (file-truename | 1284 (setq file (file-truename |
1285 (expand-file-name (substitute-in-file-name (car files)))) | 1285 (expand-file-name (substitute-in-file-name (car files)))) |
1286 tofile (expand-file-name | 1286 tofile (expand-file-name |
1287 ;; Generate name to move to from inbox name, | 1287 ;; Generate name to move to from inbox name, |
1312 ;; and the actual inbox is /usr/spool/mail/foo/foo. | 1312 ;; and the actual inbox is /usr/spool/mail/foo/foo. |
1313 (if (file-directory-p file) | 1313 (if (file-directory-p file) |
1314 (setq file (expand-file-name (user-login-name) | 1314 (setq file (expand-file-name (user-login-name) |
1315 file))))) | 1315 file))))) |
1316 (cond (popmail | 1316 (cond (popmail |
1317 (if (and rmail-pop-password-required (not rmail-pop-password)) | 1317 (if rmail-pop-password-required |
1318 (setq rmail-pop-password | 1318 (progn (setq got-password (not (rmail-have-password))) |
1319 (rmail-read-passwd | 1319 (setq password (rmail-get-pop-password)))) |
1320 (format "Password for %s: " | |
1321 (substring file (+ popmail 3)))) | |
1322 got-password t)) | |
1323 (if (eq system-type 'windows-nt) | 1320 (if (eq system-type 'windows-nt) |
1324 ;; cannot have "po:" in file name | 1321 ;; cannot have "po:" in file name |
1325 (setq tofile | 1322 (setq tofile |
1326 (expand-file-name | 1323 (expand-file-name |
1327 (concat ".newmail-pop-" (substring file (+ popmail 3))) | 1324 (concat ".newmail-pop-" (substring file (+ popmail 3))) |
1373 (if rmail-preserve-inbox | 1370 (if rmail-preserve-inbox |
1374 (list "-p") | 1371 (list "-p") |
1375 nil) | 1372 nil) |
1376 rmail-movemail-flags | 1373 rmail-movemail-flags |
1377 (list file tofile) | 1374 (list file tofile) |
1378 (if rmail-pop-password | 1375 (if password (list password) nil)))) |
1379 (list rmail-pop-password) | |
1380 nil)))) | |
1381 (apply 'call-process args)) | 1376 (apply 'call-process args)) |
1382 (if (not (buffer-modified-p errors)) | 1377 (if (not (buffer-modified-p errors)) |
1383 ;; No output => movemail won | 1378 ;; No output => movemail won |
1384 nil | 1379 nil |
1385 (set-buffer errors) | 1380 (set-buffer errors) |
1399 ;; wrong. Otherwise, see if there is a specific | 1394 ;; wrong. Otherwise, see if there is a specific |
1400 ;; reason to think that the problem is a wrong passwd. | 1395 ;; reason to think that the problem is a wrong passwd. |
1401 (if (or got-password | 1396 (if (or got-password |
1402 (re-search-forward rmail-pop-password-error | 1397 (re-search-forward rmail-pop-password-error |
1403 nil t)) | 1398 nil t)) |
1404 (setq rmail-pop-password nil)) | 1399 (rmail-set-pop-password nil)) |
1405 (sit-for 3) | 1400 (sit-for 3) |
1406 nil)) | 1401 nil)) |
1407 (if errors (kill-buffer errors)))))) | 1402 (if errors (kill-buffer errors)))))) |
1408 ;; At this point, TOFILE contains the name to read: | 1403 ;; At this point, TOFILE contains the name to read: |
1409 ;; Either the alternate name (if we renamed) | 1404 ;; Either the alternate name (if we renamed) |
3276 TEXT and INDENT are not used." | 3271 TEXT and INDENT are not used." |
3277 (speedbar-with-attached-buffer | 3272 (speedbar-with-attached-buffer |
3278 (message "Moving message to %s" token) | 3273 (message "Moving message to %s" token) |
3279 (rmail-output-to-rmail-file token))) | 3274 (rmail-output-to-rmail-file token))) |
3280 | 3275 |
3276 ; Functions for setting, getting and encoding the POP password. | |
3277 ; The password is encoded to prevent it from being easily accessible | |
3278 ; to "prying eyes." Obviously, this encoding isn't "real security," | |
3279 ; nor is it meant to be. | |
3280 | |
3281 ;;;###autoload | |
3282 (defun rmail-set-pop-password (password) | |
3283 "Set PASSWORD to be used for retrieving mail from a POP server." | |
3284 (interactive "sPassword: ") | |
3285 (if password | |
3286 (setq rmail-encoded-pop-password | |
3287 (rmail-encode-string password (emacs-pid))) | |
3288 (setq rmail-pop-password nil) | |
3289 (setq rmail-encoded-pop-password nil))) | |
3290 | |
3291 (defun rmail-get-pop-password () | |
3292 "Get the password for retrieving mail from a POP server. If none | |
3293 has been set, then prompt the user for one." | |
3294 (if (not rmail-encoded-pop-password) | |
3295 (progn (if (not rmail-pop-password) | |
3296 (setq rmail-pop-password (rmail-read-passwd "POP password: "))) | |
3297 (rmail-set-pop-password rmail-pop-password) | |
3298 (setq rmail-pop-password nil))) | |
3299 (rmail-encode-string rmail-encoded-pop-password (emacs-pid))) | |
3300 | |
3301 (defun rmail-have-password () | |
3302 (or rmail-pop-password rmail-encoded-pop-password)) | |
3303 | |
3304 (defun rmail-encode-string (string mask) | |
3305 "Encode STRING with integer MASK, by taking the exclusive OR of the | |
3306 lowest byte in the mask with the first character of string, the | |
3307 second-lowest-byte with the second character of the string, etc., | |
3308 restarting at the lowest byte of the mask whenever it runs out. | |
3309 Returns the encoded string. Calling the function again with an | |
3310 encoded string (and the same mask) will decode the string." | |
3311 (let* ((string-vector (string-to-vector string)) (i 0) | |
3312 (len (length string-vector)) (curmask mask) charmask) | |
3313 (while (< i len) | |
3314 (if (= curmask 0) | |
3315 (setq curmask mask)) | |
3316 (setq charmask (% curmask 256)) | |
3317 (setq curmask (lsh curmask -8)) | |
3318 (aset string-vector i (logxor charmask (aref string-vector i))) | |
3319 (setq i (1+ i))) | |
3320 (concat string-vector))) | |
3281 | 3321 |
3282 (provide 'rmail) | 3322 (provide 'rmail) |
3283 | 3323 |
3284 ;;; rmail.el ends here | 3324 ;;; rmail.el ends here |