# HG changeset patch
# User rosfran
# Date 1166624738 0
# Node ID 803a006ca67849ebb7fefde5af21b0797cba7b43
# Parent  1cf29cf20fb376ce3e5f008e2bb054c5f4e8ee67
[svn r235] Added filters to some MythTV backend messages.

diff -r 1cf29cf20fb3 -r 803a006ca678 gmyth/src/gmyth_file_transfer.c
--- a/gmyth/src/gmyth_file_transfer.c	Wed Dec 20 01:03:38 2006 +0000
+++ b/gmyth/src/gmyth_file_transfer.c	Wed Dec 20 14:25:38 2006 +0000
@@ -596,36 +596,6 @@
 	        gmyth_debug ("Total transfer data read: %d\n", total_read);
         }
         g_free (data_buffer);
-	    } else {
-				transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE(transfer);
-				
-				if ( transfer->priv != NULL && transfer->priv->livetv != NULL )
-				{
-				
-					total_read = GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN;	
-				
-			  	if ( transfer->priv->do_next_program_chain )
-			  	{			  					  		
-			  		
-			  		g_mutex_lock( transfer->mutex );
-			  		
-			  		ret = gmyth_livetv_next_program_chain( transfer->priv->livetv );
-			  		
-			  		g_mutex_unlock( transfer->mutex );
-			  		
-						if ( !ret )
-						{
-							gmyth_debug( "Cannot change to the next program chain!" );
-						}
-						else
-						{
-							gmyth_debug( "OK!!! MOVED to the next program chain [%s]!", 
-													(gmyth_tvchain_get_id( transfer->priv->livetv->tvchain ))->str );
-						}
-						
-			  	}
-			  	
-				} /* if */
       } /* if */
     } else {
     	total_read = GMYTHTV_FILE_TRANSFER_READ_ERROR;
@@ -637,6 +607,32 @@
     strlist = NULL;
   }
   
+  if ( bytes_sent == 0 && max_tries == 0 ) 
+	{
+		gmyth_debug( "Trying to move to the next program chain..." );
+		transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE(transfer);
+		
+		if ( transfer->priv != NULL && transfer->priv->livetv != NULL &&
+					transfer->priv->do_next_program_chain )
+		{
+		
+			total_read = GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN;	
+		
+	  		g_mutex_lock( transfer->mutex );
+	  		
+	  		ret = gmyth_livetv_next_program_chain( transfer->priv->livetv );
+	  		
+	  		g_mutex_unlock( transfer->mutex );
+  		
+			if ( !ret )
+				gmyth_debug( "Cannot change to the next program chain!" );
+			else
+				gmyth_debug( "OK!!! MOVED to the next program chain [%s]!", 
+										(gmyth_tvchain_get_id( transfer->priv->livetv->tvchain ))->str );						
+		}
+
+	} /* if */
+  
   myth_control_release_context( );
   g_string_free (query, TRUE);
 
diff -r 1cf29cf20fb3 -r 803a006ca678 gmyth/src/gmyth_livetv.c
--- a/gmyth/src/gmyth_livetv.c	Wed Dec 20 01:03:38 2006 +0000
+++ b/gmyth/src/gmyth_livetv.c	Wed Dec 20 14:25:38 2006 +0000
@@ -157,21 +157,23 @@
 		
 		case GMYTH_BACKEND_PROGRAM_INFO_CHANGED:
 		{
-			gmyth_debug( "LIVETV Program Changed event received [ msg = %s ]\n", message );
-			gmyth_debug( "OK!!! MOVED to the next program chain [%s]!", 
-									(gmyth_tvchain_get_id( live_tv->tvchain ))->str );
-			/* advertises the FileTransfer about the program info changed */
-			if ( live_tv->file_transfer != NULL )
-			{
-				gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" );
-				
-				gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer,
-	             msg_code, (gpointer)live_tv );
-	             
-	      //gmyth_livetv_monitor_handler_stop( live_tv );	      
-			} else
-				gmyth_debug( "LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
-			/*}*/
+			gmyth_debug( "LIVETV Program Changed request received [ msg = %s ]. Watching if the new "\
+				"TV Chain ID is the same as the old one...\n", message );
+			if ( g_ascii_strcasecmp ( message, (gmyth_tvchain_get_id( live_tv->tvchain ))->str ) != 0 ) {				
+				gmyth_debug( "OK!!! MOVED to the next program chain [actual == %s]!", 
+										(gmyth_tvchain_get_id( live_tv->tvchain ))->str );
+				/* advertises the FileTransfer about the program info changed */
+				if ( live_tv->file_transfer != NULL )
+				{
+					gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" );
+					
+					gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer,
+		             msg_code, (gpointer)live_tv );
+		             
+		      //gmyth_livetv_monitor_handler_stop( live_tv );	      
+				} else
+					gmyth_debug( "LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");				
+			}
 			break;
 		}
 		default:
diff -r 1cf29cf20fb3 -r 803a006ca678 gmyth/src/gmyth_monitor_handler.c
--- a/gmyth/src/gmyth_monitor_handler.c	Wed Dec 20 01:03:38 2006 +0000
+++ b/gmyth/src/gmyth_monitor_handler.c	Wed Dec 20 14:25:38 2006 +0000
@@ -322,8 +322,8 @@
   	{	        	
   	
     	if ( g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_CHAIN" ) ||
-    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) ||
-    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "SCHEDULE_CHANGE" ) ||
+    			/* g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) || 
+    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "SCHEDULE_CHANGE" ) || */
     			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_WATCH" ) )
     	{
     		gmyth_debug( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", *back_msg_action );