From 43aa02ccbd484d8c7cecec7c38c446847b34e007 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 19 Aug 2022 10:51:24 +0200 Subject: Implement new datastructures --- limox.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'limox.c') diff --git a/limox.c b/limox.c index 5bdaa7b..6c84971 100644 --- a/limox.c +++ b/limox.c @@ -40,19 +40,16 @@ static xmpp_sm_state_t* sm_state; static int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata) { - // local variables - xmpp_stanza_t* body; - const char* content; - - body = xmpp_stanza_get_child_by_name(stanza, "body"); + xmpp_stanza_t* body = xmpp_stanza_get_child_by_name(stanza, "body"); if (body == NULL) { printf("DEBUG: Got message stanza of type char without body!\n"); return 1; } - content = xmpp_stanza_get_text(body); + const char* content = xmpp_stanza_get_text(body); + const char* sender = xmpp_stanza_get_from(stanza); - gui_add_message(xmpp_stanza_get_from(stanza), content); + data_add_incoming_message(sender, content); return 1; } @@ -60,16 +57,14 @@ static int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, static int roster_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata) { - printf("DEBUG: Received roster.\n"); - // iterate over roster result xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, "query"); for (xmpp_stanza_t* item = xmpp_stanza_get_children(query); item; item = xmpp_stanza_get_next(item)) { - add_roster_item(xmpp_stanza_get_attribute(item, "jid"), - xmpp_stanza_get_attribute(item, "subscription"), - xmpp_stanza_get_attribute(item, "name")); + data_add_roster_item(xmpp_stanza_get_attribute(item, "jid"), + xmpp_stanza_get_attribute(item, "subscription"), + xmpp_stanza_get_attribute(item, "name")); } return 1; -- cgit v1.2.3-70-g09d2