diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 1e2e1b32..59412718 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -979,6 +979,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status connection_get_jid(); conn.domain = strdup(conn.jid->domainpart); + log_debug("conn.domain=%s", conn.jid->domainpart); connection_clear_data(); conn.features_by_jid = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_destroy); @@ -1163,3 +1164,32 @@ connection_get_profanity_identifier(void) { return prof_identifier; } + +void +connection_debug_print_features() +{ + log_debug("=== Connection Features ==="); + + GHashTableIter iter; + gpointer jid_ptr, features_ptr; + + g_hash_table_iter_init(&iter, conn.features_by_jid); + while (g_hash_table_iter_next(&iter, &jid_ptr, &features_ptr)) { + const char* jid = (const char*)jid_ptr; + GHashTable* features = (GHashTable*)features_ptr; + + if (!features || g_hash_table_size(features) == 0) { + log_debug("%s:\t(no features)", jid); + continue; + } + + GList* feature_keys = g_hash_table_get_keys(features); + for (GList* l = feature_keys; l != NULL; l = l->next) { + const char* feature = (const char*)l->data; + log_debug("%s:\t%s", jid, feature); + } + g_list_free(feature_keys); + } + + log_debug("=== End of Features ==="); +} diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index b3a1bf98..5609d2ec 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1417,6 +1417,8 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata) return 0; } +static gboolean autoping_error_shown = false; + static int _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata) { @@ -1425,10 +1427,13 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata) } if (connection_supports(XMPP_FEATURE_PING) == FALSE) { - log_warning("Server doesn't advertise %s feature, disabling autoping.", XMPP_FEATURE_PING); - prefs_set_autoping(0); - cons_show_error("Server ping not supported (%s), autoping disabled.", XMPP_FEATURE_PING); - return 0; + // TODO: do we need to check it on each autoping call? + log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_PING); + if (!autoping_error_shown) { + connection_debug_print_features(); + cons_show_error("Server ping not supported (%s). Check log for details.", XMPP_FEATURE_PING); + } + autoping_error_shown = 1; } if (autoping_wait) { @@ -1499,7 +1504,7 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata) if (g_strcmp0(errtype, STANZA_TYPE_CANCEL) == 0) { log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id); prefs_set_autoping(0); - cons_show_error("Server ping not supported, autoping disabled."); + cons_show_error("Autoping is not supported by the server (stanza cancelled). The feature has been disabled automatically."); xmpp_timed_handler_delete(connection_get_conn(), _autoping_timed_send); } @@ -2515,6 +2520,7 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza) GSList* items = NULL; if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) { + log_warning("_disco_items_result_handler: Received unexpected disco id: %s", id); return; } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 26d3d259..ff320e80 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -208,6 +208,8 @@ const char* connection_jid_for_feature(const char* const feature); const char* connection_get_profanity_identifier(void); +void connection_debug_print_features(); + char* message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id); char* message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id); char* message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id); diff --git a/tests/unittests/log/stub_log.c b/tests/unittests/log/stub_log.c index aba5a603..c25ecf76 100644 --- a/tests/unittests/log/stub_log.c +++ b/tests/unittests/log/stub_log.c @@ -26,7 +26,7 @@ #include "log.h" void -log_init(log_level_t filter, char* log_file) +log_init(log_level_t filter, const char* const log_file) { } log_level_t diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index 76a072e9..e2af28b8 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -156,6 +156,11 @@ connection_get_profanity_identifier(void) return "profident"; } +void +connection_debug_print_features() +{ +} + jabber_conn_status_t connection_register(const char* const altdomain, int port, const char* const tls_policy, const char* const username, const char* const password)