gmyth/tests/gmyth_test_recordings.c
author renatofilho
Thu Jun 14 18:19:52 2007 +0100 (2007-06-14)
branchtrunk
changeset 750 312d6bc514f3
parent 618 88001a25ab5a
child 754 cb885ee44618
permissions -rw-r--r--
[svn r756] fixed indent using GNU Style
     1 #include <glib-object.h>
     2 
     3 #include <gmyth/gmyth_uri.h>
     4 #include <gmyth/gmyth_backendinfo.h>
     5 #include <gmyth/gmyth_scheduler.h>
     6 #include <gmyth/gmyth_epg.h>
     7 #include <gmyth/gmyth_common.h>
     8 
     9 #include "common.h"
    10 
    11 static gboolean
    12 test_recording_list(GMythBackendInfo * backend_info)
    13 {
    14   GList *list = NULL;
    15   gint length = 0;
    16   GMythScheduler *scheduler = gmyth_scheduler_new();
    17 
    18   if (gmyth_scheduler_connect_with_timeout(scheduler,
    19 										   backend_info, 10) == TRUE)
    20 	{
    21 	  g_debug("===== Scheduler connection success =====");
    22 	}
    23   else
    24 	{
    25 	  g_debug("===== Scheduler connection failed =====");
    26 	  return FALSE;
    27 	}
    28 
    29   length = gmyth_scheduler_get_recorded_list(scheduler, &list);
    30 
    31   g_debug("===== %d Recordings found =====\n", length);
    32   length--;
    33   while (length >= 0)
    34 	{
    35 	  RecordedInfo *record = (RecordedInfo *) g_list_nth_data(list, length);
    36 	  if (record == 0)
    37 		{
    38 		  g_debug("===== Recorded list returned NULL pointer =====\n");
    39 		  length--;
    40 		  continue;
    41 		}
    42 	  g_debug("===== Record id = %d =====\n", record->record_id);
    43 	  g_debug("===== Record name = %s =====\n",
    44 			  (record ? record->basename->str : "NULL"));
    45 	  length--;
    46 	}
    47 
    48   gmyth_scheduler_disconnect(scheduler);
    49 
    50   if (scheduler != NULL)
    51 	g_object_unref(scheduler);
    52 
    53   if (list != NULL)
    54 	g_list_free(list);
    55 
    56 }
    57 
    58 int
    59 main(int args, const char **argv)
    60 {
    61   GMythBackendInfo *backend_info;
    62   g_type_init();
    63 
    64   backend_info = gmyth_backend_info_new_with_uri(argv[1]);
    65 
    66   test_recording_list(backend_info);
    67 
    68   fprintf(stdout, SYNC_STRING);
    69   fflush(NULL);
    70   getchar();
    71 
    72   if (backend_info != NULL)
    73 	g_object_unref(backend_info);
    74 
    75   return (0);
    76 }