From: <me...@us...> - 2008-02-07 19:36:19
|
Revision: 921 http://gmyth.svn.sourceforge.net/gmyth/?rev=921&view=rev Author: melunko Date: 2008-02-07 11:36:22 -0800 (Thu, 07 Feb 2008) Log Message: ----------- Added gmyth_dbus_server_check_db_connection() function Modified Paths: -------------- trunk/gmyth-dbus/src/gmyth-dbus-server.c trunk/gmyth-dbus/src/gmyth-dbus-server.xml Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.c =================================================================== --- trunk/gmyth-dbus/src/gmyth-dbus-server.c 2008-02-04 18:25:58 UTC (rev 920) +++ trunk/gmyth-dbus/src/gmyth-dbus-server.c 2008-02-07 19:36:22 UTC (rev 921) @@ -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; +} + Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.xml =================================================================== --- trunk/gmyth-dbus/src/gmyth-dbus-server.xml 2008-02-04 18:25:58 UTC (rev 920) +++ trunk/gmyth-dbus/src/gmyth-dbus-server.xml 2008-02-07 19:36:22 UTC (rev 921) @@ -11,6 +11,13 @@ <arg type="s" name="password" direction="in" /> </method> + <method name="CheckDbConnection"> + <arg type="s" name="host" direction="in" /> + <arg type="i" name="port" direction="in" /> + <arg type="s" name="user" direction="in" /> + <arg type="s" name="password" direction="in" /> + </method> + <method name="Connected"> <arg type="b" name="status" direction="out" /> </method> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |