* src/prefs_account.[ch]
authorColin Leroy <colin@colino.net>
Sun, 22 Sep 2002 16:30:27 +0000 (16:30 +0000)
committerColin Leroy <colin@colino.net>
Sun, 22 Sep 2002 16:30:27 +0000 (16:30 +0000)
Add an option for the POP before SMTP timeout
* src/inc.c
Remember time of last POP connection
* src/send.c
Do POP before SMTP only if timeout reached

ChangeLog.claws
configure.in
src/inc.c
src/prefs_account.c
src/prefs_account.h
src/send.c

index dc2bdbf..55fd065 100644 (file)
@@ -1,3 +1,12 @@
+2002-09-22 [colin]     0.8.3claws10
+       
+       * src/prefs_account.[ch]
+               Add an option for the POP before SMTP timeout
+       * src/inc.c
+               Remember time of last POP connection
+       * src/send.c
+               Do POP before SMTP only if timeout reached
+
 2002-09-22 [oliver]    0.8.3claws9
        
        * README.claws
index 9549574..b8c9119 100644 (file)
@@ -10,7 +10,7 @@ MINOR_VERSION=8
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws9
+EXTRA_VERSION=claws10
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 562ccee..9a81a70 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -702,6 +702,7 @@ static IncState inc_pop3_session_do(IncSession *session)
        debug_print("getting new messages of account %s...\n",
                    pop3_state->ac_prefs->account_name);
 
+       pop3_state->ac_prefs->last_pop_login_time = time(NULL);
        atm = automaton_create(N_POP3_PHASE);
 
        session->atm = atm;
index c699d6a..28d46ad 100644 (file)
@@ -111,6 +111,7 @@ static struct Send {
        GtkWidget *smtp_uid_entry;
        GtkWidget *smtp_pass_entry;
        GtkWidget *pop_bfr_smtp_chkbtn;
+       GtkWidget *pop_bfr_smtp_tm_entry;
 } p_send;
 
 static struct Compose {
@@ -340,6 +341,10 @@ static PrefParam param[] = {
         &p_send.pop_bfr_smtp_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
 
+       {"pop_before_smtp_timeout", "5", &tmp_ac_prefs.pop_before_smtp_timeout, P_INT,
+        &p_send.pop_bfr_smtp_tm_entry,
+        prefs_set_data_from_entry, prefs_set_entry},
+
        /* Compose */
        {"signature_path", "~/"DEFAULT_SIGNATURE, &tmp_ac_prefs.sig_path, P_STRING,
         &compose.sigpath_entry,
@@ -512,6 +517,10 @@ static void prefs_account_advanced_create  (void);
 
 static void prefs_account_select_folder_cb     (GtkWidget      *widget,
                                                 gpointer        data);
+
+static void pop_bfr_smtp_tm_set_sens           (GtkWidget      *widget,
+                                                gpointer        data);
+
 static void prefs_account_edit_custom_header   (void);
 
 static gint prefs_account_deleted              (GtkWidget      *widget,
@@ -683,6 +692,8 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
                gtk_widget_set_sensitive(basic.smtpserv_label, TRUE);
        }
 
+       pop_bfr_smtp_tm_set_sens (NULL, NULL);
+       
        gtk_widget_show(dialog.window);
        gtk_main();
        gtk_widget_hide(dialog.window);
@@ -1234,6 +1245,7 @@ static void prefs_account_send_create(void)
        GtkWidget *smtp_pass_entry;
        GtkWidget *vbox_spc;
        GtkWidget *pop_bfr_smtp_chkbtn;
+       GtkWidget *pop_bfr_smtp_tm_entry;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -1360,7 +1372,35 @@ static void prefs_account_send_create(void)
 
        PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_chkbtn,
                _("Authenticate with POP3 before sending"));
+       
+       gtk_signal_connect (GTK_OBJECT (pop_bfr_smtp_chkbtn), "clicked",
+                           GTK_SIGNAL_FUNC (pop_bfr_smtp_tm_set_sens),
+                           NULL);
+
+       hbox = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox);
+       gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
+
+       hbox_spc = gtk_hbox_new (FALSE, 0);
+       gtk_widget_show (hbox_spc);
+       gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
+       gtk_widget_set_usize (hbox_spc, 12, -1);
+
+       label = gtk_label_new(_("POP authentication timeout: "));
+       gtk_widget_show (label);
+       gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+       pop_bfr_smtp_tm_entry = gtk_entry_new ();
+       gtk_widget_show (pop_bfr_smtp_tm_entry);
+       gtk_widget_set_usize (pop_bfr_smtp_tm_entry, 30, -1);
+       gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_entry, FALSE, FALSE, 0);
+
+       label = gtk_label_new(_("minutes"));
+       gtk_widget_show (label);
+       gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 
+
+       
        p_send.date_chkbtn      = date_chkbtn;
        p_send.msgid_chkbtn     = msgid_chkbtn;
        p_send.customhdr_chkbtn = customhdr_chkbtn;
@@ -1370,6 +1410,7 @@ static void prefs_account_send_create(void)
        p_send.smtp_uid_entry         = smtp_uid_entry;
        p_send.smtp_pass_entry        = smtp_pass_entry;
        p_send.pop_bfr_smtp_chkbtn    = pop_bfr_smtp_chkbtn;
+       p_send.pop_bfr_smtp_tm_entry  = pop_bfr_smtp_tm_entry;
 }
 
 static void prefs_account_compose_create(void)
@@ -2051,6 +2092,12 @@ static void prefs_account_cancel(void)
        gtk_main_quit();
 }
 
+static void pop_bfr_smtp_tm_set_sens(GtkWidget *widget, gpointer data)
+{
+       gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, 
+                                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn)));
+}
+
 static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data)
 {
        FolderItem *item;
@@ -2276,6 +2323,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_toggle_button_set_active
                        (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
                gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
                
                if (!tmp_ac_prefs.account_name) {
                        gtk_toggle_button_set_active
@@ -2344,6 +2392,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_toggle_button_set_active
                        (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
                gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
 
                if (!tmp_ac_prefs.account_name) {
                        gtk_toggle_button_set_active
@@ -2414,7 +2463,8 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_toggle_button_set_active
                        (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
                gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
-               
+               gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
+
                if (!tmp_ac_prefs.account_name) {
                        gtk_toggle_button_set_active
                                (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
@@ -2483,6 +2533,7 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
 
                /* update pop_before_smtp sensitivity */
                gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, TRUE);
+               gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
                
                if (!tmp_ac_prefs.account_name) {
                        gtk_toggle_button_set_active
index 9a0dc87..308a94a 100644 (file)
@@ -128,6 +128,8 @@ struct _PrefsAccount
        gchar *tmp_smtp_pass;
 
        gboolean pop_before_smtp;
+       gint pop_before_smtp_timeout;
+       time_t last_pop_login_time;
 
        GSList *customhdr_list;
 
index 167bdd0..657a0cc 100644 (file)
@@ -360,7 +360,8 @@ gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list,
        gtk_clist_append(clist, (gchar **)text);
 
        if (ac_prefs->pop_before_smtp
-           && (ac_prefs->protocol == A_APOP || ac_prefs->protocol == A_POP3)) {
+           && (ac_prefs->protocol == A_APOP || ac_prefs->protocol == A_POP3)
+           && (time(NULL) - ac_prefs->last_pop_login_time) > (60 * ac_prefs->pop_before_smtp_timeout)) {
                g_snprintf(buf, sizeof(buf), _("Doing POP before SMTP..."));
                log_message("%s\n", buf);
                progress_dialog_set_label(dialog->dialog, buf);