From 4abed2292a3e45072da19c81b6c53fab926660c7 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 24 Mar 2004 22:27:01 +0000 Subject: add BOOL:POINTER,POINTER,POINTER,POINTER for confirm_ca_cert_import. 2004-03-24 Chris Toshok * lib/smime-marshal.list: add BOOL:POINTER,POINTER,POINTER,POINTER for confirm_ca_cert_import. * lib/e-cert-db.c (e_cert_db_class_init): initialize the confirm_ca_cert_import signal. (confirm_download_ca_cert): emit confirm_ca_cert_import and use the returned values. (handle_ca_cert_download): fix the ca trust foo. (e_cert_db_import_certs): pass the cerdb to handle_ca_cert_download since we need to emit something on that object. * lib/e-cert-db.h (struct _ECertDBClass): add confirm_ca_cert_import signal. * gui/smime-ui.glade: give names to the check buttons in the ca trust dialog. * gui/component.c (smime_confirm_ca_cert_import): new function, show the trust dialog. (smime_component_init): connect to "confirm_ca_cert_import" signal. * gui/certificate-viewer.c (fill_in_general): fix lots of uninitialized variable accesses. (certificate_viewer_show): don't show the dialog (or connect to the response signal.) that's the caller's job. * gui/certificate-manager.c (view_your): do the showing of the certificate_viewer here. (view_contact): same. (view_ca): same. (edit_ca): new function, pop up the ca trust dialog. we need more here though, to fill in the toggle buttons when bringing up the dialog, and also to save out the settings when the user clicks ok. (initialize_authoritycerts_ui): hook up the edit_ca button. * gui/Makefile.am (libevolution_smime_la_SOURCES): add ca-trust-dialog.[ch]. * gui/ca-trust-dialog.[ch]: new file implementing the ca trust dialog used for importing/editing ca trust levels. svn path=/trunk/; revision=25177 --- smime/gui/Makefile.am | 2 + smime/gui/ca-trust-dialog.c | 113 ++++++++++++++++++++++++++++++++++++++++ smime/gui/ca-trust-dialog.h | 33 ++++++++++++ smime/gui/certificate-manager.c | 55 ++++++++++++++++--- smime/gui/certificate-viewer.c | 25 ++++----- smime/gui/component.c | 23 ++++++++ smime/gui/smime-ui.glade | 9 ++-- 7 files changed, 236 insertions(+), 24 deletions(-) create mode 100644 smime/gui/ca-trust-dialog.c create mode 100644 smime/gui/ca-trust-dialog.h (limited to 'smime/gui') diff --git a/smime/gui/Makefile.am b/smime/gui/Makefile.am index 17526784d6..3a18b30784 100644 --- a/smime/gui/Makefile.am +++ b/smime/gui/Makefile.am @@ -19,6 +19,8 @@ INCLUDES = \ noinst_LTLIBRARIES = libevolution-smime.la libevolution_smime_la_SOURCES = \ + ca-trust-dialog.c \ + ca-trust-dialog.h \ certificate-manager.c \ certificate-manager.h \ certificate-viewer.c \ diff --git a/smime/gui/ca-trust-dialog.c b/smime/gui/ca-trust-dialog.c new file mode 100644 index 0000000000..2e97653601 --- /dev/null +++ b/smime/gui/ca-trust-dialog.c @@ -0,0 +1,113 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok + * + * Copyright (C) 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "ca-trust-dialog.h" +#include "certificate-viewer.h" + +#include + +#include +#include + +#define GLADE_FILE_NAME "smime-ui.glade" + +typedef struct { + GladeXML *gui; + GtkWidget *dialog; + GtkWidget *ssl_checkbutton; + GtkWidget *email_checkbutton; + GtkWidget *objsign_checkbutton; + GtkWidget *view_cert_button; + + ECert *cert; +} CATrustDialogData; + +static void +free_data (gpointer data, GObject *where_the_object_was) +{ + CATrustDialogData *ctd = data; + + g_object_unref (ctd->cert); + g_object_unref (ctd->gui); + g_free (ctd); +} + +static void +view_cert (GtkWidget *button, CATrustDialogData *data) +{ + GtkWidget *dialog = certificate_viewer_show (data->cert); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog)); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_destroy (dialog); +} + +GtkWidget* +ca_trust_dialog_show (ECert *cert, gboolean importing) +{ + CATrustDialogData *ctd_data; + + ctd_data = g_new0 (CATrustDialogData, 1); + ctd_data->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL); + + ctd_data->dialog = glade_xml_get_widget (ctd_data->gui, "ca-trust-dialog"); + ctd_data->cert = g_object_ref (cert); + + ctd_data->ssl_checkbutton = glade_xml_get_widget (ctd_data->gui, "ssl_trust_checkbutton"); + ctd_data->email_checkbutton = glade_xml_get_widget (ctd_data->gui, "email_trust_checkbutton"); + ctd_data->objsign_checkbutton = glade_xml_get_widget (ctd_data->gui, "objsign_trust_checkbutton"); + ctd_data->view_cert_button = glade_xml_get_widget (ctd_data->gui, "view_certificate_button"); + + g_signal_connect (ctd_data->view_cert_button, + "clicked", G_CALLBACK (view_cert), + ctd_data); + + gtk_widget_realize (ctd_data->dialog); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (ctd_data->dialog)->action_area), 12); + + g_object_weak_ref (G_OBJECT (ctd_data->dialog), free_data, ctd_data); + + g_object_set_data (G_OBJECT (ctd_data->dialog), "CATrustDialogData", ctd_data); + + return ctd_data->dialog; +} + +void +ca_trust_dialog_get_trust (GtkWidget *widget, gboolean *ssl, gboolean *email, gboolean *objsign) +{ + CATrustDialogData *ctd_data; + + ctd_data = g_object_get_data (G_OBJECT (widget), "CATrustDialogData"); + if (!ctd_data) + return; + + *ssl = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctd_data->ssl_checkbutton)); + *email = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctd_data->email_checkbutton)); + *objsign = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctd_data->objsign_checkbutton)); +} diff --git a/smime/gui/ca-trust-dialog.h b/smime/gui/ca-trust-dialog.h new file mode 100644 index 0000000000..e15d98170a --- /dev/null +++ b/smime/gui/ca-trust-dialog.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok + * + * Copyright (C) 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _CA_TRUST_DIALOG_H_ +#define _CA_TRUST_DIALOG_H + +#include +#include "e-cert.h" + +GtkWidget* ca_trust_dialog_show (ECert *cert, gboolean importing); + +void ca_trust_dialog_get_trust (GtkWidget *widget, gboolean *ssl, gboolean *email, gboolean *objsign); + +#endif /* _CA_TRUST_DIALOG_H_ */ diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c index 94698d2264..a59f8a0d96 100644 --- a/smime/gui/certificate-manager.c +++ b/smime/gui/certificate-manager.c @@ -33,6 +33,7 @@ #include #include "evolution-config-control.h" +#include "ca-trust-dialog.h" #include "certificate-manager.h" #include "certificate-viewer.h" @@ -192,8 +193,12 @@ view_your (GtkWidget *widget, CertificateManagerData *cfm) 4, &cert, -1); - if (cert) - certificate_viewer_show (cert); + if (cert) { + GtkWidget *dialog = certificate_viewer_show (cert); + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + } } } @@ -305,8 +310,12 @@ view_contact (GtkWidget *widget, CertificateManagerData *cfm) 3, &cert, -1); - if (cert) - certificate_viewer_show (cert); + if (cert) { + GtkWidget *dialog = certificate_viewer_show (cert); + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + } } } @@ -452,8 +461,39 @@ view_ca (GtkWidget *widget, CertificateManagerData *cfm) 1, &cert, -1); - if (cert) - certificate_viewer_show (cert); + if (cert) { + GtkWidget *dialog = certificate_viewer_show (cert); + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + } + } +} + +static void +edit_ca (GtkWidget *widget, CertificateManagerData *cfm) +{ + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->authoritycerts_treeview)), + NULL, + &iter)) { + ECert *cert; + + gtk_tree_model_get (GTK_TREE_MODEL (cfm->authoritycerts_streemodel), + &iter, + 1, &cert, + -1); + + if (cert) { + GtkWidget *dialog = ca_trust_dialog_show (cert, FALSE); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + /* XXX more stuff here surely */ + + gtk_widget_destroy (dialog); + } } } @@ -556,6 +596,9 @@ initialize_authoritycerts_ui (CertificateManagerData *cfm) if (cfm->view_ca_button) g_signal_connect (cfm->view_ca_button, "clicked", G_CALLBACK (view_ca), cfm); + if (cfm->edit_ca_button) + g_signal_connect (cfm->edit_ca_button, "clicked", G_CALLBACK (edit_ca), cfm); + if (cfm->import_ca_button) g_signal_connect (cfm->import_ca_button, "clicked", G_CALLBACK (import_ca), cfm); diff --git a/smime/gui/certificate-viewer.c b/smime/gui/certificate-viewer.c index 8fd5acb0b9..4495ca8f2b 100644 --- a/smime/gui/certificate-viewer.c +++ b/smime/gui/certificate-viewer.c @@ -70,24 +70,24 @@ fill_in_general (CertificateViewerData *cvm_data, ECert *cert) char *markup; /* issued to */ + label = glade_xml_get_widget (cvm_data->gui, "issued-to-cn"); if (e_cert_get_cn (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-to-cn"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_cn (cert)); } else { gtk_label_set_markup (GTK_LABEL (label), NOT_PART_OF_CERT_MARKUP); } + label = glade_xml_get_widget (cvm_data->gui, "issued-to-o"); if (e_cert_get_org (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-to-o"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_org (cert)); } else { gtk_label_set_markup (GTK_LABEL (label), NOT_PART_OF_CERT_MARKUP); } + label = glade_xml_get_widget (cvm_data->gui, "issued-to-ou"); if (e_cert_get_org_unit (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-to-ou"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_org_unit (cert)); } else { @@ -99,24 +99,24 @@ fill_in_general (CertificateViewerData *cvm_data, ECert *cert) gtk_label_set_text (GTK_LABEL (label), text); /* issued by */ + label = glade_xml_get_widget (cvm_data->gui, "issued-by-cn"); if (e_cert_get_issuer_cn (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-by-cn"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_issuer_cn (cert)); } else { gtk_label_set_markup (GTK_LABEL (label), NOT_PART_OF_CERT_MARKUP); } + label = glade_xml_get_widget (cvm_data->gui, "issued-by-o"); if (e_cert_get_issuer_org (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-by-o"); - gtk_label_set_text (GTK_LABEL (label), e_cert_get_issuer_org (cert)); + gtk_label_set_text (GTK_LABEL (label), e_cert_get_issuer_org (cert)); } else { gtk_label_set_markup (GTK_LABEL (label), NOT_PART_OF_CERT_MARKUP); } - + + label = glade_xml_get_widget (cvm_data->gui, "issued-by-ou"); if (e_cert_get_issuer_org_unit (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "issued-by-ou"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_issuer_org_unit (cert)); } else { @@ -124,16 +124,16 @@ fill_in_general (CertificateViewerData *cvm_data, ECert *cert) } /* validity */ + label = glade_xml_get_widget (cvm_data->gui, "validity-issued-on"); if (e_cert_get_issued_on (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "validity-issued-on"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_issued_on (cert)); } else { gtk_label_set_markup (GTK_LABEL (label), NOT_PART_OF_CERT_MARKUP); } + label = glade_xml_get_widget (cvm_data->gui, "validity-expires-on"); if (e_cert_get_expires_on (cert)) { - label = glade_xml_get_widget (cvm_data->gui, "validity-expires-on"); gtk_label_set_text (GTK_LABEL (label), e_cert_get_expires_on (cert)); } else { @@ -343,9 +343,6 @@ certificate_viewer_show (ECert *cert) g_object_weak_ref (G_OBJECT (cvm_data->dialog), free_data, cvm_data); - g_signal_connect (cvm_data->dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - - gtk_widget_show (cvm_data->dialog); + /* gtk_widget_show (cvm_data->dialog);*/ return cvm_data->dialog; } diff --git a/smime/gui/component.c b/smime/gui/component.c index 3c86b6e820..e3e5e0f695 100644 --- a/smime/gui/component.c +++ b/smime/gui/component.c @@ -25,7 +25,11 @@ #include #endif +#include + #include + +#include "ca-trust-dialog.h" #include "e-cert-db.h" #include "e-util/e-passwords.h" #include "pk11func.h" @@ -77,6 +81,21 @@ smime_pk11_change_passwd (ECertDB *db, char **old_passwd, char **passwd, gpointe return TRUE; } +static gboolean +smime_confirm_ca_cert_import (ECertDB *db, ECert *cert, gboolean *trust_ssl, gboolean *trust_email, gboolean *trust_objsign, gpointer arg) +{ + GtkWidget *dialog = ca_trust_dialog_show (cert, TRUE); + int response; + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + ca_trust_dialog_get_trust (dialog, trust_ssl, trust_email, trust_objsign); + + gtk_widget_destroy (dialog); + + return response != GTK_RESPONSE_CANCEL; +} + void smime_component_init (void) { @@ -92,4 +111,8 @@ smime_component_init (void) g_signal_connect (e_cert_db_peek (), "pk11_change_passwd", G_CALLBACK (smime_pk11_change_passwd), NULL); + + g_signal_connect (e_cert_db_peek (), + "confirm_ca_cert_import", + G_CALLBACK (smime_confirm_ca_cert_import), NULL); } diff --git a/smime/gui/smime-ui.glade b/smime/gui/smime-ui.glade index 3b80c00baa..5682522b8d 100644 --- a/smime/gui/smime-ui.glade +++ b/smime/gui/smime-ui.glade @@ -2,6 +2,7 @@ + dialog1 @@ -1861,7 +1862,7 @@ 0 - + True True Trust this CA to identify web sites. @@ -1879,7 +1880,7 @@ - + True True Trust this CA to identify email users. @@ -1897,7 +1898,7 @@ - + True True Trust this CA to identify software developers. @@ -1951,7 +1952,7 @@ 1 - + True True View Certificate -- cgit