branches/gmyth-0.1b/tests/gmyth_test_epg.c
branchtrunk
changeset 333 f9d778bb88a2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/branches/gmyth-0.1b/tests/gmyth_test_epg.c	Wed Feb 07 20:38:39 2007 +0000
     1.3 @@ -0,0 +1,60 @@
     1.4 +
     1.5 +#include "gmyth_backendinfo.h"
     1.6 +#include "gmyth_epg.h"
     1.7 +
     1.8 +static gboolean
     1.9 +test_epg_connection (GMythBackendInfo *backend_info)
    1.10 +{
    1.11 +    GMythEPG *epg = gmyth_epg_new ();
    1.12 +    gboolean res = FALSE;
    1.13 +
    1.14 +    res = gmyth_epg_connect (epg, backend_info);
    1.15 +
    1.16 +    gmyth_epg_disconnect (epg);
    1.17 +    g_object_unref (epg);
    1.18 +
    1.19 +    return res; 
    1.20 +}
    1.21 +
    1.22 +
    1.23 +static gboolean
    1.24 +test_epg_get_channels (GMythBackendInfo *backend_info)
    1.25 +{
    1.26 +    GMythEPG *epg = gmyth_epg_new ();
    1.27 +    GList *clist;
    1.28 +    gint i, length;
    1.29 +
    1.30 +    if (!gmyth_epg_connect (epg, backend_info)) {
    1.31 +        return FALSE;
    1.32 +    }
    1.33 +
    1.34 +    length = gmyth_epg_get_channel_list (epg, &clist);
    1.35 +    g_print ("==== %d channels found in the EPG ====\n", length);
    1.36 +    for (i=0; i<length; i++) {
    1.37 +        GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
    1.38 +
    1.39 +        gmyth_channel_info_print(channel_info);
    1.40 +    }
    1.41 +
    1.42 +    g_list_free (clist);
    1.43 +    gmyth_epg_disconnect (epg);
    1.44 +    g_object_unref (epg);
    1.45 +}
    1.46 +
    1.47 +int
    1.48 +main (int args, const char **argv)
    1.49 +{
    1.50 +    const char* uri = argv[1];
    1.51 +
    1.52 +    GMythBackendInfo *backend_info;
    1.53 +    g_type_init ();
    1.54 +    g_thread_init (NULL);
    1.55 +
    1.56 +    backend_info = gmyth_backend_info_new_with_uri (argv[1]);
    1.57 +
    1.58 +    test_epg_connection (backend_info);
    1.59 +    test_epg_get_channels (backend_info);
    1.60 +
    1.61 +    return 0;
    1.62 +}
    1.63 +