1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-27 20:30:13 -04:00

session: combine internal free-functions

`_session_free_saved_details()` remains as it's still required alone

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel 2022-01-27 15:48:57 +01:00
parent e31e2877fc
commit 20a8ef7a3e

View File

@ -98,7 +98,7 @@ static char* saved_status;
static void _session_reconnect(void); static void _session_reconnect(void);
static void _session_free_saved_account(void); static void _session_free_internals(void);
static void _session_free_saved_details(void); static void _session_free_saved_details(void);
void void
@ -117,8 +117,7 @@ session_connect_with_account(const ProfAccount* const account)
log_info("Connecting using account: %s", account->name); log_info("Connecting using account: %s", account->name);
_session_free_saved_account(); _session_free_internals();
_session_free_saved_details();
// save account name and password for reconnect // save account name and password for reconnect
saved_account.name = strdup(account->name); saved_account.name = strdup(account->name);
@ -152,8 +151,7 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
assert(jid != NULL); assert(jid != NULL);
assert(passwd != NULL); assert(passwd != NULL);
_session_free_saved_account(); _session_free_internals();
_session_free_saved_details();
// save details for reconnect, remember name for account creating on success // save details for reconnect, remember name for account creating on success
saved_details.name = strdup(jid); saved_details.name = strdup(jid);
@ -240,8 +238,7 @@ session_disconnect(void)
void void
session_shutdown(void) session_shutdown(void)
{ {
_session_free_saved_account(); _session_free_internals();
_session_free_saved_details();
chat_sessions_clear(); chat_sessions_clear();
presence_clear_sub_requests(); presence_clear_sub_requests();
@ -371,8 +368,7 @@ session_login_failed(void)
if (reconnect_timer == NULL) { if (reconnect_timer == NULL) {
log_debug("Connection handler: No reconnect timer"); log_debug("Connection handler: No reconnect timer");
sv_ev_failed_login(); sv_ev_failed_login();
_session_free_saved_account(); _session_free_internals();
_session_free_saved_details();
} else { } else {
log_debug("Connection handler: Restarting reconnect timer"); log_debug("Connection handler: Restarting reconnect timer");
if (prefs_get_reconnect() != 0) { if (prefs_get_reconnect() != 0) {
@ -394,8 +390,7 @@ session_lost_connection(void)
assert(reconnect_timer == NULL); assert(reconnect_timer == NULL);
reconnect_timer = g_timer_new(); reconnect_timer = g_timer_new();
} else { } else {
_session_free_saved_account(); _session_free_internals();
_session_free_saved_details();
} }
} }
@ -562,10 +557,11 @@ _session_reconnect(void)
} }
static void static void
_session_free_saved_account(void) _session_free_internals(void)
{ {
FREE_SET_NULL(saved_account.name); FREE_SET_NULL(saved_account.name);
FREE_SET_NULL(saved_account.passwd); FREE_SET_NULL(saved_account.passwd);
_session_free_saved_details();
} }
static void static void