about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-04-15 01:08:41 +0100
committerJames Booth <boothj5@gmail.com>2014-04-15 01:08:41 +0100
commitbf185d9907f3dd6e6ec2f5c1b55a40fdccea6b9f (patch)
treeaf42545da1a4132c75abd9720e6d431fbedd70fc
parent40759eddbf2804cf43b9b73004609a92a7ff055c (diff)
downloadprofani-tty-bf185d9907f3dd6e6ec2f5c1b55a40fdccea6b9f.tar.gz
Added simple stanza logging to main console
-rw-r--r--src/server_events.c6
-rw-r--r--src/server_events.h1
-rw-r--r--src/ui/core.c16
-rw-r--r--src/ui/ui.h2
-rw-r--r--src/xmpp/connection.c3
5 files changed, 28 insertions, 0 deletions
diff --git a/src/server_events.c b/src/server_events.c
index 93481b9a..afb29bcd 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -505,3 +505,9 @@ handle_bookmark_autojoin(char *jid)
     ui_room_join(jid, FALSE);
     muc_remove_invite(jid);
 }
+
+void
+handle_xmpp_stanza(const char * const msg)
+{
+    ui_handle_stanza(msg);
+}
diff --git a/src/server_events.h b/src/server_events.h
index ebff2223..ea49e1f1 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -79,5 +79,6 @@ void handle_message_error(const char * const from, const char * const type,
 void handle_presence_error(const char *from, const char * const type,
     const char *err_msg);
 void handle_bookmark_autojoin(char *jid);
+void handle_xmpp_stanza(const char * const msg);
 
 #endif
diff --git a/src/ui/core.c b/src/ui/core.c
index e96d5fff..48999319 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -220,6 +220,21 @@ _ui_duck_exists(void)
 }
 
 static void
+_ui_handle_stanza(const char * const msg)
+{
+    ProfWin *console = wins_get_console();
+    if (g_str_has_prefix(msg, "SENT:")) {
+        win_vprint_line(console, '!', COLOUR_ONLINE, "<- %s", &msg[6]);
+    } else if (g_str_has_prefix(msg, "RECV:")) {
+        win_vprint_line(console, '!', COLOUR_AWAY, "-> %s", &msg[6]);
+    }
+    win_update_virtual(console);
+    if (wins_is_current(console)) {
+        ui_current_page_off();
+    }
+}
+
+static void
 _ui_contact_typing(const char * const barejid)
 {
     ProfWin *window = wins_get_by_recipient(barejid);
@@ -1923,4 +1938,5 @@ ui_init_module(void)
     ui_input_nonblocking = _ui_input_nonblocking;
     ui_replace_input = _ui_replace_input;
     ui_invalid_command_usage = _ui_invalid_command_usage;
+    ui_handle_stanza = _ui_handle_stanza;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index e1cbc28f..43f2d5ed 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -92,6 +92,8 @@ gboolean (*ui_win_exists)(int index);
 int (*ui_win_unread)(int index);
 char * (*ui_ask_password)(void);
 
+void (*ui_handle_stanza)(const char * const msg);
+
 // ui events
 void (*ui_contact_typing)(const char * const from);
 void (*ui_incoming_msg)(const char * const from, const char * const message,
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 3d11fed5..785003e8 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -527,6 +527,9 @@ _xmpp_file_logger(void * const userdata, const xmpp_log_level_t level,
 {
     log_level_t prof_level = _get_log_level(level);
     log_msg(prof_level, area, msg);
+    if ((g_strcmp0(area, "xmpp") == 0) || (g_strcmp0(area, "conn")) == 0) {
+        handle_xmpp_stanza(msg);
+    }
 }
 
 static xmpp_log_t *