diff options
-rw-r--r-- | src/jabber.c | 21 | ||||
-rw-r--r-- | src/ui.h | 2 | ||||
-rw-r--r-- | src/windows.c | 20 |
3 files changed, 41 insertions, 2 deletions
diff --git a/src/jabber.c b/src/jabber.c index d700255b..648df07b 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -401,8 +401,25 @@ _message_handler(xmpp_conn_t * const conn, from = xmpp_stanza_get_attribute(stanza, "from"); if (room_jid_is_room_chat(from)) { - - + xmpp_stanza_t *delay = xmpp_stanza_get_child_by_name(stanza, "delay"); + if (delay != NULL) { + char *utc_stamp = xmpp_stanza_get_attribute(delay, "stamp"); + GTimeVal tv_stamp; + if(g_time_val_from_iso8601(utc_stamp, &tv_stamp)) { + 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_history(room_jid, nick, tv_stamp, message); + } + } else { + log_error("Couldn't parse datetime string receiving room history: %s", utc_stamp); + } + } else { + // handle normal groupchat messages + } cons_show("CHAT ROOM MESSAGE RECIEVED"); } else { diff --git a/src/ui.h b/src/ui.h index 90326bc6..c5094be3 100644 --- a/src/ui.h +++ b/src/ui.h @@ -107,6 +107,8 @@ void win_join_chat(const char * const room_jid, const char * const nick); void win_show_chat_room_member(const char * const room_jid, const char * const nick); 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); // console window actions void cons_about(void); diff --git a/src/windows.c b/src/windows.c index c5169201..321e10ea 100644 --- a/src/windows.c +++ b/src/windows.c @@ -509,6 +509,26 @@ win_show_chat_room_member(const char * const room_jid, const char * const nick) } void +win_show_room_history(const char * const room_jid, const char * const nick, + GTimeVal tv_stamp, const char * const message) +{ + int win_index = _find_prof_win_index(room_jid); + WINDOW *win = _wins[win_index].win; + + GDateTime *time = g_date_time_new_from_timeval_utc(&tv_stamp); + gchar *date_fmt = g_date_time_format(time, "%H:%M:%S"); + wprintw(win, "%s - ", date_fmt); + g_date_time_unref(time); + g_free(date_fmt); + + wprintw(win, "%s: ", nick); + _win_show_message(win, message); + + if (win_index == _curr_prof_win) + dirty = TRUE; +} + +void win_show(const char * const msg) { WINDOW *win = _wins[_curr_prof_win].win; |