From 6155d4803505c8588a6515bcbd517918cb1f9329 Mon Sep 17 00:00:00 2001 From: ueno Date: Wed, 19 May 2004 05:14:57 +0000 Subject: [PATCH] * riece-400.el (riece-handle-read-string): New function. (riece-handle-432-message): Use it. (riece-handle-433-message): Use it. * riece-server.el (riece-open-server): Don't inhibit quit and catch it when reading server password. --- lisp/ChangeLog | 9 ++++++++ lisp/riece-400.el | 28 +++++++++++++++--------- lisp/riece-server.el | 59 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bd997a4..b15f30d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2004-05-19 Daiki Ueno + + * riece-400.el (riece-handle-read-string): New function. + (riece-handle-432-message): Use it. + (riece-handle-433-message): Use it. + + * riece-server.el (riece-open-server): Don't inhibit quit and + catch it when reading server password. + 2004-05-18 Daiki Ueno * riece-ignore.el (riece-ignore-message-filter): Set the diff --git a/lisp/riece-400.el b/lisp/riece-400.el index 5a45b66..1c302f2 100644 --- a/lisp/riece-400.el +++ b/lisp/riece-400.el @@ -33,21 +33,29 @@ (riece-default-handle-numeric-reply riece-error-prefix prefix number name string)) +(defun riece-handle-read-string (prompt) + (condition-case nil + (let (inhibit-quit) + (read-string prompt)) + (quit))) + (defun riece-handle-432-message (prefix number name string) "ERR_ERRONEUSNICKNAME \" :Erroneous nickname\"." - (riece-send-string - (format "NICK %s\r\n" - (read-string - (format "Erroneous nickname \"%s\". Choose a new one: " - (car (riece-split-parameters string))))))) + (let ((nickname + (riece-handle-read-string + (format "Erroneous nickname \"%s\". Choose a new one: " + (car (riece-split-parameters string)))))) + (if nickname + (riece-send-string (format "NICK %s\r\n" nickname))))) (defun riece-handle-433-message (prefix number name string) "ERR_NICKNAMEINUSE \" :Nickname is already in use\"." - (riece-send-string - (format "NICK %s\r\n" - (read-string - (format "Nickname \"%s\" already in use. Choose a new one: " - (car (riece-split-parameters string))))))) + (let ((nickname + (riece-handle-read-string + (format "Nickname \"%s\" already in use. Choose a new one: " + (car (riece-split-parameters string)))))) + (if nickname + (riece-send-string (format "NICK %s\r\n" nickname))))) (defun riece-handle-464-message (prefix number name string) "ERR_PASSWDMISMATCH \":Password incorrect\"." diff --git a/lisp/riece-server.el b/lisp/riece-server.el index c552180..d49e4d4 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -153,31 +153,42 @@ the `riece-server-keyword-map' variable." (message "Logging in to %s..." server-name)) (if riece-reconnect-with-password ;password incorrect or not set. (unwind-protect - ;; XEmacs signals an error when the keyboard cannot be grabbed. - (condition-case nil - (setq password - (if (equal server-name "") - (riece-read-passwd "Password: ") - (riece-read-passwd (format "Password for %s: " - server-name)))) - (error)) + (setq password + (condition-case nil + (let (inhibit-quit) + (if (equal server-name "") + (riece-read-passwd "Password: ") + (riece-read-passwd (format "Password for %s: " + server-name)))) + (quit + (if (equal server-name "") + (message "Password: Quit") + (message (format "Password for %s: Quit" + server-name))) + 'quit))) (setq riece-reconnect-with-password nil))) - (if password - (riece-process-send-string process - (format "PASS %s\r\n" password))) - (riece-process-send-string process - (format "USER %s * * :%s\r\n" - (user-real-login-name) - (or username - "No information given"))) - (riece-process-send-string process (format "NICK %s\r\n" nickname)) - (with-current-buffer (process-buffer process) - (setq riece-last-nickname riece-real-nickname - riece-nick-accepted 'sent - riece-coding-system coding)) - (setq riece-server-process-alist - (cons (cons server-name process) - riece-server-process-alist))))) + (if (eq password 'quit) + (progn + (riece-close-server-process process) + ;; If no server process is available, exit. + (unless riece-server-process-alist + (riece-exit))) + (if password + (riece-process-send-string process + (format "PASS %s\r\n" password))) + (riece-process-send-string process + (format "USER %s * * :%s\r\n" + (user-real-login-name) + (or username + "No information given"))) + (riece-process-send-string process (format "NICK %s\r\n" nickname)) + (with-current-buffer (process-buffer process) + (setq riece-last-nickname riece-real-nickname + riece-nick-accepted 'sent + riece-coding-system coding)) + (setq riece-server-process-alist + (cons (cons server-name process) + riece-server-process-alist)))))) (defun riece-reset-process-buffer (process) (save-excursion -- 1.7.10.4