branches/gmyth-0.1b/tests/gmyth_test_epg.c
author rosfran
Tue Feb 06 00:33:35 2007 +0000 (2007-02-06)
branchtrunk
changeset 326 81b1f3006eb2
permissions -rw-r--r--
[svn r328] Some fixes on program info, and some memory clean ups.
     1 
     2 #include "gmyth_backendinfo.h"
     3 #include "gmyth_epg.h"
     4 
     5 static gboolean
     6 test_epg_connection (GMythBackendInfo *backend_info)
     7 {
     8     GMythEPG *epg = gmyth_epg_new ();
     9     gboolean res = FALSE;
    10 
    11     res = gmyth_epg_connect (epg, backend_info);
    12 
    13     gmyth_epg_disconnect (epg);
    14     g_object_unref (epg);
    15 
    16     return res; 
    17 }
    18 
    19 
    20 static gboolean
    21 test_epg_get_channels (GMythBackendInfo *backend_info)
    22 {
    23     GMythEPG *epg = gmyth_epg_new ();
    24     GList *clist;
    25     gint i, length;
    26 
    27     if (!gmyth_epg_connect (epg, backend_info)) {
    28         return FALSE;
    29     }
    30 
    31     length = gmyth_epg_get_channel_list (epg, &clist);
    32     g_print ("==== %d channels found in the EPG ====\n", length);
    33     for (i=0; i<length; i++) {
    34         GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
    35 
    36         gmyth_channel_info_print(channel_info);
    37     }
    38 
    39     g_list_free (clist);
    40     gmyth_epg_disconnect (epg);
    41     g_object_unref (epg);
    42 }
    43 
    44 int
    45 main (int args, const char **argv)
    46 {
    47     const char* uri = argv[1];
    48 
    49     GMythBackendInfo *backend_info;
    50     g_type_init ();
    51     g_thread_init (NULL);
    52 
    53     backend_info = gmyth_backend_info_new_with_uri (argv[1]);
    54 
    55     test_epg_connection (backend_info);
    56     test_epg_get_channels (backend_info);
    57 
    58     return 0;
    59 }
    60