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

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-01-02 16:52:37 +00:00
commit 2fe7063709
2 changed files with 14 additions and 3 deletions

View File

@ -517,7 +517,7 @@ gint
prefs_get_autoping_timeout(void) prefs_get_autoping_timeout(void)
{ {
if (!g_key_file_has_key(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL)) { if (!g_key_file_has_key(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL)) {
return 5; return 10;
} else { } else {
return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL); return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL);
} }

View File

@ -99,7 +99,7 @@ static int _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t
static int _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata); static int _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
static gboolean autoping_wait = FALSE; static gboolean autoping_wait = FALSE;
static GTimer *autoping_time; static GTimer *autoping_time = NULL;
void void
iq_add_handlers(void) iq_add_handlers(void)
@ -137,6 +137,10 @@ iq_autoping_check(void)
return; return;
} }
if (autoping_time == NULL) {
return;
}
gdouble elapsed = g_timer_elapsed(autoping_time, NULL); gdouble elapsed = g_timer_elapsed(autoping_time, NULL);
unsigned long seconds_elapsed = elapsed * 1.0; unsigned long seconds_elapsed = elapsed * 1.0;
gint timeout = prefs_get_autoping_timeout(); gint timeout = prefs_get_autoping_timeout();
@ -146,6 +150,7 @@ iq_autoping_check(void)
jabber_autoping_fail(); jabber_autoping_fail();
autoping_wait = FALSE; autoping_wait = FALSE;
g_timer_destroy(autoping_time); g_timer_destroy(autoping_time);
autoping_time = NULL;
} }
} }
@ -553,7 +558,10 @@ static int
_auto_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) _auto_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
{ {
autoping_wait = FALSE; autoping_wait = FALSE;
g_timer_destroy(autoping_time); if (autoping_time) {
g_timer_destroy(autoping_time);
autoping_time = NULL;
}
char *id = xmpp_stanza_get_id(stanza); char *id = xmpp_stanza_get_id(stanza);
if (id == NULL) { if (id == NULL) {
@ -895,6 +903,9 @@ _autoping_timed_handler(xmpp_conn_t *const conn, void *const userdata)
xmpp_send(conn, iq); xmpp_send(conn, iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
autoping_wait = TRUE; autoping_wait = TRUE;
if (autoping_time) {
g_timer_destroy(autoping_time);
}
autoping_time = g_timer_new(); autoping_time = g_timer_new();
return 1; return 1;