Update of /cvsroot/emacs-jabber/emacs-jabber
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv13427
Modified Files:
jabber-muc.el
Log Message:
Revision: ma...@fr...--2005/emacs-jabber--cvs-head--0--patch-533
Creator: Magnus Henoch <ma...@fr...>
Improve handling of MUC nickname change errors
Index: jabber-muc.el
===================================================================
RCS file: /cvsroot/emacs-jabber/emacs-jabber/jabber-muc.el,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- jabber-muc.el 9 Jun 2008 22:48:02 -0000 1.77
+++ jabber-muc.el 17 Jun 2008 14:48:25 -0000 1.78
@@ -874,32 +874,47 @@
(item (car (jabber-xml-get-children x-muc 'item)))
(actor (jabber-xml-get-attribute (car (jabber-xml-get-children item 'actor)) 'jid))
(reason (car (jabber-xml-node-children (car (jabber-xml-get-children item 'reason)))))
- (status-code (jabber-xml-get-attribute
- (car (jabber-xml-get-children x-muc 'status))
- 'code))
- (error-node (car (jabber-xml-get-children presence 'error))))
+ (error-node (car (jabber-xml-get-children presence 'error)))
+ (status-code (if error-node
+ (jabber-xml-get-attribute error-node 'code)
+ (jabber-xml-get-attribute (car (jabber-xml-get-children x-muc 'status)) 'code))))
+ (message "from: %s, type: %s, status-code: %s, error-node: %s"
+ from type status-code error-node)
;; handle leaving a room
(cond
((or (string= type "unavailable") (string= type "error"))
;; error from room itself? or are we leaving?
(if (or (null nickname)
(string= nickname (gethash (jabber-jid-symbol group) jabber-pending-groupchats)))
- (let ((message (cond
- ((string= type "error")
- (concat "Error entering room"
- (when error-node
- (concat ": " (jabber-parse-error error-node)))))
- ((equal status-code "301")
- (concat "You have been banned"
- (when actor (concat " by " actor))
- (when reason (concat " - '" reason "'"))))
- ((equal status-code "307")
- (concat "You have been kicked"
- (when actor (concat " by " actor))
- (when reason (concat " - '" reason "'"))))
- (t
- "You have left the chatroom"))))
- (jabber-muc-remove-groupchat group)
+ ;; Assume that an error means that we were thrown out of the
+ ;; room...
+ (let* ((leavingp t)
+ (message (cond
+ ((string= type "error")
+ (cond
+ ;; ...except for certain cases.
+ ((or (equal status-code "406")
+ (equal status-code "409"))
+ (setq leavingp nil)
+ (concat "Nickname change not allowed"
+ (when error-node
+ (concat ": " (jabber-parse-error error-node)))))
+ (t
+ (concat "Error entering room"
+ (when error-node
+ (concat ": " (jabber-parse-error error-node)))))))
+ ((equal status-code "301")
+ (concat "You have been banned"
+ (when actor (concat " by " actor))
+ (when reason (concat " - '" reason "'"))))
+ ((equal status-code "307")
+ (concat "You have been kicked"
+ (when actor (concat " by " actor))
+ (when reason (concat " - '" reason "'"))))
+ (t
+ "You have left the chatroom"))))
+ (when leavingp
+ (jabber-muc-remove-groupchat group))
;; If there is no buffer for this groupchat, don't bother
;; creating one just to tell that user left the room.
(let ((buffer (get-buffer (jabber-muc-get-buffer group))))
|