From 09c10f62f20bafc599c12038170383853e4dc52e Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 3 Sep 2014 13:55:06 +0100 Subject: Send instant room request --- src/xmpp/iq.c | 11 +++++++++++ src/xmpp/stanza.c | 29 +++++++++++++++++++++++++++++ src/xmpp/stanza.h | 3 +++ src/xmpp/xmpp.h | 1 + 4 files changed, 44 insertions(+) (limited to 'src/xmpp') diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 96c94cd3..d03e635c 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -158,6 +158,16 @@ _iq_send_software_version(const char * const fulljid) xmpp_stanza_release(iq); } +static void +_iq_create_instant_room(const char * const room_jid) +{ + xmpp_conn_t * const conn = connection_get_conn(); + xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_stanza_t *iq = stanza_create_instant_room_request_iq(ctx, room_jid); + xmpp_send(conn, iq); + xmpp_stanza_release(iq); +} + static int _error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) @@ -667,4 +677,5 @@ iq_init_module(void) iq_disco_items_request = _iq_disco_items_request; iq_send_software_version = _iq_send_software_version; iq_set_autoping = _iq_set_autoping; + iq_create_instant_room = _iq_create_instant_room; } diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 6d3dcc54..ac8f0dc1 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -423,6 +423,35 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char * const room, return presence; } +xmpp_stanza_t * +stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char * const room_jid) +{ + xmpp_stanza_t *iq = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(iq, STANZA_NAME_IQ); + xmpp_stanza_set_type(iq, STANZA_TYPE_SET); + xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid); + char *id = create_unique_id("leave"); + xmpp_stanza_set_id(iq, id); + free(id); + + xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(query, STANZA_NAME_QUERY); + xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); + + xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(x, STANZA_NAME_X); + xmpp_stanza_set_type(x, "submit"); + xmpp_stanza_set_ns(x, STANZA_NS_DATA); + + xmpp_stanza_add_child(query, x); + xmpp_stanza_release(x); + + xmpp_stanza_add_child(iq, query); + xmpp_stanza_release(query); + + return iq; +} + xmpp_stanza_t * stanza_create_presence(xmpp_ctx_t * const ctx) { diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 93b584f5..7afea8e5 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -141,6 +141,7 @@ #define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates" #define STANZA_NS_MUC "http://jabber.org/protocol/muc" #define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user" +#define STANZA_NS_MUC_OWNER "http://jabber.org/protocol/muc#owner" #define STANZA_NS_CAPS "http://jabber.org/protocol/caps" #define STANZA_NS_PING "urn:xmpp:ping" #define STANZA_NS_LASTACTIVITY "jabber:iq:last" @@ -201,6 +202,8 @@ gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza); gboolean stanza_muc_requires_config(xmpp_stanza_t * const stanza); char * stanza_get_new_nick(xmpp_stanza_t * const stanza); +xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, + const char * const room_jid); int stanza_get_idle_time(xmpp_stanza_t * const stanza); char * stanza_get_caps_str(xmpp_stanza_t * const stanza); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 22f550e3..cd28ddd2 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -139,6 +139,7 @@ void (*iq_room_list_request)(gchar *conferencejid); void (*iq_disco_info_request)(gchar *jid); void (*iq_disco_items_request)(gchar *jid); void (*iq_set_autoping)(int seconds); +void (*iq_create_instant_room)(const char * const room_jid); // caps functions Capabilities* (*caps_get)(const char * const caps_str); -- cgit 1.4.1-2-gfad0