diff options
| author | Simeon Simeonov | 2018-03-19 22:06:25 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-03-19 22:06:25 +0100 |
| commit | c6f80c49de727b9857d2bbd1eeaf85930612d0ce (patch) | |
| tree | b08d5949b28907afdea01f4745b66283f2159d79 | |
| parent | 6edeb462320240d981ec307798c7841e50197758 (diff) | |
Add min password length spinbutton to common preferences
| -rw-r--r-- | libsylph/masterpassword.c | 2 | ||||
| -rw-r--r-- | libsylph/prefs_common.c | 2 | ||||
| -rw-r--r-- | libsylph/prefs_common.h | 1 | ||||
| -rw-r--r-- | src/prefs_common_dialog.c | 78 |
4 files changed, 70 insertions, 13 deletions
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c index 77ff281..b86f06b 100644 --- a/libsylph/masterpassword.c +++ b/libsylph/masterpassword.c | |||
| @@ -111,7 +111,7 @@ gchar *encrypt_with_master_password(const gchar *str) { | |||
| 111 | str, | 111 | str, |
| 112 | master_password, | 112 | master_password, |
| 113 | strlen(str), | 113 | strlen(str), |
| 114 | 32, /* TODO: to be set in prefs_common */ | 114 | prefs_common.encrypted_password_min_length, |
| 115 | TRUE) != RC_OK) { | 115 | TRUE) != RC_OK) { |
| 116 | OPENSSL_cleanse(new_str, strlen(new_str)); | 116 | OPENSSL_cleanse(new_str, strlen(new_str)); |
| 117 | g_free(new_str); | 117 | g_free(new_str); |
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 6c20319..dda4a0f 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c | |||
| @@ -423,6 +423,8 @@ static PrefParam param[] = { | |||
| 423 | P_BOOL}, | 423 | P_BOOL}, |
| 424 | {"master_password_hash", NULL, &prefs_common.master_password_hash, | 424 | {"master_password_hash", NULL, &prefs_common.master_password_hash, |
| 425 | P_STRING}, | 425 | P_STRING}, |
| 426 | {"encrypted_password_min_length", "32", | ||
| 427 | &prefs_common.encrypted_password_min_length, P_INT}, | ||
| 426 | 428 | ||
| 427 | /* Interface */ | 429 | /* Interface */ |
| 428 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, | 430 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, |
diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index bc1d2f3..92333aa 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h | |||
| @@ -252,6 +252,7 @@ struct _PrefsCommon | |||
| 252 | /* Master password */ | 252 | /* Master password */ |
| 253 | gboolean use_master_password; | 253 | gboolean use_master_password; |
| 254 | gchar *master_password_hash; | 254 | gchar *master_password_hash; |
| 255 | guint encrypted_password_min_length; | ||
| 255 | 256 | ||
| 256 | /* Interface */ | 257 | /* Interface */ |
| 257 | gboolean sep_folder; | 258 | gboolean sep_folder; |
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index dada1b1..41fdb24 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c | |||
| @@ -219,6 +219,7 @@ static struct Privacy { | |||
| 219 | #if USE_SSL | 219 | #if USE_SSL |
| 220 | static struct MasterPassword { | 220 | static struct MasterPassword { |
| 221 | GtkWidget *checkbtn_use_master_password; | 221 | GtkWidget *checkbtn_use_master_password; |
| 222 | GtkWidget *spinbtn_encrypted_password_min_length; | ||
| 222 | } master_password; | 223 | } master_password; |
| 223 | #endif | 224 | #endif |
| 224 | 225 | ||
| @@ -572,6 +573,10 @@ static PrefsUIData ui_data[] = { | |||
| 572 | #if USE_SSL | 573 | #if USE_SSL |
| 573 | {"use_master_password", &master_password.checkbtn_use_master_password, | 574 | {"use_master_password", &master_password.checkbtn_use_master_password, |
| 574 | prefs_set_data_from_toggle, prefs_set_toggle}, | 575 | prefs_set_data_from_toggle, prefs_set_toggle}, |
| 576 | {"encrypted_password_min_length", | ||
| 577 | &master_password.spinbtn_encrypted_password_min_length, | ||
| 578 | prefs_set_data_from_spinbtn, | ||
| 579 | prefs_set_spinbtn}, | ||
| 575 | #endif | 580 | #endif |
| 576 | 581 | ||
| 577 | /* Interface */ | 582 | /* Interface */ |
| @@ -2669,29 +2674,78 @@ static void prefs_privacy_create(void) | |||
| 2669 | #if USE_SSL | 2674 | #if USE_SSL |
| 2670 | static void prefs_master_password_create(void) | 2675 | static void prefs_master_password_create(void) |
| 2671 | { | 2676 | { |
| 2672 | GtkWidget *vbox1; | 2677 | GtkWidget *vbox_main; |
| 2673 | GtkWidget *vbox2; | 2678 | GtkWidget *vbox_master_password_options; |
| 2679 | GtkWidget *vbox_master_password_suboptions; | ||
| 2674 | GtkWidget *hbox1; | 2680 | GtkWidget *hbox1; |
| 2681 | GtkWidget *hbox_spc; | ||
| 2682 | GtkWidget *label; | ||
| 2675 | GtkWidget *checkbtn_use_master_password; | 2683 | GtkWidget *checkbtn_use_master_password; |
| 2684 | GtkWidget *spinbtn_encrypted_password_min_length; | ||
| 2685 | GtkObject *spinbtn_encrypted_password_min_length_adj; | ||
| 2676 | 2686 | ||
| 2677 | vbox1 = gtk_vbox_new (FALSE, VSPACING); | 2687 | vbox_main = gtk_vbox_new (FALSE, VSPACING); |
| 2678 | gtk_widget_show (vbox1); | 2688 | gtk_widget_show (vbox_main); |
| 2679 | gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); | 2689 | gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox_main); |
| 2680 | gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); | 2690 | gtk_container_set_border_width (GTK_CONTAINER (vbox_main), VBOX_BORDER); |
| 2681 | 2691 | ||
| 2682 | vbox2 = gtk_vbox_new (FALSE, 0); | 2692 | vbox_master_password_options = gtk_vbox_new (FALSE, 0); |
| 2683 | gtk_widget_show (vbox2); | 2693 | gtk_widget_show (vbox_master_password_options); |
| 2684 | gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0); | 2694 | gtk_box_pack_start ( |
| 2695 | GTK_BOX (vbox_main), vbox_master_password_options, FALSE, FALSE, 0); | ||
| 2696 | |||
| 2697 | PACK_CHECK_BUTTON (vbox_master_password_options, | ||
| 2698 | checkbtn_use_master_password, | ||
| 2699 | _("Use master password")); | ||
| 2685 | 2700 | ||
| 2686 | PACK_CHECK_BUTTON (vbox2, checkbtn_use_master_password, | 2701 | vbox_master_password_suboptions = gtk_vbox_new (FALSE, VSPACING_NARROW); |
| 2687 | _("Use master password")); | 2702 | gtk_widget_show (vbox_master_password_suboptions); |
| 2703 | gtk_box_pack_start (GTK_BOX (vbox_master_password_options), | ||
| 2704 | vbox_master_password_suboptions, | ||
| 2705 | FALSE, | ||
| 2706 | FALSE, | ||
| 2707 | 0); | ||
| 2688 | 2708 | ||
| 2689 | hbox1 = gtk_hbox_new (FALSE, 8); | 2709 | hbox1 = gtk_hbox_new (FALSE, 8); |
| 2690 | gtk_widget_show (hbox1); | 2710 | gtk_widget_show (hbox1); |
| 2691 | gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0); | 2711 | gtk_box_pack_start (GTK_BOX (vbox_master_password_suboptions), |
| 2712 | hbox1, | ||
| 2713 | FALSE, | ||
| 2714 | FALSE, | ||
| 2715 | 0); | ||
| 2716 | |||
| 2717 | hbox_spc = gtk_hbox_new (FALSE, 0); | ||
| 2718 | gtk_widget_show (hbox_spc); | ||
| 2719 | gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0); | ||
| 2720 | gtk_widget_set_size_request (hbox_spc, 12, -1); | ||
| 2721 | |||
| 2722 | label = gtk_label_new (_("Min. password length")); | ||
| 2723 | gtk_widget_show (label); | ||
| 2724 | gtk_box_pack_start ( | ||
| 2725 | GTK_BOX (hbox1), label, FALSE, FALSE, 0); | ||
| 2726 | |||
| 2727 | spinbtn_encrypted_password_min_length_adj = gtk_adjustment_new ( | ||
| 2728 | 32, 0, 99, 1, 5, 0); | ||
| 2729 | spinbtn_encrypted_password_min_length = gtk_spin_button_new( | ||
| 2730 | GTK_ADJUSTMENT (spinbtn_encrypted_password_min_length_adj), 1, 0); | ||
| 2731 | gtk_widget_show (spinbtn_encrypted_password_min_length); | ||
| 2732 | gtk_box_pack_start (GTK_BOX (hbox1), | ||
| 2733 | spinbtn_encrypted_password_min_length, | ||
| 2734 | FALSE, | ||
| 2735 | FALSE, | ||
| 2736 | 0); | ||
| 2737 | gtk_spin_button_set_numeric ( | ||
| 2738 | GTK_SPIN_BUTTON (spinbtn_encrypted_password_min_length), TRUE); | ||
| 2739 | gtk_widget_set_size_request (spinbtn_encrypted_password_min_length, | ||
| 2740 | 64, | ||
| 2741 | -1); | ||
| 2742 | |||
| 2743 | SET_TOGGLE_SENSITIVITY (checkbtn_use_master_password, hbox1); | ||
| 2692 | 2744 | ||
| 2693 | master_password.checkbtn_use_master_password | 2745 | master_password.checkbtn_use_master_password |
| 2694 | = checkbtn_use_master_password; | 2746 | = checkbtn_use_master_password; |
| 2747 | master_password.spinbtn_encrypted_password_min_length | ||
| 2748 | = spinbtn_encrypted_password_min_length; | ||
| 2695 | } | 2749 | } |
| 2696 | #endif /* USE_SSL */ | 2750 | #endif /* USE_SSL */ |
| 2697 | 2751 | ||
