1 #include <glib-object.h>
5 #include <gmyth/gmyth_uri.h>
6 #include <gmyth/gmyth_backendinfo.h>
7 #include <gmyth/gmyth_livetv.h>
8 #include <gmyth/gmyth_monitor_handler.h>
9 #include <gmyth/gmyth_common.h>
11 #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
14 * The GObject signal handler function, from which all status messages
15 * from the Monitor Handler will be advertized, all time it receives
16 * LiveTV status messages from the MythTV backend
18 * @param monitor a GMythMonitorHandler instance
19 * @param msg_code the MythTV's server numeric status code
20 * @param message the message's string description
21 * @param user_data pointer to the GMythLiveTV instance (NULL in the tests)
24 gmyth_livetv_monitor_signal_handler(GMythMonitorHandler * monitor,
25 gint msg_code, gchar * message,
29 ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n",
30 message, msg_code, "NULL", user_data != NULL ? "" : "NULL");
35 * Starts the Monitor Handler to this GMythLiveTV session, in order
36 * to receive the status messages from the MythTV's backend server
38 * @param live_tv the GMythLiveTV instance
40 * @return <code>true</code> if the Monitor Handler start-up process
41 * had been concluded succcesfully
44 gmyth_test_monitor_handler_start(GMythBackendInfo * backend_info,
45 GMythMonitorHandler * *monitor)
50 if (*monitor != NULL) {
51 g_object_unref(*monitor);
55 *monitor = gmyth_monitor_handler_new();
58 gmyth_monitor_handler_open(*monitor,
59 backend_info->hostname,
64 ("Connect MythTV Monitor event socket! Trying to start the message handler...");
66 res = gmyth_monitor_handler_start(*monitor);
70 ("MythTV Monitor event socket connected and listening!");
71 g_signal_connect(G_OBJECT(*monitor), "backend-events-handler",
73 gmyth_livetv_monitor_signal_handler, NULL);
76 ("Problems when trying to start MythTV Monitor event socket!");
87 test_monitor_handler_setup(gchar * uri)
90 GMythMonitorHandler *monitor;
93 uri = g_strdup(URI_DEFAULT);
95 GMythURI *gmyth_uri = gmyth_uri_new_with_value(uri);
97 GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
98 g_debug("uri = %s", uri);
100 ret = gmyth_test_monitor_handler_start(backend_info, &monitor);
103 g_debug("MonitorHandler couldn't start!\n");
109 g_object_unref(monitor);
111 if (gmyth_uri != NULL)
112 g_object_unref(gmyth_uri);
114 if (backend_info != NULL)
115 g_object_unref(backend_info);
122 main(gint args, const gchar ** argv)
130 fprintf(stdout, SYNC_STRING);
135 ret = test_monitor_handler_setup(argv[1]);
137 ret = test_monitor_handler_setup(NULL);
140 g_debug("Error when running Monitor Handler setup test script!");
142 g_debug("MonitorHandler setup test script setup with success.");