[svn r573] New function to get the information about the program info path directiory. trunk
authorrosfran
Wed Apr 18 23:13:26 2007 +0100 (2007-04-18)
branchtrunk
changeset 568f5ef83bbe8b5
parent 567 0200f97ac289
child 569 644a526d4086
[svn r573] New function to get the information about the program info path directiory.
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_programinfo.c
gmyth/src/gmyth_programinfo.h
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_util.c
gmyth/src/gmyth_util.h
     1.1 --- a/gmyth/src/gmyth_file_transfer.c	Wed Apr 18 22:01:21 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_file_transfer.c	Wed Apr 18 23:13:26 2007 +0100
     1.3 @@ -729,7 +729,6 @@
     1.4  	    ret_strlist = NULL;
     1.5      }
     1.6  
     1.7 -
     1.8      if (read_unlimited && (bytes_sent == 0)) {
     1.9  		gmyth_debug( "Trying to move to the next program chain..." );
    1.10  		if (priv->recorder != NULL &&
     2.1 --- a/gmyth/src/gmyth_livetv.c	Wed Apr 18 22:01:21 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_livetv.c	Wed Apr 18 23:13:26 2007 +0100
     2.3 @@ -42,6 +42,7 @@
     2.4  #include "gmyth_monitor_handler.h"
     2.5  
     2.6  #include "gmyth_common.h"
     2.7 +#include "gmyth_util.h"
     2.8  
     2.9  static void gmyth_livetv_class_init          (GMythLiveTVClass *klass);
    2.10  static void gmyth_livetv_init                (GMythLiveTV *object);
    2.11 @@ -492,11 +493,12 @@
    2.12          for (i=1; i<1000; i++) {
    2.13      		if ( channame != NULL )
    2.14      			g_free(channame);
    2.15 -            channame = g_strdup_printf( "%d", i );
    2.16 +            channame = g_strdup_printf( "%d", i );            
    2.17              if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) {
    2.18                  continue;
    2.19              }
    2.20              prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP);
    2.21 +            gmyth_program_info_print( prog_info );
    2.22              if (prog_info != NULL)
    2.23                  break;
    2.24          }
    2.25 @@ -510,6 +512,14 @@
    2.26  	/* check if the program chain could be obtained from the MythTV protocol message */
    2.27  	if ( prog_info != NULL )
    2.28  	{
    2.29 +      /*
    2.30 +	    GMythProgramInfo *ch_prog = gmyth_util_get_recording_from_channel( livetv->backend_info, channel );
    2.31 +	    if ( ch_prog != NULL )
    2.32 +	    {
    2.33 +          gmyth_debug( "Channel program info!" );
    2.34 +          gmyth_program_info_print( ch_prog );
    2.35 +	    }
    2.36 +      */
    2.37  		gmyth_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) );
    2.38  		livetv->proginfo = prog_info;
    2.39  		/* testing change channel */
     3.1 --- a/gmyth/src/gmyth_programinfo.c	Wed Apr 18 22:01:21 2007 +0100
     3.2 +++ b/gmyth/src/gmyth_programinfo.c	Wed Apr 18 23:13:26 2007 +0100
     3.3 @@ -334,78 +334,147 @@
     3.4   * Converts an instance of a GMythStringList, to a GMythProgramInfo.
     3.5   * 
     3.6   * @param slist The GMythStringList got from the MythTV backend server.
     3.7 + * @param pos   The position in the GMythStringList to start getting the fields.
     3.8 + * 
     3.9 + * @return a GMythProgramInfo representing the string list got from network.
    3.10 + */
    3.11 +GMythProgramInfo*
    3.12 +gmyth_program_info_from_string_list_from_pos ( GMythStringList *slist, guint pos )
    3.13 +{
    3.14 +    GMythProgramInfo *prog = gmyth_program_info_new();
    3.15 +
    3.16 +    g_return_val_if_fail (slist != NULL && 
    3.17 +            gmyth_string_list_get_string (slist, pos) != NULL, NULL);
    3.18 +
    3.19 +    prog->title = gmyth_string_list_get_string (slist, pos);    
    3.20 +    prog->subtitle = gmyth_string_list_get_string (slist, pos+1);
    3.21 +    prog->description = gmyth_string_list_get_string (slist, pos+2);
    3.22 +    prog->category = gmyth_string_list_get_string (slist, pos+3);
    3.23 +    prog->chanid = gmyth_string_list_get_string (slist, pos+4);
    3.24 +    prog->channame = gmyth_string_list_get_string (slist, pos+5);
    3.25 +    prog->chanstr = gmyth_string_list_get_string (slist, pos+6);    
    3.26 +    prog->chansign = gmyth_string_list_get_string (slist, pos+7);    
    3.27 +    prog->pathname = gmyth_string_list_get_string (slist, pos+8);
    3.28 +    
    3.29 +    prog->filesize = gmyth_string_list_get_int64 (slist, pos+9);
    3.30 +    
    3.31 +    gmyth_debug( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", 
    3.32 +                gmyth_program_info_non_null_value( prog->title ), 
    3.33 +                gmyth_program_info_non_null_value( prog->subtitle ), 
    3.34 +                gmyth_program_info_non_null_value( prog->description ), 
    3.35 +                gmyth_program_info_non_null_value( prog->category ), 
    3.36 +                gmyth_program_info_non_null_value( prog->chanid ), 
    3.37 +                gmyth_program_info_non_null_value( prog->channame ), 
    3.38 +                gmyth_program_info_non_null_value( prog->chanstr ), 
    3.39 +                gmyth_program_info_non_null_value( prog->chansign ), 
    3.40 +                gmyth_program_info_non_null_value( prog->pathname ), 
    3.41 +                gmyth_string_list_get_int (slist, pos+11) );    
    3.42 +    
    3.43 +    prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.44 +                        (time_t)gmyth_string_list_get_int (slist, pos+11) ))->str ); //DATETIME_TO_LIST(startts)
    3.45 +    prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.46 +                        (time_t)gmyth_string_list_get_int (slist, pos+12) ))->str ); //DATETIME_TO_LIST(endts)
    3.47 +    prog->duplicate = gmyth_string_list_get_int (slist, pos+13);
    3.48 +    prog->shareable = gmyth_string_list_get_int (slist, pos+14);
    3.49 +    prog->findid = gmyth_string_list_get_int (slist, pos+15);
    3.50 +    prog->hostname = gmyth_string_list_get_string (slist, pos+16);
    3.51 +    prog->sourceid = gmyth_string_list_get_int (slist, pos+17);
    3.52 +    prog->cardid = gmyth_string_list_get_int (slist, pos+18);
    3.53 +    prog->inputid = gmyth_string_list_get_int (slist, pos+19);
    3.54 +    prog->recpriority = gmyth_string_list_get_int (slist, pos+20);
    3.55 +    prog->reactivate = gmyth_string_list_get_int (slist, pos+21);
    3.56 +    prog->recordid = gmyth_string_list_get_int (slist, pos+22);
    3.57 +    gmyth_string_list_get_int (slist, pos+23);
    3.58 +    gmyth_string_list_get_int (slist, pos+24);
    3.59 +    gmyth_string_list_get_int (slist, pos+25);
    3.60 +    prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.61 +                        (time_t)gmyth_string_list_get_int (slist, pos+26) ))->str ); //DATETIME_TO_LIST(recstartts)
    3.62 +    prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.63 +                        (time_t)gmyth_string_list_get_int (slist, pos+27) ))->str ); //DATETIME_TO_LIST(recendts)
    3.64 +    prog->repeat = gmyth_string_list_get_int (slist, pos+28);
    3.65 +    prog->programflags = gmyth_string_list_get_int (slist, pos+29);
    3.66 +    prog->recgroup = gmyth_string_list_get_string (slist, pos+30); //prog->(recgroup != "") ? recgroup : "Default")
    3.67 +    prog->chancommfree = gmyth_string_list_get_int (slist, pos+31);
    3.68 +    prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos+32);
    3.69 +    prog->seriesid = gmyth_string_list_get_string (slist, pos+33);
    3.70 +    prog->programid = gmyth_string_list_get_string (slist, pos+34);
    3.71 +    gmyth_string_list_get_string (slist, pos+35);
    3.72 +    prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.73 +                        (time_t)gmyth_string_list_get_int (slist, pos+36) ))->str ); //DATETIME_TO_LIST(lastmodified)
    3.74 +    gmyth_string_list_get_int (slist, pos+37); //FLOAT_TO_LIST(stars)
    3.75 +    prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
    3.76 +                        (time_t)gmyth_string_list_get_int (slist, pos+38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
    3.77 +    prog->hasAirDate = gmyth_string_list_get_int (slist, pos+39);
    3.78 +    prog->playgroup = gmyth_string_list_get_string (slist, pos+40); //prog->(playgroup != "") ? playgroup : "Default")
    3.79 +    prog->recpriority2 = gmyth_string_list_get_int (slist, pos+41);
    3.80 +   
    3.81 +    return prog;
    3.82 +}
    3.83 +
    3.84 +/**
    3.85 + * Converts an instance of a GMythStringList, to a GMythProgramInfo.
    3.86 + * 
    3.87 + * @param slist The GMythStringList got from the MythTV backend server.
    3.88   * 
    3.89   * @return a GMythProgramInfo representing the string list got from network.
    3.90   */
    3.91  GMythProgramInfo*
    3.92  gmyth_program_info_from_string_list ( GMythStringList *slist )
    3.93  {
    3.94 +    GMythProgramInfo *prog = NULL;
    3.95 +
    3.96 +    g_return_val_if_fail (slist != NULL, NULL);
    3.97 +    
    3.98 +    prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 );
    3.99 +   
   3.100 +    return prog;
   3.101 +}
   3.102 +
   3.103 +/**
   3.104 + * Converts an instance of a GMythStringList, to a GMythProgramInfo ( NEXT_PROGRAM_INFO ).
   3.105 + * 
   3.106 + * @param slist The GMythStringList got from the MythTV backend server.
   3.107 + * 
   3.108 + * @return a GMythProgramInfo representing the string list got from network.
   3.109 + */
   3.110 +GMythProgramInfo*
   3.111 +gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist )
   3.112 +{
   3.113      GMythProgramInfo *prog = gmyth_program_info_new();
   3.114  
   3.115      g_return_val_if_fail (slist != NULL, NULL);
   3.116 +    
   3.117 +    /*    
   3.118 +    {Home Improvement[]:[]No, No, Godot[]:[]
   3.119 +     US sitcom about a DIY-obsessed father of three. When 
   3.120 +     Tim tries to sell off his extra ticket for an ice hockey game, he is arrested as a tout.[]:[]
   3.121 +     Sitcom[]:[]2007-04-18T15:30:00[]:[]2007-04-18T16:00:00[]:[]ABC1[]:[]
   3.122 +     /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] }
   3.123 +    */
   3.124  
   3.125      prog->title = gmyth_string_list_get_string (slist, 0);
   3.126      prog->subtitle = gmyth_string_list_get_string (slist, 1);
   3.127      prog->description = gmyth_string_list_get_string (slist, 2);
   3.128      prog->category = gmyth_string_list_get_string (slist, 3);
   3.129 -    prog->chanid = gmyth_string_list_get_string (slist, 4);
   3.130 -    prog->channame = gmyth_string_list_get_string (slist, 5);
   3.131 -    prog->chanstr = gmyth_string_list_get_string (slist, 6);    
   3.132 -    prog->chansign = gmyth_string_list_get_string (slist, 7);    
   3.133 -    prog->pathname = gmyth_string_list_get_string (slist, 8);
   3.134 +    prog->startts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 4) ); //DATETIME_TO_LIST(startts)
   3.135 +    prog->endts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 5) ); //DATETIME_TO_LIST(endts)
   3.136 +    prog->channame = gmyth_string_list_get_string (slist, 6);
   3.137 +    prog->chansign = gmyth_string_list_get_string (slist, 7);
   3.138 +    prog->chanstr = gmyth_string_list_get_string (slist, 8);    
   3.139 +    prog->chanid = gmyth_string_list_get_string (slist, 9);
   3.140 +    prog->filesize = gmyth_string_list_get_int64 (slist, 10);
   3.141 +        
   3.142 +    gmyth_debug( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n", 
   3.143 +                gmyth_program_info_non_null_value( prog->title ), 
   3.144 +                gmyth_program_info_non_null_value( prog->subtitle ), 
   3.145 +                gmyth_program_info_non_null_value( prog->description ), 
   3.146 +                gmyth_program_info_non_null_value( prog->category ), 
   3.147 +                gmyth_program_info_non_null_value( prog->chanid ), 
   3.148 +                gmyth_program_info_non_null_value( prog->channame ), 
   3.149 +                gmyth_program_info_non_null_value( prog->chanstr ), 
   3.150 +                gmyth_program_info_non_null_value( prog->chansign ), 
   3.151 +                gmyth_program_info_non_null_value( prog->pathname ) );    
   3.152      
   3.153 -    prog->filesize = gmyth_string_list_get_int64 (slist, 9);
   3.154 -    
   3.155 -    gmyth_debug( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", 
   3.156 -    			gmyth_program_info_non_null_value( prog->title ), 
   3.157 -    			gmyth_program_info_non_null_value( prog->subtitle ), 
   3.158 -    			gmyth_program_info_non_null_value( prog->description ), 
   3.159 -    			gmyth_program_info_non_null_value( prog->category ), 
   3.160 -    			gmyth_program_info_non_null_value( prog->chanid ), 
   3.161 -    			gmyth_program_info_non_null_value( prog->channame ), 
   3.162 -    			gmyth_program_info_non_null_value( prog->chanstr ), 
   3.163 -    			gmyth_program_info_non_null_value( prog->chansign ), 
   3.164 -    			gmyth_program_info_non_null_value( prog->pathname ), 
   3.165 -    			gmyth_string_list_get_int (slist, 11) );    
   3.166 -    
   3.167 -    prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.168 -    					(time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts)
   3.169 -    prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.170 -    					(time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts)
   3.171 -    prog->duplicate = gmyth_string_list_get_int (slist, 13);
   3.172 -    prog->shareable = gmyth_string_list_get_int (slist, 14);
   3.173 -    prog->findid = gmyth_string_list_get_int (slist, 15);
   3.174 -    prog->hostname = gmyth_string_list_get_string (slist, 16);
   3.175 -    prog->sourceid = gmyth_string_list_get_int (slist, 17);
   3.176 -    prog->cardid = gmyth_string_list_get_int (slist, 18);
   3.177 -    prog->inputid = gmyth_string_list_get_int (slist, 19);
   3.178 -    prog->recpriority = gmyth_string_list_get_int (slist, 20);
   3.179 -    prog->reactivate = gmyth_string_list_get_int (slist, 21);
   3.180 -    prog->recordid = gmyth_string_list_get_int (slist, 22);
   3.181 -    gmyth_string_list_get_int (slist, 23);
   3.182 -    gmyth_string_list_get_int (slist, 24);
   3.183 -    gmyth_string_list_get_int (slist, 25);
   3.184 -    prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.185 -    					(time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts)
   3.186 -    prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.187 -    					(time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts)
   3.188 -    prog->repeat = gmyth_string_list_get_int (slist, 28);
   3.189 -    prog->programflags = gmyth_string_list_get_int (slist, 29);
   3.190 -    prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default")
   3.191 -    prog->chancommfree = gmyth_string_list_get_int (slist, 31);
   3.192 -    prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32);
   3.193 -    prog->seriesid = gmyth_string_list_get_string (slist, 33);
   3.194 -    prog->programid = gmyth_string_list_get_string (slist, 34);
   3.195 -    gmyth_string_list_get_string (slist, 35);
   3.196 -    prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.197 -    					(time_t)gmyth_string_list_get_int (slist, 36) ))->str ); //DATETIME_TO_LIST(lastmodified)
   3.198 -    gmyth_string_list_get_int (slist, 37); //FLOAT_TO_LIST(stars)
   3.199 -    prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.200 -    					(time_t)gmyth_string_list_get_int (slist, 38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
   3.201 -    prog->hasAirDate = gmyth_string_list_get_int (slist, 39);
   3.202 -    prog->playgroup = gmyth_string_list_get_string (slist, 40); //prog->(playgroup != "") ? playgroup : "Default")
   3.203 -    prog->recpriority2 = gmyth_string_list_get_int (slist, 41);
   3.204 -   
   3.205      return prog;
   3.206  }
   3.207  
     4.1 --- a/gmyth/src/gmyth_programinfo.h	Wed Apr 18 22:01:21 2007 +0100
     4.2 +++ b/gmyth/src/gmyth_programinfo.h	Wed Apr 18 23:13:26 2007 +0100
     4.3 @@ -155,8 +155,13 @@
     4.4  
     4.5  GMythStringList*	gmyth_program_info_to_string_list (GMythProgramInfo *prog, 
     4.6                                                         GMythStringList *slist);
     4.7 +
     4.8 +GMythProgramInfo*   gmyth_program_info_from_string_list_from_pos (GMythStringList *slist, guint pos);
     4.9 +
    4.10  GMythProgramInfo* 	gmyth_program_info_from_string_list (GMythStringList *slist);
    4.11  
    4.12 +GMythProgramInfo*   gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist );
    4.13 +
    4.14  const gchar*		gmyth_program_info_to_string( const GMythProgramInfo* prog );
    4.15  
    4.16  gboolean            gmyth_program_info_is_equals( const GMythProgramInfo* prog1, 
     5.1 --- a/gmyth/src/gmyth_recorder.c	Wed Apr 18 22:01:21 2007 +0100
     5.2 +++ b/gmyth/src/gmyth_recorder.c	Wed Apr 18 23:13:26 2007 +0100
     5.3 @@ -828,6 +828,9 @@
     5.4   * Requests the actual program info from the MythTV backend server.
     5.5   * 
     5.6   * @param recorder The GMythRecorder instance.
     5.7 + * @param direction The direction to move based on the current channel (forward, backward,
     5.8 + *            up, down).
     5.9 + * 
    5.10   * @return The GMythProgramInfo next program info instance.
    5.11   */
    5.12  GMythProgramInfo *
    5.13 @@ -838,8 +841,8 @@
    5.14      GMythStringList *str_list;
    5.15      GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
    5.16  
    5.17 -    gchar *date=  NULL;
    5.18 -    struct tm *tm;
    5.19 +    gchar *date =  NULL;
    5.20 +    struct tm *tm = NULL;
    5.21      time_t t;
    5.22  
    5.23      actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
    5.24 @@ -870,7 +873,7 @@
    5.25                      __FUNCTION__);
    5.26              goto done;
    5.27          }
    5.28 -        program_info = gmyth_program_info_new();
    5.29 +        program_info = gmyth_program_info_from_string_list_next_prog(str_list);
    5.30  
    5.31          if ( NULL == program_info) {
    5.32              gmyth_debug(
    5.33 @@ -880,27 +883,9 @@
    5.34              goto done;
    5.35          }
    5.36  
    5.37 -        program_info->title = gmyth_string_list_get_string(str_list, 0);
    5.38 -        program_info->subtitle = gmyth_string_list_get_string(str_list, 1);
    5.39 -        program_info->description = gmyth_string_list_get_string(str_list, 2);
    5.40 -        program_info->category = gmyth_string_list_get_string(str_list, 3);
    5.41 -        program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
    5.42 -                        (time_t)gmyth_string_list_get_int (str_list, 4) ))->str);
    5.43 -        program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
    5.44 -                        (time_t)gmyth_string_list_get_int (str_list, 6) ))->str);
    5.45 -
    5.46 -        program_info->chansign = gmyth_string_list_get_string(str_list, 8);
    5.47 -        program_info->pathname = gmyth_string_list_get_string(str_list, 9);
    5.48 -        program_info->channame = gmyth_string_list_get_string(str_list, 10);
    5.49 -        program_info->chanid = gmyth_string_list_get_string(str_list, 11);
    5.50 -        if ( recorder->myth_socket->mythtv_version >= 12) {
    5.51 -            program_info->seriesid = gmyth_string_list_get_string(str_list, 12);
    5.52 -            program_info->programid = gmyth_string_list_get_string(str_list, 13);
    5.53 -        }
    5.54 -
    5.55          if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
    5.56 -        ( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 )) {
    5.57 -            gmyth_debug( "OK!!! Got the next program info..." );
    5.58 +        ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) {
    5.59 +            gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str );
    5.60          } else {
    5.61              gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" );
    5.62              g_object_unref(program_info);
    5.63 @@ -913,13 +898,110 @@
    5.64      
    5.65      g_mutex_unlock( recorder->mutex );
    5.66      
    5.67 -    g_object_unref(actual_proginfo);
    5.68 -    g_object_unref(str_list);
    5.69 +    if ( actual_proginfo != NULL )
    5.70 +        g_object_unref(actual_proginfo);
    5.71 +    
    5.72 +    if ( str_list != NULL )
    5.73 +        g_object_unref(str_list);
    5.74 +    
    5.75 +    if ( tmp_str != NULL )
    5.76 +        g_string_free(tmp_str, TRUE);
    5.77  
    5.78 -    g_string_free(tmp_str, TRUE);
    5.79 +    if ( date != NULL )
    5.80 +        g_free(date);
    5.81 +    //if ( tm != NULL)
    5.82 +    //    g_free (tm);
    5.83  
    5.84 -    g_free(date);
    5.85 -    g_free (tm);
    5.86 +    return program_info;
    5.87 +}
    5.88 +
    5.89 +/**
    5.90 + * Requests the program info from the MythTV backend server, based on its 
    5.91 + * channel name.
    5.92 + * 
    5.93 + * @param recorder The GMythRecorder instance.
    5.94 + * @return The GMythProgramInfo next program info instance.
    5.95 + */
    5.96 +GMythProgramInfo *
    5.97 +gmyth_recorder_get_program_info_from_channel_name( GMythRecorder *recorder, 
    5.98 +        const gchar* channel ) {
    5.99 +    //GMythProgramInfo* actual_proginfo=  NULL;
   5.100 +    GMythProgramInfo* program_info=  NULL;
   5.101 +    GMythStringList *str_list;
   5.102 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   5.103 +    
   5.104 +    /*
   5.105 +    gchar *date =  NULL;
   5.106 +    struct tm *tm = NULL;
   5.107 +    time_t t;
   5.108 +    
   5.109 +    actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
   5.110 +    */
   5.111 +    
   5.112 +    str_list = gmyth_string_list_new();    
   5.113 +    
   5.114 +    g_mutex_lock( recorder->mutex );
   5.115 +
   5.116 +    g_string_append_printf( tmp_str, " %d", recorder->recorder_num );
   5.117 +
   5.118 +    /*
   5.119 +    t = time(NULL);
   5.120 +    tm = localtime(&t);
   5.121 +    date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
   5.122 +            tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
   5.123 +    */
   5.124 +
   5.125 +    gmyth_string_list_append_string(str_list, tmp_str);
   5.126 +    gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO");
   5.127 +    gmyth_string_list_append_char_array(str_list, channel);
   5.128 +    gmyth_string_list_append_char_array(str_list, "0");
   5.129 +    gmyth_string_list_append_int(str_list, BROWSE_DIRECTION_UP);
   5.130 +    gmyth_string_list_append_char_array(str_list, "0");
   5.131 +    
   5.132 +    do {
   5.133 +
   5.134 +      if ( str_list != NULL && 
   5.135 +              gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list) > 0 ) {
   5.136 +  
   5.137 +          if (str_list == NULL) {
   5.138 +              gmyth_debug(
   5.139 +                      "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
   5.140 +                      __FUNCTION__);
   5.141 +              goto done;
   5.142 +          }
   5.143 +          program_info = gmyth_program_info_from_string_list_next_prog(str_list);
   5.144 +  
   5.145 +          if ( NULL == program_info) {
   5.146 +              gmyth_debug(
   5.147 +                      "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
   5.148 +                      __FUNCTION__);
   5.149 +              g_object_unref(program_info);
   5.150 +              goto done;
   5.151 +          }
   5.152 +  
   5.153 +          if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
   5.154 +          ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) {
   5.155 +              gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str );
   5.156 +          } else {
   5.157 +              gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting "
   5.158 +                      "next program info, it is equals to NULL!!!" );
   5.159 +              g_object_unref(program_info);
   5.160 +              program_info = NULL;
   5.161 +          }
   5.162 +  
   5.163 +      } /* if */
   5.164 +    
   5.165 +    } while ( str_list != NULL );
   5.166 +
   5.167 +done:
   5.168 +    
   5.169 +    g_mutex_unlock( recorder->mutex );
   5.170 +    
   5.171 +    if ( str_list != NULL )
   5.172 +        g_object_unref(str_list);
   5.173 +    
   5.174 +    if ( tmp_str != NULL )
   5.175 +        g_string_free(tmp_str, TRUE);
   5.176  
   5.177      return program_info;
   5.178  }
     6.1 --- a/gmyth/src/gmyth_util.c	Wed Apr 18 22:01:21 2007 +0100
     6.2 +++ b/gmyth/src/gmyth_util.c	Wed Apr 18 23:13:26 2007 +0100
     6.3 @@ -597,6 +597,104 @@
     6.4      return channel_list;
     6.5  }
     6.6  
     6.7 +/** 
     6.8 + * Gets all the recordings from remote encoder.
     6.9 + * 
    6.10 + * @param backend_info The GMythBackendInfo instance.
    6.11 + * 
    6.12 + * @return The program info's listage.
    6.13 + */
    6.14 +GSList *
    6.15 +gmyth_util_get_all_recordings (GMythBackendInfo *backend_info)
    6.16 +{
    6.17 +    GSList *program_list = NULL;
    6.18 +    GMythSocket *socket;
    6.19 +    gboolean res;    
    6.20 +    
    6.21 +    socket = gmyth_socket_new ();
    6.22 +    res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
    6.23 +            backend_info->port, TRUE);
    6.24 +
    6.25 +    if (res == TRUE) {
    6.26 +        GMythStringList *slist = gmyth_string_list_new ();
    6.27 +        guint pos = 0;
    6.28 +        gmyth_string_list_append_char_array (slist, "QUERY_RECORDINGS Play");
    6.29 +
    6.30 +        gmyth_socket_sendreceive_stringlist (socket, slist);
    6.31 +
    6.32 +        if ( slist != NULL && ( gmyth_string_list_length( slist ) > 0 ) )            
    6.33 +        {
    6.34 +            GMythProgramInfo *program = NULL;
    6.35 +            
    6.36 +            gmyth_debug( "OK! Got the program list [size=%d].", gmyth_string_list_length( slist ) );
    6.37 +            
    6.38 +            do
    6.39 +            {                
    6.40 +                program = gmyth_program_info_from_string_list_from_pos( slist, pos );
    6.41 +                
    6.42 +                if ( program != NULL )
    6.43 +                {   
    6.44 +                    pos += 41;
    6.45 +                    
    6.46 +                    program_list = g_slist_append( program_list, program );
    6.47 +                } else
    6.48 +                    break;
    6.49 +                
    6.50 +            } while ( gmyth_string_list_length( slist ) > pos );
    6.51 +            
    6.52 +        } /* if */
    6.53 +    
    6.54 +        g_object_unref (slist);
    6.55 +
    6.56 +        gmyth_socket_close_connection (socket);
    6.57 +    }
    6.58 +    g_object_unref (socket);
    6.59 +    
    6.60 +    return program_list;    
    6.61 +}
    6.62 +
    6.63 +/** 
    6.64 + * Checks if the given remote file exists, and gets its remote directory.
    6.65 + * 
    6.66 + * @param backend_info The GMythBackendInfo instance.
    6.67 + * @param channel The channel name of the program info.
    6.68 + * 
    6.69 + * @return The requested program info.
    6.70 + */
    6.71 +GMythProgramInfo *
    6.72 +gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, const gchar *channel)
    6.73 +{
    6.74 +    GSList *program_list = NULL;
    6.75 +    GMythProgramInfo *program = NULL;
    6.76 +    
    6.77 +    program_list = gmyth_util_get_all_recordings( backend_info );
    6.78 +
    6.79 +    if ( program_list != NULL && g_slist_length(program_list) >0 )            
    6.80 +    {
    6.81 +        GMythProgramInfo *program = NULL;
    6.82 +        guint pos = 0;
    6.83 +        
    6.84 +        gmyth_debug( "OK! Got the program list [size=%d].", g_slist_length( program_list ) );
    6.85 +        
    6.86 +        while ( pos < g_slist_length( program_list ) ) 
    6.87 +        {         
    6.88 +            program = (GMythProgramInfo*)g_slist_nth_data( program_list, pos );
    6.89 +            
    6.90 +            if ( program != NULL && program->channame!= NULL && 
    6.91 +                    g_ascii_strncasecmp( program->channame->str, channel, strlen(channel) ) == 0 )
    6.92 +            {   
    6.93 +                break;
    6.94 +            }
    6.95 +            
    6.96 +            ++pos;
    6.97 +            
    6.98 +        } /* while */
    6.99 +        
   6.100 +    } /* if */
   6.101 +    
   6.102 +    return program;    
   6.103 +}
   6.104 +
   6.105  #if !GLIB_CHECK_VERSION (2, 10, 0)
   6.106  
   6.107  /* Hacked from glib 2.10 <gtime.c> */
     7.1 --- a/gmyth/src/gmyth_util.h	Wed Apr 18 22:01:21 2007 +0100
     7.2 +++ b/gmyth/src/gmyth_util.h	Wed Apr 18 23:13:26 2007 +0100
     7.3 @@ -35,6 +35,7 @@
     7.4  
     7.5  #include "gmyth_stringlist.h"
     7.6  #include "gmyth_backendinfo.h"
     7.7 +#include "gmyth_programinfo.h"
     7.8  
     7.9  G_BEGIN_DECLS
    7.10  
    7.11 @@ -70,6 +71,11 @@
    7.12  
    7.13  GList *         gmyth_util_get_channel_list (GMythBackendInfo *backend_info);
    7.14  
    7.15 +GSList *        gmyth_util_get_all_recordings (GMythBackendInfo *backend_info);
    7.16 +
    7.17 +GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, 
    7.18 +                        const gchar *channel);
    7.19 +
    7.20  G_END_DECLS
    7.21  	
    7.22  #endif /*GMYTH_UTIL_H_*/