talons

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

commit c0fe6d3d75b97f04149e7d42b6d6489f05c2ed92
parent 00d923040e6130fc9023edad3cba690bcc93ad9f
Author: Oliver Lowe <o@olowe.co>
Date:   Sun, 24 Aug 2025 00:23:26 +1000

Drop SOCKS proxy support

Can use a VPN

Diffstat:
Msrc/Makefile.am | 2--
Msrc/account.c | 10----------
Msrc/common/Makefile.am | 2--
Dsrc/common/proxy.c | 280-------------------------------------------------------------------------------
Dsrc/common/proxy.h | 50--------------------------------------------------
Msrc/common/session.c | 25+++----------------------
Msrc/common/session.h | 13++-----------
Msrc/compose.c | 34++--------------------------------
Msrc/etpan/Makefile.am | 2--
Msrc/etpan/imap-thread.c | 101++++---------------------------------------------------------------------------
Msrc/etpan/imap-thread.h | 4++--
Dsrc/etpan/nntp-thread.c | 1064-------------------------------------------------------------------------------
Dsrc/etpan/nntp-thread.h | 52----------------------------------------------------
Msrc/imap.c | 36++++--------------------------------
Msrc/inc.c | 17-----------------
Msrc/main.c | 6------
Msrc/news.c | 803+++----------------------------------------------------------------------------
Msrc/prefs_account.c | 280-------------------------------------------------------------------------------
Msrc/prefs_account.h | 6------
Msrc/prefs_common.c | 8--------
Msrc/prefs_common.h | 4----
Dsrc/prefs_proxy.c | 281-------------------------------------------------------------------------------
Dsrc/prefs_proxy.h | 26--------------------------
Msrc/send_message.c | 17-----------------
24 files changed, 46 insertions(+), 3077 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am @@ -98,7 +98,6 @@ claws_mail_SOURCES = \ prefs_matcher.c \ prefs_message.c \ prefs_other.c \ - prefs_proxy.c \ prefs_quote.c \ prefs_receive.c \ prefs_send.c \ @@ -198,7 +197,6 @@ claws_mailinclude_HEADERS = \ prefs_matcher.h \ prefs_message.h \ prefs_other.h \ - prefs_proxy.h \ prefs_quote.h \ prefs_receive.h \ prefs_send.h \ diff --git a/src/account.c b/src/account.c @@ -1056,16 +1056,6 @@ static void account_clone(GtkWidget *widget, gpointer data) ACP_FASSIGN(config_version); - ACP_FASSIGN(use_proxy); - ACP_FASSIGN(use_default_proxy); - ACP_FASSIGN(use_proxy_for_send); - ACP_FASSIGN(proxy_info.proxy_type); - ACP_FDUP(proxy_info.proxy_host); - ACP_FASSIGN(proxy_info.proxy_port); - ACP_FASSIGN(proxy_info.use_proxy_auth); - ACP_FDUP(proxy_info.proxy_name); - ACP_FDUP(proxy_info.proxy_pass); - account_list = g_list_append(account_list, ac_clon); account_list_view_set(); } diff --git a/src/common/Makefile.am b/src/common/Makefile.am @@ -25,7 +25,6 @@ libclawscommon_la_SOURCES = $(arch_sources) \ passcrypt.c \ prefs.c \ progressindicator.c \ - proxy.c \ quoted-printable.c \ session.c \ smtp.c \ @@ -55,7 +54,6 @@ clawscommoninclude_HEADERS = $(arch_headers) \ passcrypt.h \ prefs.h \ progressindicator.h \ - proxy.h \ quoted-printable.h \ session.h \ smtp.h \ diff --git a/src/common/proxy.c b/src/common/proxy.c @@ -1,280 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2018 the Claws Mail team - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <glib.h> - -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ip.h> - -#include "proxy.h" -#include "socket.h" -#include "utils.h" - -gint socks4_connect(SockInfo *sock, const gchar *hostname, gushort port); -gint socks5_connect(SockInfo *sock, const gchar *hostname, gushort port, - const gchar *proxy_name, const gchar *proxy_pass); - -gint proxy_connect(SockInfo *sock, const gchar *hostname, gushort port, - ProxyInfo *proxy_info) -{ - gint ret; - - g_return_val_if_fail(sock != NULL, -1); - g_return_val_if_fail(hostname != NULL, -1); - g_return_val_if_fail(proxy_info != NULL, -1); - - debug_print("proxy_connect: connect to %s:%u via %s:%u\n", - hostname, port, - proxy_info->proxy_host, proxy_info->proxy_port); - - if (proxy_info->proxy_type == PROXY_SOCKS5) { - ret = socks5_connect(sock, hostname, port, - proxy_info->use_proxy_auth ? proxy_info->proxy_name : NULL, - proxy_info->use_proxy_auth ? proxy_info->proxy_pass : NULL); - /* Scrub the password before returning */ - if (proxy_info->proxy_pass != NULL) { - memset(proxy_info->proxy_pass, 0, strlen(proxy_info->proxy_pass)); - g_free(proxy_info->proxy_pass); - proxy_info->proxy_pass = NULL; - } - return ret; - } else if (proxy_info->proxy_type == PROXY_SOCKS4) { - return socks4_connect(sock, hostname, port); - } else { - g_warning("proxy_connect: unknown SOCKS type: %d", - proxy_info->proxy_type); - } - - return -1; -} - -gint socks4_connect(SockInfo *sock, const gchar *hostname, gushort port) -{ - guchar socks_req[1024]; - struct addrinfo hints, *res, *ai; - gboolean got_address = FALSE; - int s; - - g_return_val_if_fail(sock != NULL, -1); - g_return_val_if_fail(hostname != NULL, -1); - - debug_print("socks4_connect: connect to %s:%u\n", hostname, port); - - socks_req[0] = 4; - socks_req[1] = 1; - *((gushort *)(socks_req + 2)) = htons(port); - - /* lookup */ - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_INET; /* SOCKS4 only supports IPv4 addresses */ - - s = getaddrinfo(hostname, NULL, &hints, &res); - if (s != 0) { - fprintf(stderr, "getaddrinfo for '%s' failed: %s\n", - hostname, gai_strerror(s)); - return -1; - } - - for (ai = res; ai != NULL; ai = ai->ai_next) { - uint32_t addr; - - if (ai->ai_family != AF_INET) - continue; - - addr = ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr; - memcpy(socks_req + 4, &addr, 4); - got_address = TRUE; - break; - } - - if (res != NULL) - freeaddrinfo(res); - - if (!got_address) { - g_warning("socks4_connect: could not get valid IPv4 address for '%s'", hostname); - return -1; - } - - debug_print("got a valid IPv4 address, continuing\n"); - - /* userid (empty) */ - socks_req[8] = 0; - - if (sock_write_all(sock, (gchar *)socks_req, 9) != 9) { - g_warning("socks4_connect: SOCKS4 initial request write failed"); - return -1; - } - - if (sock_read(sock, (gchar *)socks_req, 8) != 8) { - g_warning("socks4_connect: SOCKS4 response read failed"); - return -1; - } - if (socks_req[0] != 0) { - g_warning("socks4_connect: SOCKS4 response has invalid version"); - return -1; - } - if (socks_req[1] != 90) { - g_warning("socks4_connect: SOCKS4 connection to %u.%u.%u.%u:%u failed. (%u)", socks_req[4], socks_req[5], socks_req[6], socks_req[7], ntohs(*(gushort *)(socks_req + 2)), socks_req[1]); - return -1; - } - - /* replace sock->hostname with endpoint */ - if (sock->hostname != hostname) { - g_free(sock->hostname); - sock->hostname = g_strdup(hostname); - sock->port = port; - } - - debug_print("socks4_connect: SOCKS4 connection to %s:%u successful.\n", hostname, port); - - return 0; -} - -gint socks5_connect(SockInfo *sock, const gchar *hostname, gushort port, - const gchar *proxy_name, const gchar *proxy_pass) -{ - guchar socks_req[1024]; - size_t len; - size_t size; - - g_return_val_if_fail(sock != NULL, -1); - g_return_val_if_fail(hostname != NULL, -1); - - debug_print("socks5_connect: connect to %s:%u\n", hostname, port); - - len = strlen(hostname); - if (len > 255) { - g_warning("socks5_connect: hostname too long"); - return -1; - } - - socks_req[0] = 5; - socks_req[1] = proxy_name ? 2 : 1; - socks_req[2] = 0; - socks_req[3] = 2; - - if (sock_write_all(sock, (gchar *)socks_req, 2 + socks_req[1]) != 2 + socks_req[1]) { - g_warning("socks5_connect: SOCKS5 initial request write failed"); - return -1; - } - - if (sock_read(sock, (gchar *)socks_req, 2) != 2) { - g_warning("socks5_connect: SOCKS5 response read failed"); - return -1; - } - if (socks_req[0] != 5) { - g_warning("socks5_connect: SOCKS5 response has invalid version"); - return -1; - } - if (socks_req[1] == 2) { - /* auth */ - size_t userlen, passlen; - gint reqlen; - - if (proxy_name && proxy_pass) { - debug_print("socks5_connect: auth using username '%s'\n", proxy_name); - userlen = strlen(proxy_name); - passlen = strlen(proxy_pass); - } else - userlen = passlen = 0; - - socks_req[0] = 1; - socks_req[1] = (guchar)userlen; - if (proxy_name && userlen > 0) - memcpy(socks_req + 2, proxy_name, userlen); - socks_req[2 + userlen] = (guchar)passlen; - if (proxy_pass && passlen > 0) - memcpy(socks_req + 2 + userlen + 1, proxy_pass, passlen); - - reqlen = 2 + userlen + 1 + passlen; - if (sock_write_all(sock, (gchar *)socks_req, reqlen) != reqlen) { - memset(socks_req, 0, reqlen); - g_warning("socks5_connect: SOCKS5 auth write failed"); - return -1; - } - memset(socks_req, 0, reqlen); - if (sock_read(sock, (gchar *)socks_req, 2) != 2) { - g_warning("socks5_connect: SOCKS5 auth response read failed"); - return -1; - } - if (socks_req[1] != 0) { - g_warning("socks5_connect: SOCKS5 authentication failed: user: %s (%u %u)", proxy_name ? proxy_name : "(none)", socks_req[0], socks_req[1]); - return -1; - } - } else if (socks_req[1] != 0) { - g_warning("socks5_connect: SOCKS5 reply (%u) error", socks_req[1]); - return -1; - } - - socks_req[0] = 5; - socks_req[1] = 1; - socks_req[2] = 0; - - socks_req[3] = 3; - socks_req[4] = (guchar)len; - memcpy(socks_req + 5, hostname, len); - *((gushort *)(socks_req + 5 + len)) = htons(port); - - if (sock_write_all(sock, (gchar *)socks_req, 5 + len + 2) != 5 + len + 2) { - g_warning("socks5_connect: SOCKS5 connect request write failed"); - return -1; - } - - if (sock_read(sock, (gchar *)socks_req, 10) != 10) { - g_warning("socks5_connect: SOCKS5 connect request response read failed"); - return -1; - } - if (socks_req[0] != 5) { - g_warning("socks5_connect: SOCKS5 response has invalid version"); - return -1; - } - if (socks_req[1] != 0) { - g_warning("socks5_connect: SOCKS5 connection to %s:%u failed. (%u)", - hostname, port, socks_req[1]); - return -1; - } - - size = 10; - if (socks_req[3] == 3) - size = 5 + socks_req[4] + 2; - else if (socks_req[3] == 4) - size = 4 + 16 + 2; - if (size > 10) { - size -= 10; - if (sock_read(sock, (gchar *)socks_req + 10, size) != size) { - g_warning("socks5_connect: SOCKS5 connect request response read failed"); - return -1; - } - } - - /* replace sock->hostname with endpoint */ - if (sock->hostname != hostname) { - g_free(sock->hostname); - sock->hostname = g_strdup(hostname); - sock->port = port; - } - - debug_print("socks5_connect: SOCKS5 connection to %s:%u successful.\n", hostname, port); - - return 0; -} diff --git a/src/common/proxy.h b/src/common/proxy.h @@ -1,50 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2018 the Claws Mail team - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __PROXY_H__ -#define __PROXY_H__ - -#include <glib.h> - -#include "socket.h" - -typedef struct _ProxyInfo ProxyInfo; - -typedef enum { - PROXY_SOCKS4, - PROXY_SOCKS5 -} ProxyType; - -struct _ProxyInfo -{ - ProxyType proxy_type; - gchar *proxy_host; - gushort proxy_port; - - gboolean use_proxy_auth; - gchar *proxy_name; - gchar *proxy_pass; -}; - -/* As a side effect, this function will zero out and free - * string pointed to by proxy_info->proxy_pass after the password - * is no longer needed. */ -gint proxy_connect(SockInfo *sock, const gchar *hostname, gushort port, - ProxyInfo *proxy_info); - -#endif /* __PROXY_H__ */ diff --git a/src/common/session.c b/src/common/session.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifdef HAVE_CONFIG_H @@ -103,8 +103,6 @@ void session_init(Session *session, const void *prefs_account, gboolean is_smtp) session->is_smtp = is_smtp; session->ping_tag = -1; - - session->proxy_info = NULL; } /*! @@ -125,11 +123,6 @@ gint session_connect(Session *session, const gchar *server, gushort port) session->server = g_strdup(server); session->port = port; - if (session->proxy_info) { - server = session->proxy_info->proxy_host; - port = session->proxy_info->proxy_port; - } - #ifdef G_OS_UNIX session->conn_id = sock_connect_async(server, port, session_connect_cb, session); @@ -178,18 +171,6 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) sock->is_smtp = session->is_smtp; sock->ssl_cert_auto_accept = session->ssl_cert_auto_accept; - if (session->proxy_info) { - debug_print("connecting through socks\n"); - sock_set_nonblocking_mode(sock, FALSE); - if (proxy_connect(sock, session->server, session->port, - session->proxy_info) < 0) { - g_warning("can't establish SOCKS connection"); - session->state = SESSION_ERROR; - return -1; - } - } - - #ifdef USE_GNUTLS sock->gnutls_priority = session->gnutls_priority; sock->use_tls_sni = session->use_tls_sni; @@ -207,7 +188,7 @@ static gint session_connect_cb(SockInfo *sock, gpointer data) } #endif - /* we could have gotten a timeout while waiting for user input in + /* we could have gotten a timeout while waiting for user input in * an SSL certificate dialog */ if (session->state == SESSION_TIMEOUT) { if (session->connect_finished) @@ -585,7 +566,7 @@ static gboolean session_read_msg_cb(SockInfo *source, GIOCondition condition, } return FALSE; } - + if (read_len == 0) { g_warning("sock_read: received EOF"); session->state = SESSION_EOF; diff --git a/src/common/session.h b/src/common/session.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifndef __SESSION_H__ @@ -30,7 +30,6 @@ #include <unistd.h> #include "socket.h" -#include "proxy.h" #define SESSION_BUFFSIZE 4096 @@ -148,14 +147,6 @@ struct _Session gboolean ssl_cert_auto_accept; gint ping_tag; - /* Pointer to ProxyInfo struct holding the info about proxy - * to be used. Set to NULL if no proxy is used. - * If non-NULL, the memory this pointer is pointing at does - * not belong to this Session, and shouldn't be modified - * or freed by Session. It is usually a pointer to the - * SockInfo in common prefs, or in account prefs. */ - ProxyInfo *proxy_info; - #ifdef USE_GNUTLS SSLType ssl_type; gchar *gnutls_priority; @@ -163,7 +154,7 @@ struct _Session #endif }; -void session_init (Session *session, +void session_init (Session *session, const void *prefs_account, gboolean is_smtp); gint session_connect (Session *session, diff --git a/src/compose.c b/src/compose.c @@ -639,38 +639,8 @@ static GtkRadioActionEntry compose_radio_rm_entries[] = static GtkRadioActionEntry compose_radio_enc_entries[] = { ENC_ACTION(CS_AUTO, C_AUTO, N_("_Automatic")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION(CS_US_ASCII, C_US_ASCII, N_("7bit ASCII (US-ASC_II)")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION(CS_UTF_8, C_UTF_8, N_("Unicode (_UTF-8)")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Western/"CS_ISO_8859_1, C_ISO_8859_1, "ISO-8859-_1"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Western/"CS_ISO_8859_15, C_ISO_8859_15, "ISO-8859-15"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Western/"CS_WINDOWS_1252, C_WINDOWS_1252, "Windows-1252"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, N_("Central European (ISO-8859-_2)")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Baltic/"CS_ISO_8859_13, C_ISO_8859_13, "ISO-8859-13"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Baltic/"CS_ISO_8859_4, C_ISO_8859_14, "ISO-8859-_4"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, N_("Greek (ISO-8859-_7)")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Hebrew/"CS_ISO_8859_8, C_ISO_8859_8, "ISO-8859-_8"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Hebrew/"CS_WINDOWS_1255, C_WINDOWS_1255, "Windows-1255"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Arabic/"CS_ISO_8859_6, C_ISO_8859_6, "ISO-8859-_6"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Arabic/"CS_WINDOWS_1256, C_WINDOWS_1256, "Windows-1256"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, N_("Turkish (ISO-8859-_9)")), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Cyrillic/"CS_ISO_8859_5, C_ISO_8859_5, "ISO-8859-_5"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Cyrillic/"CS_KOI8_R, C_KOI8_R, "KOI8-_R"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Cyrillic/"CS_MACCYR, C_MACCYR, "_Mac-Cyrillic"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Cyrillic/"CS_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Cyrillic/"CS_WINDOWS_1251, C_WINDOWS_1251, "Windows-1251"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Japanese/"CS_ISO_2022_JP, C_ISO_2022_JP, "ISO-2022-_JP"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Japanese/"CS_ISO_2022_JP_2, C_ISO_2022_JP_2, "ISO-2022-JP-_2"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Japanese/"CS_EUC_JP, C_EUC_JP, "_EUC-JP"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Japanese/"CS_SHIFT_JIS, C_SHIFT_JIS, "_Shift-JIS"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Chinese/"CS_GB18030, C_GB18030, "_GB18030"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Chinese/"CS_GB2312, C_GB2312, "_GB2312"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Chinese/"CS_GBK, C_GBK, "GB_K"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Chinese/"CS_BIG5, C_BIG5, "_Big5-JP"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Chinese/"CS_EUC_TW, C_EUC_TW, "EUC-_TW"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Korean/"CS_EUC_KR, C_EUC_KR, "_EUC-KR"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Korean/"CS_ISO_2022_KR, C_ISO_2022_KR, "_ISO-2022-KR"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Thai/"CS_TIS_620, C_TIS_620, "_TIS-620-KR"), /* RADIO compose_set_encoding_cb */ - ENC_ACTION("Thai/"CS_WINDOWS_874, C_WINDOWS_874, "_Windows-874"), /* RADIO compose_set_encoding_cb */ + ENC_ACTION(CS_US_ASCII, C_US_ASCII, N_("7bit ASCII (US-ASC_II)")), + ENC_ACTION(CS_UTF_8, C_UTF_8, N_("Unicode (_UTF-8)")), }; static GtkTargetEntry compose_mime_types[] = diff --git a/src/etpan/Makefile.am b/src/etpan/Makefile.am @@ -8,7 +8,6 @@ noinst_LTLIBRARIES = libclawsetpan.la libclawsetpan_la_SOURCES = \ etpan-thread-manager.c \ imap-thread.c \ - nntp-thread.c \ etpan-ssl.c clawsetpanincludedir = $(pkgincludedir)/etpan @@ -17,7 +16,6 @@ clawsetpaninclude_HEADERS = \ etpan-thread-manager.h \ etpan-errors.h \ imap-thread.h \ - nntp-thread.h \ etpan-ssl.h AM_CPPFLAGS = \ diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c @@ -37,7 +37,6 @@ #include "etpan-ssl.h" #include "utils.h" #include "mainwindow.h" -#include "proxy.h" #include "file-utils.h" #include "ssl.h" #include "ssl_certificate.h" @@ -54,91 +53,6 @@ static chash * session_hash = NULL; static guint thread_manager_signal = 0; static GIOChannel * io_channel = NULL; -static int do_mailimap_socket_connect(mailimap * imap, const char * server, - gushort port, ProxyInfo * proxy_info) -{ - SockInfo * sock; - mailstream * stream; - - if (!proxy_info) - return mailimap_socket_connect(imap, server, port); - - if (port == 0) - port = 143; - - sock = sock_connect(proxy_info->proxy_host, proxy_info->proxy_port); - - if (sock == NULL) - return MAILIMAP_ERROR_CONNECTION_REFUSED; - - if (proxy_connect(sock, server, port, proxy_info) < 0) { - sock_close(sock, TRUE); - return MAILIMAP_ERROR_CONNECTION_REFUSED; - } - - stream = mailstream_socket_open_timeout(sock->sock, - imap->imap_timeout); - if (stream == NULL) { - sock_close(sock, TRUE); - return MAILIMAP_ERROR_MEMORY; - } - - /* Libetpan now has the socket fd, and we're not interested in - * rest of the SockInfo struct. Let's free it, while not touching - * the socket itself. */ - sock_close(sock, FALSE); - - return mailimap_connect(imap, stream); -} - -#ifdef USE_GNUTLS -static int do_mailimap_ssl_connect_with_callback(mailimap * imap, const char * server, - gushort port, - void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), - void * data, - ProxyInfo *proxy_info) -{ - SockInfo * sock; - mailstream * stream; - - if (!proxy_info) - return mailimap_ssl_connect_with_callback(imap, server, - port, callback, data); - - if (port == 0) - port = 993; - - sock = sock_connect(proxy_info->proxy_host, proxy_info->proxy_port); - - if (sock == NULL) { - debug_print("Can not connect to proxy %s:%d\n", - proxy_info->proxy_host, proxy_info->proxy_port); - return MAILIMAP_ERROR_CONNECTION_REFUSED; - } - - if (proxy_connect(sock, server, port, proxy_info) < 0) { - debug_print("Can not make proxy connection via %s:%d\n", - proxy_info->proxy_host, proxy_info->proxy_port); - sock_close(sock, TRUE); - return MAILIMAP_ERROR_CONNECTION_REFUSED; - } - - stream = mailstream_ssl_open_with_callback_timeout(sock->sock, - imap->imap_timeout, callback, data); - if (stream == NULL) { - sock_close(sock, TRUE); - return MAILIMAP_ERROR_SSL; - } - - /* Libetpan now has the socket fd, and we're not interested in - * rest of the SockInfo struct. Let's free it, while not touching - * the socket itself. */ - sock_close(sock, FALSE); - - return mailimap_connect(imap, stream); -} -#endif - static gboolean thread_manager_event(GIOChannel * source, GIOCondition condition, gpointer data) @@ -515,7 +429,6 @@ struct connect_param { PrefsAccount *account; const char * server; int port; - ProxyInfo * proxy_info; }; struct connect_result { @@ -589,14 +502,13 @@ static void connect_run(struct etpan_thread_op * op) CHECK_IMAP(); - r = do_mailimap_socket_connect(param->imap, - param->server, param->port, param->proxy_info); + r = mailimap_socket_connect(param->imap, param->server, param->port); result->error = r; } -int imap_threaded_connect(Folder * folder, const char * server, int port, ProxyInfo *proxy_info) +int imap_threaded_connect(Folder * folder, const char * server, int port) { struct connect_param param; struct connect_result result; @@ -622,7 +534,6 @@ int imap_threaded_connect(Folder * folder, const char * server, int port, ProxyI param.imap = imap; param.server = server; param.port = port; - param.proxy_info = proxy_info; refresh_resolvers(); threaded_run(folder, &param, &result, connect_run); @@ -643,14 +554,11 @@ static void connect_ssl_run(struct etpan_thread_op * op) CHECK_IMAP(); - r = do_mailimap_ssl_connect_with_callback(param->imap, - param->server, param->port, - etpan_connect_ssl_context_cb, param->account, - param->proxy_info); + r = mailimap_ssl_connect_with_callback(param->imap, param->server, param->port, etpan_connect_ssl_context_cb, param->account); result->error = r; } -int imap_threaded_connect_ssl(Folder * folder, const char * server, int port, ProxyInfo *proxy_info) +int imap_threaded_connect_ssl(Folder * folder, const char * server, int port) { struct connect_param param; struct connect_result result; @@ -678,7 +586,6 @@ int imap_threaded_connect_ssl(Folder * folder, const char * server, int port, Pr param.server = server; param.port = port; param.account = folder->account; - param.proxy_info = proxy_info; if (folder->account) accept_if_valid = folder->account->ssl_certs_auto_accept; diff --git a/src/etpan/imap-thread.h b/src/etpan/imap-thread.h @@ -43,8 +43,8 @@ void imap_main_done(gboolean have_connectivity); void imap_init(Folder * folder); void imap_done(Folder * folder); -int imap_threaded_connect(Folder * folder, const char * server, int port, ProxyInfo *proxy_info); -int imap_threaded_connect_ssl(Folder * folder, const char * server, int port, ProxyInfo *proxy_info); +int imap_threaded_connect(Folder * folder, const char * server, int port); +int imap_threaded_connect_ssl(Folder * folder, const char * server, int port); int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** caps); int imap_threaded_connect_cmd(Folder * folder, const char * command, diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c @@ -1,1064 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2005-2022 the Claws Mail team and DINH Viet Hoa - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#include "claws-features.h" -#endif - -#include <glib.h> -#include <glib/gi18n.h> -#include "nntp-thread.h" -#include "news.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <sys/wait.h> -#include <gtk/gtk.h> -#include <log.h> -#include "etpan-thread-manager.h" -#include "etpan-ssl.h" -#include "utils.h" -#include "mainwindow.h" -#include "ssl_certificate.h" -#include "socket.h" -#include "remotefolder.h" -#include "main.h" -#include "account.h" -#include "statusbar.h" - -#define DISABLE_LOG_DURING_LOGIN - -#define NNTP_BATCH_SIZE 5000 - -static struct etpan_thread_manager * thread_manager = NULL; -static chash * nntp_hash = NULL; -static chash * session_hash = NULL; -static guint thread_manager_signal = 0; -static GIOChannel * io_channel = NULL; - -static int do_newsnntp_socket_connect(newsnntp * imap, const char * server, - gushort port, ProxyInfo * proxy_info) -{ - SockInfo * sock; - mailstream * stream; - - if (!proxy_info) - return newsnntp_socket_connect(imap, server, port); - - if (port == 0) - port = 119; - - sock = sock_connect(proxy_info->proxy_host, proxy_info->proxy_port); - - if (sock == NULL) - return NEWSNNTP_ERROR_CONNECTION_REFUSED; - - if (proxy_connect(sock, server, port, proxy_info) < 0) { - sock_close(sock, TRUE); - return NEWSNNTP_ERROR_CONNECTION_REFUSED; - } - - stream = mailstream_socket_open_timeout(sock->sock, - imap->nntp_timeout); - if (stream == NULL) { - sock_close(sock, TRUE); - return NEWSNNTP_ERROR_MEMORY; - } - - /* Libetpan now has the socket fd, and we're not interested in - * rest of the SockInfo struct. Let's free it, while not touching - * the socket itself. */ - sock_close(sock, FALSE); - - return newsnntp_connect(imap, stream); -} - -#ifdef USE_GNUTLS -static int do_newsnntp_ssl_connect_with_callback(newsnntp * imap, const char * server, - gushort port, - void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), - void * data, - ProxyInfo *proxy_info) -{ - SockInfo * sock; - mailstream * stream; - - if (!proxy_info) - return newsnntp_ssl_connect_with_callback(imap, server, - port, callback, data); - - if (port == 0) - port = 563; - - sock = sock_connect(proxy_info->proxy_host, proxy_info->proxy_port); - - if (sock == NULL) - return NEWSNNTP_ERROR_CONNECTION_REFUSED; - - if (proxy_connect(sock, server, port, proxy_info) < 0) { - sock_close(sock, TRUE); - return NEWSNNTP_ERROR_CONNECTION_REFUSED; - } - - stream = mailstream_ssl_open_with_callback_timeout(sock->sock, - imap->nntp_timeout, callback, data); - if (stream == NULL) { - sock_close(sock, TRUE); - return NEWSNNTP_ERROR_SSL; - } - - /* Libetpan now has the socket fd, and we're not interested in - * rest of the SockInfo struct. Let's free it, while not touching - * the socket itself. */ - sock_close(sock, FALSE); - - return newsnntp_connect(imap, stream); -} -#endif - -static void nntp_logger(int direction, const char * str, size_t size) -{ - gchar *buf; - gchar **lines; - int i = 0; - - if (size > 256) { - log_print(LOG_PROTOCOL, "NNTP%c [data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size); - return; - } - buf = malloc(size+1); - memset(buf, 0, size+1); - strncpy(buf, str, size); - buf[size] = '\0'; - - if (!strncmp(buf, "<<<<<<<", 7) - || !strncmp(buf, ">>>>>>>", 7)) { - free(buf); - return; - } - while (strstr(buf, "\r")) - *strstr(buf, "\r") = ' '; - while (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') - buf[strlen(buf)-1] = '\0'; - - lines = g_strsplit(buf, "\n", -1); - - while (lines[i] && *lines[i]) { - log_print(LOG_PROTOCOL, "NNTP%c %s\n", direction?'>':'<', lines[i]); - i++; - } - g_strfreev(lines); - free(buf); -} - -static void delete_nntp(Folder *folder, newsnntp *nntp) -{ - chashdatum key; - - key.data = &folder; - key.len = sizeof(folder); - chash_delete(session_hash, &key, NULL); - - key.data = &nntp; - key.len = sizeof(nntp); - if (nntp && nntp->nntp_stream) { - /* we don't want libetpan to logout */ - mailstream_close(nntp->nntp_stream); - nntp->nntp_stream = NULL; - } - debug_print("removing newsnntp %p\n", nntp); - newsnntp_free(nntp); -} - -static gboolean thread_manager_event(GIOChannel * source, - GIOCondition condition, - gpointer data) -{ - etpan_thread_manager_loop(thread_manager); - return TRUE; -} - -#define ETPAN_DEFAULT_NETWORK_TIMEOUT 60 -extern gboolean etpan_skip_ssl_cert_check; - -void nntp_main_init(gboolean skip_ssl_cert_check) -{ - int fd_thread_manager; - - etpan_skip_ssl_cert_check = skip_ssl_cert_check; - - nntp_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); - session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); - - thread_manager = etpan_thread_manager_new(); - - fd_thread_manager = etpan_thread_manager_get_fd(thread_manager); - - io_channel = g_io_channel_unix_new(fd_thread_manager); - - thread_manager_signal = g_io_add_watch_full(io_channel, 0, G_IO_IN, - thread_manager_event, - (gpointer) NULL, - NULL); -} - -void nntp_main_done(gboolean have_connectivity) -{ - nntp_disconnect_all(have_connectivity); - etpan_thread_manager_stop(thread_manager); -#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) - return; -#endif - etpan_thread_manager_join(thread_manager); - - g_source_remove(thread_manager_signal); - g_io_channel_unref(io_channel); - - etpan_thread_manager_free(thread_manager); - - chash_free(session_hash); - chash_free(nntp_hash); -} - -void nntp_init(Folder * folder) -{ - struct etpan_thread * thread; - chashdatum key; - chashdatum value; - - thread = etpan_thread_manager_get_thread(thread_manager); - - key.data = &folder; - key.len = sizeof(folder); - value.data = thread; - value.len = 0; - - chash_set(nntp_hash, &key, &value, NULL); -} - -void nntp_done(Folder * folder) -{ - struct etpan_thread * thread; - chashdatum key; - chashdatum value; - int r; - - key.data = &folder; - key.len = sizeof(folder); - - r = chash_get(nntp_hash, &key, &value); - if (r < 0) - return; - - thread = value.data; - - etpan_thread_unbind(thread); - - chash_delete(nntp_hash, &key, NULL); - - debug_print("remove thread\n"); -} - -static struct etpan_thread * get_thread(Folder * folder) -{ - struct etpan_thread * thread; - chashdatum key; - chashdatum value; - int r; - - key.data = &folder; - key.len = sizeof(folder); - - r = chash_get(nntp_hash, &key, &value); - if (r < 0) - return NULL; - - thread = value.data; - - return thread; -} - -static newsnntp * get_nntp(Folder * folder) -{ - newsnntp * nntp; - chashdatum key; - chashdatum value; - int r; - - key.data = &folder; - key.len = sizeof(folder); - - r = chash_get(session_hash, &key, &value); - if (r < 0) - return NULL; - - nntp = value.data; - debug_print("found nntp %p\n", nntp); - return nntp; -} - - -static void generic_cb(int cancelled, void * result, void * callback_data) -{ - struct etpan_thread_op * op; - - op = (struct etpan_thread_op *) callback_data; - - debug_print("generic_cb\n"); - op->finished = 1; -} - -static void threaded_run(Folder * folder, void * param, void * result, - void (* func)(struct etpan_thread_op * )) -{ - struct etpan_thread_op * op; - struct etpan_thread * thread; - void (*previous_stream_logger)(int direction, - const char * str, size_t size); - - nntp_folder_ref(folder); - - op = etpan_thread_op_new(); - - op->nntp = get_nntp(folder); - op->param = param; - op->result = result; - - op->run = func; - op->callback = generic_cb; - op->callback_data = op; - - previous_stream_logger = mailstream_logger; - mailstream_logger = nntp_logger; - - thread = get_thread(folder); - etpan_thread_op_schedule(thread, op); - - while (!op->finished) { - gtk_main_iteration(); - } - - mailstream_logger = previous_stream_logger; - - etpan_thread_op_free(op); - - nntp_folder_unref(folder); -} - - -/* connect */ - -struct connect_param { - newsnntp * nntp; - PrefsAccount *account; - const char * server; - int port; - ProxyInfo * proxy_info; -}; - -struct connect_result { - int error; -}; - -#define CHECK_NNTP() { \ - if (!param->nntp) { \ - result->error = NEWSNNTP_ERROR_BAD_STATE; \ - return; \ - } \ -} - -static void connect_run(struct etpan_thread_op * op) -{ - int r; - struct connect_param * param; - struct connect_result * result; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = do_newsnntp_socket_connect(param->nntp, - param->server, param->port, - param->proxy_info); - - result->error = r; -} - - -int nntp_threaded_connect(Folder * folder, const char * server, int port, ProxyInfo *proxy_info) -{ - struct connect_param param; - struct connect_result result; - chashdatum key; - chashdatum value; - newsnntp * nntp, * oldnntp; - - oldnntp = get_nntp(folder); - - nntp = newsnntp_new(0, NULL); - - if (oldnntp) { - debug_print("deleting old nntp %p\n", oldnntp); - delete_nntp(folder, oldnntp); - } - - key.data = &folder; - key.len = sizeof(folder); - value.data = nntp; - value.len = 0; - chash_set(session_hash, &key, &value, NULL); - - param.nntp = nntp; - param.server = server; - param.port = port; - param.proxy_info = proxy_info; - - refresh_resolvers(); - threaded_run(folder, &param, &result, connect_run); - - debug_print("connect ok %i with nntp %p\n", result.error, nntp); - - return result.error; -} -#ifdef USE_GNUTLS -static void connect_ssl_run(struct etpan_thread_op * op) -{ - int r; - struct connect_param * param; - struct connect_result * result; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = do_newsnntp_ssl_connect_with_callback(param->nntp, - param->server, param->port, - etpan_connect_ssl_context_cb, param->account, - param->proxy_info); - result->error = r; -} - -int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port, ProxyInfo *proxy_info) -{ - struct connect_param param; - struct connect_result result; - chashdatum key; - chashdatum value; - newsnntp * nntp, * oldnntp; - gboolean accept_if_valid = FALSE; - - oldnntp = get_nntp(folder); - - nntp = newsnntp_new(0, NULL); - - if (oldnntp) { - debug_print("deleting old nntp %p\n", oldnntp); - delete_nntp(folder, oldnntp); - } - - key.data = &folder; - key.len = sizeof(folder); - value.data = nntp; - value.len = 0; - chash_set(session_hash, &key, &value, NULL); - - param.nntp = nntp; - param.server = server; - param.port = port; - param.account = folder->account; - param.proxy_info = proxy_info; - - if (folder->account) - accept_if_valid = folder->account->ssl_certs_auto_accept; - - refresh_resolvers(); - threaded_run(folder, &param, &result, connect_ssl_run); - - if (result.error == NEWSNNTP_NO_ERROR && !etpan_skip_ssl_cert_check) { - if (etpan_certificate_check(nntp->nntp_stream, server, port, - accept_if_valid) != TRUE) - return -1; - } - debug_print("connect %d with nntp %p\n", result.error, nntp); - - return result.error; -} -#endif - -void nntp_threaded_disconnect(Folder * folder) -{ - newsnntp * nntp; - - nntp = get_nntp(folder); - if (nntp == NULL) { - debug_print("was disconnected\n"); - return; - } - - debug_print("deleting old nntp %p\n", nntp); - delete_nntp(folder, nntp); - - debug_print("disconnect ok\n"); -} - -void nntp_threaded_cancel(Folder * folder) -{ - newsnntp * nntp; - - nntp = get_nntp(folder); - if (nntp->nntp_stream != NULL) - mailstream_cancel(nntp->nntp_stream); -} - - -struct login_param { - newsnntp * nntp; - const char * login; - const char * password; -}; - -struct login_result { - int error; -}; - -static void login_run(struct etpan_thread_op * op) -{ - struct login_param * param; - struct login_result * result; - int r; -#ifdef DISABLE_LOG_DURING_LOGIN - int old_debug; -#endif - - param = op->param; - result = op->result; - - CHECK_NNTP(); - -#ifdef DISABLE_LOG_DURING_LOGIN - old_debug = mailstream_debug; - mailstream_debug = 0; -#endif - - r = newsnntp_authinfo_username(param->nntp, param->login); - /* libetpan returning NO_ERROR means it received resp.code 281: - in this case auth. is already successful, no password is needed. */ - if (r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) { - r = newsnntp_authinfo_password(param->nntp, param->password); - } - - - -#ifdef DISABLE_LOG_DURING_LOGIN - mailstream_debug = old_debug; -#endif - - result->error = r; - if (param->nntp->nntp_response) - nntp_logger(0, param->nntp->nntp_response, strlen(param->nntp->nntp_response)); - - debug_print("nntp login run - end %i\n", r); -} - -int nntp_threaded_login(Folder * folder, const char * login, const char * password) -{ - struct login_param param; - struct login_result result; - - debug_print("nntp login - begin\n"); - - param.nntp = get_nntp(folder); - param.login = login; - param.password = password; - - threaded_run(folder, &param, &result, login_run); - - debug_print("nntp login - end\n"); - - return result.error; -} - -struct date_param { - newsnntp * nntp; - struct tm * lt; -}; - -struct date_result { - int error; -}; - -static void date_run(struct etpan_thread_op * op) -{ - struct date_param * param; - struct date_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_date(param->nntp, param->lt); - - result->error = r; - debug_print("nntp date run - end %i\n", r); -} - -int nntp_threaded_date(Folder * folder, struct tm *lt) -{ - struct date_param param; - struct date_result result; - - debug_print("nntp date - begin\n"); - - param.nntp = get_nntp(folder); - param.lt = lt; - - threaded_run(folder, &param, &result, date_run); - - debug_print("nntp date - end\n"); - - return result.error; -} - -struct list_param { - newsnntp * nntp; - clist **grouplist; -}; - -struct list_result { - int error; -}; - -static void list_run(struct etpan_thread_op * op) -{ - struct list_param * param; - struct list_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_list(param->nntp, param->grouplist); - - result->error = r; - debug_print("nntp list run - end %i\n", r); -} - -int nntp_threaded_list(Folder * folder, clist **grouplist) -{ - struct list_param param; - struct list_result result; - - debug_print("nntp list - begin\n"); - - param.nntp = get_nntp(folder); - param.grouplist = grouplist; - - threaded_run(folder, &param, &result, list_run); - - debug_print("nntp list - end\n"); - - return result.error; -} - -struct post_param { - newsnntp * nntp; - char *contents; - size_t len; -}; - -struct post_result { - int error; -}; - -static void post_run(struct etpan_thread_op * op) -{ - struct post_param * param; - struct post_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_post(param->nntp, param->contents, param->len); - - result->error = r; - debug_print("nntp post run - end %i\n", r); -} - -int nntp_threaded_post(Folder * folder, char *contents, size_t len) -{ - struct post_param param; - struct post_result result; - - debug_print("nntp post - begin\n"); - - param.nntp = get_nntp(folder); - param.contents = contents; - param.len = len; - - threaded_run(folder, &param, &result, post_run); - - debug_print("nntp post - end\n"); - - return result.error; -} - -struct article_param { - newsnntp * nntp; - guint32 num; - char **contents; - size_t *len; -}; - -struct article_result { - int error; -}; - -static void article_run(struct etpan_thread_op * op) -{ - struct article_param * param; - struct article_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_article(param->nntp, param->num, param->contents, param->len); - - result->error = r; - debug_print("nntp article run - end %i\n", r); -} - -int nntp_threaded_article(Folder * folder, guint32 num, char **contents, size_t *len) -{ - struct article_param param; - struct article_result result; - - debug_print("nntp article - begin\n"); - - param.nntp = get_nntp(folder); - param.num = num; - param.contents = contents; - param.len = len; - - threaded_run(folder, &param, &result, article_run); - - debug_print("nntp article - end\n"); - - return result.error; -} - -struct group_param { - newsnntp * nntp; - const char *group; - struct newsnntp_group_info **info; -}; - -struct group_result { - int error; -}; - -static void group_run(struct etpan_thread_op * op) -{ - struct group_param * param; - struct group_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_group(param->nntp, param->group, param->info); - - result->error = r; - debug_print("nntp group run - end %i\n", r); -} - -int nntp_threaded_group(Folder * folder, const char *group, struct newsnntp_group_info **info) -{ - struct group_param param; - struct group_result result; - - debug_print("nntp group - begin\n"); - - param.nntp = get_nntp(folder); - param.group = group; - param.info = info; - - threaded_run(folder, &param, &result, group_run); - - debug_print("nntp group - end\n"); - - return result.error; -} - -struct mode_reader_param { - newsnntp * nntp; -}; - -struct mode_reader_result { - int error; -}; - -static void mode_reader_run(struct etpan_thread_op * op) -{ - struct mode_reader_param * param; - struct mode_reader_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - r = newsnntp_mode_reader(param->nntp); - - result->error = r; - debug_print("nntp mode_reader run - end %i\n", r); -} - -int nntp_threaded_mode_reader(Folder * folder) -{ - struct mode_reader_param param; - struct mode_reader_result result; - - debug_print("nntp mode_reader - begin\n"); - - param.nntp = get_nntp(folder); - - threaded_run(folder, &param, &result, mode_reader_run); - - debug_print("nntp mode_reader - end\n"); - - return result.error; -} - -struct xover_param { - newsnntp * nntp; - guint32 beg; - guint32 end; - struct newsnntp_xover_resp_item **result; - clist **msglist; -}; - -struct xover_result { - int error; -}; - -static void xover_run(struct etpan_thread_op * op) -{ - struct xover_param * param; - struct xover_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - if (param->result) { - r = newsnntp_xover_single(param->nntp, param->beg, param->result); - } else { - r = newsnntp_xover_range(param->nntp, param->beg, param->end, param->msglist); - } - - result->error = r; - debug_print("nntp xover run %d-%d - end %i\n", - param->beg, param->end, r); -} - -int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnntp_xover_resp_item **single_result, clist **multiple_result) -{ - struct xover_param param; - struct xover_result result; - clist *l = NULL, *h = NULL; - guint32 cbeg = 0, cend = 0; - - debug_print("nntp xover - begin (%d-%d)\n", beg, end); - - h = clist_new(); - - /* Request the overview in batches of NNTP_BATCH_SIZE, to prevent - * long stalls or libetpan choking on too large server response, - * and to allow updating any progress indicators while we work. */ - cbeg = beg; - while (cbeg <= end && cend <= end) { - cend = cbeg + (NNTP_BATCH_SIZE - 1); - if (cend > end) - cend = end; - - statusbar_progress_all(cbeg - beg, end - beg, 1); - GTK_EVENTS_FLUSH(); - - param.nntp = get_nntp(folder); - param.beg = cbeg; - param.end = cend; - param.result = single_result; - param.msglist = &l; - - threaded_run(folder, &param, &result, xover_run); - - /* Handle errors */ - if (result.error != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xover range\n")); - debug_print("couldn't get xover for %d-%d\n", cbeg, cend); - if (l != NULL) - newsnntp_xover_resp_list_free(l); - newsnntp_xover_resp_list_free(h); - statusbar_progress_all(0, 0, 0); - return result.error; - } - - /* Append the new data (l) to list of results (h). */ - if (l != NULL) { - debug_print("total items so far %d, items this batch %d\n", - clist_count(h), clist_count(l)); - clist_concat(h, l); - clist_free(l); - l = NULL; - } - - cbeg += NNTP_BATCH_SIZE; - } - - statusbar_progress_all(0, 0, 0); - - debug_print("nntp xover - end\n"); - - *multiple_result = h; - - return result.error; -} - -struct xhdr_param { - newsnntp * nntp; - const char *header; - guint32 beg; - guint32 end; - clist **hdrlist; -}; - -struct xhdr_result { - int error; -}; - -static void xhdr_run(struct etpan_thread_op * op) -{ - struct xhdr_param * param; - struct xhdr_result * result; - int r; - - param = op->param; - result = op->result; - - CHECK_NNTP(); - - if (param->beg == param->end) { - r = newsnntp_xhdr_single(param->nntp, param->header, param->beg, param->hdrlist); - } else { - r = newsnntp_xhdr_range(param->nntp, param->header, param->beg, param->end, param->hdrlist); - } - - result->error = r; - debug_print("nntp xhdr '%s %d-%d' run - end %i\n", - param->header, param->beg, param->end, r); -} - -int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 end, clist **hdrlist) -{ - struct xhdr_param param; - struct xhdr_result result; - clist *l = NULL; - clist *h = *hdrlist; - guint32 cbeg = 0, cend = 0; - - debug_print("nntp xhdr %s - begin (%d-%d)\n", header, beg, end); - - if (h == NULL) - h = clist_new(); - - /* Request the headers in batches of NNTP_BATCH_SIZE, to prevent - * long stalls or libetpan choking on too large server response, - * and to allow updating any progress indicators while we work. */ - cbeg = beg; - while (cbeg <= end && cend <= end) { - cend = cbeg + NNTP_BATCH_SIZE - 1; - if (cend > end) - cend = end; - - statusbar_progress_all(cbeg - beg, end - beg, 1); - GTK_EVENTS_FLUSH(); - - param.nntp = get_nntp(folder); - param.header = header; - param.beg = cbeg; - param.end = cend; - param.hdrlist = &l; - - threaded_run(folder, &param, &result, xhdr_run); - - /* Handle errors */ - if (result.error != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xhdr range\n")); - debug_print("couldn't get xhdr %s %d-%d\n", header, cbeg, cend); - if (l != NULL) - newsnntp_xhdr_free(l); - newsnntp_xhdr_free(h); - statusbar_progress_all(0, 0, 0); - return result.error; - } - - /* Append the new data (l) to list of results (h). */ - if (l != NULL) { - debug_print("total items so far %d, items this batch %d\n", - clist_count(h), clist_count(l)); - clist_concat(h, l); - clist_free(l); - l = NULL; - } - - cbeg += NNTP_BATCH_SIZE; - } - - statusbar_progress_all(0, 0, 0); - - debug_print("nntp xhdr %s - end (%d-%d)\n", header, beg, end); - - *hdrlist = h; - - return result.error; -} - -void nntp_main_set_timeout(int sec) -{ - mailstream_network_delay.tv_sec = sec; - mailstream_network_delay.tv_usec = 0; -} diff --git a/src/etpan/nntp-thread.h b/src/etpan/nntp-thread.h @@ -1,52 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2005-2012 DINH Viet Hoa and the Claws Mail team - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef NNTP_THREAD_H - -#define NNTP_THREAD_H - -#include <libetpan/libetpan.h> -#include "folder.h" -#include "proxy.h" - -void nntp_main_set_timeout(int sec); -void nntp_main_init(gboolean skip_ssl_cert_check); -void nntp_main_done(gboolean have_connectivity); - -void nntp_init(Folder * folder); -void nntp_done(Folder * folder); - -int nntp_threaded_connect(Folder * folder, const char * server, int port, ProxyInfo *proxy_info); -int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port, ProxyInfo *proxy_info); - -void nntp_threaded_disconnect(Folder * folder); - -void nntp_threaded_cancel(Folder * folder); - -int nntp_threaded_login(Folder * folder, const char * login, const char * password); -int nntp_threaded_date(Folder * folder, struct tm *lt); -int nntp_threaded_list(Folder * folder, clist **grouplist); -int nntp_threaded_post(Folder * folder, char *contents, size_t len); -int nntp_threaded_article(Folder * folder, guint32 num, char **contents, size_t *len); -int nntp_threaded_group(Folder * folder, const char *group, struct newsnntp_group_info **info); -int nntp_threaded_mode_reader(Folder * folder); -int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnntp_xover_resp_item **single_result, clist **multiple_result); -int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 end, clist **hdrlist); - -#endif diff --git a/src/imap.c b/src/imap.c @@ -1198,7 +1198,6 @@ static IMAPSession *imap_session_new(Folder * folder, const PrefsAccount *account) { IMAPSession *session; - ProxyInfo *proxy_info = NULL; gushort port; int r; int authenticated = FALSE; @@ -1237,43 +1236,17 @@ static IMAPSession *imap_session_new(Folder * folder, log_message(LOG_PROTOCOL, "%s\n", buf); g_free(buf); - if (account->use_proxy) { - if (account->use_default_proxy) { - proxy_info = (ProxyInfo *)&(prefs_common.proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get(PWS_CORE, PWS_CORE_PROXY, - PWS_CORE_PROXY_PASS); - } else { - proxy_info = (ProxyInfo *)&(account->proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get_account(account->account_id, - PWS_ACCOUNT_PROXY_PASS); - } - } - if (account->set_tunnelcmd) { r = imap_threaded_connect_cmd(folder, account->tunnelcmd, account->recv_server, port); } - else - { -#ifdef USE_GNUTLS - + else { if (ssl_type == SSL_TUNNEL) { - r = imap_threaded_connect_ssl(folder, - account->recv_server, - port, - proxy_info); - } - else -#endif - { - r = imap_threaded_connect(folder, - account->recv_server, - port, - proxy_info); + r = imap_threaded_connect_ssl(folder, account->recv_server, port); + } else { + r = imap_threaded_connect(folder, account->recv_server, port); } } @@ -1309,7 +1282,6 @@ static IMAPSession *imap_session_new(Folder * folder, SESSION(session)->server = g_strdup(account->recv_server); SESSION(session)->port = port; SESSION(session)->sock = NULL; - SESSION(session)->proxy_info = proxy_info; SESSION(session)->destroy = imap_session_destroy; session->capability = NULL; diff --git a/src/inc.c b/src/inc.c @@ -39,7 +39,6 @@ #include "prefs_account.h" #include "account.h" #include "procmsg.h" -#include "proxy.h" #include "socket.h" #include "ssl.h" #include "pop.h" @@ -838,7 +837,6 @@ static IncState inc_pop3_session_do(IncSession *session) gchar *account_name; gushort port; gchar *buf; - ProxyInfo *proxy_info = NULL; debug_print("getting new messages of account %s...\n", ac->account_name); @@ -881,21 +879,6 @@ static IncState inc_pop3_session_do(IncSession *session) progress_dialog_set_label(inc_dialog->dialog, buf); - if (ac->use_proxy) { - if (ac->use_default_proxy) { - proxy_info = (ProxyInfo *)&(prefs_common.proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get(PWS_CORE, PWS_CORE_PROXY, - PWS_CORE_PROXY_PASS); - } else { - proxy_info = (ProxyInfo *)&(ac->proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get_account(ac->account_id, - PWS_ACCOUNT_PROXY_PASS); - } - } - SESSION(pop3_session)->proxy_info = proxy_info; - GTK_EVENTS_FLUSH(); g_free(buf); diff --git a/src/main.c b/src/main.c @@ -65,7 +65,6 @@ #include "prefs_summaries.h" #include "prefs_themes.h" #include "prefs_other.h" -#include "prefs_proxy.h" #include "prefs_logging.h" #include "prefs_send.h" #include "prefs_wrapping.h" @@ -107,7 +106,6 @@ #endif #include "imap-thread.h" -#include "nntp-thread.h" #include "stock_pixmap.h" #ifdef USE_GNUTLS # include "ssl.h" @@ -502,7 +500,6 @@ int main(int argc, char *argv[]) prefs_summaries_init(); prefs_message_init(); prefs_other_init(); - prefs_proxy_init(); prefs_logging_init(); prefs_receive_init(); prefs_send_init(); @@ -549,7 +546,6 @@ int main(int argc, char *argv[]) imap_main_init(prefs_common.skip_ssl_cert_check); imap_main_set_timeout(prefs_common.io_timeout_secs); - nntp_main_init(prefs_common.skip_ssl_cert_check); /* If we can't read a folder list or don't have accounts, * it means the configuration's not done. Either this is * a brand new install, a failed/refused migration, @@ -792,7 +788,6 @@ static void exit_claws(MainWindow *mainwin) close_log_file(LOG_DEBUG_FILTERING); imap_main_done(TRUE); - nntp_main_done(TRUE); lock_socket_remove(); @@ -811,7 +806,6 @@ static void exit_claws(MainWindow *mainwin) prefs_summaries_done(); prefs_message_done(); prefs_other_done(); - prefs_proxy_done(); prefs_receive_done(); prefs_logging_done(); prefs_send_done(); diff --git a/src/news.c b/src/news.c @@ -32,7 +32,6 @@ #include <time.h> #include <libetpan/libetpan.h> -#include "nntp-thread.h" #include "news.h" #include "socket.h" #include "procmsg.h" @@ -95,16 +94,10 @@ static gchar *news_fetch_msg (Folder *folder, static void news_remove_cached_msg (Folder *folder, FolderItem *item, MsgInfo *msginfo); -#ifdef USE_GNUTLS static Session *news_session_new (Folder *folder, const PrefsAccount *account, gushort port, SSLType ssl_type); -#else -static Session *news_session_new (Folder *folder, - const PrefsAccount *account, - gushort port); -#endif static gint news_get_article (Folder *folder, gint num, @@ -251,7 +244,6 @@ static void news_folder_destroy(Folder *folder) remove_dir_recursive(dir); g_free(dir); - nntp_done(folder); RemoteFolder *rfolder = REMOTE_FOLDER(folder); if (rfolder->session) session_destroy(rfolder->session); @@ -269,258 +261,21 @@ static void news_session_destroy(Session *session) static gboolean nntp_ping(gpointer data) { - Session *session = (Session *)data; - NewsSession *news_session = NEWS_SESSION(session); - int r; - struct tm lt; - - if (session->state != SESSION_READY || news_folder_locked(news_session->folder)) - return FALSE; - - news_folder_lock(NEWS_FOLDER(news_session->folder)); - - if ((r = nntp_threaded_date(news_session->folder, &lt)) != NEWSNNTP_NO_ERROR) { - if (r != NEWSNNTP_ERROR_COMMAND_NOT_SUPPORTED && - r != NEWSNNTP_ERROR_COMMAND_NOT_UNDERSTOOD) { - log_warning(LOG_PROTOCOL, _("NNTP connection to %s:%d has been" - " disconnected.\n"), - news_session->folder->account->nntp_server, - news_session->folder->account->set_nntpport ? - news_session->folder->account->nntpport : NNTP_PORT); - REMOTE_FOLDER(news_session->folder)->session = NULL; - news_folder_unlock(NEWS_FOLDER(news_session->folder)); - session->state = SESSION_DISCONNECTED; - session->sock = NULL; - session_destroy(session); - return FALSE; - } - } - - news_folder_unlock(NEWS_FOLDER(news_session->folder)); - session_set_access_time(session); - return TRUE; + fprintf(stderr, "TODO(otl): delete nntp_ping\n"); + return FALSE; } -#ifdef USE_GNUTLS -static Session *news_session_new(Folder *folder, const PrefsAccount *account, gushort port, - SSLType ssl_type) -#else -static Session *news_session_new(Folder *folder, const PrefsAccount *account, gushort port) -#endif +static Session *news_session_new(Folder *folder, const PrefsAccount *account, gushort port, SSLType ssl_type) { - NewsSession *session; - const char *server = account->nntp_server; - int r = 0; - ProxyInfo *proxy_info = NULL; - - cm_return_val_if_fail(server != NULL, NULL); - - log_message(LOG_PROTOCOL, - _("Account '%s': Connecting to NNTP server: %s:%d...\n"), - folder->account->account_name, server, port); - - session = g_new0(NewsSession, 1); - session_init(SESSION(session), folder->account, FALSE); - SESSION(session)->type = SESSION_NEWS; - SESSION(session)->server = g_strdup(server); - SESSION(session)->port = port; - SESSION(session)->sock = NULL; - SESSION(session)->destroy = news_session_destroy; - - if (account->use_proxy) { - if (account->use_default_proxy) { - proxy_info = (ProxyInfo *)&(prefs_common.proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get(PWS_CORE, PWS_CORE_PROXY, - PWS_CORE_PROXY_PASS); - } else { - proxy_info = (ProxyInfo *)&(account->proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get_account(account->account_id, - PWS_ACCOUNT_PROXY_PASS); - } - } - SESSION(session)->proxy_info = proxy_info; - - nntp_init(folder); - -#ifdef USE_GNUTLS - SESSION(session)->use_tls_sni = account->use_tls_sni; - if (ssl_type != SSL_NONE) - r = nntp_threaded_connect_ssl(folder, server, port, proxy_info); - else -#endif - r = nntp_threaded_connect(folder, server, port, proxy_info); - - if (r != NEWSNNTP_NO_ERROR) { - log_error(LOG_PROTOCOL, _("Error logging in to %s:%d...\n"), server, port); - session_destroy(SESSION(session)); - return NULL; - } - - session->folder = folder; - - return SESSION(session); + fprintf(stderr, "TODO(otl): delete news_session_new\n"); + return NULL; } static Session *news_session_new_for_folder(Folder *folder) { - Session *session; - PrefsAccount *ac; - const gchar *userid = NULL; - gchar *passwd = NULL; - gushort port; - int r; - - cm_return_val_if_fail(folder != NULL, NULL); - cm_return_val_if_fail(folder->account != NULL, NULL); - - ac = folder->account; - -#ifdef USE_GNUTLS - port = ac->set_nntpport ? ac->nntpport - : ac->ssl_nntp ? NNTPS_PORT : NNTP_PORT; - session = news_session_new(folder, ac, port, ac->ssl_nntp); -#else - if (ac->ssl_nntp != SSL_NONE) { - if (alertpanel_full(_("Insecure connection"), - _("This connection is configured to be secured " - "using TLS, but TLS is not available " - "in this build of Claws Mail. \n\n" - "Do you want to continue connecting to this " - "server? The communication would not be " - "secure."), - NULL, _("_Cancel"), NULL, _("Con_tinue connecting"), - NULL, NULL, ALERTFOCUS_FIRST, FALSE, NULL, ALERT_WARNING) != G_ALERTALTERNATE) - return NULL; - } - port = ac->set_nntpport ? ac->nntpport : NNTP_PORT; - session = news_session_new(folder, ac, port); -#endif - - if (ac->use_nntp_auth && ac->userid && ac->userid[0]) { - userid = ac->userid; - if (password_get(userid, ac->nntp_server, "nntp", port, &passwd)) { - /* NOP */; - } else if ((passwd = passwd_store_get_account(ac->account_id, - PWS_ACCOUNT_RECV)) == NULL) { - passwd = input_dialog_query_password_keep(ac->nntp_server, - userid, - &(ac->session_passwd)); - } - } - - if (session != NULL) - r = nntp_threaded_mode_reader(folder); - else - r = NEWSNNTP_ERROR_CONNECTION_REFUSED; - - if (r != NEWSNNTP_NO_ERROR) { - if (r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME) { - /* - FIX ME when libetpan implements 480 to indicate authorization - is required to use this capability. Libetpan treats a 480 as a - 381 which is clearly wrong. - RFC 4643 section 2. - Response code 480 - Generic response - Meaning: command unavailable until the client - has authenticated itself. - */ - /* if the server does not advertise the capability MODE-READER, - we normally should not send MODE READER. However this can't - hurt: a transit-only server returns 502 and closes the cnx. - Ref.: http://tools.ietf.org/html/rfc3977#section-5.3 - */ - log_error(LOG_PROTOCOL, _("Libetpan does not support return code 480 " - "so for now we choose to continue\n")); - } - else if (r == NEWSNNTP_ERROR_UNEXPECTED_RESPONSE) { - /* if the server does not advertise the capability MODE-READER, - we normally should not send MODE READER. However this can't - hurt: a transit-only server returns 502 and closes the cnx. - Ref.: http://tools.ietf.org/html/rfc3977#section-5.3 - */ - log_error(LOG_PROTOCOL, _("Mode reader failed, continuing nevertheless\n")); - } - else { - /* An error state bail out */ - log_error(LOG_PROTOCOL, _("Error creating session with %s:%d\n"), ac->nntp_server, port); - if (session != NULL) - session_destroy(SESSION(session)); - g_free(passwd); - if (ac->session_passwd) { - g_free(ac->session_passwd); - ac->session_passwd = NULL; - } - return NULL; - } - } - - if ((session != NULL) && ac->use_nntp_auth) { /* FIXME: && ac->use_nntp_auth_onconnect */ - if (nntp_threaded_login(folder, userid, passwd) != - NEWSNNTP_NO_ERROR) { - log_error(LOG_PROTOCOL, _("Error authenticating to %s:%d...\n"), ac->nntp_server, port); - session_destroy(SESSION(session)); - g_free(passwd); - if (ac->session_passwd) { - g_free(ac->session_passwd); - ac->session_passwd = NULL; - } - return NULL; - } - } - g_free(passwd); - - return session; -} - -static NewsSession *news_session_get(Folder *folder) -{ - RemoteFolder *rfolder = REMOTE_FOLDER(folder); - - cm_return_val_if_fail(folder != NULL, NULL); - cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL); - cm_return_val_if_fail(folder->account != NULL, NULL); - - if (prefs_common.work_offline && - !inc_offline_should_override(FALSE, - _("Claws Mail needs network access in order " - "to access the News server."))) { - return NULL; - } - - if (!rfolder->session) { - rfolder->session = news_session_new_for_folder(folder); - session_register_ping(SESSION(rfolder->session), nntp_ping); - return NEWS_SESSION(rfolder->session); - } - - /* Handle port change (also ssl/nossl change) without needing to - * restart application. */ - if (rfolder->session->port != folder->account->nntpport) { - session_destroy(rfolder->session); - rfolder->session = news_session_new_for_folder(folder); - session_register_ping(SESSION(rfolder->session), nntp_ping); - goto newsession; - } - - if (time(NULL) - rfolder->session->last_access_time < - SESSION_TIMEOUT_INTERVAL) { - return NEWS_SESSION(rfolder->session); - } - - if (!nntp_ping(rfolder->session)) { - rfolder->session = news_session_new_for_folder(folder); - session_register_ping(SESSION(rfolder->session), nntp_ping); - } - -newsession: - if (rfolder->session) - session_set_access_time(rfolder->session); - - return NEWS_SESSION(rfolder->session); + fprintf(stderr, "TODO(otl): delete news_session_new_for_folder\n"); + return NULL; } static void news_remove_cached_msg(Folder *folder, FolderItem *item, MsgInfo *msginfo) @@ -545,54 +300,8 @@ static void news_remove_cached_msg(Folder *folder, FolderItem *item, MsgInfo *ms static gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num) { - gchar *path, *filename; - NewsSession *session; - gint ok; - - cm_return_val_if_fail(folder != NULL, NULL); - cm_return_val_if_fail(item != NULL, NULL); - - path = folder_item_get_path(item); - if (!is_dir_exist(path)) - make_dir_hier(path); - filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL); - g_free(path); - - if (is_file_exist(filename)) { - debug_print("article %d has been already cached.\n", num); - return filename; - } - - session = news_session_get(folder); - if (!session) { - g_free(filename); - return NULL; - } - - ok = news_select_group(folder, item->path, NULL, NULL, NULL); - if (ok != NEWSNNTP_NO_ERROR) { - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - } - g_free(filename); - return NULL; - } - - debug_print("getting article %d...\n", num); - ok = news_get_article(folder, - num, filename); - if (ok != NEWSNNTP_NO_ERROR) { - g_warning("can't read article %d", num); - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - } - g_free(filename); - return NULL; - } - GTK_EVENTS_FLUSH(); - return filename; + fprintf(stderr, "TODO: delete news_fetch_msg\n"); + return NULL; } static NewsGroupInfo *news_group_info_new(const gchar *name, @@ -623,119 +332,8 @@ static gint news_group_info_compare(NewsGroupInfo *ginfo1, GSList *news_get_group_list(Folder *folder) { - gchar *path, *filename; - FILE *fp; - GSList *list = NULL; - GSList *last = NULL; - gchar buf[BUFFSIZE]; - - cm_return_val_if_fail(folder != NULL, NULL); - cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL); - - path = folder_item_get_path(FOLDER_ITEM(folder->node->data)); - if (!is_dir_exist(path)) - make_dir_hier(path); - filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL); - g_free(path); - - if ((fp = g_fopen(filename, "rb")) == NULL) { - NewsSession *session; - gint ok; - clist *grouplist = NULL; - clistiter *cur; - fp = g_fopen(filename, "wb"); - - if (!fp) { - g_free(filename); - return NULL; - } - session = news_session_get(folder); - if (!session) { - fclose(fp); - g_free(filename); - return NULL; - } - - ok = nntp_threaded_list(folder, &grouplist); - - if (ok != NEWSNNTP_NO_ERROR) { - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - } - fclose(fp); - g_free(filename); - return NULL; - } - - if (grouplist) { - for (cur = clist_begin(grouplist); cur; cur = clist_next(cur)) { - struct newsnntp_group_info *info = (struct newsnntp_group_info *) - clist_content(cur); - if (fprintf(fp, "%s %d %d %c\n", - info->grp_name, - info->grp_last, - info->grp_first, - info->grp_type) < 0) { - log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n")); - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - fclose(fp); - g_free(filename); - newsnntp_list_free(grouplist); - return NULL; - } - } - newsnntp_list_free(grouplist); - } - if (safe_fclose(fp) == EOF) { - log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n")); - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - g_free(filename); - return NULL; - } - - if ((fp = g_fopen(filename, "rb")) == NULL) { - FILE_OP_ERROR(filename, "g_fopen"); - g_free(filename); - return NULL; - } - } - - while (fgets(buf, sizeof(buf), fp) != NULL) { - gchar *p = buf; - gchar *name; - gint last_num; - gint first_num; - gchar type; - NewsGroupInfo *ginfo; - - p = strchr(p, ' '); - if (!p) continue; - *p = '\0'; - p++; - name = buf; - - if (sscanf(p, "%d %d %c", &last_num, &first_num, &type) < 3) - continue; - - ginfo = news_group_info_new(name, first_num, last_num, type); - - if (!last) - last = list = g_slist_append(NULL, ginfo); - else { - last = g_slist_append(last, ginfo); - last = last->next; - } - } - - fclose(fp); - g_free(filename); - - list = g_slist_sort(list, (GCompareFunc)news_group_info_compare); - - return list; + fprintf(stderr, "TODO(otl): delete news_get_group_list\n"); + return NULL; } void news_group_list_free(GSList *group_list) @@ -767,51 +365,16 @@ void news_remove_group_list_cache(Folder *folder) g_free(filename); } -gint news_post(Folder *folder, const gchar *file) +int news_post(Folder *folder, const gchar *file) { - gint ok; - char *contents = file_read_to_str_no_recode(file); - NewsSession *session; - - cm_return_val_if_fail(folder != NULL, -1); - cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, -1); - cm_return_val_if_fail(contents != NULL, -1); - - session = news_session_get(folder); - if (!session) { - g_free(contents); - return -1; - } - - ok = nntp_threaded_post(folder, contents, strlen(contents)); - - g_free(contents); - - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(folder)->session = NULL; - } - - return (ok == NEWSNNTP_NO_ERROR ? 0 : -1); + fprintf(stderr, "TODO(otl): delete news_post\n"); + return -1; } -static gint news_get_article(Folder *folder, gint num, gchar *filename) +static int news_get_article(Folder *folder, gint num, gchar *filename) { - size_t len; - char *result = NULL; - int r; - - r = nntp_threaded_article(folder, num, &result, &len); - - if (r == NEWSNNTP_NO_ERROR) { - if (str_write_to_file(result, filename, FALSE) < 0) { - mmap_string_unref(result); - return -1; - } - mmap_string_unref(result); - } - - return r; + fprintf(stderr, "TODO(otl): delete news_post\n"); + return -1; } /** @@ -830,36 +393,8 @@ static gint news_get_article(Folder *folder, gint num, gchar *filename) static gint news_select_group(Folder *folder, const gchar *group, gint *num, gint *first, gint *last) { - gint ok; - gint num_, first_, last_; - struct newsnntp_group_info *info = NULL; - NewsSession *session = NEWS_SESSION(news_session_get(folder)); - - cm_return_val_if_fail(session != NULL, -1); - - if (!num || !first || !last) { - if (session->group && g_ascii_strcasecmp(session->group, group) == 0) - return NEWSNNTP_NO_ERROR; - num = &num_; - first = &first_; - last = &last_; - } - - g_free(session->group); - session->group = NULL; - - ok = nntp_threaded_group(folder, group, &info); - - if (ok == NEWSNNTP_NO_ERROR && info) { - session->group = g_strdup(group); - *num = info->grp_first; - *first = info->grp_first; - *last = info->grp_last; - newsnntp_group_free(info); - } else { - log_warning(LOG_PROTOCOL, _("couldn't select group: %s\n"), group); - } - return ok; + fprintf(stderr, "TODO(otl): delete news_select_group\n"); + return -1; } static MsgInfo *news_parse_xover(struct newsnntp_xover_resp_item *item) @@ -1027,47 +562,8 @@ static gchar *news_item_get_path(Folder *folder, FolderItem *item) static gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list, gboolean *old_uids_valid) { - NewsSession *session; - gint i, ok, num, first, last, nummsgs = 0; - gchar *dir; - - cm_return_val_if_fail(item != NULL, -1); - cm_return_val_if_fail(item->folder != NULL, -1); - cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, -1); - - session = news_session_get(folder); - cm_return_val_if_fail(session != NULL, -1); - - *old_uids_valid = TRUE; - - news_folder_lock(NEWS_FOLDER(item->folder)); - - ok = news_select_group(folder, item->path, &num, &first, &last); - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't set group: %s\n"), item->path); - news_folder_unlock(NEWS_FOLDER(item->folder)); - return -1; - } - - dir = news_folder_get_path(folder); - if (num <= 0) - remove_all_numbered_files(dir); - else if (last < first) - log_warning(LOG_PROTOCOL, _("invalid article range: %d - %d\n"), - first, last); - else { - for (i = first; i <= last; i++) { - *msgnum_list = g_slist_prepend(*msgnum_list, - GINT_TO_POINTER(i)); - nummsgs++; - } - debug_print("removing old messages from %d to %d in %s\n", - first, last, dir); - remove_numbered_files(dir, 1, first - 1); - } - g_free(dir); - news_folder_unlock(NEWS_FOLDER(item->folder)); - return nummsgs; + fprintf(stderr, "TODO: delete news_get_num_list\n"); + return -1; } static void news_set_msg_flags(FolderItem *item, MsgInfo *msginfo) @@ -1092,262 +588,26 @@ static void news_set_msg_flags(FolderItem *item, MsgInfo *msginfo) static void news_get_extra_fields(NewsSession *session, FolderItem *item, GSList *msglist) { - MsgInfo *msginfo = NULL; - gint ok; - GSList *cur; - clist *hdrlist = NULL; - clistiter *hdr; - gint first = -1, last = -1; - GHashTable *hash_table; - - cm_return_if_fail(session != NULL); - cm_return_if_fail(item != NULL); - cm_return_if_fail(item->folder != NULL); - cm_return_if_fail(FOLDER_CLASS(item->folder) == &news_class); - - if (msglist == NULL) - return; - - news_folder_lock(NEWS_FOLDER(item->folder)); - - hash_table = g_hash_table_new(g_direct_hash, g_direct_equal); - - for (cur = msglist; cur; cur = cur->next) { - msginfo = (MsgInfo *)cur->data; - if (first == -1 || msginfo->msgnum < first) - first = msginfo->msgnum; - if (last == -1 || msginfo->msgnum > last) - last = msginfo->msgnum; - g_hash_table_insert(hash_table, - GINT_TO_POINTER(msginfo->msgnum), msginfo); - } - - if (first == -1 || last == -1) { - g_hash_table_destroy(hash_table); - return; - } - -/* Newsgroups */ - ok = nntp_threaded_xhdr(item->folder, "newsgroups", first, last, &hdrlist); - - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n")); - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(item->folder)->session = NULL; - } - news_folder_unlock(NEWS_FOLDER(item->folder)); - if (hdrlist != NULL) - newsnntp_xhdr_free(hdrlist); - return; - } - - for (hdr = clist_begin(hdrlist); hdr; hdr = clist_next(hdr)) { - struct newsnntp_xhdr_resp_item *hdrval = clist_content(hdr); - msginfo = g_hash_table_lookup(hash_table, GINT_TO_POINTER(hdrval->hdr_article)); - if (msginfo) { - if (msginfo->newsgroups) - g_free(msginfo->newsgroups); - msginfo->newsgroups = g_strdup(hdrval->hdr_value); - } - } - newsnntp_xhdr_free(hdrlist); - hdrlist = NULL; - -/* To */ - ok = nntp_threaded_xhdr(item->folder, "to", first, last, &hdrlist); - - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n")); - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(item->folder)->session = NULL; - } - news_folder_unlock(NEWS_FOLDER(item->folder)); - if (hdrlist != NULL) - newsnntp_xhdr_free(hdrlist); - return; - } - - for (hdr = clist_begin(hdrlist); hdr; hdr = clist_next(hdr)) { - struct newsnntp_xhdr_resp_item *hdrval = clist_content(hdr); - msginfo = g_hash_table_lookup(hash_table, GINT_TO_POINTER(hdrval->hdr_article)); - if (msginfo) { - if (msginfo->to) - g_free(msginfo->to); - msginfo->to = g_strdup(hdrval->hdr_value); - } - } - newsnntp_xhdr_free(hdrlist); - hdrlist = NULL; - -/* Cc */ - ok = nntp_threaded_xhdr(item->folder, "cc", first, last, &hdrlist); - - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n")); - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(item->folder)->session = NULL; - } - news_folder_unlock(NEWS_FOLDER(item->folder)); - if (hdrlist != NULL) - newsnntp_xhdr_free(hdrlist); - return; - } - - for (hdr = clist_begin(hdrlist); hdr; hdr = clist_next(hdr)) { - struct newsnntp_xhdr_resp_item *hdrval = clist_content(hdr); - msginfo = g_hash_table_lookup(hash_table, GINT_TO_POINTER(hdrval->hdr_article)); - if (msginfo) { - if (msginfo->cc) - g_free(msginfo->cc); - msginfo->cc = g_strdup(hdrval->hdr_value); - } - } - newsnntp_xhdr_free(hdrlist); - hdrlist = NULL; - - g_hash_table_destroy(hash_table); - news_folder_unlock(NEWS_FOLDER(item->folder)); + fprintf(stderr, "TODO(otl): delete news_get_extra_fields\n"); + return; } static GSList *news_get_msginfos_for_range(NewsSession *session, FolderItem *item, guint begin, guint end) { - GSList *newlist = NULL; - GSList *llast = NULL; - MsgInfo *msginfo; - gint ok; - clist *msglist = NULL; - clistiter *cur; - cm_return_val_if_fail(session != NULL, NULL); - cm_return_val_if_fail(item != NULL, NULL); - - log_message(LOG_PROTOCOL, _("getting xover %d - %d in %s...\n"), - begin, end, item->path); - - news_folder_lock(NEWS_FOLDER(item->folder)); - - ok = news_select_group(item->folder, item->path, NULL, NULL, NULL); - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't set group: %s\n"), item->path); - news_folder_unlock(NEWS_FOLDER(item->folder)); - return NULL; - } - - ok = nntp_threaded_xover(item->folder, begin, end, NULL, &msglist); - - if (ok != NEWSNNTP_NO_ERROR) { - log_warning(LOG_PROTOCOL, _("couldn't get xover\n")); - if (ok == NEWSNNTP_ERROR_STREAM) { - session_destroy(SESSION(session)); - REMOTE_FOLDER(item->folder)->session = NULL; - } - news_folder_unlock(NEWS_FOLDER(item->folder)); - if (msglist != NULL) - newsnntp_xover_resp_list_free(msglist); - return NULL; - } - - if (msglist) { - for (cur = clist_begin(msglist); cur; cur = clist_next(cur)) { - struct newsnntp_xover_resp_item *ritem = (struct newsnntp_xover_resp_item *)clist_content(cur); - msginfo = news_parse_xover(ritem); - - if (!msginfo) { - log_warning(LOG_PROTOCOL, _("invalid xover line\n")); - continue; - } - - msginfo->folder = item; - news_set_msg_flags(item, msginfo); - msginfo->flags.tmp_flags |= MSG_NEWS; - - if (!newlist) - llast = newlist = g_slist_append(newlist, msginfo); - else { - llast = g_slist_append(llast, msginfo); - llast = llast->next; - } - } - newsnntp_xover_resp_list_free(msglist); - } - - news_folder_unlock(NEWS_FOLDER(item->folder)); - - session_set_access_time(SESSION(session)); - - news_get_extra_fields(session, item, newlist); - - return newlist; + fprintf(stderr, "TODO(otl): delete news_get_msginfos_for_range\n"); + return NULL; } static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num) { - GSList *msglist = NULL; - NewsSession *session; - MsgInfo *msginfo = NULL; - - session = news_session_get(folder); - cm_return_val_if_fail(session != NULL, NULL); - cm_return_val_if_fail(item != NULL, NULL); - cm_return_val_if_fail(item->folder != NULL, NULL); - cm_return_val_if_fail(FOLDER_CLASS(item->folder) == &news_class, NULL); - - msglist = news_get_msginfos_for_range(session, item, num, num); - - if (msglist) - msginfo = msglist->data; - - g_slist_free(msglist); - - return msginfo; + fprintf(stderr, "TODO: delete news_get_msginfo\n"); + return NULL; } static GSList *news_get_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_list) { - NewsSession *session; - GSList *elem, *msginfo_list = NULL, *tmp_msgnum_list, *tmp_msginfo_list; - guint first, last, next; - - cm_return_val_if_fail(folder != NULL, NULL); - cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL); - cm_return_val_if_fail(msgnum_list != NULL, NULL); - cm_return_val_if_fail(item != NULL, NULL); - - session = news_session_get(folder); - cm_return_val_if_fail(session != NULL, NULL); - - tmp_msgnum_list = g_slist_copy(msgnum_list); - tmp_msgnum_list = g_slist_sort(tmp_msgnum_list, g_int_compare); - - progressindicator_start(PROGRESS_TYPE_NETWORK); - - first = GPOINTER_TO_INT(tmp_msgnum_list->data); - last = first; - - news_folder_lock(NEWS_FOLDER(item->folder)); - - for(elem = g_slist_next(tmp_msgnum_list); elem != NULL; elem = g_slist_next(elem)) { - next = GPOINTER_TO_INT(elem->data); - if(next != (last + 1)) { - tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last); - msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list); - first = next; - } - last = next; - } - - news_folder_unlock(NEWS_FOLDER(item->folder)); - - tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last); - msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list); - - g_slist_free(tmp_msgnum_list); - - progressindicator_stop(PROGRESS_TYPE_NETWORK); - - return msginfo_list; + fprintf(stderr, "TODO: delete news_get_msginfos\n"); + return NULL; } static gboolean news_scan_required(Folder *folder, FolderItem *item) @@ -1403,16 +663,12 @@ void nntp_disconnect_all(gboolean have_connectivity) { GList *list; - nntp_main_set_timeout(1); - for (list = account_get_list(); list != NULL; list = list->next) { PrefsAccount *account = list->data; if (account->protocol == A_NNTP) { RemoteFolder *folder = (RemoteFolder *)account->folder; if (folder && folder->session) { NewsSession *session = (NewsSession *)folder->session; - if (have_connectivity) - nntp_threaded_disconnect(FOLDER(folder)); SESSION(session)->state = SESSION_DISCONNECTED; SESSION(session)->sock = NULL; session_destroy(SESSION(session)); @@ -1420,6 +676,5 @@ void nntp_disconnect_all(gboolean have_connectivity) } } } - nntp_main_set_timeout(prefs_common.io_timeout_secs); } diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -314,24 +314,6 @@ typedef struct SSLPage GtkWidget *use_nonblocking_ssl_checkbtn; } SSLPage; -typedef struct ProxyPage -{ - PrefsPage page; - - GtkWidget *vbox; - - GtkWidget *proxy_checkbtn; - GtkWidget *default_proxy_checkbtn; - GtkWidget *socks4_radiobtn; - GtkWidget *socks5_radiobtn; - GtkWidget *proxy_host_entry; - GtkWidget *proxy_port_spinbtn; - GtkWidget *proxy_auth_checkbtn; - GtkWidget *proxy_name_entry; - GtkWidget *proxy_pass_entry; - GtkWidget *proxy_send_checkbtn; -} ProxyPage; - typedef struct AdvancedPage { PrefsPage page; @@ -377,7 +359,6 @@ static PrivacyPage privacy_page; #ifdef USE_GNUTLS static SSLPage ssl_page; #endif -static ProxyPage proxy_page; static AdvancedPage advanced_page; struct BasicProtocol { @@ -855,48 +836,6 @@ static PrefParam ssl_param[] = { {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} }; -static PrefParam proxy_param[] = { - /* SOCKS proxy */ - {"use_proxy", "FALSE", &tmp_ac_prefs.use_proxy, P_BOOL, - &proxy_page.proxy_checkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, - - {"use_default_proxy", "TRUE", &tmp_ac_prefs.use_default_proxy, P_BOOL, - &proxy_page.default_proxy_checkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, - - {"use_proxy_for_send", "TRUE", &tmp_ac_prefs.use_proxy_for_send, P_BOOL, - &proxy_page.proxy_send_checkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, - - {"proxy_type", "1", &tmp_ac_prefs.proxy_info.proxy_type, P_ENUM, - &proxy_page.socks4_radiobtn, - prefs_account_enum_set_data_from_radiobtn, - prefs_account_enum_set_radiobtn}, - - {"proxy_host", "localhost", &tmp_ac_prefs.proxy_info.proxy_host, P_STRING, - &proxy_page.proxy_host_entry, - prefs_set_data_from_entry, prefs_set_entry}, - - {"proxy_port", "1080", &tmp_ac_prefs.proxy_info.proxy_port, P_USHORT, - &proxy_page.proxy_port_spinbtn, - prefs_set_data_from_spinbtn, prefs_set_spinbtn}, - - {"use_proxy_auth", "FALSE", &tmp_ac_prefs.proxy_info.use_proxy_auth, P_BOOL, - &proxy_page.proxy_auth_checkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, - - {"proxy_name", "", &tmp_ac_prefs.proxy_info.proxy_name, P_STRING, - &proxy_page.proxy_name_entry, - prefs_set_data_from_entry, prefs_set_entry}, - - {"proxy_pass", NULL, &tmp_ac_prefs.proxy_info.proxy_pass, P_PASSWORD, - NULL, NULL, NULL}, - - - {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} -}; - static PrefParam advanced_param[] = { {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL, &advanced_page.smtpport_checkbtn, @@ -2970,163 +2909,6 @@ static void ssl_create_widget_func(PrefsPage * _page, #undef CREATE_RADIO_BUTTONS #endif /* USE_GNUTLS */ -static void proxy_create_widget_func(PrefsPage * _page, - GtkWindow * window, - gpointer data) -{ - ProxyPage *page = (ProxyPage *) _page; - PrefsAccount *ac_prefs = (PrefsAccount *) data; - GtkWidget *vbox1, *vbox2, *vbox3, *vbox4; - GtkWidget *proxy_frame; - GtkWidget *proxy_checkbtn; - GtkWidget *default_proxy_checkbtn; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *socks4_radiobtn; - GtkWidget *socks5_radiobtn; - GtkWidget *proxy_host_entry; - GtkWidget *proxy_port_spinbtn; - GtkWidget *proxy_auth_checkbtn; - GtkWidget *proxy_name_entry; - GtkWidget *proxy_pass_entry; - GtkWidget *proxy_send_checkbtn; - GtkWidget *table; - gchar *buf; - - vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); - gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); - - proxy_checkbtn = gtk_check_button_new_with_label (_("Use proxy server")); - PACK_FRAME (vbox1, proxy_frame, NULL); - gtk_frame_set_label_widget (GTK_FRAME(proxy_frame), proxy_checkbtn); - - vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); - gtk_container_add (GTK_CONTAINER (proxy_frame), vbox2); - gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); - - default_proxy_checkbtn = - gtk_check_button_new_with_label (C_("In account preferences, referring to whether or not use proxy settings from common preferences", "Use default settings")); - CLAWS_SET_TIP(default_proxy_checkbtn, - _("Use global proxy server settings")); - gtk_box_pack_start (GTK_BOX (vbox2), default_proxy_checkbtn, FALSE, FALSE, 0); - - vbox3 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); - gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); - gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0); - - socks4_radiobtn = gtk_radio_button_new_with_label(NULL, "SOCKS4"); - gtk_box_pack_start (GTK_BOX (hbox), socks4_radiobtn, FALSE, FALSE, 0); - g_object_set_data(G_OBJECT(socks4_radiobtn), MENU_VAL_ID, - GINT_TO_POINTER(PROXY_SOCKS4)); - - CREATE_RADIO_BUTTON(hbox, socks5_radiobtn, socks4_radiobtn, "SOCKS5", - PROXY_SOCKS5); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); - gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0); - - label = gtk_label_new(_("Hostname")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - proxy_host_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_host_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_box_pack_start(GTK_BOX(hbox), proxy_host_entry, TRUE, TRUE, 0); - - label = gtk_label_new(_("Port")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - proxy_port_spinbtn = gtk_spin_button_new_with_range(0, 65535, 1080); - gtk_widget_set_size_request(proxy_port_spinbtn, 64, -1); - gtk_box_pack_start(GTK_BOX(hbox), proxy_port_spinbtn, FALSE, FALSE, 0); - - vbox4 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); - gtk_box_pack_start(GTK_BOX(vbox3), vbox4, FALSE, FALSE, 0); - - PACK_CHECK_BUTTON (vbox4, proxy_auth_checkbtn, _("Use authentication")); - - table = gtk_grid_new(); - gtk_box_pack_start (GTK_BOX (vbox4), table, FALSE, FALSE, 0); - - label = gtk_label_new(_("Username")); - gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1); - - proxy_name_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_name_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_grid_attach(GTK_GRID(table), proxy_name_entry, 1, 0, 1, 1); - gtk_widget_set_hexpand(proxy_name_entry, TRUE); - gtk_widget_set_halign(proxy_name_entry, GTK_ALIGN_FILL); - - label = gtk_label_new(_("Password")); - gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1); - - proxy_pass_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE); - gtk_entry_set_icon_from_icon_name(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, - "view-reveal-symbolic"); - gtk_entry_set_icon_activatable(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_entry_set_icon_tooltip_text(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, _("Show password")); - g_signal_connect(proxy_pass_entry, "icon-press", - G_CALLBACK(prefs_account_showpwd_toggled), NULL); - gtk_grid_attach(GTK_GRID(table), proxy_pass_entry, 3, 0, 1, 1); - gtk_widget_set_hexpand(proxy_pass_entry, TRUE); - gtk_widget_set_halign(proxy_pass_entry, GTK_ALIGN_FILL); - - gtk_box_pack_start(GTK_BOX(vbox2), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); - - PACK_CHECK_BUTTON(vbox2, proxy_send_checkbtn, - _("Use proxy server for sending")); - CLAWS_SET_TIP(proxy_send_checkbtn, - _("If disabled, messages will be sent using direct connection to configured outgoing server, bypassing any configured proxy server")); - - SET_TOGGLE_SENSITIVITY(proxy_auth_checkbtn, table); - SET_TOGGLE_SENSITIVITY(socks5_radiobtn, vbox4); - SET_TOGGLE_SENSITIVITY(proxy_checkbtn, vbox2); - SET_TOGGLE_SENSITIVITY_REVERSE(default_proxy_checkbtn, vbox3); - - gtk_widget_show_all(vbox1); - - page->proxy_checkbtn = proxy_checkbtn; - page->default_proxy_checkbtn = default_proxy_checkbtn; - page->socks4_radiobtn = socks4_radiobtn; - page->socks5_radiobtn = socks5_radiobtn; - page->proxy_host_entry = proxy_host_entry; - page->proxy_port_spinbtn = proxy_port_spinbtn; - page->proxy_auth_checkbtn = proxy_auth_checkbtn; - page->proxy_name_entry = proxy_name_entry; - page->proxy_pass_entry = proxy_pass_entry; - page->proxy_send_checkbtn = proxy_send_checkbtn; - page->vbox = vbox1; - page->page.widget = vbox1; - - tmp_ac_prefs = *ac_prefs; - - if (new_account) { - prefs_set_dialog_to_default(proxy_param); - } else { - prefs_set_dialog(proxy_param); - - /* Passwords are handled outside of PrefParams. */ - buf = passwd_store_get_account(ac_prefs->account_id, - PWS_ACCOUNT_PROXY_PASS); - gtk_entry_set_text(GTK_ENTRY(page->proxy_pass_entry), - buf != NULL ? buf : ""); - if (buf != NULL) { - memset(buf, 0, strlen(buf)); - g_free(buf); - } - } - - page->vbox = vbox1; - - page->page.widget = vbox1; -} - static void advanced_create_widget_func(PrefsPage * _page, GtkWindow * window, gpointer data) @@ -3541,19 +3323,6 @@ static gint prefs_ssl_apply(void) } #endif -static gint prefs_proxy_apply(void) -{ - prefs_set_data_from_dialog(proxy_param); - - /* Passwords are stored outside of PrefParams. */ - passwd_store_set_account(tmp_ac_prefs.account_id, - PWS_ACCOUNT_PROXY_PASS, - gtk_entry_get_text(GTK_ENTRY(proxy_page.proxy_pass_entry)), - FALSE); - - return 0; -} - static gint prefs_advanced_apply(void) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.domain_checkbtn)) && @@ -3635,11 +3404,6 @@ static void ssl_destroy_widget_func(PrefsPage *_page) } #endif -static void proxy_destroy_widget_func(PrefsPage *_page) -{ - /* ProxyPage *page = (ProxyPage *) _page; */ -} - static void advanced_destroy_widget_func(PrefsPage *_page) { /* AdvancedPage *page = (AdvancedPage *) _page; */ @@ -3729,16 +3493,6 @@ static gboolean ssl_can_close_func(PrefsPage *_page) } #endif -static gboolean proxy_can_close_func(PrefsPage *_page) -{ - ProxyPage *page = (ProxyPage *) _page; - - if (!page->page.page_open) - return TRUE; - - return prefs_proxy_apply() >= 0; -} - static gboolean advanced_can_close_func(PrefsPage *_page) { AdvancedPage *page = (AdvancedPage *) _page; @@ -3851,17 +3605,6 @@ static void ssl_save_func(PrefsPage *_page) } #endif -static void proxy_save_func(PrefsPage *_page) -{ - ProxyPage *page = (ProxyPage *) _page; - - if (!page->page.page_open) - return; - - if (prefs_proxy_apply() >= 0) - cancelled = FALSE; -} - static void advanced_save_func(PrefsPage *_page) { AdvancedPage *page = (AdvancedPage *) _page; @@ -4085,24 +3828,6 @@ static gboolean sslcert_get_password(gpointer source, gpointer data) } #endif -static void register_proxy_page(void) -{ - static gchar *path[3]; - - path[0] = _("Account"); - path[1] = _("Proxy"); - path[2] = NULL; - - proxy_page.page.path = path; - proxy_page.page.weight = 1000.0; - proxy_page.page.create_widget = proxy_create_widget_func; - proxy_page.page.destroy_widget = proxy_destroy_widget_func; - proxy_page.page.save_page = proxy_save_func; - proxy_page.page.can_close = proxy_can_close_func; - - prefs_account_register_page((PrefsPage *) &proxy_page); -} - static void register_advanced_page(void) { static gchar *path[3]; @@ -4134,7 +3859,6 @@ void prefs_account_init() hooks_register_hook(SSLCERT_GET_CLIENT_CERT_HOOKLIST, sslcert_get_client_cert_hook, NULL); hooks_register_hook(SSL_CERT_GET_PASSWORD, sslcert_get_password, NULL); #endif - register_proxy_page(); #ifdef USE_OAUTH2 register_oauth2_page(); #endif @@ -4155,7 +3879,6 @@ PrefsAccount *prefs_account_new(void) prefs_set_default(templates_param); prefs_set_default(privacy_param); prefs_set_default(ssl_param); - prefs_set_default(proxy_param); prefs_set_default(advanced_param); *ac_prefs = tmp_ac_prefs; ac_prefs->account_id = prefs_account_get_new_id(); @@ -4200,7 +3923,6 @@ PrefsAccount *prefs_account_new_from_config(const gchar *label) prefs_read_config(templates_param, label, rcpath, NULL); prefs_read_config(privacy_param, label, rcpath, NULL); prefs_read_config(ssl_param, label, rcpath, NULL); - prefs_read_config(proxy_param, label, rcpath, NULL); prefs_read_config(advanced_param, label, rcpath, NULL); g_free(rcpath); @@ -4339,7 +4061,6 @@ void prefs_account_write_config_all(GList *account_list) WRITE_PARAM(templates_param) WRITE_PARAM(privacy_param) WRITE_PARAM(ssl_param) - WRITE_PARAM(proxy_param) WRITE_PARAM(advanced_param) g_free(privacy_prefs); @@ -4386,7 +4107,6 @@ void prefs_account_free(PrefsAccount *ac_prefs) prefs_free(templates_param); prefs_free(privacy_param); prefs_free(ssl_param); - prefs_free(proxy_param); prefs_free(advanced_param); } diff --git a/src/prefs_account.h b/src/prefs_account.h @@ -214,12 +214,6 @@ struct _PrefsAccount /* Unique account ID */ gint account_id; - /* SOCKS proxy */ - gboolean use_proxy; - gboolean use_default_proxy; - gboolean use_proxy_for_send; - ProxyInfo proxy_info; - struct _Folder *folder; GHashTable *privacy_prefs; SMTPSession *session; diff --git a/src/prefs_common.c b/src/prefs_common.c @@ -950,14 +950,6 @@ static PrefParam param[] = { {"master_passphrase_salt", "", &prefs_common.primary_passphrase_salt, P_STRING, NULL, NULL, NULL }, {"master_passphrase_pbkdf2_rounds", "50000", &prefs_common.primary_passphrase_pbkdf2_rounds, P_INT, NULL, NULL, NULL}, - {"use_proxy", "FALSE", &prefs_common.use_proxy, P_BOOL, NULL, NULL, NULL}, - {"proxy_type", "1", &prefs_common.proxy_info.proxy_type, P_ENUM, NULL, NULL, NULL}, - {"proxy_host", "localhost", &prefs_common.proxy_info.proxy_host, P_STRING, NULL, NULL, NULL}, - {"proxy_port", "1080", &prefs_common.proxy_info.proxy_port, P_USHORT, NULL, NULL, NULL}, - {"use_proxy_auth", "FALSE", &prefs_common.proxy_info.use_proxy_auth, P_BOOL, NULL, NULL, NULL}, - {"proxy_name", "", &prefs_common.proxy_info.proxy_name, P_STRING, NULL, NULL, NULL}, - {"proxy_pass", NULL, &prefs_common.proxy_info.proxy_pass, P_STRING, NULL, NULL, NULL}, - {"qs_press_timeout", "500", &prefs_common.qs_press_timeout, P_INT, NULL, NULL, NULL}, diff --git a/src/prefs_common.h b/src/prefs_common.h @@ -531,10 +531,6 @@ struct _PrefsCommon gboolean mainwin_toolbar_always_enable_actions; - /* Proxy */ - gboolean use_proxy; - ProxyInfo proxy_info; - /* Quicksearch */ guint qs_press_timeout; }; diff --git a/src/prefs_proxy.c b/src/prefs_proxy.c @@ -1,281 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2018-2025 the Claws Mail team - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include <glib.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> - -#include "common/defs.h" -#include "common/proxy.h" - -#include "gtk/menu.h" - -#include "prefs_common.h" -#include "prefs_gtk.h" -#include "passwordstore.h" - -typedef struct _ProxyPage -{ - PrefsPage page; - - GtkWidget *proxy_checkbtn; - GtkWidget *socks4_radiobtn; - GtkWidget *socks5_radiobtn; - GtkWidget *proxy_host_entry; - GtkWidget *proxy_port_spinbtn; - GtkWidget *proxy_auth_checkbtn; - GtkWidget *proxy_name_entry; - GtkWidget *proxy_pass_entry; -} ProxyPage; - -static void showpwd_toggled(GtkEntry *entry, gpointer user_data); - -static void prefs_proxy_create_widget(PrefsPage *_page, GtkWindow *window, - gpointer data) -{ - ProxyPage *page = (ProxyPage *)_page; - - GtkWidget *vbox0, *vbox1, *vbox2; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *proxy_checkbtn; - GtkWidget *socks4_radiobtn, *socks5_radiobtn; - GtkWidget *proxy_auth_checkbtn; - GtkWidget *proxy_frame; - GtkWidget *proxy_host_entry; - GtkWidget *proxy_port_spinbtn; - GtkWidget *proxy_name_entry; - GtkWidget *proxy_pass_entry; - GtkWidget *button; - GtkWidget *table; - gchar *buf; - - vbox0 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); - gtk_container_set_border_width(GTK_CONTAINER(vbox0), VBOX_BORDER); - - proxy_checkbtn = gtk_check_button_new_with_label(_("Use proxy server")); - PACK_FRAME(vbox0, proxy_frame, NULL); - gtk_frame_set_label_widget(GTK_FRAME(proxy_frame), proxy_checkbtn); - - vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); - gtk_container_set_border_width(GTK_CONTAINER(vbox1), 8); - gtk_container_add(GTK_CONTAINER(proxy_frame), vbox1); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); - - socks4_radiobtn = gtk_radio_button_new_with_label(NULL, "SOCKS4"); - gtk_box_pack_start(GTK_BOX(hbox), socks4_radiobtn, FALSE, FALSE, 0); - g_object_set_data(G_OBJECT(socks4_radiobtn), MENU_VAL_ID, - GINT_TO_POINTER(PROXY_SOCKS4)); - - socks5_radiobtn = gtk_radio_button_new_with_label_from_widget( - GTK_RADIO_BUTTON(socks4_radiobtn), "SOCKS5"); - gtk_box_pack_start(GTK_BOX(hbox), socks5_radiobtn, FALSE, FALSE, 0); - g_object_set_data(G_OBJECT(socks5_radiobtn), MENU_VAL_ID, - GINT_TO_POINTER(PROXY_SOCKS5)); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); - - label = gtk_label_new(_("Hostname")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - proxy_host_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_host_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_box_pack_start(GTK_BOX(hbox), proxy_host_entry, TRUE, TRUE, 0); - - label = gtk_label_new(_("Port")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - proxy_port_spinbtn = gtk_spin_button_new_with_range(0, 65535, 1080); - gtk_widget_set_size_request(proxy_port_spinbtn, 64, -1); - gtk_box_pack_start(GTK_BOX(hbox), proxy_port_spinbtn, FALSE, FALSE, 0); - - vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); - gtk_box_pack_start(GTK_BOX(vbox1), vbox2, FALSE, FALSE, 0); - - PACK_CHECK_BUTTON(vbox2, proxy_auth_checkbtn, _("Use authentication")); - - table = gtk_grid_new(); - - gtk_grid_set_row_spacing(GTK_GRID(table), VSPACING_NARROW); - gtk_grid_set_column_spacing(GTK_GRID(table), 9); - gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); - - label = gtk_label_new(_("Username")); - gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1); - - proxy_name_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_name_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_grid_attach(GTK_GRID(table), proxy_name_entry, 1, 0, 1, 1); - gtk_widget_set_hexpand(proxy_name_entry, TRUE); - gtk_widget_set_halign(proxy_name_entry, GTK_ALIGN_FILL); - - label = gtk_label_new(_("Password")); - gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1); - - proxy_pass_entry = gtk_entry_new(); - gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1); - gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE); - gtk_entry_set_icon_from_icon_name(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, - "view-reveal-symbolic"); - gtk_entry_set_icon_activatable(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_entry_set_icon_tooltip_text(GTK_ENTRY(proxy_pass_entry), - GTK_ENTRY_ICON_SECONDARY, _("Show password")); - g_signal_connect(proxy_pass_entry, "icon-press", - G_CALLBACK(showpwd_toggled), NULL); - - gtk_grid_attach(GTK_GRID(table), proxy_pass_entry, 3, 0, 1, 1); - gtk_widget_set_hexpand(proxy_pass_entry, TRUE); - gtk_widget_set_halign(proxy_pass_entry, GTK_ALIGN_FILL); - - gtk_widget_show_all(vbox0); - - SET_TOGGLE_SENSITIVITY(proxy_checkbtn, vbox1); - SET_TOGGLE_SENSITIVITY(proxy_auth_checkbtn, table); - SET_TOGGLE_SENSITIVITY(socks5_radiobtn, vbox2); - - /* Set widgets to their correct states, based on prefs. */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(proxy_checkbtn), - prefs_common.use_proxy); - if (prefs_common.proxy_info.proxy_type == PROXY_SOCKS4) - button = socks4_radiobtn; - else - button = socks5_radiobtn; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - gtk_entry_set_text(GTK_ENTRY(proxy_host_entry), - prefs_common.proxy_info.proxy_host); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(proxy_port_spinbtn), - (gdouble)prefs_common.proxy_info.proxy_port); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(proxy_auth_checkbtn), - prefs_common.proxy_info.use_proxy_auth); - gtk_entry_set_text(GTK_ENTRY(proxy_name_entry), - prefs_common.proxy_info.proxy_name); - - buf = - passwd_store_get(PWS_CORE, PWS_CORE_PROXY, PWS_CORE_PROXY_PASS); - gtk_entry_set_text(GTK_ENTRY(proxy_pass_entry), buf != NULL ? buf : ""); - if (buf != NULL) { - memset(buf, 0, strlen(buf)); - g_free(buf); - } - - page->proxy_checkbtn = proxy_checkbtn; - page->socks4_radiobtn = socks4_radiobtn; - page->socks5_radiobtn = socks5_radiobtn; - page->proxy_host_entry = proxy_host_entry; - page->proxy_port_spinbtn = proxy_port_spinbtn; - page->proxy_auth_checkbtn = proxy_auth_checkbtn; - page->proxy_name_entry = proxy_name_entry; - page->proxy_pass_entry = proxy_pass_entry; - page->page.widget = vbox0; -} - - -static void prefs_proxy_destroy_widget(PrefsPage *_page) -{ -} - - -static void prefs_proxy_save(PrefsPage *_page) -{ - ProxyPage *page = (ProxyPage *)_page; - - prefs_common.use_proxy = gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(page->proxy_checkbtn)); - - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->socks4_radiobtn))) - prefs_common.proxy_info.proxy_type = PROXY_SOCKS4; - else - prefs_common.proxy_info.proxy_type = PROXY_SOCKS5; - - g_free(prefs_common.proxy_info.proxy_host); - prefs_common.proxy_info.proxy_host = g_strdup(gtk_entry_get_text( - GTK_ENTRY(page->proxy_host_entry))); - - prefs_common.proxy_info.proxy_port = gtk_spin_button_get_value_as_int( - GTK_SPIN_BUTTON(page->proxy_port_spinbtn)); - - prefs_common.proxy_info.use_proxy_auth = gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(page->proxy_auth_checkbtn)); - - g_free(prefs_common.proxy_info.proxy_name); - prefs_common.proxy_info.proxy_name = g_strdup(gtk_entry_get_text( - GTK_ENTRY(page->proxy_name_entry))); - - passwd_store_set(PWS_CORE, PWS_CORE_PROXY, PWS_CORE_PROXY_PASS, - gtk_entry_get_text(GTK_ENTRY(page->proxy_pass_entry)), FALSE); -} - - -ProxyPage *prefs_proxy; - -void prefs_proxy_init(void) -{ - ProxyPage *page; - static gchar *path[3]; - - path[0] = _("Mail Handling"); - path[1] = _("Proxy"); - path[2] = NULL; - - page = g_new0(ProxyPage, 1); - page->page.path = path; - page->page.create_widget = prefs_proxy_create_widget; - page->page.destroy_widget = prefs_proxy_destroy_widget; - page->page.save_page = prefs_proxy_save; - page->page.weight = 190.0; - - prefs_gtk_register_page((PrefsPage *)page); - prefs_proxy = page; -} - -void prefs_proxy_done(void) -{ - prefs_gtk_unregister_page((PrefsPage *)prefs_proxy); - g_free(prefs_proxy); -} - -static void showpwd_toggled(GtkEntry *entry, gpointer user_data) -{ - gboolean visible = gtk_entry_get_visibility(GTK_ENTRY(entry)); - - if (visible) { - gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); - gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), - GTK_ENTRY_ICON_SECONDARY, - "view-reveal-symbolic"); - gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), - GTK_ENTRY_ICON_SECONDARY, - _("Show password")); - } else { - gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE); - gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), - GTK_ENTRY_ICON_SECONDARY, - "view-conceal-symbolic"); - gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), - GTK_ENTRY_ICON_SECONDARY, - _("Hide password")); - } -} diff --git a/src/prefs_proxy.h b/src/prefs_proxy.h @@ -1,26 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2018 the Claws Mail team - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef PREFS_PROXY_H -#define PREFS_PROXY_H - -void prefs_proxy_init (void); -void prefs_proxy_done (void); - -#endif /* PREFS_PROXY_H */ diff --git a/src/send_message.c b/src/send_message.c @@ -47,7 +47,6 @@ #include "alertpanel.h" #include "manage_window.h" #include "logwindow.h" -#include "proxy.h" #include "socket.h" #include "utils.h" #include "gtkutils.h" @@ -217,7 +216,6 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g MsgFlags flags = {0, 0}; long fp_pos = 0; gchar spec_from[BUFFSIZE]; - ProxyInfo *proxy_info = NULL; cm_return_val_if_fail(ac_prefs != NULL, -1); cm_return_val_if_fail(ac_prefs->address != NULL, -1); @@ -390,21 +388,6 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g smtp_session->send_data = (guchar *)get_outgoing_rfc2822_str(fp); smtp_session->send_data_len = strlen((gchar *)smtp_session->send_data); - if (ac_prefs->use_proxy && ac_prefs->use_proxy_for_send) { - if (ac_prefs->use_default_proxy) { - proxy_info = (ProxyInfo *)&(prefs_common.proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get(PWS_CORE, PWS_CORE_PROXY, - PWS_CORE_PROXY_PASS); - } else { - proxy_info = (ProxyInfo *)&(ac_prefs->proxy_info); - if (proxy_info->use_proxy_auth) - proxy_info->proxy_pass = passwd_store_get_account(ac_prefs->account_id, - PWS_ACCOUNT_PROXY_PASS); - } - } - SESSION(smtp_session)->proxy_info = proxy_info; - session_set_timeout(session, prefs_common.io_timeout_secs * 1000); /* connect if necessary */