From f1cf444e051ab925511ee304c2c5577d59216a26 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 8 May 2016 00:21:06 +0100 Subject: Move conneciton initialisation to _connection_handler --- src/xmpp/connection.c | 27 +++++++++++---------------- src/xmpp/connection.h | 2 -- src/xmpp/session.c | 5 ----- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 2fa0f200..db81bfbb 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -316,12 +316,6 @@ connection_set_priority(const int priority) conn.priority = priority; } -void -connection_set_domain(char *domain) -{ - conn.domain = strdup(domain); -} - #ifdef HAVE_LIBMESODE TLSCertificate* connection_get_tls_peer_cert(void) @@ -367,16 +361,7 @@ connection_send_stanza(const char *const stanza) } } -void -connection_disco_on_login(void) -{ - DiscoInfo *info = malloc(sizeof(struct disco_info_t)); - info->item = strdup(conn.domain); - info->features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); - conn.disco_items = g_slist_append(conn.disco_items, info); -} - -void +static void _disco_item_destroy(DiscoInfo *info) { if (info) { @@ -418,8 +403,18 @@ _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status // login success if (status == XMPP_CONN_CONNECT) { log_debug("Connection handler: XMPP_CONN_CONNECT"); + conn.conn_status = JABBER_CONNECTED; + Jid *my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn)); + conn.domain = strdup(my_jid->domainpart); + jid_destroy(my_jid); + + DiscoInfo *info = malloc(sizeof(struct disco_info_t)); + info->item = strdup(conn.domain); + info->features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); + conn.disco_items = g_slist_append(conn.disco_items, info); + session_login_success(connection_is_secured()); } else if (status == XMPP_CONN_DISCONNECT) { diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 6d6218ea..6c86ced9 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -41,12 +41,10 @@ void connection_init(void); jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port, const char *const tls_policy); -void connection_disco_on_login(void); void connection_set_status(jabber_conn_status_t status); void connection_set_presence_msg(const char *const message); void connection_set_priority(const int priority); -void connection_set_domain(char *domain); void connection_set_priority(int priority); void connection_set_disco_items(GSList *disco_items); diff --git a/src/xmpp/session.c b/src/xmpp/session.c index 2ea0bcc2..a1a223ff 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -294,10 +294,6 @@ session_login_success(gboolean secured) _session_free_saved_details(); } - Jid *my_jid = jid_create(connection_get_fulljid()); - connection_set_domain(my_jid->domainpart); - jid_destroy(my_jid); - chat_sessions_init(); message_handlers_init(); @@ -309,7 +305,6 @@ session_login_success(gboolean secured) blocking_request(); // items discovery - connection_disco_on_login(); iq_disco_info_request_onconnect(connection_get_domain()); iq_disco_items_request_onconnect(connection_get_domain()); -- cgit 1.4.1-2-gfad0