[gnome-keyring/dbus-api] [secrets] Add skeleton of search object.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-keyring/dbus-api] [secrets] Add skeleton of search object.
- Date: Mon, 27 Jul 2009 15:13:40 +0000 (UTC)
commit d6974c331db6b3a05e1d853baa0a140f9a842e2f
Author: Stef Walter <stef memberwebs com>
Date: Sat Jul 25 15:43:42 2009 +0000
[secrets] Add skeleton of search object.
pkcs11/secret-store/Makefile.am | 4 +-
pkcs11/secret-store/gck-secret-collection.c | 28 +++-
pkcs11/secret-store/gck-secret-collection.h | 3 +
pkcs11/secret-store/gck-secret-fields.c | 170 +++++++++++++++++++++++++
pkcs11/secret-store/gck-secret-fields.h | 45 +++++++
pkcs11/secret-store/gck-secret-item.c | 159 ++++-------------------
pkcs11/secret-store/gck-secret-search.c | 184 +++++++++++++++++++++++++++
pkcs11/secret-store/gck-secret-search.h | 47 +++++++
8 files changed, 499 insertions(+), 141 deletions(-)
---
diff --git a/pkcs11/secret-store/Makefile.am b/pkcs11/secret-store/Makefile.am
index 208311c..e3fdd33 100644
--- a/pkcs11/secret-store/Makefile.am
+++ b/pkcs11/secret-store/Makefile.am
@@ -14,7 +14,9 @@ noinst_LTLIBRARIES = \
libgck_secret_store_la_SOURCES = \
gck-secret-collection.h gck-secret-collection.c \
+ gck-secret-fields.h gck-secret-fields.c \
gck-secret-item.h gck-secret-item.c \
- gck-secret-object.h gck-secret-object.c
+ gck-secret-object.h gck-secret-object.c \
+ gck-secret-search.h gck-secret-search.c
# -------------------------------------------------------------------------------
diff --git a/pkcs11/secret-store/gck-secret-collection.c b/pkcs11/secret-store/gck-secret-collection.c
index 4beee9f..d4bf163 100644
--- a/pkcs11/secret-store/gck-secret-collection.c
+++ b/pkcs11/secret-store/gck-secret-collection.c
@@ -31,6 +31,7 @@ enum {
struct _GckSecretCollection {
GckSecretObject parent;
+ GHashTable *secrets;
};
G_DEFINE_TYPE (GckSecretCollection, gck_secret_collection, GCK_TYPE_SECRET_OBJECT);
@@ -59,11 +60,11 @@ gck_secret_collection_get_attribute (GckObject *base, GckSession *session, CK_AT
static void
gck_secret_collection_init (GckSecretCollection *self)
{
-
+ self->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
}
-static GObject*
-gck_secret_collection_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static GObject*
+gck_secret_collection_constructor (GType type, guint n_props, GObjectConstructParam *props)
{
GckSecretCollection *self = GCK_SECRET_COLLECTION (G_OBJECT_CLASS (gck_secret_collection_parent_class)->constructor(type, n_props, props));
g_return_val_if_fail (self, NULL);
@@ -102,9 +103,9 @@ gck_secret_collection_get_property (GObject *obj, guint prop_id, GValue *value,
static void
gck_secret_collection_dispose (GObject *obj)
{
-#if 0
GckSecretCollection *self = GCK_SECRET_COLLECTION (obj);
-#endif
+
+ g_hash_table_remove_all (self->secrets);
G_OBJECT_CLASS (gck_secret_collection_parent_class)->dispose (obj);
}
@@ -112,9 +113,11 @@ gck_secret_collection_dispose (GObject *obj)
static void
gck_secret_collection_finalize (GObject *obj)
{
-#if 0
GckSecretCollection *self = GCK_SECRET_COLLECTION (obj);
-#endif
+
+ if (self->secrets)
+ g_hash_table_destroy (self->secrets);
+ self->secrets = NULL;
G_OBJECT_CLASS (gck_secret_collection_parent_class)->finalize (obj);
}
@@ -137,5 +140,14 @@ gck_secret_collection_class_init (GckSecretCollectionClass *klass)
}
/* -----------------------------------------------------------------------------
- * PUBLIC
+ * PUBLIC
*/
+
+GckLogin*
+gck_secret_collection_lookup_secret (GckSecretCollection *self,
+ const gchar *identifier)
+{
+ g_return_val_if_fail (GCK_IS_SECRET_COLLECTION (self), NULL);
+ g_return_val_if_fail (identifier, NULL);
+ return g_hash_table_lookup (self->secrets, identifier);
+}
diff --git a/pkcs11/secret-store/gck-secret-collection.h b/pkcs11/secret-store/gck-secret-collection.h
index 53d9125..02492d7 100644
--- a/pkcs11/secret-store/gck-secret-collection.h
+++ b/pkcs11/secret-store/gck-secret-collection.h
@@ -42,4 +42,7 @@ struct _GckSecretCollectionClass {
GType gck_secret_collection_get_type (void);
+GckLogin* gck_secret_collection_lookup_secret (GckSecretCollection *self,
+ const gchar *identifier);
+
#endif /* __GCK_SECRET_COLLECTION_H__ */
diff --git a/pkcs11/secret-store/gck-secret-fields.c b/pkcs11/secret-store/gck-secret-fields.c
new file mode 100644
index 0000000..ee8d541
--- /dev/null
+++ b/pkcs11/secret-store/gck-secret-fields.c
@@ -0,0 +1,170 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2009 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#include "config.h"
+
+#include "gck-secret-fields.h"
+
+#include "gck/gck-attributes.h"
+
+#include <string.h>
+
+GType
+gck_secret_fields_boxed_type (void)
+{
+ static GType type = 0;
+ if (!type)
+ type = g_boxed_type_register_static ("GHashTable_Fields",
+ (GBoxedCopyFunc)g_hash_table_ref,
+ (GBoxedFreeFunc)g_hash_table_unref);
+ return type;
+}
+
+GHashTable*
+gck_secret_fields_new (void)
+{
+ return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+}
+
+CK_RV
+gck_secret_fields_parse (CK_ATTRIBUTE_PTR attr, GHashTable **fields)
+{
+ GHashTable *result;
+ gchar *name;
+ gsize n_name;
+ gchar *value;
+ gsize n_value;
+ gchar *ptr;
+ gchar *last;
+
+ g_assert (attr);
+ g_assert (fields);
+
+ ptr = attr->pValue;
+ last = ptr + attr->ulValueLen;
+
+ if (!ptr && last != ptr)
+ return CKR_ATTRIBUTE_VALUE_INVALID;
+
+ result = gck_secret_fields_new ();
+
+ while (ptr && ptr != last) {
+ g_assert (ptr < last);
+
+ name = ptr;
+ ptr = memchr (ptr, 0, last - ptr);
+
+ /* No value is present? */
+ if (!ptr) {
+ g_hash_table_unref (result);
+ return CKR_ATTRIBUTE_VALUE_INVALID;
+ }
+
+ n_name = ptr - name;
+ value = ptr;
+ ptr = memchr (ptr, 0, last - ptr);
+
+ /* The last value */
+ if (ptr == NULL)
+ ptr = last;
+
+ n_value = ptr - value;
+
+ /* Validate the name and value*/
+ if (!g_utf8_validate (name, n_name, NULL) ||
+ !g_utf8_validate (value, n_value, NULL)) {
+ g_hash_table_unref (result);
+ return CKR_ATTRIBUTE_VALUE_INVALID;
+ }
+
+ g_hash_table_replace (result, g_strndup (name, n_name), g_strndup (value, n_value));
+ }
+
+ *fields = result;
+ return CKR_OK;
+}
+
+static void
+each_field_append (gpointer key, gpointer value, gpointer user_data)
+{
+ GString *result = user_data;
+ g_string_append (result, key);
+ g_string_append_c (result, '\0');
+ g_string_append (result, value);
+ g_string_append_c (result, '\0');
+}
+
+static void
+each_field_length (gpointer key, gpointer value, gpointer user_data)
+{
+ gsize *length = user_data;
+ *length += strlen (key);
+ *length += strlen (value);
+ *length += 2;
+}
+
+CK_RV
+gck_secret_fields_serialize (CK_ATTRIBUTE_PTR attr, GHashTable *fields)
+{
+ GString *result;
+ gsize length;
+ CK_RV rv;
+
+ g_assert (attr);
+ g_assert (fields);
+
+ if (!attr->pValue) {
+ length = 0;
+ g_hash_table_foreach (fields, each_field_length, &length);
+ attr->ulValueLen = length;
+ return CKR_OK;
+ }
+
+ result = g_string_sized_new (256);
+ g_hash_table_foreach (fields, each_field_append, result);
+
+ rv = gck_attribute_set_data (attr, result->str, result->len);
+ g_string_free (result, TRUE);
+
+ return rv;
+}
+
+gboolean
+gck_secret_fields_match (GHashTable *haystack, GHashTable *needle)
+{
+ GHashTableIter iter;
+ gpointer key, value, hay;
+
+ g_return_val_if_fail (haystack, FALSE);
+ g_return_val_if_fail (needle, FALSE);
+
+ g_hash_table_iter_init (&iter, needle);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ g_assert (key && value);
+ hay = g_hash_table_lookup (haystack, key);
+ if (hay == NULL)
+ return FALSE;
+ if (!g_str_equal (hay, value))
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/pkcs11/secret-store/gck-secret-fields.h b/pkcs11/secret-store/gck-secret-fields.h
new file mode 100644
index 0000000..060f2d9
--- /dev/null
+++ b/pkcs11/secret-store/gck-secret-fields.h
@@ -0,0 +1,45 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2009 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#ifndef __GCK_SECRET_FIELDS_H__
+#define __GCK_SECRET_FIELDS_H__
+
+#include "pkcs11.h"
+
+#include <glib.h>
+#include <glib-object.h>
+
+#define GCK_BOXED_SECRET_FIELDS (gck_secret_fields_boxed_type ())
+
+GType gck_secret_fields_boxed_type (void);
+
+GHashTable* gck_secret_fields_new (void);
+
+CK_RV gck_secret_fields_parse (CK_ATTRIBUTE_PTR attr,
+ GHashTable **fields);
+
+CK_RV gck_secret_fields_serialize (CK_ATTRIBUTE_PTR attr,
+ GHashTable *fields);
+
+gboolean gck_secret_fields_match (GHashTable *haystack,
+ GHashTable *needle);
+
+#endif /* __GCK_SECRET_FIELDS_H__ */
diff --git a/pkcs11/secret-store/gck-secret-item.c b/pkcs11/secret-store/gck-secret-item.c
index 022809c..aa56a75 100644
--- a/pkcs11/secret-store/gck-secret-item.c
+++ b/pkcs11/secret-store/gck-secret-item.c
@@ -21,6 +21,7 @@
#include "config.h"
+#include "gck-secret-fields.h"
#include "gck-secret-item.h"
#include "gck/gck-attributes.h"
@@ -51,120 +52,6 @@ G_DEFINE_TYPE (GckSecretItem, gck_secret_item, GCK_TYPE_SECRET_OBJECT);
* INTERNAL
*/
-static GType
-fields_boxed_type (void)
-{
- static GType type = 0;
- if (!type)
- type = g_boxed_type_register_static ("GHashTable_Fields",
- (GBoxedCopyFunc)g_hash_table_ref,
- (GBoxedFreeFunc)g_hash_table_unref);
- return type;
-}
-
-static void
-each_field_append (gpointer key, gpointer value, gpointer user_data)
-{
- GString *result = user_data;
- g_string_append (result, key);
- g_string_append_c (result, '\0');
- g_string_append (result, value);
- g_string_append_c (result, '\0');
-}
-
-static void
-each_field_length (gpointer key, gpointer value, gpointer user_data)
-{
- gsize *length = user_data;
- *length += strlen (key);
- *length += strlen (value);
- *length += 2;
-}
-
-static CK_RV
-attribute_set_fields (CK_ATTRIBUTE_PTR attr, GHashTable *fields)
-{
- GString *result;
- gsize length;
- CK_RV rv;
-
- g_assert (attr);
- g_assert (fields);
-
- if (!attr->pValue) {
- length = 0;
- g_hash_table_foreach (fields, each_field_length, &length);
- attr->ulValueLen = length;
- return CKR_OK;
- }
-
- result = g_string_sized_new (256);
- g_hash_table_foreach (fields, each_field_append, result);
-
- rv = gck_attribute_set_data (attr, result->str, result->len);
- g_string_free (result, TRUE);
-
- return rv;
-}
-
-static CK_RV
-attribute_get_fields (CK_ATTRIBUTE_PTR attr, GHashTable **fields)
-{
- GHashTable *result;
- gchar *name;
- gsize n_name;
- gchar *value;
- gsize n_value;
- gchar *ptr;
- gchar *last;
-
- g_assert (attr);
- g_assert (fields);
-
- ptr = attr->pValue;
- last = ptr + attr->ulValueLen;
-
- if (!ptr && last != ptr)
- return CKR_ATTRIBUTE_VALUE_INVALID;
-
- result = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- while (ptr && ptr != last) {
- g_assert (ptr < last);
-
- name = ptr;
- ptr = memchr (ptr, 0, last - ptr);
-
- /* No value is present? */
- if (!ptr) {
- g_hash_table_unref (result);
- return CKR_ATTRIBUTE_VALUE_INVALID;
- }
-
- n_name = ptr - name;
- value = ptr;
- ptr = memchr (ptr, 0, last - ptr);
-
- /* The last value */
- if (ptr == NULL)
- ptr = last;
-
- n_value = ptr - value;
-
- /* Validate the name and value*/
- if (!g_utf8_validate (name, n_name, NULL) ||
- !g_utf8_validate (value, n_value, NULL)) {
- g_hash_table_unref (result);
- return CKR_ATTRIBUTE_VALUE_INVALID;
- }
-
- g_hash_table_replace (result, g_strndup (name, n_name), g_strndup (value, n_value));
- }
-
- *fields = result;
- return CKR_OK;
-}
-
static gboolean
complete_set_secret (GckTransaction *transaction, GObject *obj, gpointer user_data)
{
@@ -232,6 +119,15 @@ begin_set_fields (GckSecretItem *self, GckTransaction *transaction, GHashTable *
* OBJECT
*/
+static gboolean
+gck_secret_item_real_is_locked (GckSecretObject *obj, GckSession *session)
+{
+ GckSecretItem *self = GCK_SECRET_ITEM (obj);
+ if (!self->collection)
+ return TRUE;
+ return gck_secret_object_is_locked (GCK_SECRET_OBJECT (self), session);
+}
+
static CK_RV
gck_secret_item_real_get_attribute (GckObject *base, GckSession *session, CK_ATTRIBUTE_PTR attr)
{
@@ -242,7 +138,7 @@ gck_secret_item_real_get_attribute (GckObject *base, GckSession *session, CK_ATT
switch (attr->type) {
case CKA_VALUE:
- if (gck_secret_item_real_is_locked (self, session))
+ if (gck_secret_item_real_is_locked (GCK_SECRET_OBJECT (self), session))
return CKR_USER_NOT_LOGGED_IN;
g_return_val_if_fail (self->secret, CKR_GENERAL_ERROR);
password = gck_login_get_password (self->secret, &n_password);
@@ -252,11 +148,11 @@ gck_secret_item_real_get_attribute (GckObject *base, GckSession *session, CK_ATT
g_return_val_if_fail (self->collection, CKR_GENERAL_ERROR);
identifier = gck_secret_object_get_identifier (GCK_SECRET_OBJECT (self->collection));
return gck_attribute_set_string (attr, identifier);
-
+
case CKA_G_FIELDS:
- return attribute_set_fields (attr, self->fields);
+ return gck_secret_fields_serialize (attr, self->fields);
}
-
+
return GCK_OBJECT_CLASS (gck_secret_item_parent_class)->get_attribute (base, session, attr);
}
@@ -268,21 +164,21 @@ gck_secret_item_real_set_attribute (GckObject *base, GckSession *session,
GHashTable *fields;
GckLogin *login;
CK_RV rv;
-
+
/* Check that the object is not locked */
- if (!gck_secret_item_real_is_locked (self, session)) {
+ if (!gck_secret_item_real_is_locked (GCK_SECRET_OBJECT (self), session)) {
gck_transaction_fail (transaction, CKR_USER_NOT_LOGGED_IN);
return;
}
-
+
switch (attr->type) {
case CKA_VALUE:
login = gck_login_new (attr->pValue, attr->ulValueLen);
begin_set_secret (self, transaction, login);
break;
-
+
case CKA_G_FIELDS:
- rv = attribute_get_fields (attr, &fields);
+ rv = gck_secret_fields_parse (attr, &fields);
if (rv != CKR_OK)
gck_transaction_fail (transaction, rv);
else
@@ -405,25 +301,24 @@ gck_secret_item_class_init (GckSecretItemClass *klass)
gck_class->get_attribute = gck_secret_item_real_get_attribute;
gck_class->set_attribute = gck_secret_item_real_set_attribute;
-
+
secret_class->is_locked = gck_secret_item_real_is_locked;
- secret_class->lock = gck_secret_item_real_lock;
g_object_class_install_property (gobject_class, PROP_SECRET,
- g_param_spec_object ("secret", "Secret", "Item's Secret",
+ g_param_spec_object ("secret", "Secret", "Item's Secret",
GCK_TYPE_LOGIN, G_PARAM_READWRITE));
-
+
g_object_class_install_property (gobject_class, PROP_SECRET,
- g_param_spec_object ("collection", "Collection", "Item's Collection",
+ g_param_spec_object ("collection", "Collection", "Item's Collection",
GCK_TYPE_SECRET_COLLECTION, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
+
g_object_class_install_property (gobject_class, PROP_FIELDS,
- g_param_spec_boxed ("fields", "Fields", "Item's fields",
- fields_boxed_type (), G_PARAM_READWRITE));
+ g_param_spec_boxed ("fields", "Fields", "Item's fields",
+ GCK_BOXED_SECRET_FIELDS, G_PARAM_READWRITE));
}
/* -----------------------------------------------------------------------------
- * PUBLIC
+ * PUBLIC
*/
GckSecretCollection*
diff --git a/pkcs11/secret-store/gck-secret-search.c b/pkcs11/secret-store/gck-secret-search.c
new file mode 100644
index 0000000..1fd476e
--- /dev/null
+++ b/pkcs11/secret-store/gck-secret-search.c
@@ -0,0 +1,184 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2009 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#include "config.h"
+
+#include "gck-secret-fields.h"
+#include "gck-secret-search.h"
+
+#include "pkcs11g.h"
+
+#include <glib/gi18n.h>
+
+enum {
+ PROP_0,
+ PROP_FIELDS
+};
+
+struct _GckSecretSearch {
+ GckObject parent;
+ GHashTable *fields;
+ GList *managers;
+ GList *objects;
+};
+
+G_DEFINE_TYPE (GckSecretSearch, gck_secret_search, GCK_TYPE_OBJECT);
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+
+static void
+manager_gone_away (gpointer user_data, GObject *where_the_object_was)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (user_data);
+ GList *l;
+
+ g_return_if_fail (self);
+
+ l = g_list_find (self->managers, where_the_object_was);
+ g_return_if_fail (l != NULL);
+ self->managers = g_list_delete_link (self->managers, l);
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static CK_RV
+gck_secret_search_get_attribute (GckObject *base, GckSession *session, CK_ATTRIBUTE_PTR attr)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (base);
+
+ switch (attr->type) {
+ case CKA_G_FIELDS:
+ return gck_secret_fields_serialize (attr, self->fields);
+ }
+
+ return GCK_OBJECT_CLASS (gck_secret_search_parent_class)->get_attribute (base, session, attr);
+}
+
+
+static void
+gck_secret_search_init (GckSecretSearch *self)
+{
+
+}
+
+static GObject*
+gck_secret_search_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (G_OBJECT_CLASS (gck_secret_search_parent_class)->constructor(type, n_props, props));
+ g_return_val_if_fail (self, NULL);
+
+ g_return_val_if_fail (self->fields, NULL);
+
+ return G_OBJECT (self);
+}
+
+static void
+gck_secret_search_set_property (GObject *obj, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (obj);
+ switch (prop_id) {
+ case PROP_FIELDS:
+ g_return_if_fail (!self->fields);
+ self->fields = g_value_dup_boxed (value);
+ g_return_if_fail (self->fields);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gck_secret_search_get_property (GObject *obj, guint prop_id, GValue *value,
+ GParamSpec *pspec)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (obj);
+ switch (prop_id) {
+ case PROP_FIELDS:
+ g_return_if_fail (self->fields);
+ g_value_set_boxed (value, gck_secret_search_get_fields (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gck_secret_search_dispose (GObject *obj)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (obj);
+ GList *l;
+
+ for (l = self->managers; l; l = g_list_next (l))
+ g_object_weak_unref (G_OBJECT (l->data), manager_gone_away, self);
+ g_list_free (self->managers);
+ self->managers = NULL;
+
+ G_OBJECT_CLASS (gck_secret_search_parent_class)->dispose (obj);
+}
+
+static void
+gck_secret_search_finalize (GObject *obj)
+{
+ GckSecretSearch *self = GCK_SECRET_SEARCH (obj);
+
+ g_assert (!self->managers);
+
+ if (self->fields)
+ g_hash_table_destroy (self->fields);
+ self->fields = NULL;
+
+ G_OBJECT_CLASS (gck_secret_search_parent_class)->finalize (obj);
+}
+
+static void
+gck_secret_search_class_init (GckSecretSearchClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GckObjectClass *gck_class = GCK_OBJECT_CLASS (klass);
+
+ gck_secret_search_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->constructor = gck_secret_search_constructor;
+ gobject_class->dispose = gck_secret_search_dispose;
+ gobject_class->finalize = gck_secret_search_finalize;
+ gobject_class->set_property = gck_secret_search_set_property;
+ gobject_class->get_property = gck_secret_search_get_property;
+
+ gck_class->get_attribute = gck_secret_search_get_attribute;
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+GHashTable*
+gck_secret_search_get_fields (GckSecretSearch *self)
+{
+ g_return_val_if_fail (GCK_IS_SECRET_SEARCH (self), NULL);
+ return self->fields;
+}
diff --git a/pkcs11/secret-store/gck-secret-search.h b/pkcs11/secret-store/gck-secret-search.h
new file mode 100644
index 0000000..450a808
--- /dev/null
+++ b/pkcs11/secret-store/gck-secret-search.h
@@ -0,0 +1,47 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2009 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#ifndef __GCK_SECRET_SEARCH_H__
+#define __GCK_SECRET_SEARCH_H__
+
+#include <glib-object.h>
+
+#include "gck/gck-object.h"
+
+#define GCK_TYPE_SECRET_SEARCH (gck_secret_search_get_type ())
+#define GCK_SECRET_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCK_TYPE_SECRET_SEARCH, GckSecretSearch))
+#define GCK_SECRET_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCK_TYPE_SECRET_SEARCH, GckSecretSearchClass))
+#define GCK_IS_SECRET_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCK_TYPE_SECRET_SEARCH))
+#define GCK_IS_SECRET_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCK_TYPE_SECRET_SEARCH))
+#define GCK_SECRET_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCK_TYPE_SECRET_SEARCH, GckSecretSearchClass))
+
+typedef struct _GckSecretSearch GckSecretSearch;
+typedef struct _GckSecretSearchClass GckSecretSearchClass;
+
+struct _GckSecretSearchClass {
+ GckObjectClass parent_class;
+};
+
+GType gck_secret_search_get_type (void);
+
+GHashTable* gck_secret_search_get_fields (GckSecretSearch *self);
+
+#endif /* __GCK_SECRET_SEARCH_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]