aboutsummaryrefslogtreecommitdiffstats
path: root/smime/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-03-25 06:27:01 +0800
committerChris Toshok <toshok@src.gnome.org>2004-03-25 06:27:01 +0800
commit4abed2292a3e45072da19c81b6c53fab926660c7 (patch)
tree5c16f8f099a57565169029004f124bc6d3732af7 /smime/gui
parent2ac983181ab03ef7f71cba91201c2d88add302b0 (diff)
downloadgsoc2013-evolution-4abed2292a3e45072da19c81b6c53fab926660c7.tar.gz
gsoc2013-evolution-4abed2292a3e45072da19c81b6c53fab926660c7.tar.zst
gsoc2013-evolution-4abed2292a3e45072da19c81b6c53fab926660c7.zip
add BOOL:POINTER,POINTER,POINTER,POINTER for confirm_ca_cert_import.
2004-03-24 Chris Toshok <toshok@ximian.com> * 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
Diffstat (limited to 'smime/gui')
-rw-r--r--smime/gui/Makefile.am2
-rw-r--r--smime/gui/ca-trust-dialog.c113
-rw-r--r--smime/gui/ca-trust-dialog.h33
-rw-r--r--smime/gui/certificate-manager.c55
-rw-r--r--smime/gui/certificate-viewer.c25
-rw-r--r--smime/gui/component.c23
-rw-r--r--smime/gui/smime-ui.glade9
7 files changed, 236 insertions, 24 deletions
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 <toshok@ximian.com>
+ *
+ * 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 <config.h>
+#endif
+
+#include "ca-trust-dialog.h"
+#include "certificate-viewer.h"
+
+#include <gtk/gtk.h>
+
+#include <libgnome/gnome-i18n.h>
+#include <glade/glade.h>
+
+#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 <toshok@ximian.com>
+ *
+ * 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 <gtk/gtkwidget.h>
+#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 <glade/glade.h>
#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 <config.h>
#endif
+#include <gtk/gtk.h>
+
#include <libgnome/gnome-i18n.h>
+
+#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 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
+<requires lib="gnome"/>
<widget class="GtkDialog" id="certificate-viewer-dialog">
<property name="title" translatable="yes">dialog1</property>
@@ -1861,7 +1862,7 @@
<property name="spacing">0</property>
<child>
- <widget class="GtkCheckButton" id="checkbutton1">
+ <widget class="GtkCheckButton" id="ssl_trust_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Trust this CA to identify web sites.</property>
@@ -1879,7 +1880,7 @@
</child>
<child>
- <widget class="GtkCheckButton" id="checkbutton2">
+ <widget class="GtkCheckButton" id="email_trust_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Trust this CA to identify email users.</property>
@@ -1897,7 +1898,7 @@
</child>
<child>
- <widget class="GtkCheckButton" id="checkbutton3">
+ <widget class="GtkCheckButton" id="objsign_trust_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Trust this CA to identify software developers.</property>
@@ -1951,7 +1952,7 @@
<property name="yscale">1</property>
<child>
- <widget class="GtkButton" id="button1">
+ <widget class="GtkButton" id="view_certificate_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">View Certificate</property>