From ca75c1c2317f7fb4b89132f1b5e8554c072486c7 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 9 Nov 2012 01:36:53 +0000 Subject: [PATCH] Moved chat room leave presence creation to stanza module --- src/jabber.c | 11 ++--------- src/stanza.c | 6 ++++-- src/stanza.h | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/jabber.c b/src/jabber.c index f54dbb86..7d9528f4 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -246,19 +246,12 @@ void jabber_leave_chat_room(const char * const room_jid) { char *nick = room_get_nick_for_room(room_jid); - GString *full_jid = g_string_new(room_jid); - g_string_append(full_jid, "/"); - g_string_append(full_jid, nick); - xmpp_stanza_t *presence = xmpp_stanza_new(jabber_conn.ctx); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); - xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE); - xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_jid->str); + xmpp_stanza_t *presence = stanza_create_room_leave(jabber_conn.ctx, + room_jid, nick); xmpp_send(jabber_conn.conn, presence); xmpp_stanza_release(presence); - g_string_free(full_jid, TRUE); - room_leave(room_jid); } diff --git a/src/stanza.c b/src/stanza.c index 3530b671..4fc4479a 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -98,7 +98,7 @@ stanza_create_room_presence(xmpp_ctx_t *ctx, const char * const room, return presence; } -/* + xmpp_stanza_t * stanza_create_room_leave(xmpp_ctx_t *ctx, const char * const room, const char * const nick) @@ -110,7 +110,9 @@ stanza_create_room_leave(xmpp_ctx_t *ctx, const char * const room, xmpp_stanza_t *presence = xmpp_stanza_new(ctx); xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE); + xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_jid->str); g_string_free(full_jid, TRUE); + + return presence; } -*/ diff --git a/src/stanza.h b/src/stanza.h index 7da1bcf2..98ca7bd9 100644 --- a/src/stanza.h +++ b/src/stanza.h @@ -77,4 +77,8 @@ xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_room_presence(xmpp_ctx_t *ctx, const char * const room, const char * const nick); + +xmpp_stanza_t* stanza_create_room_leave(xmpp_ctx_t *ctx, + const char * const room, const char * const nick); + #endif