[svn r448] Fills a list with all the added program info into the TV Chain. trunk
authorrosfran
Fri Mar 23 15:14:43 2007 +0000 (2007-03-23)
branchtrunk
changeset 4434d883f3edcdd
parent 442 db17a60b9b42
child 444 d6603c86582f
[svn r448] Fills a list with all the added program info into the TV Chain.
gmyth/src/gmyth_programinfo.c
gmyth/src/gmyth_programinfo.h
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_recorder.h
     1.1 --- a/gmyth/src/gmyth_programinfo.c	Fri Mar 23 15:08:55 2007 +0000
     1.2 +++ b/gmyth/src/gmyth_programinfo.c	Fri Mar 23 15:14:43 2007 +0000
     1.3 @@ -469,3 +469,24 @@
     1.4          prog->hasAirDate,
     1.5          gmyth_program_info_non_null_value(prog->playgroup) );
     1.6  }
     1.7 +
     1.8 +/**
     1.9 + * Say if an instance of a GMythProgramInfo is equals to another one.
    1.10 + * 
    1.11 + * @param prog The first GMythProgramInfo instance.
    1.12 + * @param prog The second GMythProgramInfo instance.
    1.13 + * 
    1.14 + * @return <code>true</code>, if the program infos are equals.
    1.15 + */
    1.16 +gboolean
    1.17 +gmyth_program_info_is_equals( const GMythProgramInfo* prog1, const GMythProgramInfo* prog2 )
    1.18 +{
    1.19 +    if ( ( strcmp( gmyth_program_info_non_null_value( prog1->title ), 
    1.20 +            gmyth_program_info_non_null_value( prog2->title ) ) == 0 ) ||
    1.21 +         ( strcmp( gmyth_program_info_non_null_value( prog1->pathname ), 
    1.22 +            gmyth_program_info_non_null_value( prog2->pathname ) ) == 0 ) )
    1.23 +        return TRUE;
    1.24 +    else
    1.25 +        return FALSE;
    1.26 +
    1.27 +}
    1.28 \ No newline at end of file
     2.1 --- a/gmyth/src/gmyth_programinfo.h	Fri Mar 23 15:08:55 2007 +0000
     2.2 +++ b/gmyth/src/gmyth_programinfo.h	Fri Mar 23 15:14:43 2007 +0000
     2.3 @@ -159,6 +159,8 @@
     2.4  
     2.5  const gchar*		gmyth_program_info_to_string( const GMythProgramInfo* prog );
     2.6  
     2.7 +gboolean            gmyth_program_info_is_equals( const GMythProgramInfo* prog1, const GMythProgramInfo* prog2 );
     2.8 +
     2.9  G_END_DECLS
    2.10  
    2.11  #endif /*_GMYTH_PROGRAMINFO_H*/
     3.1 --- a/gmyth/src/gmyth_recorder.c	Fri Mar 23 15:08:55 2007 +0000
     3.2 +++ b/gmyth/src/gmyth_recorder.c	Fri Mar 23 15:14:43 2007 +0000
     3.3 @@ -27,7 +27,7 @@
     3.4   * along with this program; if not, write to the Free Software
     3.5   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     3.6   */
     3.7 - 
     3.8 +
     3.9  #ifdef HAVE_CONFIG_H
    3.10  #include "config.h"
    3.11  #endif
    3.12 @@ -42,14 +42,14 @@
    3.13  
    3.14  #define	 GMYTHTV_RECORDER_HEADER			"QUERY_RECORDER"
    3.15  
    3.16 -static void gmyth_recorder_class_init          (GMythRecorderClass *klass);
    3.17 -static void gmyth_recorder_init                (GMythRecorder *object);
    3.18 +static void gmyth_recorder_class_init(GMythRecorderClass *klass);
    3.19 +static void gmyth_recorder_init(GMythRecorder *object);
    3.20  
    3.21 -static void gmyth_recorder_dispose  (GObject *object);
    3.22 -static void gmyth_recorder_finalize (GObject *object);
    3.23 +static void gmyth_recorder_dispose(GObject *object);
    3.24 +static void gmyth_recorder_finalize(GObject *object);
    3.25  
    3.26  G_DEFINE_TYPE(GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
    3.27 -    
    3.28 +
    3.29  static void
    3.30  gmyth_recorder_class_init (GMythRecorderClass *klass)
    3.31  {
    3.32 @@ -62,38 +62,33 @@
    3.33  }
    3.34  
    3.35  static void
    3.36 -gmyth_recorder_init (GMythRecorder *gmyth_remote_encoder)
    3.37 -{
    3.38 +gmyth_recorder_init(GMythRecorder *gmyth_remote_encoder) {
    3.39  }
    3.40  
    3.41  static void
    3.42 -gmyth_recorder_dispose  (GObject *object)
    3.43 -{
    3.44 -  GMythRecorder *recorder = GMYTH_RECORDER(object);
    3.45 -  
    3.46 -  gmyth_recorder_close(recorder);
    3.47 -  
    3.48 -	if ( recorder->myth_socket != NULL ) {
    3.49 -		g_object_unref (recorder->myth_socket);
    3.50 -		recorder->myth_socket = NULL;
    3.51 -	}
    3.52 -    
    3.53 -	G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
    3.54 +gmyth_recorder_dispose(GObject *object) {
    3.55 +    GMythRecorder *recorder=  GMYTH_RECORDER(object);
    3.56 +
    3.57 +    gmyth_recorder_close(recorder);
    3.58 +
    3.59 +    if ( recorder->myth_socket != NULL) {
    3.60 +        g_object_unref(recorder->myth_socket);
    3.61 +        recorder->myth_socket = NULL;
    3.62 +    }
    3.63 +
    3.64 +    G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
    3.65  }
    3.66  
    3.67 +static void
    3.68 +gmyth_recorder_finalize(GObject *object) {
    3.69 +    g_signal_handlers_destroy(object);
    3.70  
    3.71 -static void
    3.72 -gmyth_recorder_finalize (GObject *object)
    3.73 -{
    3.74 -	g_signal_handlers_destroy (object);
    3.75 -
    3.76 -  G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
    3.77 +    G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
    3.78  }
    3.79  
    3.80  void
    3.81 -gmyth_recorder_close  (GMythRecorder *recorder)
    3.82 -{
    3.83 -  gmyth_recorder_finish_recording( recorder );
    3.84 +gmyth_recorder_close(GMythRecorder *recorder) {
    3.85 +    gmyth_recorder_finish_recording( recorder);
    3.86  }
    3.87  
    3.88  /** Creates a new instance of GMythRecorder.
    3.89 @@ -101,16 +96,15 @@
    3.90   * @return a new instance of GMythRecorder.
    3.91   */
    3.92  GMythRecorder*
    3.93 -gmyth_recorder_new (int num, GString *hostname, gshort port)
    3.94 -{
    3.95 -	GMythRecorder *encoder = GMYTH_RECORDER ( g_object_new (
    3.96 -			GMYTH_RECORDER_TYPE, FALSE ));
    3.97 -			
    3.98 -	encoder->recorder_num = num;
    3.99 -	encoder->hostname = g_string_new (hostname->str);
   3.100 -	encoder->port = port;
   3.101 -	
   3.102 -	return encoder;
   3.103 +gmyth_recorder_new(int num, GString *hostname, gshort port) {
   3.104 +    GMythRecorder *encoder=  GMYTH_RECORDER ( g_object_new (
   3.105 +                    GMYTH_RECORDER_TYPE, FALSE ));
   3.106 +
   3.107 +    encoder->recorder_num = num;
   3.108 +    encoder->hostname = g_string_new(hostname->str);
   3.109 +    encoder->port = port;
   3.110 +
   3.111 +    return encoder;
   3.112  }
   3.113  
   3.114  /** Configures the remote encoder instance connecting it to Mythtv backend.
   3.115 @@ -120,26 +114,25 @@
   3.116   * @return TRUE if successfull, FALSE if any error happens.
   3.117   */
   3.118  gboolean
   3.119 -gmyth_recorder_setup (GMythRecorder *recorder)
   3.120 -{
   3.121 -	assert (recorder);
   3.122 -	gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__);
   3.123 +gmyth_recorder_setup(GMythRecorder *recorder) {
   3.124 +    assert (recorder);
   3.125 +    gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__);
   3.126  
   3.127 -	if (recorder->myth_socket == NULL) {
   3.128 -		
   3.129 -		recorder->myth_socket = gmyth_socket_new ();
   3.130 -		
   3.131 -		if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str, 
   3.132 -					recorder->port, TRUE ) ) {
   3.133 -			g_warning ("GMythRemoteEncoder: Connection to backend failed");	
   3.134 -			return FALSE;
   3.135 -		}
   3.136 -		
   3.137 -	} else {
   3.138 -		g_warning("Remote encoder socket already created\n");
   3.139 -	}
   3.140 +    if (recorder->myth_socket == NULL) {
   3.141  
   3.142 -	return TRUE;
   3.143 +        recorder->myth_socket = gmyth_socket_new ();
   3.144 +
   3.145 +        if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str,
   3.146 +                        recorder->port, TRUE ) ) {
   3.147 +            gmyth_debug ("GMythRemoteEncoder: Connection to backend failed");
   3.148 +            return FALSE;
   3.149 +        }
   3.150 +
   3.151 +    } else {
   3.152 +        gmyth_debug("Remote encoder socket already created\n");
   3.153 +    }
   3.154 +
   3.155 +    return TRUE;
   3.156  }
   3.157  
   3.158  /** Sends the SPAWN_LIVETV command through Mythtv protocol. This command
   3.159 @@ -150,36 +143,35 @@
   3.160   * @return true if success, false if any error happens.
   3.161   */
   3.162  gboolean
   3.163 -gmyth_recorder_spawntv (GMythRecorder *recorder, GString *tvchain_id)
   3.164 -{
   3.165 -	GMythStringList *str_list;
   3.166 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.167 -	
   3.168 -	gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str);
   3.169 -	
   3.170 -	str_list = gmyth_string_list_new ();
   3.171 -	
   3.172 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.173 -	
   3.174 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.175 -	gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   3.176 -	gmyth_string_list_append_string (str_list, tvchain_id);
   3.177 -	gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0)
   3.178 +gmyth_recorder_spawntv(GMythRecorder *recorder, GString *tvchain_id) {
   3.179 +    GMythStringList *str_list;
   3.180 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.181  
   3.182 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.183 -	
   3.184 +    gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str);
   3.185 +
   3.186 +    str_list = gmyth_string_list_new ();
   3.187 +
   3.188 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.189 +
   3.190 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.191 +    gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   3.192 +    gmyth_string_list_append_string (str_list, tvchain_id);
   3.193 +    gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0)
   3.194 +
   3.195 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.196 +
   3.197      g_string_free (tmp_str, TRUE);
   3.198 -    
   3.199 +
   3.200      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.201      if (tmp_str == NULL) {
   3.202 -    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.203 -    	return FALSE;
   3.204 -	}
   3.205 -	
   3.206 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.207 +        return FALSE;
   3.208 +    }
   3.209 +
   3.210      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.211 -    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.212 -	    g_object_unref (str_list);
   3.213 -    	return FALSE;
   3.214 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.215 +        g_object_unref (str_list);
   3.216 +        return FALSE;
   3.217      }
   3.218  
   3.219      g_object_unref (str_list);
   3.220 @@ -196,34 +188,33 @@
   3.221   * @return true if success, false if any error happens.
   3.222   */
   3.223  gboolean
   3.224 -gmyth_recorder_spawntv_no_tvchain (GMythRecorder *recorder)
   3.225 -{
   3.226 -	GMythStringList *str_list;
   3.227 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.228 -	
   3.229 -	gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__);
   3.230 -	
   3.231 -	str_list = gmyth_string_list_new ();
   3.232 -	
   3.233 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.234 -	
   3.235 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.236 -	gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   3.237 +gmyth_recorder_spawntv_no_tvchain(GMythRecorder *recorder) {
   3.238 +    GMythStringList *str_list;
   3.239 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.240  
   3.241 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.242 -	
   3.243 +    gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__);
   3.244 +
   3.245 +    str_list = gmyth_string_list_new ();
   3.246 +
   3.247 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.248 +
   3.249 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.250 +    gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   3.251 +
   3.252 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.253 +
   3.254      g_string_free (tmp_str, TRUE);
   3.255 -    
   3.256 +
   3.257      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.258      if (tmp_str == NULL) {
   3.259 -    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.260 -    	return FALSE;
   3.261 -	}
   3.262 -	
   3.263 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.264 +        return FALSE;
   3.265 +    }
   3.266 +
   3.267      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.268 -    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.269 -	    g_object_unref (str_list);
   3.270 -    	return FALSE;
   3.271 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   3.272 +        g_object_unref (str_list);
   3.273 +        return FALSE;
   3.274      }
   3.275  
   3.276      g_object_unref (str_list);
   3.277 @@ -237,31 +228,30 @@
   3.278   * @return true if success, false if any error happens.
   3.279   */
   3.280  gboolean
   3.281 -gmyth_recorder_stop_livetv (GMythRecorder *recorder)
   3.282 -{
   3.283 -	GMythStringList *str_list;
   3.284 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.285 +gmyth_recorder_stop_livetv(GMythRecorder *recorder) {
   3.286 +    GMythStringList *str_list;
   3.287 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.288  
   3.289 -	gmyth_debug ("[%s]", __FUNCTION__);
   3.290 +    gmyth_debug ("[%s]", __FUNCTION__);
   3.291  
   3.292 -	str_list = gmyth_string_list_new ();
   3.293 +    str_list = gmyth_string_list_new ();
   3.294  
   3.295 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.296 -	gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" );
   3.297 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.298 +    gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" );
   3.299  
   3.300 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.301 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.302  
   3.303 -	g_string_free (tmp_str, TRUE);
   3.304 +    g_string_free (tmp_str, TRUE);
   3.305  
   3.306 -	tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.307 -	if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.308 -		g_warning ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str);
   3.309 -		g_object_unref (str_list);
   3.310 -		return FALSE;
   3.311 -	}
   3.312 +    tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.313 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.314 +        gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str);
   3.315 +        g_object_unref (str_list);
   3.316 +        return FALSE;
   3.317 +    }
   3.318  
   3.319 -	g_object_unref (str_list);
   3.320 -	return TRUE;
   3.321 +    g_object_unref (str_list);
   3.322 +    return TRUE;
   3.323  
   3.324  }
   3.325  
   3.326 @@ -272,38 +262,37 @@
   3.327   * @return TRUE if success, FALSE if any error happens.
   3.328   */
   3.329  gboolean
   3.330 -gmyth_recorder_send_frontend_ready_command (GMythRecorder *recorder)
   3.331 -{
   3.332 -	GMythStringList *str_list;
   3.333 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.334 -	
   3.335 -	gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num );
   3.336 -	
   3.337 -	str_list = gmyth_string_list_new ();
   3.338 -	
   3.339 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.340 -	
   3.341 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.342 -	gmyth_string_list_append_string (str_list, g_string_new ("FRONTEND_READY"));
   3.343 +gmyth_recorder_send_frontend_ready_command(GMythRecorder *recorder) {
   3.344 +    GMythStringList *str_list;
   3.345 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.346  
   3.347 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.348 -	
   3.349 -  g_string_free (tmp_str, TRUE);
   3.350 -    
   3.351 -  tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.352 -  if (tmp_str == NULL) {
   3.353 -  	g_warning ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", __FUNCTION__, tmp_str->str);
   3.354 -  	return FALSE;
   3.355 -	}
   3.356 -	
   3.357 -  if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.358 -  	g_warning ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str);
   3.359 +    gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num );
   3.360 +
   3.361 +    str_list = gmyth_string_list_new ();
   3.362 +
   3.363 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.364 +
   3.365 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.366 +    gmyth_string_list_append_string (str_list, g_string_new ("FRONTEND_READY"));
   3.367 +
   3.368 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.369 +
   3.370 +    g_string_free (tmp_str, TRUE);
   3.371 +
   3.372 +    tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.373 +    if (tmp_str == NULL) {
   3.374 +        gmyth_debug ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", __FUNCTION__, tmp_str->str);
   3.375 +        return FALSE;
   3.376 +    }
   3.377 +
   3.378 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.379 +        gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str);
   3.380 +        g_object_unref (str_list);
   3.381 +        return FALSE;
   3.382 +    }
   3.383 +
   3.384      g_object_unref (str_list);
   3.385 -  	return FALSE;
   3.386 -  }
   3.387 -
   3.388 -  g_object_unref (str_list);
   3.389 -  return TRUE;
   3.390 +    return TRUE;
   3.391  
   3.392  }
   3.393  
   3.394 @@ -315,35 +304,35 @@
   3.395   * @return true if success, false if any error happens.
   3.396   */
   3.397  gboolean
   3.398 -gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel)
   3.399 -{
   3.400 -	GMythStringList *str_list;
   3.401 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.402 -	
   3.403 -	gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
   3.404 -	
   3.405 -	str_list = gmyth_string_list_new ();
   3.406 -	
   3.407 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.408 -	
   3.409 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.410 -	gmyth_string_list_append_string (str_list, g_string_new ("CHECK_CHANNEL"));
   3.411 -	gmyth_string_list_append_char_array (str_list, channel);
   3.412 +gmyth_recorder_check_channel_name(GMythRecorder *recorder,
   3.413 +        gchar* channel) {
   3.414 +    GMythStringList *str_list;
   3.415 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.416  
   3.417 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.418 -	
   3.419 +    gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
   3.420 +
   3.421 +    str_list = gmyth_string_list_new ();
   3.422 +
   3.423 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.424 +
   3.425 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.426 +    gmyth_string_list_append_string (str_list, g_string_new ("CHECK_CHANNEL"));
   3.427 +    gmyth_string_list_append_char_array (str_list, channel);
   3.428 +
   3.429 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.430 +
   3.431      g_string_free (tmp_str, TRUE);
   3.432 -    
   3.433 +
   3.434      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.435      if (tmp_str == NULL) {
   3.436 -    	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.437 -    	return FALSE;
   3.438 -	}
   3.439 -	
   3.440 +        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.441 +        return FALSE;
   3.442 +    }
   3.443 +
   3.444      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0 ) {
   3.445 -    	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.446 -	    g_object_unref (str_list);
   3.447 -    	return FALSE;
   3.448 +        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.449 +        g_object_unref (str_list);
   3.450 +        return FALSE;
   3.451      }
   3.452  
   3.453      g_object_unref (str_list);
   3.454 @@ -359,9 +348,9 @@
   3.455   * @return true if success, false if any error happens.
   3.456   */
   3.457  gboolean
   3.458 -gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel)
   3.459 -{
   3.460 -	return gmyth_recorder_check_channel_name( recorder, g_strdup_printf( "%d", channel ) );
   3.461 +gmyth_recorder_check_channel(GMythRecorder *recorder, gint channel) {
   3.462 +    return gmyth_recorder_check_channel_name( recorder, g_strdup_printf( "%d",
   3.463 +            channel));
   3.464  }
   3.465  
   3.466  /** Send a SET_CHANNEL command request to the backend, to start streaming on another 
   3.467 @@ -372,35 +361,34 @@
   3.468   * @return true if success, false if any error happens.
   3.469   */
   3.470  gboolean
   3.471 -gmyth_recorder_set_channel (GMythRecorder *recorder, gint channel)
   3.472 -{
   3.473 -	GMythStringList *str_list;
   3.474 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.475 -	
   3.476 -	gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
   3.477 -	
   3.478 -	str_list = gmyth_string_list_new ();
   3.479 -	
   3.480 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.481 -	
   3.482 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.483 -	gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   3.484 -	gmyth_string_list_append_int (str_list, channel);
   3.485 +gmyth_recorder_set_channel(GMythRecorder *recorder, gint channel) {
   3.486 +    GMythStringList *str_list;
   3.487 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.488  
   3.489 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.490 -	
   3.491 +    gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
   3.492 +
   3.493 +    str_list = gmyth_string_list_new ();
   3.494 +
   3.495 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.496 +
   3.497 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.498 +    gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   3.499 +    gmyth_string_list_append_int (str_list, channel);
   3.500 +
   3.501 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.502 +
   3.503      g_string_free (tmp_str, TRUE);
   3.504 -    
   3.505 +
   3.506      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.507      if (tmp_str == NULL) {
   3.508 -    	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.509 -    	return FALSE;
   3.510 -	}
   3.511 -	
   3.512 +        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.513 +        return FALSE;
   3.514 +    }
   3.515 +
   3.516      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.517 -    	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.518 -	    g_object_unref (str_list);
   3.519 -    	return FALSE;
   3.520 +        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   3.521 +        g_object_unref (str_list);
   3.522 +        return FALSE;
   3.523      }
   3.524  
   3.525      g_object_unref (str_list);
   3.526 @@ -416,35 +404,35 @@
   3.527   * @return true if success, false if any error happens.
   3.528   */
   3.529  gboolean
   3.530 -gmyth_recorder_set_channel_name (GMythRecorder *recorder, const gchar* channel)
   3.531 -{
   3.532 -	GMythStringList *str_list;
   3.533 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.534 -	
   3.535 -	gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel);
   3.536 -	
   3.537 -	str_list = gmyth_string_list_new ();
   3.538 -	
   3.539 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.540 -	
   3.541 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.542 -	gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   3.543 -	gmyth_string_list_append_char_array (str_list, channel);
   3.544 +gmyth_recorder_set_channel_name(GMythRecorder *recorder,
   3.545 +        const gchar* channel) {
   3.546 +    GMythStringList *str_list;
   3.547 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.548  
   3.549 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.550 -	
   3.551 +    gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel);
   3.552 +
   3.553 +    str_list = gmyth_string_list_new ();
   3.554 +
   3.555 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.556 +
   3.557 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.558 +    gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   3.559 +    gmyth_string_list_append_char_array (str_list, channel);
   3.560 +
   3.561 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.562 +
   3.563      g_string_free (tmp_str, TRUE);
   3.564 -    
   3.565 +
   3.566      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.567      if (tmp_str == NULL) {
   3.568 -    	g_warning ("[%s] SET_CHANNEL name request returned NULL!", __FUNCTION__);
   3.569 -    	return FALSE;
   3.570 -	}
   3.571 -	
   3.572 -    if (tmp_str!= NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */ ) {
   3.573 -    	g_warning ("XXXXXX[%s] SET_CHANNEL name request returned not ok", __FUNCTION__);
   3.574 -	    g_object_unref (str_list);
   3.575 -    	return FALSE;
   3.576 +        gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!", __FUNCTION__);
   3.577 +        return FALSE;
   3.578 +    }
   3.579 +
   3.580 +    if (tmp_str!= NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */) {
   3.581 +        gmyth_debug ("XXXXXX[%s] SET_CHANNEL name request returned not ok", __FUNCTION__);
   3.582 +        g_object_unref (str_list);
   3.583 +        return FALSE;
   3.584      }
   3.585  
   3.586      g_object_unref (str_list);
   3.587 @@ -468,35 +456,35 @@
   3.588   * @return true if success, false if any error happens.
   3.589   */
   3.590  gboolean
   3.591 -gmyth_recorder_change_channel (GMythRecorder *recorder, const GMythRecorderChannelChangeDirection direction)
   3.592 -{
   3.593 -	GMythStringList *str_list;
   3.594 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.595 -	
   3.596 -	gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction);
   3.597 -	
   3.598 -	str_list = gmyth_string_list_new ();
   3.599 -	
   3.600 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.601 -	
   3.602 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.603 -	gmyth_string_list_append_string (str_list, g_string_new ("CHANGE_CHANNEL"));
   3.604 -	gmyth_string_list_append_int (str_list, direction);
   3.605 +gmyth_recorder_change_channel(GMythRecorder *recorder,
   3.606 +        const GMythRecorderChannelChangeDirection direction) {
   3.607 +    GMythStringList *str_list;
   3.608 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.609  
   3.610 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.611 -	
   3.612 +    gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction);
   3.613 +
   3.614 +    str_list = gmyth_string_list_new ();
   3.615 +
   3.616 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.617 +
   3.618 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.619 +    gmyth_string_list_append_string (str_list, g_string_new ("CHANGE_CHANNEL"));
   3.620 +    gmyth_string_list_append_int (str_list, direction);
   3.621 +
   3.622 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.623 +
   3.624      g_string_free (tmp_str, TRUE);
   3.625 -    
   3.626 +
   3.627      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.628      if (tmp_str == NULL) {
   3.629 -    	g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
   3.630 -    	return FALSE;
   3.631 -	}
   3.632 -	
   3.633 +        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
   3.634 +        return FALSE;
   3.635 +    }
   3.636 +
   3.637      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) {
   3.638 -    	g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
   3.639 -	    g_object_unref (str_list);
   3.640 -    	return FALSE;
   3.641 +        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
   3.642 +        g_object_unref (str_list);
   3.643 +        return FALSE;
   3.644      }
   3.645  
   3.646      g_object_unref (str_list);
   3.647 @@ -511,34 +499,33 @@
   3.648   * @return true if success, false if any error happens.
   3.649   */
   3.650  gboolean
   3.651 -gmyth_recorder_pause_recording ( GMythRecorder *recorder )
   3.652 -{
   3.653 -	GMythStringList *str_list;
   3.654 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.655 -	
   3.656 -	gmyth_debug ("[%s] PAUSE", __FUNCTION__);
   3.657 -	
   3.658 -	str_list = gmyth_string_list_new ();
   3.659 -	
   3.660 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.661 -	
   3.662 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.663 -	gmyth_string_list_append_string (str_list, g_string_new ("PAUSE"));
   3.664 +gmyth_recorder_pause_recording( GMythRecorder *recorder) {
   3.665 +    GMythStringList *str_list;
   3.666 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.667  
   3.668 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.669 -	
   3.670 +    gmyth_debug ("[%s] PAUSE", __FUNCTION__);
   3.671 +
   3.672 +    str_list = gmyth_string_list_new ();
   3.673 +
   3.674 +    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.675 +
   3.676 +    gmyth_string_list_append_string (str_list, tmp_str);
   3.677 +    gmyth_string_list_append_string (str_list, g_string_new ("PAUSE"));
   3.678 +
   3.679 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.680 +
   3.681      g_string_free (tmp_str, TRUE);
   3.682 -    
   3.683 +
   3.684      tmp_str = gmyth_string_list_get_string (str_list, 0);
   3.685      if (tmp_str == NULL) {
   3.686 -    	g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   3.687 -    	return FALSE;
   3.688 -	}
   3.689 -	
   3.690 +        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   3.691 +        return FALSE;
   3.692 +    }
   3.693 +
   3.694      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   3.695 -    	g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   3.696 -	    g_object_unref (str_list);
   3.697 -    	return FALSE;
   3.698 +        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   3.699 +        g_object_unref (str_list);
   3.700 +        return FALSE;
   3.701      }
   3.702  
   3.703      g_object_unref (str_list);
   3.704 @@ -546,6 +533,21 @@
   3.705  
   3.706  }
   3.707  
   3.708 +static gboolean 
   3.709 +gmyth_recorder_find_if_program_exists( GMythRecorder* recorder, GMythProgramInfo* prog )
   3.710 +{
   3.711 +    GSList *lst = NULL;
   3.712 +    for ( lst = recorder->progs_info_list; lst != NULL; lst = g_slist_next( lst ) )
   3.713 +    {
   3.714 +        gmyth_debug ( "Got program info from list = [%s]", 
   3.715 +                gmyth_program_info_to_string( (GMythProgramInfo*)lst->data ) );
   3.716 +        if ( gmyth_program_info_is_equals ( prog, (GMythProgramInfo*)lst->data ) )
   3.717 +            return TRUE;
   3.718 +    }
   3.719 +    
   3.720 +    return FALSE;
   3.721 +}
   3.722 +
   3.723  /**
   3.724   * Requests the actual program info from the MythTV backend server.
   3.725   * 
   3.726 @@ -553,42 +555,50 @@
   3.727   * @return The actual program info.
   3.728   */
   3.729  GMythProgramInfo *
   3.730 -gmyth_recorder_get_current_program_info ( GMythRecorder *recorder )
   3.731 -{
   3.732 -	GMythStringList *str_list;
   3.733 -	GMythProgramInfo *program_info = gmyth_program_info_new();
   3.734 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.735 -	
   3.736 -	str_list = gmyth_string_list_new ();
   3.737 -	
   3.738 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   3.739 -	
   3.740 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.741 -	
   3.742 -	if ( recorder->myth_socket->mythtv_version >= 26 )
   3.743 -		gmyth_string_list_append_string (str_list, g_string_new ("GET_CURRENT_RECORDING"));
   3.744 -	else
   3.745 -		gmyth_string_list_append_string (str_list, g_string_new ("GET_PROGRAM_INFO"));
   3.746 +gmyth_recorder_get_current_program_info(
   3.747 +        GMythRecorder *recorder) {
   3.748 +    GMythStringList *str_list;
   3.749 +    GMythProgramInfo *program_info = gmyth_program_info_new();
   3.750 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.751  
   3.752 -	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.753 +    str_list = gmyth_string_list_new();
   3.754  
   3.755 -  g_string_free (tmp_str, TRUE);
   3.756 +    g_string_append_printf( tmp_str, " %d", recorder->recorder_num);
   3.757  
   3.758 -  if (str_list == NULL) {
   3.759 -  	g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", __FUNCTION__);
   3.760 -  	return FALSE;
   3.761 -	}
   3.762 -  
   3.763 -  program_info = gmyth_program_info_from_string_list( str_list );
   3.764 +    gmyth_string_list_append_string(str_list, tmp_str);
   3.765  
   3.766 -  if ( NULL == program_info || NULL == program_info->pathname || program_info->pathname->len <= 0 ) {
   3.767 -  	g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", __FUNCTION__);
   3.768 -    g_object_unref (program_info);
   3.769 -  	return NULL;
   3.770 -  }
   3.771 +    if ( recorder->myth_socket->mythtv_version >= 26)
   3.772 +        gmyth_string_list_append_string(str_list,
   3.773 +                g_string_new("GET_CURRENT_RECORDING"));
   3.774 +    else
   3.775 +        gmyth_string_list_append_string(str_list,
   3.776 +                g_string_new("GET_PROGRAM_INFO"));
   3.777  
   3.778 -  g_object_unref (str_list);
   3.779 -  return program_info;
   3.780 +    gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list);
   3.781 +
   3.782 +    g_string_free(tmp_str, TRUE);
   3.783 +
   3.784 +    if (str_list == NULL) {
   3.785 +        gmyth_debug(
   3.786 +                "[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!",
   3.787 +                __FUNCTION__);
   3.788 +        return FALSE;
   3.789 +    }
   3.790 +
   3.791 +    program_info = gmyth_program_info_from_string_list( str_list );
   3.792 +
   3.793 +    if ( NULL == program_info || NULL == program_info->pathname || program_info->pathname->len <= 0) {
   3.794 +        gmyth_debug(
   3.795 +                "GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!");
   3.796 +        g_object_unref(program_info);
   3.797 +        return NULL;
   3.798 +    }
   3.799 +    
   3.800 +    if ( !gmyth_recorder_find_if_program_exists( recorder, program_info ) )
   3.801 +        recorder->progs_info_list = g_slist_append( recorder->progs_info_list, program_info );
   3.802 +
   3.803 +    g_object_unref(str_list);
   3.804 +    return program_info;
   3.805  
   3.806  }
   3.807  
   3.808 @@ -599,64 +609,65 @@
   3.809   * @return The GMythRecorder instance.
   3.810   */
   3.811  GMythRecorder *
   3.812 -gmyth_recorder_get_recorder_from_num ( gint rec_id )
   3.813 -{
   3.814 -	GMythRecorder* recorder = NULL;
   3.815 -	GMythStringList *str_list;
   3.816 -	GString *tmp_str = g_string_new( "GET_RECORDER_FROM_NUM" );
   3.817 -	gint command_size = 0;
   3.818 -	
   3.819 -	gchar *recorder_host = NULL;
   3.820 -	gint recorder_port;
   3.821 -	
   3.822 -	str_list = gmyth_string_list_new ();
   3.823 -	
   3.824 -	/* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */
   3.825 -	 
   3.826 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.827 -	gmyth_string_list_append_int (str_list, rec_id);
   3.828 +gmyth_recorder_get_recorder_from_num( gint rec_id) {
   3.829 +    GMythRecorder* recorder=  NULL;
   3.830 +    GMythStringList *str_list;
   3.831 +    GString *tmp_str = g_string_new( "GET_RECORDER_FROM_NUM");
   3.832 +    gint command_size = 0;
   3.833  
   3.834 -	command_size = gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   3.835 +    gchar *recorder_host=  NULL;
   3.836 +    gint recorder_port;
   3.837  
   3.838 -  g_string_free (tmp_str, TRUE);
   3.839 +    str_list = gmyth_string_list_new();
   3.840  
   3.841 -  if (str_list == NULL) {
   3.842 -  	g_warning ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", 
   3.843 -		  			__FUNCTION__, rec_id);
   3.844 -  	return NULL;
   3.845 -	}
   3.846 -	
   3.847 -	if ( command_size > 0 )
   3.848 -	{
   3.849 -		recorder_host = gmyth_string_list_get_char_array( str_list, 0 );
   3.850 -		recorder_port = gmyth_string_list_get_int( str_list, 1 );
   3.851 -		
   3.852 -		if ( g_strstr_len( recorder_host, strlen(recorder_host), "nohost" ) != NULL )
   3.853 -		{
   3.854 -			gmyth_debug( "No available recorder with the recorder ID number %d!", rec_id );
   3.855 -		} else {
   3.856 -	  
   3.857 -		  recorder = gmyth_recorder_new( rec_id, g_string_new( recorder_host ), (gshort)recorder_port );
   3.858 -		
   3.859 -		  if ( NULL == recorder ) {
   3.860 -		  	g_warning ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", 
   3.861 -		  			__FUNCTION__, rec_id);
   3.862 -		    g_object_unref (recorder);
   3.863 -		  	return NULL;
   3.864 -		  }
   3.865 -		  
   3.866 -		}
   3.867 -	  
   3.868 -	} else {
   3.869 -		gmyth_debug( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", rec_id );
   3.870 -	}
   3.871 +    /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */
   3.872  
   3.873 -  g_object_unref (str_list);
   3.874 -  
   3.875 -  if ( recorder_host != NULL )
   3.876 -  	g_free( recorder_host );
   3.877 -  
   3.878 -  return recorder;
   3.879 +    gmyth_string_list_append_string(str_list, tmp_str);
   3.880 +    gmyth_string_list_append_int(str_list, rec_id);
   3.881 +
   3.882 +    command_size = gmyth_socket_sendreceive_stringlist(recorder->myth_socket,
   3.883 +            str_list);
   3.884 +
   3.885 +    g_string_free(tmp_str, TRUE);
   3.886 +
   3.887 +    if (str_list == NULL) {
   3.888 +        gmyth_debug(
   3.889 +                "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
   3.890 +                __FUNCTION__, rec_id);
   3.891 +        return NULL;
   3.892 +    }
   3.893 +
   3.894 +    if ( command_size > 0) {
   3.895 +        recorder_host = gmyth_string_list_get_char_array( str_list, 0 );
   3.896 +        recorder_port = gmyth_string_list_get_int( str_list, 1);
   3.897 +
   3.898 +        if ( g_strstr_len( recorder_host, strlen(recorder_host), "nohost")!= NULL) {
   3.899 +            gmyth_debug( "No available recorder with the recorder ID number %d!", rec_id );
   3.900 +        } else {
   3.901 +
   3.902 +            recorder = gmyth_recorder_new( rec_id,
   3.903 +                    g_string_new( recorder_host), (gshort)recorder_port);
   3.904 +
   3.905 +            if ( NULL == recorder) {
   3.906 +                gmyth_debug(
   3.907 +                        "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
   3.908 +                        __FUNCTION__, rec_id);
   3.909 +                g_object_unref(recorder);
   3.910 +                return NULL;
   3.911 +            }
   3.912 +
   3.913 +        }
   3.914 +
   3.915 +    } else {
   3.916 +        gmyth_debug( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", rec_id );
   3.917 +    }
   3.918 +
   3.919 +    g_object_unref(str_list);
   3.920 +
   3.921 +    if ( recorder_host != NULL)
   3.922 +        g_free( recorder_host);
   3.923 +
   3.924 +    return recorder;
   3.925  
   3.926  }
   3.927  
   3.928 @@ -667,92 +678,90 @@
   3.929   * @return The GMythProgramInfo next program info instance.
   3.930   */
   3.931  GMythProgramInfo *
   3.932 -gmyth_recorder_get_next_program_info ( GMythRecorder *recorder, const GMythRecorderBrowseDirection direction )
   3.933 -{
   3.934 -	GMythProgramInfo* actual_proginfo = NULL;
   3.935 -	GMythProgramInfo* program_info = NULL;
   3.936 -	GMythStringList *str_list;
   3.937 -	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   3.938 -	
   3.939 -	gchar *date = NULL;
   3.940 -  struct tm *tm;
   3.941 -  time_t t;
   3.942 -  
   3.943 -  actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
   3.944 -	
   3.945 -	str_list = gmyth_string_list_new ();
   3.946 -	
   3.947 -	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
   3.948 -	 
   3.949 -  t = time(NULL);
   3.950 -  tm = localtime(&t);
   3.951 -  date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d",
   3.952 -           tm->tm_year + 1900, tm->tm_mon + 1,
   3.953 -           tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
   3.954 +gmyth_recorder_get_next_program_info(
   3.955 +        GMythRecorder *recorder, const GMythRecorderBrowseDirection direction) {
   3.956 +    GMythProgramInfo* actual_proginfo=  NULL;
   3.957 +    GMythProgramInfo* program_info=  NULL;
   3.958 +    GMythStringList *str_list;
   3.959 +    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
   3.960  
   3.961 -	gmyth_string_list_append_string (str_list, tmp_str);
   3.962 -	gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO");
   3.963 -	gmyth_string_list_append_string (str_list, actual_proginfo->channame);
   3.964 -  gmyth_string_list_append_string (str_list, actual_proginfo->chanid);
   3.965 -  gmyth_string_list_append_int (str_list, direction);
   3.966 -  gmyth_string_list_append_char_array (str_list, date);
   3.967 -	
   3.968 -	if ( gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list) > 0 )
   3.969 -	{
   3.970 -  
   3.971 -	  if (str_list == NULL) {
   3.972 -	  	g_warning ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", 
   3.973 -			  			__FUNCTION__);
   3.974 -	  	goto done;
   3.975 -		}
   3.976 -		program_info = gmyth_program_info_new();
   3.977 -		
   3.978 -	  if ( NULL == program_info ) {
   3.979 -	  	g_warning ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", 
   3.980 -	  			__FUNCTION__);
   3.981 -	    g_object_unref (program_info);
   3.982 -	  	goto done;
   3.983 -	  }
   3.984 -	  
   3.985 -		program_info->title = gmyth_string_list_get_string (str_list, 0);
   3.986 -		program_info->subtitle = gmyth_string_list_get_string (str_list, 1);
   3.987 -		program_info->description = gmyth_string_list_get_string (str_list, 2);
   3.988 -		program_info->category = gmyth_string_list_get_string (str_list, 3);
   3.989 -		program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.990 -    					(time_t)gmyth_string_list_get_int (str_list, 4) ))->str );
   3.991 -		program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
   3.992 -    					(time_t)gmyth_string_list_get_int (str_list, 6) ))->str );
   3.993 -	
   3.994 -	  program_info->chansign = gmyth_string_list_get_string (str_list, 8);
   3.995 -	  program_info->pathname = gmyth_string_list_get_string (str_list, 9);
   3.996 -	  program_info->channame = gmyth_string_list_get_string (str_list, 10);
   3.997 -	  program_info->chanid = gmyth_string_list_get_string (str_list, 11);
   3.998 -	  if ( recorder->myth_socket->mythtv_version >= 12 ) {
   3.999 -	          program_info->seriesid = gmyth_string_list_get_string (str_list, 12);
  3.1000 -	          program_info->programid = gmyth_string_list_get_string (str_list, 13);
  3.1001 -	  }
  3.1002 -	  
  3.1003 -	  if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
  3.1004 -	  	( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 ) ) 
  3.1005 -	  {
  3.1006 -	  		gmyth_debug( "OK!!! Got the next program info..." );
  3.1007 -	  } else {
  3.1008 -	  	gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" );
  3.1009 -	    g_object_unref (program_info);
  3.1010 -	    program_info = NULL;
  3.1011 -	  }
  3.1012 -	  
  3.1013 -	} /* if */
  3.1014 +    gchar *date=  NULL;
  3.1015 +    struct tm *tm;
  3.1016 +    time_t t;
  3.1017  
  3.1018 -done:
  3.1019 -  g_string_free (tmp_str, TRUE);
  3.1020 +    actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
  3.1021  
  3.1022 -  g_object_unref (str_list);
  3.1023 -  
  3.1024 -  if ( date != NULL )
  3.1025 -  	g_free( date );
  3.1026 -  
  3.1027 -  return program_info;
  3.1028 +    str_list = gmyth_string_list_new();
  3.1029 +
  3.1030 +    g_string_append_printf( tmp_str, " %d", recorder->recorder_num);
  3.1031 +
  3.1032 +    t = time(NULL);
  3.1033 +    tm = localtime(&t);
  3.1034 +    date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
  3.1035 +            tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
  3.1036 +
  3.1037 +    gmyth_string_list_append_string(str_list, tmp_str);
  3.1038 +    gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO");
  3.1039 +    gmyth_string_list_append_string(str_list, actual_proginfo->channame);
  3.1040 +    gmyth_string_list_append_string(str_list, actual_proginfo->chanid);
  3.1041 +    gmyth_string_list_append_int(str_list, direction);
  3.1042 +    gmyth_string_list_append_char_array(str_list, date);
  3.1043 +
  3.1044 +    if ( gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list)> 0) {
  3.1045 +
  3.1046 +        if (str_list == NULL) {
  3.1047 +            gmyth_debug(
  3.1048 +                    "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
  3.1049 +                    __FUNCTION__);
  3.1050 +            goto done;
  3.1051 +        }
  3.1052 +        program_info = gmyth_program_info_new();
  3.1053 +
  3.1054 +        if ( NULL == program_info) {
  3.1055 +            gmyth_debug(
  3.1056 +                    "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
  3.1057 +                    __FUNCTION__);
  3.1058 +            g_object_unref(program_info);
  3.1059 +            goto done;
  3.1060 +        }
  3.1061 +
  3.1062 +        program_info->title = gmyth_string_list_get_string(str_list, 0);
  3.1063 +        program_info->subtitle = gmyth_string_list_get_string(str_list, 1);
  3.1064 +        program_info->description = gmyth_string_list_get_string(str_list, 2);
  3.1065 +        program_info->category = gmyth_string_list_get_string(str_list, 3);
  3.1066 +        program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
  3.1067 +                        (time_t)gmyth_string_list_get_int (str_list, 4) ))->str);
  3.1068 +        program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
  3.1069 +                        (time_t)gmyth_string_list_get_int (str_list, 6) ))->str);
  3.1070 +
  3.1071 +        program_info->chansign = gmyth_string_list_get_string(str_list, 8);
  3.1072 +        program_info->pathname = gmyth_string_list_get_string(str_list, 9);
  3.1073 +        program_info->channame = gmyth_string_list_get_string(str_list, 10);
  3.1074 +        program_info->chanid = gmyth_string_list_get_string(str_list, 11);
  3.1075 +        if ( recorder->myth_socket->mythtv_version >= 12) {
  3.1076 +            program_info->seriesid = gmyth_string_list_get_string(str_list, 12);
  3.1077 +            program_info->programid = gmyth_string_list_get_string(str_list, 13);
  3.1078 +        }
  3.1079 +
  3.1080 +        if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
  3.1081 +        ( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 )) {
  3.1082 +            gmyth_debug( "OK!!! Got the next program info..." );
  3.1083 +        } else {
  3.1084 +            gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" );
  3.1085 +            g_object_unref(program_info);
  3.1086 +            program_info = NULL;
  3.1087 +        }
  3.1088 +
  3.1089 +    } /* if */
  3.1090 +
  3.1091 +    done: g_string_free(tmp_str, TRUE);
  3.1092 +
  3.1093 +    g_object_unref(str_list);
  3.1094 +
  3.1095 +    if ( date != NULL)
  3.1096 +        g_free( date);
  3.1097 +
  3.1098 +    return program_info;
  3.1099  
  3.1100  }
  3.1101  
  3.1102 @@ -764,34 +773,32 @@
  3.1103   * @return The position, in bytes, of the offset to the read header.
  3.1104   */
  3.1105  gint64
  3.1106 -gmyth_recorder_get_file_position ( GMythRecorder *recorder )
  3.1107 -{
  3.1108 -  gint64 pos = 0;
  3.1109 -  GString *query = g_string_new( GMYTHTV_RECORDER_HEADER );
  3.1110 +gmyth_recorder_get_file_position( GMythRecorder *recorder) {
  3.1111 +    gint64 pos = 0;
  3.1112 +    GString *query = g_string_new( GMYTHTV_RECORDER_HEADER);
  3.1113  
  3.1114 -  GMythStringList *str_list = gmyth_string_list_new ();
  3.1115 +    GMythStringList *str_list = gmyth_string_list_new();
  3.1116  
  3.1117 -  g_string_append_printf( query, " %d", recorder->recorder_num );
  3.1118 +    g_string_append_printf( query, " %d", recorder->recorder_num);
  3.1119  
  3.1120 -  gmyth_string_list_append_string (str_list, query);
  3.1121 -  gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION" );
  3.1122 +    gmyth_string_list_append_string(str_list, query);
  3.1123 +    gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION");
  3.1124  
  3.1125 -  gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
  3.1126 +    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
  3.1127  
  3.1128 -  if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) 
  3.1129 -  {
  3.1130 -    GString *str = NULL;
  3.1131 -    if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr ( str->str, "bad" ) == NULL )
  3.1132 -      pos = gmyth_util_decode_long_long( str_list, 0 );
  3.1133 -  } 
  3.1134 +    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
  3.1135 +        GString *str=  NULL;
  3.1136 +        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL)
  3.1137 +            pos = gmyth_util_decode_long_long( str_list, 0);
  3.1138 +    }
  3.1139  
  3.1140  #ifndef GMYTHTV_ENABLE_DEBUG
  3.1141 -  g_print( "[%s] Got file position = %lld\n", __FUNCTION__, pos );
  3.1142 +    g_print( "[%s] Got file position = %lld\n", __FUNCTION__, pos);
  3.1143  #endif
  3.1144 -  if (str_list!=NULL)
  3.1145 -    g_object_unref (str_list);
  3.1146 +    if (str_list!=NULL)
  3.1147 +        g_object_unref(str_list);
  3.1148  
  3.1149 -  return pos;
  3.1150 +    return pos;
  3.1151  
  3.1152  }
  3.1153  
  3.1154 @@ -803,40 +810,38 @@
  3.1155   * @return <code>true</code>, if the actual remote file is bein recorded.
  3.1156   */
  3.1157  gboolean
  3.1158 -gmyth_recorder_is_recording ( GMythRecorder *recorder )
  3.1159 -{
  3.1160 -  gboolean ret = TRUE;
  3.1161 -  
  3.1162 -  g_return_val_if_fail( recorder != NULL, FALSE );
  3.1163 +gmyth_recorder_is_recording( GMythRecorder *recorder) {
  3.1164 +    gboolean ret=  TRUE;
  3.1165  
  3.1166 -  GMythStringList *str_list = gmyth_string_list_new ();
  3.1167 -  GString *message = g_string_new ("");
  3.1168 +    g_return_val_if_fail( recorder != NULL, FALSE );
  3.1169  
  3.1170 -  g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num);
  3.1171 -  gmyth_string_list_append_string (str_list, message);
  3.1172 -  gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING"));
  3.1173 +    GMythStringList *str_list = gmyth_string_list_new();
  3.1174 +    GString *message = g_string_new("");
  3.1175  
  3.1176 -  gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
  3.1177 +    g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
  3.1178 +            recorder->recorder_num);
  3.1179 +    gmyth_string_list_append_string(str_list, message);
  3.1180 +    gmyth_string_list_append_string(str_list, g_string_new("IS_RECORDING"));
  3.1181  
  3.1182 -  if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 )
  3.1183 -  {
  3.1184 -    GString *str = NULL;
  3.1185 -    if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) 
  3.1186 -    {
  3.1187 -      gint is_rec = gmyth_string_list_get_int( str_list, 0 );
  3.1188 -      if ( is_rec != 0 )
  3.1189 -        ret = TRUE;
  3.1190 -      else
  3.1191 -        ret = FALSE;
  3.1192 +    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
  3.1193 +
  3.1194 +    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
  3.1195 +        GString *str=  NULL;
  3.1196 +        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad")!= 0) {
  3.1197 +            gint is_rec = gmyth_string_list_get_int( str_list, 0);
  3.1198 +            if ( is_rec != 0)
  3.1199 +                ret = TRUE;
  3.1200 +            else
  3.1201 +                ret = FALSE;
  3.1202 +        }
  3.1203      }
  3.1204 -  }
  3.1205 -  gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
  3.1206 -  //g_static_mutex_unlock (&mutex);
  3.1207 +    gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
  3.1208 +    //g_static_mutex_unlock (&mutex);
  3.1209  
  3.1210 -  if ( str_list != NULL )
  3.1211 +    if ( str_list != NULL )
  3.1212      g_object_unref (str_list);
  3.1213  
  3.1214 -  return ret;
  3.1215 +    return ret;
  3.1216  
  3.1217  }
  3.1218  
  3.1219 @@ -848,39 +853,37 @@
  3.1220   * @return <code>true</code>, if the recording had been actually closed.
  3.1221   */
  3.1222  gboolean
  3.1223 -gmyth_recorder_finish_recording ( GMythRecorder *recorder )
  3.1224 -{
  3.1225 -  gboolean ret = TRUE;
  3.1226 -  
  3.1227 -  g_return_val_if_fail( recorder != NULL, FALSE );
  3.1228 +gmyth_recorder_finish_recording( GMythRecorder *recorder) {
  3.1229 +    gboolean ret=  TRUE;
  3.1230  
  3.1231 -  GMythStringList *str_list = gmyth_string_list_new ();
  3.1232 -  GString *message = g_string_new ("");
  3.1233 +    g_return_val_if_fail( recorder != NULL, FALSE );
  3.1234  
  3.1235 -  g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num);
  3.1236 -  gmyth_string_list_append_string (str_list, message);
  3.1237 -  gmyth_string_list_append_string (str_list, g_string_new ("FINISH_RECORDING"));
  3.1238 +    GMythStringList *str_list = gmyth_string_list_new();
  3.1239 +    GString *message = g_string_new("");
  3.1240  
  3.1241 -  gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
  3.1242 +    g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
  3.1243 +            recorder->recorder_num);
  3.1244 +    gmyth_string_list_append_string(str_list, message);
  3.1245 +    gmyth_string_list_append_string(str_list, g_string_new("FINISH_RECORDING"));
  3.1246  
  3.1247 -  if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 )
  3.1248 -  {
  3.1249 -    GString *str = NULL;
  3.1250 -    if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "ok" )!= 0 ) 
  3.1251 -    {
  3.1252 -      gint is_rec = gmyth_string_list_get_int( str_list, 0 );
  3.1253 -      if ( is_rec != 0 )
  3.1254 -        ret = TRUE;
  3.1255 -      else
  3.1256 -        ret = FALSE;
  3.1257 +    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
  3.1258 +
  3.1259 +    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
  3.1260 +        GString *str=  NULL;
  3.1261 +        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "ok")!= 0) {
  3.1262 +            gint is_rec = gmyth_string_list_get_int( str_list, 0);
  3.1263 +            if ( is_rec != 0)
  3.1264 +                ret = TRUE;
  3.1265 +            else
  3.1266 +                ret = FALSE;
  3.1267 +        }
  3.1268      }
  3.1269 -  }
  3.1270 -  gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
  3.1271 -  //g_static_mutex_unlock (&mutex);
  3.1272 +    gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
  3.1273 +    //g_static_mutex_unlock (&mutex);
  3.1274  
  3.1275 -  if ( str_list != NULL )
  3.1276 +    if ( str_list != NULL )
  3.1277      g_object_unref (str_list);
  3.1278  
  3.1279 -  return ret;
  3.1280 +    return ret;
  3.1281  
  3.1282  }
     4.1 --- a/gmyth/src/gmyth_recorder.h	Fri Mar 23 15:08:55 2007 +0000
     4.2 +++ b/gmyth/src/gmyth_recorder.h	Fri Mar 23 15:14:43 2007 +0000
     4.3 @@ -74,6 +74,8 @@
     4.4      gint recorder_num;
     4.5      GString *hostname;
     4.6      gint port;
     4.7 +    
     4.8 +    GSList* progs_info_list;
     4.9  };
    4.10  
    4.11  typedef enum _GMythRecorderChannelChangeDirection {