# HG changeset patch # User rosfran # Date 1176934406 -3600 # Node ID f5ef83bbe8b5aa009deb5b6b9af24f12b5a45762 # Parent 0200f97ac28942448bbf10dca24fa02f1a5caac5 [svn r573] New function to get the information about the program info path directiory. diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_file_transfer.c Wed Apr 18 23:13:26 2007 +0100 @@ -729,7 +729,6 @@ ret_strlist = NULL; } - if (read_unlimited && (bytes_sent == 0)) { gmyth_debug( "Trying to move to the next program chain..." ); if (priv->recorder != NULL && diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Wed Apr 18 23:13:26 2007 +0100 @@ -42,6 +42,7 @@ #include "gmyth_monitor_handler.h" #include "gmyth_common.h" +#include "gmyth_util.h" static void gmyth_livetv_class_init (GMythLiveTVClass *klass); static void gmyth_livetv_init (GMythLiveTV *object); @@ -492,11 +493,12 @@ for (i=1; i<1000; i++) { if ( channame != NULL ) g_free(channame); - channame = g_strdup_printf( "%d", i ); + channame = g_strdup_printf( "%d", i ); if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) { continue; } prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP); + gmyth_program_info_print( prog_info ); if (prog_info != NULL) break; } @@ -510,6 +512,14 @@ /* check if the program chain could be obtained from the MythTV protocol message */ if ( prog_info != NULL ) { + /* + GMythProgramInfo *ch_prog = gmyth_util_get_recording_from_channel( livetv->backend_info, channel ); + if ( ch_prog != NULL ) + { + gmyth_debug( "Channel program info!" ); + gmyth_program_info_print( ch_prog ); + } + */ gmyth_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) ); livetv->proginfo = prog_info; /* testing change channel */ diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_programinfo.c Wed Apr 18 23:13:26 2007 +0100 @@ -334,78 +334,147 @@ * Converts an instance of a GMythStringList, to a GMythProgramInfo. * * @param slist The GMythStringList got from the MythTV backend server. + * @param pos The position in the GMythStringList to start getting the fields. + * + * @return a GMythProgramInfo representing the string list got from network. + */ +GMythProgramInfo* +gmyth_program_info_from_string_list_from_pos ( GMythStringList *slist, guint pos ) +{ + GMythProgramInfo *prog = gmyth_program_info_new(); + + g_return_val_if_fail (slist != NULL && + gmyth_string_list_get_string (slist, pos) != NULL, NULL); + + prog->title = gmyth_string_list_get_string (slist, pos); + prog->subtitle = gmyth_string_list_get_string (slist, pos+1); + prog->description = gmyth_string_list_get_string (slist, pos+2); + prog->category = gmyth_string_list_get_string (slist, pos+3); + prog->chanid = gmyth_string_list_get_string (slist, pos+4); + prog->channame = gmyth_string_list_get_string (slist, pos+5); + prog->chanstr = gmyth_string_list_get_string (slist, pos+6); + prog->chansign = gmyth_string_list_get_string (slist, pos+7); + prog->pathname = gmyth_string_list_get_string (slist, pos+8); + + prog->filesize = gmyth_string_list_get_int64 (slist, pos+9); + + gmyth_debug( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", + gmyth_program_info_non_null_value( prog->title ), + gmyth_program_info_non_null_value( prog->subtitle ), + gmyth_program_info_non_null_value( prog->description ), + gmyth_program_info_non_null_value( prog->category ), + gmyth_program_info_non_null_value( prog->chanid ), + gmyth_program_info_non_null_value( prog->channame ), + gmyth_program_info_non_null_value( prog->chanstr ), + gmyth_program_info_non_null_value( prog->chansign ), + gmyth_program_info_non_null_value( prog->pathname ), + gmyth_string_list_get_int (slist, pos+11) ); + + prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+11) ))->str ); //DATETIME_TO_LIST(startts) + prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+12) ))->str ); //DATETIME_TO_LIST(endts) + prog->duplicate = gmyth_string_list_get_int (slist, pos+13); + prog->shareable = gmyth_string_list_get_int (slist, pos+14); + prog->findid = gmyth_string_list_get_int (slist, pos+15); + prog->hostname = gmyth_string_list_get_string (slist, pos+16); + prog->sourceid = gmyth_string_list_get_int (slist, pos+17); + prog->cardid = gmyth_string_list_get_int (slist, pos+18); + prog->inputid = gmyth_string_list_get_int (slist, pos+19); + prog->recpriority = gmyth_string_list_get_int (slist, pos+20); + prog->reactivate = gmyth_string_list_get_int (slist, pos+21); + prog->recordid = gmyth_string_list_get_int (slist, pos+22); + gmyth_string_list_get_int (slist, pos+23); + gmyth_string_list_get_int (slist, pos+24); + gmyth_string_list_get_int (slist, pos+25); + prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+26) ))->str ); //DATETIME_TO_LIST(recstartts) + prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+27) ))->str ); //DATETIME_TO_LIST(recendts) + prog->repeat = gmyth_string_list_get_int (slist, pos+28); + prog->programflags = gmyth_string_list_get_int (slist, pos+29); + prog->recgroup = gmyth_string_list_get_string (slist, pos+30); //prog->(recgroup != "") ? recgroup : "Default") + prog->chancommfree = gmyth_string_list_get_int (slist, pos+31); + prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos+32); + prog->seriesid = gmyth_string_list_get_string (slist, pos+33); + prog->programid = gmyth_string_list_get_string (slist, pos+34); + gmyth_string_list_get_string (slist, pos+35); + prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+36) ))->str ); //DATETIME_TO_LIST(lastmodified) + gmyth_string_list_get_int (slist, pos+37); //FLOAT_TO_LIST(stars) + prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (slist, pos+38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate)) + prog->hasAirDate = gmyth_string_list_get_int (slist, pos+39); + prog->playgroup = gmyth_string_list_get_string (slist, pos+40); //prog->(playgroup != "") ? playgroup : "Default") + prog->recpriority2 = gmyth_string_list_get_int (slist, pos+41); + + return prog; +} + +/** + * Converts an instance of a GMythStringList, to a GMythProgramInfo. + * + * @param slist The GMythStringList got from the MythTV backend server. * * @return a GMythProgramInfo representing the string list got from network. */ GMythProgramInfo* gmyth_program_info_from_string_list ( GMythStringList *slist ) { + GMythProgramInfo *prog = NULL; + + g_return_val_if_fail (slist != NULL, NULL); + + prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 ); + + return prog; +} + +/** + * Converts an instance of a GMythStringList, to a GMythProgramInfo ( NEXT_PROGRAM_INFO ). + * + * @param slist The GMythStringList got from the MythTV backend server. + * + * @return a GMythProgramInfo representing the string list got from network. + */ +GMythProgramInfo* +gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist ) +{ GMythProgramInfo *prog = gmyth_program_info_new(); g_return_val_if_fail (slist != NULL, NULL); + + /* + {Home Improvement[]:[]No, No, Godot[]:[] + US sitcom about a DIY-obsessed father of three. When + Tim tries to sell off his extra ticket for an ice hockey game, he is arrested as a tout.[]:[] + Sitcom[]:[]2007-04-18T15:30:00[]:[]2007-04-18T16:00:00[]:[]ABC1[]:[] + /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] } + */ prog->title = gmyth_string_list_get_string (slist, 0); prog->subtitle = gmyth_string_list_get_string (slist, 1); prog->description = gmyth_string_list_get_string (slist, 2); prog->category = gmyth_string_list_get_string (slist, 3); - prog->chanid = gmyth_string_list_get_string (slist, 4); - prog->channame = gmyth_string_list_get_string (slist, 5); - prog->chanstr = gmyth_string_list_get_string (slist, 6); - prog->chansign = gmyth_string_list_get_string (slist, 7); - prog->pathname = gmyth_string_list_get_string (slist, 8); + prog->startts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 4) ); //DATETIME_TO_LIST(startts) + prog->endts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 5) ); //DATETIME_TO_LIST(endts) + prog->channame = gmyth_string_list_get_string (slist, 6); + prog->chansign = gmyth_string_list_get_string (slist, 7); + prog->chanstr = gmyth_string_list_get_string (slist, 8); + prog->chanid = gmyth_string_list_get_string (slist, 9); + prog->filesize = gmyth_string_list_get_int64 (slist, 10); + + gmyth_debug( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n", + gmyth_program_info_non_null_value( prog->title ), + gmyth_program_info_non_null_value( prog->subtitle ), + gmyth_program_info_non_null_value( prog->description ), + gmyth_program_info_non_null_value( prog->category ), + gmyth_program_info_non_null_value( prog->chanid ), + gmyth_program_info_non_null_value( prog->channame ), + gmyth_program_info_non_null_value( prog->chanstr ), + gmyth_program_info_non_null_value( prog->chansign ), + gmyth_program_info_non_null_value( prog->pathname ) ); - prog->filesize = gmyth_string_list_get_int64 (slist, 9); - - gmyth_debug( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", - gmyth_program_info_non_null_value( prog->title ), - gmyth_program_info_non_null_value( prog->subtitle ), - gmyth_program_info_non_null_value( prog->description ), - gmyth_program_info_non_null_value( prog->category ), - gmyth_program_info_non_null_value( prog->chanid ), - gmyth_program_info_non_null_value( prog->channame ), - gmyth_program_info_non_null_value( prog->chanstr ), - gmyth_program_info_non_null_value( prog->chansign ), - gmyth_program_info_non_null_value( prog->pathname ), - gmyth_string_list_get_int (slist, 11) ); - - prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts) - prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts) - prog->duplicate = gmyth_string_list_get_int (slist, 13); - prog->shareable = gmyth_string_list_get_int (slist, 14); - prog->findid = gmyth_string_list_get_int (slist, 15); - prog->hostname = gmyth_string_list_get_string (slist, 16); - prog->sourceid = gmyth_string_list_get_int (slist, 17); - prog->cardid = gmyth_string_list_get_int (slist, 18); - prog->inputid = gmyth_string_list_get_int (slist, 19); - prog->recpriority = gmyth_string_list_get_int (slist, 20); - prog->reactivate = gmyth_string_list_get_int (slist, 21); - prog->recordid = gmyth_string_list_get_int (slist, 22); - gmyth_string_list_get_int (slist, 23); - gmyth_string_list_get_int (slist, 24); - gmyth_string_list_get_int (slist, 25); - prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts) - prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts) - prog->repeat = gmyth_string_list_get_int (slist, 28); - prog->programflags = gmyth_string_list_get_int (slist, 29); - prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default") - prog->chancommfree = gmyth_string_list_get_int (slist, 31); - prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32); - prog->seriesid = gmyth_string_list_get_string (slist, 33); - prog->programid = gmyth_string_list_get_string (slist, 34); - gmyth_string_list_get_string (slist, 35); - prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 36) ))->str ); //DATETIME_TO_LIST(lastmodified) - gmyth_string_list_get_int (slist, 37); //FLOAT_TO_LIST(stars) - prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (slist, 38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate)) - prog->hasAirDate = gmyth_string_list_get_int (slist, 39); - prog->playgroup = gmyth_string_list_get_string (slist, 40); //prog->(playgroup != "") ? playgroup : "Default") - prog->recpriority2 = gmyth_string_list_get_int (slist, 41); - return prog; } diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_programinfo.h Wed Apr 18 23:13:26 2007 +0100 @@ -155,8 +155,13 @@ GMythStringList* gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist); + +GMythProgramInfo* gmyth_program_info_from_string_list_from_pos (GMythStringList *slist, guint pos); + GMythProgramInfo* gmyth_program_info_from_string_list (GMythStringList *slist); +GMythProgramInfo* gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist ); + const gchar* gmyth_program_info_to_string( const GMythProgramInfo* prog ); gboolean gmyth_program_info_is_equals( const GMythProgramInfo* prog1, diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_recorder.c Wed Apr 18 23:13:26 2007 +0100 @@ -828,6 +828,9 @@ * Requests the actual program info from the MythTV backend server. * * @param recorder The GMythRecorder instance. + * @param direction The direction to move based on the current channel (forward, backward, + * up, down). + * * @return The GMythProgramInfo next program info instance. */ GMythProgramInfo * @@ -838,8 +841,8 @@ GMythStringList *str_list; GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gchar *date= NULL; - struct tm *tm; + gchar *date = NULL; + struct tm *tm = NULL; time_t t; actual_proginfo = gmyth_recorder_get_current_program_info(recorder); @@ -870,7 +873,7 @@ __FUNCTION__); goto done; } - program_info = gmyth_program_info_new(); + program_info = gmyth_program_info_from_string_list_next_prog(str_list); if ( NULL == program_info) { gmyth_debug( @@ -880,27 +883,9 @@ goto done; } - program_info->title = gmyth_string_list_get_string(str_list, 0); - program_info->subtitle = gmyth_string_list_get_string(str_list, 1); - program_info->description = gmyth_string_list_get_string(str_list, 2); - program_info->category = gmyth_string_list_get_string(str_list, 3); - program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (str_list, 4) ))->str); - program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (str_list, 6) ))->str); - - program_info->chansign = gmyth_string_list_get_string(str_list, 8); - program_info->pathname = gmyth_string_list_get_string(str_list, 9); - program_info->channame = gmyth_string_list_get_string(str_list, 10); - program_info->chanid = gmyth_string_list_get_string(str_list, 11); - if ( recorder->myth_socket->mythtv_version >= 12) { - program_info->seriesid = gmyth_string_list_get_string(str_list, 12); - program_info->programid = gmyth_string_list_get_string(str_list, 13); - } - if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) &&*/ - ( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 )) { - gmyth_debug( "OK!!! Got the next program info..." ); + ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) { + gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str ); } else { gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" ); g_object_unref(program_info); @@ -913,13 +898,110 @@ g_mutex_unlock( recorder->mutex ); - g_object_unref(actual_proginfo); - g_object_unref(str_list); + if ( actual_proginfo != NULL ) + g_object_unref(actual_proginfo); + + if ( str_list != NULL ) + g_object_unref(str_list); + + if ( tmp_str != NULL ) + g_string_free(tmp_str, TRUE); - g_string_free(tmp_str, TRUE); + if ( date != NULL ) + g_free(date); + //if ( tm != NULL) + // g_free (tm); - g_free(date); - g_free (tm); + return program_info; +} + +/** + * Requests the program info from the MythTV backend server, based on its + * channel name. + * + * @param recorder The GMythRecorder instance. + * @return The GMythProgramInfo next program info instance. + */ +GMythProgramInfo * +gmyth_recorder_get_program_info_from_channel_name( GMythRecorder *recorder, + const gchar* channel ) { + //GMythProgramInfo* actual_proginfo= NULL; + GMythProgramInfo* program_info= NULL; + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); + + /* + gchar *date = NULL; + struct tm *tm = NULL; + time_t t; + + actual_proginfo = gmyth_recorder_get_current_program_info(recorder); + */ + + str_list = gmyth_string_list_new(); + + g_mutex_lock( recorder->mutex ); + + g_string_append_printf( tmp_str, " %d", recorder->recorder_num ); + + /* + t = time(NULL); + tm = localtime(&t); + date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900, + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + */ + + gmyth_string_list_append_string(str_list, tmp_str); + gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO"); + gmyth_string_list_append_char_array(str_list, channel); + gmyth_string_list_append_char_array(str_list, "0"); + gmyth_string_list_append_int(str_list, BROWSE_DIRECTION_UP); + gmyth_string_list_append_char_array(str_list, "0"); + + do { + + if ( str_list != NULL && + gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list) > 0 ) { + + if (str_list == NULL) { + gmyth_debug( + "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", + __FUNCTION__); + goto done; + } + program_info = gmyth_program_info_from_string_list_next_prog(str_list); + + if ( NULL == program_info) { + gmyth_debug( + "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", + __FUNCTION__); + g_object_unref(program_info); + goto done; + } + + if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) &&*/ + ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) { + gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str ); + } else { + gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting " + "next program info, it is equals to NULL!!!" ); + g_object_unref(program_info); + program_info = NULL; + } + + } /* if */ + + } while ( str_list != NULL ); + +done: + + g_mutex_unlock( recorder->mutex ); + + if ( str_list != NULL ) + g_object_unref(str_list); + + if ( tmp_str != NULL ) + g_string_free(tmp_str, TRUE); return program_info; } diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_util.c Wed Apr 18 23:13:26 2007 +0100 @@ -597,6 +597,104 @@ return channel_list; } +/** + * Gets all the recordings from remote encoder. + * + * @param backend_info The GMythBackendInfo instance. + * + * @return The program info's listage. + */ +GSList * +gmyth_util_get_all_recordings (GMythBackendInfo *backend_info) +{ + GSList *program_list = NULL; + GMythSocket *socket; + gboolean res; + + socket = gmyth_socket_new (); + res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, + backend_info->port, TRUE); + + if (res == TRUE) { + GMythStringList *slist = gmyth_string_list_new (); + guint pos = 0; + gmyth_string_list_append_char_array (slist, "QUERY_RECORDINGS Play"); + + gmyth_socket_sendreceive_stringlist (socket, slist); + + if ( slist != NULL && ( gmyth_string_list_length( slist ) > 0 ) ) + { + GMythProgramInfo *program = NULL; + + gmyth_debug( "OK! Got the program list [size=%d].", gmyth_string_list_length( slist ) ); + + do + { + program = gmyth_program_info_from_string_list_from_pos( slist, pos ); + + if ( program != NULL ) + { + pos += 41; + + program_list = g_slist_append( program_list, program ); + } else + break; + + } while ( gmyth_string_list_length( slist ) > pos ); + + } /* if */ + + g_object_unref (slist); + + gmyth_socket_close_connection (socket); + } + g_object_unref (socket); + + return program_list; +} + +/** + * Checks if the given remote file exists, and gets its remote directory. + * + * @param backend_info The GMythBackendInfo instance. + * @param channel The channel name of the program info. + * + * @return The requested program info. + */ +GMythProgramInfo * +gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, const gchar *channel) +{ + GSList *program_list = NULL; + GMythProgramInfo *program = NULL; + + program_list = gmyth_util_get_all_recordings( backend_info ); + + if ( program_list != NULL && g_slist_length(program_list) >0 ) + { + GMythProgramInfo *program = NULL; + guint pos = 0; + + gmyth_debug( "OK! Got the program list [size=%d].", g_slist_length( program_list ) ); + + while ( pos < g_slist_length( program_list ) ) + { + program = (GMythProgramInfo*)g_slist_nth_data( program_list, pos ); + + if ( program != NULL && program->channame!= NULL && + g_ascii_strncasecmp( program->channame->str, channel, strlen(channel) ) == 0 ) + { + break; + } + + ++pos; + + } /* while */ + + } /* if */ + + return program; +} + #if !GLIB_CHECK_VERSION (2, 10, 0) /* Hacked from glib 2.10 */ diff -r 0200f97ac289 -r f5ef83bbe8b5 gmyth/src/gmyth_util.h --- a/gmyth/src/gmyth_util.h Wed Apr 18 22:01:21 2007 +0100 +++ b/gmyth/src/gmyth_util.h Wed Apr 18 23:13:26 2007 +0100 @@ -35,6 +35,7 @@ #include "gmyth_stringlist.h" #include "gmyth_backendinfo.h" +#include "gmyth_programinfo.h" G_BEGIN_DECLS @@ -70,6 +71,11 @@ GList * gmyth_util_get_channel_list (GMythBackendInfo *backend_info); +GSList * gmyth_util_get_all_recordings (GMythBackendInfo *backend_info); + +GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, + const gchar *channel); + G_END_DECLS #endif /*GMYTH_UTIL_H_*/