aboutsummaryrefslogtreecommitdiffstats
path: root/smime/gui/certificate-manager.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-11-26 16:54:48 +0800
committerChris Toshok <toshok@src.gnome.org>2003-11-26 16:54:48 +0800
commit4e4c16760abdbc2ab34b159e52c5c027a1b2ad26 (patch)
tree3011e05a12b84f273ae36b6109293a55fe1aec53 /smime/gui/certificate-manager.c
parent30ff908fcddcf18107d8b0fd39e4504b2a69ef19 (diff)
downloadgsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar.gz
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar.bz2
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar.lz
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar.xz
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.tar.zst
gsoc2013-evolution-4e4c16760abdbc2ab34b159e52c5c027a1b2ad26.zip
mostly implement a viewer for certificates.
2003-11-26 Chris Toshok <toshok@ximian.com> * gui/certificate-viewer.[ch]: mostly implement a viewer for certificates. * gui/smime-ui.glade: fingerprints-sh1 -> fingerprints-sha1. * gui/certificate-manager.c (import_your): new function, use e-pkcs12 to implement it. (initialize_yourcerts_ui): hook up the import button. (view_contact): new function, bring up the certificate viewer. (initialize_contactcerts_ui): hook up the view button. (view_ca): new function, bring up the certificate viewer. (initialize_authoritycerts_ui): hook up the view button. * gui/Makefile.am (libevolution_smime_la_SOURCES): add certificate-viewer.[ch] * lib/e-cert.c (e_cert_dispose): free all the new cached foo. (e_cert_populate): populate all the new cached foo. (e_cert_get_issuer_cn): new function. (e_cert_get_issuer_org): same. (e_cert_get_issuer_org_unit): same. (e_cert_get_issued_on_time): same. (e_cert_get_issued_on): same. (e_cert_get_expires_on_time): same. (e_cert_get_expires_on): same. (e_cert_get_serial_number): same. (e_cert_get_sha1_fingerprint): same. (e_cert_get_md5_fingerprint): same. * lib/e-cert.h: add prototypes for lots more accessors. * lib/e-cert-db.c (e_cert_db_find_cert_by_key): fix typo. (e_cert_db_find_cert_by_email_address): call CERT_DestroyCertificate to free the cert. (default_nickname): new function. (e_cert_db_import_user_cert): implement. (e_cert_db_import_server_cert): add blurb. * lib/e-pkcs12.[ch]: new files. * lib/Makefile.am (libessmime_la_SOURCES): add e-pkcs12.[ch] svn path=/trunk/; revision=23486
Diffstat (limited to 'smime/gui/certificate-manager.c')
-rw-r--r--smime/gui/certificate-manager.c70
1 files changed, 69 insertions, 1 deletions
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);