diff -r ea19ac6f452e -r b200d6198191 gmyth-dbus/src/gmyth-dbus-server.c --- a/gmyth-dbus/src/gmyth-dbus-server.c Fri Feb 01 13:38:20 2008 +0000 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Thu Feb 07 19:36:22 2008 +0000 @@ -86,6 +86,13 @@ const gchar *user, const gchar *password, GError **error); +static gboolean gmyth_dbus_server_check_db_connection (GObject *self, + const gchar *host, + gint port, + const gchar *user, + const gchar *password, + GError **error); + static gboolean gmyth_dbus_server_get_channel_list (GObject *obj, GPtrArray **channels, GError **error); @@ -1282,3 +1289,33 @@ return FALSE; } +static gboolean +gmyth_dbus_server_check_db_connection (GObject *obj, + const gchar *host, + gint port, + const gchar *user, + const gchar *password, + GError **error) +{ + GMythQuery *query = gmyth_query_new (); + GMythBackendInfo *binfo; + gboolean ret; + + gmyth_debug (""); + + binfo = gmyth_backend_info_new_full (host, user, password, MYTH_DEFAULT_DB, port); + + ret = gmyth_query_connect_with_timeout (query, binfo, 2 /*seconds*/); + gmyth_query_disconnect (query); + + g_object_unref (query); + g_object_unref (binfo); + + if (!ret) { + g_set_error (error, GMYTH_DBUS_ERROR, GMYTH_DBUS_ERROR_CONNECTION, + _("Fail to connect with backend")); + } + + return ret; +} +