[tracker/rss-enclosures] libtracker-data, tracker-store, etc: Add graph_id to the class-signal API
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] libtracker-data, tracker-store, etc: Add graph_id to the class-signal API
- Date: Wed, 24 Nov 2010 01:36:41 +0000 (UTC)
commit 7532df2e8f671348771b2d3dfa1a255d52df64c6
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Aug 30 13:46:52 2010 +0200
libtracker-data, tracker-store, etc: Add graph_id to the class-signal API
data/dbus/tracker-resources.xml | 4 +-
examples/class-signal/class-signal.c | 4 +-
src/libtracker-common/tracker-dbus.h | 3 +-
src/libtracker-data/tracker-class.c | 91 +++++++++++++++----------
src/libtracker-data/tracker-class.h | 5 +-
src/tracker-store/tracker-events.c | 4 +
src/tracker-store/tracker-resources.c | 12 ++--
tests/functional-tests/class-signal-test.vala | 1 +
8 files changed, 77 insertions(+), 47 deletions(-)
---
diff --git a/data/dbus/tracker-resources.xml b/data/dbus/tracker-resources.xml
index e709adc..b415217 100644
--- a/data/dbus/tracker-resources.xml
+++ b/data/dbus/tracker-resources.xml
@@ -56,8 +56,8 @@
<signal name="ClassSignal">
<arg type="s" name ="classname" />
- <arg type="a(iii)" name="deletes" />
- <arg type="a(iii)" name="inserts" />
+ <arg type="a(iiii)" name="deletes" />
+ <arg type="a(iiii)" name="inserts" />
</signal>
</interface>
diff --git a/examples/class-signal/class-signal.c b/examples/class-signal/class-signal.c
index 34a3512..3f8324a 100644
--- a/examples/class-signal/class-signal.c
+++ b/examples/class-signal/class-signal.c
@@ -75,9 +75,11 @@ class_signal_cb (DBusMessage *message)
while ((arg_type = dbus_message_iter_get_arg_type (&arr)) != DBUS_TYPE_INVALID) {
DBusMessageIter strct;
- gint subject = 0, predicate = 0, object = 0;
+ gint graph = 0, subject = 0, predicate = 0, object = 0;
dbus_message_iter_recurse (&arr, &strct);
+ dbus_message_iter_get_basic (&strct, &graph);
+ dbus_message_iter_next (&strct);
dbus_message_iter_get_basic (&strct, &subject);
dbus_message_iter_next (&strct);
dbus_message_iter_get_basic (&strct, &predicate);
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
index 483c4b7..b97cde9 100644
--- a/src/libtracker-common/tracker-dbus.h
+++ b/src/libtracker-common/tracker-dbus.h
@@ -41,12 +41,13 @@ G_BEGIN_DECLS
#define TRACKER_TYPE_INT_ARRAY_MAP \
dbus_g_type_get_map ("GHashTable", G_TYPE_INT, DBUS_TYPE_G_INT_ARRAY)
-#define TRACKER_TYPE_THREE_INT_ARRAY \
+#define TRACKER_TYPE_FOUR_INT_ARRAY \
dbus_g_type_get_collection ("GPtrArray", \
dbus_g_type_get_struct("GValueArray", \
G_TYPE_INT, \
G_TYPE_INT, \
G_TYPE_INT, \
+ G_TYPE_INT, \
G_TYPE_INVALID))
#define TRACKER_TYPE_EVENT_ARRAY \
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c
index a4ac1db..b5af70e 100644
--- a/src/libtracker-data/tracker-class.c
+++ b/src/libtracker-data/tracker-class.c
@@ -48,21 +48,21 @@ struct _TrackerClassPrivate {
struct {
struct {
GArray *sub_pred_ids;
- GArray *object_ids;
+ GArray *obj_graph_ids;
} pending;
struct {
GArray *sub_pred_ids;
- GArray *object_ids;
+ GArray *obj_graph_ids;
} ready;
} deletes;
struct {
struct {
GArray *sub_pred_ids;
- GArray *object_ids;
+ GArray *obj_graph_ids;
} pending;
struct {
GArray *sub_pred_ids;
- GArray *object_ids;
+ GArray *obj_graph_ids;
} ready;
} inserts;
};
@@ -94,14 +94,14 @@ tracker_class_init (TrackerClass *service)
priv->last_domain_indexes = NULL;
priv->deletes.pending.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->deletes.pending.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->deletes.pending.obj_graph_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
priv->deletes.ready.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->deletes.ready.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->deletes.ready.obj_graph_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
priv->inserts.pending.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->inserts.pending.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->inserts.pending.obj_graph_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
priv->inserts.ready.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->inserts.ready.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->inserts.ready.obj_graph_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
/* Make GET_PRIV working */
service->priv = priv;
@@ -121,14 +121,14 @@ class_finalize (GObject *object)
g_array_free (priv->domain_indexes, TRUE);
g_array_free (priv->deletes.pending.sub_pred_ids, TRUE);
- g_array_free (priv->deletes.pending.object_ids, TRUE);
+ g_array_free (priv->deletes.pending.obj_graph_ids, TRUE);
g_array_free (priv->deletes.ready.sub_pred_ids, TRUE);
- g_array_free (priv->deletes.ready.object_ids, TRUE);
+ g_array_free (priv->deletes.ready.obj_graph_ids, TRUE);
g_array_free (priv->inserts.pending.sub_pred_ids, TRUE);
- g_array_free (priv->inserts.pending.object_ids, TRUE);
+ g_array_free (priv->inserts.pending.obj_graph_ids, TRUE);
g_array_free (priv->inserts.ready.sub_pred_ids, TRUE);
- g_array_free (priv->inserts.ready.object_ids, TRUE);
+ g_array_free (priv->inserts.ready.obj_graph_ids, TRUE);
if (priv->last_domain_indexes)
g_array_free (priv->last_domain_indexes, TRUE);
@@ -482,15 +482,20 @@ tracker_class_foreach_insert_event (TrackerClass *class,
priv = GET_PRIV (class);
for (i = 0; i < priv->inserts.ready.sub_pred_ids->len; i++) {
- gint subject_id, pred_id, object_id;
+ gint graph_id, subject_id, pred_id, object_id;
gint64 sub_pred_id;
+ gint64 obj_graph_id;
sub_pred_id = g_array_index (priv->inserts.ready.sub_pred_ids, gint64, i);
+ obj_graph_id = g_array_index (priv->inserts.ready.obj_graph_ids, gint64, i);
+
pred_id = sub_pred_id & 0xffffffff;
subject_id = sub_pred_id >> 32;
- object_id = g_array_index (priv->inserts.ready.object_ids, gint, i);
+ object_id = obj_graph_id & 0xffffffff;
+ graph_id = obj_graph_id >> 32;
+
- foreach (subject_id, pred_id, object_id, user_data);
+ foreach (graph_id, subject_id, pred_id, object_id, user_data);
}
}
@@ -508,15 +513,19 @@ tracker_class_foreach_delete_event (TrackerClass *class,
priv = GET_PRIV (class);
for (i = 0; i < priv->deletes.ready.sub_pred_ids->len; i++) {
- gint subject_id, pred_id, object_id;
+ gint graph_id, subject_id, pred_id, object_id;
gint64 sub_pred_id;
+ gint64 obj_graph_id;
sub_pred_id = g_array_index (priv->deletes.ready.sub_pred_ids, gint64, i);
+ obj_graph_id = g_array_index (priv->deletes.ready.obj_graph_ids, gint64, i);
+
pred_id = sub_pred_id & 0xffffffff;
subject_id = sub_pred_id >> 32;
- object_id = g_array_index (priv->deletes.ready.object_ids, gint, i);
+ object_id = obj_graph_id & 0xffffffff;
+ graph_id = obj_graph_id >> 32;
- foreach (subject_id, pred_id, object_id, user_data);
+ foreach (graph_id, subject_id, pred_id, object_id, user_data);
}
}
@@ -531,10 +540,10 @@ tracker_class_reset_ready_events (TrackerClass *class)
/* Reset */
g_array_set_size (priv->deletes.ready.sub_pred_ids, 0);
- g_array_set_size (priv->deletes.ready.object_ids, 0);
+ g_array_set_size (priv->deletes.ready.obj_graph_ids, 0);
g_array_set_size (priv->inserts.ready.sub_pred_ids, 0);
- g_array_set_size (priv->inserts.ready.object_ids, 0);
+ g_array_set_size (priv->inserts.ready.obj_graph_ids, 0);
}
@@ -549,10 +558,10 @@ tracker_class_reset_pending_events (TrackerClass *class)
/* Reset */
g_array_set_size (priv->deletes.pending.sub_pred_ids, 0);
- g_array_set_size (priv->deletes.pending.object_ids, 0);
+ g_array_set_size (priv->deletes.pending.obj_graph_ids, 0);
g_array_set_size (priv->inserts.pending.sub_pred_ids, 0);
- g_array_set_size (priv->inserts.pending.object_ids, 0);
+ g_array_set_size (priv->inserts.pending.obj_graph_ids, 0);
}
@@ -565,10 +574,10 @@ tracker_class_transact_events (TrackerClass *class)
priv = GET_PRIV (class);
/* Move */
- g_array_insert_vals (priv->deletes.ready.object_ids,
- priv->deletes.ready.object_ids->len,
- priv->deletes.pending.object_ids->data,
- priv->deletes.pending.object_ids->len);
+ g_array_insert_vals (priv->deletes.ready.obj_graph_ids,
+ priv->deletes.ready.obj_graph_ids->len,
+ priv->deletes.pending.obj_graph_ids->data,
+ priv->deletes.pending.obj_graph_ids->len);
g_array_insert_vals (priv->deletes.ready.sub_pred_ids,
priv->deletes.ready.sub_pred_ids->len,
@@ -577,14 +586,14 @@ tracker_class_transact_events (TrackerClass *class)
/* Reset */
g_array_set_size (priv->deletes.pending.sub_pred_ids, 0);
- g_array_set_size (priv->deletes.pending.object_ids, 0);
+ g_array_set_size (priv->deletes.pending.obj_graph_ids, 0);
/* Move */
- g_array_insert_vals (priv->inserts.ready.object_ids,
- priv->inserts.ready.object_ids->len,
- priv->inserts.pending.object_ids->data,
- priv->inserts.pending.object_ids->len);
+ g_array_insert_vals (priv->inserts.ready.obj_graph_ids,
+ priv->inserts.ready.obj_graph_ids->len,
+ priv->inserts.pending.obj_graph_ids->data,
+ priv->inserts.pending.obj_graph_ids->len);
g_array_insert_vals (priv->inserts.ready.sub_pred_ids,
priv->inserts.ready.sub_pred_ids->len,
@@ -593,37 +602,42 @@ tracker_class_transact_events (TrackerClass *class)
/* Reset */
g_array_set_size (priv->inserts.pending.sub_pred_ids, 0);
- g_array_set_size (priv->inserts.pending.object_ids, 0);
+ g_array_set_size (priv->inserts.pending.obj_graph_ids, 0);
}
static void
insert_vals_into_arrays (GArray *sub_pred_ids,
- GArray *object_ids,
+ GArray *obj_graph_ids,
+ gint graph_id,
gint subject_id,
gint pred_id,
gint object_id)
{
guint i;
gint64 sub_pred_id;
+ gint64 obj_graph_id;
sub_pred_id = (gint64) subject_id;
sub_pred_id = sub_pred_id << 32 | pred_id;
+ obj_graph_id = (gint64) object_id;
+ obj_graph_id = obj_graph_id << 32 | graph_id;
for (i = 0; i < sub_pred_ids->len; i++) {
if (sub_pred_id < g_array_index (sub_pred_ids, gint64, i)) {
g_array_insert_val (sub_pred_ids, i, sub_pred_id);
- g_array_insert_val (object_ids, i, object_id);
+ g_array_insert_val (obj_graph_ids, i, obj_graph_id);
return;
}
}
g_array_append_val (sub_pred_ids, sub_pred_id);
- g_array_append_val (object_ids, object_id);
+ g_array_append_val (obj_graph_ids, obj_graph_id);
}
void
tracker_class_add_insert_event (TrackerClass *class,
+ gint graph_id,
gint subject_id,
gint pred_id,
gint object_id)
@@ -634,7 +648,8 @@ tracker_class_add_insert_event (TrackerClass *class,
priv = GET_PRIV (class);
insert_vals_into_arrays (priv->inserts.pending.sub_pred_ids,
- priv->inserts.pending.object_ids,
+ priv->inserts.pending.obj_graph_ids,
+ graph_id,
subject_id,
pred_id,
object_id);
@@ -642,6 +657,7 @@ tracker_class_add_insert_event (TrackerClass *class,
void
tracker_class_add_delete_event (TrackerClass *class,
+ gint graph_id,
gint subject_id,
gint pred_id,
gint object_id)
@@ -652,7 +668,8 @@ tracker_class_add_delete_event (TrackerClass *class,
priv = GET_PRIV (class);
insert_vals_into_arrays (priv->deletes.pending.sub_pred_ids,
- priv->deletes.pending.object_ids,
+ priv->deletes.pending.obj_graph_ids,
+ graph_id,
subject_id,
pred_id,
object_id);
diff --git a/src/libtracker-data/tracker-class.h b/src/libtracker-data/tracker-class.h
index 2bc90a1..2b4d5c1 100644
--- a/src/libtracker-data/tracker-class.h
+++ b/src/libtracker-data/tracker-class.h
@@ -50,7 +50,8 @@ struct _TrackerClassClass {
GObjectClass parent_class;
};
-typedef void (*TrackerEventsForeach) (gint subject_id,
+typedef void (*TrackerEventsForeach) (gint graph_id,
+ gint subject_id,
gint pred_id,
gint object_id,
gpointer user_data);
@@ -102,10 +103,12 @@ void tracker_class_reset_ready_events (TrackerClass *cla
void tracker_class_reset_pending_events (TrackerClass *class);
void tracker_class_transact_events (TrackerClass *class);
void tracker_class_add_delete_event (TrackerClass *class,
+ gint graph_id,
gint subject_id,
gint pred_id,
gint object_id);
void tracker_class_add_insert_event (TrackerClass *class,
+ gint graph_id,
gint subject_id,
gint pred_id,
gint object_id);
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index 0175675..ddc0654 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -104,6 +104,7 @@ tracker_events_add_insert (gint graph_id,
if (class) {
tracker_class_add_insert_event (class,
+ graph_id,
subject_id,
pred_id,
object_id);
@@ -116,6 +117,7 @@ tracker_events_add_insert (gint graph_id,
for (i = 0; i < rdf_types->len; i++) {
if (is_allowed (private, rdf_types->pdata[i], 0)) {
tracker_class_add_insert_event (rdf_types->pdata[i],
+ graph_id,
subject_id,
pred_id,
object_id);
@@ -165,6 +167,7 @@ tracker_events_add_delete (gint graph_id,
if (class) {
tracker_class_add_delete_event (class,
+ graph_id,
subject_id,
pred_id,
object_id);
@@ -177,6 +180,7 @@ tracker_events_add_delete (gint graph_id,
for (i = 0; i < rdf_types->len; i++) {
if (is_allowed (private, rdf_types->pdata[i], 0)) {
tracker_class_add_delete_event (rdf_types->pdata[i],
+ graph_id,
subject_id,
pred_id,
object_id);
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index 3fc0d1b..89f68c8 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -131,8 +131,8 @@ tracker_resources_class_init (TrackerResourcesClass *klass)
tracker_marshal_VOID__STRING_BOXED_BOXED,
G_TYPE_NONE, 3,
G_TYPE_STRING,
- TRACKER_TYPE_THREE_INT_ARRAY,
- TRACKER_TYPE_THREE_INT_ARRAY);
+ TRACKER_TYPE_FOUR_INT_ARRAY,
+ TRACKER_TYPE_FOUR_INT_ARRAY);
g_type_class_add_private (object_class, sizeof (TrackerResourcesPrivate));
}
@@ -534,7 +534,8 @@ tracker_resources_batch_commit (TrackerResources *self,
}
static void
-foreach_add_to_iter (gint subject_id,
+foreach_add_to_iter (gint graph_id,
+ gint subject_id,
gint pred_id,
gint object_id,
gpointer user_data)
@@ -543,6 +544,7 @@ foreach_add_to_iter (gint subject_id,
DBusMessageIter struct_iter;
dbus_message_iter_open_container (array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter);
+ dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &graph_id);
dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &subject_id);
dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &pred_id);
dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &object_id);
@@ -571,7 +573,7 @@ emit_class_signal (TrackerResources *self,
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &class_uri);
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
- "(iii)", &deletes_iter);
+ "(iiii)", &deletes_iter);
tracker_class_foreach_delete_event (class, foreach_add_to_iter, &deletes_iter);
@@ -579,7 +581,7 @@ emit_class_signal (TrackerResources *self,
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
- "(iii)", &inserts_iter);
+ "(iiii)", &inserts_iter);
tracker_class_foreach_insert_event (class, foreach_add_to_iter, &inserts_iter);
diff --git a/tests/functional-tests/class-signal-test.vala b/tests/functional-tests/class-signal-test.vala
index f5d1cfd..5affae3 100644
--- a/tests/functional-tests/class-signal-test.vala
+++ b/tests/functional-tests/class-signal-test.vala
@@ -25,6 +25,7 @@ const string title_data = "title";
struct Event {
+ int graph_id;
int subject_id;
int pred_id;
int object_id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]