Add connection_clear_data()

This commit is contained in:
James Booth
2016-05-10 23:53:44 +01:00
parent a7fa27df01
commit 7e079f3684
3 changed files with 21 additions and 32 deletions

View File

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