[evolution-data-server] Bug #609646 - Unset global DBus variables on destroy or disconnect
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #609646 - Unset global DBus variables on destroy or disconnect
- Date: Thu, 11 Feb 2010 19:14:25 +0000 (UTC)
commit 37db6483a1e5e091f3b0aae1de2ed3f944bac52b
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 11 20:12:23 2010 +0100
Bug #609646 - Unset global DBus variables on destroy or disconnect
addressbook/libebook/e-book.c | 30 +++++++++++++++++++++++++++++-
calendar/libecal/e-cal.c | 29 +++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 6443f6c..919dcce 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -217,6 +217,31 @@ e_book_init (EBook *book)
book->priv = priv;
}
+static DBusHandlerResult
+filter_dbus_msgs_cb (DBusConnection *pconnection, DBusMessage *message, void *user_data)
+{
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
+ DBusGConnection *conn = connection;
+
+ LOCK_CONN ();
+ factory_proxy = NULL;
+ connection = NULL;
+ UNLOCK_CONN ();
+ dbus_g_connection_unref (conn);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+factory_proxy_destroy_cb (DBusGProxy *proxy, gpointer user_data)
+{
+ LOCK_CONN ();
+ factory_proxy = NULL;
+ UNLOCK_CONN ();
+}
+
static gboolean
e_book_activate(GError **error)
{
@@ -235,6 +260,8 @@ e_book_activate(GError **error)
UNLOCK_CONN ();
return FALSE;
}
+
+ dbus_connection_add_filter (dbus_g_connection_get_connection (connection), filter_dbus_msgs_cb, NULL, NULL);
}
dbus_error_init (&derror);
@@ -257,7 +284,8 @@ e_book_activate(GError **error)
UNLOCK_CONN ();
return FALSE;
}
- g_object_add_weak_pointer (G_OBJECT (factory_proxy), (gpointer)&factory_proxy);
+
+ g_signal_connect (factory_proxy, "destroy", G_CALLBACK (factory_proxy_destroy_cb), NULL);
}
UNLOCK_CONN ();
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 247c18f..a73e2b0 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -553,6 +553,31 @@ e_cal_class_init (ECalClass *klass)
g_type_class_add_private (klass, sizeof (ECalPrivate));
}
+static DBusHandlerResult
+filter_dbus_msgs_cb (DBusConnection *pconnection, DBusMessage *message, void *user_data)
+{
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
+ DBusGConnection *conn = connection;
+
+ LOCK_CONN ();
+ factory_proxy = NULL;
+ connection = NULL;
+ UNLOCK_CONN ();
+ dbus_g_connection_unref (conn);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+factory_proxy_destroy_cb (DBusGProxy *proxy, gpointer user_data)
+{
+ LOCK_CONN ();
+ factory_proxy = NULL;
+ UNLOCK_CONN ();
+}
+
/* one-time start up for libecal */
static gboolean
e_cal_activate(GError **error)
@@ -571,6 +596,8 @@ e_cal_activate(GError **error)
UNLOCK_CONN ();
return FALSE;
}
+
+ dbus_connection_add_filter (dbus_g_connection_get_connection (connection), filter_dbus_msgs_cb, NULL, NULL);
}
dbus_error_init (&derror);
@@ -594,6 +621,8 @@ e_cal_activate(GError **error)
UNLOCK_CONN ();
return FALSE;
}
+
+ g_signal_connect (factory_proxy, "destroy", G_CALLBACK (factory_proxy_destroy_cb), NULL);
}
UNLOCK_CONN ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]