mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Request for device list when OMEMO is ready
This commit is contained in:
parent
95da03ac28
commit
1f9d46037c
@ -83,14 +83,8 @@ omemo_generate_crypto_materials(ProfAccount *account)
|
|||||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
char *barejid = xmpp_jid_bare(ctx, session_get_account_name());
|
char *barejid = xmpp_jid_bare(ctx, session_get_account_name());
|
||||||
|
|
||||||
GList *device_list = g_hash_table_lookup(omemo_ctx.device_list, barejid);
|
|
||||||
g_hash_table_steal(omemo_ctx.device_list, barejid);
|
|
||||||
|
|
||||||
omemo_ctx.device_id = randombytes_uniform(0x80000000);
|
omemo_ctx.device_id = randombytes_uniform(0x80000000);
|
||||||
|
|
||||||
device_list = g_list_append(device_list, GINT_TO_POINTER(omemo_ctx.device_id));
|
|
||||||
g_hash_table_insert(omemo_ctx.device_list, strdup(barejid), device_list);
|
|
||||||
|
|
||||||
signal_protocol_key_helper_generate_identity_key_pair(&omemo_ctx.identity_key_pair, omemo_ctx.signal);
|
signal_protocol_key_helper_generate_identity_key_pair(&omemo_ctx.identity_key_pair, omemo_ctx.signal);
|
||||||
signal_protocol_key_helper_generate_registration_id(&omemo_ctx.registration_id, 0, omemo_ctx.signal);
|
signal_protocol_key_helper_generate_registration_id(&omemo_ctx.registration_id, 0, omemo_ctx.signal);
|
||||||
signal_protocol_key_helper_generate_pre_keys(&omemo_ctx.pre_keys_head, randombytes_random(), 100, omemo_ctx.signal);
|
signal_protocol_key_helper_generate_pre_keys(&omemo_ctx.pre_keys_head, randombytes_random(), 100, omemo_ctx.signal);
|
||||||
@ -102,7 +96,9 @@ omemo_generate_crypto_materials(ProfAccount *account)
|
|||||||
|
|
||||||
loaded = TRUE;
|
loaded = TRUE;
|
||||||
|
|
||||||
omemo_devicelist_publish(device_list);
|
/* Ensure we get our current device list, and it gets updated with our
|
||||||
|
* device_id */
|
||||||
|
omemo_devicelist_request(barejid);
|
||||||
omemo_bundle_publish();
|
omemo_bundle_publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,18 @@ omemo_devicelist_publish(GList *device_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
omemo_devicelist_fetch(void)
|
omemo_devicelist_request(const char * const jid)
|
||||||
{
|
{
|
||||||
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
|
char *id = connection_create_stanza_id("devicelist_request");
|
||||||
|
|
||||||
|
xmpp_stanza_t *iq = stanza_create_omemo_devicelist_request(ctx, id, jid);
|
||||||
|
iq_id_handler_add(id, _omemo_receive_devicelist, NULL, NULL);
|
||||||
|
|
||||||
|
iq_send_stanza(iq);
|
||||||
|
|
||||||
|
free(id);
|
||||||
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -74,12 +84,22 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t *root = NULL;
|
||||||
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
|
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
|
||||||
if (!event) {
|
if (event) {
|
||||||
|
root = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
|
||||||
|
if (pubsub) {
|
||||||
|
root = pubsub;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!root) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(event, "items");
|
xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items");
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
void omemo_devicelist_subscribe(void);
|
void omemo_devicelist_subscribe(void);
|
||||||
void omemo_devicelist_publish(GList *device_list);
|
void omemo_devicelist_publish(GList *device_list);
|
||||||
|
void omemo_devicelist_request(const char * const jid);
|
||||||
void omemo_bundle_publish(void);
|
void omemo_bundle_publish(void);
|
||||||
|
@ -2092,6 +2092,30 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room,
|
|||||||
return iq;
|
return iq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t*
|
||||||
|
stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id,
|
||||||
|
const char *const jid)
|
||||||
|
{
|
||||||
|
xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
|
||||||
|
xmpp_stanza_set_to(iq, jid);
|
||||||
|
|
||||||
|
xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
|
||||||
|
xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
|
||||||
|
|
||||||
|
xmpp_stanza_t *items = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(items, "items");
|
||||||
|
xmpp_stanza_set_attribute(items, "node", STANZA_NS_OMEMO_DEVICELIST);
|
||||||
|
|
||||||
|
xmpp_stanza_add_child(pubsub, items);
|
||||||
|
xmpp_stanza_add_child(iq, pubsub);
|
||||||
|
|
||||||
|
xmpp_stanza_release(items);
|
||||||
|
xmpp_stanza_release(pubsub);
|
||||||
|
|
||||||
|
return iq;
|
||||||
|
}
|
||||||
|
|
||||||
xmpp_stanza_t*
|
xmpp_stanza_t*
|
||||||
stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid)
|
stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid)
|
||||||
{
|
{
|
||||||
|
@ -288,6 +288,7 @@ 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_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);
|
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);
|
||||||
|
|
||||||
|
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_subscribe(xmpp_ctx_t *ctx, const char *const jid);
|
||||||
xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids);
|
xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids);
|
||||||
xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, uint32_t device_id, const unsigned char * const identity_key, size_t identity_key_length, const unsigned char * const signed_prekey, size_t signed_prekey_length, const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length, GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length);
|
xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, uint32_t device_id, const unsigned char * const identity_key, size_t identity_key_length, const unsigned char * const signed_prekey, size_t signed_prekey_length, const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length, GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length);
|
||||||
|
Loading…
Reference in New Issue
Block a user