[tracker/dbus-fd-experiment: 10/13] Add example steroids client
- From: Adrien Bustany <abustany src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dbus-fd-experiment: 10/13] Add example steroids client
- Date: Mon, 24 May 2010 14:29:37 +0000 (UTC)
commit 64226d2078c2077b39f05c0ad96f142deb118c39
Author: Adrien Bustany <abustany gnome org>
Date: Mon May 24 08:53:18 2010 -0400
Add example steroids client
configure.ac | 1 +
examples/Makefile.am | 3 +-
examples/steroids/Makefile.am | 31 +++++++++++++++++++++
examples/steroids/steroids-sparql.c | 51 +++++++++++++++++++++++++++++++++++
4 files changed, 85 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7f506a9..0eefae9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1931,6 +1931,7 @@ AC_CONFIG_FILES([
examples/libtracker-extract/Makefile
examples/libtracker-miner/Makefile
examples/rss-reader/Makefile
+ examples/steroids/Makefile
])
AC_OUTPUT
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 41a8a67..2eacd64 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -3,4 +3,5 @@ include $(top_srcdir)/Makefile.decl
SUBDIRS = \
libtracker-extract \
libtracker-miner \
- rss-reader
+ rss-reader \
+ steroids
diff --git a/examples/steroids/Makefile.am b/examples/steroids/Makefile.am
new file mode 100644
index 0000000..19fe433
--- /dev/null
+++ b/examples/steroids/Makefile.am
@@ -0,0 +1,31 @@
+include $(top_srcdir)/Makefile.decl
+
+INCLUDES = \
+ -DSHAREDIR=\""$(datadir)"\" \
+ -DG_LOG_DOMAIN=\"Tracker\" \
+ -DTRACKER_COMPILATION \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ -I$(top_builddir)/src/libtracker-client \
+ $(WARN_CFLAGS) \
+ $(GLIB2_CFLAGS) \
+ $(GCOV_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(DBUS_CFLAGS)
+
+noinst_PROGRAMS = steroids-sparql
+
+steroids_sparql_SOURCES = \
+ steroids-sparql.c
+
+steroids_sparql_LDADD = \
+ $(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
+ $(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(DBUS_LIBS) \
+ $(GMODULE_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GIO_LIBS) \
+ $(GCOV_LIBS) \
+ $(GLIB2_LIBS) \
+ -lz \
+ -lm
diff --git a/examples/steroids/steroids-sparql.c b/examples/steroids/steroids-sparql.c
new file mode 100644
index 0000000..278e033
--- /dev/null
+++ b/examples/steroids/steroids-sparql.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <libtracker-client/tracker.h>
+
+int
+main (int argc, char **argv) {
+ const char *query;
+ TrackerClient *client;
+ GError *error = NULL;
+ TrackerResultIterator *iterator;
+
+ if (argc != 2) {
+ fprintf (stderr, "Usage: %s query\n", argv[0]);
+ exit (1);
+ }
+
+ query = argv[1];
+
+ client = tracker_client_new (0, 0);
+
+ iterator = tracker_resources_sparql_query_steroids (client, query, &error);
+
+ if (!iterator) {
+ fprintf (stderr, "Query failed, but errors are not supported yet :-/\n");
+ exit (1);
+ }
+
+ while (tracker_result_iterator_has_next (iterator)) {
+ int i;
+
+ tracker_result_iterator_next (iterator, &error);
+
+ // TODO: Check for error here
+
+ for (i = 0; i < tracker_result_iterator_n_columns (iterator); i++) {
+ printf ("%s", tracker_result_iterator_value (iterator, i));
+
+ if (i != tracker_result_iterator_n_columns (iterator) - 1) {
+ printf (", ");
+ }
+ }
+
+ printf ("\n");
+ }
+
+ tracker_result_iterator_free (iterator);
+ g_object_unref (client);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]