[tracker/architecture-sparql-up-in-daemon] Share the same function to get the classes to signal



commit 8d4969697d910292ee52d8ea3bf94fcae2f6f295
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Apr 23 12:17:09 2009 +0200

    Share the same function to get the classes to signal
---
 src/trackerd/tracker-dbus.c |   33 ++++++++++++++++++++++++---------
 src/trackerd/tracker-dbus.h |    1 +
 src/trackerd/tracker-main.c |   20 +-------------------
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/trackerd/tracker-dbus.c b/src/trackerd/tracker-dbus.c
index 6639114..936dfb5 100644
--- a/src/trackerd/tracker-dbus.c
+++ b/src/trackerd/tracker-dbus.c
@@ -258,6 +258,25 @@ tracker_dbus_shutdown (void)
 	connection = NULL;
 }
 
+
+GStrv
+tracker_dbus_get_notifiable_classes (void)
+{
+	TrackerDBResultSet *result_set;
+	GStrv               classes_to_signal = NULL;
+
+	result_set = tracker_data_query_sparql ("SELECT ?class WHERE { ?class tracker:notify true }", NULL);
+
+	if (result_set) {
+		guint count = 0;
+
+		classes_to_signal = tracker_dbus_query_result_to_strv (result_set, 0, &count);
+		g_object_unref (result_set);
+	}
+
+	return classes_to_signal;
+}
+
 gboolean
 tracker_dbus_register_objects (TrackerConfig	*config,
 			       TrackerLanguage	*language,
@@ -265,7 +284,8 @@ tracker_dbus_register_objects (TrackerConfig	*config,
 {
 	gpointer object, resources;
 	GSList *event_sources = NULL;
-	TrackerDBResultSet *result_set;
+	guint ui;
+	GStrv classes_to_signal;
 
 	g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
 	g_return_val_if_fail (TRACKER_IS_LANGUAGE (language), FALSE);
@@ -335,15 +355,11 @@ tracker_dbus_register_objects (TrackerConfig	*config,
 	/* Reverse list since we added objects at the top each time */
 	objects = g_slist_reverse (objects);
 
-	result_set = tracker_data_query_sparql ("SELECT ?class WHERE { ?class tracker:notify true }", NULL);
+	classes_to_signal = tracker_dbus_get_notifiable_classes ();
 
-	if (result_set) {
-		GStrv classes_to_signal;
-		guint ui, count = 0;
+	if (classes_to_signal) {
 
-		classes_to_signal = tracker_dbus_query_result_to_strv (result_set, 0, &count);
-
-		for (ui = 0; ui < count; ui++) {
+		for (ui = 0; classes_to_signal[ui] != NULL; ui++) {
 			const gchar *rdf_class = classes_to_signal[ui];
 			gchar *replaced;
 			gchar *path, *uri, *hash;
@@ -395,7 +411,6 @@ tracker_dbus_register_objects (TrackerConfig	*config,
 		}
 
 		g_strfreev (classes_to_signal);
-		g_object_unref (result_set);
 	}
 
 
diff --git a/src/trackerd/tracker-dbus.h b/src/trackerd/tracker-dbus.h
index 0fbf797..d5a6646 100644
--- a/src/trackerd/tracker-dbus.h
+++ b/src/trackerd/tracker-dbus.h
@@ -43,6 +43,7 @@ gboolean    tracker_dbus_register_objects        (TrackerConfig    *config,
 GObject    *tracker_dbus_get_object              (GType             type);
 void        tracker_dbus_indexer_check_is_paused (void);
 DBusGProxy *tracker_dbus_indexer_get_proxy       (void);
+GStrv       tracker_dbus_get_notifiable_classes  (void);
 
 G_END_DECLS
 
diff --git a/src/trackerd/tracker-main.c b/src/trackerd/tracker-main.c
index e209a3d..94aa478 100644
--- a/src/trackerd/tracker-main.c
+++ b/src/trackerd/tracker-main.c
@@ -816,24 +816,6 @@ start_cb (gpointer user_data)
 }
 
 
-static GStrv
-tracker_daemon_get_notifiable_classes (void)
-{
-	TrackerDBResultSet *result_set;
-	GStrv               classes_to_signal = NULL;
-
-	result_set = tracker_data_query_sparql ("SELECT ?class WHERE { ?class tracker:notify true }", NULL);
-
-	if (result_set) {
-		guint count = 0;
-
-		classes_to_signal = tracker_dbus_query_result_to_strv (result_set, 0, &count);
-		g_object_unref (result_set);
-	}
-
-	return classes_to_signal;
-}
-
 gint
 main (gint argc, gchar *argv[])
 {
@@ -1045,7 +1027,7 @@ main (gint argc, gchar *argv[])
 		return EXIT_FAILURE;
 	}
 
-	tracker_events_init (tracker_daemon_get_notifiable_classes);
+	tracker_events_init (tracker_dbus_get_notifiable_classes);
 	tracker_push_init (config);
 
 	g_message ("Waiting for DBus requests...");



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