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

Merge pull request #1891 from profanity-im/minor-improvements

Minor improvements
This commit is contained in:
Michael Vetter 2023-10-09 08:57:19 +02:00 committed by GitHub
commit 4e0981abc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 21 deletions

View File

@ -1,8 +1,9 @@
<!--- Make sure to read CONTRIBUTING.md -->
<!--- It mentions the rules to follow and helpful tools -->
# How to test the functionality
* step 1
<!-- For completed items, change [ ] to [x]. -->
- [ ] 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

6
.gitignore vendored
View File

@ -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.*

View File

@ -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();
}
}

View File

@ -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) {

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);