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

Send instant room request

This commit is contained in:
James Booth 2014-09-03 13:55:06 +01:00
parent d7b3e99a27
commit 09c10f62f2
5 changed files with 47 additions and 1 deletions

View File

@ -1797,7 +1797,9 @@ cmd_room(gchar **args, struct cmd_help_t help)
}
if (g_strcmp0(args[1], "accept") == 0) {
// check that we're in room, we're owner and room requires configuration
// TODO check that we're in room, we're owner and room requires configuration
char *room = ui_current_recipient();
iq_create_instant_room(room);
} else if (g_strcmp0(args[1], "cancel") == 0) {
// check that we're in room, we're owner and room requires configuration

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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);

View File

@ -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);