[evolution-kolab] CamelKolabIMAPXSettings: Add "pkcs11-pin" string property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] CamelKolabIMAPXSettings: Add "pkcs11-pin" string property.
- Date: Thu, 12 Jul 2012 12:44:06 +0000 (UTC)
commit 3a074f9f55fcf43ead2dbeb3acf0a58d3cb3e2b4
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 3 10:59:47 2012 -0400
CamelKolabIMAPXSettings: Add "pkcs11-pin" string property.
src/libekolab/camel-kolab-imapx-settings.c | 103 +++++++++++++++++++++++++---
src/libekolab/camel-kolab-imapx-settings.h | 8 ++
2 files changed, 102 insertions(+), 9 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-settings.c b/src/libekolab/camel-kolab-imapx-settings.c
index e6235cc..2f5e203 100644
--- a/src/libekolab/camel-kolab-imapx-settings.c
+++ b/src/libekolab/camel-kolab-imapx-settings.c
@@ -31,15 +31,20 @@
#include "camel-kolab-imapx-settings.h"
+#include <libedataserver/libedataserver.h>
+
#include <libekolab/kolab-enumtypes.h>
/*----------------------------------------------------------------------------*/
struct _CamelKolabIMAPXSettingsPrivate {
+ GMutex *property_lock;
+ gchar *pkcs11_pin;
};
enum {
- PROP_0
+ PROP_0,
+ PROP_PKCS11_PIN
};
#define CAMEL_KOLAB_IMAPX_SETTINGS_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CAMEL_TYPE_KOLAB_IMAPX_SETTINGS, CamelKolabIMAPXSettingsPrivate))
@@ -50,20 +55,17 @@ G_DEFINE_TYPE (CamelKolabIMAPXSettings, camel_kolab_imapx_settings, CAMEL_TYPE_I
/* object/class init */
static void
-camel_kolab_imapx_settings_init (CamelKolabIMAPXSettings *self)
-{
- g_assert (CAMEL_IS_KOLAB_IMAPX_SETTINGS (self));
-
- self->priv = CAMEL_KOLAB_IMAPX_SETTINGS_PRIVATE (self);
-}
-
-static void
camel_kolab_imapx_settings_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PKCS11_PIN:
+ camel_kolab_imapx_settings_set_pkcs11_pin (
+ CAMEL_KOLAB_IMAPX_SETTINGS (object),
+ g_value_get_string (value));
+ return;
default:
break;
}
@@ -78,6 +80,12 @@ camel_kolab_imapx_settings_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PKCS11_PIN:
+ g_value_set_string (
+ value,
+ camel_kolab_imapx_settings_get_pkcs11_pin (
+ CAMEL_KOLAB_IMAPX_SETTINGS (object)));
+ return;
default:
break;
}
@@ -86,6 +94,21 @@ camel_kolab_imapx_settings_get_property (GObject *object,
}
static void
+camel_kolab_imapx_settings_finalize (GObject *object)
+{
+ CamelKolabIMAPXSettingsPrivate *priv;
+
+ priv = CAMEL_KOLAB_IMAPX_SETTINGS_PRIVATE (object);
+
+ g_mutex_free (priv->property_lock);
+
+ g_free (priv->pkcs11_pin);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_kolab_imapx_settings_parent_class)->finalize (object);
+}
+
+static void
camel_kolab_imapx_settings_class_init (CamelKolabIMAPXSettingsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -94,6 +117,26 @@ camel_kolab_imapx_settings_class_init (CamelKolabIMAPXSettingsClass *klass)
object_class->set_property = camel_kolab_imapx_settings_set_property;
object_class->get_property = camel_kolab_imapx_settings_get_property;
+ object_class->finalize = camel_kolab_imapx_settings_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PKCS11_PIN,
+ g_param_spec_string (
+ "pkcs11-pin",
+ "PKCS #11 PIN",
+ "PKCS #11 certificate PIN",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_kolab_imapx_settings_init (CamelKolabIMAPXSettings *self)
+{
+ self->priv = CAMEL_KOLAB_IMAPX_SETTINGS_PRIVATE (self);
+ self->priv->property_lock = g_mutex_new ();
}
/*----------------------------------------------------------------------------*/
@@ -137,4 +180,46 @@ camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings)
return url;
}
+const gchar *
+camel_kolab_imapx_settings_get_pkcs11_pin (CamelKolabIMAPXSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings), NULL);
+
+ return settings->priv->pkcs11_pin;
+}
+
+gchar *
+camel_kolab_imapx_settings_dup_pkcs11_pin (CamelKolabIMAPXSettings *settings)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings), NULL);
+
+ g_mutex_lock (settings->priv->property_lock);
+
+ protected = camel_kolab_imapx_settings_get_pkcs11_pin (settings);
+ duplicate = g_strdup (protected);
+
+ g_mutex_unlock (settings->priv->property_lock);
+
+ return duplicate;
+}
+
+void
+camel_kolab_imapx_settings_set_pkcs11_pin (CamelKolabIMAPXSettings *settings,
+ const gchar *pkcs11_pin)
+{
+ g_return_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings));
+
+ g_mutex_lock (settings->priv->property_lock);
+
+ g_free (settings->priv->pkcs11_pin);
+ settings->priv->pkcs11_pin = e_util_strdup_strip (pkcs11_pin);
+
+ g_mutex_unlock (settings->priv->property_lock);
+
+ g_object_notify (G_OBJECT (settings), "pkcs11-pin");
+}
+
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/camel-kolab-imapx-settings.h b/src/libekolab/camel-kolab-imapx-settings.h
index 5c511a9..b8be803 100644
--- a/src/libekolab/camel-kolab-imapx-settings.h
+++ b/src/libekolab/camel-kolab-imapx-settings.h
@@ -78,6 +78,14 @@ camel_kolab_imapx_settings_get_type (void);
CamelURL *
camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings);
+const gchar *
+camel_kolab_imapx_settings_get_pkcs11_pin (CamelKolabIMAPXSettings *settings);
+gchar *
+camel_kolab_imapx_settings_dup_pkcs11_pin (CamelKolabIMAPXSettings *settings);
+void
+camel_kolab_imapx_settings_set_pkcs11_pin (CamelKolabIMAPXSettings *settings,
+ const gchar *pkcs11_pin);
+
G_END_DECLS
/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]