tracker r1315 - branches/xesam-support/src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1315 - branches/xesam-support/src/trackerd
- Date: Fri, 25 Apr 2008 16:37:24 +0100 (BST)
Author: pvanhoof
Date: Fri Apr 25 15:37:24 2008
New Revision: 1315
URL: http://svn.gnome.org/viewvc/tracker?rev=1315&view=rev
Log:
And now finally a functional NameOwnerChanged patch
Modified:
branches/xesam-support/src/trackerd/tracker-xesam-search.c
Modified: branches/xesam-support/src/trackerd/tracker-xesam-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-search.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-search.c Fri Apr 25 15:37:24 2008
@@ -150,6 +150,15 @@
}
}
+static GHashTable *sessions = NULL;
+
+static void
+my_sessions_cleanup (GList *data)
+{
+ g_list_foreach (data, (GFunc) g_free, NULL);
+ g_list_free (data);
+}
+
void
tracker_xesam_search_name_owner_changed (DBusGProxy *proxy,
const char *name,
@@ -157,39 +166,70 @@
const char *new_owner,
TrackerXesamSearch *self)
{
- // Todo: figure out the session_id-s owned by the lost client based
- // on prev_owner
-
- /* foreach session_id in prev_owner
- tracker_xesam_search_close_session_interal (session_id, NULL); */
+ if (sessions) {
+ GList *my_sessions = g_hash_table_lookup (sessions, prev_owner);
+ if (my_sessions) {
+ GList *copy = my_sessions;
+ while (copy) {
+ gchar *session_id = copy->data;
+ tracker_xesam_search_close_session_interal (session_id, NULL);
+ copy = g_list_next (copy);
+ }
+ my_sessions_cleanup (my_sessions);
+ }
+ g_hash_table_remove (sessions, prev_owner);
+ }
}
/*
* Functions
*/
+
void
tracker_xesam_search_new_session (TrackerXesamSearch *object, DBusGMethodInvocation *context)
{
gchar *session_id = NULL;
guint request_id = tracker_dbus_get_next_request_id ();
GError *error = NULL;
+ GList *my_sessions;
+ gchar *key = dbus_g_method_get_sender (context);
+ gboolean insert = FALSE;
+
+ if (!sessions)
+ sessions = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, NULL);
+
+ my_sessions = g_hash_table_lookup (sessions, key);
- /** We need this to link sessions to NameOwnerChanged events ... :-\
- * sender = dbus_g_method_get_sender (context); */
+ if (!my_sessions)
+ insert = TRUE;
tracker_xesam_create_session (object, &session_id, &error);
+
if (error) {
dbus_g_method_return_error (context, error);
g_error_free (error);
} else {
+ my_sessions = g_list_prepend (my_sessions,
+ g_strdup (session_id));
+
+ if (insert)
+ g_hash_table_insert (sessions,
+ g_strdup (key),
+ my_sessions);
+ else
+ g_hash_table_replace (sessions,
+ g_strdup (key),
+ my_sessions);
+
dbus_g_method_return (context, session_id);
g_free (session_id);
}
+ g_free (key);
tracker_dbus_request_success (request_id);
-
}
@@ -200,15 +240,26 @@
{
guint request_id = tracker_dbus_get_next_request_id ();
GError *error = NULL;
+ gchar *key = dbus_g_method_get_sender (context);
tracker_xesam_search_close_session_interal (session_id, &error);
if (error) {
dbus_g_method_return_error (context, error);
g_error_free (error);
- } else
+ } else {
+
+ if (sessions) {
+ GList *my_sessions = g_hash_table_lookup (sessions, key);
+ if (my_sessions)
+ my_sessions_cleanup (my_sessions);
+ g_hash_table_remove (sessions, key);
+ }
+
dbus_g_method_return (context);
+ }
+ g_free (key);
tracker_dbus_request_success (request_id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]