about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-10 02:28:38 +0000
committerJames Booth <boothj5@gmail.com>2012-11-10 02:28:38 +0000
commit7799623b4a26e2005b7a3a8db82265df7a7e35ca (patch)
treea90841829d47b91ebd917797f66129cc5b6ed9fe /src
parenta5082a54bdf94b46e6364e3c149cf673cc76807f (diff)
downloadprofani-tty-7799623b4a26e2005b7a3a8db82265df7a7e35ca.tar.gz
Show error text if received
Diffstat (limited to 'src')
-rw-r--r--src/command.c1
-rw-r--r--src/jabber.c39
-rw-r--r--src/profanity.c1
-rw-r--r--src/stanza.h1
4 files changed, 27 insertions, 15 deletions
diff --git a/src/command.c b/src/command.c
index d9536411..b91a1180 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1093,6 +1093,7 @@ _cmd_close(const char * const inp, struct cmd_help_t help)
     if (win_in_groupchat()) {
         char *room_jid = win_get_recipient();
         jabber_leave_chat_room(room_jid);
+        win_close_win();
     } else if (win_in_chat()) {
 
         if (prefs_get_states()) {
diff --git a/src/jabber.c b/src/jabber.c
index b1b8afd2..7e62a5a8 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -389,27 +389,38 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
 static int
 _error_handler(xmpp_stanza_t * const stanza)
 {
-    char *err_msg = NULL;
-    xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    gchar *err_msg = NULL;
+    gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+        xmpp_stanza_t *text_stanza =
+            xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
 
-    if (error == NULL) {
+    if (error_stanza == NULL) {
         log_debug("error message without <error/> received");
-        return 1;
     } else {
-        xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error);
 
-        if (err_cond == NULL) {
-            log_debug("error message without <defined-condition/> received");
-            return 1;
+        // check for text
+        if (text_stanza != NULL) {
+            err_msg = xmpp_stanza_get_text(text_stanza);
+            prof_handle_error_message(from, err_msg);
+
+            // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
+
+        // otherwise show defined-condition
         } else {
-            err_msg = xmpp_stanza_get_name(err_cond);
-        }
+            xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error_stanza);
 
-        // TODO: process 'type' attribute from <error/> [RFC6120, 8.3.2]
-    }
+            if (err_cond == NULL) {
+                log_debug("error message without <defined-condition/> or <text/> received");
 
-    gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
-    prof_handle_error_message(from, err_msg);
+            } else {
+                err_msg = xmpp_stanza_get_name(err_cond);
+                prof_handle_error_message(from, err_msg);
+
+                // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
+            }
+        }
+    }
 
     return 1;
 }
diff --git a/src/profanity.c b/src/profanity.c
index 4e99e25a..f7df4f03 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -229,7 +229,6 @@ void
 prof_handle_leave_room(const char * const room)
 {
     room_leave(room);
-    win_close_win();
 }
 
 void
diff --git a/src/stanza.h b/src/stanza.h
index 93f1c057..5acb6aee 100644
--- a/src/stanza.h
+++ b/src/stanza.h
@@ -42,6 +42,7 @@
 #define STANZA_NAME_DELAY "delay"
 #define STANZA_NAME_ERROR "error"
 #define STANZA_NAME_PING "ping"
+#define STANZA_NAME_TEXT "text"
 
 #define STANZA_TYPE_CHAT "chat"
 #define STANZA_TYPE_GROUPCHAT "groupchat"