diff options
author | Maximilian Wuttke <mwuttke97@posteo.de> | 2021-03-09 17:47:43 +0100 |
---|---|---|
committer | Maximilian Wuttke <mwuttke97@posteo.de> | 2021-03-09 17:47:43 +0100 |
commit | 68469149cd960a5a8fb9cd6ec4a5dd4ca139a4a7 (patch) | |
tree | de09005cdacd27415195d1eae15db974f1d49067 | |
parent | 412485610085fd4b521c9699a964eb6b39255c1c (diff) | |
download | profani-tty-68469149cd960a5a8fb9cd6ec4a5dd4ca139a4a7.tar.gz |
Logging [OMEMO]
Also "handle" some errors in `_omemo_bundle_publish_configure` if the stanzas can't be found
-rw-r--r-- | src/xmpp/omemo.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c index 8058d8f2..b51335b5 100644 --- a/src/xmpp/omemo.c +++ b/src/xmpp/omemo.c @@ -63,8 +63,11 @@ 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); + log_debug("[OMEMO] omemo_devicelist_publish()"); + if (connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) { stanza_attach_publish_options(ctx, iq, "pubsub#access_model", "open"); + // stanza_attach_publish_options(ctx, iq, "pubsub#max_items", "max"); } iq_send_stanza(iq); @@ -99,6 +102,8 @@ omemo_bundle_publish(gboolean first) size_t signed_prekey_signature_length; GList *prekeys = NULL, *ids = NULL, *lengths = NULL; + log_debug("OMEMO: omemo_bundle_publish()"); + omemo_identity_key(&identity_key, &identity_key_length); omemo_signed_prekey(&signed_prekey, &signed_prekey_length); omemo_signed_prekey_signature(&signed_prekey_signature, &signed_prekey_signature_length); @@ -493,6 +498,8 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata) static int _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata) { + log_debug("[OMEMO] _omemo_bundle_publish_result()"); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) != 0) { @@ -510,14 +517,16 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata) Jid* jid = jid_create(connection_get_fulljid()); char* id = connection_create_stanza_id(); char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id()); - log_info("[OMEMO] node: %s", node); + log_info("[OMEMO] node: %s", node); xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node); g_free(node); iq_id_handler_add(id, _omemo_bundle_publish_configure, NULL, userdata); + log_debug("[OMEMO] _omemo_bundle_publish_result(): sending pubsub conf request"); iq_send_stanza(iq); + log_debug("[OMEMO] _omemo_bundle_publish_result(): sent pubsub conf request"); xmpp_stanza_release(iq); free(id); @@ -528,10 +537,24 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata) static int _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdata) { + log_debug("[OMEMO] _omemo_bundle_publish_configure()"); + /* TODO handle error */ xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_name(stanza, "pubsub"); + if (!pubsub) { + log_error("[OMEMO] The stanza doesn't contain a 'pubsub' child"); + return 0; + } xmpp_stanza_t* configure = xmpp_stanza_get_child_by_name(pubsub, STANZA_NAME_CONFIGURE); + if (!configure) { + log_error("[OMEMO] The stanza doesn't contain a 'configure' child"); + return 0; + } xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(configure, "x"); + if (!x) { + log_error("[OMEMO] The stanza doesn't contain an 'x' child"); + return 0; + } DataForm* form = form_create(x); char* tag = g_hash_table_lookup(form->var_to_tag, "pubsub#access_model"); @@ -552,6 +575,8 @@ _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdat iq_send_stanza(iq); + log_debug("[OMEMO] _omemo_bundle_publish_configure() done"); + xmpp_stanza_release(iq); free(id); jid_destroy(jid); |