about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/server_events.c15
-rw-r--r--src/server_events.h3
-rw-r--r--src/ui/core.c34
-rw-r--r--src/ui/ui.h2
-rw-r--r--src/ui/window.c41
-rw-r--r--src/ui/window.h3
-rw-r--r--src/xmpp/presence.c2
7 files changed, 16 insertions, 84 deletions
diff --git a/src/server_events.c b/src/server_events.c
index 724c3d00..b9917f52 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -39,17 +39,26 @@
 
 // handle presence stanza errors
 void
-handle_presence_error(const char *from, const char *err_msg)
+handle_presence_error(const char *from, const char * const type,
+    const char *err_msg)
 {
-    ui_handle_error_message(from, err_msg);
-
+    // handle nickname conflict on entering room
     if (g_strcmp0(err_msg, "conflict") == 0) {
         // remove the room from muc
         Jid *room_jid = jid_create(from);
         if (!muc_get_roster_received(room_jid->barejid)) {
             muc_leave_room(room_jid->barejid);
+            ui_handle_recipient_error(room_jid->barejid, err_msg);
         }
         jid_destroy(room_jid);
+
+    // handle any other error from recipient
+    } else if (from != NULL) {
+        ui_handle_recipient_error(from, err_msg);
+
+    // handle errors from no recipient
+    } else {
+        ui_handle_error(err_msg);
     }
 }
 
diff --git a/src/server_events.h b/src/server_events.h
index 0eab4d2c..95a502ba 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -25,7 +25,6 @@
 
 #include "xmpp/xmpp.h"
 
-void handle_presence_error(const char *from, const char *err_msg);
 void handle_login_account_success(char *account_name);
 void handle_lost_connection(void);
 void handle_failed_login(void);
@@ -77,5 +76,7 @@ void handle_roster_add(const char * const barejid, const char * const name);
 void handle_autoping_cancel(void);
 void handle_message_error(const char * const from, const char * const type,
     const char * const err_msg);
+void handle_presence_error(const char *from, const char * const type,
+    const char *err_msg);
 
 #endif
diff --git a/src/ui/core.c b/src/ui/core.c
index cdac6e8f..80f3c6ac 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -339,22 +339,6 @@ _ui_group_removed(const char * const contact, const char * const group)
 }
 
 static void
-_ui_handle_error_message(const char * const from, const char * const err_msg)
-{
-    if (err_msg == NULL) {
-        cons_show_error("Unknown error received from service.");
-    } else {
-        ProfWin *current = wins_get_current();
-        gboolean handled = win_handle_error_message(current, from, err_msg);
-        if (handled != TRUE) {
-            cons_show_error("Error received from server: %s", err_msg);
-        }
-    }
-
-    ui_print_error_from_recipient(from, err_msg);
-}
-
-static void
 _ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg)
 {
     ProfWin *win = wins_get_by_recipient(recipient);
@@ -390,6 +374,7 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
 static void
 _ui_handle_recipient_error(const char * const recipient, const char * const err_msg)
 {
+    cons_debug("RECIPIENT = %s", recipient);
     ProfWin *win = wins_get_by_recipient(recipient);
     GString *msg = g_string_new("");
     g_string_printf(msg, "Error from %s: %s", recipient, err_msg);
@@ -870,21 +855,6 @@ _ui_current_page_off(void)
 }
 
 static void
-_ui_print_error_from_recipient(const char * const from, const char *err_msg)
-{
-    if (from == NULL || err_msg == NULL)
-        return;
-
-    ProfWin *window = wins_get_by_recipient(from);
-    if (window != NULL) {
-        win_vprint_line(window, '-', COLOUR_ERROR, "%s", err_msg);
-        if (wins_is_current(window)) {
-            wins_refresh_current();
-        }
-    }
-}
-
-static void
 _ui_print_system_msg_from_recipient(const char * const from, const char *message)
 {
     int num = 0;
@@ -1727,7 +1697,6 @@ ui_init_module(void)
     ui_contact_not_in_group = _ui_contact_not_in_group;
     ui_group_added = _ui_group_added;
     ui_group_removed = _ui_group_removed;
-    ui_handle_error_message = _ui_handle_error_message;
     ui_disconnected = _ui_disconnected;
     ui_handle_special_keys = _ui_handle_special_keys;
     ui_close_connected_win = _ui_close_connected_win;
@@ -1750,7 +1719,6 @@ ui_init_module(void)
     ui_current_print_formatted_line = _ui_current_print_formatted_line;
     ui_current_error_line = _ui_current_error_line;
     ui_current_page_off = _ui_current_page_off;
-    ui_print_error_from_recipient = _ui_print_error_from_recipient;
     ui_print_system_msg_from_recipient = _ui_print_system_msg_from_recipient;
     ui_recipient_gone = _ui_recipient_gone;
     ui_new_chat_win = _ui_new_chat_win;
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 9d7ba282..c30bbb12 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -68,9 +68,7 @@ void (*ui_untrust)(const char * const recipient);
 unsigned long (*ui_get_idle_time)(void);
 void (*ui_reset_idle_time)(void);
 void (*ui_new_chat_win)(const char * const to);
-void (*ui_print_error_from_recipient)(const char * const from, const char *err_msg);
 void (*ui_print_system_msg_from_recipient)(const char * const from, const char *message);
-void (*ui_handle_error_message)(const char * const from, const char * const err_msg);
 gint (*ui_unread)(void);
 void (*ui_close_connected_win)(int index);
 int (*ui_close_all_wins)(void);
diff --git a/src/ui/window.c b/src/ui/window.c
index a74479d8..2e2fbf6a 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -38,9 +38,6 @@
 
 static void _win_chat_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
     const char * const from, const char * const message);
-static gboolean
-_muc_handle_error_message(ProfWin *window, const char * const from,
-    const char * const err_msg);
 
 ProfWin*
 win_create(const char * const title, int cols, win_type_t type)
@@ -314,44 +311,6 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
     }
 }
 
-gboolean
-win_handle_error_message(ProfWin *window, const char * const from,
-    const char * const err_msg)
-{
-    gboolean handled = FALSE;
-    switch (window->type)
-    {
-        case WIN_CHAT:
-        case WIN_PRIVATE:
-        case WIN_DUCK:
-        case WIN_CONSOLE:
-            handled =  FALSE;
-            break;
-        case WIN_MUC:
-            handled = _muc_handle_error_message(window, from, err_msg);
-            break;
-        default:
-            assert(FALSE);
-            break;
-    }
-
-    return handled;
-}
-
-static gboolean
-_muc_handle_error_message(ProfWin *window, const char * const from,
-    const char * const err_msg)
-{
-    gboolean handled = FALSE;
-    if (g_strcmp0(err_msg, "conflict") == 0) {
-        win_print_line(window, '-', 0, "Nickname already in use.");
-        win_refresh(window);
-        handled = TRUE;
-    }
-
-    return handled;
-}
-
 static void
 _win_chat_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
     const char * const from, const char * const message)
diff --git a/src/ui/window.h b/src/ui/window.h
index 752787dc..eb92f5e4 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -74,8 +74,5 @@ void win_show_status_string(ProfWin *window, const char * const from,
     const char * const default_show);
 void win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
     const char * const from, const char * const message);
-gboolean
-win_handle_error_message(ProfWin *window, const char * const from,
-    const char * const err_msg);
 
 #endif
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 682a91c3..ae392ad9 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -370,7 +370,7 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
     g_string_free(log_msg, TRUE);
 
-    handle_presence_error(from, err_msg);
+    handle_presence_error(from, type, err_msg);
 
     free(err_msg);