diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-12-01 10:53:20 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-02-20 23:04:25 +0800 |
commit | 23f5773903d64a554d977ae7d0ebbaca73528f1f (patch) | |
tree | 104e1a59da8bf96b004bce204b79f47bbe0a6d13 /smime | |
parent | 49bc4c2d765ee1780c23fdc9f42152850dabb220 (diff) | |
download | gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.gz gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.zst gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.zip |
Coding style and whitespace cleanup.
Diffstat (limited to 'smime')
-rw-r--r-- | smime/gui/ca-trust-dialog.c | 4 | ||||
-rw-r--r-- | smime/gui/cert-trust-dialog.c | 4 | ||||
-rw-r--r-- | smime/gui/certificate-manager.c | 39 | ||||
-rw-r--r-- | smime/gui/certificate-manager.h | 2 | ||||
-rw-r--r-- | smime/gui/certificate-viewer.c | 8 | ||||
-rw-r--r-- | smime/gui/component.c | 18 | ||||
-rw-r--r-- | smime/gui/e-cert-selector.c | 64 | ||||
-rw-r--r-- | smime/gui/e-cert-selector.h | 41 | ||||
-rw-r--r-- | smime/lib/e-asn1-object.c | 63 | ||||
-rw-r--r-- | smime/lib/e-cert-db.c | 57 | ||||
-rw-r--r-- | smime/lib/e-cert-trust.c | 28 | ||||
-rw-r--r-- | smime/lib/e-cert.c | 156 | ||||
-rw-r--r-- | smime/lib/e-pkcs12.c | 62 |
13 files changed, 227 insertions, 319 deletions
diff --git a/smime/gui/ca-trust-dialog.c b/smime/gui/ca-trust-dialog.c index df2a1f825a..5827d9821a 100644 --- a/smime/gui/ca-trust-dialog.c +++ b/smime/gui/ca-trust-dialog.c @@ -108,7 +108,9 @@ ca_trust_dialog_show (ECert *cert, gtk_label_set_text ((GtkLabel *) w, txt); g_free (txt); - g_signal_connect (ctd_data->dialog, "response", G_CALLBACK (catd_response), ctd_data); + g_signal_connect ( + ctd_data->dialog, "response", + G_CALLBACK (catd_response), ctd_data); g_object_set_data_full (G_OBJECT (ctd_data->dialog), "CATrustDialogData", ctd_data, free_data); diff --git a/smime/gui/cert-trust-dialog.c b/smime/gui/cert-trust-dialog.c index d4d6648b32..f18a28f446 100644 --- a/smime/gui/cert-trust-dialog.c +++ b/smime/gui/cert-trust-dialog.c @@ -130,7 +130,9 @@ cert_trust_dialog_show (ECert *cert) ctd_data->label = e_builder_get_widget(ctd_data->builder, "trust-label"); - g_signal_connect (ctd_data->dialog, "response", G_CALLBACK(ctd_response), ctd_data); + g_signal_connect ( + ctd_data->dialog, "response", + G_CALLBACK (ctd_response), ctd_data); g_object_set_data_full (G_OBJECT (ctd_data->dialog), "CertTrustDialogData", ctd_data, free_data); diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c index be30929cda..ac42e1d5ad 100644 --- a/smime/gui/certificate-manager.c +++ b/smime/gui/certificate-manager.c @@ -51,6 +51,10 @@ #include "e-util/e-util-private.h" #include "widgets/misc/e-preferences-window.h" +#define E_CERT_MANAGER_CONFIG_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CERT_MANAGER_CONFIG, ECertManagerConfigPrivate)) + G_DEFINE_TYPE (ECertManagerConfig, e_cert_manager_config, GTK_TYPE_BOX); enum { @@ -406,7 +410,8 @@ treeview_add_column (CertPage *cp, gtk_tree_view_append_column (cp->treeview, column); header = gtk_tree_view_column_get_button (column); - g_signal_connect (header, "button-release-event", + g_signal_connect ( + header, "button-release-event", G_CALLBACK (treeview_header_clicked), cp->popup_menu); /* The first column should not be concealable so there's no point in displaying @@ -419,9 +424,11 @@ treeview_add_column (CertPage *cp, gettext (cp->columns[column_index].column_title)); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), cp->columns[column_index].visible); gtk_menu_attach (cp->popup_menu, item, 0, 1, column_index - 1, column_index); - g_signal_connect (item, "toggled", + g_signal_connect ( + item, "toggled", G_CALLBACK (header_popup_item_toggled), column); - g_signal_connect (column, "notify::visible", + g_signal_connect ( + column, "notify::visible", G_CALLBACK (treeview_column_visibility_changed), item); } @@ -504,8 +511,9 @@ view_cert (GtkWidget *button, if (cert) { GtkWidget *dialog = certificate_viewer_show (cert); - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); + g_signal_connect ( + dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (dialog); } } @@ -816,23 +824,28 @@ initialize_ui (CertPage *cp) treeview_add_column (cp, i); selection = gtk_tree_view_get_selection (cp->treeview); - g_signal_connect (selection, "changed", + g_signal_connect ( + selection, "changed", G_CALLBACK (treeview_selection_changed), cp); if (cp->import_button) - g_signal_connect (cp->import_button, "clicked", + g_signal_connect ( + cp->import_button, "clicked", G_CALLBACK (import_cert), cp); if (cp->edit_button) - g_signal_connect (cp->edit_button, "clicked", + g_signal_connect ( + cp->edit_button, "clicked", G_CALLBACK (edit_cert), cp); if (cp->delete_button) - g_signal_connect (cp->delete_button, "clicked", + g_signal_connect ( + cp->delete_button, "clicked", G_CALLBACK (delete_cert), cp); if (cp->view_button) - g_signal_connect (cp->view_button, "clicked", + g_signal_connect ( + cp->view_button, "clicked", G_CALLBACK (view_cert), cp); } @@ -930,7 +943,8 @@ cert_manager_config_set_property (GObject *object, ecmc->priv->pref_window = g_value_get_object (value); /* When the preferences window is "closed" (= hidden), save * state of all treeviews. */ - g_signal_connect_swapped (ecmc->priv->pref_window, "hide", + g_signal_connect_swapped ( + ecmc->priv->pref_window, "hide", G_CALLBACK (cert_manager_config_window_hide), ecmc); return; } @@ -967,8 +981,7 @@ e_cert_manager_config_init (ECertManagerConfig *ecmc) GtkWidget *parent, *widget; CertPage *cp; - priv = G_TYPE_INSTANCE_GET_PRIVATE ( - ecmc, E_TYPE_CERT_MANAGER_CONFIG, ECertManagerConfigPrivate); + priv = E_CERT_MANAGER_CONFIG_GET_PRIVATE (ecmc); ecmc->priv = priv; /* We need to peek the db here to make sure it (and NSS) are fully initialized. */ diff --git a/smime/gui/certificate-manager.h b/smime/gui/certificate-manager.h index 13a60ce161..2eba92cd01 100644 --- a/smime/gui/certificate-manager.h +++ b/smime/gui/certificate-manager.h @@ -47,8 +47,8 @@ ((obj), E_TYPE_CERT_MANAGER_CONFIG, ECertManagerConfigClass)) typedef struct _ECertManagerConfig ECertManagerConfig; -typedef struct _ECertManagerConfigPrivate ECertManagerConfigPrivate; typedef struct _ECertManagerConfigClass ECertManagerConfigClass; +typedef struct _ECertManagerConfigPrivate ECertManagerConfigPrivate; struct _ECertManagerConfig { GtkBox parent; diff --git a/smime/gui/certificate-viewer.c b/smime/gui/certificate-viewer.c index 89f7d1fd8d..6691d1fbec 100644 --- a/smime/gui/certificate-viewer.c +++ b/smime/gui/certificate-viewer.c @@ -274,7 +274,9 @@ fill_in_details (CertificateViewerData *cvm_data, "text", 0, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cvm_data->hierarchy_tree)); - g_signal_connect (selection, "changed", G_CALLBACK (hierarchy_selection_changed), cvm_data); + g_signal_connect ( + selection, "changed", + G_CALLBACK (hierarchy_selection_changed), cvm_data); /* hook up all the fields tree foo */ cvm_data->fields_tree = e_builder_get_widget (cvm_data->builder, "cert-fields-treeview"); @@ -284,7 +286,9 @@ fill_in_details (CertificateViewerData *cvm_data, "text", 0, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (cvm_data->fields_tree)); - g_signal_connect (selection, "changed", G_CALLBACK (fields_selection_changed), cvm_data); + g_signal_connect ( + selection, "changed", + G_CALLBACK (fields_selection_changed), cvm_data); /* hook up all the field display foo */ cvm_data->field_text = e_builder_get_widget (cvm_data->builder, "cert-field-value-textview"); diff --git a/smime/gui/component.c b/smime/gui/component.c index fcbb9faf9f..e902f43fd0 100644 --- a/smime/gui/component.c +++ b/smime/gui/component.c @@ -117,15 +117,15 @@ smime_component_init (void) return; init_done = TRUE; - g_signal_connect (e_cert_db_peek (), - "pk11_passwd", - G_CALLBACK (smime_pk11_passwd), NULL); + g_signal_connect ( + e_cert_db_peek (), "pk11_passwd", + G_CALLBACK (smime_pk11_passwd), NULL); - g_signal_connect (e_cert_db_peek (), - "pk11_change_passwd", - G_CALLBACK (smime_pk11_change_passwd), NULL); + g_signal_connect ( + e_cert_db_peek (), "pk11_change_passwd", + G_CALLBACK (smime_pk11_change_passwd), NULL); - g_signal_connect (e_cert_db_peek (), - "confirm_ca_cert_import", - G_CALLBACK (smime_confirm_ca_cert_import), NULL); + g_signal_connect ( + e_cert_db_peek (), "confirm_ca_cert_import", + G_CALLBACK (smime_confirm_ca_cert_import), NULL); } diff --git a/smime/gui/e-cert-selector.c b/smime/gui/e-cert-selector.c index 24cc9b374a..a5135d2c7d 100644 --- a/smime/gui/e-cert-selector.c +++ b/smime/gui/e-cert-selector.c @@ -37,6 +37,10 @@ #include "e-util/e-util.h" #include "e-util/e-util-private.h" +#define E_CERT_SELECTOR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CERT_SELECTOR, ECertSelectorPrivate)) + struct _ECertSelectorPrivate { CERTCertList *certlist; @@ -209,7 +213,9 @@ e_cert_selector_new (gint type, gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox), active); - g_signal_connect (p->combobox, "changed", G_CALLBACK(ecs_cert_changed), ecs); + g_signal_connect ( + p->combobox, "changed", + G_CALLBACK (ecs_cert_changed), ecs); g_object_unref (builder); @@ -221,38 +227,50 @@ e_cert_selector_new (gint type, static void e_cert_selector_init (ECertSelector *ecs) { - gtk_dialog_add_buttons ((GtkDialog *) ecs, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_dialog_add_buttons ( + GTK_DIALOG (ecs), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - ecs->priv = g_malloc0 (sizeof (*ecs->priv)); + ecs->priv = E_CERT_SELECTOR_GET_PRIVATE (ecs); } static void -e_cert_selector_finalize (GObject *o) +e_cert_selector_finalize (GObject *object) { - ECertSelector *ecs = (ECertSelector *) o; + ECertSelectorPrivate *priv; - if (ecs->priv->certlist) - CERT_DestroyCertList (ecs->priv->certlist); + priv = E_CERT_SELECTOR_GET_PRIVATE (object); - g_free (ecs->priv); + if (priv->certlist) + CERT_DestroyCertList (priv->certlist); - ((GObjectClass *) e_cert_selector_parent_class)->finalize (o); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_cert_selector_parent_class)->finalize (object); } static void -e_cert_selector_class_init (ECertSelectorClass *klass) +e_cert_selector_class_init (ECertSelectorClass *class) { - ((GObjectClass *) klass)->finalize = e_cert_selector_finalize; - ((GtkDialogClass *) klass)->response = e_cert_selector_response; - - ecs_signals[ECS_SELECTED] = - g_signal_new("selected", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECertSelectorClass, selected), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); + GObjectClass *object_class; + GtkDialogClass *dialog_class; + + g_type_class_add_private (class, sizeof (ECertSelectorPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->finalize = e_cert_selector_finalize; + + dialog_class = GTK_DIALOG_CLASS (class); + dialog_class->response = e_cert_selector_response; + + ecs_signals[ECS_SELECTED] = g_signal_new ( + "selected", + G_OBJECT_CLASS_TYPE (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ECertSelectorClass, selected), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, + G_TYPE_POINTER); } + diff --git a/smime/gui/e-cert-selector.h b/smime/gui/e-cert-selector.h index 5520b5621c..e51f1263ef 100644 --- a/smime/gui/e-cert-selector.h +++ b/smime/gui/e-cert-selector.h @@ -26,24 +26,34 @@ #include <gtk/gtk.h> -#ifdef cplusplus -extern "C" { -#pragma } -#endif /* cplusplus */ +/* Standard GObject macros */ +#define E_TYPE_CERT_SELECTOR \ + (e_cert_selector_get_type ()) +#define E_CERT_SELECTOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CERT_SELECTOR, ECertSelector)) +#define E_CERT_SELECTOR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CERT_SELECTOR, ECertSelectorClass)) +#define E_IS_CERT_SELECTOR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CERT_SELECTOR)) +#define E_IS_CERT_SELECTOR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CERT_SELECTOR)) +#define E_CERT_SELECTOR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CERT_SELECTOR, ECertSelectorClass)) -#define E_TYPE_CERT_SELECTOR (e_cert_selector_get_type ()) -#define E_CERT_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CERT_SELECTOR, ECertSelector)) -#define E_CERT_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CERT_SELECTOR, ECertSelectorClass)) -#define E_IS_CERT_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CERT_SELECTOR)) -#define E_IS_CERT_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CERT_SELECTOR)) +G_BEGIN_DECLS -typedef struct _ECertSelector ECertSelector; -typedef struct _ECertSelectorClass ECertSelectorClass; +typedef struct _ECertSelector ECertSelector; +typedef struct _ECertSelectorClass ECertSelectorClass; +typedef struct _ECertSelectorPrivate ECertSelectorPrivate; struct _ECertSelector { GtkDialog parent; - - struct _ECertSelectorPrivate *priv; + ECertSelectorPrivate *priv; }; struct _ECertSelectorClass { @@ -60,8 +70,7 @@ enum _e_cert_selector_type { GType e_cert_selector_get_type (void); GtkWidget *e_cert_selector_new (gint type, const gchar *currentid); -#ifdef cplusplus -} -#endif /* cplusplus */ +G_END_DECLS #endif /* E_CERT_SELECTOR_H */ + diff --git a/smime/lib/e-asn1-object.c b/smime/lib/e-asn1-object.c index 4dd519e2d4..53441516f5 100644 --- a/smime/lib/e-asn1-object.c +++ b/smime/lib/e-asn1-object.c @@ -47,6 +47,10 @@ #include "secasn1.h" +#define E_ASN1_OBJECT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_ASN1_OBJECT, EASN1ObjectPrivate)) + struct _EASN1ObjectPrivate { PRUint32 tag; PRUint32 type; @@ -61,74 +65,43 @@ struct _EASN1ObjectPrivate { guint data_len; }; -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; +G_DEFINE_TYPE (EASN1Object, e_asn1_object, G_TYPE_OBJECT) static void -e_asn1_object_dispose (GObject *object) +e_asn1_object_finalize (GObject *object) { - EASN1Object *obj = E_ASN1_OBJECT (object); - if (obj->priv) { + EASN1ObjectPrivate *priv; - if (obj->priv->display_name) - g_free (obj->priv->display_name); + priv = E_ASN1_OBJECT_GET_PRIVATE (object); - if (obj->priv->value) - g_free (obj->priv->value); + g_free (priv->display_name); + g_free (priv->value); - g_list_foreach (obj->priv->children, (GFunc) g_object_unref, NULL); - g_list_free (obj->priv->children); + g_list_free_full (priv->children, (GDestroyNotify) g_object_unref); - g_free (obj->priv); - obj->priv = NULL; - } + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_asn1_object_parent_class)->finalize (object); } static void -e_asn1_object_class_init (EASN1ObjectClass *klass) +e_asn1_object_class_init (EASN1ObjectClass *class) { GObjectClass *object_class; - object_class = G_OBJECT_CLASS (klass); + g_type_class_add_private (class, sizeof (EASN1ObjectPrivate)); - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = e_asn1_object_dispose; + object_class = G_OBJECT_CLASS (class); + object_class->finalize = e_asn1_object_finalize; } static void e_asn1_object_init (EASN1Object *asn1) { - asn1->priv = g_new0 (EASN1ObjectPrivate, 1); + asn1->priv = E_ASN1_OBJECT_GET_PRIVATE (asn1); asn1->priv->valid_container = TRUE; } -GType -e_asn1_object_get_type (void) -{ - static GType asn1_object_type = 0; - - if (!asn1_object_type) { - static const GTypeInfo asn1_object_info = { - sizeof (EASN1ObjectClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_asn1_object_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EASN1Object), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_asn1_object_init, - }; - - asn1_object_type = g_type_register_static ( - PARENT_TYPE, "EASN1Object", &asn1_object_info, 0); - } - - return asn1_object_type; -} - /* This function is used to interpret an integer that * was encoded in a DER buffer. This function is used * when converting a DER buffer into a nsIASN1Object diff --git a/smime/lib/e-cert-db.c b/smime/lib/e-cert-db.c index 6006168e20..7cc7fc0939 100644 --- a/smime/lib/e-cert-db.c +++ b/smime/lib/e-cert-db.c @@ -88,12 +88,7 @@ enum { static guint e_cert_db_signals[LAST_SIGNAL]; -struct _ECertDBPrivate { - guint reserved; -}; - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; +G_DEFINE_TYPE (ECertDB, e_cert_db, G_TYPE_OBJECT) GQuark e_certdb_error_quark (void) @@ -368,23 +363,6 @@ e_cert_db_get_certs_from_package (PRArenaPool *arena, return collectArgs; } -static void -e_cert_db_dispose (GObject *object) -{ - ECertDB *ec = E_CERT_DB (object); - - if (!ec->priv) - return; - - /* XXX free instance specific data */ - - g_free (ec->priv); - ec->priv = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - #ifdef notyet PRBool ucs2_ascii_conversion_fn (PRBool toUnicode, @@ -541,15 +519,11 @@ install_loadable_roots (void) } static void -e_cert_db_class_init (ECertDBClass *klass) +e_cert_db_class_init (ECertDBClass *class) { GObjectClass *object_class; - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = e_cert_db_dispose; + object_class = G_OBJECT_CLASS (class); initialize_nss (); /* check to see if you have a rootcert module installed */ @@ -589,31 +563,6 @@ e_cert_db_class_init (ECertDBClass *klass) static void e_cert_db_init (ECertDB *ec) { - ec->priv = g_new0 (ECertDBPrivate, 1); -} - -GType -e_cert_db_get_type (void) -{ - static GType cert_type = 0; - - if (!cert_type) { - static const GTypeInfo cert_info = { - sizeof (ECertDBClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_cert_db_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ECertDB), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_cert_db_init, - }; - - cert_type = g_type_register_static (PARENT_TYPE, "ECertDB", &cert_info, 0); - } - - return cert_type; } GStaticMutex init_mutex = G_STATIC_MUTEX_INIT; diff --git a/smime/lib/e-cert-trust.c b/smime/lib/e-cert-trust.c index e1c7124e41..a23e0a7083 100644 --- a/smime/lib/e-cert-trust.c +++ b/smime/lib/e-cert-trust.c @@ -181,19 +181,33 @@ e_cert_trust_set_objsign_trust (CERTCertTrust *trust, { trust->objectSigningFlags = 0; if (peer || tPeer) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_VALID_PEER); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_VALID_PEER); if (tPeer) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_TRUSTED); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_TRUSTED); if (ca || tCA) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_VALID_CA); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_VALID_CA); if (tClientCA) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_TRUSTED_CLIENT_CA); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_TRUSTED_CLIENT_CA); if (tCA) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_TRUSTED_CA); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_TRUSTED_CA); if (user) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_USER); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_USER); if (warn) - e_cert_trust_add_trust (&trust->objectSigningFlags, CERTDB_SEND_WARN); + e_cert_trust_add_trust ( + &trust->objectSigningFlags, + CERTDB_SEND_WARN); } void diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c index 930dd65474..0849634767 100644 --- a/smime/lib/e-cert.c +++ b/smime/lib/e-cert.c @@ -47,7 +47,9 @@ #include <glib/gi18n.h> #include <libedataserver/e-data-server-util.h> -#include <e-util/e-util.h> /* for e_utf8_strftime, what about e_time_format_time? */ + +/* for e_utf8_strftime, what about e_time_format_time? */ +#include <e-util/e-util.h> #include "e-cert.h" #include "e-cert-trust.h" @@ -55,6 +57,10 @@ #include "certdb.h" #include "hasht.h" +#define E_CERT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CERT, ECertPrivate)) + struct _ECertPrivate { CERTCertificate *cert; @@ -86,112 +92,80 @@ struct _ECertPrivate { gboolean delete; }; -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; +G_DEFINE_TYPE (ECert, e_cert, G_TYPE_OBJECT) static void -e_cert_dispose (GObject *object) +e_cert_finalize (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->org_unit_name) - PORT_Free (ec->priv->org_unit_name); - if (ec->priv->cn) - PORT_Free (ec->priv->cn); - - if (ec->priv->issuer_org_name) - PORT_Free (ec->priv->issuer_org_name); - if (ec->priv->issuer_org_unit_name) - PORT_Free (ec->priv->issuer_org_unit_name); - if (ec->priv->issuer_cn) - PORT_Free (ec->priv->issuer_cn); - - if (ec->priv->issued_on_string) - PORT_Free (ec->priv->issued_on_string); - if (ec->priv->expires_on_string) - PORT_Free (ec->priv->expires_on_string); - if (ec->priv->serial_number) - PORT_Free (ec->priv->serial_number); - - g_free (ec->priv->usage_string); - - if (ec->priv->sha1_fingerprint) - PORT_Free (ec->priv->sha1_fingerprint); - if (ec->priv->md5_fingerprint) - PORT_Free (ec->priv->md5_fingerprint); - - if (ec->priv->asn1) - g_object_unref (ec->priv->asn1); - - if (ec->priv->delete) { + ECertPrivate *priv; + + priv = E_CERT_GET_PRIVATE (object); + + if (priv->org_name) + PORT_Free (priv->org_name); + if (priv->org_unit_name) + PORT_Free (priv->org_unit_name); + if (priv->cn) + PORT_Free (priv->cn); + + if (priv->issuer_org_name) + PORT_Free (priv->issuer_org_name); + if (priv->issuer_org_unit_name) + PORT_Free (priv->issuer_org_unit_name); + if (priv->issuer_cn) + PORT_Free (priv->issuer_cn); + + if (priv->issued_on_string) + PORT_Free (priv->issued_on_string); + if (priv->expires_on_string) + PORT_Free (priv->expires_on_string); + if (priv->serial_number) + PORT_Free (priv->serial_number); + + g_free (priv->usage_string); + + if (priv->sha1_fingerprint) + PORT_Free (priv->sha1_fingerprint); + if (priv->md5_fingerprint) + PORT_Free (priv->md5_fingerprint); + + if (priv->asn1) + g_object_unref (priv->asn1); + + if (priv->delete) { printf ("attempting to delete cert marked for deletion\n"); - if (e_cert_get_cert_type (ec) == E_CERT_USER) { - PK11_DeleteTokenCertAndKey (ec->priv->cert, NULL); - } else if (!PK11_IsReadOnly (ec->priv->cert->slot)) { + if (e_cert_get_cert_type (E_CERT (object)) == E_CERT_USER) { + PK11_DeleteTokenCertAndKey (priv->cert, NULL); + } else if (!PK11_IsReadOnly (priv->cert->slot)) { /* If the list of built-ins does contain a non-removable * copy of this certificate, our call will not remove * the certificate permanently, but rather remove all trust. */ - SEC_DeletePermCertificate (ec->priv->cert); + SEC_DeletePermCertificate (priv->cert); } } - if (ec->priv->cert) { - CERT_DestroyCertificate (ec->priv->cert); - ec->priv->cert = NULL; - } + if (priv->cert) + CERT_DestroyCertificate (priv->cert); - g_free (ec->priv); - ec->priv = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_cert_parent_class)->finalize (object); } static void -e_cert_class_init (ECertClass *klass) +e_cert_class_init (ECertClass *class) { GObjectClass *object_class; - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); + g_type_class_add_private (class, sizeof (ECertPrivate)); - object_class->dispose = e_cert_dispose; + object_class = G_OBJECT_CLASS (class); + object_class->finalize = e_cert_finalize; } 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; + ec->priv = E_CERT_GET_PRIVATE (ec); } static void @@ -216,7 +190,9 @@ e_cert_populate (ECert *cert) struct tm exploded_tm; gchar buf[32]; - PR_ExplodeTime (cert->priv->issued_on, PR_LocalTimeParameters, &explodedTime); + PR_ExplodeTime ( + cert->priv->issued_on, + PR_LocalTimeParameters, &explodedTime); exploded_tm.tm_sec = explodedTime.tm_sec; exploded_tm.tm_min = explodedTime.tm_min; exploded_tm.tm_hour = explodedTime.tm_hour; @@ -226,7 +202,9 @@ e_cert_populate (ECert *cert) e_utf8_strftime (buf, sizeof(buf), _("%d/%m/%Y"), &exploded_tm); cert->priv->issued_on_string = g_strdup (buf); - PR_ExplodeTime (cert->priv->expires_on, PR_LocalTimeParameters, &explodedTime); + PR_ExplodeTime ( + cert->priv->expires_on, + PR_LocalTimeParameters, &explodedTime); exploded_tm.tm_sec = explodedTime.tm_sec; exploded_tm.tm_min = explodedTime.tm_min; exploded_tm.tm_hour = explodedTime.tm_hour; @@ -1036,7 +1014,8 @@ process_name (CERTName *name, return FALSE; } - avavalue = g_string_new_len ((gchar *) decodeItem->data, decodeItem->len); + avavalue = g_string_new_len ( + (gchar *) decodeItem->data, decodeItem->len); SECITEM_FreeItem (decodeItem, PR_TRUE); @@ -1271,7 +1250,8 @@ e_cert_mark_for_deletion (ECert *cert) if (PK11_NeedLogin (cert->priv->cert->slot) && !PK11_NeedUserInit (cert->priv->cert->slot) && !PK11_IsInternal (cert->priv->cert->slot)) { - if (SECSuccess != PK11_Authenticate (cert->priv->cert->slot, PR_TRUE, NULL)) { + if (PK11_Authenticate ( + cert->priv->cert->slot, PR_TRUE, NULL) != SECSuccess) { return FALSE; } } diff --git a/smime/lib/e-pkcs12.c b/smime/lib/e-pkcs12.c index 5f7a73ce65..7bdc9e7f1c 100644 --- a/smime/lib/e-pkcs12.c +++ b/smime/lib/e-pkcs12.c @@ -63,13 +63,6 @@ #include "pk11func.h" #include "secerr.h" -struct _EPKCS12Private { - gint mumble; -}; - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; - /* static callback functions for the NSS PKCS#12 library */ static SECItem * PR_CALLBACK nickname_collision (SECItem *, PRBool *, gpointer ); @@ -84,71 +77,22 @@ static gboolean handle_error (gint myerr); #define PKCS12_BACKUP_FAILED 6 #define PKCS12_NSS_ERROR 7 -static void -e_pkcs12_dispose (GObject *object) -{ - EPKCS12 *pk = E_PKCS12 (object); - - if (!pk->priv) - return; - - /* XXX free instance private foo */ - - g_free (pk->priv); - pk->priv = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} +G_DEFINE_TYPE (EPKCS12, e_pkcs12, G_TYPE_OBJECT) static void -e_pkcs12_class_init (EPKCS12Class *klass) +e_pkcs12_class_init (EPKCS12Class *class) { - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = e_pkcs12_dispose; } static void e_pkcs12_init (EPKCS12 *ec) { - ec->priv = g_new0 (EPKCS12Private, 1); -} - -GType -e_pkcs12_get_type (void) -{ - static GType pkcs12_type = 0; - - if (!pkcs12_type) { - static const GTypeInfo pkcs12_info = { - sizeof (EPKCS12Class), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_pkcs12_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EPKCS12), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_pkcs12_init, - }; - - pkcs12_type = g_type_register_static (PARENT_TYPE, "EPKCS12", &pkcs12_info, 0); - } - - return pkcs12_type; } EPKCS12 * e_pkcs12_new (void) { - EPKCS12 *pk = E_PKCS12 (g_object_new (E_TYPE_PKCS12, NULL)); - - return pk; + return g_object_new (E_TYPE_PKCS12, NULL); } static gboolean |