2008-09-16 [mones] 3.5.0cvs105
authorRicardo Mones <mones@claws-mail.org>
Tue, 16 Sep 2008 09:11:21 +0000 (09:11 +0000)
committerRicardo Mones <mones@claws-mail.org>
Tue, 16 Sep 2008 09:11:21 +0000 (09:11 +0000)
* src/imap.c
* src/inc.c
* src/mainwindow.c
* src/mainwindow.h
* src/news.c
* src/prefs_account.h
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_other.c
* src/send_message.c
* src/gtk/inputdialog.c
* src/gtk/inputdialog.h
Implement session passwords: unsaved passwords for receiving
or sending of accounts can be remembered while running to
avoid repetitive typing.
As keeping passwords in memory is unsafe a new preference
in Other page is added to activate or not such capability.

15 files changed:
ChangeLog
PATCHSETS
configure.ac
src/gtk/inputdialog.c
src/gtk/inputdialog.h
src/imap.c
src/inc.c
src/mainwindow.c
src/mainwindow.h
src/news.c
src/prefs_account.h
src/prefs_common.c
src/prefs_common.h
src/prefs_other.c
src/send_message.c

index a0f7d6d..9abc8bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-09-16 [mones]     3.5.0cvs105
+
+       * src/imap.c
+       * src/inc.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/news.c
+       * src/prefs_account.h
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_other.c
+       * src/send_message.c
+       * src/gtk/inputdialog.c
+       * src/gtk/inputdialog.h
+               Implement session passwords: unsaved passwords for receiving
+               or sending of accounts can be remembered while running to 
+               avoid repetitive typing.
+               As keeping passwords in memory is unsafe a new preference 
+               in Other page is added to activate or not such capability.
+
 2008-09-14 [colin]     3.5.0cvs104
 
        * src/codeconv.c
index 684a639..70bdcd6 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.30.2.31 -r 1.30.2.32 tools/README;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 tools/csv2addressbook.pl;  ) > 3.5.0cvs102.patchset
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 claws-mail.pc.in;  cvs diff -u -r 1.155.2.90 -r 1.155.2.91 src/Makefile.am;  cvs diff -u -r 1.382.2.474 -r 1.382.2.475 src/compose.c;  cvs diff -u -r 1.50.2.50 -r 1.50.2.51 src/compose.h;  cvs diff -u -r 1.23.2.29 -r 1.23.2.30 src/crash.c;  cvs diff -u -r 1.2.2.30 -r 1.2.2.31 src/folder_item_prefs.c;  cvs diff -u -r 1.2.2.17 -r 1.2.2.18 src/folder_item_prefs.h;  cvs diff -u -r 1.115.2.204 -r 1.115.2.205 src/main.c;  cvs diff -u -r 1.105.2.144 -r 1.105.2.145 src/prefs_account.c;  cvs diff -u -r 1.204.2.177 -r 1.204.2.178 src/prefs_common.c;  cvs diff -u -r 1.103.2.112 -r 1.103.2.113 src/prefs_common.h;  cvs diff -u -r 1.52.2.66 -r 1.52.2.67 src/prefs_folder_item.c;  cvs diff -u -r 1.5.2.36 -r 1.5.2.37 src/prefs_spelling.c;  cvs diff -u -r 1.12.2.66 -r 1.12.2.67 src/prefs_template.c;  cvs diff -u -r 1.5.12.18 -r 1.5.12.19 src/quote_fmt.h;  cvs diff -u -r 1.22.2.39 -r 1.22.2.40 src/quote_fmt_parse.y;  cvs diff -u -r 1.43.2.104 -r 1.43.2.105 src/toolbar.c;  cvs diff -u -r 1.19.2.28 -r 1.19.2.29 src/toolbar.h;  cvs diff -u -r 1.20.2.17 -r 1.20.2.18 src/gtk/Makefile.am;  cvs diff -u -r 1.4.2.66 -r 1.4.2.67 src/gtk/about.c;  cvs diff -u -r 1.2.2.37 -r 1.2.2.38 src/gtk/filesel.c;  cvs diff -u -r 1.9.2.60 -r 1.9.2.61 src/gtk/gtkaspell.c;  cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/gtkaspell.h;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/bogofilter/Makefile.am;  cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/plugins/dillo_viewer/Makefile.am;  cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/plugins/spamassassin/Makefile.am;  cvs diff -u -r 1.4.2.11 -r 1.4.2.12 src/plugins/trayicon/Makefile.am;  ) > 3.5.0cvs103.patchset
 ( cvs diff -u -r 1.65.2.59 -r 1.65.2.60 src/codeconv.c;  cvs diff -u -r 1.15.2.20 -r 1.15.2.21 src/codeconv.h;  ) > 3.5.0cvs104.patchset
+( cvs diff -u -r 1.179.2.227 -r 1.179.2.228 src/imap.c;  cvs diff -u -r 1.149.2.94 -r 1.149.2.95 src/inc.c;  cvs diff -u -r 1.274.2.271 -r 1.274.2.272 src/mainwindow.c;  cvs diff -u -r 1.39.2.50 -r 1.39.2.51 src/mainwindow.h;  cvs diff -u -r 1.101.2.53 -r 1.101.2.54 src/news.c;  cvs diff -u -r 1.49.2.39 -r 1.49.2.40 src/prefs_account.h;  cvs diff -u -r 1.204.2.178 -r 1.204.2.179 src/prefs_common.c;  cvs diff -u -r 1.103.2.113 -r 1.103.2.114 src/prefs_common.h;  cvs diff -u -r 1.1.2.30 -r 1.1.2.31 src/prefs_other.c;  cvs diff -u -r 1.17.2.49 -r 1.17.2.50 src/send_message.c;  cvs diff -u -r 1.2.2.32 -r 1.2.2.33 src/gtk/inputdialog.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/inputdialog.h;  ) > 3.5.0cvs105.patchset
index 5752506..a69378a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=104
+EXTRA_VERSION=105
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b4e4e2f..c82c39d 100644 (file)
@@ -133,6 +133,40 @@ gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
        return input_dialog_open(title, message, NULL, default_string, FALSE, NULL);
 }
 
+gchar *input_dialog_with_invisible_checkbtn(const gchar *title, const gchar *message,
+                                  const gchar *default_string, const gchar *checkbtn_label,
+                                  gboolean *checkbtn_state)
+{
+       if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
+
+       if (!dialog)
+               input_dialog_create(TRUE);
+
+       type = INPUT_DIALOG_INVISIBLE;
+       gtk_widget_hide(combo);
+       gtk_widget_show(entry);
+
+       if (checkbtn_label && checkbtn_state) {
+               gtk_widget_show(remember_checkbtn);
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn), *checkbtn_state);
+       }
+       else {
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn), FALSE);
+               gtk_widget_hide(remember_checkbtn);
+       }
+
+       gtk_widget_hide(icon_q);
+       gtk_widget_show(icon_p);
+       is_pass = TRUE;
+       gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+#ifdef MAEMO
+       hildon_gtk_entry_set_input_mode(GTK_ENTRY(entry), 
+               HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
+#endif
+
+       return input_dialog_open(title, message, checkbtn_label, default_string, FALSE, checkbtn_state);
+}
+
 gchar *input_dialog_combo(const gchar *title, const gchar *message,
                          const gchar *default_string, GList *list)
 {
@@ -224,6 +258,46 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user)
        return pass;
 }
 
+gchar *input_dialog_query_password_keep(const gchar *server, const gchar *user, const gchar **keep)
+{
+       gchar *message;
+       gchar *pass;
+
+       if (server && user)
+               message = g_strdup_printf(_("Input password for %s on %s:"),
+                                 user, server);
+       else if (server)
+               message = g_strdup_printf(_("Input password for %s:"),
+                                 server);
+       else if (user)
+               message = g_strdup_printf(_("Input password for %s:"),
+                                 user);
+       else
+               message = g_strdup_printf(_("Input password:"));
+        if (keep && prefs_common.session_passwords) {
+               if (*keep != NULL) {
+                       pass = g_strdup (keep);
+               }
+               else {
+                       gboolean state = FALSE;
+                       pass = input_dialog_with_invisible_checkbtn(_("Input password"), 
+                                       message, NULL,
+                                       _("Remember password for this session"), 
+                                       &state);
+                       if (state) {
+                               *keep = g_strdup (pass);
+                               debug_print("keeping session password for account\n");
+                       }
+               }
+       }
+       else {
+               pass = input_dialog_with_invisible(_("Input password"), message, NULL);
+       }               
+       g_free(message);
+
+       return pass;
+}
+
 static void input_dialog_create(gboolean is_password)
 {
        static PangoFontDescription *font_desc;
index 08cd459..9374512 100644 (file)
@@ -33,6 +33,11 @@ gchar *input_dialog_with_checkbtn(const gchar        *title,
 gchar *input_dialog_with_invisible     (const gchar    *title,
                                         const gchar    *message,
                                         const gchar    *default_string);
+gchar *input_dialog_with_invisible_checkbtn(const gchar        *title,
+                                          const gchar  *message,
+                                          const gchar  *default_string,
+                                          const gchar  *checkbtn_label,
+                                          gboolean *checkbtn_state);
 gchar *input_dialog_combo              (const gchar    *title,
                                         const gchar    *message,
                                         const gchar    *default_string,
@@ -44,5 +49,7 @@ gchar *input_dialog_combo_remember    (const gchar    *title,
                                         gboolean       *remember);
 gchar *input_dialog_query_password     (const gchar    *server,
                                         const gchar    *user);
-
+gchar *input_dialog_query_password_keep        (const gchar    *server,
+                                        const gchar    *user,
+                                        const gchar    **keep);
 #endif /* __INPUTDIALOG_H__ */
index 1b50b76..71e316a 100644 (file)
@@ -190,8 +190,8 @@ static void  imap_folder_destroy    (Folder         *folder);
 
 static IMAPSession *imap_session_new   (Folder         *folder,
                                         const PrefsAccount     *account);
-static gint    imap_session_authenticate(IMAPSession           *session,
-                                         const PrefsAccount    *account);
+static gint    imap_session_authenticate(IMAPSession   *session,
+                                         PrefsAccount  *account);
 static void    imap_session_destroy    (Session        *session);
 
 static gchar   *imap_fetch_msg         (Folder         *folder, 
@@ -1153,7 +1153,7 @@ static IMAPSession *imap_session_new(Folder * folder,
 }
 
 static gint imap_session_authenticate(IMAPSession *session, 
-                                     const PrefsAccount *account)
+                                     PrefsAccount *account)
 {
        gchar *pass, *acc_pass;
        gboolean failed = FALSE;
@@ -1164,7 +1164,9 @@ try_again:
        pass = acc_pass;
        if (!pass && account->imap_auth_type != IMAP_AUTH_ANON) {
                gchar *tmp_pass;
-               tmp_pass = input_dialog_query_password(account->recv_server, account->userid);
+               tmp_pass = input_dialog_query_password_keep(account->recv_server, 
+                                                           account->userid,
+                                                           &(account->session_passwd));
                if (!tmp_pass)
                        return MAILIMAP_NO_ERROR;
                Xstrdup_a(pass, tmp_pass, {g_free(tmp_pass); return MAILIMAP_NO_ERROR;});
@@ -1180,6 +1182,10 @@ try_again:
                if (!failed && !is_fatal(ok)) {
                        acc_pass = NULL;
                        failed = TRUE;
+                       if (account->session_passwd != NULL) {
+                               g_free(account->session_passwd);
+                               account->session_passwd = NULL;
+                       }
                        goto try_again;
                } else {
                        if (prefs_common.no_recv_err_panel) {
index a15803c..f37f9f9 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -566,9 +566,10 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                                        (inc_dialog->dialog->window,
                                         NULL, NULL);
 
-                       pass = input_dialog_query_password
+                       pass = input_dialog_query_password_keep
                                (pop3_session->ac_prefs->recv_server,
-                                pop3_session->user);
+                                pop3_session->user,
+                                &(pop3_session->ac_prefs->session_passwd));
 
                        if (inc_dialog->show_dialog)
                                manage_window_focus_out
@@ -635,6 +636,10 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                        break;
                case INC_AUTH_FAILED:
                        SET_PIXMAP_AND_TEXT(errorpix, _("Auth failed"));
+                       if (pop3_session->ac_prefs->session_passwd) {
+                               g_free(pop3_session->ac_prefs->session_passwd);
+                               pop3_session->ac_prefs->session_passwd = NULL;
+                       }
                        break;
                case INC_LOCKED:
                        SET_PIXMAP_AND_TEXT(errorpix, _("Locked"));
index 2f7a7ef..b870574 100644 (file)
@@ -386,6 +386,9 @@ static void addr_harvest_msg_cb      ( GtkAction    *action,
 static void sync_cb             ( GtkAction    *action,
                                  gpointer       data );
 
+static void forget_session_passwords_cb        (GtkAction      *action,
+                                        gpointer        data );
+
 static gboolean mainwindow_focus_in_event      (GtkWidget      *widget, 
                                                 GdkEventFocus  *focus,
                                                 gpointer        data);
@@ -691,6 +694,8 @@ static GtkActionEntry mainwin_entries[] =
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
        {"Tools/FilteringLog",                  NULL, N_("Filtering Lo_g"), NULL, NULL, G_CALLBACK(filtering_debug_window_show_cb) }, 
        {"Tools/NetworkLog",                    NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) }, 
+       /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
+       {"Tools/ForgetSessionPasswords",                NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) }, 
 
 /* Configuration menu */       
        {"Configuration/ChangeAccount",         NULL, N_("C_hange current account") },
@@ -1849,7 +1854,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator7", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "FilteringLog", "Tools/FilteringLog", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
-               MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator9", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 
 /* Configuration menu */
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "ChangeAccount", "Configuration/ChangeAccount", GTK_UI_MANAGER_MENU)
@@ -3038,6 +3045,18 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (prefs_common.layout_mode != SMALL_LAYOUT || mainwin->in_folder)
                state |= M_IN_MSGLIST;
 
+       if (prefs_common.session_passwords) {
+               GList *list = NULL;
+
+               for (list = account_get_list(); list != NULL; list = list->next) {
+                       PrefsAccount *account = list->data;
+                       if (account->session_passwd || account->session_smtp_passwd) {
+                               state |= M_SESSION_PASSWORDS;
+                               break;
+                       }
+               }
+       }
+
        return state;
 }
 
@@ -3132,6 +3151,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/Tools/ListUrls"                 , M_TARGET_EXIST},
                {"Menu/Tools/Actions"                      , M_TARGET_EXIST|M_ACTIONS_EXIST},
                {"Menu/Tools/Execute"                      , M_DELAY_EXEC},
+               {"Menu/Tools/ForgetSessionPasswords"       , M_SESSION_PASSWORDS},
                {"Menu/Tools/DeleteDuplicates/SelFolder"   , M_MSG_EXIST|M_ALLOW_DELETE},
 
                {"Menu/Configuration", M_UNLOCKED},
@@ -4943,6 +4963,34 @@ static void sync_cb(GtkAction *action, gpointer data)
        mainwindow_check_synchronise(mainwin, FALSE);
 }
 
+static void forget_session_passwords_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       GList *list = NULL;
+        gint fgtn = 0;
+       gint accs = 0;
+
+       main_window_lock(mainwin);
+       for (list = account_get_list(); list != NULL; list = list->next) {
+               PrefsAccount *account = list->data;
+               if (account->session_passwd) {
+                       g_free(account->session_passwd);
+                       account->session_passwd = NULL;
+                       ++fgtn;
+               }
+               if (account->session_smtp_passwd) {
+                       g_free(account->session_smtp_passwd);
+                       account->session_smtp_passwd = NULL;
+                       ++fgtn;
+               }
+               ++accs;
+       }
+       main_window_unlock(mainwin);
+       alertpanel_notice(ngettext("Forgotten %d password in %d accounts.\n",
+                                  "Forgotten %d passwords in %d accounts.\n",
+                                  fgtn), fgtn, accs);  
+}
+
 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
 {
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
index b09b9e3..fb6abb6 100644 (file)
@@ -63,7 +63,8 @@ typedef enum
        M_SUMMARY_ISLIST      = 1 << 22,
        M_IN_MSGLIST          = 1 << 23,
        M_HAVE_MULTI_ACCOUNT  = 1 << 24,
-       M_FOLDER_SELECTED     = 1 << 25
+       M_FOLDER_SELECTED     = 1 << 25,
+       M_SESSION_PASSWORDS   = 1 << 26
 } SensitiveCond;
 
 typedef enum
index b9947a0..06b474d 100644 (file)
@@ -338,8 +338,9 @@ static Session *news_session_new_for_folder(Folder *folder)
                if (ac->passwd && ac->passwd[0])
                        passwd = g_strdup(ac->passwd);
                else
-                       passwd = input_dialog_query_password(ac->nntp_server,
-                                                            userid);
+                       passwd = input_dialog_query_password_keep(ac->nntp_server,
+                                                                 userid,
+                                                                 &(ac->session_passwd));
        }
 
 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
@@ -371,6 +372,10 @@ static Session *news_session_new_for_folder(Folder *folder)
                        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;
                }
        }
index 8770530..850aaea 100644 (file)
@@ -69,6 +69,7 @@ struct _PrefsAccount
        gboolean use_nntp_auth_onconnect;
        gchar *userid;
        gchar *passwd;
+       gchar *session_passwd;
 
        gchar * local_mbox;
        gboolean use_mail_command;
@@ -113,6 +114,7 @@ struct _PrefsAccount
        SMTPAuthType smtp_auth_type;
        gchar *smtp_userid;
        gchar *smtp_passwd;
+       gchar *session_smtp_passwd;
 
        /* Temporarily preserved password */
        gchar *tmp_smtp_pass;
index d9c859e..dadc6aa 100644 (file)
@@ -821,6 +821,8 @@ static PrefParam param[] = {
         &prefs_common.cmds_use_system_default, P_BOOL, NULL, NULL, NULL},
        {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
         P_BOOL, NULL, NULL, NULL},
+       {"session_passwords", "FALSE", &prefs_common.session_passwords,
+        P_BOOL, NULL, NULL, NULL},
        {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
         NULL, NULL, NULL},
        {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
index 8387d75..8dc37e1 100644 (file)
@@ -401,6 +401,7 @@ struct _PrefsCommon
     guint filtering_debug_loglength;
 
     gboolean confirm_on_exit;
+       gboolean session_passwords;
        gboolean clean_on_exit;
        gboolean ask_on_clean;
        gboolean warn_queued_on_exit;
index 8aaa0b2..fc6669f 100644 (file)
@@ -59,6 +59,7 @@ typedef struct _OtherPage
        GtkWidget *checkbtn_askonfilter;
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
+       GtkWidget *checkbtn_session_passwords;
 } OtherPage;
 
 static struct KeybindDialog {
@@ -508,6 +509,10 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *checkbtn_askonfilter;
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
+
+       GtkWidget *frame_sess_pass;
+       GtkWidget *vbox_sess_pass;
+       GtkWidget *checkbtn_session_passwords;
        gchar *shred_binary = NULL;
        CLAWS_TIP_DECL();
 
@@ -521,6 +526,11 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
                (vbox_addr, checkbtn_addaddrbyclick,
                 _("Add address to destination when double-clicked"));
 
+       vbox_sess_pass = gtkut_get_options_frame(vbox1, &frame_sess_pass, _("Session passwords"));
+       
+       PACK_CHECK_BUTTON
+               (vbox_sess_pass, checkbtn_session_passwords,
+                _("Enable the option of keeping unsaved account passwords while running"));
        /* On Exit */
        vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
 
@@ -609,6 +619,8 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick), 
                prefs_common.add_address_by_click);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_session_passwords), 
+               prefs_common.session_passwords);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit), 
                prefs_common.confirm_on_exit);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit), 
@@ -631,6 +643,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.real_time_sync);
 
        prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
+       prefs_other->checkbtn_session_passwords = checkbtn_session_passwords;
        prefs_other->checkbtn_confonexit = checkbtn_confonexit;
        prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
        prefs_other->checkbtn_askonclean = checkbtn_askonclean;
@@ -648,9 +661,27 @@ static void prefs_other_save(PrefsPage *_page)
 {
        OtherPage *page = (OtherPage *) _page;
        gboolean gtk_can_change_accels;
+       GList * list = NULL;
 
        prefs_common.add_address_by_click = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
+       prefs_common.session_passwords = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_session_passwords));
+
+       if (!prefs_common.session_passwords) {
+               for (list = account_get_list(); list != NULL; list = list->next) {
+                       PrefsAccount *account = list->data;
+                       if (account->session_passwd) {
+                               g_free(account->session_passwd);
+                               account->session_passwd = NULL;
+                       }
+                       if (account->session_smtp_passwd) {
+                               g_free(account->session_smtp_passwd);
+                               account->session_smtp_passwd = NULL;
+                       }
+               }
+       }
+
        prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
        prefs_common.clean_on_exit = gtk_toggle_button_get_active(
index 14977d0..f5f8268 100644 (file)
@@ -251,9 +251,10 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                                                g_strdup(ac_prefs->tmp_smtp_pass);
                                else {
                                        smtp_session->pass =
-                                               input_dialog_query_password
+                                               input_dialog_query_password_keep
                                                        (ac_prefs->smtp_server,
-                                                        smtp_session->user);
+                                                        smtp_session->user,
+                                                        &(ac_prefs->session_smtp_passwd));
                                        if (!smtp_session->pass) {
                                                session_destroy(session);
                                                return -1;
@@ -270,9 +271,10 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                                                g_strdup(ac_prefs->tmp_pass);
                                else {
                                        smtp_session->pass =
-                                               input_dialog_query_password
+                                               input_dialog_query_password_keep
                                                        (ac_prefs->smtp_server,
-                                                        smtp_session->user);
+                                                        smtp_session->user,
+                                                        &(ac_prefs->session_smtp_passwd));
                                        if (!smtp_session->pass) {
                                                session_destroy(session);
                                                return -1;
@@ -388,6 +390,10 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                        g_free(ac_prefs->tmp_pass);
                        ac_prefs->tmp_pass = NULL;
                }
+               if (ac_prefs->session_smtp_passwd) {
+                       g_free(ac_prefs->session_smtp_passwd);
+                       ac_prefs->session_smtp_passwd = NULL;
+               }
                ret = -1;
        } else if (SMTP_SESSION(session)->state == SMTP_MAIL_SENT_OK) {
                log_message(LOG_PROTOCOL, "%s\n", _("Mail sent successfully."));