From bf185d9907f3dd6e6ec2f5c1b55a40fdccea6b9f Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 15 Apr 2014 01:08:41 +0100 Subject: [PATCH] Added simple stanza logging to main console --- src/server_events.c | 6 ++++++ src/server_events.h | 1 + src/ui/core.c | 16 ++++++++++++++++ src/ui/ui.h | 2 ++ src/xmpp/connection.c | 3 +++ 5 files changed, 28 insertions(+) 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 @@ -219,6 +219,21 @@ _ui_duck_exists(void) return wins_duck_exists(); } +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) { @@ -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 *