| 38 |
38 |
|
| 39 |
39 |
#include "imap.h"
|
| 40 |
40 |
#include "socket.h"
|
|
41 |
#include "socks.h"
|
| 41 |
42 |
#include "ssl.h"
|
| 42 |
43 |
#include "recv.h"
|
| 43 |
44 |
#include "procmsg.h"
|
| ... | ... | |
| 250 |
251 |
#if USE_SSL
|
| 251 |
252 |
static SockInfo *imap_open (const gchar *server,
|
| 252 |
253 |
gushort port,
|
|
254 |
SocksInfo *socks_info,
|
| 253 |
255 |
SSLType ssl_type);
|
| 254 |
256 |
#else
|
| 255 |
257 |
static SockInfo *imap_open (const gchar *server,
|
| 256 |
|
gushort port);
|
|
258 |
gushort port,
|
|
259 |
SocksInfo *socks_info);
|
| 257 |
260 |
#endif
|
| 258 |
261 |
|
| 259 |
262 |
static gint imap_msg_list_change_perm_flags (GSList *msglist,
|
| ... | ... | |
| 664 |
667 |
static gint imap_session_connect(IMAPSession *session)
|
| 665 |
668 |
{
|
| 666 |
669 |
SockInfo *sock;
|
|
670 |
SocksInfo *socks_info = NULL;
|
| 667 |
671 |
PrefsAccount *account;
|
| 668 |
672 |
const gchar *pass;
|
| 669 |
673 |
|
| ... | ... | |
| 689 |
693 |
pass = account->tmp_pass;
|
| 690 |
694 |
}
|
| 691 |
695 |
|
|
696 |
if (account->use_socks && account->use_socks_for_recv &&
|
|
697 |
account->proxy_host) {
|
|
698 |
socks_info = socks_info_new(account->socks_type, account->proxy_host, account->proxy_port, account->use_proxy_auth ? account->proxy_name : NULL, account->use_proxy_auth ? account->proxy_pass : NULL);
|
|
699 |
}
|
|
700 |
|
| 692 |
701 |
#if USE_SSL
|
| 693 |
702 |
if ((sock = imap_open(SESSION(session)->server, SESSION(session)->port,
|
| 694 |
|
SESSION(session)->ssl_type)) == NULL)
|
|
703 |
socks_info, SESSION(session)->ssl_type)) == NULL)
|
| 695 |
704 |
#else
|
| 696 |
|
if ((sock = imap_open(SESSION(session)->server, SESSION(session)->port))
|
|
705 |
if ((sock = imap_open(SESSION(session)->server, SESSION(session)->port,
|
|
706 |
socks_info))
|
| 697 |
707 |
== NULL)
|
| 698 |
708 |
#endif
|
| 699 |
709 |
return IMAP_ERROR;
|
| 700 |
710 |
|
|
711 |
if (socks_info)
|
|
712 |
socks_info_free(socks_info);
|
|
713 |
|
| 701 |
714 |
SESSION(session)->sock = sock;
|
| 702 |
715 |
|
| 703 |
716 |
if (imap_greeting(session) != IMAP_SUCCESS)
|
| ... | ... | |
| 2866 |
2879 |
|
| 2867 |
2880 |
#if USE_SSL
|
| 2868 |
2881 |
static SockInfo *imap_open(const gchar *server, gushort port,
|
| 2869 |
|
SSLType ssl_type)
|
|
2882 |
SocksInfo *socks_info, SSLType ssl_type)
|
| 2870 |
2883 |
#else
|
| 2871 |
|
static SockInfo *imap_open(const gchar *server, gushort port)
|
|
2884 |
static SockInfo *imap_open(const gchar *server, gushort port,
|
|
2885 |
SocksInfo *socks_info)
|
| 2872 |
2886 |
#endif
|
| 2873 |
2887 |
{
|
| 2874 |
2888 |
SockInfo *sock = NULL;
|
|
2889 |
const gchar *server_;
|
|
2890 |
gushort port_;
|
|
2891 |
|
|
2892 |
if (socks_info) {
|
|
2893 |
server_ = socks_info->proxy_host;
|
|
2894 |
port_ = socks_info->proxy_port;
|
|
2895 |
} else {
|
|
2896 |
server_ = server;
|
|
2897 |
port_ = port;
|
|
2898 |
}
|
|
2899 |
|
| 2875 |
2900 |
#if USE_THREADS
|
| 2876 |
2901 |
gint conn_id;
|
| 2877 |
2902 |
|
| 2878 |
|
if ((conn_id = sock_connect_async_thread(server, port)) < 0 ||
|
|
2903 |
if ((conn_id = sock_connect_async_thread(server_, port_)) < 0 ||
|
| 2879 |
2904 |
sock_connect_async_thread_wait(conn_id, &sock) < 0) {
|
| 2880 |
2905 |
log_warning(_("Can't connect to IMAP4 server: %s:%d\n"),
|
| 2881 |
2906 |
server, port);
|
| 2882 |
2907 |
return NULL;
|
| 2883 |
2908 |
}
|
| 2884 |
2909 |
#else
|
| 2885 |
|
if ((sock = sock_connect(server, port)) == NULL) {
|
|
2910 |
if ((sock = sock_connect(server_, port_)) == NULL) {
|
| 2886 |
2911 |
log_warning(_("Can't connect to IMAP4 server: %s:%d\n"),
|
| 2887 |
2912 |
server, port);
|
| 2888 |
2913 |
return NULL;
|
| 2889 |
2914 |
}
|
| 2890 |
2915 |
#endif
|
| 2891 |
2916 |
|
|
2917 |
if (socks_info) {
|
|
2918 |
if (socks_connect(sock, server, port, socks_info) < 0) {
|
|
2919 |
log_warning("Can't establish SOCKS connection: %s:%d\n",
|
|
2920 |
server, port);
|
|
2921 |
return NULL;
|
|
2922 |
}
|
|
2923 |
}
|
|
2924 |
|
| 2892 |
2925 |
#if USE_SSL
|
| 2893 |
2926 |
if (ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
|
| 2894 |
2927 |
log_warning(_("Can't establish IMAP4 session with: %s:%d\n"),
|