enable NNTP over SSL
authorPaul Mangan <paul@claws-mail.org>
Mon, 25 Mar 2002 09:37:38 +0000 (09:37 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 25 Mar 2002 09:37:38 +0000 (09:37 +0000)
AUTHORS
ChangeLog.claws
configure.in
src/account.c
src/news.c
src/nntp.c
src/nntp.h
src/prefs_account.c
src/prefs_account.h

diff --git a/AUTHORS b/AUTHORS
index dd878668726d9c274279e86ca731f2078ad7d3c1..269ad2f60c6d2b6f61528d1fb0b6cffe333bdc54 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -136,3 +136,4 @@ contributors (beside the above; based on Changelog)
        Wilbert Berendsen
        Bob Woodside
        Stefaan Eeckels
+       Pascal Jermini
index 8468bd7a5103ab753a639853b227aa44c55732b5..fdfb913f862ccd1a9fac8c8d41baca4f649cceeb 100644 (file)
@@ -1,3 +1,12 @@
+2002-03-25 [paul]      0.7.4claws40
+
+       * src/account.c
+         src/news.c
+         src/nntp.[ch]
+         src/prefs_account.[ch]
+               enable NNTP over SSL. patch submitted by
+               Pascal Jermini <pascal@infinity.hn.org>
+
 2002-03-24 [paul]      0.7.4claws39
 
        * src/prefs_common.c
index 1e19c44cdc2878d4a028edb1bc90bacf17b08f96..de76bf60bc320d8b2e0b6ea49d9b49b8e4bbc3bd 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws39
+EXTRA_VERSION=claws40
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 7a953f8eaac66c951fae27c253bcbf1c6d73b094..bfbf656a1ed5e6e88aebb0d496b008b7cfa7490c 100644 (file)
@@ -752,7 +752,8 @@ static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
                             ac_prefs->protocol == A_IMAP4 ?
                             (ac_prefs->ssl_imap ? "IMAP4 (SSL)" : "IMAP4") :
                             ac_prefs->protocol == A_LOCAL ? "Local" :
-                            ac_prefs->protocol == A_NNTP ? "NNTP"  :  "";
+                            ac_prefs->protocol == A_NNTP ? 
+                                 (ac_prefs->ssl_nntp ? "NNTP (SSL)"  :  "NNTP") : "";
 #else
        text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3  ? "POP3" :
                             ac_prefs->protocol == A_APOP  ? "POP3 (APOP)" :
index 9bff6fc469940dc6b9f4f52124a84f97cc0e1d59..6e46ecc2b17d7db2b91c5bdea0af86474a396b35 100644 (file)
 #include "alertpanel.h"
 
 #define NNTP_PORT      119
+#if USE_SSL
+#define NNTPS_PORT 563
+#endif
 
 static void news_folder_init            (Folder        *folder,
                                          const gchar   *name,
                                          const gchar   *path);
 
+#if USE_SSL
+static Session *news_session_new        (const gchar   *server,
+                                         gushort        port,
+                                         const gchar   *userid,
+                                         const gchar   *passwd, gboolean use_ssl);
+#else
 static Session *news_session_new        (const gchar   *server,
                                          gushort        port,
                                          const gchar   *userid,
                                          const gchar   *passwd);
+#endif
 
 static gint news_get_article_cmd        (NNTPSession   *session,
                                          const gchar   *cmd,
@@ -120,8 +130,13 @@ static void news_folder_init(Folder *folder, const gchar *name,
        folder->remove_msg   = news_remove_msg;
 }
 
+#if USE_SSL
+static Session *news_session_new(const gchar *server, gushort port,
+                                const gchar *userid, const gchar *passwd, gboolean use_ssl)
+#else
 static Session *news_session_new(const gchar *server, gushort port,
                                 const gchar *userid, const gchar *passwd)
+#endif
 {
        gchar buf[NNTPBUFSIZE];
        NNTPSession *session;
@@ -132,9 +147,18 @@ static Session *news_session_new(const gchar *server, gushort port,
        log_message(_("creating NNTP connection to %s:%d ...\n"), server, port);
 
        if (userid && passwd)
+#if USE_SSL
+               nntp_sock = nntp_open_auth(server, port, buf, userid, passwd, use_ssl);
+#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);
+#else
                nntp_sock = nntp_open(server, port, buf);
+#endif
+
        if (nntp_sock == NULL)
                return NULL;
 
@@ -167,11 +191,22 @@ static Session *news_session_new_for_folder(Folder *folder)
        PrefsAccount *ac;
        const gchar *userid = NULL;
        gchar *passwd = NULL;
+       int port;
 
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(folder->account != NULL, NULL);
 
        ac = folder->account;
+
+#if USE_SSL
+       if (ac->set_nntpport) {
+                port = ac->nntpport;
+       } else {
+                port = ac->ssl_nntp ? NNTPS_PORT : NNTP_PORT;
+       }
+#else
+       port = ac->set_nntpport ? ac->nntpport : NNTP_PORT;
+#endif
        if (ac->use_nntp_auth && ac->userid && ac->userid[0]) {
                userid = ac->userid;
                if (ac->passwd && ac->passwd[0])
@@ -181,9 +216,15 @@ static Session *news_session_new_for_folder(Folder *folder)
                                                             userid);
        }
 
+#if USE_SSL
        session = news_session_new(ac->nntp_server,
-                                  ac->set_nntpport ? ac->nntpport : NNTP_PORT,
+                                  port, 
+                                  userid, passwd, ac->ssl_nntp);
+#else
+       session = news_session_new(ac->nntp_server,
+                                  port, 
                                   userid, passwd);
+#endif
        g_free(passwd);
 
        return session;
index 458ffe739b1cfbefb039464d4183b05737a03ad8..a15921fb65569d1610eba4b9657b3b1776c2f99c 100644 (file)
@@ -28,6 +28,7 @@
 #include "intl.h"
 #include "nntp.h"
 #include "socket.h"
+#include "ssl.h"
 #include "utils.h"
 
 static gint verbose = 1;
@@ -43,7 +44,11 @@ static gint nntp_gen_command (NNTPSockInfo   *sock,
                                 const gchar    *format,
                                 ...);
 
+#if USE_SSL
+NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf, gboolean use_ssl)
+#else
 NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
+#endif
 {
        SockInfo *sock;
        NNTPSockInfo *nntp_sock;
@@ -53,6 +58,14 @@ NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
                            server, port);
                return NULL;
        }
+
+#if USE_SSL
+       if (use_ssl && !ssl_init_socket(sock)) {
+                sock_close(sock);
+                return NULL;
+       }
+#endif
+       
        nntp_sock = g_new0(NNTPSockInfo, 1);
        nntp_sock->sock = sock;
 
@@ -65,12 +78,22 @@ 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)
+#else
 NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
                             const gchar *userid, const gchar *passwd)
+#endif
 {
        NNTPSockInfo *sock;
 
+#if USE_SSL
+       sock = nntp_open(server, port, buf, use_ssl);
+#else
        sock = nntp_open(server, port, buf);
+#endif
+
        if (!sock) return NULL;
 
        sock->userid = g_strdup(userid);
index 3063c08360d71ecd3f9abde31fb9134037433dc5..4ebfe3f2a38e443965d1dd4715f8b70f35f8b968 100644 (file)
@@ -45,14 +45,31 @@ struct _NNTPSockInfo
 
 #define NNTPBUFSIZE    8192
 
+#if USE_SSL
+NNTPSockInfo *nntp_open                (const gchar    *server,
+                                gushort         port,
+                                gchar          *buf,
+                                gboolean use_ssl);
+#else
 NNTPSockInfo *nntp_open                (const gchar    *server,
                                 gushort         port,
                                 gchar          *buf);
+#endif
+
+#if USE_SSL
+NNTPSockInfo *nntp_open_auth   (const gchar    *server,
+                                gushort         port,
+                                gchar          *buf,
+                                const gchar    *userid,
+                                const gchar    *passwd,
+                                gboolean use_ssl);
+#else
 NNTPSockInfo *nntp_open_auth   (const gchar    *server,
                                 gushort         port,
                                 gchar          *buf,
                                 const gchar    *userid,
                                 const gchar    *passwd);
+#endif
 void nntp_close                        (NNTPSockInfo   *sock);
 gint nntp_group                        (NNTPSockInfo   *sock,
                                 const gchar    *group,
index 25b62ce799d50b8664ee97bbc467ecb92d15583f..a3c4841c0fef834c6918f4413e6e10b72fe4fa4a 100644 (file)
@@ -141,6 +141,7 @@ static struct SSLPrefs {
        GtkWidget *receive_frame;
        GtkWidget *pop_chkbtn;
        GtkWidget *imap_chkbtn;
+       GtkWidget *nntp_chkbtn;
 
        GtkWidget *send_frame;
        GtkWidget *smtp_nossl_radiobtn;
@@ -362,6 +363,8 @@ static PrefParam param[] = {
         &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},
 #endif /* USE_SSL */
 
        /* Advanced */
@@ -1478,6 +1481,7 @@ static void prefs_account_ssl_create(void)
        GtkWidget *vbox2;
        GtkWidget *pop_chkbtn;
        GtkWidget *imap_chkbtn;
+       GtkWidget *nntp_chkbtn;
 
        GtkWidget *send_frame;
        GtkWidget *vbox3;
@@ -1501,6 +1505,8 @@ static void prefs_account_ssl_create(void)
                           _("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)"));
 
@@ -1538,6 +1544,7 @@ static void prefs_account_ssl_create(void)
        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;
@@ -1963,9 +1970,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_set_sensitive(receive.imap_frame, FALSE);
                gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
 #if USE_SSL
-               gtk_widget_set_sensitive(ssl.receive_frame, FALSE);
+               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);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
@@ -2023,6 +2031,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                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.send_frame, TRUE);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
@@ -2082,6 +2091,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                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.send_frame, TRUE);
 #endif
                gtk_widget_hide(advanced.popport_hbox);
@@ -2142,6 +2152,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                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.send_frame, TRUE);
 #endif
                gtk_widget_show(advanced.popport_hbox);
index 45f1d7f6554ab0c0a77649cd1bfcec646bcbbac4..6215fd9aa5c9f803fc1a48832b0cabbded9471bf 100644 (file)
@@ -94,6 +94,7 @@ struct _PrefsAccount
        /* SSL */
        gboolean ssl_pop;
        gboolean ssl_imap;
+       gboolean ssl_nntp;
        SSLSMTPType ssl_smtp;
 #endif /* USE_SSL */