|
From: <ren...@us...> - 2007-10-29 20:13:29
|
Revision: 884
http://gmyth.svn.sourceforge.net/gmyth/?rev=884&view=rev
Author: renatofilho
Date: 2007-10-29 13:13:33 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
close service after disconnect called
Modified Paths:
--------------
trunk/gmyth-dbus/src/gmyth-dbus-server.c
trunk/gmyth-dbus/src/main.c
Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.c
===================================================================
--- trunk/gmyth-dbus/src/gmyth-dbus-server.c 2007-10-29 19:56:35 UTC (rev 883)
+++ trunk/gmyth-dbus/src/gmyth-dbus-server.c 2007-10-29 20:13:33 UTC (rev 884)
@@ -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
Modified: trunk/gmyth-dbus/src/main.c
===================================================================
--- trunk/gmyth-dbus/src/main.c 2007-10-29 19:56:35 UTC (rev 883)
+++ trunk/gmyth-dbus/src/main.c 2007-10-29 20:13:33 UTC (rev 884)
@@ -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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ren...@us...> - 2007-11-19 17:57:42
|
Revision: 887
http://gmyth.svn.sourceforge.net/gmyth/?rev=887&view=rev
Author: renatofilho
Date: 2007-11-19 09:57:40 -0800 (Mon, 19 Nov 2007)
Log Message:
-----------
fixed disconnect signal
Modified Paths:
--------------
trunk/gmyth-dbus/src/gmyth-dbus-server.c
trunk/gmyth-dbus/src/main.c
Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.c
===================================================================
--- trunk/gmyth-dbus/src/gmyth-dbus-server.c 2007-11-15 20:33:59 UTC (rev 886)
+++ trunk/gmyth-dbus/src/gmyth-dbus-server.c 2007-11-19 17:57:40 UTC (rev 887)
@@ -37,7 +37,7 @@
enum
{
- DISCONNECTED,
+ SHUTDOWN,
LAST_SIGNAL
};
@@ -65,15 +65,19 @@
gboolean connected;
GMythEPG *myth_epg;
GMythScheduler *myth_scheduler;
+
+ guint shutdown_cb_id;
};
#define GMYTH_DBUS_SERVER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GMYTH_DBUS_SERVER_TYPE, GMythDbusServerPrivate))
-static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass);
-static void gmyth_dbus_server_init (GMythDbusServer *self);
-static void gmyth_dbus_server_dispose (GObject *object);
-static void gmyth_dbus_server_finalize (GObject *object);
+static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass);
+static void gmyth_dbus_server_init (GMythDbusServer *self);
+static void gmyth_dbus_server_dispose (GObject *object);
+static void gmyth_dbus_server_finalize (GObject *object);
+static void gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self);
+static gboolean gmyth_dbus_server_shutdown_cb (GMythDbusServer *self);
/* Dbus */
static gboolean gmyth_dbus_server_connect (GObject *obj,
@@ -173,8 +177,8 @@
object_class->dispose = gmyth_dbus_server_dispose;
object_class->finalize = gmyth_dbus_server_finalize;
- signals[DISCONNECTED] =
- g_signal_new ("disconnected",
+ signals[SHUTDOWN] =
+ g_signal_new ("shutdown",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0,
@@ -298,6 +302,8 @@
gmyth_dbus_server_internal_disconnect (obj, NULL);
}
+ gmyth_dbus_server_cancel_shutdown (GMYTH_DBUS_SERVER (obj));
+
priv->myth_backend = gmyth_backend_info_new_full (host,
user,
password,
@@ -353,7 +359,8 @@
if (priv->connected)
{
gmyth_dbus_server_internal_disconnect (obj, error);
- g_signal_emit (obj, signals[DISCONNECTED], 0);
+ priv->shutdown_cb_id = g_timeout_add (60000,
+ (GSourceFunc) gmyth_dbus_server_shutdown_cb, obj);
}
return TRUE;
@@ -1238,3 +1245,30 @@
return NULL;
}
+
+static void
+gmyth_dbus_server_cancel_shutdown (GMythDbusServer *self)
+{
+ GMythDbusServerPrivate *priv;
+
+ priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self);
+
+ if (priv->shutdown_cb_id)
+ {
+ g_source_remove (priv->shutdown_cb_id);
+ priv->shutdown_cb_id = 0;
+ }
+}
+
+static gboolean
+gmyth_dbus_server_shutdown_cb (GMythDbusServer *self)
+{
+ GMythDbusServerPrivate *priv;
+
+ priv = GMYTH_DBUS_SERVER_GET_PRIVATE (self);
+
+ priv->shutdown_cb_id = 0;
+ g_signal_emit (self, signals[SHUTDOWN], 0);
+ return FALSE;
+}
+
Modified: trunk/gmyth-dbus/src/main.c
===================================================================
--- trunk/gmyth-dbus/src/main.c 2007-11-15 20:33:59 UTC (rev 886)
+++ trunk/gmyth-dbus/src/main.c 2007-11-19 17:57:40 UTC (rev 887)
@@ -23,7 +23,7 @@
if (srv)
{
g_signal_connect (G_OBJECT (srv),
- "disconnected",
+ "shutdown",
G_CALLBACK (_disconnected_cb),
loop);
g_main_loop_run (loop);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ren...@us...> - 2008-01-23 20:04:56
|
Revision: 897
http://gmyth.svn.sourceforge.net/gmyth/?rev=897&view=rev
Author: renatofilho
Date: 2008-01-23 12:04:59 -0800 (Wed, 23 Jan 2008)
Log Message:
-----------
fixed channel_id, program_id types
Modified Paths:
--------------
trunk/gmyth-dbus/src/Makefile.am
trunk/gmyth-dbus/src/gmyth-dbus-common.h
trunk/gmyth-dbus/src/gmyth-dbus-server.c
trunk/gmyth-dbus/src/gmyth-dbus-server.xml
Modified: trunk/gmyth-dbus/src/Makefile.am
===================================================================
--- trunk/gmyth-dbus/src/Makefile.am 2008-01-23 20:04:22 UTC (rev 896)
+++ trunk/gmyth-dbus/src/Makefile.am 2008-01-23 20:04:59 UTC (rev 897)
@@ -4,6 +4,8 @@
gmythdbus_SOURCES = \
gmyth-dbus-server.h \
gmyth-dbus-server.c \
+ gmyth-debug.h \
+ gmyth-debug.c \
main.c
gmythdbus_LDADD = \
Modified: trunk/gmyth-dbus/src/gmyth-dbus-common.h
===================================================================
--- trunk/gmyth-dbus/src/gmyth-dbus-common.h 2008-01-23 20:04:22 UTC (rev 896)
+++ trunk/gmyth-dbus/src/gmyth-dbus-common.h 2008-01-23 20:04:59 UTC (rev 897)
@@ -7,13 +7,13 @@
#define GMYTH_DBUS_PROGRAM_G_TYPE \
dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_INT, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
- G_TYPE_STRING, \
G_TYPE_INVALID);
#define GMYTH_DBUS_CHANNEL_G_TYPE \
@@ -27,29 +27,29 @@
#define GMYTH_DBUS_RECORD_G_TYPE \
dbus_g_type_get_struct ("GValueArray", \
G_TYPE_UINT, \
- G_TYPE_UINT, \
- G_TYPE_UINT, \
G_TYPE_STRING, \
+ G_TYPE_INT, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
+ G_TYPE_STRING, \
G_TYPE_UINT64, \
G_TYPE_INVALID);
#define GMYTH_DBUS_SCHEDULE_G_TYPE \
dbus_g_type_get_struct ("GValueArray", \
G_TYPE_UINT, \
- G_TYPE_UINT, \
- G_TYPE_UINT, \
G_TYPE_STRING, \
+ G_TYPE_INT, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
G_TYPE_STRING, \
+ G_TYPE_STRING, \
G_TYPE_UINT, \
G_TYPE_INVALID);
Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.c
===================================================================
--- trunk/gmyth-dbus/src/gmyth-dbus-server.c 2008-01-23 20:04:22 UTC (rev 896)
+++ trunk/gmyth-dbus/src/gmyth-dbus-server.c 2008-01-23 20:04:59 UTC (rev 897)
@@ -140,7 +140,7 @@
GError **error);
static gboolean gmyth_dbus_server_add_schedule (GObject *obj,
guint channel_id,
- guint program_id,
+ const gchar *program_id,
const gchar *start_time,
const gchar *end_time,
gboolean recurring,
@@ -150,7 +150,7 @@
static gboolean gmyth_dbus_server_add_exception (GObject *obj,
guint schedule_id,
guint channel_id,
- guint program_id,
+ const gchar *program_id,
const gchar *start_time,
const gchar *end_time,
const gchar *description,
@@ -220,6 +220,7 @@
GMYTH_DBUS_ERROR_CONNECTION,
_("Not connected"));
+ gmyth_debug ("Not connected with MythTV Server");
return FALSE;
}
@@ -235,12 +236,13 @@
GMYTH_DBUS_ERROR,
GMYTH_DBUS_ERROR_EPG,
_("Fail to connect with EPG"));
-
+ gmyth_debug ("Fail to connected with EPG");
return FALSE;
}
}
+ gmyth_debug ("Connected EPG");
return TRUE;
}
@@ -258,6 +260,7 @@
GMYTH_DBUS_ERROR_CONNECTION,
_("Not connected"));
+ gmyth_debug ("Not connected with MythTV Server");
return FALSE;
}
@@ -275,10 +278,12 @@
GMYTH_DBUS_ERROR_SCHEDULE,
_("Fail to connect with Schedule"));
+ gmyth_debug (_("Fail to connect with Schedule"));
return FALSE;
}
}
+ gmyth_debug ("Connected with Schedule");
return TRUE;
}
@@ -293,12 +298,13 @@
GMythSocket *s;
GMythDbusServerPrivate *priv;
- g_debug ("%s:%d", __FUNCTION__, __LINE__);
+ gmyth_debug ("");
priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
if (priv->connected)
{
+ gmyth_debug ("Release Old connection");
gmyth_dbus_server_internal_disconnect (obj, NULL);
}
@@ -313,11 +319,13 @@
s = gmyth_backend_info_get_connected_socket (priv->myth_backend);
if (s)
{
+ gmyth_debug ("Connected");
priv->connected = TRUE;
g_object_unref (s);
}
else
{
+ gmyth_debug ("Fail to connect with MythTVServer");
priv->connected = FALSE;
g_object_unref (priv->myth_backend);
priv->myth_backend = NULL;
@@ -338,8 +346,8 @@
{
GMythDbusServerPrivate *priv;
- g_debug ("%s:%d", __FUNCTION__, __LINE__);
+ gmyth_debug ("");
priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
if (priv->myth_backend)
@@ -625,7 +633,7 @@
end_str = g_time_val_to_iso8601 (data->endts);
dbus_g_type_struct_set (&program,
- 0, data->chanid->str,
+ 0, data->xx_channel_id,
1, start_str,
2, end_str,
3, data->title->str,
@@ -658,8 +666,8 @@
dbus_g_type_struct_set (val,
0, info->record_id,
- 1, info->program_id,
- 2, info->channel_id,
+ 1, info->xx_program_id->str,
+ 2, info->xx_channel_id,
3, start_str,
4, end_str,
5, info->title->str,
@@ -816,8 +824,8 @@
dbus_g_type_struct_set (&schedule,
0, data->schedule_id,
- 1, data->program_id,
- 2, data->channel_id,
+ 1, data->xx_program_id->str,
+ 2, data->xx_channel_id,
3, start_str_time,
4, end_str_time,
5, data->title->str,
@@ -1006,7 +1014,7 @@
static ScheduleInfo*
gmyth_dbus_server_new_schedule_info (const gchar* description,
guint channel_id,
- guint program_id,
+ const gchar* program_id,
GTimeVal *start_vtime,
GTimeVal *end_vtime)
{
@@ -1017,8 +1025,8 @@
/* record_id == -1 for generating a new id */
new_sched_info->schedule_id = -1;
- new_sched_info->channel_id = channel_id;
- new_sched_info->program_id = program_id;
+ new_sched_info->xx_channel_id = channel_id;
+ new_sched_info->xx_program_id = g_string_new (program_id);
new_sched_info->start_time = g_new0 (GTimeVal, 1);
*new_sched_info->start_time = *start_vtime;
new_sched_info->end_time = g_new0 (GTimeVal, 1);
@@ -1039,7 +1047,7 @@
static gboolean
gmyth_dbus_server_add_schedule (GObject *obj,
guint channel_id,
- guint program_id,
+ const gchar *program_id,
const gchar *start_time,
const gchar *end_time,
gboolean recurring,
@@ -1065,11 +1073,14 @@
g_time_val_from_iso8601 (start_time, &start_vtime);
g_time_val_from_iso8601 (end_time, &end_vtime);
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
sch_info = gmyth_dbus_server_new_schedule_info (description,
channel_id,
program_id,
&start_vtime,
&end_vtime);
+
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
if (sch_info != NULL) {
GMythScheduleType type;
GTimeVal t_now;
@@ -1081,17 +1092,20 @@
g_get_current_time (&t_now);
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
has_record = gmyth_scheduler_was_recorded_before (priv->myth_scheduler,
channel_id,
(time_t) start_vtime.tv_sec);
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
if ((t_now.tv_sec >= start_vtime.tv_sec)
&& (t_now.tv_sec <= end_vtime.tv_sec) && has_record)
{
GMythSocket *socket;
gboolean res = FALSE;
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
socket = gmyth_backend_info_get_connected_socket (priv->myth_backend);
res = gmyth_scheduler_reactivate_schedule(priv->myth_scheduler,
channel_id,
@@ -1099,17 +1113,21 @@
if (res) {
GMythStringList *slist = gmyth_string_list_new();
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
gmyth_string_list_append_char_array(slist, "RESCHEDULE_RECORDINGS 0");
gmyth_socket_sendreceive_stringlist(socket, slist);
res = (gmyth_string_list_get_int(slist, 0) == 1);
g_object_unref(slist);
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
}
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
g_object_unref(socket);
return res;
}
else
{
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
if (!gmyth_scheduler_add_schedule_full (priv->myth_scheduler,
sch_info,
type))
@@ -1118,8 +1136,11 @@
return FALSE;
}
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
(*schedule_id) = sch_info->schedule_id;
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
gmyth_schedule_info_free (sch_info);
+ g_debug ("%s:%d", __FUNCTION__, __LINE__);
return TRUE;
}
}
@@ -1130,7 +1151,7 @@
gmyth_dbus_server_add_exception (GObject *obj,
guint schedule_id,
guint channel_id,
- guint program_id,
+ const gchar *program_id,
const gchar *start_time,
const gchar *end_time,
const gchar *description,
Modified: trunk/gmyth-dbus/src/gmyth-dbus-server.xml
===================================================================
--- trunk/gmyth-dbus/src/gmyth-dbus-server.xml 2008-01-23 20:04:22 UTC (rev 896)
+++ trunk/gmyth-dbus/src/gmyth-dbus-server.xml 2008-01-23 20:04:59 UTC (rev 897)
@@ -36,20 +36,20 @@
<arg type="i" name="channel" direction="in" />
<arg type="s" name="start_time" direction="in" />
<arg type="s" name="end_time" direction="in" />
- <arg type="a(sssssss)" name="program_list" direction="out" />
+ <arg type="a(issssss)" name="program_list" direction="out" />
</method>
<method name="GetRecordedList">
- <arg type="a(uuussssssst)" name="records" direction="out" />
+ <arg type="a(usissssssst)" name="records" direction="out" />
</method>
<method name="GetRecordedInfo">
<arg type="s" name="basename" direction="in" />
- <arg type="(uuussssssst)" name="details" direction="out" />
+ <arg type="(usissssssst)" name="details" direction="out" />
</method>
<method name="GetScheduleList">
- <arg type="a(uuussssu)" name="schedules" direction="out" />
+ <arg type="a(usissssu)" name="schedules" direction="out" />
</method>
<method name="FileExists">
@@ -68,13 +68,13 @@
</method>
<method name="StopRecording">
- <arg type="u" name="channel_id" direction="in" />
+ <arg type="i" name="channel_id" direction="in" />
<arg type="b" name="result" direction="out" />
</method>
<method name="AddSchedule">
- <arg type="u" name="channel_id" direction="in" />
- <arg type="u" name="program_id" direction="in" />
+ <arg type="i" name="channel_id" direction="in" />
+ <arg type="s" name="program_id" direction="in" />
<arg type="s" name="start_time" direction="in" />
<arg type="s" name="end_time" direction="in" />
<arg type="b" name="recurring" direction="in" />
@@ -84,8 +84,8 @@
<method name="AddException">
<arg type="u" name="schedule_id" direction="in" />
- <arg type="u" name="program_id" direction="in" />
- <arg type="u" name="channel_id" direction="in" />
+ <arg type="s" name="program_id" direction="in" />
+ <arg type="i" name="channel_id" direction="in" />
<arg type="s" name="start_time" direction="in" />
<arg type="s" name="end_time" direction="in" />
<arg type="s" name="description" direction="in" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ren...@us...> - 2008-01-31 19:56:16
|
Revision: 908
http://gmyth.svn.sourceforge.net/gmyth/?rev=908&view=rev
Author: renatofilho
Date: 2008-01-31 11:56:16 -0800 (Thu, 31 Jan 2008)
Log Message:
-----------
added gmyth-debug functions
Added Paths:
-----------
trunk/gmyth-dbus/src/gmyth_debug.c
trunk/gmyth-dbus/src/gmyth_debug.h
Added: trunk/gmyth-dbus/src/gmyth_debug.c
===================================================================
--- trunk/gmyth-dbus/src/gmyth_debug.c (rev 0)
+++ trunk/gmyth-dbus/src/gmyth_debug.c 2008-01-31 19:56:16 UTC (rev 908)
@@ -0,0 +1,58 @@
+/**
+ * GMyth Library
+ *
+ * @file gmyth/gmyth_debug.c
+ *
+ *
+ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
+ * @author Renato Filho <ren...@in...>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gmyth_debug.h"
+
+void
+gmyth_debug_real(const char *func,
+ const char *file, const int line, gboolean newline,
+ const char *format, ...)
+{
+ va_list args;
+ char buffer[1025];
+ char str_time[255];
+ time_t the_time;
+
+
+ if (g_getenv ("GMYTH-DEBUG"))
+ {
+ va_start(args, format);
+
+ g_vsnprintf(buffer, 1024, format, args);
+
+ va_end(args);
+
+ time(&the_time);
+ strftime(str_time, 254, "%H:%M:%S", localtime(&the_time));
+
+ g_printerr(newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
+ "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self(), func,
+ file, line, buffer);
+ }
+}
Added: trunk/gmyth-dbus/src/gmyth_debug.h
===================================================================
--- trunk/gmyth-dbus/src/gmyth_debug.h (rev 0)
+++ trunk/gmyth-dbus/src/gmyth_debug.h 2008-01-31 19:56:16 UTC (rev 908)
@@ -0,0 +1,42 @@
+/**
+ * GMyth Library
+ *
+ * @file gmyth/gmyth_debug.h
+ *
+ *
+ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
+ * @author Renato Filho <ren...@in...>
+ *
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __GMYTH_DEBUG_H__
+#define __GMYTH_DEBUG_H__
+
+#include <stdarg.h>
+#include <glib.h>
+#include <time.h>
+
+G_BEGIN_DECLS
+#define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+void
+gmyth_debug_real(const char *func,
+ const char *file, int line, gboolean newline,
+ const char *format, ...)
+G_GNUC_PRINTF(5, 6);
+
+G_END_DECLS
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|