about summary refs log tree commit diff stats
path: root/src/jabber.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jabber.c')
-rw-r--r--src/jabber.c39
1 files changed, 25 insertions, 14 deletions
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;
 }
t'>
13
14
15