# HG changeset patch # User renatofilho # Date 1195495060 0 # Node ID c5a9d9583e64ca3ef0617f8c80bd2ecf5667bd59 # Parent 22df7edb6e37a9bbe15a79dc221767a237e53f90 [svn r887] fixed disconnect signal diff -r 22df7edb6e37 -r c5a9d9583e64 gmyth-dbus/src/gmyth-dbus-server.c --- a/gmyth-dbus/src/gmyth-dbus-server.c Thu Nov 15 20:33:59 2007 +0000 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Mon Nov 19 17:57:40 2007 +0000 @@ -37,7 +37,7 @@ enum { - DISCONNECTED, + SHUTDOWN, LAST_SIGNAL }; @@ -65,15 +65,19 @@ gboolean connected; GMythEPG *myth_epg; GMythScheduler *myth_scheduler; + + guint shutdown_cb_id; }; #define GMYTH_DBUS_SERVER_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GMYTH_DBUS_SERVER_TYPE, GMythDbusServerPrivate)) -static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass); -static void gmyth_dbus_server_init (GMythDbusServer *self); -static void gmyth_dbus_server_dispose (GObject *object); -static void gmyth_dbus_server_finalize (GObject *object); +static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass); +static void gmyth_dbus_server_init (GMythDbusServer *self); +static void gmyth_dbus_server_dispose (GObject *object); +static void gmyth_dbus_server_finalize (GObject *object); +static void gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self); +static gboolean gmyth_dbus_server_shutdown_cb (GMythDbusServer *self); /* Dbus */ static gboolean gmyth_dbus_server_connect (GObject *obj, @@ -173,8 +177,8 @@ object_class->dispose = gmyth_dbus_server_dispose; object_class->finalize = gmyth_dbus_server_finalize; - signals[DISCONNECTED] = - g_signal_new ("disconnected", + signals[SHUTDOWN] = + g_signal_new ("shutdown", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, @@ -298,6 +302,8 @@ gmyth_dbus_server_internal_disconnect (obj, NULL); } + gmyth_dbus_server_cancel_shutdown (GMYTH_DBUS_SERVER (obj)); + priv->myth_backend = gmyth_backend_info_new_full (host, user, password, @@ -353,7 +359,8 @@ if (priv->connected) { gmyth_dbus_server_internal_disconnect (obj, error); - g_signal_emit (obj, signals[DISCONNECTED], 0); + priv->shutdown_cb_id = g_timeout_add (60000, + (GSourceFunc) gmyth_dbus_server_shutdown_cb, obj); } return TRUE; @@ -1238,3 +1245,30 @@ return NULL; } + +static void +gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self) +{ + GMythDbusServerPrivate *priv; + + priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self); + + if (priv->shutdown_cb_id) + { + g_source_remove (priv->shutdown_cb_id); + priv->shutdown_cb_id = 0; + } +} + +static gboolean +gmyth_dbus_server_shutdown_cb (GMythDbusServer *self) +{ + GMythDbusServerPrivate *priv; + + priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self); + + priv->shutdown_cb_id = 0; + g_signal_emit (self, signals[SHUTDOWN], 0); + return FALSE; +} + diff -r 22df7edb6e37 -r c5a9d9583e64 gmyth-dbus/src/main.c --- a/gmyth-dbus/src/main.c Thu Nov 15 20:33:59 2007 +0000 +++ b/gmyth-dbus/src/main.c Mon Nov 19 17:57:40 2007 +0000 @@ -23,7 +23,7 @@ if (srv) { g_signal_connect (G_OBJECT (srv), - "disconnected", + "shutdown", G_CALLBACK (_disconnected_cb), loop); g_main_loop_run (loop);