[tracker/class-signal: 9/17] tracker-store: Class-signal impl. without any sorting or optimizations



commit 480604847278e1c32a4d416fa7fc8f9b3a5b151b
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Aug 18 12:29:53 2010 +0200

    tracker-store: Class-signal impl. without any sorting or optimizations

 data/dbus/tracker-resources.xml        |    6 +
 src/libtracker-common/tracker-dbus.h   |   22 +++-
 src/tracker-store/tracker-dbus.c       |    2 +-
 src/tracker-store/tracker-events.c     |  177 +++++++++++++++++++++++++-------
 src/tracker-store/tracker-marshal.list |    1 +
 src/tracker-store/tracker-resources.c  |  124 ++++++++++++++++++++---
 src/tracker-store/tracker-resources.h  |   10 ++-
 7 files changed, 281 insertions(+), 61 deletions(-)
---
diff --git a/data/dbus/tracker-resources.xml b/data/dbus/tracker-resources.xml
index 0de4185..1403a26 100644
--- a/data/dbus/tracker-resources.xml
+++ b/data/dbus/tracker-resources.xml
@@ -54,5 +54,11 @@
       <arg type="a{sas}" name="subjects" />
    </signal>
 
+   <signal name="ClassSignal">
+      <arg type="s" name ="classname" />
+      <arg type="a(iii)" name="deletes" />
+      <arg type="a(iii)" name="inserts" />
+   </signal>
+
   </interface>
 </node>
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
index 35eb699..af56129 100644
--- a/src/libtracker-common/tracker-dbus.h
+++ b/src/libtracker-common/tracker-dbus.h
@@ -28,8 +28,6 @@
 #include <dbus/dbus-glib-lowlevel.h>
 #include <dbus/dbus-glib.h>
 
-#define TRACKER_TYPE_STR_STRV_MAP (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRV))
-
 G_BEGIN_DECLS
 
 #if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
@@ -39,17 +37,29 @@ G_BEGIN_DECLS
 #define TRACKER_DBUS_ERROR_DOMAIN "TrackerDBus"
 #define TRACKER_DBUS_ERROR        tracker_dbus_error_quark()
 
-#define TRACKER_TYPE_EVENT_ARRAY	  \
+
+#define TRACKER_TYPE_STR_STRV_MAP	  \
+	dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRV)
+
+#define TRACKER_TYPE_THREE_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_INVALID))
+
+#define TRACKER_TYPE_EVENT_ARRAY	\
 	dbus_g_type_get_collection ("GPtrArray", \
 	                            dbus_g_type_get_struct ("GValueArray", \
 	                                                    G_TYPE_STRING, \
 	                                                    G_TYPE_STRING, \
 	                                                    G_TYPE_INT, \
 	                                                    G_TYPE_INVALID))
-#define TRACKER_TYPE_G_STRV_ARRAY	  \
+#define TRACKER_TYPE_G_STRV_ARRAY	\
 	dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV)
 
-#define tracker_dbus_async_return_if_fail(expr,context)	  \
+#define tracker_dbus_async_return_if_fail(expr,context)	\
 	G_STMT_START { \
 		if G_LIKELY(expr) { } else { \
 			GError *assert_error = NULL; \
@@ -67,7 +77,7 @@ G_BEGIN_DECLS
 		}; \
 	} G_STMT_END
 
-#define tracker_dbus_return_val_if_fail(expr,val,error)	  \
+#define tracker_dbus_return_val_if_fail(expr,val,error)	\
 	G_STMT_START { \
 		if G_LIKELY(expr) { } else { \
 			g_set_error (error, \
diff --git a/src/tracker-store/tracker-dbus.c b/src/tracker-store/tracker-dbus.c
index 5d297e3..344a138 100644
--- a/src/tracker-store/tracker-dbus.c
+++ b/src/tracker-store/tracker-dbus.c
@@ -279,7 +279,7 @@ tracker_dbus_register_objects (void)
 	objects = g_slist_prepend (objects, object);
 
 	/* Add org.freedesktop.Tracker1.Resources */
-	object = resources = tracker_resources_new ();
+	object = resources = tracker_resources_new (connection);
 	if (!object) {
 		g_critical ("Could not create TrackerResources object to register");
 		return FALSE;
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index d7d56a1..b396bab 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -30,12 +30,16 @@ typedef struct {
 	GHashTable *allowances_id;
 	GHashTable *allowances;
 	struct {
-		GArray *sub_pred_ids;
+		//GArray *sub_pred_ids;
+		GArray *subject_ids;
+		GArray *pred_ids;
 		GArray *object_ids;
 		GArray *class_ids;
 	} deletes;
 	struct {
-		GArray *sub_pred_ids;
+		//GArray *sub_pred_ids;
+		GArray *subject_ids;
+		GArray *pred_ids;
 		GArray *object_ids;
 		GArray *class_ids;
 	} inserts;
@@ -44,10 +48,46 @@ typedef struct {
 
 static EventsPrivate *private;
 
+/*
+void showbits64(gint64 a)
+{
+  int i  , k , mask;
+
+  for( i =63 ; i >= 0 ; i--)
+  {
+     mask = 1 << i;
+     k = a & mask;
+     if( k == 0)
+        printf("0 ");
+     else
+        printf ("1 ");
+  }
+	printf ("\n");
+}
+
+void showbits(gint a)
+{
+  int i  , k , mask;
+
+  for( i =31 ; i >= 0 ; i--)
+  {
+     mask = 1 << i;
+     k = a & mask;
+     if( k == 0)
+        printf("0 ");
+     else
+        printf ("1 ");
+  }
+	printf ("\n");
+}
+*/
+
 static void
 get_from_array (gint    class_id,
                 GArray *class_ids,
-                GArray *sub_pred_ids,
+                //GArray *sub_pred_ids,
+                GArray *subject_ids_in,
+                GArray *pred_ids_in,
                 GArray *object_ids_in,
                 GArray *subject_ids,
                 GArray *pred_ids,
@@ -66,11 +106,29 @@ get_from_array (gint    class_id,
 
 		if (class_id_v == class_id) {
 			gint subject_id, pred_id, object_id;
-			gint64 sub_pred_id;
+			/*gint64 sub_pred_id;
 
 			sub_pred_id = g_array_index (sub_pred_ids, gint64, i);
+
+			printf ("get_array\n");
+
+			printf ("sub_pred_id: ");
+			showbits64 (sub_pred_id);
+			printf ("\n");
+
 			subject_id = sub_pred_id >> 32;
 			pred_id = sub_pred_id << 32;
+
+			printf ("subject_id: ");
+			showbits (subject_id);
+			printf("\n");
+
+			printf ("pred_id: ");
+			showbits (pred_id);
+			printf("\n");*/
+
+			subject_id = g_array_index (subject_ids_in, gint, i);
+			pred_id = g_array_index (pred_ids_in, gint, i);
 			object_id = g_array_index (object_ids_in, gint, i);
 
 			g_array_append_val (subject_ids, subject_id);
@@ -93,7 +151,9 @@ tracker_events_get_inserts (gint    class_id,
 
 	get_from_array (class_id,
 	                private->inserts.class_ids,
-	                private->inserts.sub_pred_ids,
+	                //private->inserts.sub_pred_ids,
+	                private->inserts.subject_ids,
+	                private->inserts.pred_ids,
 	                private->inserts.object_ids,
 	                subject_ids,
 	                pred_ids,
@@ -113,7 +173,9 @@ tracker_events_get_deletes (gint    class_id,
 
 	get_from_array (class_id,
 	                private->deletes.class_ids,
-	                private->deletes.sub_pred_ids,
+	                //private->deletes.sub_pred_ids,
+	                private->inserts.subject_ids,
+	                private->inserts.pred_ids,
 	                private->deletes.object_ids,
 	                subject_ids,
 	                pred_ids,
@@ -135,34 +197,54 @@ is_allowed (EventsPrivate *private, TrackerClass *rdf_class, gint class_id)
 
 static void
 insert_vals_into_arrays (GArray *class_ids,
-                         GArray *sub_pred_ids,
+                         //GArray *sub_pred_ids,
+                         GArray *subject_ids,
+                         GArray *pred_ids,
                          GArray *object_ids,
                          gint    class_id,
                          gint    subject_id,
                          gint    pred_id,
                          gint    object_id)
 {
-	guint i;
-	gboolean inserted = FALSE;
-	gint64 sub_pred_id = (gint64) subject_id;
-
-	sub_pred_id = sub_pred_id << 32 | pred_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 (class_ids, i, class_id);
-			g_array_insert_val (sub_pred_ids, i, sub_pred_id);
-			g_array_insert_val (object_ids, i, object_id);
-			inserted = TRUE;
-			break;
-		}
-	}
-
-	if (!inserted) {
+//	guint i;
+//	gboolean inserted = FALSE;
+	/*gint64 sub_pred_id = (gint64) subject_id;
+
+	sub_pred_id = sub_pred_id << 32 | (gint64) pred_id;
+
+	printf ("insert_vals\n");
+	printf ("subject_id: ");
+	showbits (subject_id);
+	printf("\n");
+
+	printf ("pred_id: ");
+	showbits (subject_id);
+	printf("\n");
+
+	printf ("sub_pred_id: ");
+	showbits64 (sub_pred_id);
+	printf("\n");*/
+
+	//for (i = 0; i < sub_pred_ids->len; i++) {
+//	for (i = 0; i < subject_ids->len; i++) {
+//		 if (sub_pred_id < g_array_index (sub_pred_ids, gint64, i)) {
+//			g_array_insert_val (class_ids, i, class_id);
+//			//g_array_insert_val (sub_pred_ids, i, sub_pred_id);
+//			g_array_insert_val (subject_ids, i, subject_id);
+//			g_array_insert_val (pred_ids, i, pred_id);
+//			g_array_insert_val (object_ids, i, object_id);
+//			inserted = TRUE;
+//			break;
+//		}
+//	}
+
+//	if (!inserted) {
 		g_array_append_val (class_ids, class_id);
-		g_array_append_val (sub_pred_ids, sub_pred_ids);
+		//g_array_append_val (sub_pred_ids, sub_pred_ids);
+		g_array_append_val (subject_ids, subject_id);
+		g_array_append_val (pred_ids, pred_id);
 		g_array_append_val (object_ids, object_id);
-	}
+//	}
 }
 
 void
@@ -190,7 +272,9 @@ tracker_events_add_insert (gint         graph_id,
 		 * In case of create, object is the rdf:type */
 		if (is_allowed (private, NULL, object_id)) {
 			insert_vals_into_arrays (private->inserts.class_ids,
-			                         private->inserts.sub_pred_ids,
+			                         //private->inserts.sub_pred_ids,
+			                         private->inserts.subject_ids,
+			                         private->inserts.pred_ids,
 			                         private->inserts.object_ids,
 			                         object_id,
 			                         subject_id, pred_id, object_id);
@@ -201,7 +285,9 @@ tracker_events_add_insert (gint         graph_id,
 		for (i = 0; i < rdf_types->len; i++) {
 			if (is_allowed (private, rdf_types->pdata[i], 0)) {
 				insert_vals_into_arrays (private->inserts.class_ids,
-				                         private->inserts.sub_pred_ids,
+				                         //private->inserts.sub_pred_ids,
+				                         private->inserts.subject_ids,
+				                         private->inserts.pred_ids,
 				                         private->inserts.object_ids,
 				                         tracker_class_get_id (rdf_types->pdata[i]),
 				                         subject_id, pred_id, object_id);
@@ -235,7 +321,9 @@ tracker_events_add_delete (gint         graph_id,
 		 * In case of delete, object is the rdf:type */
 		if (is_allowed (private, NULL, object_id)) {
 			insert_vals_into_arrays (private->deletes.class_ids,
-			                         private->deletes.sub_pred_ids,
+			                         //private->deletes.sub_pred_ids,
+			                         private->deletes.subject_ids,
+			                         private->deletes.pred_ids,
 			                         private->deletes.object_ids,
 			                         object_id,
 			                         subject_id, pred_id, object_id);
@@ -246,7 +334,9 @@ tracker_events_add_delete (gint         graph_id,
 		for (i = 0; i < rdf_types->len; i++) {
 			if (is_allowed (private, rdf_types->pdata[i], 0)) {
 				insert_vals_into_arrays (private->deletes.class_ids,
-				                         private->deletes.sub_pred_ids,
+				                         //private->deletes.sub_pred_ids,
+				                         private->deletes.subject_ids,
+				                         private->deletes.pred_ids,
 				                         private->deletes.object_ids,
 				                         tracker_class_get_id (rdf_types->pdata[i]),
 				                         subject_id, pred_id, object_id);
@@ -262,11 +352,15 @@ tracker_events_reset (void)
 	g_return_if_fail (private != NULL);
 
 	g_array_set_size (private->deletes.class_ids, 0);
-	g_array_set_size (private->deletes.sub_pred_ids, 0);
+	//g_array_set_size (private->deletes.sub_pred_ids, 0);
+	g_array_set_size (private->deletes.subject_ids, 0);
+	g_array_set_size (private->deletes.pred_ids, 0);
 	g_array_set_size (private->deletes.object_ids, 0);
 
 	g_array_set_size (private->inserts.class_ids, 0);
-	g_array_set_size (private->inserts.sub_pred_ids, 0);
+	//g_array_set_size (private->inserts.sub_pred_ids, 0);
+	g_array_set_size (private->inserts.subject_ids, 0);
+	g_array_set_size (private->inserts.pred_ids, 0);
 	g_array_set_size (private->inserts.object_ids, 0);
 
 	private->frozen = FALSE;
@@ -287,11 +381,15 @@ free_private (EventsPrivate *private)
 	g_hash_table_unref (private->allowances_id);
 
 	g_array_free (private->deletes.class_ids, TRUE);
-	g_array_free (private->deletes.sub_pred_ids, TRUE);
+	//g_array_free (private->deletes.sub_pred_ids, TRUE);
+	g_array_free (private->deletes.subject_ids, TRUE);
+	g_array_free (private->deletes.pred_ids, TRUE);
 	g_array_free (private->deletes.object_ids, TRUE);
 
 	g_array_free (private->inserts.class_ids, TRUE);
-	g_array_free (private->inserts.sub_pred_ids, TRUE);
+	//g_array_free (private->inserts.sub_pred_ids, TRUE);
+	g_array_free (private->inserts.subject_ids, TRUE);
+	g_array_free (private->inserts.pred_ids, TRUE);
 	g_array_free (private->inserts.object_ids, TRUE);
 
 	g_free (private);
@@ -313,11 +411,15 @@ tracker_events_init (TrackerNotifyClassGetter callback)
 	private->allowances_id = g_hash_table_new (g_direct_hash, g_direct_equal);
 
 	private->deletes.class_ids = g_array_new (FALSE, FALSE, sizeof (gint));
-	private->deletes.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+	//private->deletes.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+	private->deletes.subject_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+	private->deletes.pred_ids = g_array_new (FALSE, FALSE, sizeof (gint));
 	private->deletes.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
 
 	private->inserts.class_ids = g_array_new (FALSE, FALSE, sizeof (gint));
-	private->inserts.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+	//private->inserts.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+	private->inserts.subject_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+	private->inserts.pred_ids = g_array_new (FALSE, FALSE, sizeof (gint));
 	private->inserts.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
 
 	classes_to_signal = (*callback)();
@@ -335,6 +437,9 @@ tracker_events_init (TrackerNotifyClassGetter callback)
 			g_hash_table_insert (private->allowances_id,
 			                     GINT_TO_POINTER (tracker_class_get_id (class)),
 			                     GINT_TO_POINTER (TRUE));
+			g_debug ("ClassSignal allowance: %s has ID %d",
+			         tracker_class_get_name (class),
+			         tracker_class_get_id (class));
 		}
 	}
 	g_strfreev (classes_to_signal);
diff --git a/src/tracker-store/tracker-marshal.list b/src/tracker-store/tracker-marshal.list
index 3dafeb6..9aeb1b9 100644
--- a/src/tracker-store/tracker-marshal.list
+++ b/src/tracker-store/tracker-marshal.list
@@ -4,6 +4,7 @@ VOID:STRING,STRING
 VOID:STRING,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN
 VOID:BOXED
 VOID:BOXED,BOXED
+VOID:STRING,BOXED,BOXED
 
 # Indexer signals
 VOID:DOUBLE,UINT,UINT,BOOL
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index 0bd07c4..56d1e78 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -75,11 +75,12 @@ G_DEFINE_TYPE(TrackerResources, tracker_resources, G_TYPE_OBJECT)
 
 enum {
 	WRITEBACK,
+	CLASSSIGNAL,
 	LAST_SIGNAL
 };
 
 typedef struct {
-	gboolean nothing;
+	DBusConnection *connection;
 } TrackerResourcesPrivate;
 
 typedef struct {
@@ -94,6 +95,14 @@ typedef struct {
 	gpointer user_data;
 } InThreadPtr;
 
+typedef struct {
+	GArray *subject_ids;
+	GArray *pred_ids;
+	GArray *object_ids;
+} TrackerIds;
+
+static TrackerIds inserts_ids = { NULL, NULL, NULL };
+static TrackerIds deletes_ids = { NULL, NULL, NULL };
 static void tracker_resources_finalize (GObject *object);
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -117,6 +126,19 @@ tracker_resources_class_init (TrackerResourcesClass *klass)
 		              G_TYPE_NONE, 1,
 		              TRACKER_TYPE_STR_STRV_MAP);
 
+	/* This is just for introspection to work */
+	signals[CLASSSIGNAL] =
+		g_signal_new ("class-signal",
+		              G_OBJECT_CLASS_TYPE (object_class),
+		              G_SIGNAL_RUN_LAST,
+		              G_STRUCT_OFFSET (TrackerResourcesClass, class_signal),
+		              NULL, NULL,
+		              tracker_marshal_VOID__STRING_BOXED_BOXED,
+		              G_TYPE_NONE, 3,
+		              G_TYPE_STRING,
+		              TRACKER_TYPE_THREE_INT_ARRAY,
+		              TRACKER_TYPE_THREE_INT_ARRAY);
+
 	g_type_class_add_private (object_class, sizeof (TrackerResourcesPrivate));
 }
 
@@ -127,9 +149,16 @@ tracker_resources_init (TrackerResources *object)
 }
 
 TrackerResources *
-tracker_resources_new (void)
+tracker_resources_new (DBusGConnection *connection)
 {
-	return g_object_new (TRACKER_TYPE_RESOURCES, NULL);
+	TrackerResourcesPrivate *priv;
+	TrackerResources *resources = g_object_new (TRACKER_TYPE_RESOURCES, NULL);
+
+	priv = TRACKER_RESOURCES_GET_PRIVATE (resources);
+
+	priv->connection = dbus_connection_ref (dbus_g_connection_get_connection (connection));
+
+	return resources;
 }
 
 /*
@@ -509,17 +538,78 @@ tracker_resources_batch_commit (TrackerResources         *self,
 	/* no longer needed */
 }
 
-static struct {
-	GArray *subject_ids;
-	GArray *pred_ids;
-	GArray *object_ids;
-} inserts_ids = { NULL, NULL, NULL };
+static void
+emit_class_signal (TrackerResources *self,
+                   TrackerClass     *class,
+                   TrackerIds       *deletes,
+                   TrackerIds       *inserts)
+{
+	TrackerResourcesPrivate *priv;
+	DBusMessageIter iter, deletes_iter, inserts_iter;
+	DBusMessage *message;
+	const gchar *class_uri;
+	guint i;
 
-static struct {
-	GArray *subject_ids;
-	GArray *pred_ids;
-	GArray *object_ids;
-} deletes_ids = { NULL, NULL, NULL };
+	priv = TRACKER_RESOURCES_GET_PRIVATE (self);
+
+	message = dbus_message_new_signal (TRACKER_RESOURCES_PATH,
+	                                   TRACKER_RESOURCES_INTERFACE,
+	                                   "ClassSignal");
+
+	class_uri = tracker_class_get_uri (class);
+
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &class_uri);
+
+	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, 
+	                                  "(iii)", &deletes_iter);
+
+	for (i = 0; i < deletes->subject_ids->len; i++) {
+		DBusMessageIter struct_iter;
+		gint subject_id, pred_id, object_id;
+
+		subject_id = g_array_index (deletes->subject_ids, gint, i);
+		pred_id = g_array_index (deletes->pred_ids, gint, i);
+		object_id = g_array_index (deletes->object_ids, gint, i);
+
+		dbus_message_iter_open_container (&deletes_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter);
+
+		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);
+
+		dbus_message_iter_close_container (&deletes_iter, &struct_iter);
+	}
+
+	dbus_message_iter_close_container (&iter, &deletes_iter);
+
+
+	dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, 
+	                                  "(iii)", &inserts_iter);
+
+	for (i = 0; i < inserts->subject_ids->len; i++) {
+		DBusMessageIter struct_iter;
+		gint subject_id, pred_id, object_id;
+
+		subject_id = g_array_index (inserts->subject_ids, gint, i);
+		pred_id = g_array_index (inserts->pred_ids, gint, i);
+		object_id = g_array_index (inserts->object_ids, gint, i);
+
+		dbus_message_iter_open_container (&inserts_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter);
+
+		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);
+
+		dbus_message_iter_close_container (&inserts_iter, &struct_iter);
+	}
+
+	dbus_message_iter_close_container (&iter, &inserts_iter);
+
+	dbus_connection_send (priv->connection, message, NULL);
+
+	dbus_message_unref (message);
+}
 
 static void
 on_statements_committed (gpointer user_data)
@@ -555,7 +645,7 @@ on_statements_committed (gpointer user_data)
 		g_array_set_size (deletes_ids.pred_ids, 0);
 		g_array_set_size (deletes_ids.object_ids, 0);
 
-		tracker_events_get_inserts (tracker_class_get_id (class),
+		tracker_events_get_deletes (tracker_class_get_id (class),
 		                            deletes_ids.subject_ids,
 		                            deletes_ids.pred_ids,
 		                            deletes_ids.object_ids);
@@ -569,7 +659,9 @@ on_statements_committed (gpointer user_data)
 		                            inserts_ids.pred_ids,
 		                            inserts_ids.object_ids);
 
-		/* TODO: Emit the signal with tracker_class_get_uri (class) */
+		if (inserts_ids.subject_ids->len > 0 || deletes_ids.subject_ids->len > 0) {
+			emit_class_signal (user_data, class, &deletes_ids, &inserts_ids);
+		}
 	}
 
 	tracker_events_reset ();
@@ -649,6 +741,8 @@ tracker_resources_finalize (GObject      *object)
 	tracker_data_remove_commit_statement_callback (on_statements_committed, object);
 	tracker_data_remove_rollback_statement_callback (on_statements_rolled_back, object);
 
+	dbus_connection_unref (priv->connection);
+
 	G_OBJECT_CLASS (tracker_resources_parent_class)->finalize (object);
 }
 
diff --git a/src/tracker-store/tracker-resources.h b/src/tracker-store/tracker-resources.h
index 2148c7e..a24d675 100644
--- a/src/tracker-store/tracker-resources.h
+++ b/src/tracker-store/tracker-resources.h
@@ -46,12 +46,16 @@ struct TrackerResources {
 struct TrackerResourcesClass {
 	GObjectClass parent;
 
-	void     (*writeback)                          (TrackerResources *resources,
-	                                                GStrv subjects);
+	void     (*writeback)                               (TrackerResources *resources,
+	                                                     GStrv subjects);
+	void     (*class_signal)                            (TrackerResources *resources,
+	                                                     const gchar      *classname,
+	                                                     GPtrArray        *deletes,
+	                                                     GPtrArray        *inserts);
 };
 
 GType             tracker_resources_get_type            (void);
-TrackerResources *tracker_resources_new                 (void);
+TrackerResources *tracker_resources_new                 (DBusGConnection        *connection);
 void              tracker_resources_prepare             (TrackerResources       *object);
 void              tracker_resources_unprepare           (TrackerResources       *object);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]