From 1609f69980b34649ee50ab8ec411609ad94106c9 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Thu, 23 Oct 2003 16:11:32 +0000 Subject: initial addition of s/mime foo. 2003-10-23 Chris Toshok * lib/e-cert.[ch], lib/Makefile.am, gui/certificate-manager.[ch], gui/Makefile.am, gui/smime-ui.glade, Makefile.am: initial addition of s/mime foo. svn path=/trunk/; revision=23042 --- smime/.cvsignore | 2 + smime/ChangeLog | 6 + smime/Makefile.am | 1 + smime/gui/.cvsignore | 3 + smime/gui/Makefile.am | 34 + smime/gui/certificate-manager.c | 346 ++++++++ smime/gui/certificate-manager.h | 9 + smime/gui/smime-ui.glade | 1753 +++++++++++++++++++++++++++++++++++++++ smime/lib/.cvsignore | 3 + smime/lib/Makefile.am | 24 + smime/lib/e-cert.c | 148 ++++ smime/lib/e-cert.h | 67 ++ 12 files changed, 2396 insertions(+) create mode 100644 smime/.cvsignore create mode 100644 smime/ChangeLog create mode 100644 smime/Makefile.am create mode 100644 smime/gui/.cvsignore create mode 100644 smime/gui/Makefile.am create mode 100644 smime/gui/certificate-manager.c create mode 100644 smime/gui/certificate-manager.h create mode 100644 smime/gui/smime-ui.glade create mode 100644 smime/lib/.cvsignore create mode 100644 smime/lib/Makefile.am create mode 100644 smime/lib/e-cert.c create mode 100644 smime/lib/e-cert.h diff --git a/smime/.cvsignore b/smime/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/smime/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/smime/ChangeLog b/smime/ChangeLog new file mode 100644 index 0000000000..fa7072a960 --- /dev/null +++ b/smime/ChangeLog @@ -0,0 +1,6 @@ +2003-10-23 Chris Toshok + + * lib/e-cert.[ch], lib/Makefile.am, gui/certificate-manager.[ch], + gui/Makefile.am, gui/smime-ui.glade, Makefile.am: initial addition + of s/mime foo. + diff --git a/smime/Makefile.am b/smime/Makefile.am new file mode 100644 index 0000000000..1d3390b381 --- /dev/null +++ b/smime/Makefile.am @@ -0,0 +1 @@ +SUBDIRS= lib gui \ No newline at end of file diff --git a/smime/gui/.cvsignore b/smime/gui/.cvsignore new file mode 100644 index 0000000000..22a4e7292f --- /dev/null +++ b/smime/gui/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in + diff --git a/smime/gui/Makefile.am b/smime/gui/Makefile.am new file mode 100644 index 0000000000..fee07fa2ca --- /dev/null +++ b/smime/gui/Makefile.am @@ -0,0 +1,34 @@ +INCLUDES = \ + -DG_LOG_DOMAIN=\"evolution-smime\" \ + -I$(top_srcdir) \ + -I$(top_srcdir)/smime/lib \ + -I$(top_srcdir)/shell \ + -I$(top_builddir) \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ + -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ + -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ + -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ + -DPREFIX=\""$(prefix)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED \ + -DLIBGNOME_DISABLE_DEPRECATED \ + -DLIBGNOMEUI_DISABLE_DEPRECATED \ + $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ + $(CAMEL_CFLAGS) + +noinst_LTLIBRARIES = libevolution-smime.la + +libevolution_smime_la_SOURCES = \ + certificate-manager.c + +libevolution_smime_la_LIBADD = \ + $(top_builddir)/smime/lib/libessmime.la \ + $(EVOLUTION_ADDRESSBOOK_LIBS) $(CAMEL_LIBS) + + +glade_DATA = smime-ui.glade + +EXTRA_DIST = \ + $(glade_DATA) diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c new file mode 100644 index 0000000000..97d0a1d919 --- /dev/null +++ b/smime/gui/certificate-manager.c @@ -0,0 +1,346 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok + * + * 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. + * + */ + +#define GLADE_FILE_NAME "smime-ui.glade" + +#include +#include +#include +#include +#include + +#include + +#include +#include "evolution-config-control.h" +#include "certificate-manager.h" + +#include "e-cert.h" + +#include "nss.h" +#include +#include +#include +#include +#include + +typedef struct { + GladeXML *gui; + + GtkWidget *yourcerts_treeview; + GtkTreeStore *yourcerts_treemodel; + GHashTable *yourcerts_root_hash; + + GtkWidget *contactcerts_treeview; + GtkTreeStore *contactcerts_treemodel; + GHashTable *contactcerts_root_hash; + + GtkWidget *authoritycerts_treeview; + GtkTreeStore *authoritycerts_treemodel; + GHashTable *authoritycerts_root_hash; +} CertificateManagerData; + +typedef enum { + USER_CERT, + CONTACT_CERT, + CA_CERT +} CertType; + +static void +initialize_yourcerts_ui (CertificateManagerData *cfm) +{ + GtkCellRenderer *cell = gtk_cell_renderer_text_new (); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->yourcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Certificate Name"), + cell, + "text", 0, + NULL)); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->yourcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Purposes"), + cell, + "text", 1, + NULL)); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->yourcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Serial Number"), + cell, + "text", 2, + NULL)); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->yourcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Expires"), + cell, + "text", 3, + NULL)); + + cfm->yourcerts_treemodel = gtk_tree_store_new (4, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + + gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->yourcerts_treeview), + GTK_TREE_MODEL (cfm->yourcerts_treemodel)); + + cfm->yourcerts_root_hash = g_hash_table_new (g_str_hash, g_str_equal); +} + +static void +initialize_contactcerts_ui (CertificateManagerData *cfm) +{ + GtkCellRenderer *cell = gtk_cell_renderer_text_new (); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->contactcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Certificate Name"), + cell, + "text", 0, + NULL)); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->contactcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("E-Mail Address"), + cell, + "text", 1, + NULL)); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->contactcerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Purposes"), + cell, + "text", 2, + NULL)); + + cfm->contactcerts_treemodel = gtk_tree_store_new (3, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + + gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->contactcerts_treeview), + GTK_TREE_MODEL (cfm->contactcerts_treemodel)); + + cfm->contactcerts_root_hash = g_hash_table_new (g_str_hash, g_str_equal); +} + +static gint +iter_string_compare (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer user_data) +{ + char *string1, *string2; + + gtk_tree_model_get (model, a, + 0, &string1, + -1); + + gtk_tree_model_get (model, b, + 0, &string2, + -1); + + return g_utf8_collate (string1, string2); +} + +static void +initialize_authoritycerts_ui (CertificateManagerData *cfm) +{ + GtkCellRenderer *cell = gtk_cell_renderer_text_new (); + + gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->authoritycerts_treeview), + gtk_tree_view_column_new_with_attributes (_("Certificate Name"), + cell, + "text", 0, + NULL)); + + cfm->authoritycerts_treemodel = gtk_tree_store_new (1, + G_TYPE_STRING); + + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (cfm->authoritycerts_treemodel), + 0, + iter_string_compare, NULL, NULL); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cfm->authoritycerts_treemodel), + 0, + GTK_SORT_ASCENDING); + + gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->authoritycerts_treeview), + GTK_TREE_MODEL (cfm->authoritycerts_treemodel)); + + cfm->authoritycerts_root_hash = g_hash_table_new (g_str_hash, g_str_equal); +} + +static CertType +get_cert_type (ECert *cert) +{ + const char *nick = e_cert_get_nickname (cert); + const char *email = e_cert_get_email (cert); + + if (e_cert_is_ca_cert (cert)) + return CA_CERT; + + /* XXX more stuff in here */ + else + return USER_CERT; +} + +typedef void (*AddCertCb)(CertificateManagerData *cfm, ECert *cert); + +static void +add_user_cert (CertificateManagerData *cfm, ECert *cert) +{ + GtkTreeIter iter; + GtkTreeIter *parent_iter = NULL; + const char *organization = e_cert_get_org (cert); + const char *common_name; + + if (organization) { + parent_iter = g_hash_table_lookup (cfm->yourcerts_root_hash, organization); + if (!parent_iter) { + /* create a new toplevel node */ + gtk_tree_store_append (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, NULL); + + gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, + 0, organization, -1); + + /* now copy it off into parent_iter and insert it into + the hashtable */ + parent_iter = gtk_tree_iter_copy (&iter); + g_hash_table_insert (cfm->yourcerts_root_hash, g_strdup (organization), parent_iter); + } + } + + gtk_tree_store_append (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, parent_iter); + + common_name = e_cert_get_cn (cert); + if (common_name) { + gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, + 0, common_name, -1); + } + else + gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, + 0, e_cert_get_nickname (cert), -1); +} + +static void +add_contact_cert (CertificateManagerData *cfm, ECert *cert) +{ + /* nothing yet */ +} + +static void +add_ca_cert (CertificateManagerData *cfm, ECert *cert) +{ + GtkTreeIter iter; + GtkTreeIter *parent_iter = NULL; + const char *organization = e_cert_get_org (cert); + const char *common_name; + + if (organization) { + parent_iter = g_hash_table_lookup (cfm->authoritycerts_root_hash, organization); + if (!parent_iter) { + /* create a new toplevel node */ + gtk_tree_store_append (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, NULL); + + gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, + 0, organization, -1); + + /* now copy it off into parent_iter and insert it into + the hashtable */ + parent_iter = gtk_tree_iter_copy (&iter); + g_hash_table_insert (cfm->authoritycerts_root_hash, g_strdup (organization), parent_iter); + } + } + + + gtk_tree_store_append (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, parent_iter); + + common_name = e_cert_get_cn (cert); + if (common_name) { + gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, + 0, common_name, -1); + } + else + gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, + 0, e_cert_get_nickname (cert), -1); +} + +static void +load_certs (CertificateManagerData *cfm, + CertType type, + AddCertCb add_cert) +{ + CERTCertList *certList; + CERTCertListNode *node; + + certList = PK11_ListCerts (PK11CertListUnique, NULL); + + printf ("certList = %p\n", certList); + + for (node = CERT_LIST_HEAD(certList); + !CERT_LIST_END(node, certList); + node = CERT_LIST_NEXT(node)) { + ECert *cert = e_cert_new ((CERTCertificate*)node->cert); + if (get_cert_type(cert) == type) { + printf ("cert (nickname = '%s') matches\n", e_cert_get_nickname (cert)); + add_cert (cfm, cert); + } + /* XXX we leak cert */ + } + +} + +static void +populate_ui (CertificateManagerData *cfm) +{ + load_certs (cfm, USER_CERT, add_user_cert); + load_certs (cfm, CONTACT_CERT, add_contact_cert); + load_certs (cfm, CA_CERT, add_ca_cert); +} + +EvolutionConfigControl* +certificate_manager_config_control_new (void) +{ + CertificateManagerData *cfm_data = g_new0 (CertificateManagerData, 1); + GtkWidget *control_widget; + + /* XXX this should happen someplace else, and shouldn't + reference my default mozilla profile :) */ + NSS_InitReadWrite ("/home/toshok/.mozilla/default/xuvq7jx3.slt"); + + cfm_data->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL); + + cfm_data->yourcerts_treeview = glade_xml_get_widget (cfm_data->gui, "yourcerts-treeview"); + cfm_data->contactcerts_treeview = glade_xml_get_widget (cfm_data->gui, "contactcerts-treeview"); + cfm_data->authoritycerts_treeview = glade_xml_get_widget (cfm_data->gui, "authoritycerts-treeview"); + + initialize_yourcerts_ui(cfm_data); + initialize_contactcerts_ui(cfm_data); + initialize_authoritycerts_ui(cfm_data); + + populate_ui (cfm_data); + + control_widget = glade_xml_get_widget (cfm_data->gui, "cert-manager-notebook"); + gtk_widget_ref (control_widget); + + gtk_container_remove (GTK_CONTAINER (control_widget->parent), control_widget); + + return evolution_config_control_new (control_widget); +} diff --git a/smime/gui/certificate-manager.h b/smime/gui/certificate-manager.h new file mode 100644 index 0000000000..0cd1bb1be5 --- /dev/null +++ b/smime/gui/certificate-manager.h @@ -0,0 +1,9 @@ + +#ifndef _CERTIFICATE_MANAGER_H_ +#define _CERTIFICATE_MANAGER_H + +#include "evolution-config-control.h" + +EvolutionConfigControl* certificate_manager_config_control_new (void); + +#endif /* _CERTIFICATE_MANAGER_H_ */ diff --git a/smime/gui/smime-ui.glade b/smime/gui/smime-ui.glade new file mode 100644 index 0000000000..a3475d21b6 --- /dev/null +++ b/smime/gui/smime-ui.glade @@ -0,0 +1,1753 @@ + + + + + + + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + True + True + True + GTK_POS_TOP + False + False + + + + 6 + True + False + 6 + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + False + 0 + + + + True + SSL Client Certificate + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + SSL Server Certificate + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Email Signer Certificate + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Email Recipient Certificate + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + True + <b>This certificate has been verified for the following uses:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + True + + + + + + True + + + 0 + False + True + + + + + + 3 + True + 15 + 2 + False + 0 + 6 + + + + True + <b>Issued To</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 1 + 0 + 3 + + + 0 + 2 + 0 + 1 + fill + + + + + + + True + Common Name (CN) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Organization (O) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Organizational Unit (OU) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Serial Number + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Common Name (CN) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + Organization (O) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + Organizational Unit (OU) + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 8 + 9 + fill + + + + + + + True + Issued On + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 10 + 11 + fill + + + + + + + True + Expires On + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 11 + 12 + fill + + + + + + + True + <b>Issued By</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 1 + 0 + 3 + + + 0 + 2 + 5 + 6 + fill + + + + + + + True + <b>Fingerprints</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 2 + 12 + 13 + fill + + + + + + + True + SHA1 Fingerprint + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 13 + 14 + fill + + + + + + + True + MD5 Fingerprint + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 1 + 14 + 15 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 8 + 9 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 10 + 11 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 11 + 12 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 13 + 14 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 14 + 15 + fill + + + + + + + True + True + <Not Part of Certificate> + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + <b>Validity</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 2 + 9 + 10 + fill + + + + + + 0 + False + True + + + + + False + True + + + + + + True + General + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + False + 0 + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + + + + + + + + True + <b>Certificate Hierarchy</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + + + + + + + + True + <b>Certificate Fields</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + True + <b>Field Value</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + True + + + + + False + True + + + + + + True + Details + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + + + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 6 + True + False + 6 + + + + True + You have certificates from these organizations that identify you: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 6 + + + + True + True + True + View + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-save + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Backup + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-save + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Backup All + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + Import + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + gtk-delete + True + GTK_RELIEF_NORMAL + + + + + 0 + False + True + + + + + False + True + + + + + + True + Your Certificates + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 6 + True + False + 6 + + + + True + You have certificates on file that identify these people: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 0 + + + + True + True + True + View + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-properties + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Edit + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + import + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + gtk-delete + True + GTK_RELIEF_NORMAL + + + + + 0 + False + True + + + + + False + True + + + + + + True + Contact Certificates + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 6 + True + False + 6 + + + + True + You have certificates on file that identify these certificate authorities: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 0 + + + + True + True + True + View + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-properties + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Edit + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + Import + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + gtk-delete + True + GTK_RELIEF_NORMAL + + + + + 0 + False + True + + + + + False + True + + + + + + True + Authorities + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + + diff --git a/smime/lib/.cvsignore b/smime/lib/.cvsignore new file mode 100644 index 0000000000..74b73492ca --- /dev/null +++ b/smime/lib/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +*.la diff --git a/smime/lib/Makefile.am b/smime/lib/Makefile.am new file mode 100644 index 0000000000..4af28f2994 --- /dev/null +++ b/smime/lib/Makefile.am @@ -0,0 +1,24 @@ +INCLUDES = \ + -DG_LOG_DOMAIN=\"evolution-smime\" \ + -I$(top_srcdir) \ + -I$(top_srcdir)/shell \ + -I$(top_builddir) \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ + -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ + -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ + -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ + -DPREFIX=\""$(prefix)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED \ + -DLIBGNOME_DISABLE_DEPRECATED \ + -DLIBGNOMEUI_DISABLE_DEPRECATED \ + $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ + $(CAMEL_CFLAGS) + +noinst_LTLIBRARIES = libessmime.la + +libessmime_la_SOURCES = \ + e-cert.c \ + e-cert.h diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c new file mode 100644 index 0000000000..5636730401 --- /dev/null +++ b/smime/lib/e-cert.c @@ -0,0 +1,148 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-cert.c + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Chris Toshok (toshok@ximian.com) + */ + +#include "e-cert.h" + +struct _ECertPrivate { + CERTCertificate *cert; + char *org_name; + char *cn; +}; + +#define PARENT_TYPE G_TYPE_OBJECT +static GObjectClass *parent_class; + +static void +e_cert_dispose (GObject *object) +{ + ECert *ec = E_CERT (object); + + if (!ec->priv) + return; + + if (ec->priv->org_name) + PORT_Free (ec->priv->org_name); + if (ec->priv->cn) + PORT_Free (ec->priv->org_name); + + g_free (ec->priv); + ec->priv = NULL; + + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +e_cert_class_init (ECertClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS(klass); + + parent_class = g_type_class_ref (PARENT_TYPE); + + object_class->dispose = e_cert_dispose; +} + +static void +e_cert_init (ECert *ec) +{ + ec->priv = g_new0 (ECertPrivate, 1); +} + +GType +e_cert_get_type (void) +{ + static GType cert_type = 0; + + if (!cert_type) { + static const GTypeInfo cert_info = { + sizeof (ECertClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) e_cert_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (ECert), + 0, /* n_preallocs */ + (GInstanceInitFunc) e_cert_init, + }; + + cert_type = g_type_register_static (PARENT_TYPE, "ECert", &cert_info, 0); + } + + return cert_type; +} + + + +static void +e_cert_populate (ECert *cert) +{ + CERTCertificate *c = cert->priv->cert; + cert->priv->org_name = CERT_GetOrgName (&c->subject); + cert->priv->cn = CERT_GetCommonName (&c->subject); +} + +ECert* +e_cert_new (CERTCertificate *cert) +{ + ECert *ecert = E_CERT (g_object_new (E_TYPE_CERT, NULL)); + + ecert->priv->cert = cert; + + e_cert_populate (ecert); + + return ecert; +} + + + + +const char* +e_cert_get_nickname (ECert *cert) +{ + return cert->priv->cert->nickname; +} + +const char* +e_cert_get_email (ECert *cert) +{ +} + +const char* +e_cert_get_org (ECert *cert) +{ + return cert->priv->org_name; +} + +const char* +e_cert_get_cn (ECert *cert) +{ + return cert->priv->cn; +} + +gboolean +e_cert_is_ca_cert (ECert *cert) +{ + return CERT_IsCACert (cert->priv->cert, NULL); +} diff --git a/smime/lib/e-cert.h b/smime/lib/e-cert.h new file mode 100644 index 0000000000..86517dad79 --- /dev/null +++ b/smime/lib/e-cert.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok + * + * 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 _E_CERT_H_ +#define _E_CERT_H_ + +#include +#include + +#define E_TYPE_CERT (e_cert_get_type ()) +#define E_CERT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CERT, ECert)) +#define E_CERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CERT, ECertClass)) +#define E_IS_CERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CERT)) +#define E_IS_CERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CERT)) +#define E_CERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_CERT, ECertClass)) + +typedef struct _ECert ECert; +typedef struct _ECertClass ECertClass; +typedef struct _ECertPrivate ECertPrivate; + +struct _ECert { + GObject parent; + + ECertPrivate *priv; +}; + +struct _ECertClass { + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_ecert_reserved0) (void); + void (*_ecert_reserved1) (void); + void (*_ecert_reserved2) (void); + void (*_ecert_reserved3) (void); + void (*_ecert_reserved4) (void); +}; + +GType e_cert_get_type (void); + +ECert* e_cert_new (CERTCertificate *cert); + +const char* e_cert_get_nickname (ECert *cert); +const char* e_cert_get_email (ECert *cert); +const char* e_cert_get_org (ECert *cert); +const char* e_cert_get_cn (ECert *cert); + +gboolean e_cert_is_ca_cert (ECert *cert); +#endif /* _E_CERT_H_ */ -- cgit