about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-28 22:37:50 +0000
committerJames Booth <boothj5@gmail.com>2014-01-28 22:37:50 +0000
commit5afb296e67785725e4462358fcc227e5f28b1a46 (patch)
treeb6aa5b3d87369a9680df51a6f09037d22a3a9faf /src
parentb231133f9b07e76eb7c3d6df4f01ceb14bcc3cd5 (diff)
downloadprofani-tty-5afb296e67785725e4462358fcc227e5f28b1a46.tar.gz
Moved error handling logic to server_events
Diffstat (limited to 'src')
-rw-r--r--src/server_events.c32
-rw-r--r--src/server_events.h5
-rw-r--r--src/xmpp/message.c13
3 files changed, 20 insertions, 30 deletions
diff --git a/src/server_events.c b/src/server_events.c
index e9dd7997..1e99383c 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -37,6 +37,7 @@
 #include "otr.h"
 #endif
 
+// TODO - replace with stanza error handlers
 void
 handle_error_message(const char *from, const char *err_msg)
 {
@@ -52,25 +53,26 @@ handle_error_message(const char *from, const char *err_msg)
     }
 }
 
+// handle message stanza errors
 void
-handle_recipient_not_found(const char * const recipient, const char * const err_msg)
+handle_message_error(const char * const from, const char * const type,
+    const char * const err_msg)
 {
-    ui_handle_recipient_not_found(recipient, err_msg);
-    if (prefs_get_boolean(PREF_STATES) && chat_session_exists(recipient)) {
-        chat_session_set_recipient_supports(recipient, FALSE);
-    }
-}
+    // handle recipient not found ('from' contains a value and type is 'cancel')
+    if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) {
+        ui_handle_recipient_not_found(from, err_msg);
+        if (prefs_get_boolean(PREF_STATES) && chat_session_exists(from)) {
+            chat_session_set_recipient_supports(from, FALSE);
+        }
 
-void
-handle_recipient_error(const char * const recipient, const char * const err_msg)
-{
-    ui_handle_recipient_error(recipient, err_msg);
-}
+    // handle any other error from recipient
+    } else if (from != NULL) {
+        ui_handle_recipient_error(from, err_msg);
 
-void
-handle_error(const char * const err_msg)
-{
-    ui_handle_error(err_msg);
+    // handle errors from no recipient
+    } else {
+        ui_handle_error(err_msg);
+    }
 }
 
 void
diff --git a/src/server_events.h b/src/server_events.h
index ab2e29fd..a0ea6d13 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -75,8 +75,7 @@ void handle_group_remove(const char * const contact,
 void handle_roster_remove(const char * const barejid);
 void handle_roster_add(const char * const barejid, const char * const name);
 void handle_autoping_cancel(void);
-void handle_recipient_not_found(const char * const recipient, const char * const err_msg);
-void handle_recipient_error(const char * const recipient, const char * const err_msg);
-void handle_error(const char * const err_msg);
+void handle_message_error(const char * const from, const char * const type,
+    const char * const err_msg);
 
 #endif
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 5ea54f2d..5a7e9075 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -224,18 +224,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
     g_string_free(log_msg, TRUE);
 
-    // 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);
-    }
+    handle_message_error(from, type, err_msg);
 
     free(err_msg);