diff -r 16c33370755e -r 781db4177ba2 gmyth-dbus/src/gmyth-dbus-server.c --- a/gmyth-dbus/src/gmyth-dbus-server.c Tue Oct 30 14:08:04 2007 +0000 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Fri Dec 21 14:07:54 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; +} +