gmyth-dbus/src/gmyth-dbus-server.c
branchtrunk
changeset 929 00536b0eb88b
parent 912 b200d6198191
child 932 58d43e2186ba
     1.1 --- a/gmyth-dbus/src/gmyth-dbus-server.c	Thu Feb 07 19:36:22 2008 +0000
     1.2 +++ b/gmyth-dbus/src/gmyth-dbus-server.c	Mon Feb 25 18:40:34 2008 +0000
     1.3 @@ -92,7 +92,11 @@
     1.4                                                       const gchar *user,
     1.5                                                       const gchar *password,
     1.6                                                       GError **error);
     1.7 -
     1.8 +static gboolean
     1.9 +gmyth_dbus_server_check_server_connection (GObject *obj,
    1.10 +                                const gchar *host,
    1.11 +                                gint port,
    1.12 +                                GError **error);
    1.13  static gboolean gmyth_dbus_server_get_channel_list  (GObject *obj,
    1.14                                                       GPtrArray **channels,
    1.15                                                       GError **error);
    1.16 @@ -1313,6 +1317,32 @@
    1.17  
    1.18      if (!ret) {
    1.19          g_set_error (error, GMYTH_DBUS_ERROR, GMYTH_DBUS_ERROR_CONNECTION,
    1.20 +                     _("Fail to connect with backend database"));
    1.21 +    }
    1.22 +
    1.23 +    return ret;
    1.24 +}
    1.25 +
    1.26 +static gboolean
    1.27 +gmyth_dbus_server_check_server_connection (GObject *obj,                             
    1.28 +                                const gchar *host,
    1.29 +                                gint port,
    1.30 +                                GError **error) 
    1.31 +{
    1.32 +    GMythSocket *msocket = gmyth_socket_new ();
    1.33 +    gboolean ret;
    1.34 +
    1.35 +    gmyth_debug ("");
    1.36 +
    1.37 +    g_debug ("Checking server connection");
    1.38 +    ret = gmyth_socket_connect_with_timeout (msocket, host, port, 2);
    1.39 +    g_debug ("Return %s", ret ? "ok" : "bad");
    1.40 +    gmyth_socket_close_connection (msocket);
    1.41 +
    1.42 +    g_object_unref (msocket);
    1.43 +
    1.44 +    if (!ret) {
    1.45 +        g_set_error (error, GMYTH_DBUS_ERROR, GMYTH_DBUS_ERROR_CONNECTION,
    1.46                       _("Fail to connect with backend"));
    1.47      }
    1.48