1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Moved room join stanza creation

This commit is contained in:
James Booth 2012-11-09 01:04:32 +00:00
parent d2497b2e92
commit 187ea6e8b8
3 changed files with 26 additions and 14 deletions

View File

@ -234,20 +234,8 @@ jabber_subscribe(const char * const recipient)
void
jabber_join(const char * const room_jid, const char * const nick)
{
GString *to = g_string_new(room_jid);
g_string_append(to, "/");
g_string_append(to, nick);
xmpp_stanza_t *presence = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, to->str);
xmpp_stanza_t *x = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X);
xmpp_stanza_set_ns(x, STANZA_NS_MUC);
xmpp_stanza_add_child(presence, x);
xmpp_stanza_t *presence = stanza_create_room_presence(jabber_conn.ctx,
room_jid, nick);
xmpp_send(jabber_conn.conn, presence);
xmpp_stanza_release(presence);

View File

@ -78,3 +78,24 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
return msg;
}
xmpp_stanza_t *
stanza_create_room_presence(xmpp_ctx_t *ctx, const char * const room,
const char * const nick)
{
GString *to = g_string_new(room);
g_string_append(to, "/");
g_string_append(to, nick);
xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, to->str);
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X);
xmpp_stanza_set_ns(x, STANZA_NS_MUC);
xmpp_stanza_add_child(presence, x);
return presence;
}

View File

@ -74,4 +74,7 @@ xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx,
const char * const recipient, const char * const type,
const char * const message, const char * const state);
xmpp_stanza_t* stanza_create_room_presence(xmpp_ctx_t *ctx,
const char * const room, const char * const nick);
#endif