From 4e4c16760abdbc2ab34b159e52c5c027a1b2ad26 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 26 Nov 2003 08:54:48 +0000 Subject: mostly implement a viewer for certificates. 2003-11-26 Chris Toshok * 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 --- smime/gui/certificate-manager.c | 70 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) (limited to 'smime/gui/certificate-manager.c') 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 #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 @@ -114,6 +116,26 @@ handle_selection_changed (GtkTreeSelection *selection, gtk_widget_set_sensitive (view_button, cert_selected); } +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) { @@ -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) { @@ -190,6 +212,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) { @@ -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); @@ -324,6 +369,26 @@ iter_string_compare (GtkTreeModel *model, return g_utf8_collate (string1, string2); } +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) { @@ -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); -- cgit