[svn r921] Added gmyth_dbus_server_check_db_connection() function trunk
authormelunko
Thu Feb 07 19:36:22 2008 +0000 (2008-02-07)
branchtrunk
changeset 912b200d6198191
parent 911 da7ce603d47f
child 913 c0f13b16964f
[svn r921] Added gmyth_dbus_server_check_db_connection() function
gmyth-dbus/src/gmyth-dbus-server.c
gmyth-dbus/src/gmyth-dbus-server.xml
     1.1 --- a/gmyth-dbus/src/gmyth-dbus-server.c	Mon Feb 04 18:23:49 2008 +0000
     1.2 +++ b/gmyth-dbus/src/gmyth-dbus-server.c	Thu Feb 07 19:36:22 2008 +0000
     1.3 @@ -86,6 +86,13 @@
     1.4                                                       const gchar *user,
     1.5                                                       const gchar *password,
     1.6                                                       GError **error);
     1.7 +static gboolean gmyth_dbus_server_check_db_connection (GObject *self,
     1.8 +                                                     const gchar *host,
     1.9 +                                                     gint port,
    1.10 +                                                     const gchar *user,
    1.11 +                                                     const gchar *password,
    1.12 +                                                     GError **error);
    1.13 +
    1.14  static gboolean gmyth_dbus_server_get_channel_list  (GObject *obj,
    1.15                                                       GPtrArray **channels,
    1.16                                                       GError **error);
    1.17 @@ -1282,3 +1289,33 @@
    1.18      return FALSE;
    1.19  }
    1.20  
    1.21 +static gboolean
    1.22 +gmyth_dbus_server_check_db_connection (GObject *obj,                             
    1.23 +                                const gchar *host,
    1.24 +                                gint port,
    1.25 +                                const gchar *user,
    1.26 +                                const gchar *password,
    1.27 +                                GError **error) 
    1.28 +{
    1.29 +    GMythQuery *query = gmyth_query_new ();
    1.30 +    GMythBackendInfo *binfo;
    1.31 +    gboolean ret;
    1.32 +
    1.33 +    gmyth_debug ("");
    1.34 +
    1.35 +    binfo = gmyth_backend_info_new_full (host, user, password, MYTH_DEFAULT_DB, port);
    1.36 +
    1.37 +    ret = gmyth_query_connect_with_timeout (query, binfo, 2 /*seconds*/);
    1.38 +    gmyth_query_disconnect (query);
    1.39 +
    1.40 +    g_object_unref (query);
    1.41 +    g_object_unref (binfo);
    1.42 +
    1.43 +    if (!ret) {
    1.44 +        g_set_error (error, GMYTH_DBUS_ERROR, GMYTH_DBUS_ERROR_CONNECTION,
    1.45 +                     _("Fail to connect with backend"));
    1.46 +    }
    1.47 +
    1.48 +    return ret;
    1.49 +}
    1.50 +
     2.1 --- a/gmyth-dbus/src/gmyth-dbus-server.xml	Mon Feb 04 18:23:49 2008 +0000
     2.2 +++ b/gmyth-dbus/src/gmyth-dbus-server.xml	Thu Feb 07 19:36:22 2008 +0000
     2.3 @@ -11,6 +11,13 @@
     2.4        <arg type="s" name="password" direction="in" />
     2.5      </method>
     2.6  
     2.7 +    <method name="CheckDbConnection">
     2.8 +      <arg type="s" name="host" direction="in" />
     2.9 +      <arg type="i" name="port" direction="in" />
    2.10 +      <arg type="s" name="user" direction="in" />
    2.11 +      <arg type="s" name="password" direction="in" />
    2.12 +    </method>
    2.13 +
    2.14      <method name="Connected">
    2.15        <arg type="b" name="status" direction="out" />
    2.16      </method>