mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
device_list iq should be from barejid or none
Ensure we request device_list and remove non conforming handling of responses. Move initialisation of iq_handlers before call to sv_ev_login_account_success
This commit is contained in:
parent
6bb7deeb9c
commit
0dd5441f92
@ -203,6 +203,8 @@ omemo_on_connect(ProfAccount *account)
|
||||
if (g_key_file_load_from_file(omemo_ctx.sessions_keyfile, omemo_ctx.sessions_filename->str, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
|
||||
load_sessions();
|
||||
}
|
||||
|
||||
omemo_devicelist_subscribe();
|
||||
}
|
||||
|
||||
void
|
||||
@ -368,13 +370,14 @@ omemo_prekeys(GList **prekeys, GList **ids, GList **lengths)
|
||||
void
|
||||
omemo_set_device_list(const char *const from, GList * device_list)
|
||||
{
|
||||
Jid *jid = jid_create(from);
|
||||
Jid *jid;
|
||||
if (from) {
|
||||
jid = jid_create(from);
|
||||
} else {
|
||||
jid = jid_create(connection_get_fulljid());
|
||||
}
|
||||
|
||||
g_hash_table_insert(omemo_ctx.device_list, strdup(jid->barejid), device_list);
|
||||
if (strchr(jid->barejid, '@') == NULL) {
|
||||
// barejid is server so we should handle it as our own device list
|
||||
g_hash_table_insert(omemo_ctx.device_list_handler, strdup(jid->barejid), handle_own_device_list);
|
||||
}
|
||||
|
||||
OmemoDeviceListHandler handler = g_hash_table_lookup(omemo_ctx.device_list_handler, jid->barejid);
|
||||
if (handler) {
|
||||
|
@ -74,7 +74,7 @@ void
|
||||
omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
char *id = connection_create_stanza_id("devicelist_request");
|
||||
char *id = connection_create_stanza_id("bundle_request");
|
||||
|
||||
xmpp_stanza_t *iq = stanza_create_omemo_bundle_request(ctx, id, jid, device_id);
|
||||
iq_id_handler_add(id, func, free_func, userdata);
|
||||
@ -278,9 +278,6 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
{
|
||||
GList *device_list = NULL;
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
if (!from) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *root = NULL;
|
||||
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
|
||||
@ -303,19 +300,17 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
}
|
||||
|
||||
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
|
||||
if (!item) {
|
||||
return 1;
|
||||
}
|
||||
if (item) {
|
||||
xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
|
||||
if (!list) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
|
||||
if (!list) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *device;
|
||||
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
||||
const char *id = xmpp_stanza_get_id(device);
|
||||
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
||||
xmpp_stanza_t *device;
|
||||
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
||||
const char *id = xmpp_stanza_get_id(device);
|
||||
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
||||
}
|
||||
}
|
||||
omemo_set_device_list(from, device_list);
|
||||
|
||||
|
@ -291,6 +291,12 @@ session_get_account_name(void)
|
||||
void
|
||||
session_login_success(gboolean secured)
|
||||
{
|
||||
chat_sessions_init();
|
||||
|
||||
message_handlers_init();
|
||||
presence_handlers_init();
|
||||
iq_handlers_init();
|
||||
|
||||
// logged in with account
|
||||
if (saved_account.name) {
|
||||
log_debug("Connection handler: logged in with account name: %s", saved_account.name);
|
||||
@ -309,21 +315,9 @@ session_login_success(gboolean secured)
|
||||
_session_free_saved_details();
|
||||
}
|
||||
|
||||
chat_sessions_init();
|
||||
|
||||
message_handlers_init();
|
||||
presence_handlers_init();
|
||||
iq_handlers_init();
|
||||
|
||||
roster_request();
|
||||
bookmark_request();
|
||||
blocking_request();
|
||||
#ifdef HAVE_OMEMO
|
||||
omemo_devicelist_subscribe();
|
||||
if (omemo_loaded()) {
|
||||
/* TODO: update devicelist */
|
||||
}
|
||||
#endif
|
||||
|
||||
// items discovery
|
||||
char *domain = connection_get_domain();
|
||||
|
Loading…
Reference in New Issue
Block a user