mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
MUC: Add voice request
closes https://github.com/profanity-im/profanity/issues/1211
This commit is contained in:
parent
dbd8657759
commit
ec6f9df486
@ -755,6 +755,7 @@ cmd_ac_init(void)
|
||||
|
||||
affiliation_cmd_ac = autocomplete_new();
|
||||
autocomplete_add(affiliation_cmd_ac, "list");
|
||||
autocomplete_add(affiliation_cmd_ac, "request");
|
||||
autocomplete_add(affiliation_cmd_ac, "set");
|
||||
|
||||
role_cmd_ac = autocomplete_new();
|
||||
|
@ -692,13 +692,15 @@ static struct cmd_t command_defs[] = {
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/affiliation set <affiliation> <jid> [<reason>]",
|
||||
"/affiliation list [<affiliation>]")
|
||||
"/affiliation list [<affiliation>]",
|
||||
"/affiliation request")
|
||||
CMD_DESC(
|
||||
"Manage room affiliations. "
|
||||
"Affiliation may be one of owner, admin, member, outcast or none.")
|
||||
CMD_ARGS(
|
||||
{ "set <affiliation> <jid> [<reason>]", "Set the affiliation of user with jid, with an optional reason." },
|
||||
{ "list [<affiliation>]", "List all users with the specified affiliation, or all if none specified." })
|
||||
{ "list [<affiliation>]", "List all users with the specified affiliation, or all if none specified." },
|
||||
{ "request", "Request voice."})
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
|
||||
|
@ -4161,6 +4161,11 @@ cmd_affiliation(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_strcmp0(cmd, "request") == 0) {
|
||||
message_request_voice(mucwin->roomjid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1560,3 +1560,15 @@ _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text
|
||||
return signcrypt;
|
||||
}
|
||||
#endif // HAVE_LIBGPGME
|
||||
|
||||
void
|
||||
message_request_voice(const char* const roomjid)
|
||||
{
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t* stanza = stanza_request_voice(ctx, roomjid);
|
||||
|
||||
log_debug("Requesting voice in %s", roomjid);
|
||||
|
||||
_send_message_stanza(stanza);
|
||||
xmpp_stanza_release(stanza);
|
||||
}
|
||||
|
@ -2755,3 +2755,61 @@ stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* cons
|
||||
|
||||
return iq;
|
||||
}
|
||||
|
||||
xmpp_stanza_t*
|
||||
stanza_request_voice(xmpp_ctx_t* ctx, const char* const room)
|
||||
{
|
||||
char* id = connection_create_stanza_id();
|
||||
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id);
|
||||
free(id);
|
||||
|
||||
xmpp_stanza_t* request_voice_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(request_voice_st, STANZA_NAME_X);
|
||||
xmpp_stanza_set_type(request_voice_st, STANZA_TYPE_SUBMIT);
|
||||
xmpp_stanza_set_ns(request_voice_st, STANZA_NS_DATA);
|
||||
|
||||
xmpp_stanza_t* form_type = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(form_type, STANZA_NAME_FIELD);
|
||||
xmpp_stanza_set_attribute(form_type, STANZA_ATTR_VAR, "FORM_TYPE");
|
||||
|
||||
xmpp_stanza_t* value_request = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(value_request, STANZA_NAME_VALUE);
|
||||
|
||||
xmpp_stanza_t* request_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(request_text, STANZA_NS_VOICEREQUEST);
|
||||
|
||||
xmpp_stanza_add_child(value_request, request_text);
|
||||
xmpp_stanza_release(request_text);
|
||||
|
||||
xmpp_stanza_add_child(form_type, value_request);
|
||||
xmpp_stanza_release(value_request);
|
||||
|
||||
xmpp_stanza_add_child(request_voice_st, form_type);
|
||||
xmpp_stanza_release(form_type);
|
||||
|
||||
xmpp_stanza_t* request_role = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(request_role, STANZA_NAME_FIELD);
|
||||
xmpp_stanza_set_attribute(request_role, STANZA_ATTR_VAR, "muc#role");
|
||||
xmpp_stanza_set_attribute(request_role, STANZA_ATTR_TYPE, "list-single");
|
||||
xmpp_stanza_set_attribute(request_role, STANZA_ATTR_LABEL, "Requested role");
|
||||
|
||||
xmpp_stanza_t* value_role = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(value_role, STANZA_NAME_VALUE);
|
||||
|
||||
xmpp_stanza_t* role_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(role_text, "participant");
|
||||
|
||||
xmpp_stanza_add_child(value_role, role_text);
|
||||
xmpp_stanza_release(role_text);
|
||||
|
||||
xmpp_stanza_add_child(request_role, value_role);
|
||||
xmpp_stanza_release(value_role);
|
||||
|
||||
xmpp_stanza_add_child(request_voice_st, request_role);
|
||||
xmpp_stanza_release(request_role);
|
||||
|
||||
xmpp_stanza_add_child(message, request_voice_st);
|
||||
xmpp_stanza_release(request_voice_st);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
@ -158,6 +158,7 @@
|
||||
#define STANZA_TYPE_SET "set"
|
||||
#define STANZA_TYPE_ERROR "error"
|
||||
#define STANZA_TYPE_RESULT "result"
|
||||
#define STANZA_TYPE_SUBMIT "submit"
|
||||
|
||||
#define STANZA_ATTR_TO "to"
|
||||
#define STANZA_ATTR_FROM "from"
|
||||
@ -186,6 +187,7 @@
|
||||
#define STANZA_ATTR_FILENAME "filename"
|
||||
#define STANZA_ATTR_SIZE "size"
|
||||
#define STANZA_ATTR_CONTENTTYPE "content-type"
|
||||
#define STANZA_ATTR_LABEL "label"
|
||||
|
||||
#define STANZA_TEXT_AWAY "away"
|
||||
#define STANZA_TEXT_DND "dnd"
|
||||
@ -233,6 +235,7 @@
|
||||
#define STANZA_NS_EXT_GAJIM_BOOKMARKS "xmpp:gajim.org/bookmarks"
|
||||
#define STANZA_NS_RSM "http://jabber.org/protocol/rsm"
|
||||
#define STANZA_NS_REGISTER "jabber:iq:register"
|
||||
#define STANZA_NS_VOICEREQUEST "http://jabber.org/protocol/muc#request"
|
||||
|
||||
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
|
||||
|
||||
@ -338,7 +341,6 @@ xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const cha
|
||||
void stanza_attach_publish_options_va(xmpp_ctx_t* const ctx, xmpp_stanza_t* const iq, int count, ...);
|
||||
void stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const iq, const char* const option, const char* const value);
|
||||
|
||||
|
||||
xmpp_stanza_t* stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid);
|
||||
xmpp_stanza_t* stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid);
|
||||
xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids);
|
||||
@ -396,4 +398,7 @@ xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, cons
|
||||
|
||||
xmpp_stanza_t* stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password);
|
||||
|
||||
xmpp_stanza_t*
|
||||
stanza_request_voice(xmpp_ctx_t* ctx, const char* const room);
|
||||
|
||||
#endif
|
||||
|
@ -214,6 +214,7 @@ void message_send_composing(const char* const jid);
|
||||
void message_send_paused(const char* const jid);
|
||||
void message_send_gone(const char* const jid);
|
||||
void message_send_invite(const char* const room, const char* const contact, const char* const reason);
|
||||
void message_request_voice(const char* const roomjid);
|
||||
|
||||
bool message_is_sent_by_us(const ProfMessage* const message, bool checkOID);
|
||||
|
||||
|
@ -213,6 +213,11 @@ message_send_invite(const char* const room, const char* const contact,
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
message_request_voice(const char* const roomjid)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user