tracker r1541 - in branches/xesam-support: . src/trackerd



Author: pvanhoof
Date: Fri May 30 10:26:46 2008
New Revision: 1541
URL: http://svn.gnome.org/viewvc/tracker?rev=1541&view=rev

Log:
2008-05-30  Philip Van Hoof  <pvanhoof gnome org>

        * src/trackerd/tracker-xesam-live-search.c:
        * src/trackerd/tracker-xesam-live-search.h:
        * src/trackerd/tracker-xesam-manager.c:

        Making it possible to pass which exact events occurred, to better
        finetune the periodic LiveSearch query in future



Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
   branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
   branches/xesam-support/src/trackerd/tracker-xesam-manager.c

Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c	Fri May 30 10:26:46 2008
@@ -268,13 +268,16 @@
 
 /* Created and Modified items */
 static void
-get_hits_added_modified (TrackerXesamLiveSearch *self, DBConnection *db_con, GArray **added, GArray **modified) 
+get_hits_added_modified (TrackerXesamLiveSearch *self, MatchWithEventsFlags flags, DBConnection *db_con, GArray **added, GArray **modified) 
 {
 	gboolean            ls_valid = TRUE;
 	GArray             *m_added = NULL;
 	GArray             *m_modified = NULL;
 	TrackerDBResultSet *result_set;
 
+	/* Right now we are ignoring flags (both creates and updates are 
+	 * searched) */
+
 	result_set = tracker_db_get_live_search_new_ids (db_con, 
 		tracker_xesam_live_search_get_id (self),
 		tracker_xesam_live_search_get_from_query (self),
@@ -379,47 +382,51 @@
  * Find all items that match with the current events for @self.
  **/
 void
-tracker_xesam_live_search_match_with_events (TrackerXesamLiveSearch *self, GArray **added, GArray **removed, GArray **modified)
+tracker_xesam_live_search_match_with_events (TrackerXesamLiveSearch *self, MatchWithEventsFlags flags, GArray **added, GArray **removed, GArray **modified)
 {
-	DBConnection *db_con = NULL;
+	DBConnection       *db_con = NULL;
 	TrackerDBResultSet *result_set;
-	gboolean ls_valid = TRUE;
-	GArray *m_added = NULL, *m_removed = NULL, *m_modified = NULL;
+	gboolean            ls_valid = TRUE;
+	GArray             *m_added = NULL;
+	GArray             *m_removed = NULL;
+	GArray             *m_modified = NULL;
 
 	GObject *xesam = tracker_dbus_get_object (TRACKER_TYPE_XESAM);
 
 	g_object_get (xesam, "db-connection", &db_con, NULL);
 
-	/* Deleted items */
+	if (flags & MATCH_WITH_EVENTS_DELETES) {
 
-	result_set = tracker_db_get_live_search_deleted_ids (db_con, 
-		tracker_xesam_live_search_get_id (self));
+		/* Deleted items */
+		result_set = tracker_db_get_live_search_deleted_ids (db_con, 
+			tracker_xesam_live_search_get_id (self));
 
-	if (!result_set)
-		goto part_two;
+		if (!result_set)
+			goto part_two;
 
-	while (ls_valid) {
-		GValue ls_value = { 0, };
-		gint ls_i_value;
+		while (ls_valid) {
+			GValue ls_value = { 0, };
+			gint ls_i_value;
 
-		_tracker_db_result_set_get_value (result_set, 0, &ls_value);
-		ls_i_value = g_value_get_int (&ls_value);
+			_tracker_db_result_set_get_value (result_set, 0, &ls_value);
+			ls_i_value = g_value_get_int (&ls_value);
 
-		if (m_removed == NULL)
-			m_removed = g_array_new (FALSE, TRUE, sizeof (guint32));
-		g_array_append_val (m_removed, ls_i_value);
+			if (m_removed == NULL)
+				m_removed = g_array_new (FALSE, TRUE, sizeof (guint32));
+			g_array_append_val (m_removed, ls_i_value);
 
-		g_value_unset (&ls_value);
+			g_value_unset (&ls_value);
 
-		ls_valid = tracker_db_result_set_iter_next (result_set);
-	}
+			ls_valid = tracker_db_result_set_iter_next (result_set);
+		}
 
-	g_object_unref (result_set);
+		g_object_unref (result_set);
+	}
 
 part_two:
 
 	/* Created and Modified items */
-	get_hits_added_modified (self, db_con, &m_added, &m_modified);
+	get_hits_added_modified (self, flags, db_con, &m_added, &m_modified);
 
 	*added = m_added;
 	*removed = m_removed;

Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.h	Fri May 30 10:26:46 2008
@@ -39,6 +39,14 @@
 typedef struct _TrackerXesamLiveSearchClass TrackerXesamLiveSearchClass;
 typedef struct _TrackerXesamLiveSearchPriv TrackerXesamLiveSearchPriv;
 
+typedef enum {
+	MATCH_WITH_EVENTS_CREATES = 1<<0,
+	MATCH_WITH_EVENTS_DELETES = 1<<1,
+	MATCH_WITH_EVENTS_MODIFIES = 1<<2
+} MatchWithEventsFlags;
+
+#define MATCH_WITH_EVENTS_ALL_FLAGS (MATCH_WITH_EVENTS_CREATES|MATCH_WITH_EVENTS_DELETES|MATCH_WITH_EVENTS_MODIFIES)
+
 struct _TrackerXesamLiveSearch {
 	GObject parent_instance;
 	TrackerXesamLiveSearchPriv * priv;
@@ -101,6 +109,7 @@
 							   GArray                  *hit_ids);
 void         tracker_xesam_live_search_emit_done          (TrackerXesamLiveSearch  *self);
 void         tracker_xesam_live_search_match_with_events  (TrackerXesamLiveSearch  *self, 
+							   MatchWithEventsFlags     flags,
 							   GArray                 **added, 
 							   GArray                 **removed, 
 							   GArray                 **modified);

Modified: branches/xesam-support/src/trackerd/tracker-xesam-manager.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-manager.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-manager.c	Fri May 30 10:26:46 2008
@@ -234,7 +234,8 @@
 			g_debug ("Search being handled, ID :%s", tracker_xesam_live_search_get_id (searches->data));
 
 			search = searches->data;
-			tracker_xesam_live_search_match_with_events (search, 
+			tracker_xesam_live_search_match_with_events (search,
+								     MATCH_WITH_EVENTS_ALL_FLAGS,
 								     &added, 
 								     &removed, 
 								     &modified);



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