[tracker/direct-access: 79/121] tracker-miner-rss: Fixed compiler errors and use new libtracker-sparql
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 79/121] tracker-miner-rss: Fixed compiler errors and use new libtracker-sparql
- Date: Thu, 22 Jul 2010 14:50:29 +0000 (UTC)
commit 84e07823961412b03ee0a16fa02a60d2f3099e3f
Author: Martyn Russell <martyn lanedo com>
Date: Tue Jul 20 13:12:48 2010 +0100
tracker-miner-rss: Fixed compiler errors and use new libtracker-sparql
src/libtracker-bus/tracker-bus.vala | 8 +--
src/libtracker-sparql/tracker-connection.vala | 7 ++
src/miners/rss/Makefile.am | 4 +-
src/miners/rss/tracker-miner-rss.c | 109 ++++++++++++++-----------
src/miners/rss/tracker-miner-rss.h | 2 +
5 files changed, 73 insertions(+), 57 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index cf1d75a..480abed 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -17,12 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-public const string TRACKER_DBUS_SERVICE = "org.freedesktop.Tracker1";
-public const string TRACKER_DBUS_INTERFACE_RESOURCES = TRACKER_DBUS_SERVICE + ".Resources";
-public const string TRACKER_DBUS_OBJECT_RESOURCES = "/org/freedesktop/Tracker1/Resources";
-public const string TRACKER_DBUS_INTERFACE_STEROIDS = TRACKER_DBUS_SERVICE + ".Steroids";
-public const string TRACKER_DBUS_OBJECT_STEROIDS = "/org/freedesktop/Tracker1/Steroids";
-
+// Note: DBus name below can NOT be a defined string as above, compiler error
+// due to the order Vala evaluates strings and interfaces apparently.
[DBus (name = "org.freedesktop.Tracker1.Resources")]
private interface Tracker.Bus.Resources : GLib.Object {
public abstract string[,] sparql_query (string query) throws DBus.Error;
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 606b30b..e7d5ef4 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -17,6 +17,13 @@
* Boston, MA 02110-1301, USA.
*/
+// Convenience
+public const string TRACKER_DBUS_SERVICE = "org.freedesktop.Tracker1";
+public const string TRACKER_DBUS_INTERFACE_RESOURCES = TRACKER_DBUS_SERVICE + ".Resources";
+public const string TRACKER_DBUS_OBJECT_RESOURCES = "/org/freedesktop/Tracker1/Resources";
+public const string TRACKER_DBUS_INTERFACE_STEROIDS = TRACKER_DBUS_SERVICE + ".Steroids";
+public const string TRACKER_DBUS_OBJECT_STEROIDS = "/org/freedesktop/Tracker1/Steroids";
+
public abstract class Tracker.Sparql.Connection : Object {
static bool direct_only;
static weak Connection? singleton;
diff --git a/src/miners/rss/Makefile.am b/src/miners/rss/Makefile.am
index 316b178..958ed84 100644
--- a/src/miners/rss/Makefile.am
+++ b/src/miners/rss/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES = \
-DTRACKER_COMPILATION \
-I$(top_srcdir)/src \
-I$(top_builddir)/src \
- -I$(top_builddir)/src/libtracker-client \
+ -I$(top_builddir)/src/libtracker-sparql \
$(WARN_CFLAGS) \
$(GMODULE_CFLAGS) \
$(DBUS_CFLAGS) \
@@ -24,7 +24,7 @@ tracker_miner_rss_SOURCES = \
tracker-miner-rss.c
tracker_miner_rss_LDADD = \
- $(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
+ $(top_builddir)/src/libtracker-sparql/libtracker-sparql- TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(LIBGRSS_LIBS) \
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index d4ef515..fe5ff7f 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -32,8 +32,8 @@
#define TRACKER_MINER_RSS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_MINER_RSS, TrackerMinerRSSPrivate))
-#define TRACKER_DBUS_OBJECT_FEED TRACKER_DBUS_OBJECT "/Resources/Classes/mfo/FeedChannel"
#define TRACKER_DBUS_INTERFACE_FEED TRACKER_DBUS_INTERFACE_RESOURCES ".Class"
+#define TRACKER_DBUS_OBJECT_FEED TRACKER_DBUS_OBJECT_RESOURCES "/Classes/mfo/FeedChannel"
typedef struct _TrackerMinerRSSPrivate TrackerMinerRSSPrivate;
@@ -140,7 +140,7 @@ tracker_miner_rss_init (TrackerMinerRSS *object)
}
proxy = dbus_g_proxy_new_for_name (connection,
- TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_SERVICE, /* org.freedesktop.Tracker1 */
TRACKER_DBUS_OBJECT_FEED,
TRACKER_DBUS_INTERFACE_FEED);
@@ -182,7 +182,7 @@ verify_channel_update (GObject *source,
error = NULL;
- tracker_miner_execute_update_finish (TRACKER_MINER (source), result, &error);
+ tracker_sparql_connection_update_finish (TRACKER_SPARQL_CONNECTION (source), result, &error);
if (error != NULL) {
g_critical ("Could not update channel information, %s", error->message);
g_error_free (error);
@@ -220,11 +220,13 @@ update_updated_interval (TrackerMinerRSS *miner,
tracker_sparql_builder_object_date (sparql, now);
tracker_sparql_builder_insert_close (sparql);
- tracker_miner_execute_update (TRACKER_MINER (miner),
- tracker_sparql_builder_get_result (sparql),
- NULL,
- verify_channel_update,
- NULL);
+ /* FIXME: Should be async */
+ tracker_sparql_connection_update_async (tracker_miner_get_connection (TRACKER_MINER (miner)),
+ tracker_sparql_builder_get_result (sparql),
+ G_PRIORITY_DEFAULT,
+ NULL,
+ verify_channel_update,
+ NULL);
g_object_unref (sparql);
}
@@ -265,7 +267,7 @@ verify_item_insertion (GObject *source,
error = NULL;
- tracker_miner_execute_update_finish (TRACKER_MINER (source), result, &error);
+ tracker_sparql_connection_update_finish (TRACKER_SPARQL_CONNECTION (source), result, &error);
if (error != NULL) {
g_critical ("Could not insert feed information, %s", error->message);
g_error_free (error);
@@ -279,12 +281,12 @@ item_verify_reply_cb (GObject *source_object,
{
time_t t;
gchar *uri;
- gchar **values;
+ const gchar *str;
const gchar *url;
gdouble latitude;
gdouble longitude;
const gchar *tmp_string;
- const GPtrArray *response;
+ TrackerSparqlCursor *cursor;
GError *error;
TrackerSparqlBuilder *sparql;
FeedItem *item;
@@ -294,9 +296,9 @@ item_verify_reply_cb (GObject *source_object,
miner = TRACKER_MINER_RSS (source_object);
error = NULL;
- response = tracker_miner_execute_sparql_finish (TRACKER_MINER (source_object),
- res,
- &error);
+ cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (source_object),
+ res,
+ &error);
if (error != NULL) {
g_message ("Could not verify feed existance, %s", error->message);
@@ -304,8 +306,13 @@ item_verify_reply_cb (GObject *source_object,
return;
}
- values = g_ptr_array_index (response, 0);
- if (g_strcmp0 (values[0], "1") == 0) {
+ if (!tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+ g_message ("No data in query response??");
+ return;
+ }
+
+ str = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+ if (g_strcmp0 (str, "1") == 0) {
return;
}
@@ -394,11 +401,12 @@ item_verify_reply_cb (GObject *source_object,
tracker_sparql_builder_insert_close (sparql);
- tracker_miner_execute_update (TRACKER_MINER (miner),
- tracker_sparql_builder_get_result (sparql),
- NULL,
- verify_item_insertion,
- NULL);
+ tracker_sparql_connection_update_async (tracker_miner_get_connection (TRACKER_MINER (miner)),
+ tracker_sparql_builder_get_result (sparql),
+ G_PRIORITY_DEFAULT,
+ NULL,
+ verify_item_insertion,
+ NULL);
g_object_unref (sparql);
}
@@ -423,11 +431,11 @@ check_if_save (TrackerMinerRSS *miner,
url,
communication_channel);
- tracker_miner_execute_sparql (TRACKER_MINER (miner),
- query,
- NULL,
- item_verify_reply_cb,
- item);
+ tracker_sparql_connection_query_async (tracker_miner_get_connection (TRACKER_MINER (miner)),
+ query,
+ NULL,
+ item_verify_reply_cb,
+ item);
g_free (query);
}
@@ -471,19 +479,15 @@ feeds_retrieve_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- gint interval;
- guint i;
- gchar **values;
GList *channels;
- const GPtrArray *response;
- GError *error;
+ TrackerSparqlCursor *cursor;
+ GError *error = NULL;
TrackerMinerRSSPrivate *priv;
FeedChannel *chan;
- error = NULL;
- response = tracker_miner_execute_sparql_finish (TRACKER_MINER (source_object),
- res,
- &error);
+ cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (source_object),
+ res,
+ &error);
if (error != NULL) {
g_message ("Could not retrieve feeds, %s", error->message);
@@ -493,26 +497,33 @@ feeds_retrieve_cb (GObject *source_object,
channels = NULL;
- g_message ("Found %d feeds", response->len);
+ g_message ("Found feeds");
+
+ while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+ const gchar *source;
+ const gchar *interval;
+ const gchar *subject;
+ gint mins;
- for (i = 0; i < response->len; i++) {
- values = g_ptr_array_index (response, i);
+ source = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+ interval = tracker_sparql_cursor_get_string (cursor, 1, NULL);
+ subject = tracker_sparql_cursor_get_string (cursor, 2, NULL);
chan = feed_channel_new ();
g_object_set_data_full (G_OBJECT (chan),
"subject",
- g_strdup (values [2]),
+ g_strdup (subject),
g_free);
- feed_channel_set_source (chan, values [0]);
+ feed_channel_set_source (chan, g_strdup (source));
/* TODO How to manage feeds with an update mfo:updateInterval == 0 ?
* Here the interval is forced to be at least 1 minute, but perhaps those
* elements are to be considered "disabled"
*/
- interval = strtoull (values [1], NULL, 10);
- if (interval <= 0)
- interval = 1;
- feed_channel_set_update_interval (chan, interval);
+ mins = strtoull (interval, NULL, 10);
+ if (mins <= 0)
+ mins = 1;
+ feed_channel_set_update_interval (chan, mins);
channels = g_list_prepend (channels, chan);
}
@@ -534,11 +545,11 @@ retrieve_and_schedule_feeds (TrackerMinerRSS *miner)
"?chanUrn nie:url ?chanUrl . "
"?settings mfo:updateInterval ?interval }";
- tracker_miner_execute_sparql (TRACKER_MINER (miner),
- sparql,
- NULL,
- feeds_retrieve_cb,
- NULL);
+ tracker_sparql_connection_query_async (tracker_miner_get_connection (TRACKER_MINER (miner)),
+ sparql,
+ NULL,
+ feeds_retrieve_cb,
+ NULL);
}
static const gchar *
diff --git a/src/miners/rss/tracker-miner-rss.h b/src/miners/rss/tracker-miner-rss.h
index 3977a4a..e46f23a 100644
--- a/src/miners/rss/tracker-miner-rss.h
+++ b/src/miners/rss/tracker-miner-rss.h
@@ -23,6 +23,8 @@
#include <libtracker-miner/tracker-miner.h>
+#include <libtracker-sparql/tracker-sparql.h>
+
G_BEGIN_DECLS
#define TRACKER_TYPE_MINER_RSS (tracker_miner_rss_get_type())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]