diff options
| author | Simeon Simeonov | 2018-02-26 12:17:39 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-02-26 12:17:39 +0100 |
| commit | ade95c14a055a404fd1f2b9cb6da94d12cc61a98 (patch) | |
| tree | c38f7fe5e34beef03e18ce8e1d0e3aee14164a64 | |
| parent | 0b3cbf57875fd692e4ba0b336fefa4bee1ed00dc (diff) | |
Signature box patch
| -rw-r--r-- | libsylph/prefs_common.c | 2 | ||||
| -rw-r--r-- | libsylph/prefs_common.h | 1 | ||||
| -rw-r--r-- | src/prefs_common_dialog.c | 122 | ||||
| -rw-r--r-- | src/rfc2015.c | 32 |
4 files changed, 152 insertions, 5 deletions
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 8ed74a3..91814fd 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c | |||
| @@ -406,6 +406,8 @@ static PrefParam param[] = { | |||
| 406 | P_BOOL}, | 406 | P_BOOL}, |
| 407 | {"gpg_signature_popup", "FALSE", &prefs_common.gpg_signature_popup, | 407 | {"gpg_signature_popup", "FALSE", &prefs_common.gpg_signature_popup, |
| 408 | P_BOOL}, | 408 | P_BOOL}, |
| 409 | {"gpg_signature_popup_mode", "1", &prefs_common.gpg_signature_popup_mode, | ||
| 410 | P_INT}, | ||
| 409 | {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL}, | 411 | {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL}, |
| 410 | {"store_passphrase_timeout", "0", | 412 | {"store_passphrase_timeout", "0", |
| 411 | &prefs_common.store_passphrase_timeout, P_INT}, | 413 | &prefs_common.store_passphrase_timeout, P_INT}, |
diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index ba9ddb5..910f370 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h | |||
| @@ -243,6 +243,7 @@ struct _PrefsCommon | |||
| 243 | /* Privacy */ | 243 | /* Privacy */ |
| 244 | gboolean auto_check_signatures; | 244 | gboolean auto_check_signatures; |
| 245 | gboolean gpg_signature_popup; | 245 | gboolean gpg_signature_popup; |
| 246 | gint gpg_signature_popup_mode; | ||
| 246 | gboolean store_passphrase; | 247 | gboolean store_passphrase; |
| 247 | gint store_passphrase_timeout; | 248 | gint store_passphrase_timeout; |
| 248 | gboolean passphrase_grab; | 249 | gboolean passphrase_grab; |
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index b46c9b7..fa4be4e 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c | |||
| @@ -205,6 +205,7 @@ static struct JunkMail { | |||
| 205 | static struct Privacy { | 205 | static struct Privacy { |
| 206 | GtkWidget *checkbtn_auto_check_signatures; | 206 | GtkWidget *checkbtn_auto_check_signatures; |
| 207 | GtkWidget *checkbtn_gpg_signature_popup; | 207 | GtkWidget *checkbtn_gpg_signature_popup; |
| 208 | GtkWidget *radiobtn_gpg_signature_all; | ||
| 208 | GtkWidget *checkbtn_store_passphrase; | 209 | GtkWidget *checkbtn_store_passphrase; |
| 209 | GtkWidget *spinbtn_store_passphrase; | 210 | GtkWidget *spinbtn_store_passphrase; |
| 210 | GtkObject *spinbtn_store_passphrase_adj; | 211 | GtkObject *spinbtn_store_passphrase_adj; |
| @@ -314,6 +315,13 @@ static void prefs_common_attach_toolbtn_pos_set_radiobtn (PrefParam *pparam); | |||
| 314 | static void prefs_common_online_mode_set_data_from_radiobtn(PrefParam *pparam); | 315 | static void prefs_common_online_mode_set_data_from_radiobtn(PrefParam *pparam); |
| 315 | static void prefs_common_online_mode_set_radiobtn (PrefParam *pparam); | 316 | static void prefs_common_online_mode_set_radiobtn (PrefParam *pparam); |
| 316 | 317 | ||
| 318 | #if USE_GPGME | ||
| 319 | static void prefs_common_gpg_signature_popup_mode_set_data_from_radiobtn( | ||
| 320 | PrefParam *pparam); | ||
| 321 | static void prefs_common_gpg_signature_popup_mode_set_radiobtn( | ||
| 322 | PrefParam *pparam); | ||
| 323 | #endif | ||
| 324 | |||
| 317 | static PrefsUIData ui_data[] = { | 325 | static PrefsUIData ui_data[] = { |
| 318 | /* Receive */ | 326 | /* Receive */ |
| 319 | {"autochk_newmail", &receive.checkbtn_autochk, | 327 | {"autochk_newmail", &receive.checkbtn_autochk, |
| @@ -540,6 +548,9 @@ static PrefsUIData ui_data[] = { | |||
| 540 | prefs_set_data_from_toggle, prefs_set_toggle}, | 548 | prefs_set_data_from_toggle, prefs_set_toggle}, |
| 541 | {"gpg_signature_popup", &privacy.checkbtn_gpg_signature_popup, | 549 | {"gpg_signature_popup", &privacy.checkbtn_gpg_signature_popup, |
| 542 | prefs_set_data_from_toggle, prefs_set_toggle}, | 550 | prefs_set_data_from_toggle, prefs_set_toggle}, |
| 551 | {"gpg_signature_popup_mode", &privacy.radiobtn_gpg_signature_all, | ||
| 552 | prefs_common_gpg_signature_popup_mode_set_data_from_radiobtn, | ||
| 553 | prefs_common_gpg_signature_popup_mode_set_radiobtn}, | ||
| 543 | {"store_passphrase", &privacy.checkbtn_store_passphrase, | 554 | {"store_passphrase", &privacy.checkbtn_store_passphrase, |
| 544 | prefs_set_data_from_toggle, prefs_set_toggle}, | 555 | prefs_set_data_from_toggle, prefs_set_toggle}, |
| 545 | {"store_passphrase_timeout", &privacy.spinbtn_store_passphrase, | 556 | {"store_passphrase_timeout", &privacy.spinbtn_store_passphrase, |
| @@ -2478,10 +2489,14 @@ static void prefs_privacy_create(void) | |||
| 2478 | GtkWidget *vbox2; | 2489 | GtkWidget *vbox2; |
| 2479 | GtkWidget *vbox3; | 2490 | GtkWidget *vbox3; |
| 2480 | GtkWidget *hbox1; | 2491 | GtkWidget *hbox1; |
| 2492 | GtkWidget *vbox_sign_popup_mode; | ||
| 2493 | GtkWidget *hbox_sign_popup_mode; | ||
| 2481 | GtkWidget *hbox_spc; | 2494 | GtkWidget *hbox_spc; |
| 2482 | GtkWidget *label; | 2495 | GtkWidget *label; |
| 2483 | GtkWidget *checkbtn_auto_check_signatures; | 2496 | GtkWidget *checkbtn_auto_check_signatures; |
| 2484 | GtkWidget *checkbtn_gpg_signature_popup; | 2497 | GtkWidget *checkbtn_gpg_signature_popup; |
| 2498 | GtkWidget *radiobtn_gpg_signature_all; | ||
| 2499 | GtkWidget *radiobtn_gpg_signature_bad; | ||
| 2485 | GtkWidget *checkbtn_store_passphrase; | 2500 | GtkWidget *checkbtn_store_passphrase; |
| 2486 | GtkObject *spinbtn_store_passphrase_adj; | 2501 | GtkObject *spinbtn_store_passphrase_adj; |
| 2487 | GtkWidget *spinbtn_store_passphrase; | 2502 | GtkWidget *spinbtn_store_passphrase; |
| @@ -2505,6 +2520,56 @@ static void prefs_privacy_create(void) | |||
| 2505 | PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup, | 2520 | PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup, |
| 2506 | _("Show signature check result in a popup window")); | 2521 | _("Show signature check result in a popup window")); |
| 2507 | 2522 | ||
| 2523 | vbox_sign_popup_mode = gtk_vbox_new (FALSE, VSPACING_NARROW); | ||
| 2524 | gtk_widget_show (vbox_sign_popup_mode); | ||
| 2525 | gtk_box_pack_start (GTK_BOX (vbox2), vbox_sign_popup_mode, FALSE, FALSE, 0); | ||
| 2526 | |||
| 2527 | hbox_sign_popup_mode = gtk_hbox_new (FALSE, 8); | ||
| 2528 | gtk_widget_show (hbox_sign_popup_mode); | ||
| 2529 | gtk_box_pack_start (GTK_BOX (vbox_sign_popup_mode), | ||
| 2530 | hbox_sign_popup_mode, | ||
| 2531 | FALSE, | ||
| 2532 | FALSE, | ||
| 2533 | 0); | ||
| 2534 | |||
| 2535 | hbox_spc = gtk_hbox_new (FALSE, 0); | ||
| 2536 | gtk_widget_show (hbox_spc); | ||
| 2537 | gtk_box_pack_start (GTK_BOX (hbox_sign_popup_mode), | ||
| 2538 | hbox_spc, | ||
| 2539 | FALSE, | ||
| 2540 | FALSE, | ||
| 2541 | 0); | ||
| 2542 | gtk_widget_set_size_request (hbox_spc, 12, -1); | ||
| 2543 | |||
| 2544 | radiobtn_gpg_signature_all = gtk_radio_button_new_with_label( | ||
| 2545 | NULL, | ||
| 2546 | _("All signatures")); | ||
| 2547 | gtk_widget_show(radiobtn_gpg_signature_all); | ||
| 2548 | gtk_box_pack_start(GTK_BOX (hbox_sign_popup_mode), | ||
| 2549 | radiobtn_gpg_signature_all, | ||
| 2550 | FALSE, | ||
| 2551 | FALSE, | ||
| 2552 | 0); | ||
| 2553 | g_object_set_data(G_OBJECT (radiobtn_gpg_signature_all), | ||
| 2554 | MENU_VAL_ID, | ||
| 2555 | GINT_TO_POINTER (1)); | ||
| 2556 | |||
| 2557 | radiobtn_gpg_signature_bad = gtk_radio_button_new_with_label_from_widget( | ||
| 2558 | GTK_RADIO_BUTTON (radiobtn_gpg_signature_all), | ||
| 2559 | _("Bad signatures only")); | ||
| 2560 | gtk_widget_show(radiobtn_gpg_signature_bad); | ||
| 2561 | gtk_box_pack_start(GTK_BOX (hbox_sign_popup_mode), | ||
| 2562 | radiobtn_gpg_signature_bad, | ||
| 2563 | FALSE, | ||
| 2564 | FALSE, | ||
| 2565 | 0); | ||
| 2566 | g_object_set_data(G_OBJECT (radiobtn_gpg_signature_bad), | ||
| 2567 | MENU_VAL_ID, | ||
| 2568 | GINT_TO_POINTER (0)); | ||
| 2569 | |||
| 2570 | SET_TOGGLE_SENSITIVITY (checkbtn_gpg_signature_popup, | ||
| 2571 | hbox_sign_popup_mode); | ||
| 2572 | |||
| 2508 | PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase, | 2573 | PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase, |
| 2509 | _("Store passphrase in memory temporarily")); | 2574 | _("Store passphrase in memory temporarily")); |
| 2510 | 2575 | ||
| @@ -2572,7 +2637,8 @@ static void prefs_privacy_create(void) | |||
| 2572 | = checkbtn_auto_check_signatures; | 2637 | = checkbtn_auto_check_signatures; |
| 2573 | privacy.checkbtn_gpg_signature_popup | 2638 | privacy.checkbtn_gpg_signature_popup |
| 2574 | = checkbtn_gpg_signature_popup; | 2639 | = checkbtn_gpg_signature_popup; |
| 2575 | privacy.checkbtn_store_passphrase = checkbtn_store_passphrase; | 2640 | privacy.radiobtn_gpg_signature_all = radiobtn_gpg_signature_all; |
| 2641 | privacy.checkbtn_store_passphrase = checkbtn_store_passphrase; | ||
| 2576 | privacy.spinbtn_store_passphrase = spinbtn_store_passphrase; | 2642 | privacy.spinbtn_store_passphrase = spinbtn_store_passphrase; |
| 2577 | privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj; | 2643 | privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj; |
| 2578 | #ifndef G_OS_WIN32 | 2644 | #ifndef G_OS_WIN32 |
| @@ -4719,6 +4785,60 @@ static void prefs_common_online_mode_set_radiobtn(PrefParam *pparam) | |||
| 4719 | } | 4785 | } |
| 4720 | } | 4786 | } |
| 4721 | 4787 | ||
| 4788 | #if USE_GPGME | ||
| 4789 | static void prefs_common_gpg_signature_popup_mode_set_data_from_radiobtn( | ||
| 4790 | PrefParam *pparam) | ||
| 4791 | { | ||
| 4792 | PrefsUIData *ui_data; | ||
| 4793 | GtkRadioButton *radiobtn; | ||
| 4794 | GSList *group; | ||
| 4795 | |||
| 4796 | ui_data = (PrefsUIData *)pparam->ui_data; | ||
| 4797 | g_return_if_fail(ui_data != NULL); | ||
| 4798 | g_return_if_fail(*ui_data->widget != NULL); | ||
| 4799 | |||
| 4800 | radiobtn = GTK_RADIO_BUTTON(*ui_data->widget); | ||
| 4801 | group = gtk_radio_button_get_group(radiobtn); | ||
| 4802 | while (group != NULL) { | ||
| 4803 | GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data); | ||
| 4804 | |||
| 4805 | if (gtk_toggle_button_get_active(btn)) { | ||
| 4806 | prefs_common.gpg_signature_popup_mode = | ||
| 4807 | GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn), MENU_VAL_ID)); | ||
| 4808 | break; | ||
| 4809 | } | ||
| 4810 | group = group->next; | ||
| 4811 | } | ||
| 4812 | } | ||
| 4813 | |||
| 4814 | static void prefs_common_gpg_signature_popup_mode_set_radiobtn( | ||
| 4815 | PrefParam *pparam) | ||
| 4816 | { | ||
| 4817 | PrefsUIData *ui_data; | ||
| 4818 | GtkRadioButton *radiobtn; | ||
| 4819 | GSList *group; | ||
| 4820 | |||
| 4821 | ui_data = (PrefsUIData *)pparam->ui_data; | ||
| 4822 | g_return_if_fail(ui_data != NULL); | ||
| 4823 | g_return_if_fail(*ui_data->widget != NULL); | ||
| 4824 | |||
| 4825 | radiobtn = GTK_RADIO_BUTTON(*ui_data->widget); | ||
| 4826 | group = gtk_radio_button_get_group(radiobtn); | ||
| 4827 | while (group != NULL) { | ||
| 4828 | GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data); | ||
| 4829 | gint data; | ||
| 4830 | |||
| 4831 | data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn), | ||
| 4832 | MENU_VAL_ID)); | ||
| 4833 | if (data == prefs_common.gpg_signature_popup_mode) { | ||
| 4834 | gtk_toggle_button_set_active(btn, TRUE); | ||
| 4835 | break; | ||
| 4836 | } | ||
| 4837 | group = group->next; | ||
| 4838 | } | ||
| 4839 | } | ||
| 4840 | #endif | ||
| 4841 | |||
| 4722 | static void prefs_common_dispitem_clicked(void) | 4842 | static void prefs_common_dispitem_clicked(void) |
| 4723 | { | 4843 | { |
| 4724 | prefs_summary_column_open(FOLDER_ITEM_IS_SENT_FOLDER | 4844 | prefs_summary_column_open(FOLDER_ITEM_IS_SENT_FOLDER |
diff --git a/src/rfc2015.c b/src/rfc2015.c index ebfa96c..48825e2 100644 --- a/src/rfc2015.c +++ b/src/rfc2015.c | |||
| @@ -210,8 +210,12 @@ static void check_signature(MimeInfo *mimeinfo, MimeInfo *partinfo, FILE *fp) | |||
| 210 | gchar *tmp_file; | 210 | gchar *tmp_file; |
| 211 | gint n_exclude_chars = 0; | 211 | gint n_exclude_chars = 0; |
| 212 | 212 | ||
| 213 | if (prefs_common.gpg_signature_popup) | 213 | if (prefs_common.gpg_signature_popup && |
| 214 | prefs_common.gpg_signature_popup_mode == 1) | ||
| 215 | { | ||
| 216 | /* FIXME: Perhaps some macro instead of 1 */ | ||
| 214 | statuswindow = gpgmegtk_sig_status_create(); | 217 | statuswindow = gpgmegtk_sig_status_create(); |
| 218 | } | ||
| 215 | 219 | ||
| 216 | err = gpgme_new(&ctx); | 220 | err = gpgme_new(&ctx); |
| 217 | if (err) { | 221 | if (err) { |
| @@ -309,8 +313,21 @@ leave: | |||
| 309 | result = _("Error verifying the signature"); | 313 | result = _("Error verifying the signature"); |
| 310 | } | 314 | } |
| 311 | debug_print("verification status: %s\n", result); | 315 | debug_print("verification status: %s\n", result); |
| 312 | if (prefs_common.gpg_signature_popup) | 316 | if (prefs_common.gpg_signature_popup && |
| 317 | prefs_common.gpg_signature_popup_mode == 1) | ||
| 318 | { | ||
| 319 | /* FIXME: Perhaps some macro instead of 1 */ | ||
| 320 | gpgmegtk_sig_status_update(statuswindow, ctx); | ||
| 321 | } else if (prefs_common.gpg_signature_popup && | ||
| 322 | verifyresult->signatures->status != GPG_ERR_NO_DATA && | ||
| 323 | verifyresult->signatures->status != GPG_ERR_NO_ERROR) | ||
| 324 | { | ||
| 325 | /* prefs_common.gpg_signature_popup_mode == 0 is useless as long as | ||
| 326 | * there are only two modes (0 and 1) | ||
| 327 | */ | ||
| 328 | statuswindow = gpgmegtk_sig_status_create(); | ||
| 313 | gpgmegtk_sig_status_update(statuswindow, ctx); | 329 | gpgmegtk_sig_status_update(statuswindow, ctx); |
| 330 | } | ||
| 314 | 331 | ||
| 315 | g_free (partinfo->sigstatus); | 332 | g_free (partinfo->sigstatus); |
| 316 | partinfo->sigstatus = g_strdup (result); | 333 | partinfo->sigstatus = g_strdup (result); |
| @@ -319,8 +336,11 @@ leave: | |||
| 319 | gpgme_data_release(text); | 336 | gpgme_data_release(text); |
| 320 | if (ctx) | 337 | if (ctx) |
| 321 | gpgme_release(ctx); | 338 | gpgme_release(ctx); |
| 322 | if (prefs_common.gpg_signature_popup) | 339 | if (prefs_common.gpg_signature_popup) { |
| 340 | /* gpgmegtk_sig_status_destroy handles NULL params so no complicated | ||
| 341 | check is needed */ | ||
| 323 | gpgmegtk_sig_status_destroy(statuswindow); | 342 | gpgmegtk_sig_status_destroy(statuswindow); |
| 343 | } | ||
| 324 | } | 344 | } |
| 325 | 345 | ||
| 326 | /* | 346 | /* |
| @@ -427,7 +447,11 @@ static gpgme_data_t pgp_decrypt(MsgInfo *msginfo, MimeInfo *partinfo, FILE *fp) | |||
| 427 | debug_print("verification status: %s\n", result); | 447 | debug_print("verification status: %s\n", result); |
| 428 | debug_print("full status: %s\n", | 448 | debug_print("full status: %s\n", |
| 429 | msginfo->encinfo->sigstatus_full); | 449 | msginfo->encinfo->sigstatus_full); |
| 430 | if (prefs_common.gpg_signature_popup) { | 450 | if (prefs_common.gpg_signature_popup && |
| 451 | ((prefs_common.gpg_signature_popup_mode == 1) || | ||
| 452 | (verifyresult->signatures->status != GPG_ERR_NO_DATA && | ||
| 453 | verifyresult->signatures->status != GPG_ERR_NO_ERROR))) | ||
| 454 | { | ||
| 431 | GpgmegtkSigStatus statuswindow; | 455 | GpgmegtkSigStatus statuswindow; |
| 432 | statuswindow = gpgmegtk_sig_status_create(); | 456 | statuswindow = gpgmegtk_sig_status_create(); |
| 433 | gpgmegtk_sig_status_update(statuswindow, ctx); | 457 | gpgmegtk_sig_status_update(statuswindow, ctx); |
