[libgnome-keyring] Make sure to return find results in original order from daemon



commit 0f8d16efc4f47815e6cbd908608aac44b2e68dc5
Author: Stef Walter <stefw collabora co uk>
Date:   Thu Oct 20 16:59:19 2011 +0200

    Make sure to return find results in original order from daemon
    
     * And add a testing tool to check the order

 .gitignore                         |    1 +
 library/gnome-keyring.c            |    3 ++
 library/tests/Makefile.am          |    3 +-
 library/tests/frob-list-modified.c |   71 ++++++++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6f1e09c..e88e649 100644
--- a/.gitignore
+++ b/.gitignore
@@ -120,6 +120,7 @@ run-auto-test.h
 /library/tests/test-keyrings
 /library/tests/test-memory
 /library/tests/test-other
+/library/tests/frob-list-modified
 
 # /po
 /po/*.gmo
diff --git a/library/gnome-keyring.c b/library/gnome-keyring.c
index 6e9a15b..aa55c88 100644
--- a/library/gnome-keyring.c
+++ b/library/gnome-keyring.c
@@ -2215,6 +2215,9 @@ find_items_6_reply (GkrOperation *op, DBusMessage *reply, gpointer data)
 	/* Do we have any more items? */
 	if (!args->queued) {
 		if (args->found) {
+			/* Back to the original order returned from daemon */
+			args->found = g_list_reverse (args->found);
+
 			cb = gkr_operation_pop (op);
 			gkr_callback_invoke_ok_list (cb, args->found);
 			if (cb->callback == find_items_sync)
diff --git a/library/tests/Makefile.am b/library/tests/Makefile.am
index b4d5ead..6139368 100644
--- a/library/tests/Makefile.am
+++ b/library/tests/Makefile.am
@@ -19,7 +19,8 @@ check_PROGRAMS = \
 
 noinst_PROGRAMS = \
 	frob-any-daemon \
-	frob-unlock-keyring
+	frob-unlock-keyring \
+	frob-list-modified
 
 test: $(TEST_PROGS)
 	gtester -k --verbose $(TEST_PROGS)
diff --git a/library/tests/frob-list-modified.c b/library/tests/frob-list-modified.c
new file mode 100644
index 0000000..e45f91a
--- /dev/null
+++ b/library/tests/frob-list-modified.c
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include "gnome-keyring.h"
+#include <glib.h>
+
+int
+main (int argc, char **argv)
+{
+	GnomeKeyringResult res;
+	gchar *date;
+	gchar *display;
+	GList *results, *l;
+	GnomeKeyringFound *found;
+	GnomeKeyringAttributeList *attributes;
+	GnomeKeyringItemInfo *info;
+	GDateTime *datetime;
+
+	g_test_init (&argc, &argv, NULL);
+	g_set_prgname ("frob-list-modified");
+
+	attributes = gnome_keyring_attribute_list_new ();
+
+	res = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                     attributes, &results);
+	g_assert_cmpint (res, ==, GNOME_KEYRING_RESULT_OK);
+
+	gnome_keyring_attribute_list_free (attributes);
+
+	for (l = results; l != NULL; l = g_list_next (l)) {
+		found = l->data;
+		res = gnome_keyring_item_get_info_sync (found->keyring, found->item_id, &info);
+		g_assert_cmpint (res, ==, GNOME_KEYRING_RESULT_OK);
+
+		datetime = g_date_time_new_from_unix_utc (gnome_keyring_item_info_get_mtime (info));
+		date = g_date_time_format (datetime, "%Y%m%dT%H%M%S");
+		display = gnome_keyring_item_info_get_display_name (info);
+		g_print ("%lu %s: %s/%u: %s\n", gnome_keyring_item_info_get_mtime (info),
+		         date, found->keyring, found->item_id, display);
+		g_date_time_unref (datetime);
+		g_free (date);
+		g_free (display);
+
+		gnome_keyring_item_info_free (info);
+	}
+
+	g_list_free (results);
+	return 0;
+}



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