*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
gpointer data);
-void session_init(Session *session)
+void session_init(Session *session, const void *prefs_account, gboolean is_smtp)
{
session->type = SESSION_UNKNOWN;
session->sock = NULL;
session->server = NULL;
session->port = 0;
-#if USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
session->ssl_type = SSL_NONE;
#endif
session->nonblocking = TRUE;
session->timeout_interval = 0;
session->data = NULL;
+ session->account = prefs_account;
+ session->is_smtp = is_smtp;
}
/*!
session_close(session);
return -1;
}
+ sock->is_smtp = session->is_smtp;
return session_connect_cb(sock, session);
#endif
}
session->sock = sock;
-
-#if USE_OPENSSL
+ sock->account = session->account;
+ sock->is_smtp = session->is_smtp;
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
if (session->ssl_type == SSL_TUNNEL) {
sock_set_nonblocking_mode(sock, FALSE);
if (!ssl_init_socket(sock)) {
g_warning("can't initialize SSL.");
- log_error(_("SSL handshake failed\n"));
+ log_error(LOG_PROTOCOL, _("SSL handshake failed\n"));
session->state = SESSION_ERROR;
return -1;
}
g_source_remove(session->timeout_tag);
session->timeout_interval = interval;
- if (interval > 0)
+ if (interval > 0) {
+#if GLIB_CHECK_VERSION(2,14,0)
+ if (interval % 1000 == 0)
+ session->timeout_tag =
+ g_timeout_add_seconds(interval/1000, session_timeout_cb, session);
+ else
+#endif
session->timeout_tag =
g_timeout_add(interval, session_timeout_cb, session);
- else
+ } else
session->timeout_tag = 0;
}
return 0;
}
-#if USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
gint session_start_tls(Session *session)
{
gboolean nb_mode;
if (!ssl_init_socket_with_method(session->sock, SSL_METHOD_TLSv1)) {
g_warning("couldn't start TLS session.\n");
if (nb_mode)
- sock_set_nonblocking_mode(session->sock, TRUE);
+ sock_set_nonblocking_mode(session->sock, session->nonblocking);
return -1;
}