[tracker/rss-enclosures] libtracker-client: Drop tracker_result_iterator_has_next
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] libtracker-client: Drop tracker_result_iterator_has_next
- Date: Sat, 26 Jun 2010 23:27:20 +0000 (UTC)
commit 952cbd92b68db123fd146f4233d20d3b0d71c71b
Author: Jürg Billeter <j bitron ch>
Date: Tue Jun 22 15:12:05 2010 +0200
libtracker-client: Drop tracker_result_iterator_has_next
Merged into tracker_result_iterator_next to simplify API.
examples/tracker-steroids/benchmark-tracker-ipc.c | 4 +-
examples/tracker-steroids/benchmark.c | 4 +-
examples/tracker-steroids/steroids-sparql-async.c | 4 +-
examples/tracker-steroids/steroids-sparql.c | 4 +-
src/libtracker-client/tracker.c | 49 +++++----------------
src/libtracker-client/tracker.h | 3 +-
src/libtracker-miner/tracker-miner-fs.c | 12 ++---
src/miners/fs/tracker-miner-files-reindex.c | 4 +-
src/miners/fs/tracker-miner-files.c | 3 +-
tests/tracker-steroids/tracker-test.c | 13 ++----
10 files changed, 27 insertions(+), 73 deletions(-)
---
diff --git a/examples/tracker-steroids/benchmark-tracker-ipc.c b/examples/tracker-steroids/benchmark-tracker-ipc.c
index e39045e..e2d263b 100644
--- a/examples/tracker-steroids/benchmark-tracker-ipc.c
+++ b/examples/tracker-steroids/benchmark-tracker-ipc.c
@@ -70,9 +70,7 @@ main (int argc, char **argv)
iterator = tracker_resources_sparql_query_iterate (client, query, &error);
- while (tracker_result_iterator_has_next (iterator)) {
- tracker_result_iterator_next (iterator);
-
+ while (tracker_result_iterator_next (iterator)) {
for (i = 0; i < tracker_result_iterator_n_columns (iterator); i++) {
const char *data;
diff --git a/examples/tracker-steroids/benchmark.c b/examples/tracker-steroids/benchmark.c
index f74c9f3..497a9e6 100644
--- a/examples/tracker-steroids/benchmark.c
+++ b/examples/tracker-steroids/benchmark.c
@@ -70,9 +70,7 @@ main (int argc, char **argv)
iterator = tracker_resources_sparql_query_iterate (client, query, &error);
- while (tracker_result_iterator_has_next (iterator)) {
- tracker_result_iterator_next (iterator);
-
+ while (tracker_result_iterator_next (iterator)) {
for (i = 0; i < tracker_result_iterator_n_columns (iterator); i++) {
const char *data;
diff --git a/examples/tracker-steroids/steroids-sparql-async.c b/examples/tracker-steroids/steroids-sparql-async.c
index 24b24e2..698c934 100644
--- a/examples/tracker-steroids/steroids-sparql-async.c
+++ b/examples/tracker-steroids/steroids-sparql-async.c
@@ -36,11 +36,9 @@ query_cb (TrackerResultIterator *iterator,
exit (EXIT_FAILURE);
}
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
int i;
- tracker_result_iterator_next (iterator);
-
for (i = 0; i < tracker_result_iterator_n_columns (iterator); i++) {
g_print ("%s", tracker_result_iterator_value (iterator, i));
diff --git a/examples/tracker-steroids/steroids-sparql.c b/examples/tracker-steroids/steroids-sparql.c
index ecf2a2c..719d9dc 100644
--- a/examples/tracker-steroids/steroids-sparql.c
+++ b/examples/tracker-steroids/steroids-sparql.c
@@ -47,11 +47,9 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
gint i;
- tracker_result_iterator_next (iterator);
-
for (i = 0; i < tracker_result_iterator_n_columns (iterator); i++) {
g_print ("%s", tracker_result_iterator_value (iterator, i));
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index a47fcc1..a22138b 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -1699,9 +1699,7 @@ tracker_resources_sparql_query (TrackerClient *client,
* return;
* }
*
- * while (tracker_result_iterator_has_next (iterator)) {
- * tracker_result_iterator_next (iterator);
- *
+ * while (tracker_result_iterator_next (iterator)) {
* g_message ("Album: %s, Title: %s",
* tracker_result_iterator_value (iterator, 0),
* tracker_result_iterator_value (iterator, 1));
@@ -1902,40 +1900,16 @@ tracker_result_iterator_n_columns (TrackerResultIterator *iterator)
}
/**
- * tracker_result_iterator_has_next:
- * @iterator: A TrackerResultIterator
- *
- * Checks if the iterator has more rows
- *
- * Returns: %TRUE if there are more rows to fetch, otherwise %FALSE.
- *
- * Since: 0.9
- **/
-gboolean
-tracker_result_iterator_has_next (TrackerResultIterator *iterator)
-{
- g_return_val_if_fail (iterator != NULL, FALSE);
-
-#ifdef HAVE_DBUS_FD_PASSING
- return iterator->buffer_index < iterator->buffer_size;
-#else /* HAVE_DBUS_FD_PASSING */
- if (!iterator->results->len) {
- return FALSE;
- }
-
- return (iterator->current_row < (gint) (iterator->results->len - 1));
-#endif /* HAVE_DBUS_FD_PASSING */
-}
-
-/**
* tracker_result_iterator_next:
* @iterator: A TrackerResultIterator
*
* Fetches the next row for the results.
*
+ * Returns: %TRUE if a rows was fetched, otherwise %FALSE.
+ *
* Since: 0.9
**/
-void
+gboolean
tracker_result_iterator_next (TrackerResultIterator *iterator)
{
g_return_if_fail (iterator != NULL);
@@ -1943,8 +1917,8 @@ tracker_result_iterator_next (TrackerResultIterator *iterator)
#ifdef HAVE_DBUS_FD_PASSING
int last_offset;
- if (!tracker_result_iterator_has_next (iterator)) {
- return;
+ if (iterator->buffer_index >= iterator->buffer_size) {
+ return FALSE;
}
/* So, the make up on each iterator segment is:
@@ -1961,13 +1935,14 @@ tracker_result_iterator_next (TrackerResultIterator *iterator)
last_offset = iterator_buffer_read_int (iterator);
iterator->data = iterator->buffer + iterator->buffer_index;
iterator->buffer_index += last_offset + 1;
-#else /* HAVE_DBUS_FD_PASSING */
- if (!iterator->results->len) {
- return;
- }
- if (iterator->current_row < (gint)iterator->results->len) {
+ return TRUE;
+#else /* HAVE_DBUS_FD_PASSING */
+ if (iterator->current_row < (gint)iterator->results->len - 1) {
iterator->current_row++;
+ return TRUE;
+ } else {
+ return FALSE;
}
#endif /* HAVE_DBUS_FD_PASSING */
}
diff --git a/src/libtracker-client/tracker.h b/src/libtracker-client/tracker.h
index 79b4fa9..a3dea6e 100644
--- a/src/libtracker-client/tracker.h
+++ b/src/libtracker-client/tracker.h
@@ -145,8 +145,7 @@ TrackerResultIterator *
GError **error);
void tracker_result_iterator_free (TrackerResultIterator *iterator);
guint tracker_result_iterator_n_columns (TrackerResultIterator *iterator);
-gboolean tracker_result_iterator_has_next (TrackerResultIterator *iterator);
-void tracker_result_iterator_next (TrackerResultIterator *iterator);
+gboolean tracker_result_iterator_next (TrackerResultIterator *iterator);
const gchar * tracker_result_iterator_value (TrackerResultIterator *iterator,
guint column);
void tracker_resources_sparql_update (TrackerClient *client,
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ea326fb..bb587e8 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1077,12 +1077,10 @@ sparql_query_cb (GObject *object,
}
if (!iterator ||
- !tracker_result_iterator_has_next (iterator))
+ !tracker_result_iterator_next (iterator))
return;
- tracker_result_iterator_next (iterator);
-
- if (!tracker_result_iterator_has_next (iterator)) {
+ if (!tracker_result_iterator_next (iterator)) {
data->iri = g_strdup (tracker_result_iterator_value (iterator, 0));
if (data->get_mime)
data->mime = g_strdup (tracker_result_iterator_value (iterator, 1));
@@ -1165,10 +1163,9 @@ cache_query_cb (GObject *object,
return;
}
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
GFile *file;
- tracker_result_iterator_next (iterator);
file = g_file_new_for_uri (tracker_result_iterator_value (iterator, 0));
g_hash_table_insert (data->values,
@@ -1648,11 +1645,10 @@ item_update_children_uri_cb (GObject *object,
g_critical ("Could not query children: %s", error->message);
g_error_free (error);
} else if (iterator) {
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
const gchar *child_source_uri, *child_mime, *child_urn;
gchar *child_uri;
- tracker_result_iterator_next (iterator);
child_urn = tracker_result_iterator_value (iterator, 0);
child_source_uri = tracker_result_iterator_value (iterator, 1);
child_mime = tracker_result_iterator_value (iterator, 2);
diff --git a/src/miners/fs/tracker-miner-files-reindex.c b/src/miners/fs/tracker-miner-files-reindex.c
index 70e4346..a510843 100644
--- a/src/miners/fs/tracker-miner-files-reindex.c
+++ b/src/miners/fs/tracker-miner-files-reindex.c
@@ -174,9 +174,7 @@ mime_types_cb (TrackerResultIterator *iterator,
tracker_dbus_request_comment (mtd->request_id, mtd->context,
"Found files that will need reindexing");
- while (tracker_result_iterator_has_next (iterator)) {
- tracker_result_iterator_next (iterator);
-
+ while (tracker_result_iterator_next (iterator)) {
if (tracker_result_iterator_value (iterator, 0)) {
const gchar *url = (const gchar *) tracker_result_iterator_value (iterator, 0);
GFile *file = g_file_new_for_uri (url);
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index eb36f51..9bf0e9e 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -767,13 +767,12 @@ query_mount_points_cb (GObject *source,
g_strdup (TRACKER_NON_REMOVABLE_MEDIA_DATASOURCE_URN),
GINT_TO_POINTER (VOLUME_MOUNTED));
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
gint state;
const gchar *urn;
state = VOLUME_MOUNTED_IN_STORE;
- tracker_result_iterator_next (iterator);
urn = tracker_result_iterator_value (iterator, 0);
if (strcmp (urn, TRACKER_NON_REMOVABLE_MEDIA_DATASOURCE_URN) == 0) {
diff --git a/tests/tracker-steroids/tracker-test.c b/tests/tracker-steroids/tracker-test.c
index 7adbbee..f2b2d2c 100644
--- a/tests/tracker-steroids/tracker-test.c
+++ b/tests/tracker-steroids/tracker-test.c
@@ -180,14 +180,13 @@ test_tracker_sparql_query_iterate ()
g_assert (!error);
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
GStrv row;
g_assert (i < r1->len);
n_rows ++;
- tracker_result_iterator_next (iterator);
row = g_ptr_array_index (r1, i++);
g_assert (!g_strcmp0 (tracker_result_iterator_value (iterator, 0), row[0]));
@@ -219,14 +218,13 @@ test_tracker_sparql_query_iterate_largerow ()
g_assert (!error);
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
GStrv row;
g_assert (i < r1->len);
n_rows ++;
- tracker_result_iterator_next (iterator);
row = g_ptr_array_index (r1, i++);
g_assert (!g_strcmp0 (tracker_result_iterator_value (iterator, 0), row[0]));
@@ -269,15 +267,13 @@ test_tracker_sparql_query_iterate_empty ()
g_assert (iterator);
g_assert (!error);
- g_assert (!tracker_result_iterator_has_next (iterator));
+ g_assert (!tracker_result_iterator_next (iterator));
g_assert (!tracker_result_iterator_n_columns (iterator));
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) {
tracker_result_iterator_value (iterator, 0);
exit (0);
}
g_test_trap_assert_failed ();
- /* And just to make coverage happy... */
- tracker_result_iterator_next (iterator);
}
static void
@@ -455,12 +451,11 @@ async_query_cb (TrackerResultIterator *iterator,
g_assert (!inner_error);
- while (tracker_result_iterator_has_next (iterator)) {
+ while (tracker_result_iterator_next (iterator)) {
GStrv row;
g_assert (i < r1->len);
- tracker_result_iterator_next (iterator);
row = g_ptr_array_index (r1, i++);
g_assert (!g_strcmp0 (tracker_result_iterator_value (iterator, 0), row[0]));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]