tracker r1481 - in branches/indexer-split: . src/trackerd



Author: pvanhoof
Date: Mon May 26 09:07:30 2008
New Revision: 1481
URL: http://svn.gnome.org/viewvc/tracker?rev=1481&view=rev

Log:
        * svn merge -r 1423:1480 ../xesam-support



Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/trackerd/tracker-db-sqlite.c
   branches/indexer-split/src/trackerd/tracker-db-sqlite.h
   branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
   branches/indexer-split/src/trackerd/tracker-xesam-live-search.c
   branches/indexer-split/src/trackerd/tracker-xesam-live-search.h
   branches/indexer-split/src/trackerd/tracker-xesam-query.h
   branches/indexer-split/src/trackerd/tracker-xesam-session.c
   branches/indexer-split/src/trackerd/tracker-xesam.c

Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c	Mon May 26 09:07:30 2008
@@ -3406,7 +3406,7 @@
 
 
 void 
-tracker_db_delete_handled_events (DBConnection *db_con, TrackerDBResultSet *events)
+tracker_db_delete_handled_events (DBConnection *db_con)
 {
 	tracker_exec_proc_no_reply (db_con->cache->db, "DeleteHandledEvents", NULL);
 }

Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.h	Mon May 26 09:07:30 2008
@@ -320,8 +320,7 @@
 
 /* XESAM stuff */
 TrackerDBResultSet *tracker_db_get_events                      (DBConnection *db_con);
-void                tracker_db_delete_handled_events           (DBConnection   *db_con, 
-                                                                TrackerDBResultSet *events);
+void                tracker_db_delete_handled_events           (DBConnection   *db_con);
 TrackerDBResultSet *tracker_db_get_live_search_deleted_ids     (DBConnection *db_con, 
                                                                 const gchar *search_id);
 TrackerDBResultSet *tracker_db_get_live_search_new_ids         (DBConnection *db_con, 

Modified: branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-xesam.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-xesam.c	Mon May 26 09:07:30 2008
@@ -241,11 +241,11 @@
 }
 
 void 
-tracker_dbus_xesam_name_owner_changed (DBusGProxy        *proxy,
+tracker_dbus_xesam_name_owner_changed (DBusGProxy          *proxy,
 					 const char        *name,
 					 const char        *prev_owner,
 					 const char        *new_owner,
-					 TrackerDBusXesam *self)
+					 TrackerDBusXesam  *self)
 {
 	if (sessions) {
 		GList *my_sessions = g_hash_table_lookup (sessions, prev_owner);
@@ -304,10 +304,11 @@
 					my_sessions);
 
 		dbus_g_method_return (context, session_id);
-		g_free (session_id);
 	}
 
+	g_free (session_id);
 	g_free (key);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -364,22 +365,30 @@
 
 	if (session) {
 		GValue *new_val = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_session_set_property (session, prop, val, &new_val, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else if (new_val) {
+		} else if (new_val)
 			dbus_g_method_return (context, new_val);
+
+		if (new_val)
 			g_value_unset (new_val);
-		}
 
-		g_object_unref (session);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (session)
+		g_object_unref (session);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -395,23 +404,32 @@
 
 	if (session) {
 		GValue *value = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_session_get_property (session, prop, &value, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else
 			dbus_g_method_return (context, value);
+
+		if (value) {
 			g_value_unset (value);
 			g_free (value);
 		}
 
-		g_object_unref (session);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (session)
+		g_object_unref (session);
+
 	tracker_dbus_request_success (request_id);
 
 	return;
@@ -431,25 +449,32 @@
 	if (session) {
 		TrackerXesamLiveSearch *search;
 		gchar *search_id = NULL;
-		search = tracker_xesam_session_create_search (session, query_xml, &search_id, &error);
 
-		if (search)
-			g_object_unref (search);
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
+		search = tracker_xesam_session_create_search (session, query_xml, &search_id, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else 
 			dbus_g_method_return (context, search_id);
-			g_free (search_id);
-		}
 
-		g_object_unref (session);
+		if (search)
+			g_object_unref (search);
+
+		g_free (search_id);
+
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (session)
+		g_object_unref (session);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -463,6 +488,11 @@
 	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_activate (search, &error);
 
 		if (error) {
@@ -471,12 +501,14 @@
 		} else
 			dbus_g_method_return (context);
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -491,6 +523,11 @@
 
 	if (search) {
 		guint count = -1;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_get_hit_count (search, &count, &error);
 
 		if (error) {
@@ -499,13 +536,14 @@
 		} else
 			dbus_g_method_return (context, count);
 
-		g_object_unref (search);
-
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -542,22 +580,30 @@
 
 	if (search) {
 		GPtrArray *hits = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_get_hits (search, count, &hits, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else
 			dbus_g_method_return (context, hits);
+
+		if (hits)
 			freeup_hits_data (hits);
-		}
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -576,22 +622,30 @@
 
 	if (search) {
 		GPtrArray *hits = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_get_range_hits (search, a, b, &hits, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else 
 			dbus_g_method_return (context, hits);
+
+		if (hits)
 			freeup_hits_data (hits);
-		}
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -609,23 +663,30 @@
 
 	if (search) {
 		GPtrArray *hit_data = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_get_hit_data (search, hit_ids, fields, &hit_data, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else 
 			dbus_g_method_return (context, hit_data);
-			freeup_hits_data (hit_data);
-		}
 
+		if (hit_data)
+			freeup_hits_data (hit_data);
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -645,23 +706,30 @@
 
 	if (search) {
 		GPtrArray *hit_data = NULL;
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_get_range_hit_data (search, a, b, fields, &hit_data, &error);
 
 		if (error) {
 			dbus_g_method_return_error (context, error);
 			g_error_free (error);
-		} else {
+		} else
 			dbus_g_method_return (context, hit_data);
-			freeup_hits_data (hit_data);
-		}
 
+		if (hit_data)
+			freeup_hits_data (hit_data);
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 
@@ -675,6 +743,11 @@
 	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
+
+		if (error)
+			g_error_free (error);
+		error = NULL;
+
 		tracker_xesam_live_search_close (search, &error);
 
 		if (error) {
@@ -683,12 +756,14 @@
 		} else
 			dbus_g_method_return (context);
 
-		g_object_unref (search);
 	} else if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	}
 
+	if (search)
+		g_object_unref (search);
+
 	tracker_dbus_request_success (request_id);
 }
 

Modified: branches/indexer-split/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-live-search.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-live-search.c	Mon May 26 09:07:30 2008
@@ -15,7 +15,8 @@
  *
  * You should have received a copy of the GNU General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA  02110-1301, USA.
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301, USA.
  */
 
 #include <string.h>
@@ -49,15 +50,15 @@
 {
 	TrackerXesamLiveSearch *self = (TrackerXesamLiveSearch *) object;
 	TrackerXesamLiveSearchPriv *priv = self->priv;
+
 	if (priv->session)
 		g_object_unref (priv->session);
+
 	g_free (priv->search_id);
 	g_free (priv->query);
+
 	g_free (priv->from_sql);
 	g_free (priv->where_sql);
-
-	if (priv->session)
-		g_object_unref (priv->session);
 }
 
 void
@@ -65,8 +66,10 @@
 				       gpointer session)
 {
 	TrackerXesamLiveSearchPriv *priv = self->priv;
+
 	if (priv->session)
 		g_object_unref (priv->session);
+
 	priv->session = g_object_ref (session);
 }
 
@@ -214,7 +217,6 @@
 /**
  * tracker_xesam_live_search_match_with_events:
  * @self: A #TrackerXesamLiveSearch
- * @result_set: a #TrackerDBResultSet with all items in Events
  * @added: (caller-owns) (out): added items
  * @removed: (caller-owns) (out): removed items
  * @modified: (caller-owns) (out): modified items
@@ -222,7 +224,7 @@
  * Find all items that match with the current events for @self.
  **/
 void
-tracker_xesam_live_search_match_with_events (TrackerXesamLiveSearch *self, TrackerDBResultSet *events, GArray **added, GArray **removed, GArray **modified)
+tracker_xesam_live_search_match_with_events (TrackerXesamLiveSearch *self, GArray **added, GArray **removed, GArray **modified)
 {
 	TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
 	DBConnection *db_con = NULL;
@@ -723,13 +725,16 @@
 	return (const gchar*) priv->search_id;
 }
 
+
 /**
  * tracker_xesam_live_search_parse_query:
  * @self: a #TrackerXesamLiveSearch
  *
  * Parses the current xml query and sets the sql
+ *
+ * Return value: whether parsing succeeded, if not @error will also be set
  **/
-void
+gboolean
 tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch  *self,
 				       GError                 **error)
 {
@@ -737,11 +742,12 @@
 	TrackerDBusXesam           *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
 	DBConnection               *db_con = NULL;
 	GError                     *parse_error = NULL;
+	gchar                      *orig_from, *orig_where;
 
 	g_object_get (proxy, "db-connection", &db_con, NULL);
 
-	g_free (priv->from_sql);
-	g_free (priv->where_sql);
+	orig_from = priv->from_sql;
+	orig_where = priv->where_sql;
 
 	priv->from_sql = NULL;
 	priv->where_sql = NULL;
@@ -752,16 +758,27 @@
 				    &parse_error);
 
 	if (parse_error) {
-			gchar *str = g_strdup_printf ("Parse error: %s", 
-				parse_error->message);
-			g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN, 
-				     TRACKER_XESAM_ERROR_PARSING_FAILED,
-				     str);
-			g_free (str);
-			g_error_free (parse_error);
+		gchar *str = g_strdup_printf ("Parse error: %s", 
+			parse_error->message);
+		g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN, 
+			     TRACKER_XESAM_ERROR_PARSING_FAILED,
+			     str);
+		g_free (str);
+		g_error_free (parse_error);
+
+		g_free (priv->from_sql);
+		g_free (priv->where_sql);
+
+		priv->from_sql = orig_from;
+		priv->where_sql = orig_where;
+
+		return FALSE;
+	} else {
+		g_free (orig_from);
+		g_free (orig_where);
 	}
 
-	return;
+	return TRUE;
 }
 
 /**

Modified: branches/indexer-split/src/trackerd/tracker-xesam-live-search.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-live-search.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-live-search.h	Mon May 26 09:07:30 2008
@@ -53,20 +53,19 @@
 void         tracker_xesam_live_search_set_id             (TrackerXesamLiveSearch  *self,
 							   const gchar             *search_id);
 const gchar* tracker_xesam_live_search_get_id             (TrackerXesamLiveSearch  *self);
-
 const gchar* tracker_xesam_live_search_get_where_query    (TrackerXesamLiveSearch  *self);
 const gchar* tracker_xesam_live_search_get_from_query     (TrackerXesamLiveSearch  *self);
 const gchar* tracker_xesam_live_search_get_xml_query      (TrackerXesamLiveSearch  *self);
 void         tracker_xesam_live_search_set_xml_query      (TrackerXesamLiveSearch  *self, 
 							   const gchar             *xml_query);
-void         tracker_xesam_live_search_set_session        (TrackerXesamLiveSearch *self, 
+void         tracker_xesam_live_search_set_session        (TrackerXesamLiveSearch  *self, 
+							   gpointer                 session);
+void         tracker_xesam_live_search_set_session        (TrackerXesamLiveSearch  *self, 
 							   gpointer                 session);
-void         tracker_xesam_live_search_set_session        (TrackerXesamLiveSearch *self, 
-							   gpointer session);
 void         tracker_xesam_live_search_activate           (TrackerXesamLiveSearch  *self,
 							   GError                 **error);
 gboolean     tracker_xesam_live_search_is_active          (TrackerXesamLiveSearch  *self);
-void         tracker_xesam_live_search_parse_query        (TrackerXesamLiveSearch  *self,
+gboolean     tracker_xesam_live_search_parse_query        (TrackerXesamLiveSearch  *self,
 							   GError                 **error);
 void         tracker_xesam_live_search_get_hit_data       (TrackerXesamLiveSearch  *self,
 							   GArray                  *hit_ids,
@@ -80,7 +79,7 @@
 void         tracker_xesam_live_search_get_range_hit_data (TrackerXesamLiveSearch  *self,
 							   guint                    a,
 							   guint                    b,
-							   GStrv                  fields, 
+							   GStrv                    fields, 
 							   GPtrArray              **hit_data,
 							   GError                 **error);
 void         tracker_xesam_live_search_get_range_hits     (TrackerXesamLiveSearch  *self,
@@ -101,7 +100,6 @@
 							   GArray                  *hit_ids);
 void         tracker_xesam_live_search_emit_done          (TrackerXesamLiveSearch  *self);
 void         tracker_xesam_live_search_match_with_events  (TrackerXesamLiveSearch  *self, 
-							   TrackerDBResultSet      *events,
 							   GArray                 **added, 
 							   GArray                 **removed, 
 							   GArray                 **modified);

Modified: branches/indexer-split/src/trackerd/tracker-xesam-query.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-query.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-query.h	Mon May 26 09:07:30 2008
@@ -26,6 +26,10 @@
 
 #include "tracker-db.h"
 
-void tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, gchar **from, gchar **where, GError **error);
+void                    tracker_xesam_query_to_sql          (DBConnection *db_con, 
+                                                             const char   *query, 
+                                                             gchar       **from, 
+                                                             gchar       **where, 
+                                                             GError      **error);
 
 #endif

Modified: branches/indexer-split/src/trackerd/tracker-xesam-session.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-session.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-session.c	Mon May 26 09:07:30 2008
@@ -73,13 +73,14 @@
 	const gchar *exts[1] = {NULL};
 	const gchar *dummy_onto[4] = {"dummy-onto","0.1","/usr/share/xesam/ontologies/dummy-onto-0.1", NULL};
 	GPtrArray *ontos = g_ptr_array_new ();
-	
+
 	priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,TRACKER_TYPE_XESAM_SESSION,struct _TrackerXesamSessionPriv);
 
 	g_ptr_array_add (ontos, dummy_onto);
 	
 	priv->session_id = NULL;
 
+
 	priv->searches = g_hash_table_new_full (g_str_hash, g_str_equal, 
 				(GDestroyNotify) g_free,
 				(GDestroyNotify) g_object_unref);
@@ -369,7 +370,7 @@
  * Signals will not be emitted before a call to @tracker_xesam_live_search_activate
  * has been made. 
  *
- * @returns: (caller-owns): a new non-activated #TrackerXesamLiveSearch
+ * @returns: (null-ok) (caller-owns): a new non-activated #TrackerXesamLiveSearch
  **/
 TrackerXesamLiveSearch* 
 tracker_xesam_session_create_search (TrackerXesamSession  *self, 
@@ -381,18 +382,23 @@
 	TrackerXesamSessionPriv *priv = self->priv;
 
 	search = tracker_xesam_live_search_new (query_xml);
+
 	tracker_xesam_live_search_set_session (search, self);
 	tracker_xesam_live_search_set_id (search, tracker_xesam_generate_unique_key ());
-	if (search_id) 
-		*search_id = g_strdup (tracker_xesam_live_search_get_id (search));
 
-	tracker_xesam_live_search_set_session (search, self);
+	if (tracker_xesam_live_search_parse_query (search, error)) {
 
-	g_hash_table_insert (priv->searches, 
-		g_strdup (tracker_xesam_live_search_get_id (search)),
-		g_object_ref (search));
+		g_hash_table_insert (priv->searches, 
+			g_strdup (tracker_xesam_live_search_get_id (search)),
+			g_object_ref (search));
 
-	tracker_xesam_live_search_parse_query (search, error);
+		if (search_id) 
+			*search_id = g_strdup (tracker_xesam_live_search_get_id (search));
+
+	} else {
+		g_object_unref (search);
+		search = NULL;
+	}
 
 	return search;
 }
@@ -417,6 +423,11 @@
 
 	if (search)
 		g_object_ref (search);
+	else {
+		g_set_error (error, TRACKER_XESAM_ERROR_DOMAIN, 
+				TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
+				"SearchID not registered");
+	}
 
 	return search;
 }

Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c	Mon May 26 09:07:30 2008
@@ -189,13 +189,11 @@
 static gboolean 
 live_search_handler (gpointer data)
 {
-	TrackerDBResultSet *result_set;
 	TrackerDBusXesam   *proxy;
 	DBConnection       *db_con = NULL;
 	GList              *sessions;
 	gboolean            reason_to_live = FALSE;
 
-	sessions = g_hash_table_get_values (xesam_sessions);
 	proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
 
 	if (!proxy) {
@@ -208,69 +206,61 @@
 		return FALSE;
 	}
 
-	result_set = tracker_db_get_events (db_con);
-
-	if (result_set && tracker_db_result_set_get_n_rows (result_set) > 0) {
-		reason_to_live = TRUE;
-
-		while (sessions) {
-			GList *searches;
-
-			searches = tracker_xesam_session_get_searches (sessions->data);
-
-			while (searches) {
-				TrackerXesamLiveSearch *search;
-				GArray                 *added = NULL;
-				GArray                 *removed = NULL;
-				GArray                 *modified = NULL;
-
-				search = searches->data;
-				tracker_xesam_live_search_match_with_events (search, 
-									     result_set, 
-									     &added, 
-									     &removed, 
-									     &modified);
-
-				if (added && added->len > 0) { 
-					tracker_xesam_live_search_emit_hits_added (search, added->len);
-				}
-
-				if (added) {
-					g_array_free (added, TRUE);
-				}
+	sessions = g_hash_table_get_values (xesam_sessions);
 
-				if (removed && removed->len > 0) {
-					tracker_xesam_live_search_emit_hits_removed (search, removed);
-				}
+	while (sessions) {
+		GList *searches;
+		searches = tracker_xesam_session_get_searches (sessions->data);
+
+		while (searches) {
+			TrackerXesamLiveSearch *search;
+			GArray                 *added = NULL;
+			GArray                 *removed = NULL;
+			GArray                 *modified = NULL;
+			search = searches->data;
+			tracker_xesam_live_search_match_with_events (search, 
+								     &added, 
+								     &removed, 
+								     &modified);
+
+			if (added && added->len > 0) {
+				reason_to_live = TRUE;
+				tracker_xesam_live_search_emit_hits_added (search, added->len);
+			}
 
-				if (removed) {
-					g_array_free (removed, TRUE);
-				}
+			if (added) {
+				g_array_free (added, TRUE);
+			}
 
-				if (modified && modified->len > 0) {
-					tracker_xesam_live_search_emit_hits_modified (search, modified);
-				}
+			if (removed && removed->len > 0) {
+				reason_to_live = TRUE;
+				tracker_xesam_live_search_emit_hits_removed (search, removed);
+			}
 
-				if (modified) {
-					g_array_free (modified, TRUE);
-				}
+			if (removed) {
+				g_array_free (removed, TRUE);
+			}
 
-				searches = g_list_next (searches);
+			if (modified && modified->len > 0) {
+				reason_to_live = TRUE;
+				tracker_xesam_live_search_emit_hits_modified (search, modified);
 			}
 
-			g_list_free (searches);
+			if (modified) {
+				g_array_free (modified, TRUE);
+			}
 
-			sessions = g_list_next (sessions);
+			searches = g_list_next (searches);
 		}
 
-		g_list_free (sessions);
+		g_list_free (searches);
 
-		tracker_db_delete_handled_events (db_con, result_set);
+		sessions = g_list_next (sessions);
 	}
 
-	if (result_set) {
-		g_object_unref (result_set);
-	}
+	g_list_free (sessions);
+
+	tracker_db_delete_handled_events (db_con);
 
 	return reason_to_live;
 }
@@ -288,12 +278,12 @@
 
 	/* We could do this in a thread too, in case blocking the GMainLoop is
 	 * not ideal (it's not, because during these blocks of code, no DBus
-	 * request handler can run). I have added sufficient locking to let a
-	 * thread do it too (although untested).
+	 * request handler can run). 
 	 * 
 	 * In case of a thread we could use usleep() and stop the thread if
 	 * we didn't get a wakeup-call nor we had items to process this loop
 	 */
+
 	if (!live_search_handler_running) {
 		live_search_handler_running = TRUE;
 		g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
@@ -312,9 +302,6 @@
 	guint         t, ut, p, u, r;
 	GTimeVal      tv;
 
-	/* This function is hardly cryptographically random but should
-	 * be "good enough" 
-	 */
 	g_get_current_time (&tv);
 
 	t = tv.tv_sec;
@@ -328,39 +315,9 @@
 	u = 0;
 #endif
 
-	/* Don't bother to seed; if it's based on the time or any
-	 * other changing info we can get, we may as well just use
-	 * that changing info. since we don't seed we'll at least get
-	 * a different number on every call to this function in the
-	 * same executable.
-	 */
 	r = rand ();
-
-	/* The letters may increase uniqueness by preventing "melds"
-	 * i.e. 01t01k01 and 0101t0k1 are not the same  
-	 */
 	key = g_strdup_printf ("%ut%uut%uu%up%ur%uk%u",
-			       /* Duplicate keys must be generated by
-				* two different program instances */ 
-			       serial,
-			       /* Duplicate keys must be generated in
-				* the same microsecond */
-			       t,
-			       ut,
-			       /* Duplicate keys must be generated by
-				* the same user */
-			       u,
-			       /* Duplicate keys must be generated by
-				* two programs that got the same PID */
-			       p,
-			       /* Duplicate keys must be generated with
-				* the same random seed and the same
-				* index into the series of pseudorandom
-				* values */
-			       r,
-			       /* Duplicate keys must result from
-				* running this function at the same
-				* stack location */
+			       serial, t, ut, u, p, r,
 			       GPOINTER_TO_UINT (&key));
 
 	++serial;



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