aboutsummaryrefslogtreecommitdiffstats
path: root/smime/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-01-06 04:49:44 +0800
committerChris Toshok <toshok@src.gnome.org>2004-01-06 04:49:44 +0800
commit135e1d6968e7205611aea943496f1fd3f5ba04fc (patch)
treeff25a0c6d048796fad7ea3ca9044169219e0e1d3 /smime/gui
parentb43eee1113b480b13bcfb51bd5188133ed8f0c1b (diff)
downloadgsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar.gz
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar.bz2
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar.lz
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar.xz
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.tar.zst
gsoc2013-evolution-135e1d6968e7205611aea943496f1fd3f5ba04fc.zip
new function, implement the password dialog for PK11 slot authentication.
2004-01-05 Chris Toshok <toshok@ximian.com> * gui/component.c (smime_pk11_passwd): new function, implement the password dialog for PK11 slot authentication. (smime_component_init): new function, initialize any gui related signals that the backend exposes. * gui/certificate-manager.c (import_your): use e_cert_db_import_pkcs12_file. (delete_your): new function, implement. (view_your): same. (backup_your): new function, stub out. (backup_all_your): same. (create_yourcerts_treemodel): new function. (initialize_yourcerts_ui): do all the sorting foo, and hook up all the signals. (ainitialize_contactcerts_ui): same. (initialize_authoritycerts_ui): same. (view_contact): treemodel -> streemodel. (view_ca): same. (delete_contact): same, and convert from the sort iter to the child iter before we remove. (delete_ca): same. (import_contact): call gtk_tree_view_expand_all. (import_ca): same. (add_user_cert): append to the child model, not the sort model. (add_contact_cert): same. (add_ca_cert): same. (unload_certs): implement the E_CERT_USER case, and fix the USER/CA stuff to use the sorted treemodels. (load_certs): remove spew. (populate_ui): expand all the tree views. * lib/.cvsignore: ignore the generated marshalling files. * lib/Makefile.am: add the marshalling foo. * lib/smime-marshal.list (BOOL): new file. * lib/e-cert-db.c (pk11_password): new function, emit the pk11_passwd signal. (initialize_nss): new function, split out all the nss init code here, and add all the PKCS12 cipers. (install_loadable_roots): new function, split this code out from the class_init. (e_cert_db_class_init): call initialize_nss() and install_loadable_roots(). also register our pk11_passwd signal. (e_cert_db_import_pkcs12_file): implement. (e_cert_db_login_to_slot): new function, implement. * lib/e-cert-db.h (struct _ECertDBClass): add pk11_passwd signal, and add prototype for e_cert_db_login_to_slot. * lib/e-pkcs12.c (input_to_decoder): remove spew. (prompt_for_password): fix this. (import_from_file_helper): fix fix fix, and remove spew. (write_export_file): nuke, we don't need this. svn path=/trunk/; revision=24058
Diffstat (limited to 'smime/gui')
-rw-r--r--smime/gui/Makefile.am5
-rw-r--r--smime/gui/certificate-manager.c374
-rw-r--r--smime/gui/component.c61
-rw-r--r--smime/gui/component.h28
4 files changed, 333 insertions, 135 deletions
diff --git a/smime/gui/Makefile.am b/smime/gui/Makefile.am
index a15fdade86..614c2d5525 100644
--- a/smime/gui/Makefile.am
+++ b/smime/gui/Makefile.am
@@ -22,7 +22,10 @@ libevolution_smime_la_SOURCES = \
certificate-viewer.c \
certificate-viewer.h \
e-cert-selector.c \
- e-cert-selector.h
+ e-cert-selector.h \
+ component.c \
+ component.h
+
libevolution_smime_la_LIBADD = \
$(top_builddir)/smime/lib/libessmime.la \
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index d2ae5e4fea..3d2c1a31bf 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -33,7 +33,6 @@
#include "e-cert.h"
#include "e-cert-db.h"
-#include "e-pkcs12.h"
#include "nss.h"
#include <cms.h>
@@ -47,6 +46,7 @@ typedef struct {
GtkWidget *yourcerts_treeview;
GtkTreeStore *yourcerts_treemodel;
+ GtkTreeModel *yourcerts_streemodel;
GHashTable *yourcerts_root_hash;
GtkWidget *view_your_button;
GtkWidget *backup_your_button;
@@ -55,7 +55,7 @@ typedef struct {
GtkWidget *delete_your_button;
GtkWidget *contactcerts_treeview;
- GtkTreeStore *contactcerts_treemodel;
+ GtkTreeModel *contactcerts_streemodel;
GHashTable *contactcerts_root_hash;
GtkWidget *view_contact_button;
GtkWidget *edit_contact_button;
@@ -63,7 +63,7 @@ typedef struct {
GtkWidget *delete_contact_button;
GtkWidget *authoritycerts_treeview;
- GtkTreeStore *authoritycerts_treemodel;
+ GtkTreeModel *authoritycerts_streemodel;
GHashTable *authoritycerts_root_hash;
GtkWidget *view_ca_button;
GtkWidget *edit_ca_button;
@@ -123,13 +123,13 @@ import_your (GtkWidget *widget, CertificateManagerData *cfm)
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 */)) {
+ if (e_cert_db_import_pkcs12_file (e_cert_db_peek (),
+ 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_tree_view_expand_all (GTK_TREE_VIEW (cfm->yourcerts_treeview));
}
}
@@ -137,6 +137,72 @@ import_your (GtkWidget *widget, CertificateManagerData *cfm)
}
static void
+delete_your (GtkWidget *widget, CertificateManagerData *cfm)
+{
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->yourcerts_treeview)),
+ NULL,
+ &iter)) {
+ ECert *cert;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->yourcerts_streemodel),
+ &iter,
+ 4, &cert,
+ -1);
+
+ if (cert) {
+ GtkTreeIter child_iter;
+ printf ("DELETE\n");
+ e_cert_db_delete_cert (e_cert_db_peek (), cert);
+ gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (cfm->yourcerts_streemodel),
+ &child_iter,
+ &iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->yourcerts_streemodel))),
+ &child_iter);
+
+ /* we need two unrefs here, one to unref the
+ gtk_tree_model_get above, and one to unref
+ the initial ref when we created the cert
+ and added it to the tree */
+ g_object_unref (cert);
+ g_object_unref (cert);
+ }
+ }
+
+}
+
+static void
+view_your (GtkWidget *widget, CertificateManagerData *cfm)
+{
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->yourcerts_treeview)),
+ NULL,
+ &iter)) {
+ ECert *cert;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->yourcerts_streemodel),
+ &iter,
+ 4, &cert,
+ -1);
+
+ if (cert)
+ certificate_viewer_show (cert);
+ }
+}
+
+static void
+backup_your (GtkWidget *widget, CertificateManagerData *cfm)
+{
+}
+
+static void
+backup_all_your (GtkWidget *widget, CertificateManagerData *cfm)
+{
+}
+
+static void
yourcerts_selection_changed (GtkTreeSelection *selection, CertificateManagerData *cfm)
{
handle_selection_changed (selection,
@@ -146,70 +212,77 @@ yourcerts_selection_changed (GtkTreeSelection *selection, CertificateManagerData
cfm->delete_your_button);
}
+static GtkTreeModel*
+create_yourcerts_treemodel (void)
+{
+ return GTK_TREE_MODEL (gtk_tree_store_new (5,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT));
+}
+
static void
initialize_yourcerts_ui (CertificateManagerData *cfm)
{
GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ column = 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 (_("Certificate Name"),
- cell,
- "text", 0,
- NULL));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 0);
+ column = 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 (_("Purposes"),
- cell,
- "text", 1,
- NULL));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 1);
+ column = 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 (_("Serial Number"),
- cell,
- "text", 2,
- NULL));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 2);
+ column = gtk_tree_view_column_new_with_attributes (_("Expires"),
+ cell,
+ "text", 3,
+ 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 (5,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_OBJECT);
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 3);
- 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);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cfm->yourcerts_streemodel),
+ 0,
+ GTK_SORT_ASCENDING);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cfm->yourcerts_treeview));
g_signal_connect (selection, "changed", G_CALLBACK (yourcerts_selection_changed), cfm);
- if (cfm->import_your_button) {
+ if (cfm->import_your_button)
g_signal_connect (cfm->import_your_button, "clicked", G_CALLBACK (import_your), cfm);
- }
- if (cfm->delete_your_button) {
- /* g_signal_connect */
- }
+ if (cfm->delete_your_button)
+ g_signal_connect (cfm->delete_your_button, "clicked", G_CALLBACK (delete_your), cfm);
- if (cfm->view_your_button) {
- /* g_signal_connect */
- }
+ if (cfm->view_your_button)
+ g_signal_connect (cfm->view_your_button, "clicked", G_CALLBACK (view_your), cfm);
- if (cfm->backup_your_button) {
- /* g_signal_connect */
- }
+ if (cfm->backup_your_button)
+ g_signal_connect (cfm->backup_your_button, "clicked", G_CALLBACK (backup_your), cfm);
- if (cfm->backup_all_your_button) {
- /* g_signal_connect */
- }
+ if (cfm->backup_all_your_button)
+ g_signal_connect (cfm->backup_all_your_button, "clicked", G_CALLBACK (backup_all_your), cfm);
}
static void
@@ -222,7 +295,7 @@ view_contact (GtkWidget *widget, CertificateManagerData *cfm)
&iter)) {
ECert *cert;
- gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_treemodel),
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_streemodel),
&iter,
3, &cert,
-1);
@@ -249,6 +322,7 @@ import_contact (GtkWidget *widget, CertificateManagerData *cfm)
so we blow away the contact cert display and regenerate it. */
unload_certs (cfm, E_CERT_CONTACT);
load_certs (cfm, E_CERT_CONTACT, add_contact_cert);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (cfm->contactcerts_treeview));
}
}
@@ -265,16 +339,20 @@ delete_contact (GtkWidget *widget, CertificateManagerData *cfm)
&iter)) {
ECert *cert;
- gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_treemodel),
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_streemodel),
&iter,
3, &cert,
-1);
if (cert) {
+ GtkTreeIter child_iter;
printf ("DELETE\n");
e_cert_db_delete_cert (e_cert_db_peek (), cert);
- gtk_tree_store_remove (cfm->contactcerts_treemodel,
- &iter);
+ gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (cfm->contactcerts_streemodel),
+ &child_iter,
+ &iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->contactcerts_streemodel))),
+ &child_iter);
/* we need two unrefs here, one to unref the
gtk_tree_model_get above, and one to unref
@@ -297,14 +375,14 @@ contactcerts_selection_changed (GtkTreeSelection *selection, CertificateManagerD
cfm->delete_contact_button);
}
-static GtkTreeStore*
+static GtkTreeModel*
create_contactcerts_treemodel (void)
{
- return gtk_tree_store_new (4,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_OBJECT);
+ return GTK_TREE_MODEL (gtk_tree_store_new (4,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT));
}
static void
@@ -312,27 +390,31 @@ initialize_contactcerts_ui (CertificateManagerData *cfm)
{
GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ column = 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 (_("Certificate Name"),
- cell,
- "text", 0,
- NULL));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 0);
+ column = 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 (_("E-Mail Address"),
- cell,
- "text", 1,
- NULL));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 1);
+ column = gtk_tree_view_column_new_with_attributes (_("Purposes"),
+ cell,
+ "text", 2,
+ NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->contactcerts_treeview),
- gtk_tree_view_column_new_with_attributes (_("Purposes"),
- cell,
- "text", 2,
- NULL));
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->contactcerts_treeview),
- GTK_TREE_MODEL (cfm->contactcerts_treemodel));
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 2);
cfm->contactcerts_root_hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -350,25 +432,6 @@ initialize_contactcerts_ui (CertificateManagerData *cfm)
}
-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
view_ca (GtkWidget *widget, CertificateManagerData *cfm)
{
@@ -379,7 +442,7 @@ view_ca (GtkWidget *widget, CertificateManagerData *cfm)
&iter)) {
ECert *cert;
- gtk_tree_model_get (GTK_TREE_MODEL (cfm->authoritycerts_treemodel),
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->authoritycerts_streemodel),
&iter,
1, &cert,
-1);
@@ -406,6 +469,7 @@ import_ca (GtkWidget *widget, CertificateManagerData *cfm)
so we blow away the CA cert display and regenerate it. */
unload_certs (cfm, E_CERT_CA);
load_certs (cfm, E_CERT_CA, add_ca_cert);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (cfm->authoritycerts_treeview));
}
}
@@ -422,16 +486,20 @@ delete_ca (GtkWidget *widget, CertificateManagerData *cfm)
&iter)) {
ECert *cert;
- gtk_tree_model_get (GTK_TREE_MODEL (cfm->authoritycerts_treemodel),
+ gtk_tree_model_get (GTK_TREE_MODEL (cfm->authoritycerts_streemodel),
&iter,
1, &cert,
-1);
if (cert) {
+ GtkTreeIter child_iter;
printf ("DELETE\n");
e_cert_db_delete_cert (e_cert_db_peek (), cert);
- gtk_tree_store_remove (cfm->authoritycerts_treemodel,
- &iter);
+ gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (cfm->authoritycerts_streemodel),
+ &child_iter,
+ &iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->authoritycerts_streemodel))),
+ &child_iter);
/* we need two unrefs here, one to unref the
gtk_tree_model_get above, and one to unref
@@ -454,12 +522,12 @@ authoritycerts_selection_changed (GtkTreeSelection *selection, CertificateManage
cfm->delete_ca_button);
}
-static GtkTreeStore*
+static GtkTreeModel*
create_authoritycerts_treemodel (void)
{
- return gtk_tree_store_new (2,
- G_TYPE_STRING,
- G_TYPE_OBJECT);
+ return GTK_TREE_MODEL (gtk_tree_store_new (2,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT));
}
@@ -468,20 +536,15 @@ initialize_authoritycerts_ui (CertificateManagerData *cfm)
{
GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ column = gtk_tree_view_column_new_with_attributes (_("Certificate Name"),
+ cell,
+ "text", 0,
+ NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (cfm->authoritycerts_treeview),
- gtk_tree_view_column_new_with_attributes (_("Certificate Name"),
- cell,
- "text", 0,
- NULL));
-
- 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);
+ column);
+ gtk_tree_view_column_set_sort_column_id (column, 0);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cfm->authoritycerts_treeview));
g_signal_connect (selection, "changed", G_CALLBACK (authoritycerts_selection_changed), cfm);
@@ -502,14 +565,15 @@ add_user_cert (CertificateManagerData *cfm, ECert *cert)
GtkTreeIter iter;
GtkTreeIter *parent_iter = NULL;
const char *organization = e_cert_get_org (cert);
+ GtkTreeModel *model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->yourcerts_streemodel));
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_append (GTK_TREE_STORE (model), &iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, organization, -1);
/* now copy it off into parent_iter and insert it into
@@ -519,15 +583,15 @@ add_user_cert (CertificateManagerData *cfm, ECert *cert)
}
}
- gtk_tree_store_append (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter, parent_iter);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent_iter);
if (e_cert_get_cn (cert))
- gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_cn (cert),
4, cert,
-1);
else
- gtk_tree_store_set (GTK_TREE_STORE (cfm->yourcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_nickname (cert),
4, cert,
-1);
@@ -539,14 +603,15 @@ add_contact_cert (CertificateManagerData *cfm, ECert *cert)
GtkTreeIter iter;
GtkTreeIter *parent_iter = NULL;
const char *organization = e_cert_get_org (cert);
+ GtkTreeModel *model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->contactcerts_streemodel));
if (organization) {
parent_iter = g_hash_table_lookup (cfm->contactcerts_root_hash, organization);
if (!parent_iter) {
/* create a new toplevel node */
- gtk_tree_store_append (GTK_TREE_STORE (cfm->contactcerts_treemodel), &iter, NULL);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (cfm->contactcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, organization, -1);
/* now copy it off into parent_iter and insert it into
@@ -556,16 +621,16 @@ add_contact_cert (CertificateManagerData *cfm, ECert *cert)
}
}
- gtk_tree_store_append (GTK_TREE_STORE (cfm->contactcerts_treemodel), &iter, parent_iter);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent_iter);
if (e_cert_get_cn (cert))
- gtk_tree_store_set (GTK_TREE_STORE (cfm->contactcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_cn (cert),
1, e_cert_get_email (cert),
3, cert,
-1);
else
- gtk_tree_store_set (GTK_TREE_STORE (cfm->contactcerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_nickname (cert),
1, e_cert_get_email (cert),
3, cert,
@@ -578,14 +643,16 @@ add_ca_cert (CertificateManagerData *cfm, ECert *cert)
GtkTreeIter iter;
GtkTreeIter *parent_iter = NULL;
const char *organization = e_cert_get_org (cert);
+ GtkTreeModel *model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (cfm->authoritycerts_streemodel));
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_append (GTK_TREE_STORE (model),
+ &iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, organization, -1);
/* now copy it off into parent_iter and insert it into
@@ -596,15 +663,15 @@ add_ca_cert (CertificateManagerData *cfm, ECert *cert)
}
- gtk_tree_store_append (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter, parent_iter);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent_iter);
if (e_cert_get_cn (cert))
- gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_cn (cert),
1, cert,
-1);
else
- gtk_tree_store_set (GTK_TREE_STORE (cfm->authoritycerts_treemodel), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
0, e_cert_get_nickname (cert),
1, cert,
-1);
@@ -626,13 +693,42 @@ static void
unload_certs (CertificateManagerData *cfm,
ECertType type)
{
+ GtkTreeModel *treemodel;
+
switch (type) {
case E_CERT_USER:
+ treemodel = create_yourcerts_treemodel ();
+
+ cfm->yourcerts_streemodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (treemodel));
+
+ g_object_unref (treemodel);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->yourcerts_treeview),
+ cfm->yourcerts_streemodel);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cfm->yourcerts_streemodel),
+ 0,
+ GTK_SORT_ASCENDING);
+
+ if (cfm->yourcerts_root_hash)
+ g_hash_table_destroy (cfm->yourcerts_root_hash);
+
+ cfm->yourcerts_root_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ destroy_key, destroy_value);
break;
case E_CERT_CONTACT:
- cfm->contactcerts_treemodel = create_contactcerts_treemodel ();
+ treemodel = create_contactcerts_treemodel ();
+
+ cfm->contactcerts_streemodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (treemodel));
+
+ g_object_unref (treemodel);
+
gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->contactcerts_treeview),
- GTK_TREE_MODEL (cfm->contactcerts_treemodel));
+ cfm->contactcerts_streemodel);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cfm->contactcerts_streemodel),
+ 0,
+ GTK_SORT_ASCENDING);
if (cfm->contactcerts_root_hash)
g_hash_table_destroy (cfm->contactcerts_root_hash);
@@ -643,9 +739,18 @@ unload_certs (CertificateManagerData *cfm,
case E_CERT_SITE:
break;
case E_CERT_CA:
- cfm->authoritycerts_treemodel = create_authoritycerts_treemodel ();
+ treemodel = create_authoritycerts_treemodel ();
+
+ cfm->authoritycerts_streemodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (treemodel));
+
+ g_object_unref (treemodel);
+
gtk_tree_view_set_model (GTK_TREE_VIEW (cfm->authoritycerts_treeview),
- GTK_TREE_MODEL (cfm->authoritycerts_treemodel));
+ cfm->authoritycerts_streemodel);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cfm->authoritycerts_streemodel),
+ 0,
+ GTK_SORT_ASCENDING);
if (cfm->authoritycerts_root_hash)
g_hash_table_destroy (cfm->authoritycerts_root_hash);
@@ -671,18 +776,14 @@ load_certs (CertificateManagerData *cfm,
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 (e_cert_get_cert_type(cert) == type) {
- printf ("cert (nickname = '%s') matches\n", e_cert_get_nickname (cert));
add_cert (cfm, cert);
}
}
-
}
static void
@@ -696,6 +797,11 @@ populate_ui (CertificateManagerData *cfm)
unload_certs (cfm, E_CERT_CA);
load_certs (cfm, E_CERT_CA, add_ca_cert);
+
+ /* expand all three trees */
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (cfm->yourcerts_treeview));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (cfm->contactcerts_treeview));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (cfm->authoritycerts_treeview));
}
EvolutionConfigControl*
diff --git a/smime/gui/component.c b/smime/gui/component.c
new file mode 100644
index 0000000000..7c9658b9d1
--- /dev/null
+++ b/smime/gui/component.c
@@ -0,0 +1,61 @@
+/* -*- 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.
+ *
+ */
+
+#include <libgnome/gnome-i18n.h>
+#include "e-cert-db.h"
+#include "e-util/e-passwords.h"
+#include "pk11func.h"
+
+static gboolean
+smime_pk11_passwd (ECertDB *db, PK11SlotInfo* slot, gboolean retry, char **passwd, gpointer arg)
+{
+ char *prompt;
+ char *slot_name = g_strdup (PK11_GetSlotName (slot));
+
+ g_strchomp (slot_name);
+
+ prompt = g_strdup_printf (_("Enter the password for `%s'"), slot_name);
+ g_free (slot_name);
+
+ *passwd = e_passwords_ask_password (_("Enter password"), NULL, NULL,
+ prompt, TRUE,
+ E_PASSWORDS_DO_NOT_REMEMBER, NULL,
+ NULL);
+
+ g_free (prompt);
+
+ /* this should return FALSE if they canceled. */
+ return TRUE;
+}
+
+void
+smime_component_init (void)
+{
+ static gboolean init_done = FALSE;
+ if (init_done)
+ return;
+
+ init_done = TRUE;
+ g_signal_connect (e_cert_db_peek (),
+ "pk11_passwd",
+ G_CALLBACK (smime_pk11_passwd), NULL);
+}
diff --git a/smime/gui/component.h b/smime/gui/component.h
new file mode 100644
index 0000000000..dbcd97bd2a
--- /dev/null
+++ b/smime/gui/component.h
@@ -0,0 +1,28 @@
+/* -*- 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 _SMIME_COMPONENT_H_
+#define _SMIME_COMPONENT_H_
+
+void smime_component_init (void);
+
+#endif /* _SMIME_COMPONENT_H_ */