[tracker] plugins/evolution: Make it possible to compile the evolution plugin, not working yet
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] plugins/evolution: Make it possible to compile the evolution plugin, not working yet
- Date: Mon, 16 Aug 2010 15:34:20 +0000 (UTC)
commit b997f5c4780b03dbf7c30d0629e856e36e87781c
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Aug 2 10:53:35 2010 +0200
plugins/evolution: Make it possible to compile the evolution plugin, not working yet
src/plugins/evolution/Makefile.am | 4 +-
src/plugins/evolution/tracker-evolution-plugin.c | 179 ++++++++++++----------
2 files changed, 97 insertions(+), 86 deletions(-)
---
diff --git a/src/plugins/evolution/Makefile.am b/src/plugins/evolution/Makefile.am
index 7db1433..02e8b3e 100644
--- a/src/plugins/evolution/Makefile.am
+++ b/src/plugins/evolution/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES = \
-DG_LOG_DOMAIN=\"Tracker\" \
-DTRACKER_COMPILATION \
-I$(top_builddir)/src \
- -I$(top_builddir)/src/libtracker-client \
+ -I$(top_builddir)/src/libtracker-sparql \
$(WARN_CFLAGS) \
$(DBUS_CFLAGS) \
$(EVOLUTION_PLUGIN_CFLAGS) \
@@ -36,7 +36,7 @@ liborg_freedesktop_Tracker_evolution_plugin_la_SOURCES = \
liborg_freedesktop_Tracker_evolution_plugin_la_LDFLAGS = -module -avoid-version
liborg_freedesktop_Tracker_evolution_plugin_la_LIBADD = \
- $(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 \
$(EVOLUTION_PLUGIN_LIBS) \
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index 8e56d8d..d3a4ca7 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -57,8 +57,7 @@
#include <e-util/e-account-utils.h>
#endif
-#include <libtracker-client/tracker.h>
-#include <libtracker-client/tracker-sparql-builder.h>
+#include <libtracker-sparql/tracker-sparql.h>
#include <libtracker-common/tracker-date-time.h>
#include <libtracker-common/tracker-ontologies.h>
@@ -78,7 +77,7 @@
* reads, never writes). We hope that's sufficient for not having to get our
* code involved in Camel's cruel inneryard of having to lock the db_r ptr. */
-#define TRACKER_SERVICE "org.freedesktop.Tracker1"
+#define TRACKER_SERVICE "org.freedesktop.Tracker1"
#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
#define RDF_PREFIX TRACKER_RDF_PREFIX
@@ -107,7 +106,7 @@ G_DEFINE_TYPE (TrackerEvolutionPlugin, tracker_evolution_plugin, TRACKER_TYPE_MI
* during registration of accounts and folders). I know this is cruel. I know. */
typedef struct {
- TrackerClient *client;
+ TrackerSparqlConnection *connection;
gchar *sparql;
gboolean commit;
gint prio;
@@ -169,9 +168,9 @@ typedef struct {
GHashTable *registered_stores;
GList *registered_clients;
EAccountList *accounts;
- TrackerClient *client;
+ TrackerSparqlConnection *connection;
DBusGProxy *dbus_proxy;
- DBusGConnection *connection;
+ DBusGConnection *dbusconnection;
time_t last_time;
gboolean resuming, paused;
guint total_popped, of_total;
@@ -327,7 +326,7 @@ free_pool_item (gpointer data, gpointer user_data)
{
PoolItem *item = data;
g_free (item->sparql);
- g_object_unref (item->client);
+ g_object_unref (item->connection);
g_slice_free (PoolItem, item);
}
@@ -352,15 +351,21 @@ thread_pool_exec (gpointer data, gpointer user_data)
pool->freeup (data, pool->cancel);
}
-
-static void
-reply_void (GError *error, gpointer user_data)
+static void
+reply_void (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
PoolItem *item = user_data;
ThreadPool *pool = item->pool;
+ GError *error = NULL;
+
+ tracker_sparql_connection_update_finish (TRACKER_SPARQL_CONNECTION (source_object),
+ result, &error);
if (error) {
g_debug ("Tracker plugin: Error updating data: %s\n", error->message);
+ g_error_free (error);
}
g_mutex_lock (item->mutex);
@@ -387,10 +392,15 @@ exec_update (gpointer data, gpointer user_data)
item->has_happened = FALSE;
if (item->commit) {
- tracker_resources_batch_commit_async (item->client, reply_void, item);
+ /* tracker_resources_batch_commit_async (item->client, reply_void, item); */
} else {
- tracker_resources_batch_sparql_update_async (item->client, item->sparql,
- reply_void, item);
+
+ tracker_sparql_connection_update_async (item->connection,
+ item->sparql,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ reply_void, item);
+
}
g_mutex_lock (item->mutex);
@@ -481,7 +491,7 @@ send_sparql_update (TrackerEvolutionPlugin *self, const gchar *sparql, gint prio
{
TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (self);
- if (priv->client) {
+ if (priv->connection) {
PoolItem *item = g_slice_new (PoolItem);
if (!sparql_pool)
@@ -491,7 +501,7 @@ send_sparql_update (TrackerEvolutionPlugin *self, const gchar *sparql, gint prio
item->dont_free = FALSE;
item->prio = prio;
item->commit = FALSE;
- item->client = g_object_ref (priv->client);
+ item->connection = g_object_ref (priv->connection);
item->sparql = g_strdup (sparql);
thread_pool_push (sparql_pool, item, NULL);
@@ -503,7 +513,7 @@ send_sparql_commit (TrackerEvolutionPlugin *self, gboolean update)
{
TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (self);
- if (priv->client) {
+ if (priv->connection) {
PoolItem *item = g_slice_new (PoolItem);
if (update) {
@@ -526,7 +536,7 @@ send_sparql_commit (TrackerEvolutionPlugin *self, gboolean update)
item->dont_free = FALSE;
item->prio = 0;
item->commit = TRUE;
- item->client = g_object_ref (priv->client);
+ item->connection = g_object_ref (priv->connection);
item->sparql = NULL;
thread_pool_push (sparql_pool, item, NULL);
@@ -540,7 +550,7 @@ add_contact (TrackerSparqlBuilder *sparql, const gchar *predicate, const gchar *
get_email_and_fullname (value, &email, &fullname);
- email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ email_uri = tracker_sparql_escape_uri_printf ("mailto:%s", email);
tracker_sparql_builder_subject_iri (sparql, email_uri);
tracker_sparql_builder_predicate (sparql, "rdf:type");
@@ -825,10 +835,10 @@ on_folder_summary_changed (CamelFolder *folder,
/* This is not a path but a URI, don't use the
* OS's directory separator here */
- uri = tracker_uri_printf_escaped ("%s/%s/%s",
- em_uri,
- camel_folder_get_full_name (folder),
- uid);
+ uri = tracker_sparql_escape_uri_printf ("%s/%s/%s",
+ em_uri,
+ camel_folder_get_full_name (folder),
+ uid);
sparql = tracker_sparql_builder_new_update ();
@@ -910,10 +920,10 @@ on_folder_summary_changed (CamelFolder *folder,
/* This is not a path but a URI, don't use the OS's
* directory separator here */
- uri = tracker_uri_printf_escaped ("%s/%s/%s",
- em_uri,
- camel_folder_get_full_name (folder),
- (char*) changes->uid_removed->pdata[i]);
+ uri = tracker_sparql_escape_uri_printf ("%s/%s/%s",
+ em_uri,
+ camel_folder_get_full_name (folder),
+ (char*) changes->uid_removed->pdata[i]);
g_string_append_printf (sparql, "DELETE FROM <%s> { <%s> a rdfs:Resource }\n ", uri, uri);
g_free (uri);
@@ -1030,7 +1040,7 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
folder = g_hash_table_lookup (priv->cached_folders, iter->full_name);
- uri = tracker_uri_printf_escaped ("%s/%s/%s", em_uri, iter->full_name, uid);
+ uri = tracker_sparql_escape_uri_printf ("%s/%s/%s", em_uri, iter->full_name, uid);
if (!sparql) {
sparql = tracker_sparql_builder_new_update ();
@@ -1199,8 +1209,8 @@ introduce_store_deal_with_deleted (TrackerEvolutionPlugin *self,
* directory separator here */
g_ptr_array_add (subjects_a,
- tracker_uri_printf_escaped ("%s/%s/%s", em_uri,
- mailbox, uid));
+ tracker_sparql_escape_uri_printf ("%s/%s/%s", em_uri,
+ mailbox, uid));
if (count > 100) {
more = TRUE;
@@ -1724,57 +1734,57 @@ register_client_second_half (ClientRegistry *info)
}
static void
-on_register_client_qry (GPtrArray *results,
- GError *error,
- gpointer user_data)
+on_register_client_qry (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ TrackerSparqlCursor *cursor;
ClientRegistry *info = user_data;
TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (info->self);
- guint i;
+ GError *error = NULL;
+
+ cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (source_object),
+ res, &error);
if (error) {
g_warning ("%s\n", error->message);
g_error_free (error);
g_slice_free (ClientRegistry, info);
+ if (cursor) {
+ //g_object_unref (cursor);
+ }
return;
}
- if (!results) {
+ if (!tracker_sparql_cursor_next (cursor, NULL, NULL)) {
if (priv->resuming) {
info->last_checkout = priv->last_time;
+ } else if (priv->resuming && priv->last_time != 0) {
+ info->last_checkout = priv->last_time;
} else {
info->last_checkout = 0;
}
} else {
- if (results->len == 0 && priv->resuming && priv->last_time != 0) {
- info->last_checkout = priv->last_time;
- } else {
- if (results->len == 0) {
- info->last_checkout = 0;
- } else {
- for (i = 0; i < results->len; i++) {
- const gchar **str = g_ptr_array_index (results, i);
- GError *new_error = NULL;
-
- info->last_checkout = (guint64) tracker_string_to_date (str[0], NULL, &new_error);
-
- if (new_error) {
- g_warning ("%s", new_error->message);
- g_error_free (error);
- g_ptr_array_foreach (results, (GFunc) g_strfreev, NULL);
- g_ptr_array_free (results, TRUE);
- return;
- }
+ do {
+ const gchar *str = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+ GError *new_error = NULL;
- break;
- }
+ info->last_checkout = (guint64) tracker_string_to_date (str, NULL, &new_error);
+
+ if (new_error) {
+ g_warning ("%s", new_error->message);
+ g_error_free (error);
+ //g_object_unref (cursor);
+ return;
}
- }
- g_ptr_array_foreach (results, (GFunc) g_strfreev, NULL);
- g_ptr_array_free (results, TRUE);
+
+ break;
+ } while (tracker_sparql_cursor_next (cursor, NULL, NULL));
}
register_client_second_half (info);
+
+ //g_object_unref (cursor);
}
static void
@@ -1784,7 +1794,7 @@ register_client (TrackerEvolutionPlugin *self)
ClientRegistry *info;
const gchar *query;
- if (!priv->client) {
+ if (!priv->connection) {
return;
}
@@ -1797,9 +1807,10 @@ register_client (TrackerEvolutionPlugin *self)
query = "SELECT ?c "
"WHERE { <" DATASOURCE_URN "> nie:contentLastModified ?c }";
- tracker_resources_sparql_query_async (priv->client, query,
- on_register_client_qry,
- info);
+ tracker_sparql_connection_query_async (priv->connection, query,
+ NULL,
+ on_register_client_qry,
+ info);
}
@@ -2153,10 +2164,10 @@ name_owner_changed_cb (DBusGProxy *proxy,
if (g_strcmp0 (name, TRACKER_SERVICE) == 0) {
if (tracker_is_empty_string (new_owner) && !tracker_is_empty_string (old_owner)) {
- if (priv->client) {
- TrackerClient *client = priv->client;
+ if (priv->connection) {
+ TrackerSparqlConnection *connection = priv->connection;
- priv->client = NULL;
+ priv->connection = NULL;
if (sparql_pool) {
ThreadPool *pool = sparql_pool;
@@ -2170,13 +2181,13 @@ name_owner_changed_cb (DBusGProxy *proxy,
thread_pool_destroy (pool);
}
- g_object_unref (client);
+ g_object_unref (connection);
}
}
if (tracker_is_empty_string (old_owner) && !tracker_is_empty_string (new_owner)) {
- if (!priv->client) {
- priv->client = tracker_client_new (0, G_MAXINT);
+ if (!priv->connection) {
+ priv->connection = tracker_sparql_connection_get (NULL);
}
register_client (user_data);
}
@@ -2267,10 +2278,10 @@ tracker_evolution_plugin_finalize (GObject *plugin)
g_object_unref (priv->accounts);
- if (priv->client) {
- TrackerClient *client = priv->client;
+ if (priv->connection) {
+ TrackerSparqlConnection *connection = priv->connection;
- priv->client = NULL;
+ priv->connection = NULL;
if (sparql_pool) {
ThreadPool *pool = sparql_pool;
@@ -2284,7 +2295,7 @@ tracker_evolution_plugin_finalize (GObject *plugin)
thread_pool_destroy (pool);
}
- g_object_unref (client);
+ g_object_unref (connection);
}
if (priv->dbus_proxy) {
@@ -2292,7 +2303,7 @@ tracker_evolution_plugin_finalize (GObject *plugin)
}
if (priv->connection) {
- dbus_g_connection_unref (priv->connection);
+ dbus_g_connection_unref (priv->dbusconnection);
}
G_OBJECT_CLASS (tracker_evolution_plugin_parent_class)->finalize (plugin);
@@ -2322,7 +2333,7 @@ tracker_evolution_plugin_init (TrackerEvolutionPlugin *plugin)
EIterator *it;
GError *error = NULL;
- priv->client = NULL;
+ priv->connection = NULL;
priv->last_time = 0;
priv->resuming = FALSE;
priv->paused = FALSE;
@@ -2332,13 +2343,13 @@ tracker_evolution_plugin_init (TrackerEvolutionPlugin *plugin)
priv->registered_stores = NULL;
priv->registered_clients = NULL;
- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ priv->dbusconnection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (error) {
goto error_handler;
}
- priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->connection,
+ priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->dbusconnection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
@@ -2392,8 +2403,8 @@ miner_started (TrackerMiner *miner)
{
TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (miner);
- if (!priv->client) {
- priv->client = tracker_client_new (0, G_MAXINT);
+ if (!priv->connection) {
+ priv->connection = tracker_sparql_connection_get (NULL);
}
dbus_g_proxy_begin_call (priv->dbus_proxy, "ListNames",
@@ -2428,10 +2439,10 @@ miner_paused (TrackerMiner *miner)
priv->paused = TRUE;
priv->last_time = 0;
- if (priv->client) {
- TrackerClient *client = priv->client;
+ if (priv->connection) {
+ TrackerSparqlConnection *connection = priv->connection;
- priv->client = NULL;
+ priv->connection = NULL;
if (sparql_pool) {
ThreadPool *pool = sparql_pool;
@@ -2445,7 +2456,7 @@ miner_paused (TrackerMiner *miner)
thread_pool_destroy (pool);
}
- g_object_unref (client);
+ g_object_unref (connection);
/* By setting this to NULL, events will still be catched by our
* handlers, but the send_sparql_* calls will just ignore it.
@@ -2491,8 +2502,8 @@ miner_resumed (TrackerMiner *miner)
priv->total_popped = 0;
priv->of_total = 0;
- if (!priv->client) {
- priv->client = tracker_client_new (0, G_MAXINT);
+ if (!priv->connection) {
+ priv->connection = tracker_sparql_connection_get (NULL);
}
g_object_set (miner, "progress", 0.0, "status", _("Processingâ?¦"), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]