+2004-05-19 Daiki Ueno <ueno@unixuser.org>
+
+ * 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 <ueno@unixuser.org>
* riece-ignore.el (riece-ignore-message-filter): Set the
(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 \"<nick> :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 \"<nick> :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\"."
(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