# HG changeset patch
# User rosfran
# Date 1169838497 0
# Node ID 0a8fe4427e41565a19bb0afc6ae3970ca9c0dde8
# Parent  bbf4568147717153be87695f612dae33d2506823
[svn r308] A lot of improvements related SET_CHANNEL messages.

diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_backendinfo.c
--- a/gmyth/src/gmyth_backendinfo.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_backendinfo.c	Fri Jan 26 19:08:17 2007 +0000
@@ -59,6 +59,7 @@
     backend_info->password = NULL;    
     backend_info->db_name  = NULL;
     backend_info->port = -1;
+    backend_info->uri		   = NULL;
 }
 
 static void
@@ -77,6 +78,12 @@
     backend_info->db_name  = NULL;
     backend_info->port = -1;
 
+    if ( backend_info->uri != NULL )
+    {
+    	g_object_unref(backend_info->uri);
+    	backend_info->uri = NULL;
+    }
+
     G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object);
 }
 
@@ -107,6 +114,9 @@
 {
     GMythBackendInfo *backend_info = 
         GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
+    
+    backend_info->uri = gmyth_uri_new_with_value( 
+    				g_strdup_printf( "myth://%s:%s@%s:%d/?%s", username, password, hostname, port, db_name ) );
 
     gmyth_backend_info_set_hostname (backend_info, hostname);
     gmyth_backend_info_set_username (backend_info, username);
@@ -123,17 +133,18 @@
     GMythBackendInfo *backend_info = 
         GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
         
-    GMythURI* uri = gmyth_uri_new_with_value( uri_str );
+    backend_info->uri = gmyth_uri_new_with_value( uri_str );
     
-    gchar** path_parts = g_strsplit( gmyth_uri_get_path( uri ), "&", -1 );
+    gchar** path_parts = g_strsplit( gmyth_uri_get_path( backend_info->uri ), "&", -1 );
     
-    gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri ) );
-    gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( uri ) );
-    gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( uri ) );
+    gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host ( backend_info->uri ) );
+    gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( backend_info->uri ) );
+    gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( backend_info->uri ) );
     /* gets the path info to database name, from the URI, and removes the trash chars */
     gmyth_backend_info_set_db_name (backend_info, path_parts != NULL && path_parts[0] != NULL 
-    				&& strlen( path_parts[0] ) > 0 ? g_strstrip( g_strdelimit( path_parts[0], "/?", ' ' ) ) : gmyth_uri_get_path( uri ) );
-    gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( uri ) );
+    				&& strlen( path_parts[0] ) > 0 ? g_strstrip( g_strdup( g_strdelimit( path_parts[0], "/?", ' ' ) ) ) 
+    						: gmyth_uri_get_path( backend_info->uri ) );
+    gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( backend_info->uri ) );
     
     g_strfreev( path_parts );
 		
@@ -230,3 +241,18 @@
     return backend_info->port;
 }
 
+const GMythURI*
+gmyth_backend_info_get_uri (GMythBackendInfo *backend_info)
+{
+	
+	if ( NULL == backend_info->uri )
+	{
+		backend_info->uri = gmyth_uri_new_with_value( 
+	    				g_strdup_printf( "myth://%s:%s@%s:%d/?%s", backend_info->username, backend_info->password, 
+	    				backend_info->hostname, backend_info->port, backend_info->db_name ) );
+	}
+	
+	return backend_info->uri;	
+}
+
+
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_backendinfo.h
--- a/gmyth/src/gmyth_backendinfo.h	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_backendinfo.h	Fri Jan 26 19:08:17 2007 +0000
@@ -29,6 +29,8 @@
 
 #include <glib-object.h>
 
+#include "gmyth_uri.h"
+
 G_BEGIN_DECLS
 
 #define GMYTH_BACKEND_INFO_TYPE               (gmyth_backend_info_get_type ())
@@ -60,6 +62,8 @@
     gchar *db_name;
     gint port;
     gchar *path;
+    
+    GMythURI* uri;
 };
 
 
@@ -87,6 +91,10 @@
 const gchar*        gmyth_backend_info_get_db_name  (GMythBackendInfo *backend_info);
 gint                gmyth_backend_info_get_port     (GMythBackendInfo *backend_info);
 
+const GMythURI*			gmyth_backend_info_get_uri			(GMythBackendInfo *backend_info);
+
+/*const gchar*      gmyth_backend_info_get_full_uri (GMythBackendInfo *backend_info);*/
+
 G_END_DECLS
 
 #endif /* __GMYTH_BACKEND_INFO_H__ */
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_common.c
--- a/gmyth/src/gmyth_common.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_common.c	Fri Jan 26 19:08:17 2007 +0000
@@ -79,8 +79,9 @@
 {
 	if ( channel_info != NULL )
 	{
-    gmyth_debug("ChannelInfo (Name, ID) = (%s, %d)\n", 
-             channel_info->channel_name->str, channel_info->channel_ID);
+    gmyth_debug("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n", 
+             channel_info->channel_name->str, channel_info->channel_num->str, 
+             channel_info->channel_ID);
 	}
 }
 
@@ -90,7 +91,7 @@
 	
 	if ( program_info != NULL ) {
 		
-	  gmyth_debug("ProgramInfo\n\tTitle = %s\n\t"
+	  gmyth_debug( "ProgramInfo\n\tTitle = %s\n\t"
 	           "Description = %s\n\t"
 	           "Start time= %s\t"
 	           "End time = %s\n"
@@ -101,7 +102,7 @@
 	           gmyth_util_time_to_string_from_time_val(program_info->startts),
 	           gmyth_util_time_to_string_from_time_val(program_info->endts), 
 	           program_info->pathname->str,
-	           program_info->filesize);
+	           program_info->filesize );
 	           
 	}
 	
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_common.h
--- a/gmyth/src/gmyth_common.h	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_common.h	Fri Jan 26 19:08:17 2007 +0000
@@ -43,6 +43,8 @@
 	/** The channel ID in backend database */
 	gint channel_ID;
 	
+	GString* channel_num; 
+	
 	/** The channel name in backend database */
 	GString *channel_name;
 
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_epg.c
--- a/gmyth/src/gmyth_epg.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_epg.c	Fri Jan 26 19:08:17 2007 +0000
@@ -148,7 +148,7 @@
     assert(gmyth_epg);
 
     msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, 
-    		"SELECT chanid,name FROM channel;");
+    		"SELECT chanid, channum, name FROM channel;");
 
 	(*glist_ptr) = NULL;
 	
@@ -163,11 +163,10 @@
 
         	channel_info = g_new0(GMythChannelInfo, 1);
             channel_info->channel_ID = g_ascii_strtoull (row[0], NULL, 10);
-            channel_info->channel_name = g_string_new (row[1]);
+            channel_info->channel_num = g_string_new (row[1]);
+            channel_info->channel_name = g_string_new (row[2]);
        
-#if 0
             gmyth_channel_info_print(channel_info);
-#endif
             
             (*glist_ptr) = g_list_append ((*glist_ptr), channel_info);
     	}
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_livetv.c
--- a/gmyth/src/gmyth_livetv.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_livetv.c	Fri Jan 26 19:08:17 2007 +0000
@@ -33,6 +33,7 @@
 #include "gmyth_remote_util.h"
 #include "gmyth_tvchain.h"
 #include "gmyth_socket.h"
+#include "gmyth_backendinfo.h"
 #include "gmyth_debug.h"
 
 #include "gmyth_file_transfer.h"
@@ -74,6 +75,8 @@
 	livetv->recorder = NULL;
 	livetv->tvchain = NULL;
 	livetv->proginfo = NULL;
+	livetv->uri = NULL;
+
 }
 
 static void
@@ -120,6 +123,12 @@
 		g_object_unref (livetv->backend_info);
 		livetv->backend_info = NULL;
 	}
+	
+	if ( livetv->uri != NULL )
+	{
+		g_object_unref (livetv->uri);
+		livetv->uri = NULL;
+	}
 
 	G_OBJECT_CLASS ( gmyth_livetv_parent_class )->finalize ( object );
 }
@@ -252,8 +261,22 @@
   
 }  
 
+
+/*
+static gchar*
+gmyth_livetv_create_remote_url( GMythLiveTV *livetv )
+{
+	gchar *uri = g_strdup("");
+	gmyth_backend_info_get_remote_h
+	
+	//gmyth_backend(livetv->backend_info)
+	
+	return uri;
+}
+*/
+
 static gboolean
-gmyth_livetv_setup_recorder ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info )
+gmyth_livetv_setup_recorder_channel_name ( GMythLiveTV *livetv, gchar* channel, GMythBackendInfo *backend_info )
 {
 	gboolean res = TRUE;
 
@@ -328,7 +351,7 @@
     /* IS_RECORDING again, just like the MythTV backend does... */
     gmyth_recorder_is_recording (livetv->recorder);
     
-		if ( channel != -1 ) 
+		if ( channel != NULL ) 
 		{
 			/* Pauses remote encoder. */
 			res = gmyth_recorder_pause_recording(livetv->recorder);
@@ -338,11 +361,11 @@
 				goto error;
 			}
 	
-	  	if ( gmyth_recorder_check_channel( livetv->recorder, channel ) )
+	  	if ( gmyth_recorder_check_channel_name( livetv->recorder, channel ) )
 	  	{
-		  	if ( gmyth_recorder_set_channel( livetv->recorder, channel ) )
+		  	if ( gmyth_recorder_set_channel_name( livetv->recorder, channel ) )
 		  	{
-		  		g_print( "[%s] Channel changed!!! abc1 [%d].\n", __FUNCTION__, channel );
+		  		g_print( "[%s] Channel changed!!! [%s].\n", __FUNCTION__, channel );
 		  	}
 	  	}
 	
@@ -361,39 +384,43 @@
 		return FALSE;
 	}
 	/* prints program info data text */ 
+	gmyth_debug( "New ProgramInfo...\n" );
 	gmyth_program_info_print( prog_info );
 	/* DEBUG message */
+	gmyth_debug( "Old ProgramInfo...\n" );
+	gmyth_program_info_print( livetv->proginfo );
+	
+	/* check if the program chain could be obtained from the MythTV protocol message */
+	if ( prog_info != NULL )
+	{
+		livetv->proginfo = prog_info;		
+	} else {
+		
+		/* check for the program info in the TV program chain could be obtained 
+		   from the MythTV MySQL database */
 
-	// Reload all TV chain from Mysql database.
-	gmyth_tvchain_reload_all (livetv->tvchain);
-
-	if ( livetv->tvchain == NULL ) {
-		res = FALSE;
-		goto error;
+		/* Reload all TV chain from Mysql database. */
+		gmyth_tvchain_reload_all (livetv->tvchain);
+	
+		if ( livetv->tvchain == NULL ) {
+			res = FALSE;
+			goto error;
+		}
+		
+		/* Get program info from database using chanid and starttime */
+		livetv->proginfo = gmyth_tvchain_get_program_at (livetv->tvchain, tvchain_curr_index++ );
+		if ( livetv->proginfo == NULL ) {
+			g_warning ("[%s] LiveTV not successfully started.\n", __FUNCTION__ );
+			res = FALSE;
+			goto error;
+		} else {
+			res = TRUE;
+			gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", livetv->proginfo->pathname->str );
+		}
+		
 	}
 	
-	// Get program info from database using chanid and starttime
-	livetv->proginfo = gmyth_tvchain_get_program_at (livetv->tvchain, tvchain_curr_index++ );
-	if ( livetv->proginfo == NULL ) {
-		g_warning ("[%s] LiveTV not successfully started.\n", __FUNCTION__ );
-		res = FALSE;
-		goto error;
-	} else {
-		res = TRUE;
-		gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", livetv->proginfo->pathname->str );
-	}
-	
- if ( res == TRUE) {
-    /* loop finished, set the max tries variable to zero again... */
-    gint wait_to_transfer = GMYTHTV_TRANSFER_MAX_WAITS;
-
-    g_usleep (200);
-
-    while (wait_to_transfer-- > 0 &&
-        (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
-      g_usleep (1000);
-  }
-
+	livetv->uri = gmyth_backend_info_get_uri( backend_info );
 	
 	g_static_mutex_unlock( &lock );
 
@@ -440,6 +467,13 @@
 
 }
 
+static gboolean
+gmyth_livetv_setup_recorder ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info )
+{
+	return gmyth_livetv_setup_recorder_channel_name ( livetv, ( channel != -1 ) ? 
+				g_strdup_printf( "%d", channel ) : NULL, backend_info );
+}
+
 gboolean
 gmyth_livetv_channel_setup ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info )
 {
@@ -447,6 +481,12 @@
 }
 
 gboolean
+gmyth_livetv_channel_name_setup ( GMythLiveTV *livetv, gchar* channel, GMythBackendInfo *backend_info )
+{
+	return gmyth_livetv_setup_recorder_channel_name ( livetv, channel, backend_info );
+}
+
+gboolean
 gmyth_livetv_setup ( GMythLiveTV *livetv, GMythBackendInfo *backend_info )
 {
 	return gmyth_livetv_setup_recorder ( livetv, -1, backend_info );
@@ -480,9 +520,10 @@
 
 	if ( prog_info != NULL ) {		
 		res = TRUE;
+		livetv->proginfo = prog_info;
 		gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK, program info changed.");
 	} else {
-		g_warning ("LiveTV not successfully started on the next program chain.\n", __FUNCTION__ );
+		g_warning ("[%s] LiveTV not successfully started on the next program chain.\n", __FUNCTION__ );
 		res = FALSE;
 		goto error;
 	}
@@ -521,24 +562,27 @@
 GMythFileTransfer *
 gmyth_livetv_create_file_transfer( GMythLiveTV *livetv )
 {
-	GMythURI* uri = NULL;
+	//GMythURI* uri = NULL;
 	
-	if ( NULL == livetv || NULL == livetv->proginfo )
+	if ( NULL == livetv )
 		goto done;
 	
 	if ( !livetv->setup_done )
 	{
 		gmyth_debug( "Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!" );
 		goto done;
-	}	
-
-  gmyth_debug( "URI path = %s.\n", livetv->proginfo->pathname->str ); 
+	}
+	
+	if ( livetv->proginfo != NULL )
+  	gmyth_debug( "URI path = %s.\n", livetv->proginfo->pathname->str );
+  else
+  	gmyth_debug( "URI path = %s.\n", livetv->uri->uri->str ); 
   
   g_static_mutex_lock( &lock );
   
   if ( livetv->file_transfer != NULL )
   {
-  	gmyth_file_transfer_close( livetv->file_transfer );
+  	/*gmyth_file_transfer_close( livetv->file_transfer );*/
   	g_object_unref( livetv->file_transfer );
   	livetv->file_transfer = NULL;
   }  	
@@ -551,14 +595,25 @@
     goto done;
   }
   
-  uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str );
-  if ( NULL == uri )
+  if ( livetv->uri != NULL )  
+  { 
+  	if ( livetv->uri->path != NULL )
+  	{
+  		g_string_free( livetv->uri->path, FALSE );
+  		livetv->uri->path = NULL;
+  	}
+  	livetv->uri->path = g_string_new( g_strrstr( livetv->proginfo->pathname->str, "/" ) );
+  } else {
+  	livetv->uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str );
+  }
+  	
+  if ( NULL == livetv->uri )
   {  	
   	gmyth_debug( "Couldn't parse the URI to start LiveTV! [ uri = %s ]", livetv->proginfo->pathname->str );
   	goto done;  	
   }
 
-	if ( !gmyth_file_transfer_open( livetv->file_transfer, uri != NULL ? gmyth_uri_get_path(uri) : 
+	if ( !gmyth_file_transfer_open( livetv->file_transfer, livetv->uri != NULL ? gmyth_uri_get_path(livetv->uri) : 
 				livetv->proginfo->pathname->str ) )
 	{
 		gmyth_debug( "Error: couldn't open the FileTransfer from LiveTV source!" );
@@ -570,11 +625,13 @@
 	g_static_mutex_unlock( &lock );
 
 done:
+	/*
 	if ( uri != NULL )
 	{
 		g_object_unref( uri );
 		uri = NULL;
-	}	
+	}
+	*/	
 	
 	return livetv->file_transfer;
 	
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_livetv.h
--- a/gmyth/src/gmyth_livetv.h	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_livetv.h	Fri Jan 26 19:08:17 2007 +0000
@@ -72,6 +72,7 @@
 	GMythFileTransfer 	*file_transfer;
 	
 	GMythMonitorHandler *monitor;
+	GMythURI						*uri;
 
 	gboolean 						is_livetv;
 	gboolean 						setup_done;
@@ -87,6 +88,7 @@
 
 gboolean gmyth_livetv_setup (GMythLiveTV *livetv, GMythBackendInfo *backend_info);
 gboolean gmyth_livetv_channel_setup ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info );
+gboolean gmyth_livetv_channel_name_setup ( GMythLiveTV *livetv, gchar* channel, GMythBackendInfo *backend_info );
 gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv );
 
 GMythFileTransfer *gmyth_livetv_create_file_transfer( GMythLiveTV *livetv );
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_programinfo.c
--- a/gmyth/src/gmyth_programinfo.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_programinfo.c	Fri Jan 26 19:08:17 2007 +0000
@@ -403,37 +403,42 @@
     prog->channame = gmyth_string_list_get_string (slist, 7);
     prog->pathname = gmyth_string_list_get_string (slist, 8);
     prog->filesize = gmyth_string_list_get_int64 (slist, 9);
+    gmyth_string_list_get_int64 (slist, 10);
 
-    prog->startts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 10) ); //DATETIME_TO_LIST(startts)
-    prog->endts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 11) ); //DATETIME_TO_LIST(endts)
-    prog->duplicate = gmyth_string_list_get_int (slist, 12);
-    prog->shareable = gmyth_string_list_get_int (slist, 13);
-    prog->findid = gmyth_string_list_get_int (slist, 14);
-    prog->hostname = gmyth_string_list_get_string (slist, 15);
-    prog->sourceid = gmyth_string_list_get_int (slist, 16);
-    prog->cardid = gmyth_string_list_get_int (slist, 17);
-    prog->inputid = gmyth_string_list_get_int (slist, 18);
-    prog->recpriority = gmyth_string_list_get_int (slist, 19);
-    prog->reactivate = gmyth_string_list_get_int (slist, 20);
-    prog->recordid = gmyth_string_list_get_int (slist, 21);
-    gmyth_string_list_get_int (slist, 22);
+    prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
+    					(time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts)
+    prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
+    					(time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts)
+    prog->duplicate = gmyth_string_list_get_int (slist, 13);
+    prog->shareable = gmyth_string_list_get_int (slist, 14);
+    prog->findid = gmyth_string_list_get_int (slist, 15);
+    prog->hostname = gmyth_string_list_get_string (slist, 16);
+    prog->sourceid = gmyth_string_list_get_int (slist, 17);
+    prog->cardid = gmyth_string_list_get_int (slist, 18);
+    prog->inputid = gmyth_string_list_get_int (slist, 19);
+    prog->recpriority = gmyth_string_list_get_int (slist, 20);
+    prog->reactivate = gmyth_string_list_get_int (slist, 21);
+    prog->recordid = gmyth_string_list_get_int (slist, 22);
     gmyth_string_list_get_int (slist, 23);
     gmyth_string_list_get_int (slist, 24);
-    prog->recstartts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 25) ); //DATETIME_TO_LIST(recstartts)
-    prog->recendts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 26) ); //DATETIME_TO_LIST(recendts)
-    prog->repeat = gmyth_string_list_get_int (slist, 27);
-    prog->programflags = gmyth_string_list_get_int (slist, 28);
-    prog->recgroup = gmyth_string_list_get_string (slist, 29); //prog->(recgroup != "") ? recgroup : "Default")
-    prog->chancommfree = gmyth_string_list_get_int (slist, 30);
-    prog->chanOutputFilters = gmyth_string_list_get_string (slist, 31);
-    prog->seriesid = gmyth_string_list_get_string (slist, 32);
-    prog->programid = gmyth_string_list_get_string (slist, 33);
-    prog->lastmodified = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 34) ); //DATETIME_TO_LIST(lastmodified)
-    gmyth_string_list_get_int (slist, 35); //FLOAT_TO_LIST(stars)
-    prog->originalAirDate = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 36) ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
-    prog->hasAirDate = gmyth_string_list_get_int (slist, 37);
-    prog->playgroup = gmyth_string_list_get_string (slist, 38); //prog->(playgroup != "") ? playgroup : "Default")
-    prog->recpriority2 = gmyth_string_list_get_int (slist, 39);
+    gmyth_string_list_get_int (slist, 25);
+    prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
+    					(time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts)
+    prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
+    					(time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts)
+    prog->repeat = gmyth_string_list_get_int (slist, 28);
+    prog->programflags = gmyth_string_list_get_int (slist, 29);
+    prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default")
+    prog->chancommfree = gmyth_string_list_get_int (slist, 31);
+    prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32);
+    prog->seriesid = gmyth_string_list_get_string (slist, 33);
+    prog->programid = gmyth_string_list_get_string (slist, 34);
+    prog->lastmodified = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 35) ); //DATETIME_TO_LIST(lastmodified)
+    gmyth_string_list_get_int (slist, 36); //FLOAT_TO_LIST(stars)
+    prog->originalAirDate = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 37) ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
+    prog->hasAirDate = gmyth_string_list_get_int (slist, 38);
+    prog->playgroup = gmyth_string_list_get_string (slist, 39); //prog->(playgroup != "") ? playgroup : "Default")
+    prog->recpriority2 = gmyth_string_list_get_int (slist, 40);
    
     return prog;
 }
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_recorder.c
--- a/gmyth/src/gmyth_recorder.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_recorder.c	Fri Jan 26 19:08:17 2007 +0000
@@ -258,16 +258,16 @@
  * certain channel actually exists.
  * 
  * @param recorder The GMythRecorder instance.
- * @param channel	 The new channel to be checked.
+ * @param channel	 The new channel to be checked (string format).
  * @return true if success, false if any error happens.
  */
 gboolean
-gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel)
+gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel)
 {
 	GMythStringList *str_list;
 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
 	
-	gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
+	gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
 	
 	str_list = gmyth_string_list_new ();
 	
@@ -275,7 +275,7 @@
 	
 	gmyth_string_list_append_string (str_list, tmp_str);
 	gmyth_string_list_append_string (str_list, g_string_new ("CHECK_CHANNEL"));
-	gmyth_string_list_append_int (str_list, channel);
+	gmyth_string_list_append_char_array (str_list, channel);
 
 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 	
@@ -298,6 +298,19 @@
 
 }
 
+/** Send a CHECK_CHANNEL command request to the backend, in order to find if a 
+ * certain channel actually exists.
+ * 
+ * @param recorder The GMythRecorder instance.
+ * @param channel	 The new channel to be checked (decimal integer value).
+ * @return true if success, false if any error happens.
+ */
+gboolean
+gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel)
+{
+	return gmyth_recorder_check_channel_name( recorder, g_strdup_printf( "%d", channel ) );
+}
+
 /** Send a SET_CHANNEL command request to the backend, to start streaming on another 
  * TV content channel.
  * 
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_recorder.h
--- a/gmyth/src/gmyth_recorder.h	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_recorder.h	Fri Jan 26 19:08:17 2007 +0000
@@ -89,6 +89,8 @@
 
 gboolean gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel);
 
+gboolean gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel);
+
 gboolean gmyth_recorder_set_channel   (GMythRecorder *recorder,
                                        gint channel);
                                          
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_tvchain.c
--- a/gmyth/src/gmyth_tvchain.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_tvchain.c	Fri Jan 26 19:08:17 2007 +0000
@@ -383,7 +383,7 @@
 	if (proginfo) {
 		proginfo->pathname = g_string_prepend (proginfo->pathname, entry->hostprefix->str);
 	} else {
-		g_warning ("tvchain_entry_to_program( chan id = %s, starttime = %lld) failed!", entry->chanid->str, entry->starttime);
+		g_warning ("tvchain_entry_to_program( chan id = %s, starttime = %lld) failed!", entry->chanid->str, entry->starttime->tv_sec);
 	}
 
 	return proginfo;
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_uri.c
--- a/gmyth/src/gmyth_uri.c	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_uri.c	Fri Jan 26 19:08:17 2007 +0000
@@ -216,12 +216,14 @@
 	gint 		colonIdx;
 	gint 		shashIdx;
 	gint 		eIdx;
-	gchar 	    *host;
+	gchar 	*host;
 	gint 		eblacketIdx;
 	gint 		hostLen;
 	gint 		sharpIdx;
+	/*
 	gint 		questionIdx;
 	gint 		queryLen;
+	*/
 	
 	uriLen = strlen(value);
 	uri->uri = g_string_new( value );
@@ -355,10 +357,10 @@
 	
 }
 
-gint
-gmyth_uri_get_channel_num( GMythURI* uri )
+gchar*
+gmyth_uri_get_channel_name( GMythURI* uri )
 {
-	gint channel = -1;
+	gchar* channel = NULL;
 	
 	g_return_val_if_fail( uri != NULL && uri->uri != NULL && uri->uri->str != NULL, FALSE );
 	
@@ -366,23 +368,37 @@
 	
 	if ( channel_query != NULL )
 	{
-		gmyth_debug( "Channel is in the following URI segment: %s", channel_query );
+		gmyth_debug( "TV Channel is in the following URI segment: %s", channel_query );
 		
 		gchar **chan_key_value = g_strsplit( gmyth_uri_get_query( uri ), "=", 2 );
 		
-		gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] );
-		
+		/* gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] ); */
+
 		if ( chan_key_value[1] != NULL )
 		{
-			channel = g_ascii_strtoull( chan_key_value[1], NULL, 10 ); 
+			channel = g_strdup( chan_key_value[1] ); 
 		}
-		
-		if ( chan_key_value )		
+
+		if ( chan_key_value != NULL )		
 			g_strfreev( chan_key_value );
 	}
 	
-	gmyth_debug( "Got channel decimal value from the URI: %d", channel );
-		
+	gmyth_debug( "Got channel decimal value from the URI: %s", channel );
+
 	return channel;
 	
 }
+
+gint
+gmyth_uri_get_channel_num( GMythURI* uri )
+{
+	gchar *channel_name = gmyth_uri_get_channel_name( uri );
+	
+	if ( channel_name != NULL )
+	{
+		return g_ascii_strtoull( channel_name, NULL, 10 ); 
+	}
+	
+	return -1;
+	
+}
diff -r bbf456814771 -r 0a8fe4427e41 gmyth/src/gmyth_uri.h
--- a/gmyth/src/gmyth_uri.h	Thu Jan 25 21:40:30 2007 +0000
+++ b/gmyth/src/gmyth_uri.h	Fri Jan 26 19:08:17 2007 +0000
@@ -108,6 +108,7 @@
 gboolean 		gmyth_uri_is_equals ( GMythURI* uri1, GMythURI* uri2 );
 gboolean		gmyth_uri_is_livetv ( GMythURI* uri );
 gint				gmyth_uri_get_channel_num( GMythURI* uri );
+gchar*			gmyth_uri_get_channel_name( GMythURI* uri );
 
 
 #define 		gmyth_uri_get_host(urip) 			( urip->host != NULL ? urip->host->str : "" )