[evolution-data-server] EDataCal: Cancel operations when the sender disappears.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] EDataCal: Cancel operations when the sender disappears.
- Date: Tue, 29 Jan 2013 13:47:08 +0000 (UTC)
commit b6c620c6baa0bc3804be9a04c567a8d7f10b8810
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jan 29 08:45:35 2013 -0500
EDataCal: Cancel operations when the sender disappears.
Make the GCancellables passed to backends actually do something useful.
calendar/libedata-cal/e-data-cal.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index df3c2a4..08758db 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -99,6 +99,7 @@ typedef struct {
EDataCal *cal; /* calendar */
GCancellable *cancellable;
GDBusMethodInvocation *invocation;
+ guint watcher_id;
union {
/* OP_OPEN */
@@ -185,12 +186,22 @@ op_ref (OperationData *data)
return data;
}
+static void
+op_sender_vanished_cb (GDBusConnection *connection,
+ const gchar *sender,
+ GCancellable *cancellable)
+{
+ g_cancellable_cancel (cancellable);
+}
+
static OperationData *
op_new (OperationID op,
EDataCal *cal,
GDBusMethodInvocation *invocation)
{
OperationData *data;
+ GDBusConnection *connection;
+ const gchar *sender;
data = g_slice_new0 (OperationData);
data->ref_count = 1;
@@ -200,6 +211,17 @@ op_new (OperationID op,
data->cancellable = g_cancellable_new ();
data->invocation = g_object_ref (invocation);
+ connection = g_dbus_method_invocation_get_connection (invocation);
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ data->watcher_id = g_bus_watch_name_on_connection (
+ connection, sender,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ (GBusNameAppearedCallback) NULL,
+ (GBusNameVanishedCallback) op_sender_vanished_cb,
+ g_object_ref (data->cancellable),
+ (GDestroyNotify) g_object_unref);
+
g_rec_mutex_lock (&cal->priv->pending_ops_lock);
g_hash_table_insert (
cal->priv->pending_ops,
@@ -274,6 +296,8 @@ op_unref (OperationData *data)
g_object_unref (data->cancellable);
g_object_unref (data->invocation);
+ g_bus_unwatch_name (data->watcher_id);
+
g_slice_free (OperationData, data);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]