about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-27 22:09:16 +0000
committerJames Booth <boothj5@gmail.com>2014-01-27 22:09:16 +0000
commit27293ebbc2171f52d6db6d0075b63db8fcacc0be (patch)
tree0cbcdf0b79c3345cc2f1f4406a242983bbec5934 /src/xmpp
parent678a5bd05c465e059c17fc94329a9a6620254950 (diff)
downloadprofani-tty-27293ebbc2171f52d6db6d0075b63db8fcacc0be.tar.gz
Added fallback message error handlers
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 57699e31..6f340b2d 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -193,9 +193,10 @@ static int
 _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     void * const userdata)
 {
-    // log message, function never returns NULL
     char *id = xmpp_stanza_get_id(stanza);
     char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+
+    // stanza_get_error never returns NULL
     char *err_msg = stanza_get_error_message(stanza);
 
     GString *log_msg = g_string_new("Error receievd");
@@ -211,7 +212,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     }
     g_string_append(log_msg, ", error: ");
     g_string_append(log_msg, err_msg);
-    
+
     log_info(log_msg->str);
 
     g_string_free(log_msg, TRUE);
@@ -225,6 +226,14 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     // handle recipient not found ('from' contains a value and type is 'cancel')
     if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) {
         handle_recipient_not_found(from, err_msg);
+
+    // handle any other error from recipient
+    } else if (from != NULL) {
+        handle_recipient_error(from, err_msg);
+
+    // handle errors from no recipient
+    } else {
+        handle_error(err_msg);
     }
 
     return 1;