branches/gmyth-0.1b/tests/gmyth_test_recordings.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 #include <glib-object.h>
     2 
     3 #include "gmyth_uri.h"
     4 #include "gmyth_backendinfo.h"
     5 #include "gmyth_scheduler.h"
     6 #include "gmyth_epg.h"
     7 #include "gmyth_common.h"
     8 
     9 static gboolean
    10 test_recording_list (GMythBackendInfo *backend_info)
    11 {
    12     GList *list = NULL;
    13     gint length = 0;
    14     GMythScheduler *scheduler = gmyth_scheduler_new ();
    15     
    16     if (gmyth_scheduler_connect_with_timeout (scheduler, 
    17 	    backend_info, 10) == TRUE) {
    18 	g_debug ("===== Scheduler connection success =====");
    19     } else {
    20 	g_debug ("===== Scheduler connection failed =====");
    21 	return FALSE;
    22     }
    23 
    24     length = gmyth_scheduler_get_recorded_list (scheduler, &list);
    25 
    26     g_debug ("===== %d Recordings found =====\n", length);
    27     length--;
    28     while (length >= 0) {
    29         RecordedInfo *record = (RecordedInfo*) g_list_nth_data (list, length);
    30 	if (record == 0) {
    31 	    g_debug ("===== Recorded list returned NULL pointer =====\n");
    32 	    length--;
    33 	    continue;
    34 	}
    35 	g_debug ("===== Record id = %d =====\n", record->record_id);
    36 	g_debug ("===== Record name = %s =====\n", (record ? record->basename->str : "NULL")); 
    37 	length--;
    38     }
    39 
    40     gmyth_scheduler_disconnect (scheduler);
    41     
    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 
    52     backend_info = gmyth_backend_info_new_with_uri (argv[1]);
    53 
    54     test_recording_list (backend_info);
    55 }
    56 
    57 
    58 
    59