*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#include "claws-features.h"
#endif
#include "gtk/gtkutils.h"
#include "gtk/prefswindow.h"
#include "combobox.h"
+#ifndef PASSWORD_CRYPTO_OLD
+#include "password.h"
+#include "password_gtk.h"
+#endif
#include "manage_window.h"
#ifdef HAVE_LIBETPAN
GtkWidget *checkbtn_real_time_sync;
GtkWidget *flush_metadata_faster_radiobtn;
GtkWidget *flush_metadata_safer_radiobtn;
+#ifndef PASSWORD_CRYPTO_OLD
+ GtkWidget *checkbtn_use_passphrase;
+#endif
} OtherPage;
static struct KeybindDialog {
gpointer data);
static void prefs_keybind_cancel (void);
static void prefs_keybind_apply_clicked (GtkWidget *widget);
+#ifndef PASSWORD_CRYPTO_OLD
+static void prefs_change_master_passphrase(GtkButton *button, gpointer data);
+static void prefs_use_passphrase_toggled(GtkToggleButton *button, gpointer data);
+#endif
static void prefs_keybind_select(void)
GtkWidget *flush_metadata_faster_radiobtn;
GtkWidget *flush_metadata_safer_radiobtn;
+#ifndef PASSWORD_CRYPTO_OLD
+ GtkWidget *vbox_passphrase;
+ GtkWidget *frame_passphrase;
+ GtkWidget *checkbtn_use_passphrase;
+ GtkWidget *button_change_passphrase;
+#endif
+
gchar *shred_binary = NULL;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
_("Synchronise offline folders as soon as possible"));
+#ifndef PASSWORD_CRYPTO_OLD
+ vbox_passphrase = gtkut_get_options_frame(vbox1, &frame_passphrase, _("Master passphrase"));
+
+ PACK_CHECK_BUTTON(vbox_passphrase, checkbtn_use_passphrase,
+ _("Use a master passphrase"));
+
+ CLAWS_SET_TIP(checkbtn_use_passphrase,
+ _("If checked, your saved account passwords will be protected "
+ "by a master passphrase. If no master passphrase is set, "
+ "you will be prompted to set one."));
+
+ button_change_passphrase = gtk_button_new_with_label(
+ _("Change master passphrase"));
+ gtk_widget_show (button_change_passphrase);
+ hbox1 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox1);
+ gtk_box_pack_start (GTK_BOX (vbox_passphrase), hbox1, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox1), button_change_passphrase,
+ FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (checkbtn_use_passphrase), "toggled",
+ G_CALLBACK (prefs_use_passphrase_toggled), button_change_passphrase);
+ g_signal_connect (G_OBJECT (button_change_passphrase), "clicked",
+ G_CALLBACK (prefs_change_master_passphrase), NULL);
+#endif
+
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_confonexit),
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync),
prefs_common.real_time_sync);
+#ifndef PASSWORD_CRYPTO_OLD
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_passphrase),
+ prefs_common.use_master_passphrase);
+ gtk_widget_set_sensitive(button_change_passphrase,
+ prefs_common.use_master_passphrase);
+#endif
+
prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
prefs_other->checkbtn_confonexit = checkbtn_confonexit;
prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
+#ifndef PASSWORD_CRYPTO_OLD
+ prefs_other->checkbtn_use_passphrase = checkbtn_use_passphrase;
+#endif
prefs_other->page.widget = vbox1;
}
GTK_TOGGLE_BUTTON(page->checkbtn_use_shred));
prefs_common.real_time_sync =
gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
+ GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
+
+#ifndef PASSWORD_CRYPTO_OLD
+ /* If we're disabling use of master passphrase, we need to reencrypt
+ * all account passwords with hardcoded key. */
+ if (!gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
+ && master_passphrase_is_set()) {
+ master_passphrase_change(NULL, NULL);
+
+ /* In case user did not finish the passphrase change process
+ * (e.g. did not enter a correct current master passphrase),
+ * we need to enable the "use master passphrase" checkbox again,
+ * since the old master passphrase is still valid. */
+ if (master_passphrase_is_set()) {
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), TRUE);
+ }
+ }
+
+ if (gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
+ && !master_passphrase_is_set()) {
+ master_passphrase_change_dialog();
+
+ /* In case user cancelled the passphrase change dialog, we need
+ * to disable the "use master passphrase" checkbox. */
+ if (!master_passphrase_is_set()) {
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), FALSE);
+ }
+ }
+
+ prefs_common.use_master_passphrase =
+ gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase));
+#endif
gtk_can_change_accels = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
prefs_gtk_unregister_page((PrefsPage *) prefs_other);
g_free(prefs_other);
}
+
+#ifndef PASSWORD_CRYPTO_OLD
+void prefs_change_master_passphrase(GtkButton *button, gpointer data)
+{
+ /* Call the passphrase change dialog */
+ master_passphrase_change_dialog();
+}
+
+void prefs_use_passphrase_toggled(GtkToggleButton *chkbtn, gpointer data)
+{
+ GtkWidget *button = GTK_WIDGET(data);
+ gboolean active = gtk_toggle_button_get_active(chkbtn);
+
+ if (!active)
+ gtk_widget_set_sensitive(button, active);
+}
+#endif