[gnome-keyring: 1/2] [dbus] Send a content-type along with secret as per spec.



commit 24d586d74b4959cf7d103a3b9a76a9de5796b281
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Feb 28 16:59:37 2011 +0100

    [dbus] Send a content-type along with secret as per spec.
    
    Recent changes to the secret service spec say we should be sending
    a content-type along with the secret. This changes the signature of
    a secret structure to (oayays).
    
    We have nowhere to store this content-type so we simply accept and
    ignore it, and return a place holder value where necessary.
    
    This is an incompatible change to the dbus specification and both
    gnome-keyring and libgnome-keyring need to be upgraded in sync.

 daemon/data/introspect-collection.xml |    2 +-
 daemon/data/introspect-item.xml       |    4 ++--
 daemon/data/introspect-service.xml    |    2 +-
 daemon/dbus/gkd-secret-objects.c      |    6 +++---
 daemon/dbus/gkd-secret-secret.c       |   20 +++++++++++++++++++-
 daemon/dbus/gkd-secret-service.c      |    6 +++---
 6 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/daemon/data/introspect-collection.xml b/daemon/data/introspect-collection.xml
index 61b151f..0c8c712 100644
--- a/daemon/data/introspect-collection.xml
+++ b/daemon/data/introspect-collection.xml
@@ -40,7 +40,7 @@
 		</method>
 		<method name="CreateItem">
 			<arg name="props" type="a{sv}" direction="in"/>
-			<arg name="secret" type="(oayay)" direction="in"/>
+			<arg name="secret" type="(oayays)" direction="in"/>
 			<arg name="replace" type="b" direction="in"/>
 			<arg name="item" type="o" direction="out"/>
 			<arg name="prompt" type="o" direction="out"/>
diff --git a/daemon/data/introspect-item.xml b/daemon/data/introspect-item.xml
index 753025c..3f920fb 100644
--- a/daemon/data/introspect-item.xml
+++ b/daemon/data/introspect-item.xml
@@ -37,10 +37,10 @@
 		</method>
 		<method name="GetSecret">
 			<arg name="session" type="o" direction="in"/>
-			<arg name="secret" type="(oayay)" direction="out"/>
+			<arg name="secret" type="(oayays)" direction="out"/>
 		</method>
 		<method name="SetSecret">
-			<arg name="secret" type="(oayay)" direction="in"/>
+			<arg name="secret" type="(oayays)" direction="in"/>
 		</method>
 	</interface>
 
diff --git a/daemon/data/introspect-service.xml b/daemon/data/introspect-service.xml
index 0c955b5..f5196d7 100644
--- a/daemon/data/introspect-service.xml
+++ b/daemon/data/introspect-service.xml
@@ -63,7 +63,7 @@
 		<method name="GetSecrets">
 			<arg name="items" type="ao" direction="in"/>
 			<arg name="session" type="o" direction="in"/>
-			<arg name="secrets" type="a{o(oayay)}" direction="out"/>
+			<arg name="secrets" type="a{o(oayays)}" direction="out"/>
 		</method>
 
 		<method name="ReadAlias">
diff --git a/daemon/dbus/gkd-secret-objects.c b/daemon/dbus/gkd-secret-objects.c
index a39e3e4..fa1fa77 100644
--- a/daemon/dbus/gkd-secret-objects.c
+++ b/daemon/dbus/gkd-secret-objects.c
@@ -408,7 +408,7 @@ item_method_set_secret (GkdSecretObjects *self, GckObject *item, DBusMessage *me
 	GkdSecretSecret *secret;
 	const char *caller;
 
-	if (!dbus_message_has_signature (message, "(oayay)"))
+	if (!dbus_message_has_signature (message, "(oayays)"))
 		return NULL;
 	dbus_message_iter_init (message, &iter);
 	secret = gkd_secret_secret_parse (self->service, message, &iter, &derr);
@@ -661,7 +661,7 @@ collection_method_create_item (GkdSecretObjects *self, GckObject *object, DBusMe
 	gboolean created = FALSE;
 
 	/* Parse the message */
-	if (!dbus_message_has_signature (message, "a{sv}(oayay)b"))
+	if (!dbus_message_has_signature (message, "a{sv}(oayays)b"))
 		return NULL;
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (NULL);
@@ -1292,7 +1292,7 @@ gkd_secret_objects_handle_get_secrets (GkdSecretObjects *self, DBusMessage *mess
 
 	reply = dbus_message_new_method_return (message);
 	dbus_message_iter_init_append (reply, &iter);
-	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{o(oayay)}", &array);
+	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{o(oayays)}", &array);
 
 	for (i = 0; i < n_paths; ++i) {
 
diff --git a/daemon/dbus/gkd-secret-secret.c b/daemon/dbus/gkd-secret-secret.c
index 83afd19..9cc44b7 100644
--- a/daemon/dbus/gkd-secret-secret.c
+++ b/daemon/dbus/gkd-secret-secret.c
@@ -71,7 +71,7 @@ gkd_secret_secret_parse (GkdSecretService *service, DBusMessage *message,
 	DBusMessageIter struc, array;
 	void *parameter, *value;
 	int n_value, n_parameter;
-	char *path;
+	char *path, *content_type;
 
 	g_return_val_if_fail (GKD_SECRET_IS_SERVICE (service), NULL);
 	g_return_val_if_fail (message, NULL);
@@ -107,6 +107,17 @@ gkd_secret_secret_parse (GkdSecretService *service, DBusMessage *message,
 	dbus_message_iter_recurse (&struc, &array);
 	dbus_message_iter_get_fixed_array (&array, &value, &n_value);
 
+	/*
+	 * TODO: We currently don't do anythinrg with the content type, because
+	 * we have nowhere to store it.
+	 */
+	if (!dbus_message_iter_next (&struc) ||
+	    dbus_message_iter_get_arg_type (&struc) != DBUS_TYPE_STRING) {
+		dbus_set_error (derr, DBUS_ERROR_INVALID_ARGS, "Invalid content type argument");
+		return NULL;
+	}
+	dbus_message_iter_get_basic (&struc, &content_type);
+
 	/* Try to lookup the session */
 	session = gkd_secret_service_lookup_session (service, path,
 	                                             dbus_message_get_sender (message));
@@ -133,6 +144,7 @@ gkd_secret_secret_parse (GkdSecretService *service, DBusMessage *message,
 void
 gkd_secret_secret_append (GkdSecretSecret *secret, DBusMessageIter *iter)
 {
+	const gchar *content_type = "application/octet-stream";
 	DBusMessageIter struc, array;
 	const gchar *path;
 	int length;
@@ -150,6 +162,12 @@ gkd_secret_secret_append (GkdSecretSecret *secret, DBusMessageIter *iter)
 	length = secret->n_value;
 	dbus_message_iter_append_fixed_array (&array, DBUS_TYPE_BYTE, &(secret->value), length);
 	dbus_message_iter_close_container (&struc, &array);
+
+	/*
+	 * TODO: We're just putting a place holder value here for now.
+	 */
+	dbus_message_iter_append_basic (&struc, DBUS_TYPE_STRING, &content_type);
+
 	dbus_message_iter_close_container (iter, &struc);
 }
 
diff --git a/daemon/dbus/gkd-secret-service.c b/daemon/dbus/gkd-secret-service.c
index bac9a5f..667e25d 100644
--- a/daemon/dbus/gkd-secret-service.c
+++ b/daemon/dbus/gkd-secret-service.c
@@ -665,7 +665,7 @@ service_method_create_with_master_password (GkdSecretService *self, DBusMessage
 	gchar *path;
 
 	/* Parse the incoming message */
-	if (!dbus_message_has_signature (message, "a{sv}(oayay)"))
+	if (!dbus_message_has_signature (message, "a{sv}(oayays)"))
 		return NULL;
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (NULL);
@@ -709,7 +709,7 @@ service_method_change_with_master_password (GkdSecretService *self, DBusMessage
 	const gchar *path;
 
 	/* Parse the incoming message */
-	if (!dbus_message_has_signature (message, "o(oayay)(oayay)"))
+	if (!dbus_message_has_signature (message, "o(oayays)(oayays)"))
 		return NULL;
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (NULL);
@@ -763,7 +763,7 @@ service_method_unlock_with_master_password (GkdSecretService *self, DBusMessage
 	const gchar *path;
 
 	/* Parse the incoming message */
-	if (!dbus_message_has_signature (message, "o(oayay)"))
+	if (!dbus_message_has_signature (message, "o(oayays)"))
 		return NULL;
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]