gmyth/src/gmyth_programinfo.c
author rosfran
Wed May 23 19:50:41 2007 +0100 (2007-05-23)
branchtrunk
changeset 701 2f28edb4d804
parent 698 9019388af980
child 750 312d6bc514f3
permissions -rw-r--r--
[svn r707] Fixed the wrong commentary indentation.
     1 /**
     2  * GMyth Library
     3  *
     4  * @file gmyth/gmyth_programinfo.c
     5  * 
     6  * @brief <p> GMythProgramInfo representing the program info, with the
     7  * configuration data to the actual remote file in the TV chain.
     8  *
     9  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    10  * @author Rosfran Borges <rosfran.borges@indt.org.br>
    11  * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    12  *
    13  * 
    14  * This program is free software; you can redistribute it and/or modify
    15  * it under the terms of the GNU Lesser General Public License as published by
    16  * the Free Software Foundation; either version 2 of the License, or
    17  * (at your option) any later version.
    18  *
    19  * This program is distributed in the hope that it will be useful,
    20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22  * GNU General Public License for more details.
    23  *
    24  * You should have received a copy of the GNU Lesser General Public License
    25  * along with this program; if not, write to the Free Software
    26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    27  *
    28  */
    29 
    30 #ifdef HAVE_CONFIG_H
    31 #include "config.h"
    32 #endif
    33 
    34 #include <stdlib.h>
    35 #include <string.h>
    36 #include <assert.h>
    37 
    38 #include "gmyth_programinfo.h"
    39 #include "gmyth_util.h"
    40 #include "gmyth_debug.h"
    41 
    42 static void gmyth_program_info_class_init ( GMythProgramInfoClass * klass );
    43 static void gmyth_program_info_init ( GMythProgramInfo * object );
    44 
    45 static void gmyth_program_info_dispose ( GObject * object );
    46 static void gmyth_program_info_finalize ( GObject * object );
    47 
    48 G_DEFINE_TYPE ( GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT )
    49      static const gchar *gmyth_program_info_non_null_value ( const GString *
    50                                                              str );
    51 
    52      static void gmyth_program_info_class_init ( GMythProgramInfoClass * klass )
    53 {
    54     GObjectClass *gobject_class = G_OBJECT_CLASS ( klass );
    55 
    56     gobject_class->dispose = gmyth_program_info_dispose;
    57     gobject_class->finalize = gmyth_program_info_finalize;
    58 }
    59 
    60 static void
    61 gmyth_program_info_init ( GMythProgramInfo * gmyth_program_info )
    62 {
    63     gmyth_program_info->chancommfree = 0;
    64 
    65     /** A flag informing if the program has video or not. */
    66     gmyth_program_info->isVideo = FALSE;
    67     gmyth_program_info->lenMins = 0;
    68 
    69     gmyth_program_info->stars = 0.0f;
    70     gmyth_program_info->repeat = 0;
    71 
    72     gmyth_program_info->hasAirDate = FALSE;
    73 
    74     gmyth_program_info->spread = 0;
    75     gmyth_program_info->startCol = 0;
    76 
    77     gmyth_program_info->recpriority2 = 0;
    78     gmyth_program_info->reactivate = 0;
    79 
    80     gmyth_program_info->recordid = 0;
    81     gmyth_program_info->parentid = 0;
    82 
    83     /** The backend video source id associated to this program.*/
    84     gmyth_program_info->sourceid = 0;
    85     /** the backend input id associated to this program.*/
    86     gmyth_program_info->inputid = 0;
    87     /** The backend card id associated to this program.*/
    88     gmyth_program_info->cardid = 0;
    89     gmyth_program_info->shareable = FALSE;
    90     gmyth_program_info->duplicate = FALSE;
    91 
    92     gmyth_program_info->findid = 0;
    93 
    94     gmyth_program_info->programflags = 0;
    95     gmyth_program_info->transcoder = 0;
    96 
    97     gmyth_program_info->recpriority = 0;
    98 
    99     /** The file size of the recorded program.*/
   100     gmyth_program_info->filesize = -1;
   101 }
   102 
   103 static void
   104 gmyth_program_info_dispose ( GObject * object )
   105 {
   106     GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO ( object );
   107 
   108     if ( gmyth_program_info->chanid != NULL )
   109     {
   110         g_string_free ( gmyth_program_info->chanid, TRUE );
   111         gmyth_program_info->chanid = NULL;
   112     }
   113 
   114     /** The program start time. */
   115     g_free ( gmyth_program_info->startts );
   116 
   117     /** The program end time. */
   118     g_free ( gmyth_program_info->endts );
   119 
   120     /** The recording schedule start time. */
   121     g_free ( gmyth_program_info->recstartts );
   122 
   123     /** The recording schedule end time */
   124     g_free ( gmyth_program_info->recendts );
   125 
   126     /** The program title. */
   127     if ( gmyth_program_info->title != NULL )
   128     {
   129         g_string_free ( gmyth_program_info->title, TRUE );
   130         gmyth_program_info->title = NULL;
   131     }
   132 
   133     /** The program subtitle. */
   134     if ( gmyth_program_info->subtitle != NULL )
   135     {
   136         g_string_free ( gmyth_program_info->subtitle, TRUE );
   137         gmyth_program_info->subtitle = NULL;
   138     }
   139 
   140     /** The program description. */
   141     if ( gmyth_program_info->description != NULL )
   142     {
   143         g_string_free ( gmyth_program_info->description, TRUE );
   144         gmyth_program_info->description = NULL;
   145     }
   146 
   147     /** The program category. */
   148     if ( gmyth_program_info->category != NULL )
   149     {
   150         g_string_free ( gmyth_program_info->category, TRUE );
   151         gmyth_program_info->category = NULL;
   152     }
   153 
   154     if ( gmyth_program_info->chanstr != NULL )
   155     {
   156         g_string_free ( gmyth_program_info->chanstr, TRUE );
   157         gmyth_program_info->chanstr = NULL;
   158     }
   159 
   160     if ( gmyth_program_info->chansign != NULL )
   161     {
   162         g_string_free ( gmyth_program_info->chansign, TRUE );
   163         gmyth_program_info->chansign = NULL;
   164     }
   165 
   166     /** The associated channel name. */
   167     if ( gmyth_program_info->channame != NULL )
   168     {
   169         g_string_free ( gmyth_program_info->channame, TRUE );
   170         gmyth_program_info->channame = NULL;
   171     }
   172 
   173     if ( gmyth_program_info->chanOutputFilters != NULL )
   174     {
   175         g_string_free ( gmyth_program_info->chanOutputFilters, TRUE );
   176         gmyth_program_info->chanOutputFilters = NULL;
   177     }
   178 
   179     if ( gmyth_program_info->seriesid != NULL )
   180     {
   181         g_string_free ( gmyth_program_info->seriesid, TRUE );
   182         gmyth_program_info->chanOutputFilters = NULL;
   183     }
   184 
   185     /** The program unique id. */
   186     if ( gmyth_program_info->programid != NULL )
   187     {
   188         g_string_free ( gmyth_program_info->programid, TRUE );
   189         gmyth_program_info->programid = NULL;
   190     }
   191 
   192     if ( gmyth_program_info->catType != NULL )
   193     {
   194         g_string_free ( gmyth_program_info->catType, TRUE );
   195         gmyth_program_info->catType = NULL;
   196     }
   197 
   198     if ( gmyth_program_info->sortTitle != NULL )
   199     {
   200         g_string_free ( gmyth_program_info->sortTitle, TRUE );
   201         gmyth_program_info->sortTitle = NULL;
   202     }
   203 
   204     if ( gmyth_program_info->year != NULL )
   205     {
   206         g_string_free ( gmyth_program_info->year, TRUE );
   207         gmyth_program_info->year = NULL;
   208     }
   209 
   210     g_free ( gmyth_program_info->originalAirDate );
   211 
   212     g_free ( gmyth_program_info->lastmodified );
   213 
   214     g_free ( gmyth_program_info->lastInUseTime );
   215 
   216     if ( gmyth_program_info->schedulerid != NULL )
   217     {
   218         g_string_free ( gmyth_program_info->schedulerid, TRUE );
   219         gmyth_program_info->schedulerid = NULL;
   220     }
   221 
   222     if ( gmyth_program_info->recgroup != NULL )
   223     {
   224         g_string_free ( gmyth_program_info->recgroup, TRUE );
   225         gmyth_program_info->recgroup = NULL;
   226     }
   227 
   228     if ( gmyth_program_info->playgroup != NULL )
   229     {
   230         g_string_free ( gmyth_program_info->playgroup, TRUE );
   231         gmyth_program_info->playgroup = NULL;
   232     }
   233 
   234     /** The file name of the recorded program.*/
   235     if ( gmyth_program_info->pathname != NULL )
   236     {
   237         g_string_free ( gmyth_program_info->pathname, TRUE );
   238         gmyth_program_info->pathname = NULL;
   239     }
   240 
   241     if ( gmyth_program_info->hostname != NULL )
   242     {
   243         g_string_free ( gmyth_program_info->hostname, TRUE );
   244         gmyth_program_info->hostname = NULL;
   245     }
   246 
   247     G_OBJECT_CLASS ( gmyth_program_info_parent_class )->dispose ( object );
   248 }
   249 
   250 static void
   251 gmyth_program_info_finalize ( GObject * object )
   252 {
   253     g_signal_handlers_destroy ( object );
   254 
   255     G_OBJECT_CLASS ( gmyth_program_info_parent_class )->finalize ( object );
   256 }
   257 
   258 /**
   259  * Creates a new instance of GMythProgramInfo.
   260  * 
   261  * @return a new instance of GMythProgramInfo.
   262  */
   263 GMythProgramInfo *
   264 gmyth_program_info_new ( void )
   265 {
   266     GMythProgramInfo *program_info =
   267         GMYTH_PROGRAM_INFO ( g_object_new ( GMYTH_PROGRAM_INFO_TYPE, NULL ) );
   268 
   269     return program_info;
   270 }
   271 
   272 /**
   273  * Converts an instance of a GMythProgramInfo, to a GMythStringList.
   274  * 
   275  * @param prog A GMythProgramInfo instance.
   276  * @param slist The GMythStringList to be passed to this function, in order to
   277  * 							give the responsibility of the string list creation to the
   278  * 						  API user.
   279  * 
   280  * @return a GMythStringList with the program info fields.
   281  */
   282 GMythStringList *
   283 gmyth_program_info_to_string_list ( GMythProgramInfo * prog,
   284                                     GMythStringList * slist )
   285 {
   286     g_return_val_if_fail ( prog != NULL, NULL );
   287     g_return_val_if_fail ( slist != NULL, NULL );
   288 
   289     gmyth_string_list_append_string ( slist, prog->title ); /* 0 */
   290     gmyth_string_list_append_string ( slist, prog->subtitle );  /* 1 */
   291     gmyth_string_list_append_string ( slist, prog->description );   /* 2 */
   292     gmyth_string_list_append_string ( slist, prog->category );  /* 3 */
   293     gmyth_string_list_append_string ( slist, prog->chanid );    /* 4 */
   294     gmyth_string_list_append_string ( slist, prog->chanstr );   /* 5 */
   295     gmyth_string_list_append_string ( slist, prog->chansign );  /* 6 */
   296     gmyth_string_list_append_string ( slist, prog->channame );  /* 7 */
   297     gmyth_string_list_append_string ( slist, prog->pathname );  /* 8 */
   298     gmyth_string_list_append_int64 ( slist, 0 );    /* 9 */
   299 
   300     // fixme
   301     //gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
   302     //gmyth_string_list_append_int (slist, 0); /* 10 */
   303 
   304     if ( prog->startts )
   305         gmyth_string_list_append_int ( slist, prog->startts->tv_sec );  /* 11 *///DATETIME_TO_LIST(startts)
   306     else
   307         gmyth_string_list_append_int ( slist, 0 );
   308 
   309     if ( prog->endts )
   310         gmyth_string_list_append_int ( slist, prog->endts->tv_sec );    /* 12 *///DATETIME_TO_LIST(endts)
   311     else
   312         gmyth_string_list_append_int ( slist, 0 );
   313 
   314     gmyth_string_list_append_int ( slist, prog->duplicate );    /* 13 */
   315     gmyth_string_list_append_int ( slist, prog->shareable );    /* 14 */
   316     gmyth_string_list_append_int ( slist, prog->findid );   /* 15 */
   317     gmyth_string_list_append_string ( slist, prog->hostname );  /* 16 */
   318     gmyth_string_list_append_int ( slist, prog->sourceid ); /* 17 */
   319     gmyth_string_list_append_int ( slist, prog->cardid );   /* 18 */
   320     gmyth_string_list_append_int ( slist, prog->inputid );  /* 19 */
   321     gmyth_string_list_append_int ( slist, prog->recpriority );  /* 20 */
   322     gmyth_string_list_append_int ( slist, 0 /*prog->recstatus */  );    /* 21 */
   323     gmyth_string_list_append_int ( slist, prog->recordid ); /* 22 */
   324     gmyth_string_list_append_int ( slist, 0 /*prog->rectype */  );  /* 23 */
   325     gmyth_string_list_append_int ( slist, 0 /*prog->dupin */  );    /* 24 */
   326     gmyth_string_list_append_int ( slist, 0 /*prog->dupmethod */  );    /* 25 */
   327     gmyth_string_list_append_int ( slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0 );    /* 26 *///DATETIME_TO_LIST(recstartts)
   328     gmyth_string_list_append_int ( slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0 );    /* 27 *///DATETIME_TO_LIST(recendts)
   329     gmyth_string_list_append_int ( slist, prog->repeat );   /* 28 */
   330     gmyth_string_list_append_int ( slist, prog->programflags ); /* 29 */
   331     gmyth_string_list_append_char_array ( slist, "Default" );   /* 30 *///prog->(recgroup != "") ? recgroup : "Default")
   332     gmyth_string_list_append_int ( slist, prog->chancommfree ); /* 31 */
   333     gmyth_string_list_append_string ( slist, prog->chanOutputFilters ); /* 32 */
   334     gmyth_string_list_append_string ( slist, prog->seriesid );  /* 33 */
   335     gmyth_string_list_append_string ( slist, prog->programid ); /* 34 */
   336     gmyth_string_list_append_char_array ( slist, "" );  /* 35 */
   337     gmyth_string_list_append_int ( slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0 );    /* 36 *///DATETIME_TO_LIST(lastmodified)
   338     gmyth_string_list_append_int ( slist, 0 );  /* 37 *///FLOAT_TO_LIST(stars)
   339     gmyth_string_list_append_int ( slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0 );  /* 38 *///DATETIME_TO_LIST(QDateTime(originalAirDate))
   340     gmyth_string_list_append_int ( slist, prog->hasAirDate );   /* 39 */
   341     gmyth_string_list_append_char_array ( slist, "Default" );   /* 40 *///prog->(playgroup != "") ? playgroup : "Default")
   342     gmyth_string_list_append_int ( slist, prog->recpriority2 ); /* 41 */
   343 
   344     return slist;
   345 }
   346 
   347 /**
   348  * Converts an instance of a GMythStringList, to a GMythProgramInfo.
   349  * 
   350  * @param slist The GMythStringList got from the MythTV backend server.
   351  * @param pos   The position in the GMythStringList to start getting the fields.
   352  * 
   353  * @return a GMythProgramInfo representing the string list got from network.
   354  */
   355 GMythProgramInfo *
   356 gmyth_program_info_from_string_list_from_pos ( GMythStringList * slist,
   357                                                guint pos )
   358 {
   359     GMythProgramInfo *prog = gmyth_program_info_new (  );
   360 
   361     g_return_val_if_fail ( slist != NULL &&
   362                            gmyth_string_list_get_string ( slist, pos ) != NULL,
   363                            NULL );
   364 
   365     prog->title = gmyth_string_list_get_string ( slist, pos );
   366     prog->subtitle = gmyth_string_list_get_string ( slist, pos + 1 );
   367     prog->description = gmyth_string_list_get_string ( slist, pos + 2 );
   368     prog->category = gmyth_string_list_get_string ( slist, pos + 3 );
   369     prog->chanid = gmyth_string_list_get_string ( slist, pos + 4 );
   370     prog->channame = gmyth_string_list_get_string ( slist, pos + 5 );
   371     prog->chanstr = gmyth_string_list_get_string ( slist, pos + 6 );
   372     prog->chansign = gmyth_string_list_get_string ( slist, pos + 7 );
   373     prog->pathname = gmyth_string_list_get_string ( slist, pos + 8 );
   374 
   375     prog->filesize = gmyth_string_list_get_int64 ( slist, pos + 9 );
   376 
   377     gmyth_debug ( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n",
   378                   gmyth_program_info_non_null_value ( prog->title ),
   379                   gmyth_program_info_non_null_value ( prog->subtitle ),
   380                   gmyth_program_info_non_null_value ( prog->description ),
   381                   gmyth_program_info_non_null_value ( prog->category ),
   382                   gmyth_program_info_non_null_value ( prog->chanid ),
   383                   gmyth_program_info_non_null_value ( prog->channame ),
   384                   gmyth_program_info_non_null_value ( prog->chanstr ),
   385                   gmyth_program_info_non_null_value ( prog->chansign ),
   386                   gmyth_program_info_non_null_value ( prog->pathname ),
   387                   gmyth_string_list_get_int ( slist, pos + 11 ) );
   388 
   389     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)
   390     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)
   391     prog->duplicate = gmyth_string_list_get_int ( slist, pos + 13 );
   392     prog->shareable = gmyth_string_list_get_int ( slist, pos + 14 );
   393     prog->findid = gmyth_string_list_get_int ( slist, pos + 15 );
   394     prog->hostname = gmyth_string_list_get_string ( slist, pos + 16 );
   395     prog->sourceid = gmyth_string_list_get_int ( slist, pos + 17 );
   396     prog->cardid = gmyth_string_list_get_int ( slist, pos + 18 );
   397     prog->inputid = gmyth_string_list_get_int ( slist, pos + 19 );
   398     prog->recpriority = gmyth_string_list_get_int ( slist, pos + 20 );
   399     prog->reactivate = gmyth_string_list_get_int ( slist, pos + 21 );
   400     prog->recordid = gmyth_string_list_get_int ( slist, pos + 22 );
   401     gmyth_string_list_get_int ( slist, pos + 23 );
   402     gmyth_string_list_get_int ( slist, pos + 24 );
   403     gmyth_string_list_get_int ( slist, pos + 25 );
   404     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)
   405     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)
   406     prog->repeat = gmyth_string_list_get_int ( slist, pos + 28 );
   407     prog->programflags = gmyth_string_list_get_int ( slist, pos + 29 );
   408     prog->recgroup = gmyth_string_list_get_string ( slist, pos + 30 );  //prog->(recgroup != "") ? recgroup : "Default")
   409     prog->chancommfree = gmyth_string_list_get_int ( slist, pos + 31 );
   410     prog->chanOutputFilters = gmyth_string_list_get_string ( slist, pos + 32 );
   411     prog->seriesid = gmyth_string_list_get_string ( slist, pos + 33 );
   412     prog->programid = gmyth_string_list_get_string ( slist, pos + 34 );
   413     gmyth_string_list_get_string ( slist, pos + 35 );
   414     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)
   415     gmyth_string_list_get_int ( slist, pos + 37 );  //FLOAT_TO_LIST(stars)
   416     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))
   417     prog->hasAirDate = gmyth_string_list_get_int ( slist, pos + 39 );
   418     prog->playgroup = gmyth_string_list_get_string ( slist, pos + 40 ); //prog->(playgroup != "") ? playgroup : "Default")
   419     prog->recpriority2 = gmyth_string_list_get_int ( slist, pos + 41 );
   420 
   421     return prog;
   422 }
   423 
   424 /**
   425  * Converts an instance of a GMythStringList, to a GMythProgramInfo.
   426  * 
   427  * @param slist The GMythStringList got from the MythTV backend server.
   428  * 
   429  * @return a GMythProgramInfo representing the string list got from network.
   430  */
   431 GMythProgramInfo *
   432 gmyth_program_info_from_string_list ( GMythStringList * slist )
   433 {
   434     GMythProgramInfo *prog = NULL;
   435 
   436     g_return_val_if_fail ( slist != NULL, NULL );
   437 
   438     prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 );
   439 
   440     return prog;
   441 }
   442 
   443 /**
   444  * Converts an instance of a GMythStringList, to a GMythProgramInfo ( NEXT_PROGRAM_INFO ).
   445  * 
   446  * @param slist The GMythStringList got from the MythTV backend server.
   447  * 
   448  * @return a GMythProgramInfo representing the string list got from network.
   449  */
   450 GMythProgramInfo *
   451 gmyth_program_info_from_string_list_next_prog ( GMythStringList * slist )
   452 {
   453     GMythProgramInfo *prog = gmyth_program_info_new (  );
   454 
   455     g_return_val_if_fail ( slist != NULL, NULL );
   456 
   457     /*    
   458        {Home Improvement[]:[]No, No, Godot[]:[]
   459        US sitcom about a DIY-obsessed father of three. When 
   460        Tim tries to sell off his extra ticket for an ice hockey game, he is arrested as a tout.[]:[]
   461        Sitcom[]:[]2007-04-18T15:30:00[]:[]2007-04-18T16:00:00[]:[]ABC1[]:[]
   462        /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] }
   463      */
   464 
   465     prog->title = gmyth_string_list_get_string ( slist, 0 );
   466     prog->subtitle = gmyth_string_list_get_string ( slist, 1 );
   467     prog->description = gmyth_string_list_get_string ( slist, 2 );
   468     prog->category = gmyth_string_list_get_string ( slist, 3 );
   469     prog->startts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 4 ) );    //DATETIME_TO_LIST(startts)
   470     prog->endts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 5 ) );  //DATETIME_TO_LIST(endts)
   471     prog->channame = gmyth_string_list_get_string ( slist, 6 );
   472     prog->chansign = gmyth_string_list_get_string ( slist, 7 );
   473     prog->chanstr = gmyth_string_list_get_string ( slist, 8 );
   474     prog->chanid = gmyth_string_list_get_string ( slist, 9 );
   475     prog->filesize = gmyth_string_list_get_int64 ( slist, 10 );
   476 
   477     gmyth_debug ( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n",
   478                   gmyth_program_info_non_null_value ( prog->title ),
   479                   gmyth_program_info_non_null_value ( prog->subtitle ),
   480                   gmyth_program_info_non_null_value ( prog->description ),
   481                   gmyth_program_info_non_null_value ( prog->category ),
   482                   gmyth_program_info_non_null_value ( prog->chanid ),
   483                   gmyth_program_info_non_null_value ( prog->channame ),
   484                   gmyth_program_info_non_null_value ( prog->chanstr ),
   485                   gmyth_program_info_non_null_value ( prog->chansign ),
   486                   gmyth_program_info_non_null_value ( prog->pathname ) );
   487 
   488     return prog;
   489 }
   490 
   491 static const gchar *
   492 gmyth_program_info_non_null_value ( const GString * str )
   493 {
   494     return ( str != NULL && str->str != NULL
   495              && strlen ( str->str ) > 0 ? str->str : " " );
   496 }
   497 
   498 /**
   499  * Prints out an instance of a GMythProgramInfo.
   500  * 
   501  * @param prog A GMythProgramInfo instance.
   502  * 
   503  * @return a string representing the program info.
   504  */
   505 const gchar *
   506 gmyth_program_info_to_string ( const GMythProgramInfo * prog )
   507 {
   508     return
   509         g_strdup_printf
   510         ( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "
   511           "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"
   512           "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "
   513           "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"
   514           "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "
   515           "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"
   516           "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
   517           "Play Group: %s.\n",
   518           gmyth_program_info_non_null_value ( prog->title ),
   519           gmyth_program_info_non_null_value ( prog->subtitle ),
   520           gmyth_program_info_non_null_value ( prog->description ),
   521           gmyth_program_info_non_null_value ( prog->category ),
   522           gmyth_program_info_non_null_value ( prog->chanid ),
   523           gmyth_program_info_non_null_value ( prog->channame ),
   524           gmyth_program_info_non_null_value ( prog->chanstr ),
   525           gmyth_program_info_non_null_value ( prog->chansign ),
   526           gmyth_program_info_non_null_value ( prog->pathname ), prog->filesize,
   527           gmyth_util_time_to_string_from_time_val ( prog->startts ),
   528           gmyth_util_time_to_string_from_time_val ( prog->endts ),
   529           prog->duplicate, prog->shareable, prog->findid,
   530           gmyth_program_info_non_null_value ( prog->hostname ), prog->sourceid,
   531           prog->cardid, prog->inputid, prog->recpriority, prog->reactivate,
   532           prog->recordid,
   533           gmyth_util_time_to_string_from_time_val ( prog->recstartts ),
   534           gmyth_util_time_to_string_from_time_val ( prog->recendts ),
   535           prog->repeat, prog->programflags,
   536           gmyth_program_info_non_null_value ( prog->recgroup ),
   537           prog->chancommfree,
   538           gmyth_program_info_non_null_value ( prog->chanOutputFilters ),
   539           gmyth_program_info_non_null_value ( prog->seriesid ),
   540           gmyth_program_info_non_null_value ( prog->programid ),
   541           gmyth_util_time_to_string_from_time_val ( prog->lastmodified ),
   542           gmyth_util_time_to_string_from_time_val ( prog->originalAirDate ),
   543           prog->hasAirDate,
   544           gmyth_program_info_non_null_value ( prog->playgroup ) );
   545 }
   546 
   547 /**
   548  * Say if an instance of a GMythProgramInfo is equals to another one.
   549  * 
   550  * @param prog The first GMythProgramInfo instance.
   551  * @param prog The second GMythProgramInfo instance.
   552  * 
   553  * @return <code>true</code>, if the program infos are equals.
   554  */
   555 gboolean
   556 gmyth_program_info_is_equals ( const GMythProgramInfo * prog1,
   557                                const GMythProgramInfo * prog2 )
   558 {
   559     if ( ( strcmp ( gmyth_program_info_non_null_value ( prog1->title ),
   560                     gmyth_program_info_non_null_value ( prog2->title ) ) == 0 )
   561          ||
   562          ( strcmp
   563            ( gmyth_program_info_non_null_value ( prog1->pathname ),
   564              gmyth_program_info_non_null_value ( prog2->pathname ) ) == 0 ) )
   565         return TRUE;
   566     else
   567         return FALSE;
   568 
   569 }