# HG changeset patch # User renatofilho # Date 1193688813 0 # Node ID 016b3410871d03970d8387472c01cbe23260ea6a # Parent 7fd8198b93aa69670f2ae2afe183a429b2b47f98 [svn r884] close service after disconnect called diff -r 7fd8198b93aa -r 016b3410871d gmyth-dbus/src/gmyth-dbus-server.c --- a/gmyth-dbus/src/gmyth-dbus-server.c Mon Oct 29 19:56:35 2007 +0000 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Mon Oct 29 20:13:33 2007 +0000 @@ -37,6 +37,12 @@ enum { + DISCONNECTED, + LAST_SIGNAL +}; + +enum +{ GMYTH_DBUS_ERROR_MYTHTV, GMYTH_DBUS_ERROR_CONNECTION, GMYTH_DBUS_ERROR_EPG, @@ -109,6 +115,9 @@ GError **error); static gboolean gmyth_dbus_server_disconnect (GObject *obj, GError **error); +static void gmyth_dbus_server_internal_disconnect + (GObject *obj, + GError **error); static gboolean gmyth_dbus_server_get_server_info (GObject *obj, guint64 *total_space, guint64 *used_space, @@ -151,6 +160,8 @@ #include "gmyth-dbus-server-glue.h" +static guint signals[LAST_SIGNAL] = { 0 }; + G_DEFINE_TYPE (GMythDbusServer, gmyth_dbus_server, G_TYPE_OBJECT); static void @@ -163,6 +174,15 @@ object_class->dispose = gmyth_dbus_server_dispose; object_class->finalize = gmyth_dbus_server_finalize; + signals[DISCONNECTED] = + g_signal_new ("disconnected", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + dbus_g_object_type_install_info (GMYTH_DBUS_SERVER_TYPE, &dbus_glib_gmyth_dbus_server_object_info); } @@ -276,7 +296,7 @@ if (priv->connected) { - gmyth_dbus_server_disconnect (obj, NULL); + gmyth_dbus_server_internal_disconnect (obj, error); } priv->myth_backend = gmyth_backend_info_new_full (host, @@ -329,6 +349,17 @@ gmyth_dbus_server_disconnect (GObject *obj, GError **error) { + + gmyth_dbus_server_internal_disconnect (obj, error); + g_signal_emit (obj, signals[DISCONNECTED], 0); + + return TRUE; +} + +static void +gmyth_dbus_server_internal_disconnect (GObject *obj, + GError **error) +{ GMythDbusServerPrivate *priv; g_debug ("%s:%d", __FUNCTION__, __LINE__); @@ -353,9 +384,6 @@ g_object_unref (priv->myth_scheduler); priv->myth_scheduler = NULL; } - - - return TRUE; } static gboolean diff -r 7fd8198b93aa -r 016b3410871d gmyth-dbus/src/main.c --- a/gmyth-dbus/src/main.c Mon Oct 29 19:56:35 2007 +0000 +++ b/gmyth-dbus/src/main.c Mon Oct 29 20:13:33 2007 +0000 @@ -1,5 +1,13 @@ #include "gmyth-dbus-server.h" + +static void +_disconnected_cb (GMythDbusServer *srv, + GMainLoop *loop) +{ + g_main_loop_quit (loop); +} + int main (int argc, char* argv[]) { GMainLoop *loop; @@ -13,7 +21,15 @@ srv = gmyth_dbus_server_start_dbus_service (); if (srv) + { + g_signal_connect (G_OBJECT (srv), + "disconnected", + G_CALLBACK (_disconnected_cb), + loop); g_main_loop_run (loop); + g_object_unref (srv); + } + return 0; }