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

Move conneciton initialisation to _connection_handler

This commit is contained in:
James Booth 2016-05-08 00:21:06 +01:00
parent 2f61f8d646
commit f1cf444e05
3 changed files with 11 additions and 23 deletions

View File

@ -316,12 +316,6 @@ connection_set_priority(const int priority)
conn.priority = priority; conn.priority = priority;
} }
void
connection_set_domain(char *domain)
{
conn.domain = strdup(domain);
}
#ifdef HAVE_LIBMESODE #ifdef HAVE_LIBMESODE
TLSCertificate* TLSCertificate*
connection_get_tls_peer_cert(void) connection_get_tls_peer_cert(void)
@ -367,16 +361,7 @@ connection_send_stanza(const char *const stanza)
} }
} }
void static 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
_disco_item_destroy(DiscoInfo *info) _disco_item_destroy(DiscoInfo *info)
{ {
if (info) { if (info) {
@ -418,8 +403,18 @@ _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status
// login success // login success
if (status == XMPP_CONN_CONNECT) { if (status == XMPP_CONN_CONNECT) {
log_debug("Connection handler: XMPP_CONN_CONNECT"); log_debug("Connection handler: XMPP_CONN_CONNECT");
conn.conn_status = JABBER_CONNECTED; 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()); session_login_success(connection_is_secured());
} else if (status == XMPP_CONN_DISCONNECT) { } else if (status == XMPP_CONN_DISCONNECT) {

View File

@ -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, 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); const char *const tls_policy);
void connection_disco_on_login(void);
void connection_set_status(jabber_conn_status_t status); void connection_set_status(jabber_conn_status_t status);
void connection_set_presence_msg(const char *const message); void connection_set_presence_msg(const char *const message);
void connection_set_priority(const int priority); void connection_set_priority(const int priority);
void connection_set_domain(char *domain);
void connection_set_priority(int priority); void connection_set_priority(int priority);
void connection_set_disco_items(GSList *disco_items); void connection_set_disco_items(GSList *disco_items);

View File

@ -294,10 +294,6 @@ session_login_success(gboolean secured)
_session_free_saved_details(); _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(); chat_sessions_init();
message_handlers_init(); message_handlers_init();
@ -309,7 +305,6 @@ session_login_success(gboolean secured)
blocking_request(); blocking_request();
// items discovery // items discovery
connection_disco_on_login();
iq_disco_info_request_onconnect(connection_get_domain()); iq_disco_info_request_onconnect(connection_get_domain());
iq_disco_items_request_onconnect(connection_get_domain()); iq_disco_items_request_onconnect(connection_get_domain());