[gnome-keyring/dbus-api: 2/7] [dbus] Implement Collection.Delete and Item.Delete
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api: 2/7] [dbus] Implement Collection.Delete and Item.Delete
- Date: Mon, 9 Nov 2009 17:12:18 +0000 (UTC)
commit dcaf24581674683fe92c5e62748cf6554050ce6e
Author: Stef Walter <stef memberwebs com>
Date: Sun Nov 8 18:37:14 2009 +0000
[dbus] Implement Collection.Delete and Item.Delete
Implement delete methods in the DBus secret service API.
daemon/data/introspect-collection.xml | 2 +-
daemon/data/introspect-item.xml | 1 +
daemon/dbus/gkd-secrets-objects.c | 50 +++++++++++++++++++++++++-
pkcs11/secret-store/gck-secret-collection.c | 3 +-
4 files changed, 52 insertions(+), 4 deletions(-)
---
diff --git a/daemon/data/introspect-collection.xml b/daemon/data/introspect-collection.xml
index 9fb57ec..07f1c1e 100644
--- a/daemon/data/introspect-collection.xml
+++ b/daemon/data/introspect-collection.xml
@@ -27,12 +27,12 @@
<interface name="org.freedesktop.Secrets.Collection">
<property name="Items" type="ao" access="read"/>
- <property name="Private" type="s" access="read"/>
<property name="Label" type="s" access="readwrite"/>
<property name="Locked" type="s" access="read"/>
<property name="Created" type="t" access="read"/>
<property name="Modified" type="t" access="read"/>
<method name="Delete">
+ <arg name="prompt" type="o" direction="out"/>
</method>
<method name="SearchItems">
<arg name="attributes" type="a{ss}" direction="in"/>
diff --git a/daemon/data/introspect-item.xml b/daemon/data/introspect-item.xml
index 7e0fc09..6dbf81c 100644
--- a/daemon/data/introspect-item.xml
+++ b/daemon/data/introspect-item.xml
@@ -32,6 +32,7 @@
<property name="Created" type="t" access="read"/>
<property name="Modified" type="t" access="read"/>
<method name="Delete">
+ <arg name="prompt" type="o" direction="out"/>
</method>
</interface>
diff --git a/daemon/dbus/gkd-secrets-objects.c b/daemon/dbus/gkd-secrets-objects.c
index c9c8b5d..628e11b 100644
--- a/daemon/dbus/gkd-secrets-objects.c
+++ b/daemon/dbus/gkd-secrets-objects.c
@@ -867,11 +867,36 @@ item_property_getall (GP11Object *object, DBusMessage *message)
}
static DBusMessage*
+item_method_delete (GkdSecretsObjects *self, GP11Object *object, DBusMessage *message)
+{
+ GError *error = NULL;
+ DBusMessage *reply;
+ const gchar *prompt;
+
+ if (!gp11_object_destroy (object, &error)) {
+ if (error->code == CKR_USER_NOT_LOGGED_IN)
+ reply = dbus_message_new_error_printf (message, DBUS_ERROR_FAILED,
+ "Cannot delete a locked item");
+ else
+ reply = dbus_message_new_error_printf (message, DBUS_ERROR_FAILED,
+ "Couldn't delete collection: %s",
+ error->message);
+ g_clear_error (&error);
+ return reply;
+ }
+
+ prompt = "/"; /* No prompt necessary */
+ reply = dbus_message_new_method_return (message);
+ dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &prompt, DBUS_TYPE_INVALID);
+ return reply;
+}
+
+static DBusMessage*
item_message_handler (GkdSecretsObjects *self, GP11Object *object, DBusMessage *message)
{
/* org.freedesktop.Secrets.Item.Delete() */
if (dbus_message_is_method_call (message, SECRETS_ITEM_INTERFACE, "Delete"))
- g_return_val_if_reached (NULL);
+ return item_method_delete (self, object, message);
/* org.freedesktop.DBus.Properties.Get */
if (dbus_message_is_method_call (message, PROPERTIES_INTERFACE, "Get"))
@@ -1050,11 +1075,32 @@ collection_method_search_items (GkdSecretsObjects *self, GP11Object *object, DBu
}
static DBusMessage*
+collection_method_delete (GkdSecretsObjects *self, GP11Object *object, DBusMessage *message)
+{
+ GError *error = NULL;
+ DBusMessage *reply;
+ const gchar *prompt;
+
+ if (!gp11_object_destroy (object, &error)) {
+ reply = dbus_message_new_error_printf (message, DBUS_ERROR_FAILED,
+ "Couldn't delete collection: %s",
+ error->message);
+ g_clear_error (&error);
+ return reply;
+ }
+
+ prompt = "/";
+ reply = dbus_message_new_method_return (message);
+ dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &prompt, DBUS_TYPE_INVALID);
+ return reply;
+}
+
+static DBusMessage*
collection_message_handler (GkdSecretsObjects *self, GP11Object *object, DBusMessage *message)
{
/* org.freedesktop.Secrets.Collection.Delete() */
if (dbus_message_is_method_call (message, SECRETS_COLLECTION_INTERFACE, "Delete"))
- g_return_val_if_reached (NULL);
+ return collection_method_delete (self, object, message);
/* org.freedesktop.Secrets.Collection.SearchItems() */
if (dbus_message_is_method_call (message, SECRETS_COLLECTION_INTERFACE, "SearchItems"))
diff --git a/pkcs11/secret-store/gck-secret-collection.c b/pkcs11/secret-store/gck-secret-collection.c
index 363f727..9029aa4 100644
--- a/pkcs11/secret-store/gck-secret-collection.c
+++ b/pkcs11/secret-store/gck-secret-collection.c
@@ -677,8 +677,9 @@ gck_secret_collection_save (GckSecretCollection *self, GckTransaction *transacti
g_return_if_fail (GCK_IS_TRANSACTION (transaction));
g_return_if_fail (!gck_transaction_get_failed (transaction));
+ /* HACK: We can't save unless the secret data was loaded */
if (!self->sdata)
- g_return_if_reached ();
+ return gck_transaction_fail (transaction, CKR_USER_NOT_LOGGED_IN);
master = gck_secret_data_get_master (self->sdata);
if (master == NULL || gck_secret_equals (master, NULL, 0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]