From 0023422830d4f593df69b32cb9a214ed1f18ab6d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 5 Nov 2012 22:28:06 +0000 Subject: [PATCH] Handle incoming groupchat --- src/jabber.c | 10 ++++++++-- src/ui.h | 2 ++ src/windows.c | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/jabber.c b/src/jabber.c index 648df07b..14739bc1 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -418,10 +418,16 @@ _message_handler(xmpp_conn_t * const conn, log_error("Couldn't parse datetime string receiving room history: %s", utc_stamp); } } else { - // handle normal groupchat messages + xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body"); + if (body != NULL) { + char *message = xmpp_stanza_get_text(body); + char **tokens = g_strsplit(from, "/", 0); + char *room_jid = tokens[0]; + char *nick = tokens[1]; + win_show_room_message(room_jid, nick, message); + } } - cons_show("CHAT ROOM MESSAGE RECIEVED"); } else { if (type != NULL) { diff --git a/src/ui.h b/src/ui.h index c5094be3..35c8e0b5 100644 --- a/src/ui.h +++ b/src/ui.h @@ -109,6 +109,8 @@ void win_show_chat_room_member(const char * const room_jid, int win_in_groupchat(void); void win_show_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message); +void win_show_room_message(const char * const room_jid, const char * const nick, + const char * const message); // console window actions void cons_about(void); diff --git a/src/windows.c b/src/windows.c index 321e10ea..0eb50860 100644 --- a/src/windows.c +++ b/src/windows.c @@ -528,6 +528,21 @@ win_show_room_history(const char * const room_jid, const char * const nick, dirty = TRUE; } +void +win_show_room_message(const char * const room_jid, const char * const nick, + const char * const message) +{ + int win_index = _find_prof_win_index(room_jid); + WINDOW *win = _wins[win_index].win; + + _win_show_time(win); + _win_show_user(win, nick, 1); + _win_show_message(win, message); + + if (win_index == _curr_prof_win) + dirty = TRUE; +} + void win_show(const char * const msg) {