1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

_omemo_receive_devicelist() use if/else

This commit is contained in:
Michael Vetter 2020-05-29 10:28:41 +02:00
parent b882fd495a
commit 24e8243a98

View File

@ -442,29 +442,30 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
} }
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item"); xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
if (item && g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) { if (item) {
xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) {
if (!list) { xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
return 1; if (!list) {
} return 1;
xmpp_stanza_t *device;
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
continue;
} }
const char *id = xmpp_stanza_get_id(device); xmpp_stanza_t *device;
if (id != NULL) { for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10))); if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
} else { continue;
log_error("OMEMO: received device without ID"); }
const char *id = xmpp_stanza_get_id(device);
if (id != NULL) {
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
} else {
log_error("OMEMO: received device without ID");
}
} }
} else {
log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(item));
} }
} }
if (item && g_strcmp0(xmpp_stanza_get_id(item), "current") != 0 ) {
log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(item));
}
omemo_set_device_list(from, device_list); omemo_set_device_list(from, device_list);