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



Author: pvanhoof
Date: Tue May 20 09:16:52 2008
New Revision: 1453
URL: http://svn.gnome.org/viewvc/tracker?rev=1453&view=rev

Log:
	* src/trackerd/tracker-xesam-live-search.c
	* src/trackerd/tracker-xesam-live-search.h
	* src/trackerd/tracker-dbus-xesam.c
	* src/trackerd/tracker-xesam.c
	* src/trackerd/tracker-db-sqlite.c
	* src/trackerd/tracker-db-sqlite.h: Code cleanups



Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/src/trackerd/tracker-db-sqlite.c
   branches/xesam-support/src/trackerd/tracker-db-sqlite.h
   branches/xesam-support/src/trackerd/tracker-dbus-xesam.c
   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.c

Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c	Tue May 20 09:16:52 2008
@@ -3396,7 +3396,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/xesam-support/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.h	Tue May 20 09:16:52 2008
@@ -329,8 +329,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/xesam-support/src/trackerd/tracker-dbus-xesam.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-dbus-xesam.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-dbus-xesam.c	Tue May 20 09:16:52 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/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	Tue May 20 09:16:52 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,14 @@
 {
 	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 +65,10 @@
 				       gpointer session)
 {
 	TrackerXesamLiveSearchPriv *priv = self->priv;
+
 	if (priv->session)
 		g_object_unref (priv->session);
+
 	priv->session = g_object_ref (session);
 }
 
@@ -214,7 +216,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 +223,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;

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	Tue May 20 09:16:52 2008
@@ -101,7 +101,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/xesam-support/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam.c	Tue May 20 09:16:52 2008
@@ -182,13 +182,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) {
@@ -201,69 +199,61 @@
 		return FALSE;
 	}
 
-	result_set = tracker_db_get_events (db_con);
+	sessions = g_hash_table_get_values (xesam_sessions);
 
-	if (result_set && tracker_db_result_set_get_n_rows (result_set) > 0) {
-		reason_to_live = TRUE;
+	while (sessions) {
+		GList *searches;
 
-		while (sessions) {
-			GList *searches;
+		searches = tracker_xesam_session_get_searches (sessions->data);
 
-			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);
-				}
-
-				if (removed && removed->len > 0) {
-					tracker_xesam_live_search_emit_hits_removed (search, removed);
-				}
-
-				if (removed) {
-					g_array_free (removed, TRUE);
-				}
-
-				if (modified && modified->len > 0) {
-					tracker_xesam_live_search_emit_hits_modified (search, modified);
-				}
-
-				if (modified) {
-					g_array_free (modified, TRUE);
-				}
+		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);
+			}
 
-				searches = g_list_next (searches);
+			if (added)
+				g_array_free (added, TRUE);
+
+			if (removed && removed->len > 0) {
+				reason_to_live = TRUE;
+				tracker_xesam_live_search_emit_hits_removed (search, removed);
 			}
 
-			g_list_free (searches);
+			if (removed)
+				g_array_free (removed, TRUE);
 
-			sessions = g_list_next (sessions);
+			if (modified && modified->len > 0) {
+				reason_to_live = TRUE;
+				tracker_xesam_live_search_emit_hits_modified (search, modified);
+			}
+
+			if (modified)
+				g_array_free (modified, TRUE);
+
+			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;
 }



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