2860
2860
GCancellable *cancellable,
2861
2861
GError **error)
2863
CamelNetworkService *network_service;
2864
CamelNetworkSecurityMethod method;
2863
2865
CamelStream * tcp_stream = NULL;
2866
2866
CamelSockOptData sockopt;
2867
gint ret, ssl_mode = 0;
2869
#ifdef CAMEL_HAVE_SSL
2877
2870
CamelIMAPXCommand *ic;
2878
2871
GError *local_error = NULL;
2888
2881
goto connected;
2891
if (is->url->port) {
2892
serv = g_alloca (16);
2893
sprintf((gchar *) serv, "%d", is->url->port);
2897
fallback_port = 143;
2899
#ifdef CAMEL_HAVE_SSL
2900
mode = camel_url_get_param(is->url, "use_ssl");
2901
if (mode && strcmp(mode, "never") != 0) {
2902
if (!strcmp(mode, "when-possible")) {
2903
tcp_stream = camel_tcp_stream_ssl_new_raw (is->session, is->url->host, STARTTLS_FLAGS);
2906
if (is->url->port == 0) {
2908
fallback_port = 993;
2910
tcp_stream = camel_tcp_stream_ssl_new (is->session, is->url->host, SSL_PORT_FLAGS);
2913
tcp_stream = camel_tcp_stream_raw_new ();
2916
tcp_stream = camel_tcp_stream_raw_new ();
2917
#endif /* CAMEL_HAVE_SSL */
2919
camel_session_get_socks_proxy (is->session, &socks_host, &socks_port);
2922
camel_tcp_stream_set_socks_proxy ((CamelTcpStream *) tcp_stream, socks_host, socks_port);
2923
g_free (socks_host);
2926
ret = camel_tcp_stream_connect (
2927
CAMEL_TCP_STREAM (tcp_stream), is->url->host, serv,
2928
fallback_port, cancellable, error);
2931
error, _("Could not connect to %s (port %s): "),
2932
is->url->host, serv);
2933
g_object_unref (tcp_stream);
2885
network_service = CAMEL_NETWORK_SERVICE (is->store);
2886
method = camel_network_service_get_security_method (network_service);
2888
tcp_stream = camel_network_service_connect_sync (
2889
CAMEL_NETWORK_SERVICE (is->store), cancellable, error);
2891
if (tcp_stream == NULL)
2937
2894
is->stream = (CamelIMAPXStream *) camel_imapx_stream_new (tcp_stream);
2938
2895
g_object_unref (tcp_stream);
4982
4938
fds[0].events = G_IO_IN;
4983
4939
fds[1].fd = g_cancellable_get_fd (cancellable);
4984
4940
fds[1].events = G_IO_IN;
4985
res = g_poll (fds, 2, 1000*30);
4941
res = g_poll (fds, 2, -1);
4987
4943
g_usleep (1) /* ?? */ ;
4988
4944
else if (res == 0)
5003
4959
pollfds[1].fd = camel_operation_cancel_prfd (CAMEL_OPERATION (cancellable));
5004
4960
pollfds[1].in_flags = PR_POLL_READ;
5006
res = PR_Poll (pollfds, 2, PR_MillisecondsToInterval (30 * 1000));
4962
res = PR_Poll (pollfds, 2, PR_INTERVAL_NO_TIMEOUT);
5008
4964
g_usleep (1) /* ?? */ ;
5009
4965
else if (res == 0) {
5070
imapx_server_finalize (GObject *object)
5072
CamelIMAPXServer *is = CAMEL_IMAPX_SERVER (object);
5074
camel_url_free (is->url);
5076
g_static_rec_mutex_free (&is->queue_lock);
5077
g_static_rec_mutex_free (&is->ostream_lock);
5078
g_mutex_free (is->fetch_mutex);
5079
g_cond_free (is->fetch_cond);
5081
camel_folder_change_info_free (is->changes);
5083
/* Chain up to parent's finalize() method. */
5084
G_OBJECT_CLASS (camel_imapx_server_parent_class)->finalize (object);
5088
imapx_server_constructed (GObject *object)
5090
CamelIMAPXServer *server;
5091
CamelIMAPXServerClass *class;
5093
server = CAMEL_IMAPX_SERVER (object);
5094
class = CAMEL_IMAPX_SERVER_GET_CLASS (server);
5096
server->tagprefix = class->tagprefix;
5098
if (class->tagprefix > 'Z')
5099
class->tagprefix = 'A';
5102
5025
static gboolean
5103
5026
join_helper (gpointer thread)
5137
5060
imapx_disconnect (server);
5062
if (server->session != NULL) {
5063
g_object_unref (server->session);
5064
server->session = NULL;
5139
5067
/* Chain up to parent's dispose() method. */
5140
5068
G_OBJECT_CLASS (camel_imapx_server_parent_class)->dispose (object);
5072
imapx_server_finalize (GObject *object)
5074
CamelIMAPXServer *is = CAMEL_IMAPX_SERVER (object);
5076
camel_url_free (is->url);
5078
g_static_rec_mutex_free (&is->queue_lock);
5079
g_static_rec_mutex_free (&is->ostream_lock);
5080
g_mutex_free (is->fetch_mutex);
5081
g_cond_free (is->fetch_cond);
5083
camel_folder_change_info_free (is->changes);
5085
/* Chain up to parent's finalize() method. */
5086
G_OBJECT_CLASS (camel_imapx_server_parent_class)->finalize (object);
5090
imapx_server_constructed (GObject *object)
5092
CamelIMAPXServer *server;
5093
CamelIMAPXServerClass *class;
5095
server = CAMEL_IMAPX_SERVER (object);
5096
class = CAMEL_IMAPX_SERVER_GET_CLASS (server);
5098
server->tagprefix = class->tagprefix;
5100
if (class->tagprefix > 'Z')
5101
class->tagprefix = 'A';
5144
5105
camel_imapx_server_class_init (CamelIMAPXServerClass *class)
5146
5107
GObjectClass *object_class;