mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Add connection_clear_data()
This commit is contained in:
parent
a7fa27df01
commit
7e079f3684
@ -81,10 +81,10 @@ void
|
||||
connection_init(void)
|
||||
{
|
||||
xmpp_initialize();
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
conn.presence_message = NULL;
|
||||
conn.xmpp_conn = NULL;
|
||||
conn.xmpp_ctx = NULL;
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
conn.presence_message = NULL;
|
||||
conn.domain = NULL;
|
||||
conn.features_by_jid = NULL;
|
||||
conn.available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy);
|
||||
@ -93,8 +93,7 @@ connection_init(void)
|
||||
void
|
||||
connection_shutdown(void)
|
||||
{
|
||||
connection_disco_items_free();
|
||||
connection_remove_all_available_resources();
|
||||
connection_clear_data();
|
||||
xmpp_shutdown();
|
||||
|
||||
free(conn.xmpp_log);
|
||||
@ -206,6 +205,15 @@ connection_disconnect(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
connection_clear_data(void)
|
||||
{
|
||||
g_hash_table_destroy(conn.features_by_jid);
|
||||
conn.features_by_jid = NULL;
|
||||
|
||||
g_hash_table_remove_all(conn.available_resources);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBMESODE
|
||||
TLSCertificate*
|
||||
connection_get_tls_peer_cert(void)
|
||||
@ -350,12 +358,6 @@ connection_remove_available_resource(const char *const resource)
|
||||
g_hash_table_remove(conn.available_resources, resource);
|
||||
}
|
||||
|
||||
void
|
||||
connection_remove_all_available_resources(void)
|
||||
{
|
||||
g_hash_table_remove_all(conn.available_resources);
|
||||
}
|
||||
|
||||
char*
|
||||
connection_create_uuid(void)
|
||||
{
|
||||
@ -409,13 +411,6 @@ connection_set_priority(const int priority)
|
||||
conn.priority = priority;
|
||||
}
|
||||
|
||||
void
|
||||
connection_disco_items_free(void)
|
||||
{
|
||||
g_hash_table_destroy(conn.features_by_jid);
|
||||
conn.features_by_jid = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status, const int error,
|
||||
xmpp_stream_error_t *const stream_error, void *const userdata)
|
||||
|
@ -58,10 +58,10 @@ xmpp_ctx_t* connection_get_ctx(void);
|
||||
char *connection_get_domain(void);
|
||||
char* connection_jid_for_feature(const char *const feature);
|
||||
GHashTable* connection_get_features(const char *const jid);
|
||||
void connection_disco_items_free(void);
|
||||
|
||||
void connection_clear_data(void);
|
||||
|
||||
void connection_add_available_resource(Resource *resource);
|
||||
void connection_remove_available_resource(const char *const resource);
|
||||
void connection_remove_all_available_resources(void);
|
||||
|
||||
#endif
|
||||
|
@ -208,8 +208,7 @@ session_disconnect(void)
|
||||
connection_disconnect();
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
connection_disco_items_free();
|
||||
connection_remove_all_available_resources();
|
||||
connection_clear_data();
|
||||
chat_sessions_clear();
|
||||
presence_clear_sub_requests();
|
||||
}
|
||||
@ -317,21 +316,16 @@ session_login_failed(void)
|
||||
sv_ev_failed_login();
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
connection_disco_items_free();
|
||||
connection_remove_all_available_resources();
|
||||
chat_sessions_clear();
|
||||
presence_clear_sub_requests();
|
||||
} else {
|
||||
log_debug("Connection handler: Restarting reconnect timer");
|
||||
if (prefs_get_reconnect() != 0) {
|
||||
g_timer_start(reconnect_timer);
|
||||
}
|
||||
// free resources but leave saved_user untouched
|
||||
connection_disco_items_free();
|
||||
connection_remove_all_available_resources();
|
||||
chat_sessions_clear();
|
||||
presence_clear_sub_requests();
|
||||
}
|
||||
|
||||
connection_clear_data();
|
||||
chat_sessions_clear();
|
||||
presence_clear_sub_requests();
|
||||
}
|
||||
|
||||
void
|
||||
@ -345,8 +339,8 @@ session_lost_connection(void)
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
}
|
||||
connection_disco_items_free();
|
||||
connection_remove_all_available_resources();
|
||||
|
||||
connection_clear_data();
|
||||
chat_sessions_clear();
|
||||
presence_clear_sub_requests();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user