2 #include <gmyth/gmyth_backendinfo.h>
3 #include <gmyth/gmyth_epg.h>
8 test_epg_connection (GMythBackendInfo *backend_info)
10 GMythEPG *epg = gmyth_epg_new ();
13 res = gmyth_epg_connect (epg, backend_info);
15 gmyth_epg_disconnect (epg);
24 test_epg_get_channels (GMythBackendInfo *backend_info)
26 GMythEPG *epg = gmyth_epg_new ();
30 if (!gmyth_epg_connect (epg, backend_info)) {
34 length = gmyth_epg_get_channel_list (epg, &clist);
35 g_debug ("==== %d channels found in the EPG ====\n", length);
36 for (i=0; i<length; i++) {
37 GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
39 gmyth_channel_info_print(channel_info);
43 gmyth_epg_disconnect (epg);
49 test_epg_get_channel_icon (GMythBackendInfo *backend_info)
51 GMythEPG *epg = gmyth_epg_new ();
55 if (!gmyth_epg_connect (epg, backend_info)) {
59 length = gmyth_epg_get_channel_list (epg, &clist);
60 g_debug ("==== %d channels found in the EPG ====\n", length);
61 for (i=0; i<length; i++) {
62 GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
64 if (gmyth_epg_channel_has_icon (epg, channel_info)) {
65 gchar *icon_name = g_strdup_printf ("%s.jpg", channel_info->channel_name->str);
66 guint8 *icon_data = NULL;
69 g_debug ("Channel %s has icon %s\n", channel_info->channel_name->str, channel_info->channel_icon->str);
71 if (gmyth_epg_channel_get_icon (epg, channel_info, &icon_data, &icon_length)) {
72 FILE *outfile = fopen (icon_name, "w+");
73 if (fwrite (icon_data, icon_length, 1, outfile) == icon_length)
74 g_debug ("\tIcon saved as %s", icon_name);
76 g_debug ("\tError while downloading the file or writing it");
83 g_debug ("Channel %s does not have icon\n", channel_info->channel_name->str);
85 gmyth_channel_info_print(channel_info);
89 gmyth_epg_disconnect (epg);
96 main (int args, const char **argv)
99 GMythBackendInfo *backend_info;
101 g_thread_init (NULL);
104 g_debug ("Type %s myth://hostname:port/?mythconverg\n", argv[0]);
108 backend_info = gmyth_backend_info_new_with_uri (argv[1]);
110 fprintf(stdout, SYNC_STRING);
114 test_epg_connection (backend_info);
115 test_epg_get_channels (backend_info);
116 test_epg_get_channel_icon (backend_info);
118 if ( backend_info != NULL )
119 g_object_unref( backend_info );