1 #include <glib-object.h>
3 #include <gmyth/gmyth_backendinfo.h>
4 #include <gmyth/gmyth_remote_util.h>
5 #include <gmyth/gmyth_query.h>
6 #include <gmyth/gmyth_epg.h>
7 #include <gmyth/gmyth_common.h>
12 test_recorder_availability(GMythBackendInfo * backend_info)
14 GMythRecorder *recorder;
15 GMythSocket *socket = gmyth_socket_new();
17 if (gmyth_socket_connect_to_backend(socket,
18 gmyth_backend_info_get_hostname
20 gmyth_backend_info_get_port
21 (backend_info), TRUE) == FALSE)
23 g_debug("Test recorder failed: Connection failed");
27 recorder = remote_request_next_free_recorder(socket, -1);
28 gmyth_socket_close_connection(socket);
31 g_object_unref(socket);
35 g_debug("Recorder not available\n");
39 g_debug("Recorder found (num): %d", recorder->recorder_num);
42 g_object_unref(recorder);
48 test_recorder_setup(GMythBackendInfo * backend_info)
50 GMythQuery *query = gmyth_query_new();
52 if (gmyth_query_connect_with_timeout(query, backend_info, 3) == TRUE)
54 g_debug("Mysql connection success");
59 g_debug("Mysql connection failed");
64 g_object_unref(query);
69 test_recorder_check_channels(GMythBackendInfo * backend_info)
71 GMythRecorder *recorder;
72 GMythSocket *socket = gmyth_socket_new();
73 GMythEPG *epg = gmyth_epg_new();
77 // Gets the free recorder
78 if (gmyth_socket_connect_to_backend(socket,
79 gmyth_backend_info_get_hostname
81 gmyth_backend_info_get_port
82 (backend_info), TRUE) == FALSE)
84 g_debug("Test recorder failed: Connection failed");
88 recorder = remote_request_next_free_recorder(socket, -1);
89 gmyth_socket_close_connection(socket);
90 g_object_unref(socket);
94 g_debug("[%s] Recorder not available", __FUNCTION__);
98 // Connects the recorder socket
99 gmyth_recorder_setup(recorder);
101 // Gets the list of channels
102 if (!gmyth_epg_connect(epg, backend_info))
104 g_debug("%s: Not connected\n", __FUNCTION__);
108 length = gmyth_epg_get_channel_list(epg, &clist);
109 gmyth_epg_disconnect(epg);
112 g_print("==== Verifying the %d channels found in the EPG ====\n", length);
113 for (i = 0; i < length; i++)
115 GMythChannelInfo *channel_info =
116 (GMythChannelInfo *) g_list_nth_data(clist, i);
119 // Checks the channels
120 res = gmyth_recorder_check_channel(recorder, channel_info->channel_ID);
121 g_debug("Channel %d %s", channel_info->channel_ID,
122 res ? "Found" : "Not found");
127 if (recorder != NULL)
128 g_object_unref(recorder);
133 main(int args, const char **argv)
136 GMythBackendInfo *backend_info;
140 backend_info = gmyth_backend_info_new_with_uri(argv[1]);
142 printf("******** Testing recorder availability ***********\n");
143 test_recorder_availability(backend_info);
145 printf("******** Testing recorder check channels function ***********\n");
146 test_recorder_check_channels(backend_info);
148 fprintf(stdout, SYNC_STRING);
152 if (backend_info != NULL)
153 g_object_unref(backend_info);