aboutsummaryrefslogtreecommitdiffstats
path: root/smime/gui
diff options
context:
space:
mode:
Diffstat (limited to 'smime/gui')
-rw-r--r--smime/gui/Makefile.am2
-rw-r--r--smime/gui/certificate-manager.c70
-rw-r--r--smime/gui/certificate-viewer.c125
-rw-r--r--smime/gui/certificate-viewer.h31
-rw-r--r--smime/gui/smime-ui.glade2
5 files changed, 228 insertions, 2 deletions
diff --git a/smime/gui/Makefile.am b/smime/gui/Makefile.am
index e71756fa39..aba4c31548 100644
--- a/smime/gui/Makefile.am
+++ b/smime/gui/Makefile.am
@@ -23,6 +23,8 @@ noinst_LTLIBRARIES = libevolution-smime.la
libevolution_smime_la_SOURCES = \
certificate-manager.c \
certificate-manager.h \
+ certificate-viewer.c \
+ certificate-viewer.h \
e-cert-selector.c \
e-cert-selector.h
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index 48f9ef38b1..41caa775a5 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -29,9 +29,11 @@
#include <glade/glade.h>
#include "evolution-config-control.h"
#include "certificate-manager.h"
+#include "certificate-viewer.h"
#include "e-cert.h"
#include "e-cert-db.h"
+#include "e-pkcs12.h"
#include "nss.h"
#include <cms.h>
@@ -115,6 +117,26 @@ handle_selection_changed (GtkTreeSelection *selection,
}
static void
+import_your (GtkWidget *widget, CertificateManagerData *cfm)
+{
+ GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
+
+ if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) {
+ const char *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+ EPKCS12 *pkcs12 = e_pkcs12_new ();
+
+ if (e_pkcs12_import_from_file (pkcs12, filename, NULL /* XXX */)) {
+ /* there's no telling how many certificates were added during the import,
+ so we blow away the contact cert display and regenerate it. */
+ unload_certs (cfm, E_CERT_USER);
+ load_certs (cfm, E_CERT_USER, add_user_cert);
+ }
+ }
+
+ gtk_widget_destroy (filesel);
+}
+
+static void
yourcerts_selection_changed (GtkTreeSelection *selection, CertificateManagerData *cfm)
{
handle_selection_changed (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->yourcerts_treeview)),
@@ -170,7 +192,7 @@ initialize_yourcerts_ui (CertificateManagerData *cfm)
g_signal_connect (selection, "changed", G_CALLBACK (yourcerts_selection_changed), cfm);
if (cfm->import_your_button) {
- /* g_signal_connect */
+ g_signal_connect (cfm->import_your_button, "clicked", G_CALLBACK (import_your), cfm);
}
if (cfm->delete_your_button) {
@@ -191,6 +213,26 @@ initialize_yourcerts_ui (CertificateManagerData *cfm)
}
static void
+view_contact (GtkWidget *widget, CertificateManagerData *cfm)
+{
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->contactcerts_treeview)),
+ NULL,
+ &iter)) {
+ ECert *cert;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_treemodel),
+ &iter,
+ 3, &cert,
+ -1);
+
+ if (cert)
+ certificate_viewer_show (cert);
+ }
+}
+
+static void
import_contact (GtkWidget *widget, CertificateManagerData *cfm)
{
GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
@@ -297,6 +339,9 @@ initialize_contactcerts_ui (CertificateManagerData *cfm)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cfm->contactcerts_treeview));
g_signal_connect (selection, "changed", G_CALLBACK (contactcerts_selection_changed), cfm);
+ if (cfm->view_contact_button)
+ g_signal_connect (cfm->view_contact_button, "clicked", G_CALLBACK (view_contact), cfm);
+
if (cfm->import_contact_button)
g_signal_connect (cfm->import_contact_button, "clicked", G_CALLBACK (import_contact), cfm);
@@ -325,6 +370,26 @@ iter_string_compare (GtkTreeModel *model,
}
static void
+view_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_treemodel),
+ &iter,
+ 1, &cert,
+ -1);
+
+ if (cert)
+ certificate_viewer_show (cert);
+ }
+}
+
+static void
import_ca (GtkWidget *widget, CertificateManagerData *cfm)
{
GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
@@ -421,6 +486,9 @@ initialize_authoritycerts_ui (CertificateManagerData *cfm)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cfm->authoritycerts_treeview));
g_signal_connect (selection, "changed", G_CALLBACK (authoritycerts_selection_changed), cfm);
+ if (cfm->view_ca_button)
+ g_signal_connect (cfm->view_ca_button, "clicked", G_CALLBACK (view_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
new file mode 100644
index 0000000000..4a0bc3327d
--- /dev/null
+++ b/smime/gui/certificate-viewer.c
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian, Inc. (www.ximian.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.
+ *
+ */
+
+#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;
+} CertificateViewerData;
+
+static void
+free_data (gpointer data, GObject *where_the_object_was)
+{
+ CertificateViewerData *cvm = data;
+
+ g_object_unref (cvm->gui);
+ g_free (cvm);
+}
+
+
+GtkWidget*
+certificate_viewer_show (ECert *cert)
+{
+ CertificateViewerData *cvm_data;
+ CERTCertificate *mcert;
+ GtkWidget *label;
+ const char *text;
+
+ mcert = e_cert_get_internal_cert (cert);
+
+ cvm_data = g_new0 (CertificateViewerData, 1);
+ cvm_data->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL);
+
+ cvm_data->dialog = glade_xml_get_widget (cvm_data->gui, "certificate-viewer-dialog");
+
+ /* issued to */
+ 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));
+ }
+
+ 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));
+ }
+
+ 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));
+ }
+
+ text = e_cert_get_serial_number (cert);
+ label = glade_xml_get_widget (cvm_data->gui, "issued-to-serial");
+ gtk_label_set_text (GTK_LABEL (label), text);
+
+ /* issued by */
+ 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));
+ }
+
+ 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));
+ }
+
+ 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));
+ }
+
+ /* validity */
+ 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));
+ }
+
+ 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));
+ }
+
+ /* fingerprints */
+ text = e_cert_get_sha1_fingerprint (cert);
+ label = glade_xml_get_widget (cvm_data->gui, "fingerprints-sha1");
+ gtk_label_set_text (GTK_LABEL (label), text);
+
+ text = e_cert_get_md5_fingerprint (cert);
+ label = glade_xml_get_widget (cvm_data->gui, "fingerprints-md5");
+ gtk_label_set_text (GTK_LABEL (label), text);
+
+ 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);
+ return cvm_data->dialog;
+}
diff --git a/smime/gui/certificate-viewer.h b/smime/gui/certificate-viewer.h
new file mode 100644
index 0000000000..ab60043a39
--- /dev/null
+++ b/smime/gui/certificate-viewer.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian, Inc. (www.ximian.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 _CERTIFICATE_VIEWER_H_
+#define _CERTIFICATE_VIEWER_H
+
+#include <gtk/gtkwidget.h>
+#include "e-cert.h"
+
+GtkWidget* certificate_viewer_show (ECert *cert);
+
+#endif /* _CERTIFICATE_VIEWER_H_ */
diff --git a/smime/gui/smime-ui.glade b/smime/gui/smime-ui.glade
index 3cd6f764f7..57475c1cbc 100644
--- a/smime/gui/smime-ui.glade
+++ b/smime/gui/smime-ui.glade
@@ -745,7 +745,7 @@
</child>
<child>
- <widget class="GtkLabel" id="fingerprints-sh1">
+ <widget class="GtkLabel" id="fingerprints-sha1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">&lt;Not Part of Certificate&gt;</property>