[svn r367] Itsn't mandatory to have database information in the GMyth URI.
1 #include <glib-object.h>
3 #include "gmyth_backendinfo.h"
4 #include "gmyth_remote_util.h"
5 #include "gmyth_query.h"
7 #include "gmyth_common.h"
11 test_recorder_availability (GMythBackendInfo *backend_info)
13 GMythRecorder* recorder;
14 GMythSocket *socket = gmyth_socket_new ();
16 if (gmyth_socket_connect_to_backend (socket,
17 gmyth_backend_info_get_hostname (backend_info),
18 gmyth_backend_info_get_port (backend_info), TRUE) == FALSE) {
19 g_debug ("Test recorder failed: Connection failed");
23 recorder = remote_request_next_free_recorder (socket, -1);
24 gmyth_socket_close_connection (socket);
25 if (recorder == NULL) {
26 g_debug ("Recorder not available\n");
30 g_debug ("Recorder found (num): %d", recorder->recorder_num);
36 test_recorder_setup (GMythBackendInfo *backend_info)
38 GMythQuery *query = gmyth_query_new ();
40 if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) {
41 g_debug ("Mysql connection success");
44 g_debug ("Mysql connection failed");
51 test_recorder_check_channels (GMythBackendInfo *backend_info)
53 GMythRecorder* recorder;
54 GMythSocket *socket = gmyth_socket_new ();
55 GMythEPG *epg = gmyth_epg_new ();
59 // Gets the free recorder
60 if (gmyth_socket_connect_to_backend (socket,
61 gmyth_backend_info_get_hostname (backend_info),
62 gmyth_backend_info_get_port (backend_info), TRUE) == FALSE) {
63 g_debug ("Test recorder failed: Connection failed");
67 recorder = remote_request_next_free_recorder (socket, -1);
68 gmyth_socket_close_connection (socket);
69 if (recorder == NULL) {
70 g_debug ("[%s] Recorder not available", __FUNCTION__);
74 // Connects the recorder socket
75 gmyth_recorder_setup (recorder);
77 // Gets the list of channels
78 if (!gmyth_epg_connect (epg, backend_info)) {
79 g_debug ("%s: Not connected\n", __FUNCTION__);
83 length = gmyth_epg_get_channel_list (epg, &clist);
84 gmyth_epg_disconnect (epg);
87 g_print ("==== Verifying the %d channels found in the EPG ====\n", length);
88 for (i=0; i<length; i++) {
89 GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
92 // Checks the channels
93 res = gmyth_recorder_check_channel (recorder, channel_info->channel_ID);
94 g_debug ("Channel %d %s", channel_info->channel_ID, res ? "Found" : "Not found");
103 main (int args, const char **argv)
105 const char* uri = argv[1];
107 GMythBackendInfo *backend_info;
109 g_thread_init (NULL);
111 backend_info = gmyth_backend_info_new_with_uri (argv[1]);
113 printf ("******** Testing recorder availability ***********\n");
114 test_recorder_availability (backend_info);
116 printf ("******** Testing recorder check channels function ***********\n");
117 test_recorder_check_channels (backend_info);