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



commit 617345edace57edc35a7b66cbb6b5830d47d7d9f
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Feb 28 17:06:55 2011 +0100

    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 don't expose this in the API so we simply put in a dummy value and
    don't barf.

 library/gkr-session.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/library/gkr-session.c b/library/gkr-session.c
index 9869f59..7070598 100644
--- a/library/gkr-session.c
+++ b/library/gkr-session.c
@@ -412,6 +412,7 @@ session_encode_secret (DBusMessageIter *iter, const gchar *path, gconstpointer p
                        gsize n_parameter, gconstpointer secret, gsize n_secret)
 {
 	DBusMessageIter struc, array;
+	const gchar *content_type = "text/plain; charset=utf8";
 
 	/* Write out the result message */
 	dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL, &struc);
@@ -422,6 +423,7 @@ session_encode_secret (DBusMessageIter *iter, const gchar *path, gconstpointer p
 	dbus_message_iter_open_container (&struc, DBUS_TYPE_ARRAY, "y", &array);
 	dbus_message_iter_append_fixed_array (&array, DBUS_TYPE_BYTE, &secret, n_secret);
 	dbus_message_iter_close_container (&struc, &array);
+	dbus_message_iter_append_basic (&struc, DBUS_TYPE_STRING, &content_type);
 	dbus_message_iter_close_container (iter, &struc);
 
 	return TRUE;
@@ -539,6 +541,14 @@ session_decode_secret (DBusMessageIter *iter, const char **path, gconstpointer *
 	dbus_message_iter_get_fixed_array (&array, secret, &n_elements);
 	*n_secret = n_elements;
 
+	/*
+	 * content_type: We have no use for the content-type, but check
+	 * that it's there...
+	 */
+	if (!dbus_message_iter_next (&struc) ||
+	    dbus_message_iter_get_arg_type (&struc) != DBUS_TYPE_STRING)
+		return FALSE;
+
 	return TRUE;
 }
 



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