0.8.9claws16
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 27 Jan 2003 10:33:19 +0000 (10:33 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 27 Jan 2003 10:33:19 +0000 (10:33 +0000)
* src/news.c
* src/prefs_account.[ch]
* src/common/nntp.[ch]
allow to force authentication for NNTP servers

Patch submitted by Florian Mickler <dmk@d-labs.de>

AUTHORS
ChangeLog.claws
configure.ac
src/common/nntp.c
src/common/nntp.h
src/news.c
src/prefs_account.c
src/prefs_account.h

diff --git a/AUTHORS b/AUTHORS
index 5ca0d2a..bfbe81a 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -169,3 +169,4 @@ contributors (beside the above; based on Changelog)
        Kim Schulz
        Christian Mertes
        Jens Rantil
+       Florian Mickler
index 7252239..4c27650 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-27 [christoph] 0.8.9claws16
+
+       * src/news.c
+       * src/prefs_account.[ch]
+       * src/common/nntp.[ch]
+               allow to force authentication for NNTP servers
+
+       Patch submitted by Florian Mickler <dmk@d-labs.de>
+
 2003-01-26 [paul]      0.8.9claws15
 
        * src/summaryview.c
index 90d2091..64ce6e2 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=9
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws15
+EXTRA_VERSION=claws16
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 14a5323..f98d889 100644 (file)
@@ -117,6 +117,15 @@ void nntp_close(NNTPSockInfo *sock)
        g_free(sock);
 }
 
+void nntp_forceauth(NNTPSockInfo *sock, gchar *buf, const gchar *userid, const gchar *passwd)
+
+{
+       if (!sock) return;
+               
+       nntp_gen_command(sock, buf , "AUTHINFO USER %s", userid);
+
+
+}
 gint nntp_group(NNTPSockInfo *sock, const gchar *group,
                gint *num, gint *first, gint *last)
 {
@@ -389,7 +398,16 @@ static gint nntp_gen_command(NNTPSockInfo *sock, gchar *argbuf,
 
                nntp_gen_send(sock, "%s", buf);
                ok = nntp_ok(sock, argbuf);
-       }
+
+       } else if (ok == NN_AUTHCONT) {
+                nntp_gen_send(sock, "AUTHINFO PASS %s", sock->passwd);
+                ok = nntp_ok(sock, NULL);
+
+                if (ok != NN_SUCCESS) {
+                       sock->auth_failed = TRUE;
+                        return ok;
+                }
+        }
 
        return ok;
 }
index 46d05d4..9b655b9 100644 (file)
@@ -70,6 +70,12 @@ NNTPSockInfo *nntp_open_auth (const gchar    *server,
                                 const gchar    *passwd);
 #endif
 void nntp_close                        (NNTPSockInfo   *sock);
+
+void nntp_forceauth            (NNTPSockInfo   *sock,
+                                gchar *buf, 
+                                const gchar    *userid, 
+                                const gchar    *passwd);
+
 gint nntp_group                        (NNTPSockInfo   *sock,
                                 const gchar    *group,
                                 gint           *num,
index 1f8745f..06d3963 100644 (file)
@@ -227,6 +227,7 @@ static Session *news_session_new_for_folder(Folder *folder)
        const gchar *userid = NULL;
        gchar *passwd = NULL;
        gushort port;
+       gchar buf[NNTPBUFSIZE];
 
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(folder->account != NULL, NULL);
@@ -250,6 +251,8 @@ static Session *news_session_new_for_folder(Folder *folder)
        port = ac->set_nntpport ? ac->nntpport : NNTP_PORT;
        session = news_session_new(ac->nntp_server, port, userid, passwd);
 #endif
+       if (ac->use_nntp_auth && ac->use_nntp_auth_onconnect)
+               nntp_forceauth(NNTP_SESSION(session)->nntp_sock, buf, userid, passwd);
 
        g_free(passwd);
 
index 8a78de3..8e1aa60 100644 (file)
@@ -74,6 +74,7 @@ static struct Basic {
        GtkWidget *smtpserv_entry;
        GtkWidget *nntpserv_entry;
        GtkWidget *nntpauth_chkbtn;
+       GtkWidget *nntpauth_onconnect_chkbtn;
        GtkWidget *localmbox_entry;
        GtkWidget *mailcmd_chkbtn;
        GtkWidget *mailcmd_entry;
@@ -103,9 +104,7 @@ static struct Receive {
 static struct Send {
        GtkWidget *date_chkbtn;
        GtkWidget *msgid_chkbtn;
-
        GtkWidget *customhdr_chkbtn;
-
        GtkWidget *smtp_auth_chkbtn;
        GtkWidget *smtp_auth_type_optmenu;
        GtkWidget *smtp_uid_entry;
@@ -116,7 +115,6 @@ static struct Send {
 
 static struct Compose {
        GtkWidget *sigpath_entry;
-
        GtkWidget *autocc_chkbtn;
        GtkWidget *autocc_entry;
        GtkWidget *autobcc_chkbtn;
@@ -262,6 +260,10 @@ static PrefParam param[] = {
        {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
         &basic.nntpauth_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
+       
+       {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs.use_nntp_auth_onconnect, P_BOOL,
+        &basic.nntpauth_onconnect_chkbtn,
+        prefs_set_data_from_toggle, prefs_set_toggle},
 
        {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING,
         &basic.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
@@ -804,6 +806,7 @@ static void prefs_account_basic_create(void)
        GtkWidget *smtpserv_entry;
        GtkWidget *nntpserv_entry;
        GtkWidget *nntpauth_chkbtn;
+       GtkWidget *nntpauth_onconnect_chkbtn;
        GtkWidget *localmbox_entry;
        GtkWidget *mailcmd_chkbtn;
        GtkWidget *mailcmd_entry;
@@ -930,7 +933,15 @@ static void prefs_account_basic_create(void)
        nntpauth_chkbtn = gtk_check_button_new_with_label
                (_("This server requires authentication"));
        gtk_widget_show (nntpauth_chkbtn);
-       gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 4, 1, 2,
+       
+       gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 2, 1, 2,
+                         GTK_FILL, 0, 0, 0);
+
+       nntpauth_onconnect_chkbtn = gtk_check_button_new_with_label
+               (_("Authenticate on connect"));
+       gtk_widget_show (nntpauth_onconnect_chkbtn);
+
+       gtk_table_attach (GTK_TABLE (serv_table), nntpauth_onconnect_chkbtn, 2, 4, 1, 2,
                          GTK_FILL, 0, 0, 0);
 
        recvserv_entry = gtk_entry_new ();
@@ -1030,6 +1041,7 @@ static void prefs_account_basic_create(void)
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_label);
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_entry);
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_entry);
+       SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, nntpauth_onconnect_chkbtn);
 
        basic.acname_entry   = acname_entry;
        basic.default_chkbtn = default_chkbtn;
@@ -1048,6 +1060,7 @@ static void prefs_account_basic_create(void)
        basic.nntpserv_label   = nntpserv_label;
        basic.nntpserv_entry   = nntpserv_entry;
        basic.nntpauth_chkbtn  = nntpauth_chkbtn;
+       basic.nntpauth_onconnect_chkbtn  = nntpauth_onconnect_chkbtn;
        basic.localmbox_label   = localmbox_label;
        basic.localmbox_entry   = localmbox_entry;
        basic.mailcmd_chkbtn   = mailcmd_chkbtn;
@@ -2297,8 +2310,13 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_show(basic.nntpserv_entry);
                gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
                                           0, VSPACING_NARROW);
+
                gtk_widget_set_sensitive(basic.nntpauth_chkbtn, TRUE);
                gtk_widget_show(basic.nntpauth_chkbtn);
+
+               gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, TRUE);
+               gtk_widget_show(basic.nntpauth_onconnect_chkbtn);
+
                gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
                                           1, VSPACING_NARROW);
                gtk_widget_hide(basic.recvserv_label);
@@ -2333,6 +2351,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_set_sensitive(basic.pass_entry, TRUE);
 
                /* update userid/passwd sensitive state */
+
                prefs_account_nntpauth_toggled
                        (GTK_TOGGLE_BUTTON(basic.nntpauth_chkbtn), NULL);
                gtk_widget_set_sensitive(receive.pop3_frame, FALSE);
@@ -2370,6 +2389,9 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                                           0, 0);
                gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
                gtk_widget_hide(basic.nntpauth_chkbtn);
+
+               gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
+               gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
                gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
                                           1, 0);
                gtk_widget_hide(basic.recvserv_label);
@@ -2439,6 +2461,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                                           0, 0);
                gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
                gtk_widget_hide(basic.nntpauth_chkbtn);
+
+               gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
+               gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
+
                gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
                                           1, 0);
                gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
@@ -2511,6 +2537,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                                           0, 0);
                gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
                gtk_widget_hide(basic.nntpauth_chkbtn);
+
+               gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
+               gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
+
                gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
                                           1, 0);
                gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
@@ -2590,6 +2620,7 @@ static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
        gtk_widget_set_sensitive(basic.pass_label, auth);
        gtk_widget_set_sensitive(basic.uid_entry,  auth);
        gtk_widget_set_sensitive(basic.pass_entry, auth);
+       gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, auth);
 }
 
 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
index 69e5d0b..74645c9 100644 (file)
@@ -87,6 +87,7 @@ struct _PrefsAccount
        gchar *smtp_server;
        gchar *nntp_server;
        gboolean use_nntp_auth;
+       gboolean use_nntp_auth_onconnect;
        gchar *userid;
        gchar *passwd;