diff --git a/src/command.c b/src/command.c index 563b8fb1..655a3ea7 100644 --- a/src/command.c +++ b/src/command.c @@ -1016,6 +1016,7 @@ _cmd_join(const char * const inp, struct cmd_help_t help) } cons_show("Joining %s as %s", room_jid, nick); + jabber_join(room_jid, nick); } } diff --git a/src/jabber.c b/src/jabber.c index 766c78bf..2df36417 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -279,6 +279,21 @@ jabber_subscribe(const char * const recipient) xmpp_stanza_release(presence); } +void +jabber_join(const char * const room_jid, const char * const nick) +{ + xmpp_stanza_t *presence = xmpp_stanza_new(jabber_conn.ctx); + xmpp_stanza_set_name(presence, "presence"); + + GString *to = g_string_new(room_jid); + g_string_append(to, "/"); + g_string_append(to, nick); + + xmpp_stanza_set_attribute(presence, "to", to->str); + xmpp_send(jabber_conn.conn, presence); + xmpp_stanza_release(presence); +} + void jabber_update_presence(jabber_presence_t status, const char * const msg) { diff --git a/src/jabber.h b/src/jabber.h index 3ae84610..8dacb2f8 100644 --- a/src/jabber.h +++ b/src/jabber.h @@ -46,6 +46,7 @@ jabber_conn_status_t jabber_connect(const char * const user, void jabber_disconnect(void); void jabber_process_events(void); void jabber_subscribe(const char * const recipient); +void jabber_join(const char * const room_jid, const char * const nick); void jabber_send(const char * const msg, const char * const recipient); void jabber_send_inactive(const char * const recipient); void jabber_send_composing(const char * const recipient);