Merge lp:~mhr3/libzeitgeist/no-lingering into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 228
Merged at revision: 228
Proposed branch: lp:~mhr3/libzeitgeist/no-lingering
Merge into: lp:libzeitgeist
Diff against target: 113 lines (+13/-54)
1 file modified
src/zeitgeist-log.c (+13/-54)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/no-lingering
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+99291@code.launchpad.net

Description of the change

The way we used watch_name combined with the delayed dispatching of dbus method calls caused that if Zeitgeist isn't installed on the system, all the async calls just lingered indefinitely instead of returning an error.

This branch fixes that behaviour.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looks correct. Liking the diffstat!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/zeitgeist-log.c'
--- src/zeitgeist-log.c 2012-02-13 11:07:20 +0000
+++ src/zeitgeist-log.c 2012-03-26 11:29:53 +0000
@@ -53,9 +53,6 @@
53 /* Our connection to the bus */53 /* Our connection to the bus */
54 GDBusConnection *connection;54 GDBusConnection *connection;
5555
56 /* Handle for our bus watcher, looking out for the zg daemon */
57 guint watcher_id;
58
59 /* The connection to the ZG daemon.56 /* The connection to the ZG daemon.
60 * If log != NULL it means we have a connection */57 * If log != NULL it means we have a connection */
61 GDBusProxy *log;58 GDBusProxy *log;
@@ -94,11 +91,6 @@
94 gpointer user_data;91 gpointer user_data;
95} MethodDispatchContext;92} MethodDispatchContext;
9693
97static void _zeitgeist_log_on_zg_appeared (GDBusConnection *connection,
98 const gchar *name,
99 const gchar *name_owner,
100 gpointer user_data);
101
102static void _zeitgeist_log_on_name_owner_changed (GObject *proxy,94static void _zeitgeist_log_on_name_owner_changed (GObject *proxy,
103 GParamSpec *pspec,95 GParamSpec *pspec,
104 gpointer user_data);96 gpointer user_data);
@@ -137,13 +129,15 @@
137 priv->monitors = g_hash_table_new (g_direct_hash, g_direct_equal);129 priv->monitors = g_hash_table_new (g_direct_hash, g_direct_equal);
138130
139 /* Set up the connection to the ZG daemon */131 /* Set up the connection to the ZG daemon */
140 priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION,132 g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
141 "org.gnome.zeitgeist.Engine",133 G_DBUS_PROXY_FLAGS_NONE,
142 G_BUS_NAME_WATCHER_FLAGS_AUTO_START,134 NULL,
143 _zeitgeist_log_on_zg_appeared,135 "org.gnome.zeitgeist.Engine",
144 NULL,136 "/org/gnome/zeitgeist/log/activity",
145 self,137 "org.gnome.zeitgeist.Log",
146 NULL);138 NULL,
139 _zeitgeist_log_on_zg_proxy_acquired,
140 g_object_ref (self));
147}141}
148142
149static void143static void
@@ -160,12 +154,6 @@
160 priv->connection = NULL;154 priv->connection = NULL;
161 }155 }
162156
163 if (priv->watcher_id)
164 {
165 g_bus_unwatch_name (priv->watcher_id);
166 priv->watcher_id = 0;
167 }
168
169 if (priv->log)157 if (priv->log)
170 {158 {
171 g_object_unref (priv->log);159 g_object_unref (priv->log);
@@ -1050,40 +1038,8 @@
1050 return TRUE;1038 return TRUE;
1051}1039}
10521040
1053/* Called when the Zeitgeist daemon enters the bus */
1054static void
1055_zeitgeist_log_on_zg_appeared (GDBusConnection *connection,
1056 const gchar *name,
1057 const gchar *name_owner,
1058 gpointer user_data)
1059{
1060 ZeitgeistLog *self;
1061 ZeitgeistLogPrivate *priv;
1062
1063 self = ZEITGEIST_LOG (user_data);
1064 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
1065
1066 if (priv->connection == NULL)
1067 {
1068 priv->connection = g_object_ref (connection);
1069 }
1070
1071 if (priv->log == NULL)
1072 {
1073 g_dbus_proxy_new (connection,
1074 G_DBUS_PROXY_FLAGS_NONE,
1075 NULL,
1076 name,
1077 "/org/gnome/zeitgeist/log/activity",
1078 "org.gnome.zeitgeist.Log",
1079 NULL,
1080 _zeitgeist_log_on_zg_proxy_acquired,
1081 g_object_ref (self));
1082 }
1083}
1084
1085/* Async callback for when a proxy is ready1041/* Async callback for when a proxy is ready
1086 * - triggered from _zeitgeist_log_on_zg_appeared */1042 * - triggered from zeitgeist_log_init */
1087static void1043static void
1088_zeitgeist_log_on_zg_proxy_acquired (GObject *source_object,1044_zeitgeist_log_on_zg_proxy_acquired (GObject *source_object,
1089 GAsyncResult *res,1045 GAsyncResult *res,
@@ -1118,6 +1074,9 @@
1118 goto cleanup;1074 goto cleanup;
1119 }1075 }
11201076
1077 priv->connection = G_DBUS_CONNECTION (g_object_ref (
1078 g_dbus_proxy_get_connection (priv->log)));
1079
1121 version_property = g_dbus_proxy_get_cached_property (priv->log, "version");1080 version_property = g_dbus_proxy_get_cached_property (priv->log, "version");
1122 if (version_property)1081 if (version_property)
1123 {1082 {

Subscribers

People subscribed via source and target branches