talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit b0978b8f43fa2da616a3171001ba75e7c89f9c34
parent 56422f5638fedb2bb8e0e3312403d0bce577161e
Author: Charles Lehner <cel@celehner.com>
Date:   Sat, 22 Nov 2014 20:44:25 -0500

Add callback for session connection result

Diffstat:
Msrc/common/session.c | 15++++++++++++++-
Msrc/common/session.h | 2++
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/common/session.c b/src/common/session.c @@ -128,6 +128,8 @@ gint session_connect(Session *session, const gchar *server, gushort port) if (session->conn_id < 0) { g_warning("can't connect to server."); session_close(session); + if (session->connect_finished) + session->connect_finished(session, FALSE); return -1; } @@ -142,6 +144,8 @@ gint session_connect(Session *session, const gchar *server, gushort port) if (sock == NULL) { g_warning("can't connect to server."); session_close(session); + if (session->connect_finished) + session->connect_finished(session, FALSE); return -1; } sock->is_smtp = session->is_smtp; @@ -159,6 +163,8 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) if (!sock) { g_warning("can't connect to server."); session->state = SESSION_ERROR; + if (session->connect_finished) + session->connect_finished(session, FALSE); return -1; } @@ -176,6 +182,8 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) g_warning("can't initialize SSL."); log_error(LOG_PROTOCOL, _("SSL handshake failed\n")); session->state = SESSION_ERROR; + if (session->connect_finished) + session->connect_finished(session, FALSE); return -1; } } @@ -183,8 +191,11 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) /* we could have gotten a timeout while waiting for user input in * an SSL certificate dialog */ - if (session->state == SESSION_TIMEOUT) + if (session->state == SESSION_TIMEOUT) { + if (session->connect_finished) + session->connect_finished(session, FALSE); return -1; + } sock_set_nonblocking_mode(sock, session->nonblocking); @@ -195,6 +206,8 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) session_read_msg_cb, session); + if (session->connect_finished) + session->connect_finished(session, TRUE); return 0; } diff --git a/src/common/session.h b/src/common/session.h @@ -130,6 +130,8 @@ struct _Session gint (*recv_msg) (Session *session, const gchar *msg); + void (*connect_finished) (Session *session, + gboolean success); gint (*send_data_finished) (Session *session, guint len); gint (*recv_data_finished) (Session *session,