[tracker/architecture-sparql-up-in-daemon] Made class-signals feature also work when writes take place in trackerd
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/architecture-sparql-up-in-daemon] Made class-signals feature also work when writes take place in trackerd
- Date: Thu, 23 Apr 2009 06:06:44 -0400 (EDT)
commit 6def4e565c961dccf5aa8af350d4773e0c3440f4
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Apr 23 12:05:56 2009 +0200
Made class-signals feature also work when writes take place in trackerd
---
src/libtracker-common/Makefile.am | 6 +-
.../tracker-events.c | 0
.../tracker-events.h | 0
src/tracker-indexer/Makefile.am | 4 +-
src/tracker-indexer/tracker-indexer.c | 2 +-
src/tracker-indexer/tracker-main.c | 2 +-
src/trackerd/Makefile.am | 2 +-
src/trackerd/tracker-resource-class.c | 93 ++++++++++++++++++++
8 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/src/libtracker-common/Makefile.am b/src/libtracker-common/Makefile.am
index d4a9335..6fb4bdc 100644
--- a/src/libtracker-common/Makefile.am
+++ b/src/libtracker-common/Makefile.am
@@ -53,7 +53,8 @@ libtracker_common_la_SOURCES = \
tracker-type-utils.c \
tracker-utils.c \
tracker-thumbnailer.c \
- tracker-albumart.c
+ tracker-albumart.c \
+ tracker-events.c
noinst_HEADERS = \
$(hal_headers) \
@@ -63,7 +64,8 @@ noinst_HEADERS = \
tracker-nfs-lock.h \
tracker-os-dependant.h \
tracker-thumbnailer.h \
- tracker-albumart.h
+ tracker-albumart.h \
+ tracker-events.h
libtracker_commoninclude_HEADERS = \
tracker-class.h \
diff --git a/src/tracker-indexer/tracker-events.c b/src/libtracker-common/tracker-events.c
similarity index 100%
rename from src/tracker-indexer/tracker-events.c
rename to src/libtracker-common/tracker-events.c
diff --git a/src/tracker-indexer/tracker-events.h b/src/libtracker-common/tracker-events.h
similarity index 100%
rename from src/tracker-indexer/tracker-events.h
rename to src/libtracker-common/tracker-events.h
diff --git a/src/tracker-indexer/Makefile.am b/src/tracker-indexer/Makefile.am
index 99dd9c7..e986dd1 100644
--- a/src/tracker-indexer/Makefile.am
+++ b/src/tracker-indexer/Makefile.am
@@ -54,9 +54,7 @@ tracker_indexer_SOURCES = \
tracker-removable-device.c \
tracker-removable-device.h \
tracker-push.c \
- tracker-push.h \
- tracker-events.c \
- tracker-events.h
+ tracker-push.h
tracker_indexer_LDADD = \
$(plugin_libs) \
diff --git a/src/tracker-indexer/tracker-indexer.c b/src/tracker-indexer/tracker-indexer.c
index b1b5699..1c4fe0d 100644
--- a/src/tracker-indexer/tracker-indexer.c
+++ b/src/tracker-indexer/tracker-indexer.c
@@ -68,6 +68,7 @@
#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-utils.h>
#include <libtracker-common/tracker-thumbnailer.h>
+#include <libtracker-common/tracker-events.h>
#include <libtracker-db/tracker-db-dbus.h>
@@ -82,7 +83,6 @@
#include "tracker-marshal.h"
#include "tracker-module-metadata-private.h"
#include "tracker-removable-device.h"
-#include "tracker-events.h"
#define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate))
diff --git a/src/tracker-indexer/tracker-main.c b/src/tracker-indexer/tracker-main.c
index 8293e98..072c4f7 100644
--- a/src/tracker-indexer/tracker-main.c
+++ b/src/tracker-indexer/tracker-main.c
@@ -42,6 +42,7 @@
#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-thumbnailer.h>
+#include <libtracker-common/tracker-events.h>
#include <libtracker-db/tracker-db-manager.h>
#include <libtracker-db/tracker-db-dbus.h>
@@ -52,7 +53,6 @@
#include <libtracker-data/tracker-turtle.h>
#include "tracker-dbus.h"
-#include "tracker-events.h"
#include "tracker-indexer.h"
#include "tracker-indexer-glue.h"
#include "tracker-push.h"
diff --git a/src/trackerd/Makefile.am b/src/trackerd/Makefile.am
index f04fb33..f05d541 100644
--- a/src/trackerd/Makefile.am
+++ b/src/trackerd/Makefile.am
@@ -61,7 +61,7 @@ trackerd_SOURCES = \
tracker-push-registrar.c \
tracker-push-registrar.h \
tracker-resource-class.c \
- tracker-resource-class.h
+ tracker-resource-class.h
if OS_WIN32
trackerd_win_libs = -lws2_32 -lkernel32
diff --git a/src/trackerd/tracker-resource-class.c b/src/trackerd/tracker-resource-class.c
index 93ca6d3..82776e6 100644
--- a/src/trackerd/tracker-resource-class.c
+++ b/src/trackerd/tracker-resource-class.c
@@ -28,12 +28,31 @@
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-ontology.h>
+#include <libtracker-common/tracker-events.h>
+
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-data/tracker-data-update.h>
+
#include "tracker-dbus.h"
#include "tracker-resource-class.h"
#include "tracker-marshal.h"
+#define RDF_PREFIX TRACKER_RDF_PREFIX
+#define RDF_TYPE RDF_PREFIX "type"
+
+static void on_statements_committed (gpointer user_data);
+static void on_statement_inserted (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ GPtrArray *rdf_types,
+ gpointer user_data);
+static void on_statement_deleted (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ GPtrArray *rdf_types,
+ gpointer user_data);
+
#define TRACKER_RESOURCE_CLASS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_RESOURCE_CLASS, TrackerResourceClassPrivate))
typedef struct {
@@ -99,9 +118,15 @@ tracker_resource_class_class_init (TrackerResourceClassClass *klass)
g_type_class_add_private (object_class, sizeof (TrackerResourceClassPrivate));
}
+
+
+
static void
tracker_resource_class_init (TrackerResourceClass *object)
{
+ tracker_data_set_insert_statement_callback (on_statement_inserted, object);
+ tracker_data_set_delete_statement_callback (on_statement_deleted, object);
+ tracker_data_set_commit_statement_callback (on_statements_committed, object);
}
static void
@@ -230,3 +255,71 @@ tracker_resource_class_emit_events (TrackerResourceClass *object)
priv->dels = NULL;
}
}
+
+
+static void
+on_statements_committed (gpointer user_data)
+{
+ GPtrArray *events;
+
+ events = tracker_events_get_pending ();
+
+ if (events) {
+ GSList *event_sources, *l, *to_emit = NULL;
+ guint i;
+
+ for (i = 0; i < events->len; i++) {
+ GValueArray *event = events->pdata[i];
+ const gchar *uri = g_value_get_string (g_value_array_get_nth (event, 0));
+ const gchar *rdf_class = g_value_get_string (g_value_array_get_nth (event, 1));
+ TrackerDBusEventsType type = g_value_get_int (g_value_array_get_nth (event, 2));
+
+ for (l = event_sources; l; l = l->next) {
+ TrackerResourceClass *class_ = l->data;
+ if (g_strcmp0 (rdf_class, tracker_resource_class_get_rdf_class (class_)) == 0) {
+ tracker_resource_class_add_event (class_, uri, type);
+ to_emit = g_slist_prepend (to_emit, class_);
+ }
+ }
+ }
+
+ if (to_emit) {
+ for (l = to_emit; l; l = l->next) {
+ TrackerResourceClass *class_ = l->data;
+ tracker_resource_class_emit_events (class_);
+ }
+
+ g_slist_free (to_emit);
+ }
+ }
+
+ tracker_events_reset ();
+}
+
+static void
+on_statement_inserted (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ GPtrArray *rdf_types,
+ gpointer user_data)
+{
+ if (g_strcmp0 (predicate, RDF_PREFIX "type") == 0) {
+ tracker_events_insert (subject, object, rdf_types, TRACKER_DBUS_EVENTS_TYPE_ADD);
+ } else {
+ tracker_events_insert (subject, object, rdf_types, TRACKER_DBUS_EVENTS_TYPE_UPDATE);
+ }
+}
+
+static void
+on_statement_deleted (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ GPtrArray *rdf_types,
+ gpointer user_data)
+{
+ if (g_strcmp0 (predicate, RDF_PREFIX "type") == 0) {
+ tracker_events_insert (subject, object, rdf_types, TRACKER_DBUS_EVENTS_TYPE_DELETE);
+ } else {
+ tracker_events_insert (subject, object, rdf_types, TRACKER_DBUS_EVENTS_TYPE_UPDATE);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]