summaryrefslogtreecommitdiff
path: root/limox.c
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-08-16 11:10:50 +0200
committerxengineering <me@xengineering.eu>2022-08-16 11:10:50 +0200
commit94cca91f9c0036a5ceb95ff4099d2cdc3d9265af (patch)
tree7e7d66d85f41e01b021a5ef5a3cf44a7a9c7e691 /limox.c
parent61be2e29d620006ee141ad88165de1819593ff35 (diff)
downloadlimox-94cca91f9c0036a5ceb95ff4099d2cdc3d9265af.tar
limox-94cca91f9c0036a5ceb95ff4099d2cdc3d9265af.tar.zst
limox-94cca91f9c0036a5ceb95ff4099d2cdc3d9265af.zip
Add dummy roster request
Diffstat (limited to 'limox.c')
-rw-r--r--limox.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/limox.c b/limox.c
index b254336..123ca53 100644
--- a/limox.c
+++ b/limox.c
@@ -56,6 +56,24 @@ static int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza,
return 1;
}
+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)) {
+
+ gui_add_roster_item(xmpp_stanza_get_attribute(item, "jid"),
+ xmpp_stanza_get_attribute(item, "subscription"),
+ xmpp_stanza_get_attribute(item, "name"));
+ }
+
+ return 1;
+}
+
static void conn_handler(xmpp_conn_t *conn, xmpp_conn_event_t status,int error,
xmpp_stream_error_t *stream_error, void *userdata) {
@@ -68,12 +86,26 @@ static void conn_handler(xmpp_conn_t *conn, xmpp_conn_event_t status,int error,
xmpp_handler_add(conn, message_handler, NULL, "message", "chat",
NULL);
+ // add handler for roster response
+ xmpp_handler_add(conn, roster_handler, "jabber:iq:roster", "iq",
+ "result", NULL);
+
// send initial presence
xmpp_stanza_t* presence;
presence = xmpp_presence_new(ctx);
xmpp_send(conn, presence);
xmpp_stanza_release(presence);
+ // send roster request
+ xmpp_stanza_t* iq = xmpp_iq_new(ctx, "get", "initial_roster");
+ xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(query, "query");
+ xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
+ xmpp_stanza_add_child(iq, query);
+ xmpp_stanza_release(query);
+ xmpp_send(conn, iq);
+ xmpp_stanza_release(iq);
+
break;
case XMPP_CONN_RAW_CONNECT: