about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-10-06 00:05:23 +0100
committerJames Booth <boothj5@gmail.com>2013-10-06 00:05:23 +0100
commit710c49b6b87e71c1b6c06cd6920f9b94414bdc4f (patch)
tree872fbdf20dd47e6618eaeeadb54be44c3d130425 /src
parent738be65edc17d44a3305866a4a19b8729c133e5b (diff)
downloadprofani-tty-710c49b6b87e71c1b6c06cd6920f9b94414bdc4f.tar.gz
Moved UI error handler code to ui/core
Diffstat (limited to 'src')
-rw-r--r--src/profanity.c22
-rw-r--r--src/ui/core.c26
-rw-r--r--src/ui/ui.h1
3 files changed, 28 insertions, 21 deletions
diff --git a/src/profanity.c b/src/profanity.c
index 48f8a3f5..c2de40a4 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -187,27 +187,7 @@ prof_handle_group_remove(const char * const contact,
 void
 prof_handle_error_message(const char *from, const char *err_msg)
 {
-    win_type_t win_type = ui_current_win_type();
-    if (err_msg == NULL) {
-        cons_show_error("Unknown error received from service.");
-    } else if (strcmp(err_msg, "conflict") == 0) {
-        if (win_type == WIN_MUC) {
-            ui_current_print_line("Nickname already in use.");
-        } else {
-            cons_show_error("Error received from server: %s", err_msg);
-        }
-        // 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);
-        }
-        jid_destroy(room_jid);
-
-    } else {
-        cons_show_error("Error received from server: %s", err_msg);
-    }
-
-    ui_print_error_from_recipient(from, err_msg);
+    ui_handle_error_message(from, err_msg);
 }
 
 void
diff --git a/src/ui/core.c b/src/ui/core.c
index 5502f972..be1afd03 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -403,6 +403,32 @@ ui_group_removed(const char * const contact, const char * const group)
 }
 
 void
+ui_handle_error_message(const char * const from, const char * const err_msg)
+{
+    win_type_t win_type = ui_current_win_type();
+    if (err_msg == NULL) {
+        cons_show_error("Unknown error received from service.");
+    } else if (strcmp(err_msg, "conflict") == 0) {
+        if (win_type == WIN_MUC) {
+            ui_current_print_line("Nickname already in use.");
+        } else {
+            cons_show_error("Error received from server: %s", err_msg);
+        }
+        // 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);
+        }
+        jid_destroy(room_jid);
+
+    } else {
+        cons_show_error("Error received from server: %s", err_msg);
+    }
+
+    ui_print_error_from_recipient(from, err_msg);
+}
+
+void
 ui_contact_online(const char * const barejid, const char * const resource,
     const char * const show, const char * const status, GDateTime *last_activity)
 {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 4d4ead7b..7fff0703 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -59,6 +59,7 @@ 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);