mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Send room destroy iq on /room config cancel
This commit is contained in:
parent
09c10f62f2
commit
aa9f1dfa06
@ -1803,6 +1803,8 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
||||
|
||||
} else if (g_strcmp0(args[1], "cancel") == 0) {
|
||||
// check that we're in room, we're owner and room requires configuration
|
||||
char *room = ui_current_recipient();
|
||||
iq_destroy_instant_room(room);
|
||||
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
|
@ -168,6 +168,16 @@ _iq_create_instant_room(const char * const room_jid)
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
static void
|
||||
_iq_destroy_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_destroy_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)
|
||||
@ -678,4 +688,5 @@ iq_init_module(void)
|
||||
iq_send_software_version = _iq_send_software_version;
|
||||
iq_set_autoping = _iq_set_autoping;
|
||||
iq_create_instant_room = _iq_create_instant_room;
|
||||
iq_destroy_instant_room = _iq_destroy_instant_room;
|
||||
}
|
||||
|
@ -452,6 +452,33 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char * const room_j
|
||||
return iq;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_instant_room_destroy_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 *destroy = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(destroy, STANZA_NAME_DESTROY);
|
||||
|
||||
xmpp_stanza_add_child(query, destroy);
|
||||
xmpp_stanza_release(destroy);
|
||||
|
||||
xmpp_stanza_add_child(iq, query);
|
||||
xmpp_stanza_release(query);
|
||||
|
||||
return iq;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_presence(xmpp_ctx_t * const ctx)
|
||||
{
|
||||
|
@ -74,6 +74,7 @@
|
||||
#define STANZA_NAME_PASSWORD "password"
|
||||
#define STANZA_NAME_CONFERENCE "conference"
|
||||
#define STANZA_NAME_VALUE "value"
|
||||
#define STANZA_NAME_DESTROY "destroy"
|
||||
|
||||
// error conditions
|
||||
#define STANZA_NAME_BAD_REQUEST "bad-request"
|
||||
@ -204,6 +205,8 @@ 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);
|
||||
xmpp_stanza_t* stanza_create_instant_room_destroy_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);
|
||||
|
@ -140,6 +140,7 @@ 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);
|
||||
void (*iq_destroy_instant_room)(const char * const room_jid);
|
||||
|
||||
// caps functions
|
||||
Capabilities* (*caps_get)(const char * const caps_str);
|
||||
|
Loading…
Reference in New Issue
Block a user