aboutsummaryrefslogtreecommitdiffstats
path: root/smime/lib
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-12-01 10:53:20 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-02-20 23:04:25 +0800
commit23f5773903d64a554d977ae7d0ebbaca73528f1f (patch)
tree104e1a59da8bf96b004bce204b79f47bbe0a6d13 /smime/lib
parent49bc4c2d765ee1780c23fdc9f42152850dabb220 (diff)
downloadgsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.gz
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.bz2
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.lz
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.xz
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.tar.zst
gsoc2013-evolution-23f5773903d64a554d977ae7d0ebbaca73528f1f.zip
Coding style and whitespace cleanup.
Diffstat (limited to 'smime/lib')
-rw-r--r--smime/lib/e-asn1-object.c63
-rw-r--r--smime/lib/e-cert-db.c57
-rw-r--r--smime/lib/e-cert-trust.c28
-rw-r--r--smime/lib/e-cert.c156
-rw-r--r--smime/lib/e-pkcs12.c62
5 files changed, 113 insertions, 253 deletions
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