diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 4a8702a3..26c901b2 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,8 +1,9 @@ -# How to test the functionality -* step 1 + +- [ ] I ran valgrind when using my new feature -# I ran valgrind when using my new feature -yes/no +### How to test the functionality +* step 1 +* step 2 diff --git a/.gitignore b/.gitignore index eafcb988..75c8a5f4 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,9 @@ src/gitversion.h.in src/stamp-h1 src/plugins/profapi.lo +# out-of-tree build folders +build*/ + # binaries profanity **/*.o @@ -89,8 +92,11 @@ python2/ python3/ .DS_Store +.gdbinit *.bak *.orig +*.patch +*.rej breaks *.tar.* diff --git a/src/config/accounts.c b/src/config/accounts.c index 51a7b9cd..16edc219 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -481,7 +481,7 @@ static void _accounts_set_string_option(const char* account_name, const char* const option, const char* const value) { if (accounts_account_exists(account_name)) { - g_key_file_set_string(accounts, account_name, option, value); + g_key_file_set_string(accounts, account_name, option, value ?: ""); _save_accounts(); } } diff --git a/src/event/server_events.c b/src/event/server_events.c index 66ee65a9..1638cc7f 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -300,7 +300,8 @@ sv_ev_room_history(ProfMessage* message) ProfMucWin* mucwin = wins_get_muc(message->from_jid->barejid); if (mucwin) { // if this is the first successful connection - if (ev_is_first_connect()) { + // or for some reason the `last_msg_timestamp` is not initialized + if (ev_is_first_connect() || !mucwin->last_msg_timestamp) { // save timestamp of last received muc message // so we dont display, if there was no activity in channel, once we reconnect if (mucwin->last_msg_timestamp) { diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 1e4c272a..dbadd468 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -176,8 +176,7 @@ static int _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("iq stanza handler fired"); - - iq_autoping_timer_cancel(); // reset the autoping timer + autoping_timer_extend(); char* text; size_t text_size; @@ -1391,6 +1390,13 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata) return 1; } +void +autoping_timer_extend(void) +{ + if (autoping_time) + g_timer_start(autoping_time); +} + static int _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { diff --git a/src/xmpp/message.c b/src/xmpp/message.c index ad9f545e..e9ee166d 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -153,6 +153,7 @@ static int _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("Message stanza handler fired"); + autoping_timer_extend(); if (_handled_by_plugin(stanza)) { return 1; diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 36c2f6a9..2b0ae7f7 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -347,6 +347,7 @@ static int _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("Presence stanza handler fired"); + autoping_timer_extend(); char* text = NULL; size_t text_size; diff --git a/src/xmpp/roster_list.c b/src/xmpp/roster_list.c index a104f9cd..b5a60db7 100644 --- a/src/xmpp/roster_list.c +++ b/src/xmpp/roster_list.c @@ -104,6 +104,17 @@ roster_create(void) roster_pending_presence = NULL; } +static void +_pendingPresence_free(ProfPendingPresence* presence) +{ + if (!presence) + return; + if (presence->last_activity) + g_date_time_unref(presence->last_activity); + free(presence->barejid); + free(presence); +} + void roster_destroy(void) { @@ -119,6 +130,10 @@ roster_destroy(void) free(roster); roster = NULL; + + if (roster_pending_presence) + g_slist_free_full(roster_pending_presence, (GDestroyNotify)_pendingPresence_free); + roster_pending_presence = NULL; } gboolean @@ -716,15 +731,6 @@ roster_compare_presence(PContact a, PContact b) } } -static void -_pendingPresence_free(ProfPendingPresence* presence) -{ - if (!presence) - return; - free(presence->barejid); - free(presence); -} - void roster_process_pending_presence(void) { @@ -734,10 +740,6 @@ roster_process_pending_presence(void) for (iter = roster_pending_presence; iter != NULL; iter = iter->next) { ProfPendingPresence* presence = iter->data; roster_update_presence(presence->barejid, presence->resource, presence->last_activity); - /* seems like resource isn't free on the calling side */ - if (presence->last_activity) { - g_date_time_unref(presence->last_activity); - } } g_slist_free_full(roster_pending_presence, (GDestroyNotify)_pendingPresence_free); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 2babe536..cc0b62e7 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -269,6 +269,8 @@ void iq_mam_request_older(ProfChatWin* win); void iq_register_change_password(const char* const user, const char* const password); void iq_muc_register_nick(const char* const roomjid); +void autoping_timer_extend(void); + EntityCapabilities* caps_lookup(const char* const jid); void caps_close(void); void caps_destroy(EntityCapabilities* caps);