# HG changeset patch
# User leo_sobral
# Date 1173133097 0
# Node ID f8eb1446ff5a125b99b788ca229a8e79040fc9f4
# Parent  4184f56767b81232b992f48157e3de4339bbc7f8
[svn r392] code refactor and memory leaks fixed

diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_programinfo.c
--- a/gmyth/src/gmyth_programinfo.c	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_programinfo.c	Mon Mar 05 22:18:17 2007 +0000
@@ -28,7 +28,7 @@
  */
  
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+    #include "config.h"
 #endif
 
 #include <stdlib.h>
@@ -39,8 +39,8 @@
 #include "gmyth_util.h"
 #include "gmyth_debug.h"
 
-static void gmyth_program_info_class_init          (GMythProgramInfoClass *klass);
-static void gmyth_program_info_init                (GMythProgramInfo *object);
+static void gmyth_program_info_class_init   (GMythProgramInfoClass *klass);
+static void gmyth_program_info_init         (GMythProgramInfo *object);
 
 static void gmyth_program_info_dispose  (GObject *object);
 static void gmyth_program_info_finalize (GObject *object);
@@ -52,225 +52,179 @@
 static void
 gmyth_program_info_class_init (GMythProgramInfoClass *klass)
 {
-	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 	
-  gobject_class->dispose  = gmyth_program_info_dispose;
-  gobject_class->finalize = gmyth_program_info_finalize;	
+    gobject_class->dispose  = gmyth_program_info_dispose;
+    gobject_class->finalize = gmyth_program_info_finalize;	
 }
 
 static void
 gmyth_program_info_init (GMythProgramInfo *gmyth_program_info)
 { 
-  gmyth_program_info->chancommfree = 0;
+    gmyth_program_info->chancommfree = 0;
 
 	/** A flag informing if the program has video or not. */    
-  gmyth_program_info->isVideo = FALSE;
-  gmyth_program_info->lenMins = 0;
+    gmyth_program_info->isVideo = FALSE;
+    gmyth_program_info->lenMins = 0;
   
-  gmyth_program_info->stars = 0.0f;
-  gmyth_program_info->repeat = 0;
+    gmyth_program_info->stars = 0.0f;
+    gmyth_program_info->repeat = 0;
   
-  gmyth_program_info->hasAirDate = FALSE;
+    gmyth_program_info->hasAirDate = FALSE;
 
-  gmyth_program_info->spread = 0;
-  gmyth_program_info->startCol = 0;
+    gmyth_program_info->spread = 0;
+    gmyth_program_info->startCol = 0;
 
-  gmyth_program_info->recpriority2 = 0;
-  gmyth_program_info->reactivate = 0;
+    gmyth_program_info->recpriority2 = 0;
+    gmyth_program_info->reactivate = 0;
 
-  gmyth_program_info->recordid = 0;
-  gmyth_program_info->parentid = 0;   
+    gmyth_program_info->recordid = 0;
+    gmyth_program_info->parentid = 0;   
   
-  /** The backend video source id associated to this program.*/
-  gmyth_program_info->sourceid = 0;
-  /** the backend input id associated to this program.*/
-  gmyth_program_info->inputid = 0;
-  /** The backend card id associated to this program.*/
-  gmyth_program_info->cardid = 0;
-  gmyth_program_info->shareable = FALSE;
-  gmyth_program_info->duplicate = FALSE;
+    /** The backend video source id associated to this program.*/
+    gmyth_program_info->sourceid = 0;
+    /** the backend input id associated to this program.*/
+    gmyth_program_info->inputid = 0;
+    /** The backend card id associated to this program.*/
+    gmyth_program_info->cardid = 0;
+    gmyth_program_info->shareable = FALSE;
+    gmyth_program_info->duplicate = FALSE;
 
-  gmyth_program_info->findid = 0;
+    gmyth_program_info->findid = 0;
 
-  gmyth_program_info->programflags = 0;
-  gmyth_program_info->transcoder = 0;
+    gmyth_program_info->programflags = 0;
+    gmyth_program_info->transcoder = 0;
 
-  gmyth_program_info->recpriority = 0;
+    gmyth_program_info->recpriority = 0;
 
 	/** The file size of the recorded program.*/
-  gmyth_program_info->filesize = -1;
-
-
+    gmyth_program_info->filesize = -1;
 }
 
 static void
 gmyth_program_info_dispose  (GObject *object)
 {
-  GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
+    GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
 
-	if ( gmyth_program_info->chanid != NULL )
-	{
+    if ( gmyth_program_info->chanid != NULL ) {
 		g_string_free( gmyth_program_info->chanid, TRUE );
 		gmyth_program_info->chanid = NULL;
-	}
+    }
   
-  /** The program start time. */
-	if ( gmyth_program_info->startts != NULL )
-	{
-		g_free( gmyth_program_info->startts);
-		gmyth_program_info->startts = NULL;
-	}
+    /** The program start time. */
+    g_free( gmyth_program_info->startts);
 
-  /** The program end time. */
-  if ( gmyth_program_info->endts != NULL )
-  {
+    /** The program end time. */
   	g_free( gmyth_program_info->endts );
-  	gmyth_program_info->endts = NULL;
-  }
   
-  /** The recording schedule start time. */
-  if ( gmyth_program_info->recstartts != NULL )
-  {
+    /** The recording schedule start time. */
   	g_free( gmyth_program_info->recstartts );
-  	gmyth_program_info->recstartts = NULL;
-  }
   
-  /** The recording schedule end time */
-  if ( gmyth_program_info->recendts != NULL )
-  {
+    /** The recording schedule end time */
   	g_free(gmyth_program_info->recendts);
-  	gmyth_program_info->recendts = NULL;
-  }
   
-  /** The program title. */
-  if (gmyth_program_info->title != NULL )
-  {
-  	g_string_free(gmyth_program_info->title, TRUE);
-  	gmyth_program_info->title = NULL;
-  }
+    /** The program title. */
+    if (gmyth_program_info->title != NULL ) {
+        g_string_free(gmyth_program_info->title, TRUE);
+        gmyth_program_info->title = NULL;
+    }
   
-  /** The program subtitle. */
-  if (gmyth_program_info->subtitle != NULL )
-  {
-  	g_string_free(gmyth_program_info->subtitle, TRUE );
-  	gmyth_program_info->subtitle = NULL;
-  }
-  /** The program description. */
-  if ( gmyth_program_info->description != NULL )
-  {
-  	g_string_free( gmyth_program_info->description, TRUE );
-  	gmyth_program_info->description = NULL;
-  }
+    /** The program subtitle. */
+    if (gmyth_program_info->subtitle != NULL ) {
+        g_string_free(gmyth_program_info->subtitle, TRUE );
+        gmyth_program_info->subtitle = NULL;
+    }
+
+    /** The program description. */
+    if ( gmyth_program_info->description != NULL ) {
+        g_string_free( gmyth_program_info->description, TRUE );
+        gmyth_program_info->description = NULL;
+    }
   	
-  /** The program category. */
-  if ( gmyth_program_info->category != NULL )
-  {
-  	g_string_free( gmyth_program_info->category, TRUE );
-  	gmyth_program_info->category = NULL;
-  }
+    /** The program category. */
+    if ( gmyth_program_info->category != NULL ) {
+        g_string_free( gmyth_program_info->category, TRUE );
+        gmyth_program_info->category = NULL;
+    }
   
-  if ( gmyth_program_info->chanstr != NULL )
-  {
-  	g_string_free( gmyth_program_info->chanstr, TRUE );
-  	gmyth_program_info->chanstr = NULL;
-  }
-  if ( gmyth_program_info->chansign != NULL )
-  {
-  	g_string_free( gmyth_program_info->chansign, TRUE );
-  	gmyth_program_info->chansign = NULL;
-  }
-  /** The associated channel name. */
-  if ( gmyth_program_info->channame != NULL )
-  {
-  	g_string_free( gmyth_program_info->channame, TRUE );
-  	gmyth_program_info->channame = NULL;
-  }
-  if ( gmyth_program_info->chanOutputFilters != NULL )
-  {
-  	g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
-  	gmyth_program_info->chanOutputFilters = NULL;
-  }
+    if ( gmyth_program_info->chanstr != NULL ) {
+        g_string_free( gmyth_program_info->chanstr, TRUE );
+        gmyth_program_info->chanstr = NULL;
+    }
+    
+    if ( gmyth_program_info->chansign != NULL ) {
+        g_string_free( gmyth_program_info->chansign, TRUE );
+        gmyth_program_info->chansign = NULL;
+    }
   
-  if ( gmyth_program_info->seriesid != NULL )
-  {
-  	g_string_free( gmyth_program_info->seriesid, TRUE );
-  	gmyth_program_info->chanOutputFilters = NULL;
+    /** The associated channel name. */
+    if ( gmyth_program_info->channame != NULL ) {
+        g_string_free( gmyth_program_info->channame, TRUE );
+        gmyth_program_info->channame = NULL;
+    }
 
-  }
-  /** The program unique id. */
-  if ( gmyth_program_info->programid != NULL )
-  {
-  	g_string_free( gmyth_program_info->programid, TRUE );
-  	gmyth_program_info->programid = NULL;
+    if ( gmyth_program_info->chanOutputFilters != NULL ) {
+        g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
+        gmyth_program_info->chanOutputFilters = NULL;
+    }
+  
+    if ( gmyth_program_info->seriesid != NULL ) {
+        g_string_free( gmyth_program_info->seriesid, TRUE );
+        gmyth_program_info->chanOutputFilters = NULL;
+    }
+  
+    /** The program unique id. */
+    if ( gmyth_program_info->programid != NULL ) {
+        g_string_free( gmyth_program_info->programid, TRUE );
+        gmyth_program_info->programid = NULL;
+    }
+  
+    if ( gmyth_program_info->catType != NULL ) {
+        g_string_free( gmyth_program_info->catType, TRUE );
+        gmyth_program_info->catType = NULL;
+    }
 
-  }
-  if ( gmyth_program_info->catType != NULL )
-  {
-  	g_string_free( gmyth_program_info->catType, TRUE );
-  	gmyth_program_info->catType = NULL;
+    if ( gmyth_program_info->sortTitle != NULL ) {
+        g_string_free( gmyth_program_info->sortTitle, TRUE );
+        gmyth_program_info->sortTitle = NULL;
+    }
+  
+    if ( gmyth_program_info->year != NULL ) {
+        g_string_free( gmyth_program_info->year, TRUE );
+        gmyth_program_info->year = NULL;
+    }
+  
+    g_free( gmyth_program_info->originalAirDate);
+    
+    g_free( gmyth_program_info->lastmodified );
+  
+    g_free( gmyth_program_info->lastInUseTime );
+  
+    if ( gmyth_program_info->schedulerid != NULL ) {
+        g_string_free( gmyth_program_info->schedulerid, TRUE );
+        gmyth_program_info->schedulerid = NULL;
+    }
 
-  }
+    if ( gmyth_program_info->recgroup != NULL ) {
+        g_string_free( gmyth_program_info->recgroup, TRUE );
+        gmyth_program_info->recgroup = NULL;
+    }
+  
+    if ( gmyth_program_info->playgroup != NULL ) {
+        g_string_free( gmyth_program_info->playgroup, TRUE );
+        gmyth_program_info->playgroup = NULL;
+    }
+  
+    /** The file name of the recorded program.*/
+    if ( gmyth_program_info->pathname != NULL) {
+        g_string_free( gmyth_program_info->pathname, TRUE );
+        gmyth_program_info->pathname = NULL;
+    }
 
-  if ( gmyth_program_info->sortTitle != NULL )
-  {
-  	g_string_free( gmyth_program_info->sortTitle, TRUE );
-  	gmyth_program_info->sortTitle = NULL;
-
-  }  
-  
-  if ( gmyth_program_info->year != NULL )
-  {
-  	g_string_free( gmyth_program_info->year, TRUE );
-  	gmyth_program_info->year = NULL;
-
-  }    
-  
-  if ( gmyth_program_info->originalAirDate != NULL )
-  {
-  	g_free( gmyth_program_info->originalAirDate);
-  	gmyth_program_info->originalAirDate = NULL;
-  }
-  if ( gmyth_program_info->lastmodified != NULL )
-  {
-  	g_free( gmyth_program_info->lastmodified );
-  	gmyth_program_info->lastmodified = NULL;
-
-  }
-  if (gmyth_program_info->lastInUseTime != NULL)
-  {
-  	g_free( gmyth_program_info->lastInUseTime );
-  	gmyth_program_info->lastInUseTime = NULL;
-  }
-  
-  if ( gmyth_program_info->schedulerid != NULL )
-  {
-  	g_string_free( gmyth_program_info->schedulerid, TRUE );
-  	gmyth_program_info->schedulerid = NULL;
-  }
-
-  if ( gmyth_program_info->recgroup != NULL )
-  {
-  	g_string_free( gmyth_program_info->recgroup, TRUE );
-  	gmyth_program_info->recgroup = NULL;
-  }
-  if ( gmyth_program_info->playgroup != NULL )
-  {
-  	g_string_free( gmyth_program_info->playgroup, TRUE );
-  	gmyth_program_info->playgroup = NULL;
-  }
-  
-  /** The file name of the recorded program.*/
-  if ( gmyth_program_info->pathname != NULL)
-  {
-  	g_string_free( gmyth_program_info->pathname, TRUE );
-  	gmyth_program_info->pathname = NULL;
-  }
-
-  if ( gmyth_program_info->hostname != NULL )
-  {
-  	g_string_free( gmyth_program_info->hostname, TRUE );
-  	gmyth_program_info->hostname = NULL;
-  }
+    if ( gmyth_program_info->hostname != NULL ) {
+        g_string_free( gmyth_program_info->hostname, TRUE );
+        gmyth_program_info->hostname = NULL;
+    }
    
 	G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
 }
@@ -291,7 +245,8 @@
 GMythProgramInfo*
 gmyth_program_info_new (void)
 {
-    GMythProgramInfo *program_info = GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
+    GMythProgramInfo *program_info = 
+        GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
 
     return program_info;
 }
@@ -320,12 +275,12 @@
     if (prog->startts)
         gmyth_string_list_append_int (slist, prog->startts->tv_sec);  /* 11 */ //DATETIME_TO_LIST(startts)
     else
-	gmyth_string_list_append_int (slist, 0);
+	    gmyth_string_list_append_int (slist, 0);
     
     if (prog->endts)
         gmyth_string_list_append_int (slist, prog->endts->tv_sec);  /* 12 */ //DATETIME_TO_LIST(endts)
     else
-	gmyth_string_list_append_int (slist, 0);
+    	gmyth_string_list_append_int (slist, 0);
 
     gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
     gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
@@ -340,8 +295,10 @@
     gmyth_string_list_append_int (slist, 0 /*prog->rectype*/); /* 23 */
     gmyth_string_list_append_int (slist, 0 /*prog->dupin*/); /* 24 */
     gmyth_string_list_append_int (slist, 0 /*prog->dupmethod*/); /* 25 */
-    gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0);  /* 26 */ //DATETIME_TO_LIST(recstartts)
-    gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0);  /* 27 */ //DATETIME_TO_LIST(recendts)
+    gmyth_string_list_append_int (slist, 
+            prog->recstartts != NULL ? prog->recstartts->tv_sec : 0);  /* 26 */ //DATETIME_TO_LIST(recstartts)
+    gmyth_string_list_append_int (slist, 
+            prog->recendts != NULL ? prog->recendts->tv_sec : 0);  /* 27 */ //DATETIME_TO_LIST(recendts)
     gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
     gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
     gmyth_string_list_append_char_array (slist, "Default"); /* 30 */ //prog->(recgroup != "") ? recgroup : "Default")
@@ -350,9 +307,11 @@
     gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
     gmyth_string_list_append_string (slist, prog->programid); /* 34 */
     gmyth_string_list_append_char_array (slist, ""); /* 35 */
-    gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0);  /* 36 */ //DATETIME_TO_LIST(lastmodified)
+    gmyth_string_list_append_int (slist, 
+            prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0);  /* 36 */ //DATETIME_TO_LIST(lastmodified)
     gmyth_string_list_append_int (slist, 0);  /* 37 */ //FLOAT_TO_LIST(stars)
-    gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0);  /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
+    gmyth_string_list_append_int (slist, 
+            prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0);  /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
     gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
     gmyth_string_list_append_char_array (slist, "Default");  /* 40 */ //prog->(playgroup != "") ? playgroup : "Default")
     gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
@@ -363,57 +322,14 @@
 GMythProgramInfo*
 gmyth_program_info_from_string_list ( GMythStringList *slist )
 {
-		GMythProgramInfo *prog = gmyth_program_info_new();
+    GMythProgramInfo *prog = gmyth_program_info_new();
 
     g_return_val_if_fail (slist != NULL, NULL);
-    /*
-		Unknown
-		
-		
-		
-		1000
-		9
-		1000
-		Band
-		/mnt/store//1000_20070125110059.nuv
-		0
-		0
-		1169733659
-		1169735400
-		0
-		0
-		0
-		hmelo-desktop
-		0
-		1
-		0
-		0
-		-2
-		0
-		0
-		15
-		6
-		1169733659
-		1169735400
-		0
-		0
-		LiveTV
-		0
-		
-		
-		
-		1169733659
-		0.000000
-		-1
-		0
-		Default
-		0
-		*/
+
     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);
-    //gmyth_string_list_get_string (slist, 4);
     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);    
@@ -433,7 +349,6 @@
     			gmyth_program_info_non_null_value( prog->chansign ), 
     			gmyth_program_info_non_null_value( prog->pathname ), 
     			gmyth_string_list_get_int (slist, 11) );    
-    //gmyth_string_list_get_int (slist, 9);
     
     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)
@@ -485,47 +400,47 @@
 const gchar*
 gmyth_program_info_to_string( const GMythProgramInfo* prog )
 {
-	 return g_strdup_printf( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "\
-	 		"Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"\
-	 		"Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "\
-	 		"Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"\
-	 		"Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "\
-	 		"Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"\
-	 		"Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
-	 		"Play Group: %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 ),
+    return g_strdup_printf( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "\
+        "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"\
+        "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "\
+        "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"\
+        "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "\
+        "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"\
+        "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
+        "Play Group: %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_util_time_to_string_from_time_val( prog->startts), 
-    gmyth_util_time_to_string_from_time_val( prog->endts), 
-    prog->duplicate,
-    prog->shareable,
-    prog->findid,
-    gmyth_program_info_non_null_value( prog->hostname ),
-    prog->sourceid,
-    prog->cardid,
-    prog->inputid,
-    prog->recpriority,
-    prog->reactivate,
-    prog->recordid,
-    gmyth_util_time_to_string_from_time_val(prog->recstartts),
-    gmyth_util_time_to_string_from_time_val(prog->recendts),
-    prog->repeat,
-    prog->programflags,
-    gmyth_program_info_non_null_value( prog->recgroup ),
-    prog->chancommfree,
-    gmyth_program_info_non_null_value( prog->chanOutputFilters ),
-    gmyth_program_info_non_null_value( prog->seriesid ),
-    gmyth_program_info_non_null_value( prog->programid ),
-    gmyth_util_time_to_string_from_time_val(prog->lastmodified),
-    gmyth_util_time_to_string_from_time_val(prog->originalAirDate),
-    prog->hasAirDate,
-    gmyth_program_info_non_null_value(prog->playgroup) );
+        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_util_time_to_string_from_time_val( prog->startts), 
+        gmyth_util_time_to_string_from_time_val( prog->endts), 
+        prog->duplicate,
+        prog->shareable,
+        prog->findid,
+        gmyth_program_info_non_null_value( prog->hostname ),
+        prog->sourceid,
+        prog->cardid,
+        prog->inputid,
+        prog->recpriority,
+        prog->reactivate,
+        prog->recordid,
+        gmyth_util_time_to_string_from_time_val(prog->recstartts),
+        gmyth_util_time_to_string_from_time_val(prog->recendts),
+        prog->repeat,
+        prog->programflags,
+        gmyth_program_info_non_null_value( prog->recgroup ),
+        prog->chancommfree,
+        gmyth_program_info_non_null_value( prog->chanOutputFilters ),
+        gmyth_program_info_non_null_value( prog->seriesid ),
+        gmyth_program_info_non_null_value( prog->programid ),
+        gmyth_util_time_to_string_from_time_val(prog->lastmodified),
+        gmyth_util_time_to_string_from_time_val(prog->originalAirDate),
+        prog->hasAirDate,
+        gmyth_program_info_non_null_value(prog->playgroup) );
 }
diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_programinfo.h
--- a/gmyth/src/gmyth_programinfo.h	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_programinfo.h	Mon Mar 05 22:18:17 2007 +0000
@@ -59,104 +59,102 @@
  */
 struct _GMythProgramInfo
 {
-	GObject 						parent;
+    GObject parent;
+    
+    /** The channel unique ID. */
+    GString *chanid;
+  
+    /** The program start time. */
+    GTimeVal* startts;
+    /** The program end time. */
+    GTimeVal* endts;
+    /** The recording schedule start time. */
+    GTimeVal* recstartts;
+    /** The recording schedule end time */
+    GTimeVal* recendts;
+  
+    /** The program title. */
+    GString *title;
+    /** The program subtitle. */
+    GString *subtitle;
+    /** The program description. */
+    GString *description;
+    /** The program category. */
+    GString *category;
+  
+    GString *chanstr;
+    GString *chansign;
+    /** The associated channel name. */
+    GString *channame;
+    gint chancommfree;
+    GString *chanOutputFilters;
+  
+    GString *seriesid;
+    /** The program unique id. */
+    GString *programid;
+    GString *catType;
 
-	/** The channel unique ID. */
-  GString *chanid;
-  
-  /** The program start time. */
-  GTimeVal* startts;
-  /** The program end time. */
-  GTimeVal* endts;
-  /** The recording schedule start time. */
-  GTimeVal* recstartts;
-  /** The recording schedule end time */
-  GTimeVal* recendts;
-  
-  /** The program title. */
-  GString *title;
-  /** The program subtitle. */
-  GString *subtitle;
-  /** The program description. */
-  GString *description;
-  /** The program category. */
-  GString *category;
-  
-  GString *chanstr;
-  GString *chansign;
-  /** The associated channel name. */
-  GString *channame;
-  gint chancommfree;
-  GString *chanOutputFilters;
-  
-  GString *seriesid;
-  /** The program unique id. */
-  GString *programid;
-  GString *catType;
-
-  GString *sortTitle;  
+    GString *sortTitle;  
 
 	/** A flag informing if the program has video or not. */    
-  gboolean isVideo;
-  gint lenMins;
+    gboolean isVideo;
+    gint lenMins;
   
-  GString *year;    
-  gdouble stars;
-  gint repeat;
+    GString *year;    
+    gdouble stars;
+    gint repeat;
   
-  GTimeVal* originalAirDate;
-  GTimeVal* lastmodified;
-  GTimeVal* lastInUseTime;
+    GTimeVal* originalAirDate;
+    GTimeVal* lastmodified;
+    GTimeVal* lastInUseTime;
   
-  gboolean hasAirDate;
+    gboolean hasAirDate;
 
-  gint spread;
-  gint startCol;
+    gint spread;
+    gint startCol;
 
-  gint recpriority2;
-  gint reactivate;    
+    gint recpriority2;
+    gint reactivate;    
 
-  gint recordid;
-  gint parentid;   
+    gint recordid;
+    gint parentid;   
   
-  /** The backend video source id associated to this program.*/
-  gint sourceid;
-  /** the backend input id associated to this program.*/
-  gint inputid;
-  /** The backend card id associated to this program.*/
-  gint cardid;
-  gboolean shareable;
-  gboolean duplicate;
+    /** The backend video source id associated to this program.*/
+    gint sourceid;
+    /** the backend input id associated to this program.*/
+    gint inputid;
+    /** The backend card id associated to this program.*/
+    gint cardid;
+    gboolean shareable;
+    gboolean duplicate;
 
-  GString * schedulerid;
-  gint findid;
+    GString * schedulerid;
+    gint findid;
 
-  gint programflags;
-  gint transcoder;
+    gint programflags;
+    gint transcoder;
 
-  GString *recgroup;
-  GString *playgroup;
-  gint recpriority;
+    GString *recgroup;
+    GString *playgroup;
+    gint recpriority;
 
 	/** The file size of the recorded program.*/
-  gint64 filesize;
+    gint64 filesize;
   
-  /** The file name of the recorded program.*/
-  GString *pathname;
-  GString *hostname;
-      
-  /* AvailableStatusType availableStatus;*/
-
+    /** The file name of the recorded program.*/
+    GString *pathname;
+    GString *hostname;
 };
 
-GType          			gmyth_program_info_type (void);
+GType     			gmyth_program_info_type (void);
 
 GMythProgramInfo* 	gmyth_program_info_new (void);
 
-GMythStringList* 		gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist);
+GMythStringList*	gmyth_program_info_to_string_list (GMythProgramInfo *prog, 
+                                                       GMythStringList *slist);
 GMythProgramInfo* 	gmyth_program_info_from_string_list (GMythStringList *slist);
 
-const gchar*				gmyth_program_info_to_string( const GMythProgramInfo* prog );
+const gchar*		gmyth_program_info_to_string( const GMythProgramInfo* prog );
 
 G_END_DECLS
 
diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_query.c
--- a/gmyth/src/gmyth_query.c	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_query.c	Mon Mar 05 22:18:17 2007 +0000
@@ -79,7 +79,7 @@
     
     if (gmyth_query->backend_info) {
         g_object_unref (gmyth_query->backend_info);
-	//gmyth_query->backend_info = NULL;
+        gmyth_query->backend_info = NULL;
     }
     
     G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object);
@@ -109,8 +109,9 @@
 gmyth_query_connect_with_timeout (GMythQuery *gmyth_query, 
 		GMythBackendInfo *backend_info, guint timeout)
 {
-    assert(gmyth_query);
+    assert(gmyth_query);    
     g_return_val_if_fail (gmyth_query->conn != NULL, FALSE);
+
     if (timeout != 0) {
         /* sets connection timeout */
         mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT, (gchar*) &timeout);
diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_scheduler.c
--- a/gmyth/src/gmyth_scheduler.c	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_scheduler.c	Mon Mar 05 22:18:17 2007 +0000
@@ -68,7 +68,7 @@
     sched->recordid =0;
     sched->type = 0;
     sched->search = 0;
-    sched->profile =  g_string_new("");
+    sched->profile = g_string_new("");
     
     sched->dupin = 0;
     sched->dupmethod = 0;
@@ -88,14 +88,14 @@
     sched->maxnewest = 0;
 
     sched->recpriority = 0;
-    sched->recgroup = 0;
-    sched->playgroup = 0;
+    sched->recgroup = g_string_new("");
+    sched->playgroup = g_string_new("");
     
     sched->prefinput = 0;
     sched->inactive = 0;
     
-    sched->searchType = g_string_new("");
-    sched->searchForWhat = g_string_new("");
+    sched->search_type = g_string_new("");
+    sched->search_what = g_string_new("");
     
     sched->msqlquery = gmyth_query_new ();
 }
@@ -106,10 +106,30 @@
     GMythScheduler *scheduler = GMYTH_SCHEDULER (object);
 
     if (scheduler->backend_info) { 
-	g_object_unref (scheduler->backend_info);
-	scheduler->backend_info = NULL;
+	    g_object_unref (scheduler->backend_info);
+    	scheduler->backend_info = NULL;
     }
 
+    if (scheduler->msqlquery) { 
+	    g_object_unref (scheduler->msqlquery);
+    	scheduler->msqlquery = NULL;
+    }
+
+    if (scheduler->profile != NULL)
+        g_string_free (scheduler->profile, TRUE);
+
+    if (scheduler->recgroup != NULL)
+        g_string_free (scheduler->recgroup, TRUE);
+
+    if (scheduler->playgroup != NULL)
+        g_string_free (scheduler->playgroup, TRUE);
+
+    if (scheduler->search_type != NULL)
+        g_string_free (scheduler->search_type, TRUE);
+
+    if (scheduler->search_what != NULL)
+        g_string_free (scheduler->search_what, TRUE);
+
     G_OBJECT_CLASS (gmyth_scheduler_parent_class)->dispose (object);
 }
 
@@ -224,9 +244,9 @@
         while((row = mysql_fetch_row (msql_res)) != NULL) {
         	schedule = g_new0(ScheduleInfo, 1);
         	
-        	schedule->record_id  = g_ascii_strtoull (row[0], NULL, 10);
-        	schedule->program_id = g_ascii_strtoull (row[1], NULL, 10);
-            schedule->channel_id = g_ascii_strtoull (row[2], NULL, 10);
+        	schedule->record_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
+        	schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
+            schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
             
             /* generate a time_t from a time and a date db field */
             g_sprintf (date_time, "%sT%s", row[4], row[3]);
@@ -238,10 +258,10 @@
             
             schedule->end_time = gmyth_util_string_to_time_val (date_time);
 
-            schedule->title = g_string_new (row[7]);
-            schedule->subtitle = g_string_new (row[8]);
+            schedule->title       = g_string_new (row[7]);
+            schedule->subtitle    = g_string_new (row[8]);
             schedule->description = g_string_new (row[9]);
-            schedule->category = g_string_new (row[10]);
+            schedule->category    = g_string_new (row[10]);
 
            (*schedule_list) = g_list_append (*(schedule_list), schedule);
     	}
@@ -271,11 +291,12 @@
     
     g_string_printf (query_str, 
     	"SELECT recordid,programid,chanid,starttime,progstart,"
-    	"endtime,progend,title,subtitle,description,category,filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
+    	"endtime,progend,title,subtitle,description,category,"
+        "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
 
     if (scheduler->msqlquery == NULL) {
-	g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
-	return -1;
+        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
+        return -1;
     }
 
     msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
@@ -285,7 +306,7 @@
         return -1;
     } else {
         MYSQL_ROW row;
-        *recorded_list = NULL;
+        (*recorded_list) = NULL;
         
         while((row = mysql_fetch_row (msql_res))!=NULL){
        	    record = g_new0(RecordedInfo, 1);
@@ -295,16 +316,16 @@
             record->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
             
             record->start_time = gmyth_util_string_to_time_val (row[3]);
-            record->end_time = gmyth_util_string_to_time_val (row[5]);
+            record->end_time   = gmyth_util_string_to_time_val (row[5]);
 	
-            record->title = g_string_new (row[7]);
-            record->subtitle = g_string_new (row[8]);
+            record->title       = g_string_new (row[7]);
+            record->subtitle    = g_string_new (row[8]);
             record->description = g_string_new (row[9]);
-            record->category = g_string_new (row[10]);
-            record->filesize = g_ascii_strtoull (row[11], NULL, 10);
-            record->basename = g_string_new (row[12]);
+            record->category    = g_string_new (row[10]);
+            record->filesize    = g_ascii_strtoull (row[11], NULL, 10);
+            record->basename    = g_string_new (row[12]);
 
- 	    *recorded_list = g_list_append (*recorded_list, record);
+            (*recorded_list) = g_list_append ((*recorded_list), record);
     	}
     }
     
@@ -332,8 +353,6 @@
     MYSQL_RES *msql_res;
     GString *query_str = g_string_new ("");
     
-    gchar *date_time = NULL; 
-    
     assert(scheduler);
     
     if (scheduler->msqlquery == NULL) {
@@ -352,8 +371,7 @@
 	    "search, autotranscode, transcoder, tsdefault, "
 	    "autouserjob1, autouserjob2, autouserjob3, autouserjob4) "
 	    " values ( %d, 1, %d, \"%s\","	//recordid, type, chanid, starttime
-	    " \"%s\", \"%s\", \"%s\", \"%s\","
-        //startdate, endtime, enddate, title
+	    " \"%s\", \"%s\", \"%s\", \"%s\"," //startdate, endtime, enddate, title
 	    "DEFAULT, 0, 0, 0, "	//profile, recpriority, maxnewest, inactive
 	    "0, 1, 0, 0, "			//maxepisodes, autoexpire, startoffset, endoffset
 	    "DEFAULT, 6, 15, %d, " 	//recgroup, dupmethod, dupin, station
@@ -362,9 +380,9 @@
 	    "0, 0, 0, 0 );",		//autouserjob1, autouserjob2, autouserjob3, autouserjob4
 	    schedule_info->record_id, schedule_info->channel_id,
         gmyth_util_time_to_string_only_time( schedule_info->start_time ),
-	    	gmyth_util_time_to_string_only_date( schedule_info->start_time ),
-        gmyth_util_time_to_string_only_time( schedule_info->end_time ),
-        gmyth_util_time_to_string_only_date( schedule_info->end_time ), 
+        gmyth_util_time_to_string_only_date( schedule_info->start_time ),
+	    gmyth_util_time_to_string_only_date( schedule_info->start_time ),
+        gmyth_util_time_to_string_only_date( schedule_info->end_time ),
         schedule_info->title->str, //title
     	schedule_info->channel_id,//station
     	(gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, //findday
@@ -412,8 +430,8 @@
     assert(scheduler);
     
     if (scheduler->msqlquery == NULL) {
-	g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
-	return FALSE;
+        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
+        return FALSE;
     }
 
     //========================================
@@ -530,16 +548,16 @@
 	        proginfo->chanstr = g_string_new (msql_row[6]);
 	        proginfo->chansign = g_string_new (msql_row[7]);
 	        proginfo->channame = g_string_new (msql_row[0]);
-	        proginfo->chancommfree = g_ascii_strtoull (msql_row[9], NULL, 10);
+	        proginfo->chancommfree = (gint) g_ascii_strtoll (msql_row[9], NULL, 10);
 	        proginfo->chanOutputFilters = g_string_new (msql_row[10]);
 	        proginfo->seriesid = g_string_new (msql_row[11]);
 	        proginfo->programid = g_string_new (msql_row[12]);
-	        proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10);
+	        proginfo->filesize = g_ascii_strtoll (msql_row[13], NULL, 10);
 	
 	        proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]);
 	        
 	        proginfo->stars = g_ascii_strtod (msql_row[15], NULL);
-	        proginfo->repeat = g_ascii_strtoull (msql_row[16], NULL, 10);
+	        proginfo->repeat = (gint) g_ascii_strtoll (msql_row[16], NULL, 10);
 	        
 	        if (msql_row[17] == NULL) {
 	            proginfo->originalAirDate = 0;
@@ -550,15 +568,15 @@
 	        }
 	        
 	        proginfo->hostname = g_string_new (msql_row[18]);
-	        proginfo->recordid = g_ascii_strtoull (msql_row[19], NULL, 10);
-	        proginfo->transcoder = g_ascii_strtoull (msql_row[20], NULL, 10);
+	        proginfo->recordid = (gint) g_ascii_strtoll (msql_row[19], NULL, 10);
+	        proginfo->transcoder = (gint) g_ascii_strtoll (msql_row[20], NULL, 10);
 	
 	        //proginfo->spread = -1;
 			//proginfo->programflags = proginfo->getProgramFlags();
 	
 	        proginfo->recgroup = g_string_new (msql_row[26]);
 	        proginfo->playgroup = g_string_new (msql_row[21]);
-	        proginfo->recpriority = g_ascii_strtoull (msql_row[22], NULL, 10);
+	        proginfo->recpriority = (gint) g_ascii_strtoll (msql_row[22], NULL, 10);
 	
 	        proginfo->pathname = g_string_new (msql_row[25]);
 
@@ -614,7 +632,7 @@
 			    scheduler->backend_info->port)) {
         gmyth_socket_sendreceive_stringlist (socket, strlist);
     } else {
-	g_warning ("[%s] Connection to backend failed!", __FUNCTION__);
+        g_warning ("[%s] Connection to backend failed!", __FUNCTION__);
     }
     
     g_string_free(datastr, TRUE);
@@ -644,6 +662,12 @@
     if (info->basename != NULL)
         g_string_free (info->basename, TRUE);
 
+    if (info != NULL)
+        g_free (info->start_time);
+
+    if (info != NULL)
+        g_free (info->end_time);
+
     g_free (info);
 }
 
@@ -662,6 +686,12 @@
     if (info->category != NULL)
         g_string_free (info->category, TRUE);
 
+    if (info != NULL)
+        g_free (info->start_time);
+
+    if (info != NULL)
+        g_free (info->end_time);
+
     g_free (info);
 }
 
diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_scheduler.h
--- a/gmyth/src/gmyth_scheduler.h	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_scheduler.h	Mon Mar 05 22:18:17 2007 +0000
@@ -90,20 +90,20 @@
     long prefinput;
     short int inactive;
     
-    GString *searchType;
-    GString *searchForWhat;
+    GString *search_type;
+    GString *search_what;
     
     GMythQuery *msqlquery;
     GMythBackendInfo *backend_info;
 };
 
 typedef struct {
-	gint    record_id;
-	gint    program_id;
-	gint    channel_id;
+	guint    record_id;
+	guint    program_id;
+	guint    channel_id;
 	
-  GTimeVal* start_time;
-	GTimeVal* end_time;
+    GTimeVal *start_time;
+	GTimeVal *end_time;
     
 	GString *title;
 	GString *subtitle;
diff -r 4184f56767b8 -r f8eb1446ff5a gmyth/src/gmyth_socket.c
--- a/gmyth/src/gmyth_socket.c	Mon Mar 05 21:58:21 2007 +0000
+++ b/gmyth/src/gmyth_socket.c	Mon Mar 05 22:18:17 2007 +0000
@@ -140,13 +140,12 @@
 static gint
 gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address ) {
 
-        if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) {
-                //g_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) );
-                return 0;
-        } else {
-                return -1;
-        }
-
+    if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) {
+        //g_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) );
+        return 0;
+    } else {
+        return -1;
+    }
 }
 
 static const gchar *PATH_PROC_NET_DEV = "/proc/net/dev";
@@ -177,7 +176,7 @@
 	fgets(buffer, sizeof(buffer)-1, fd);
 	while (!feof(fd)) {
 		ifname = buffer;
-		sep;
+
 		if (fgets(buffer, sizeof(buffer)-1, fd) == NULL)
 			break;
 		sep = strrchr(buffer, ':');
@@ -204,7 +203,6 @@
 	fclose(fd);
 	close(s);
 	return local_addrs;
-
 }