about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-26 18:30:34 +0000
committerJames Booth <boothj5@gmail.com>2014-01-26 18:30:34 +0000
commit292ae567aa0766dba4975c02379ec0e4a4ac3ecd (patch)
tree01710c63cc73d269ac47091dca4abb3385a9656c /src/ui
parent46b3ff6f440546a6cc253610b05f3ae957f094e7 (diff)
downloadprofani-tty-292ae567aa0766dba4975c02379ec0e4a4ac3ecd.tar.gz
Handle recipient not found
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c27
-rw-r--r--src/ui/ui.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 43b22f83..cad43e59 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -355,6 +355,32 @@ _ui_handle_error_message(const char * const from, const char * const err_msg)
 }
 
 static void
+_ui_handle_recipient_not_found(const char * const from)
+{
+    ProfWin *win = wins_get_by_recipient(from);
+    GString *msg = g_string_new("");
+
+    // Message sent to chat room which hasn't been entered yet
+    if (win->type == WIN_MUC) {
+        g_string_printf(msg, "You have not joined %s.", from);
+
+    // unknown chat recipient
+    } else {
+        if (prefs_get_boolean(PREF_STATES)) {
+            chat_session_set_recipient_supports(from, FALSE);
+        }
+        g_string_printf(msg, "Recipient %s not found at server.", from);
+    }
+
+    cons_show_error(msg->str);
+    win_print_line(win, '!', COLOUR_ERROR, msg->str);
+
+    wins_refresh_current();
+
+    g_string_free(msg, TRUE);
+}
+
+static void
 _ui_disconnected(void)
 {
     wins_lost_connection();
@@ -1718,4 +1744,5 @@ ui_init_module(void)
     ui_untrust = _ui_untrust;
     ui_chat_win_contact_online = _ui_chat_win_contact_online;
     ui_chat_win_contact_offline = _ui_chat_win_contact_offline;
+    ui_handle_recipient_not_found = _ui_handle_recipient_not_found;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 9671b1af..11ffa765 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -130,6 +130,7 @@ void (*ui_group_added)(const char * const contact, const char * const group);
 void (*ui_group_removed)(const char * const contact, const char * const group);
 void (*ui_chat_win_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity);
 void (*ui_chat_win_contact_offline)(PContact contact, char *resource, char *status);
+void (*ui_handle_recipient_not_found)(const char * const from);
 
 // contact status functions
 void (*ui_status_room)(const char * const contact);