mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Add publish option to OMEMO device list and bundle
This commit is contained in:
parent
9044e3732c
commit
d8f0bcef94
@ -22,6 +22,13 @@ omemo_devicelist_publish(GList *device_list)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *iq = stanza_create_omemo_devicelist_publish(ctx, device_list);
|
||||
|
||||
Jid *jid = jid_create(connection_get_fulljid());
|
||||
if (caps_jid_has_feature(jid->barejid, XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) {
|
||||
stanza_attach_publish_options(ctx, iq, "pubsub#access_model", "open");
|
||||
}
|
||||
jid_destroy(jid);
|
||||
|
||||
iq_send_stanza(iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
@ -62,6 +69,13 @@ omemo_bundle_publish(void)
|
||||
identity_key, identity_key_length, signed_prekey, signed_prekey_length,
|
||||
signed_prekey_signature, signed_prekey_signature_length,
|
||||
prekeys, ids, lengths);
|
||||
|
||||
Jid *jid = jid_create(connection_get_fulljid());
|
||||
if (caps_jid_has_feature(jid->barejid, XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) {
|
||||
stanza_attach_publish_options(ctx, iq, "pubsub#access_model", "open");
|
||||
}
|
||||
jid_destroy(jid);
|
||||
|
||||
iq_send_stanza(iq);
|
||||
xmpp_stanza_release(iq);
|
||||
|
||||
|
@ -1832,6 +1832,45 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
|
||||
return strdup("unknown");
|
||||
}
|
||||
|
||||
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 *publish_options = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(publish_options, STANZA_NAME_PUBLISH_OPTIONS);
|
||||
|
||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(x, STANZA_NAME_X);
|
||||
xmpp_stanza_set_ns(x, STANZA_NS_DATA);
|
||||
xmpp_stanza_set_type(x, "submit");
|
||||
xmpp_stanza_add_child(publish_options, x);
|
||||
|
||||
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_set_type(form_type, "hidden");
|
||||
xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE);
|
||||
xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(form_type_value_text, XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS);
|
||||
xmpp_stanza_add_child(form_type_value, form_type_value_text);
|
||||
xmpp_stanza_add_child(form_type, form_type_value);
|
||||
xmpp_stanza_add_child(x, form_type);
|
||||
|
||||
xmpp_stanza_t *access_model = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(access_model, STANZA_NAME_FIELD);
|
||||
xmpp_stanza_set_attribute(access_model, STANZA_ATTR_VAR, option);
|
||||
xmpp_stanza_t *access_model_value = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(access_model_value, STANZA_NAME_VALUE);
|
||||
xmpp_stanza_t *access_model_value_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(access_model_value_text, value);
|
||||
xmpp_stanza_add_child(access_model_value, access_model_value_text);
|
||||
xmpp_stanza_add_child(access_model, access_model_value);
|
||||
xmpp_stanza_add_child(x, access_model);
|
||||
|
||||
xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
|
||||
xmpp_stanza_add_child(pubsub, publish_options);
|
||||
}
|
||||
|
||||
void
|
||||
stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri)
|
||||
{
|
||||
|
@ -290,6 +290,8 @@ xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *con
|
||||
xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, const char *const node);
|
||||
xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, const char *const node, const char *const sessionid, DataForm *form);
|
||||
|
||||
void stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const publish, 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);
|
||||
|
@ -63,6 +63,8 @@
|
||||
#define XMPP_FEATURE_MUC_NONANONYMOUS "http://jabber.org/protocol/muc#muc_nonanonymous"
|
||||
#define XMPP_FEATURE_COMMANDS "http://jabber.org/protocol/commands"
|
||||
#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY "eu.siacs.conversations.axolotl.devicelist+notify"
|
||||
#define XMPP_FEATURE_PUBSUB "http://jabber.org/protocol/pubsub"
|
||||
#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS "http://jabber.org/protocol/pubsub#publish-options"
|
||||
|
||||
typedef enum {
|
||||
JABBER_CONNECTING,
|
||||
|
Loading…
Reference in New Issue
Block a user