sync with 0.7.6cvs18
authorPaul Mangan <paul@claws-mail.org>
Wed, 29 May 2002 08:28:56 +0000 (08:28 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 29 May 2002 08:28:56 +0000 (08:28 +0000)
19 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/account.c
src/imap.c
src/imap.h
src/inc.c
src/news.c
src/nntp.c
src/nntp.h
src/pop.c
src/pop.h
src/prefs_account.c
src/prefs_account.h
src/send.c
src/smtp.c
src/smtp.h
src/ssl.h

index ce2192f..fd6130c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-29
+
+       * src/pop.[ch]
+         src/inc.c
+         src/prefs_account.[ch]: enabled STLS command in POP3.
+       * src/account.c: account_clist_set_row(): display TLS setting.
+
+2002-05-28
+
+       * src/compose.c: compose_send_later_cb(): support redirect function.
+       * src/imap.[ch]
+         src/ssl.h
+         src/prefs_account.[ch]: enabled STARTTLS command in IMAP4.
+       * src/send.c
+         src/smtp.[ch]: use SSLType instead of SSLSMTPType.
+
 2002-05-28
 
        * src/utils.[ch]: make_dir(): wrapper for mkdir() and chmod().
index 8796de4..04eac03 100644 (file)
@@ -1,3 +1,12 @@
+2002-05-29 [paul]      0.7.6claws24
+
+       * sync with 0.7.6cvs18
+               see ChangeLog 2002-05-28 and 2002-05-29
+
+       * src/news.c
+         src/nntp.[ch]
+               sync with above 
+
 2002-05-28 [paul]      0.7.6claws23
 
        * sync with 0.7.6cvs16
index 0e116e3..6e579f1 100644 (file)
@@ -1,3 +1,20 @@
+2002-05-29
+
+       * src/pop.[ch]
+         src/inc.c
+         src/prefs_account.[ch]: POP3 ¤Ç STLS ¥³¥Þ¥ó¥É¤òÍ­¸ú¤Ë¤·¤¿¡£
+       * src/account.c: account_clist_set_row(): TLS ¤ÎÀßÄê¤òɽ¼¨¡£
+
+2002-05-28
+
+       * src/compose.c: compose_send_later_cb(): ¡Ö¥ê¥À¥¤¥ì¥¯¥È¡×µ¡Ç½¤Ë
+         Âбþ¡£
+       * src/imap.[ch]
+         src/ssl.h
+         src/prefs_account.[ch]: IMAP4 ¤Ç STARTTLS ¥³¥Þ¥ó¥É¤òÍ­¸ú¤Ë¤·¤¿¡£
+       * src/send.c
+         src/smtp.[ch]: SSLSMTPType ¤ÎÂå¤ï¤ê¤Ë SSLType ¤ò»ÈÍÑ¡£
+
 2002-05-28
 
        * src/utils.[ch]: make_dir(): mkdir() ¤È chmod() ¤Î¥é¥Ã¥Ñ¡¼¡£
index 2c587bc..2b8b7ce 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws23
+EXTRA_VERSION=claws24
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 52066ba..47a980d 100644 (file)
@@ -796,13 +796,20 @@ static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
        text[COL_NAME]    = ac_prefs->account_name;
 #if USE_SSL
        text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ?
-                            (ac_prefs->ssl_pop ? "POP3 (SSL)" : "POP3") :
+                            (ac_prefs->ssl_pop == SSL_TUNNEL ?
+                             "POP3 (SSL)" :
+                             ac_prefs->ssl_pop == SSL_STARTTLS ?
+                             "POP3 (TLS)" : "POP3") :
                             ac_prefs->protocol == A_APOP ?
-                            (ac_prefs->ssl_pop ?
-                             "POP3 (APOP, SSL)" : "POP3 (APOP)") :
+                            (ac_prefs->ssl_pop == SSL_TUNNEL ?
+                             "POP3 (APOP, SSL)" :
+                             ac_prefs->ssl_pop == SSL_STARTTLS ?
+                             "POP3 (APOP, TLS)" : "POP3 (APOP)") :
                             ac_prefs->protocol == A_IMAP4 ?
-                            (ac_prefs->ssl_imap ? "IMAP4 (SSL)" : "IMAP4") :
-                            ac_prefs->protocol == A_LOCAL ? "Local" :
+                            (ac_prefs->ssl_imap == SSL_TUNNEL ?
+                             "IMAP4 (SSL)" :
+                             ac_prefs->ssl_imap == SSL_STARTTLS ?
+                             "IMAP4 (TLS)" : "IMAP4") :
                             ac_prefs->protocol == A_NNTP ? 
                                  (ac_prefs->ssl_nntp ? "NNTP (SSL)"  :  "NNTP") : "";
 #else
index 76319b7..752dd75 100644 (file)
@@ -112,16 +112,17 @@ static void imap_delete_all_cached_messages       (FolderItem     *item);
 #if USE_SSL
 static SockInfo *imap_open             (const gchar    *server,
                                         gushort         port,
-                                        gboolean        use_ssl);
+                                        SSLType         ssl_type);
 #else
 static SockInfo *imap_open             (const gchar    *server,
                                         gushort         port);
 #endif
 
 static SockInfo *imap_open_tunnel(const gchar *server,
-                                 const gchar *tunnelcmd);
+                                 const gchar *tunnelcmd,
+                                 SSLType ssl_type);
 
-static SockInfo *imap_init_sock(SockInfo *sock);
+static SockInfo *imap_init_sock(SockInfo *sock, SSLType ssl_type);
 
 static gint imap_set_message_flags     (IMAPSession    *session,
                                         guint32         first_uid,
@@ -183,6 +184,7 @@ static gint imap_cmd_login  (SockInfo       *sock,
                                 const gchar    *pass);
 static gint imap_cmd_logout    (SockInfo       *sock);
 static gint imap_cmd_noop      (SockInfo       *sock);
+static gint imap_cmd_starttls  (SockInfo       *sock);
 static gint imap_cmd_namespace (SockInfo       *sock,
                                 gchar         **ns_str);
 static gint imap_cmd_list      (SockInfo       *sock,
@@ -321,7 +323,8 @@ static IMAPSession *imap_session_get(Folder *folder)
 
 #if USE_SSL
        port = folder->account->set_imapport ? folder->account->imapport
-               : folder->account->ssl_imap ? IMAPS_PORT : IMAP4_PORT;
+               : folder->account->ssl_imap == SSL_TUNNEL
+               ? IMAPS_PORT : IMAP4_PORT;
 #else
        port = folder->account->set_imapport ? folder->account->imapport
                : IMAP4_PORT;
@@ -381,11 +384,11 @@ Session *imap_session_new(const PrefsAccount *account)
 
 #ifdef USE_SSL
        /* FIXME: IMAP over SSL only... */ 
-       gboolean use_ssl;
+       SSLType ssl_type;
 
        port = account->set_imapport ? account->imapport
                : account->ssl_imap ? IMAPS_PORT : IMAP4_PORT;
-       use_ssl = account->ssl_imap ? TRUE : FALSE;     
+       ssl_type = account->ssl_imap ? TRUE : FALSE;    
 #else
        port = account->set_imapport ? account->imapport
                : IMAP4_PORT;
@@ -394,7 +397,8 @@ Session *imap_session_new(const PrefsAccount *account)
        if (account->set_tunnelcmd) {
                log_message(_("creating tunneled IMAP4 connection\n"));
                if ((imap_sock = imap_open_tunnel(account->recv_server, 
-                                                 account->tunnelcmd)) == NULL)
+                                                 account->tunnelcmd,
+                                                 ssl_type)) == NULL)
                        return NULL;
        } else {
                g_return_val_if_fail(account->recv_server != NULL, NULL);
@@ -404,7 +408,7 @@ Session *imap_session_new(const PrefsAccount *account)
                
 #if USE_SSL
                if ((imap_sock = imap_open(account->recv_server, port,
-                                          use_ssl)) == NULL)
+                                          ssl_type)) == NULL)
 #else
                if ((imap_sock = imap_open(account->recv_server, port)) == NULL)
 #endif
@@ -1588,7 +1592,8 @@ static void imap_delete_all_cached_messages(FolderItem *item)
 
 
 static SockInfo *imap_open_tunnel(const gchar *server,
-                          const gchar *tunnelcmd)
+                          const gchar *tunnelcmd,
+                          SSLType ssl_type)
 {
        SockInfo *sock;
 
@@ -1597,13 +1602,13 @@ static SockInfo *imap_open_tunnel(const gchar *server,
                            server);
                return NULL;
 
-       return imap_init_sock(sock);
+       return imap_init_sock(sock, ssl_type);
 }
 
 
 #if USE_SSL
 static SockInfo *imap_open(const gchar *server, gushort port,
-                          gboolean use_ssl)
+                          SSLType ssl_type)
 #else
 static SockInfo *imap_open(const gchar *server, gushort port)
 #endif
@@ -1617,7 +1622,7 @@ static SockInfo *imap_open(const gchar *server, gushort port)
        }
 
 #if USE_SSL
-       if (use_ssl && !ssl_init_socket(sock)) {
+       if (ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
                log_warning(_("Can't establish IMAP4 session with: %s:%d\n"),
                            server, port);
                sock_close(sock);
@@ -1625,16 +1630,32 @@ static SockInfo *imap_open(const gchar *server, gushort port)
        }
 #endif
 
-       return imap_init_sock(sock);
+       return imap_init_sock(sock, ssl_type);
 }
 
 
-static SockInfo *imap_init_sock(SockInfo *sock)
+static SockInfo *imap_init_sock(SockInfo *sock, SSLType ssl_type)
 {
        imap_cmd_count = 0;
+#if USE_SSL
+       if (ssl_type == SSL_STARTTLS) {
+               gint ok;
+
+               ok = imap_cmd_starttls(sock);
+               if (ok != IMAP_SUCCESS) {
+                       log_warning(_("Can't start TLS session.\n"));
+                       sock_close(sock);
+                       return NULL;
+               }
+               if (!ssl_init_socket_with_method(sock, SSL_METHOD_TLSv1)) {
+                       sock_close(sock);
+                       return NULL;
+               }
+       }
+#endif
 
        if (imap_cmd_noop(sock) != IMAP_SUCCESS) {
-               log_warning(_("Can't establish IMAP4 session\n"));
+               log_warning(_("Can't establish IMAP4 session\n"));
                sock_close(sock);
                return NULL;
        }
@@ -2399,6 +2420,12 @@ static gint imap_cmd_noop(SockInfo *sock)
        return imap_cmd_ok(sock, NULL);
 }
 
+static gint imap_cmd_starttls(SockInfo *sock)
+{
+       imap_cmd_gen_send(sock, "STARTTLS");
+       return imap_cmd_ok(sock, NULL);
+}
+
 #define THROW(err) { ok = err; goto catch; }
 
 static gint imap_cmd_namespace(SockInfo *sock, gchar **ns_str)
index eb2c09d..d425aa8 100644 (file)
@@ -27,6 +27,9 @@
 #include <glib.h>
 #include <time.h>
 
+#if USE_SSL
+#  include "ssl.h"
+#endif
 #include "folder.h"
 #include "session.h"
 #include "procmsg.h"
index 67b1881..75d56c7 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -654,6 +654,9 @@ static IncState inc_pop3_session_do(IncSession *session)
        gchar *buf;
        static AtmHandler handlers[] = {
                pop3_greeting_recv      ,
+#if USE_SSL
+               pop3_stls_send          , pop3_stls_recv,
+#endif
                pop3_getauth_user_send  , pop3_getauth_user_recv,
                pop3_getauth_pass_send  , pop3_getauth_pass_recv,
                pop3_getauth_apop_send  , pop3_getauth_apop_recv,
@@ -683,7 +686,7 @@ static IncState inc_pop3_session_do(IncSession *session)
        for (i = POP3_GREETING_RECV; i < N_POP3_PHASE; i++)
                atm->state[i].handler = handlers[i];
        atm->state[POP3_GREETING_RECV].condition = GDK_INPUT_READ;
-       for (i = POP3_GETAUTH_USER_SEND; i < N_POP3_PHASE; ) {
+       for (i = POP3_GREETING_RECV + 1; i < N_POP3_PHASE; ) {
                atm->state[i++].condition = GDK_INPUT_WRITE;
                atm->state[i++].condition = GDK_INPUT_READ;
        }
@@ -697,7 +700,7 @@ static IncState inc_pop3_session_do(IncSession *session)
 #if USE_SSL
        port = pop3_state->ac_prefs->set_popport ?
                pop3_state->ac_prefs->popport :
-               pop3_state->ac_prefs->ssl_pop ? 995 : 110;
+               pop3_state->ac_prefs->ssl_pop == SSL_TUNNEL ? 995 : 110;
 #else
        port = pop3_state->ac_prefs->set_popport ?
                pop3_state->ac_prefs->popport : 110;
@@ -728,7 +731,8 @@ static IncState inc_pop3_session_do(IncSession *session)
        }
 
 #if USE_SSL
-       if (pop3_state->ac_prefs->ssl_pop && !ssl_init_socket(sockinfo)) {
+       if (pop3_state->ac_prefs->ssl_pop == SSL_TUNNEL &&
+           !ssl_init_socket(sockinfo)) {
                pop3_automaton_terminate(NULL, atm);
                automaton_destroy(atm);
                return INC_CONNECT_ERROR;
index 68dcf62..c0b14c4 100644 (file)
@@ -50,6 +50,7 @@
 
 #define NNTP_PORT      119
 #if USE_SSL
+#include "ssl.h"
 #define NNTPS_PORT 563
 #endif
 
@@ -61,7 +62,7 @@ static void news_folder_init           (Folder        *folder,
 static Session *news_session_new        (const gchar   *server,
                                          gushort        port,
                                          const gchar   *userid,
-                                         const gchar   *passwd, gboolean use_ssl);
+                                         const gchar   *passwd, SSLType ssl_type);
 #else
 static Session *news_session_new        (const gchar   *server,
                                          gushort        port,
@@ -132,7 +133,7 @@ static void news_folder_init(Folder *folder, const gchar *name,
 
 #if USE_SSL
 static Session *news_session_new(const gchar *server, gushort port,
-                                const gchar *userid, const gchar *passwd, gboolean use_ssl)
+                                const gchar *userid, const gchar *passwd, SSLType ssl_type)
 #else
 static Session *news_session_new(const gchar *server, gushort port,
                                 const gchar *userid, const gchar *passwd)
@@ -148,13 +149,13 @@ static Session *news_session_new(const gchar *server, gushort port,
 
        if (userid && passwd)
 #if USE_SSL
-               nntp_sock = nntp_open_auth(server, port, buf, userid, passwd, use_ssl);
+               nntp_sock = nntp_open_auth(server, port, buf, userid, passwd, ssl_type);
 #else
                nntp_sock = nntp_open_auth(server, port, buf, userid, passwd);
 #endif
        else
 #if USE_SSL
-               nntp_sock = nntp_open(server, port, buf, use_ssl);
+               nntp_sock = nntp_open(server, port, buf, ssl_type);
 #else
                nntp_sock = nntp_open(server, port, buf);
 #endif
index e771ecb..b28065d 100644 (file)
@@ -45,7 +45,7 @@ static gint nntp_gen_command  (NNTPSockInfo   *sock,
                                 ...);
 
 #if USE_SSL
-NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf, gboolean use_ssl)
+NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf, SSLType ssl_type)
 #else
 NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
 #endif
@@ -60,7 +60,7 @@ NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
        }
 
 #if USE_SSL
-       if (use_ssl && !ssl_init_socket(sock)) {
+       if (ssl_type && !ssl_init_socket(sock)) {
                 sock_close(sock);
                 return NULL;
        }
@@ -80,7 +80,7 @@ NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
 
 #if USE_SSL
 NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
-                            const gchar *userid, const gchar *passwd, gboolean use_ssl)
+                            const gchar *userid, const gchar *passwd, SSLType ssl_type)
 #else
 NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
                             const gchar *userid, const gchar *passwd)
@@ -89,7 +89,7 @@ NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
        NNTPSockInfo *sock;
 
 #if USE_SSL
-       sock = nntp_open(server, port, buf, use_ssl);
+       sock = nntp_open(server, port, buf, ssl_type);
 #else
        sock = nntp_open(server, port, buf);
 #endif
index 4ebfe3f..54c852e 100644 (file)
 
 #include "socket.h"
 
+#if USE_SSL
+#include "ssl.h"
+#endif
+
 typedef struct _NNTPSockInfo   NNTPSockInfo;
 
 struct _NNTPSockInfo
@@ -49,7 +53,7 @@ struct _NNTPSockInfo
 NNTPSockInfo *nntp_open                (const gchar    *server,
                                 gushort         port,
                                 gchar          *buf,
-                                gboolean use_ssl);
+                                SSLType        ssl_type);
 #else
 NNTPSockInfo *nntp_open                (const gchar    *server,
                                 gushort         port,
@@ -62,7 +66,7 @@ NNTPSockInfo *nntp_open_auth  (const gchar    *server,
                                 gchar          *buf,
                                 const gchar    *userid,
                                 const gchar    *passwd,
-                                gboolean use_ssl);
+                                SSLType        ssl_type);
 #else
 NNTPSockInfo *nntp_open_auth   (const gchar    *server,
                                 gushort         port,
index f04046e..0951490 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -37,6 +37,9 @@
 #include "inc.h"
 #include "recv.h"
 #include "selective_download.h"
+#if USE_SSL
+#  include "ssl.h"
+#endif
 
 #define LOOKUP_NEXT_MSG() \
        for (;;) { \
@@ -74,6 +77,12 @@ gint pop3_greeting_recv(SockInfo *sock, gpointer data)
        gchar buf[POPBUFSIZE];
 
        if (pop3_ok(sock, buf) == PS_SUCCESS) {
+#if USE_SSL
+               if (state->ac_prefs->ssl_pop == SSL_STARTTLS) {
+                       state->greeting = g_strdup(buf);
+                       return POP3_STLS_SEND;
+               }
+#endif
                if (state->ac_prefs->protocol == A_APOP) {
                        state->greeting = g_strdup(buf);
                        return POP3_GETAUTH_APOP_SEND;
@@ -83,6 +92,36 @@ gint pop3_greeting_recv(SockInfo *sock, gpointer data)
                return -1;
 }
 
+#if USE_SSL
+gint pop3_stls_send(SockInfo *sock, gpointer data)
+{
+       pop3_gen_send(sock, "STLS");
+
+       return POP3_STLS_RECV;
+}
+
+gint pop3_stls_recv(SockInfo *sock, gpointer data)
+{
+       Pop3State *state = (Pop3State *)data;
+       gint ok;
+
+       if ((ok = pop3_ok(sock, NULL)) == PS_SUCCESS) {
+               if (!ssl_init_socket_with_method(sock, SSL_METHOD_TLSv1))
+                       return -1;
+               if (state->ac_prefs->protocol == A_APOP) {
+                       return POP3_GETAUTH_APOP_SEND;
+               } else
+                       return POP3_GETAUTH_USER_SEND;
+       } else if (ok == PS_PROTOCOL) {
+               log_warning(_("can't start TLS session\n"));
+               state->error_val = PS_PROTOCOL;
+               state->inc_state = INC_ERROR;
+               return POP3_LOGOUT_SEND;
+       } else
+               return -1;
+}
+#endif /* USE_SSL */
+
 gint pop3_getauth_user_send(SockInfo *sock, gpointer data)
 {
        Pop3State *state = (Pop3State *)data;
index 394f32a..0b785c4 100644 (file)
--- a/src/pop.h
+++ b/src/pop.h
 #ifndef __POP_H__
 #define __POP_H__
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <glib.h>
 
 #include "socket.h"
@@ -28,6 +32,10 @@ typedef struct _Pop3MsgInfo  Pop3MsgInfo;
 
 typedef enum {
        POP3_GREETING_RECV,
+#if USE_SSL
+       POP3_STLS_SEND,
+       POP3_STLS_RECV,
+#endif
        POP3_GETAUTH_USER_SEND,
        POP3_GETAUTH_USER_RECV,
        POP3_GETAUTH_PASS_SEND,
@@ -94,6 +102,10 @@ gint pop3_getauth_pass_send (SockInfo *sock, gpointer data);
 gint pop3_getauth_pass_recv    (SockInfo *sock, gpointer data);
 gint pop3_getauth_apop_send    (SockInfo *sock, gpointer data);
 gint pop3_getauth_apop_recv    (SockInfo *sock, gpointer data);
+#if USE_SSL
+gint pop3_stls_send            (SockInfo *sock, gpointer data);
+gint pop3_stls_recv            (SockInfo *sock, gpointer data);
+#endif
 gint pop3_getrange_stat_send   (SockInfo *sock, gpointer data);
 gint pop3_getrange_stat_recv   (SockInfo *sock, gpointer data);
 gint pop3_getrange_last_send   (SockInfo *sock, gpointer data);
index 502c1ea..ffce665 100644 (file)
@@ -135,15 +135,25 @@ static struct Privacy {
 
 #if USE_SSL
 static struct SSLPrefs {
-       GtkWidget *receive_frame;
-       GtkWidget *pop_chkbtn;
-       GtkWidget *imap_chkbtn;
-       GtkWidget *nntp_chkbtn;
+       GtkWidget *pop_frame;
+       GtkWidget *pop_nossl_radiobtn;
+       GtkWidget *pop_ssltunnel_radiobtn;
+       GtkWidget *pop_starttls_radiobtn;
+
+       GtkWidget *nntp_frame;
+       GtkWidget *nntp_nossl_radiobtn;
+       GtkWidget *nntp_ssltunnel_radiobtn;
+       GtkWidget *nntp_starttls_radiobtn;
+
+       GtkWidget *imap_frame;
+       GtkWidget *imap_nossl_radiobtn;
+       GtkWidget *imap_ssltunnel_radiobtn;
+       GtkWidget *imap_starttls_radiobtn;
 
        GtkWidget *send_frame;
        GtkWidget *smtp_nossl_radiobtn;
        GtkWidget *smtp_ssltunnel_radiobtn;
-       GtkWidget *smtp_sslstarttls_radiobtn;
+       GtkWidget *smtp_starttls_radiobtn;
 } ssl;
 #endif /* USE_SSL */
 
@@ -358,16 +368,23 @@ static PrefParam param[] = {
 
 #if USE_SSL
        /* SSL */
+       {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
+        &ssl.pop_nossl_radiobtn,
+        prefs_account_enum_set_data_from_radiobtn,
+        prefs_account_enum_set_radiobtn},
+       {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
+        &ssl.imap_nossl_radiobtn,
+        prefs_account_enum_set_data_from_radiobtn,
+        prefs_account_enum_set_radiobtn},
        {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
         &ssl.smtp_nossl_radiobtn,
         prefs_account_enum_set_data_from_radiobtn,
         prefs_account_enum_set_radiobtn},
-       {"ssl_pop", "FALSE", &tmp_ac_prefs.ssl_pop, P_BOOL,
-        &ssl.pop_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
-       {"ssl_imap", "FALSE", &tmp_ac_prefs.ssl_imap, P_BOOL,
-        &ssl.imap_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
        {"ssl_nntp", "FALSE", &tmp_ac_prefs.ssl_nntp, P_BOOL,
-        &ssl.nntp_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
+        &ssl.nntp_nossl_radiobtn,
+       prefs_account_enum_set_data_from_radiobtn,
+        prefs_account_enum_set_radiobtn},
+
 #endif /* USE_SSL */
 
        /* Advanced */
@@ -1474,84 +1491,156 @@ static void prefs_account_ascii_armored_warning(GtkWidget* widget,
 #endif /* USE_GPGME */
 
 #if USE_SSL
+
+#define CREATE_RADIO_BUTTONS(box,                                      \
+                            btn1, btn1_label, btn1_data,               \
+                            btn2, btn2_label, btn2_data,               \
+                            btn3, btn3_label, btn3_data)               \
+{                                                                      \
+       btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
+       gtk_widget_show (btn1);                                         \
+       gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
+       gtk_object_set_user_data (GTK_OBJECT (btn1),                    \
+                                 GINT_TO_POINTER (btn1_data));         \
+                                                                       \
+       btn2 = gtk_radio_button_new_with_label_from_widget              \
+               (GTK_RADIO_BUTTON (btn1), btn2_label);                  \
+       gtk_widget_show (btn2);                                         \
+       gtk_box_pack_start (GTK_BOX (box), btn2, FALSE, FALSE, 0);      \
+       gtk_object_set_user_data (GTK_OBJECT (btn2),                    \
+                                 GINT_TO_POINTER (btn2_data));         \
+                                                                       \
+       btn3 = gtk_radio_button_new_with_label_from_widget              \
+               (GTK_RADIO_BUTTON (btn1), btn3_label);                  \
+       gtk_widget_show (btn3);                                         \
+       gtk_box_pack_start (GTK_BOX (box), btn3, FALSE, FALSE, 0);      \
+       gtk_object_set_user_data (GTK_OBJECT (btn3),                    \
+                                 GINT_TO_POINTER (btn3_data));         \
+}
+
 static void prefs_account_ssl_create(void)
 {
        GtkWidget *vbox1;
 
-       GtkWidget *receive_frame;
+       GtkWidget *pop_frame;
        GtkWidget *vbox2;
-       GtkWidget *pop_chkbtn;
-       GtkWidget *imap_chkbtn;
-       GtkWidget *nntp_chkbtn;
+       GtkWidget *pop_nossl_radiobtn;
+       GtkWidget *pop_ssltunnel_radiobtn;
+       GtkWidget *pop_starttls_radiobtn;
 
-       GtkWidget *send_frame;
+       GtkWidget *imap_frame;
        GtkWidget *vbox3;
+       GtkWidget *imap_nossl_radiobtn;
+       GtkWidget *imap_ssltunnel_radiobtn;
+       GtkWidget *imap_starttls_radiobtn;
+
+       GtkWidget *nntp_frame;
+       GtkWidget *vbox4;
+       GtkWidget *nntp_nossl_radiobtn;
+       GtkWidget *nntp_ssltunnel_radiobtn;
+       GtkWidget *nntp_starttls_radiobtn;
+
+       GtkWidget *send_frame;
+       GtkWidget *vbox5;
        GtkWidget *smtp_nossl_radiobtn;
        GtkWidget *smtp_ssltunnel_radiobtn;
-       GtkWidget *smtp_sslstarttls_radiobtn;
+       GtkWidget *smtp_starttls_radiobtn;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
-       PACK_FRAME (vbox1, receive_frame, _("Receive"));
-
+       PACK_FRAME (vbox1, pop_frame, _("POP3"));
        vbox2 = gtk_vbox_new (FALSE, 0);
        gtk_widget_show (vbox2);
-       gtk_container_add (GTK_CONTAINER (receive_frame), vbox2);
+       gtk_container_add (GTK_CONTAINER (pop_frame), vbox2);
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
 
-       PACK_CHECK_BUTTON (vbox2, pop_chkbtn,
-                          _("Use SSL for POP3 connection"));
-       PACK_CHECK_BUTTON (vbox2, imap_chkbtn,
-                          _("Use SSL for IMAP4 connection"));
-       PACK_CHECK_BUTTON (vbox2, nntp_chkbtn,
-                          _("Use SSL for NNTP connection"));
-
-       PACK_FRAME (vbox1, send_frame, _("Send (SMTP)"));
+       CREATE_RADIO_BUTTONS(vbox2,
+                            pop_nossl_radiobtn,
+                            _("Don't use SSL"),
+                            SSL_NONE,
+                            pop_ssltunnel_radiobtn,
+                            _("Use SSL for POP3 connection"),
+                            SSL_TUNNEL,
+                            pop_starttls_radiobtn,
+                            _("Use STARTTLS command to start SSL session"),
+                            SSL_STARTTLS);
 
+       PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
        vbox3 = gtk_vbox_new (FALSE, 0);
        gtk_widget_show (vbox3);
-       gtk_container_add (GTK_CONTAINER (send_frame), vbox3);
+       gtk_container_add (GTK_CONTAINER (imap_frame), vbox3);
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
 
-       smtp_nossl_radiobtn =
-               gtk_radio_button_new_with_label(NULL, _("Don't use SSL"));
-       gtk_widget_show (smtp_nossl_radiobtn);
-       gtk_box_pack_start (GTK_BOX (vbox3), smtp_nossl_radiobtn,
-                           FALSE, FALSE, 0);
-       gtk_object_set_user_data (GTK_OBJECT (smtp_nossl_radiobtn),
-                                 GINT_TO_POINTER (SSL_SMTP_NONE));
-
-       smtp_ssltunnel_radiobtn = gtk_radio_button_new_with_label_from_widget
-               (GTK_RADIO_BUTTON (smtp_nossl_radiobtn),
-                _("Use SSL for SMTP connection"));
-       gtk_widget_show (smtp_ssltunnel_radiobtn);
-       gtk_box_pack_start (GTK_BOX (vbox3), smtp_ssltunnel_radiobtn,
-                           FALSE, FALSE, 0);
-       gtk_object_set_user_data (GTK_OBJECT (smtp_ssltunnel_radiobtn),
-                                 GINT_TO_POINTER (SSL_SMTP_TUNNEL));
-
-       smtp_sslstarttls_radiobtn = gtk_radio_button_new_with_label_from_widget
-               (GTK_RADIO_BUTTON (smtp_nossl_radiobtn),
-                _("Use STARTTLS command to start SSL session"));
-       gtk_widget_show (smtp_sslstarttls_radiobtn);
-       gtk_box_pack_start (GTK_BOX (vbox3), smtp_sslstarttls_radiobtn,
-                           FALSE, FALSE, 0);
-       gtk_object_set_user_data (GTK_OBJECT (smtp_sslstarttls_radiobtn),
-                                 GINT_TO_POINTER (SSL_SMTP_STARTTLS));
-
-       ssl.receive_frame = receive_frame;
-       ssl.pop_chkbtn    = pop_chkbtn;
-       ssl.imap_chkbtn   = imap_chkbtn;
-       ssl.nntp_chkbtn   = nntp_chkbtn;
-
-       ssl.send_frame                = send_frame;
-       ssl.smtp_nossl_radiobtn       = smtp_nossl_radiobtn;
-       ssl.smtp_ssltunnel_radiobtn   = smtp_ssltunnel_radiobtn;
-       ssl.smtp_sslstarttls_radiobtn = smtp_sslstarttls_radiobtn;
+       CREATE_RADIO_BUTTONS(vbox3,
+                            imap_nossl_radiobtn,
+                            _("Don't use SSL"),
+                            SSL_NONE,
+                            imap_ssltunnel_radiobtn,
+                            _("Use SSL for IMAP4 connection"),
+                            SSL_TUNNEL,
+                            imap_starttls_radiobtn,
+                            _("Use STARTTLS command to start SSL session"),
+                            SSL_STARTTLS);
+
+       PACK_FRAME (vbox1, nntp_frame, _("NNTP"));
+       vbox4 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox4);
+       gtk_container_add (GTK_CONTAINER (nntp_frame), vbox4);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox4), 8);
+
+       CREATE_RADIO_BUTTONS(vbox4,
+                            nntp_nossl_radiobtn,
+                            _("Don't use SSL"),
+                            SSL_NONE,
+                            nntp_ssltunnel_radiobtn,
+                            _("Use SSL for NNTP connection"),
+                            SSL_TUNNEL,
+                            nntp_starttls_radiobtn,
+                            _("Use STARTTLS command to start SSL session"),
+                            SSL_STARTTLS);
+
+       PACK_FRAME (vbox1, send_frame, _("Send (SMTP)"));
+       vbox5 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox5);
+       gtk_container_add (GTK_CONTAINER (send_frame), vbox5);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox5), 8);
+
+       CREATE_RADIO_BUTTONS(vbox5,
+                            smtp_nossl_radiobtn,
+                            _("Don't use SSL"),
+                            SSL_NONE,
+                            smtp_ssltunnel_radiobtn,
+                            _("Use SSL for SMTP connection"),
+                            SSL_TUNNEL,
+                            smtp_starttls_radiobtn,
+                            _("Use STARTTLS command to start SSL session"),
+                            SSL_STARTTLS);
+
+       ssl.pop_frame               = pop_frame;
+       ssl.pop_nossl_radiobtn      = pop_nossl_radiobtn;
+       ssl.pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
+       ssl.pop_starttls_radiobtn   = pop_starttls_radiobtn;
+
+       ssl.imap_frame              = imap_frame;
+       ssl.imap_nossl_radiobtn     = imap_nossl_radiobtn;
+       ssl.imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
+       ssl.imap_starttls_radiobtn  = imap_starttls_radiobtn;
+
+       ssl.nntp_frame              = nntp_frame;
+       ssl.nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
+       ssl.nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
+       ssl.nntp_starttls_radiobtn  = nntp_starttls_radiobtn;
+
+       ssl.send_frame              = send_frame;
+       ssl.smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
+       ssl.smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
+       ssl.smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
 }
+
+#undef CREATE_RADIO_BUTTONS
 #endif /* USE_SSL */
 
 static void crosspost_color_toggled(void)
@@ -2074,11 +2163,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                }
 
 #if USE_SSL
-               gtk_widget_set_sensitive(ssl.receive_frame, TRUE);
-               gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.nntp_chkbtn, TRUE);
-               gtk_widget_set_sensitive(ssl.send_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.pop_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.imap_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.nntp_frame, TRUE);
+               gtk_widget_set_sensitive(ssl.send_frame, TRUE);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
                gtk_widget_hide(advanced.imapport_hbox);
@@ -2138,10 +2226,9 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                }
 
 #if USE_SSL
-               gtk_widget_set_sensitive(ssl.receive_frame, FALSE);
-               gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.nntp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(ssl.pop_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.imap_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.nntp_frame, FALSE);
                gtk_widget_set_sensitive(ssl.send_frame, TRUE);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
@@ -2204,10 +2291,9 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                }
 
 #if USE_SSL
-               gtk_widget_set_sensitive(ssl.receive_frame, TRUE);
-               gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.imap_chkbtn, TRUE);
-               gtk_widget_set_sensitive(ssl.nntp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(ssl.pop_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.imap_frame, TRUE);
+               gtk_widget_set_sensitive(ssl.nntp_frame, FALSE);
                gtk_widget_set_sensitive(ssl.send_frame, TRUE);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
@@ -2271,10 +2357,9 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                }
 
 #if USE_SSL
-               gtk_widget_set_sensitive(ssl.receive_frame, TRUE);
-               gtk_widget_set_sensitive(ssl.pop_chkbtn, TRUE);
-               gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE);
-               gtk_widget_set_sensitive(ssl.nntp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(ssl.pop_frame, TRUE);
+               gtk_widget_set_sensitive(ssl.imap_frame, FALSE);
+               gtk_widget_set_sensitive(ssl.nntp_frame, FALSE);
                gtk_widget_set_sensitive(ssl.send_frame, TRUE);
 #endif
                gtk_widget_show(advanced.popport_hbox);
index 90bcf5e..e5d6825 100644 (file)
@@ -84,11 +84,10 @@ struct _PrefsAccount
        gchar * mail_command;
 
 #if USE_SSL
-       /* SSL */
-       gboolean ssl_pop;
-       gboolean ssl_imap;
-       gboolean ssl_nntp;
-       SSLSMTPType ssl_smtp;
+       SSLType ssl_pop;
+       SSLType ssl_imap;
+       SSLType ssl_nntp;
+       SSLType ssl_smtp;
 #endif /* USE_SSL */
 
        /* Temporarily preserved password */
index 94e234b..d654bd0 100644 (file)
@@ -319,7 +319,7 @@ gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list,
 
 #if USE_SSL
        port = ac_prefs->set_smtpport ? ac_prefs->smtpport :
-               ac_prefs->ssl_smtp == SSL_SMTP_TUNNEL ? SSMTP_PORT : SMTP_PORT;
+               ac_prefs->ssl_smtp == SSL_TUNNEL ? SSMTP_PORT : SMTP_PORT;
 #else
        port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT;
 #endif
index 709faef..f398ac5 100644 (file)
@@ -43,7 +43,7 @@ static gint smtp_ok(SockInfo *sock, gchar *buf, gint len);
 Session *smtp_session_new(const gchar *server, gushort port,
                          const gchar *domain,
                          const gchar *user, const gchar *pass,
-                         SSLSMTPType ssl_type)
+                         SSLType ssl_type)
 #else
 Session *smtp_session_new(const gchar *server, gushort port,
                          const gchar *domain,
@@ -59,7 +59,7 @@ Session *smtp_session_new(const gchar *server, gushort port,
        g_return_val_if_fail(server != NULL, NULL);
 
 #if USE_SSL
-       use_esmtp = user != NULL || ssl_type == SSL_SMTP_STARTTLS;
+       use_esmtp = user != NULL || ssl_type == SSL_STARTTLS;
 #else
        use_esmtp = user != NULL;
 #endif
@@ -71,7 +71,7 @@ Session *smtp_session_new(const gchar *server, gushort port,
        }
 
 #if USE_SSL
-       if (ssl_type == SSL_SMTP_TUNNEL && !ssl_init_socket(sock)) {
+       if (ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
                log_warning(_("SSL connection failed"));
                sock_close(sock);
                return NULL;
@@ -99,7 +99,7 @@ Session *smtp_session_new(const gchar *server, gushort port,
        }
 
 #if USE_SSL
-       if (ssl_type == SSL_SMTP_STARTTLS) {
+       if (ssl_type == SSL_STARTTLS) {
                val = smtp_starttls(sock);
                if (val != SM_OK) {
                        log_warning(_("Error occurred while sending STARTTLS\n"));
index 8e5707d..3fd848c 100644 (file)
@@ -47,15 +47,6 @@ typedef struct _SMTPSession  SMTPSession;
 #define        ESMTP_SIZE              0x02
 #define        ESMTP_ETRN              0x04
 
-#if USE_SSL
-typedef enum
-{
-       SSL_SMTP_NONE,
-       SSL_SMTP_TUNNEL,
-       SSL_SMTP_STARTTLS
-} SSLSMTPType;
-#endif
-
 typedef enum
 {
        SMTPAUTH_LOGIN      = 1 << 0,
@@ -78,7 +69,7 @@ Session *smtp_session_new     (const gchar    *server,
                                 const gchar    *domain,
                                 const gchar    *user,
                                 const gchar    *pass,
-                                SSLSMTPType     ssl_type);
+                                SSLType         ssl_type);
 #else
 Session *smtp_session_new      (const gchar    *server,
                                 gushort         port,
index e3c5e6b..6c13dda 100644 (file)
--- a/src/ssl.h
+++ b/src/ssl.h
@@ -40,6 +40,12 @@ typedef enum {
        SSL_METHOD_TLSv1
 } SSLMethod;
 
+typedef enum {
+       SSL_NONE,
+       SSL_TUNNEL,
+       SSL_STARTTLS
+} SSLType;
+
 void ssl_init                          (void);
 void ssl_done                          (void);
 gboolean ssl_init_socket               (SockInfo       *sockinfo);