1.1 --- a/gmyth-dbus/src/gmyth-dbus-server.c Thu Nov 15 20:33:59 2007 +0000
1.2 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Mon Nov 19 17:57:40 2007 +0000
1.3 @@ -37,7 +37,7 @@
1.4
1.5 enum
1.6 {
1.7 - DISCONNECTED,
1.8 + SHUTDOWN,
1.9 LAST_SIGNAL
1.10 };
1.11
1.12 @@ -65,15 +65,19 @@
1.13 gboolean connected;
1.14 GMythEPG *myth_epg;
1.15 GMythScheduler *myth_scheduler;
1.16 +
1.17 + guint shutdown_cb_id;
1.18 };
1.19
1.20 #define GMYTH_DBUS_SERVER_GET_PRIVATE(o) \
1.21 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GMYTH_DBUS_SERVER_TYPE, GMythDbusServerPrivate))
1.22
1.23 -static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass);
1.24 -static void gmyth_dbus_server_init (GMythDbusServer *self);
1.25 -static void gmyth_dbus_server_dispose (GObject *object);
1.26 -static void gmyth_dbus_server_finalize (GObject *object);
1.27 +static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass);
1.28 +static void gmyth_dbus_server_init (GMythDbusServer *self);
1.29 +static void gmyth_dbus_server_dispose (GObject *object);
1.30 +static void gmyth_dbus_server_finalize (GObject *object);
1.31 +static void gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self);
1.32 +static gboolean gmyth_dbus_server_shutdown_cb (GMythDbusServer *self);
1.33
1.34 /* Dbus */
1.35 static gboolean gmyth_dbus_server_connect (GObject *obj,
1.36 @@ -173,8 +177,8 @@
1.37 object_class->dispose = gmyth_dbus_server_dispose;
1.38 object_class->finalize = gmyth_dbus_server_finalize;
1.39
1.40 - signals[DISCONNECTED] =
1.41 - g_signal_new ("disconnected",
1.42 + signals[SHUTDOWN] =
1.43 + g_signal_new ("shutdown",
1.44 G_OBJECT_CLASS_TYPE (object_class),
1.45 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1.46 0,
1.47 @@ -298,6 +302,8 @@
1.48 gmyth_dbus_server_internal_disconnect (obj, NULL);
1.49 }
1.50
1.51 + gmyth_dbus_server_cancel_shutdown (GMYTH_DBUS_SERVER (obj));
1.52 +
1.53 priv->myth_backend = gmyth_backend_info_new_full (host,
1.54 user,
1.55 password,
1.56 @@ -353,7 +359,8 @@
1.57 if (priv->connected)
1.58 {
1.59 gmyth_dbus_server_internal_disconnect (obj, error);
1.60 - g_signal_emit (obj, signals[DISCONNECTED], 0);
1.61 + priv->shutdown_cb_id = g_timeout_add (60000,
1.62 + (GSourceFunc) gmyth_dbus_server_shutdown_cb, obj);
1.63 }
1.64
1.65 return TRUE;
1.66 @@ -1238,3 +1245,30 @@
1.67 return NULL;
1.68 }
1.69
1.70 +
1.71 +static void
1.72 +gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self)
1.73 +{
1.74 + GMythDbusServerPrivate *priv;
1.75 +
1.76 + priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self);
1.77 +
1.78 + if (priv->shutdown_cb_id)
1.79 + {
1.80 + g_source_remove (priv->shutdown_cb_id);
1.81 + priv->shutdown_cb_id = 0;
1.82 + }
1.83 +}
1.84 +
1.85 +static gboolean
1.86 +gmyth_dbus_server_shutdown_cb (GMythDbusServer *self)
1.87 +{
1.88 + GMythDbusServerPrivate *priv;
1.89 +
1.90 + priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self);
1.91 +
1.92 + priv->shutdown_cb_id = 0;
1.93 + g_signal_emit (self, signals[SHUTDOWN], 0);
1.94 + return FALSE;
1.95 +}
1.96 +
2.1 --- a/gmyth-dbus/src/main.c Thu Nov 15 20:33:59 2007 +0000
2.2 +++ b/gmyth-dbus/src/main.c Mon Nov 19 17:57:40 2007 +0000
2.3 @@ -23,7 +23,7 @@
2.4 if (srv)
2.5 {
2.6 g_signal_connect (G_OBJECT (srv),
2.7 - "disconnected",
2.8 + "shutdown",
2.9 G_CALLBACK (_disconnected_cb),
2.10 loop);
2.11 g_main_loop_run (loop);