# HG changeset patch # User rosfran # Date 1174662883 0 # Node ID 4d883f3edcdd79fcb6d9016d81d590653d3000a8 # Parent db17a60b9b42b7fd2ad8b38fc78dd3ef3f7bc6cb [svn r448] Fills a list with all the added program info into the TV Chain. diff -r db17a60b9b42 -r 4d883f3edcdd gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Fri Mar 23 15:08:55 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.c Fri Mar 23 15:14:43 2007 +0000 @@ -469,3 +469,24 @@ prog->hasAirDate, gmyth_program_info_non_null_value(prog->playgroup) ); } + +/** + * Say if an instance of a GMythProgramInfo is equals to another one. + * + * @param prog The first GMythProgramInfo instance. + * @param prog The second GMythProgramInfo instance. + * + * @return true, if the program infos are equals. + */ +gboolean +gmyth_program_info_is_equals( const GMythProgramInfo* prog1, const GMythProgramInfo* prog2 ) +{ + if ( ( strcmp( gmyth_program_info_non_null_value( prog1->title ), + gmyth_program_info_non_null_value( prog2->title ) ) == 0 ) || + ( strcmp( gmyth_program_info_non_null_value( prog1->pathname ), + gmyth_program_info_non_null_value( prog2->pathname ) ) == 0 ) ) + return TRUE; + else + return FALSE; + +} \ No newline at end of file diff -r db17a60b9b42 -r 4d883f3edcdd gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Fri Mar 23 15:08:55 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.h Fri Mar 23 15:14:43 2007 +0000 @@ -159,6 +159,8 @@ const gchar* gmyth_program_info_to_string( const GMythProgramInfo* prog ); +gboolean gmyth_program_info_is_equals( const GMythProgramInfo* prog1, const GMythProgramInfo* prog2 ); + G_END_DECLS #endif /*_GMYTH_PROGRAMINFO_H*/ diff -r db17a60b9b42 -r 4d883f3edcdd gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Fri Mar 23 15:08:55 2007 +0000 +++ b/gmyth/src/gmyth_recorder.c Fri Mar 23 15:14:43 2007 +0000 @@ -27,7 +27,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -42,14 +42,14 @@ #define GMYTHTV_RECORDER_HEADER "QUERY_RECORDER" -static void gmyth_recorder_class_init (GMythRecorderClass *klass); -static void gmyth_recorder_init (GMythRecorder *object); +static void gmyth_recorder_class_init(GMythRecorderClass *klass); +static void gmyth_recorder_init(GMythRecorder *object); -static void gmyth_recorder_dispose (GObject *object); -static void gmyth_recorder_finalize (GObject *object); +static void gmyth_recorder_dispose(GObject *object); +static void gmyth_recorder_finalize(GObject *object); G_DEFINE_TYPE(GMythRecorder, gmyth_recorder, G_TYPE_OBJECT) - + static void gmyth_recorder_class_init (GMythRecorderClass *klass) { @@ -62,38 +62,33 @@ } static void -gmyth_recorder_init (GMythRecorder *gmyth_remote_encoder) -{ +gmyth_recorder_init(GMythRecorder *gmyth_remote_encoder) { } static void -gmyth_recorder_dispose (GObject *object) -{ - GMythRecorder *recorder = GMYTH_RECORDER(object); - - gmyth_recorder_close(recorder); - - if ( recorder->myth_socket != NULL ) { - g_object_unref (recorder->myth_socket); - recorder->myth_socket = NULL; - } - - G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object); +gmyth_recorder_dispose(GObject *object) { + GMythRecorder *recorder= GMYTH_RECORDER(object); + + gmyth_recorder_close(recorder); + + if ( recorder->myth_socket != NULL) { + g_object_unref(recorder->myth_socket); + recorder->myth_socket = NULL; + } + + G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object); } +static void +gmyth_recorder_finalize(GObject *object) { + g_signal_handlers_destroy(object); -static void -gmyth_recorder_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - - G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object); + G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object); } void -gmyth_recorder_close (GMythRecorder *recorder) -{ - gmyth_recorder_finish_recording( recorder ); +gmyth_recorder_close(GMythRecorder *recorder) { + gmyth_recorder_finish_recording( recorder); } /** Creates a new instance of GMythRecorder. @@ -101,16 +96,15 @@ * @return a new instance of GMythRecorder. */ GMythRecorder* -gmyth_recorder_new (int num, GString *hostname, gshort port) -{ - GMythRecorder *encoder = GMYTH_RECORDER ( g_object_new ( - GMYTH_RECORDER_TYPE, FALSE )); - - encoder->recorder_num = num; - encoder->hostname = g_string_new (hostname->str); - encoder->port = port; - - return encoder; +gmyth_recorder_new(int num, GString *hostname, gshort port) { + GMythRecorder *encoder= GMYTH_RECORDER ( g_object_new ( + GMYTH_RECORDER_TYPE, FALSE )); + + encoder->recorder_num = num; + encoder->hostname = g_string_new(hostname->str); + encoder->port = port; + + return encoder; } /** Configures the remote encoder instance connecting it to Mythtv backend. @@ -120,26 +114,25 @@ * @return TRUE if successfull, FALSE if any error happens. */ gboolean -gmyth_recorder_setup (GMythRecorder *recorder) -{ - assert (recorder); - gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__); +gmyth_recorder_setup(GMythRecorder *recorder) { + assert (recorder); + gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__); - if (recorder->myth_socket == NULL) { - - recorder->myth_socket = gmyth_socket_new (); - - if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str, - recorder->port, TRUE ) ) { - g_warning ("GMythRemoteEncoder: Connection to backend failed"); - return FALSE; - } - - } else { - g_warning("Remote encoder socket already created\n"); - } + if (recorder->myth_socket == NULL) { - return TRUE; + recorder->myth_socket = gmyth_socket_new (); + + if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str, + recorder->port, TRUE ) ) { + gmyth_debug ("GMythRemoteEncoder: Connection to backend failed"); + return FALSE; + } + + } else { + gmyth_debug("Remote encoder socket already created\n"); + } + + return TRUE; } /** Sends the SPAWN_LIVETV command through Mythtv protocol. This command @@ -150,36 +143,35 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_spawntv (GMythRecorder *recorder, GString *tvchain_id) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV")); - gmyth_string_list_append_string (str_list, tvchain_id); - gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0) +gmyth_recorder_spawntv(GMythRecorder *recorder, GString *tvchain_id) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV")); + gmyth_string_list_append_string (str_list, tvchain_id); + gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0) + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - + gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -196,34 +188,33 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_spawntv_no_tvchain (GMythRecorder *recorder) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV")); +gmyth_recorder_spawntv_no_tvchain(GMythRecorder *recorder) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV")); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - + gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -237,31 +228,30 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_stop_livetv (GMythRecorder *recorder) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); +gmyth_recorder_stop_livetv(GMythRecorder *recorder) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_debug ("[%s]", __FUNCTION__); + gmyth_debug ("[%s]", __FUNCTION__); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new (); - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" ); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - g_string_free (tmp_str, TRUE); + g_string_free (tmp_str, TRUE); - tmp_str = gmyth_string_list_get_string (str_list, 0); - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; - } + tmp_str = gmyth_string_list_get_string (str_list, 0); + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { + gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; + } - g_object_unref (str_list); - return TRUE; + g_object_unref (str_list); + return TRUE; } @@ -272,38 +262,37 @@ * @return TRUE if success, FALSE if any error happens. */ gboolean -gmyth_recorder_send_frontend_ready_command (GMythRecorder *recorder) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num ); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("FRONTEND_READY")); +gmyth_recorder_send_frontend_ready_command(GMythRecorder *recorder) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - - g_string_free (tmp_str, TRUE); - - tmp_str = gmyth_string_list_get_string (str_list, 0); - if (tmp_str == NULL) { - g_warning ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str); + gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num ); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("FRONTEND_READY")); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + + g_string_free (tmp_str, TRUE); + + tmp_str = gmyth_string_list_get_string (str_list, 0); + if (tmp_str == NULL) { + gmyth_debug ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { + gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; + } + g_object_unref (str_list); - return FALSE; - } - - g_object_unref (str_list); - return TRUE; + return TRUE; } @@ -315,35 +304,35 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - 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_char_array (str_list, channel); +gmyth_recorder_check_channel_name(GMythRecorder *recorder, + gchar* channel) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + 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_char_array (str_list, channel); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - + gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0 ) { - g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -359,9 +348,9 @@ * @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 ) ); +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 @@ -372,35 +361,34 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_set_channel (GMythRecorder *recorder, gint channel) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL")); - gmyth_string_list_append_int (str_list, channel); +gmyth_recorder_set_channel(GMythRecorder *recorder, gint channel) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL")); + gmyth_string_list_append_int (str_list, channel); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - + gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -416,35 +404,35 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_set_channel_name (GMythRecorder *recorder, const gchar* channel) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL")); - gmyth_string_list_append_char_array (str_list, channel); +gmyth_recorder_set_channel_name(GMythRecorder *recorder, + const gchar* channel) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL")); + gmyth_string_list_append_char_array (str_list, channel); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] SET_CHANNEL name request returned NULL!", __FUNCTION__); - return FALSE; - } - - if (tmp_str!= NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */ ) { - g_warning ("XXXXXX[%s] SET_CHANNEL name request returned not ok", __FUNCTION__); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!", __FUNCTION__); + return FALSE; + } + + if (tmp_str!= NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */) { + gmyth_debug ("XXXXXX[%s] SET_CHANNEL name request returned not ok", __FUNCTION__); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -468,35 +456,35 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_change_channel (GMythRecorder *recorder, const GMythRecorderChannelChangeDirection direction) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("CHANGE_CHANNEL")); - gmyth_string_list_append_int (str_list, direction); +gmyth_recorder_change_channel(GMythRecorder *recorder, + const GMythRecorderChannelChangeDirection direction) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("CHANGE_CHANNEL")); + gmyth_string_list_append_int (str_list, direction); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str ); - return FALSE; - } - + gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str ); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) { - g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -511,34 +499,33 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_pause_recording ( GMythRecorder *recorder ) -{ - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gmyth_debug ("[%s] PAUSE", __FUNCTION__); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_string (str_list, g_string_new ("PAUSE")); +gmyth_recorder_pause_recording( GMythRecorder *recorder) { + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); - + gmyth_debug ("[%s] PAUSE", __FUNCTION__); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("PAUSE")); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + g_string_free (tmp_str, TRUE); - + tmp_str = gmyth_string_list_get_string (str_list, 0); if (tmp_str == NULL) { - g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); - return FALSE; - } - + gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); - g_object_unref (str_list); - return FALSE; + gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; } g_object_unref (str_list); @@ -546,6 +533,21 @@ } +static gboolean +gmyth_recorder_find_if_program_exists( GMythRecorder* recorder, GMythProgramInfo* prog ) +{ + GSList *lst = NULL; + for ( lst = recorder->progs_info_list; lst != NULL; lst = g_slist_next( lst ) ) + { + gmyth_debug ( "Got program info from list = [%s]", + gmyth_program_info_to_string( (GMythProgramInfo*)lst->data ) ); + if ( gmyth_program_info_is_equals ( prog, (GMythProgramInfo*)lst->data ) ) + return TRUE; + } + + return FALSE; +} + /** * Requests the actual program info from the MythTV backend server. * @@ -553,42 +555,50 @@ * @return The actual program info. */ GMythProgramInfo * -gmyth_recorder_get_current_program_info ( GMythRecorder *recorder ) -{ - GMythStringList *str_list; - GMythProgramInfo *program_info = gmyth_program_info_new(); - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - gmyth_string_list_append_string (str_list, tmp_str); - - if ( recorder->myth_socket->mythtv_version >= 26 ) - gmyth_string_list_append_string (str_list, g_string_new ("GET_CURRENT_RECORDING")); - else - gmyth_string_list_append_string (str_list, g_string_new ("GET_PROGRAM_INFO")); +gmyth_recorder_get_current_program_info( + GMythRecorder *recorder) { + GMythStringList *str_list; + GMythProgramInfo *program_info = gmyth_program_info_new(); + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + str_list = gmyth_string_list_new(); - g_string_free (tmp_str, TRUE); + g_string_append_printf( tmp_str, " %d", recorder->recorder_num); - if (str_list == NULL) { - g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", __FUNCTION__); - return FALSE; - } - - program_info = gmyth_program_info_from_string_list( str_list ); + gmyth_string_list_append_string(str_list, tmp_str); - if ( NULL == program_info || NULL == program_info->pathname || program_info->pathname->len <= 0 ) { - g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", __FUNCTION__); - g_object_unref (program_info); - return NULL; - } + if ( recorder->myth_socket->mythtv_version >= 26) + gmyth_string_list_append_string(str_list, + g_string_new("GET_CURRENT_RECORDING")); + else + gmyth_string_list_append_string(str_list, + g_string_new("GET_PROGRAM_INFO")); - g_object_unref (str_list); - return program_info; + gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list); + + g_string_free(tmp_str, TRUE); + + if (str_list == NULL) { + gmyth_debug( + "[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", + __FUNCTION__); + return FALSE; + } + + program_info = gmyth_program_info_from_string_list( str_list ); + + if ( NULL == program_info || NULL == program_info->pathname || program_info->pathname->len <= 0) { + gmyth_debug( + "GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!"); + g_object_unref(program_info); + return NULL; + } + + if ( !gmyth_recorder_find_if_program_exists( recorder, program_info ) ) + recorder->progs_info_list = g_slist_append( recorder->progs_info_list, program_info ); + + g_object_unref(str_list); + return program_info; } @@ -599,64 +609,65 @@ * @return The GMythRecorder instance. */ GMythRecorder * -gmyth_recorder_get_recorder_from_num ( gint rec_id ) -{ - GMythRecorder* recorder = NULL; - GMythStringList *str_list; - GString *tmp_str = g_string_new( "GET_RECORDER_FROM_NUM" ); - gint command_size = 0; - - gchar *recorder_host = NULL; - gint recorder_port; - - str_list = gmyth_string_list_new (); - - /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */ - - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_int (str_list, rec_id); +gmyth_recorder_get_recorder_from_num( gint rec_id) { + GMythRecorder* recorder= NULL; + GMythStringList *str_list; + GString *tmp_str = g_string_new( "GET_RECORDER_FROM_NUM"); + gint command_size = 0; - command_size = gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gchar *recorder_host= NULL; + gint recorder_port; - g_string_free (tmp_str, TRUE); + str_list = gmyth_string_list_new(); - if (str_list == NULL) { - g_warning ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", - __FUNCTION__, rec_id); - return NULL; - } - - if ( command_size > 0 ) - { - recorder_host = gmyth_string_list_get_char_array( str_list, 0 ); - recorder_port = gmyth_string_list_get_int( str_list, 1 ); - - if ( g_strstr_len( recorder_host, strlen(recorder_host), "nohost" ) != NULL ) - { - gmyth_debug( "No available recorder with the recorder ID number %d!", rec_id ); - } else { - - recorder = gmyth_recorder_new( rec_id, g_string_new( recorder_host ), (gshort)recorder_port ); - - if ( NULL == recorder ) { - g_warning ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", - __FUNCTION__, rec_id); - g_object_unref (recorder); - return NULL; - } - - } - - } else { - gmyth_debug( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", rec_id ); - } + /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */ - g_object_unref (str_list); - - if ( recorder_host != NULL ) - g_free( recorder_host ); - - return recorder; + gmyth_string_list_append_string(str_list, tmp_str); + gmyth_string_list_append_int(str_list, rec_id); + + command_size = gmyth_socket_sendreceive_stringlist(recorder->myth_socket, + str_list); + + g_string_free(tmp_str, TRUE); + + if (str_list == NULL) { + gmyth_debug( + "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", + __FUNCTION__, rec_id); + return NULL; + } + + if ( command_size > 0) { + recorder_host = gmyth_string_list_get_char_array( str_list, 0 ); + recorder_port = gmyth_string_list_get_int( str_list, 1); + + if ( g_strstr_len( recorder_host, strlen(recorder_host), "nohost")!= NULL) { + gmyth_debug( "No available recorder with the recorder ID number %d!", rec_id ); + } else { + + recorder = gmyth_recorder_new( rec_id, + g_string_new( recorder_host), (gshort)recorder_port); + + if ( NULL == recorder) { + gmyth_debug( + "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", + __FUNCTION__, rec_id); + g_object_unref(recorder); + return NULL; + } + + } + + } else { + gmyth_debug( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", rec_id ); + } + + g_object_unref(str_list); + + if ( recorder_host != NULL) + g_free( recorder_host); + + return recorder; } @@ -667,92 +678,90 @@ * @return The GMythProgramInfo next program info instance. */ GMythProgramInfo * -gmyth_recorder_get_next_program_info ( GMythRecorder *recorder, const GMythRecorderBrowseDirection direction ) -{ - GMythProgramInfo* actual_proginfo = NULL; - GMythProgramInfo* program_info = NULL; - GMythStringList *str_list; - GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - - gchar *date = NULL; - struct tm *tm; - time_t t; - - actual_proginfo = gmyth_recorder_get_current_program_info(recorder); - - str_list = gmyth_string_list_new (); - - g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - - t = time(NULL); - tm = localtime(&t); - date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", - tm->tm_year + 1900, tm->tm_mon + 1, - tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); +gmyth_recorder_get_next_program_info( + GMythRecorder *recorder, const GMythRecorderBrowseDirection direction) { + GMythProgramInfo* actual_proginfo= NULL; + GMythProgramInfo* program_info= NULL; + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER); - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO"); - gmyth_string_list_append_string (str_list, actual_proginfo->channame); - gmyth_string_list_append_string (str_list, actual_proginfo->chanid); - gmyth_string_list_append_int (str_list, direction); - gmyth_string_list_append_char_array (str_list, date); - - if ( gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list) > 0 ) - { - - if (str_list == NULL) { - g_warning ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", - __FUNCTION__); - goto done; - } - program_info = gmyth_program_info_new(); - - if ( NULL == program_info ) { - g_warning ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", - __FUNCTION__); - g_object_unref (program_info); - goto done; - } - - program_info->title = gmyth_string_list_get_string (str_list, 0); - program_info->subtitle = gmyth_string_list_get_string (str_list, 1); - program_info->description = gmyth_string_list_get_string (str_list, 2); - program_info->category = gmyth_string_list_get_string (str_list, 3); - program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (str_list, 4) ))->str ); - program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( - (time_t)gmyth_string_list_get_int (str_list, 6) ))->str ); - - program_info->chansign = gmyth_string_list_get_string (str_list, 8); - program_info->pathname = gmyth_string_list_get_string (str_list, 9); - program_info->channame = gmyth_string_list_get_string (str_list, 10); - program_info->chanid = gmyth_string_list_get_string (str_list, 11); - if ( recorder->myth_socket->mythtv_version >= 12 ) { - program_info->seriesid = gmyth_string_list_get_string (str_list, 12); - program_info->programid = gmyth_string_list_get_string (str_list, 13); - } - - if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) &&*/ - ( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 ) ) - { - gmyth_debug( "OK!!! Got the next program info..." ); - } else { - gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" ); - g_object_unref (program_info); - program_info = NULL; - } - - } /* if */ + gchar *date= NULL; + struct tm *tm; + time_t t; -done: - g_string_free (tmp_str, TRUE); + actual_proginfo = gmyth_recorder_get_current_program_info(recorder); - g_object_unref (str_list); - - if ( date != NULL ) - g_free( date ); - - return program_info; + str_list = gmyth_string_list_new(); + + g_string_append_printf( tmp_str, " %d", recorder->recorder_num); + + t = time(NULL); + tm = localtime(&t); + date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900, + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + + gmyth_string_list_append_string(str_list, tmp_str); + gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO"); + gmyth_string_list_append_string(str_list, actual_proginfo->channame); + gmyth_string_list_append_string(str_list, actual_proginfo->chanid); + gmyth_string_list_append_int(str_list, direction); + gmyth_string_list_append_char_array(str_list, date); + + if ( gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list)> 0) { + + if (str_list == NULL) { + gmyth_debug( + "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", + __FUNCTION__); + goto done; + } + program_info = gmyth_program_info_new(); + + if ( NULL == program_info) { + gmyth_debug( + "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", + __FUNCTION__); + g_object_unref(program_info); + goto done; + } + + program_info->title = gmyth_string_list_get_string(str_list, 0); + program_info->subtitle = gmyth_string_list_get_string(str_list, 1); + program_info->description = gmyth_string_list_get_string(str_list, 2); + program_info->category = gmyth_string_list_get_string(str_list, 3); + program_info->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (str_list, 4) ))->str); + program_info->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( + (time_t)gmyth_string_list_get_int (str_list, 6) ))->str); + + program_info->chansign = gmyth_string_list_get_string(str_list, 8); + program_info->pathname = gmyth_string_list_get_string(str_list, 9); + program_info->channame = gmyth_string_list_get_string(str_list, 10); + program_info->chanid = gmyth_string_list_get_string(str_list, 11); + if ( recorder->myth_socket->mythtv_version >= 12) { + program_info->seriesid = gmyth_string_list_get_string(str_list, 12); + program_info->programid = gmyth_string_list_get_string(str_list, 13); + } + + if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) &&*/ + ( program_info->pathname != NULL && strlen( program_info->pathname->str ) > 0 )) { + gmyth_debug( "OK!!! Got the next program info..." ); + } else { + gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" ); + g_object_unref(program_info); + program_info = NULL; + } + + } /* if */ + + done: g_string_free(tmp_str, TRUE); + + g_object_unref(str_list); + + if ( date != NULL) + g_free( date); + + return program_info; } @@ -764,34 +773,32 @@ * @return The position, in bytes, of the offset to the read header. */ gint64 -gmyth_recorder_get_file_position ( GMythRecorder *recorder ) -{ - gint64 pos = 0; - GString *query = g_string_new( GMYTHTV_RECORDER_HEADER ); +gmyth_recorder_get_file_position( GMythRecorder *recorder) { + gint64 pos = 0; + GString *query = g_string_new( GMYTHTV_RECORDER_HEADER); - GMythStringList *str_list = gmyth_string_list_new (); + GMythStringList *str_list = gmyth_string_list_new(); - g_string_append_printf( query, " %d", recorder->recorder_num ); + g_string_append_printf( query, " %d", recorder->recorder_num); - gmyth_string_list_append_string (str_list, query); - gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION" ); + gmyth_string_list_append_string(str_list, query); + gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION"); - gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); + gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list); - if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) - { - GString *str = NULL; - if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr ( str->str, "bad" ) == NULL ) - pos = gmyth_util_decode_long_long( str_list, 0 ); - } + if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) { + GString *str= NULL; + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL) + pos = gmyth_util_decode_long_long( str_list, 0); + } #ifndef GMYTHTV_ENABLE_DEBUG - g_print( "[%s] Got file position = %lld\n", __FUNCTION__, pos ); + g_print( "[%s] Got file position = %lld\n", __FUNCTION__, pos); #endif - if (str_list!=NULL) - g_object_unref (str_list); + if (str_list!=NULL) + g_object_unref(str_list); - return pos; + return pos; } @@ -803,40 +810,38 @@ * @return true, if the actual remote file is bein recorded. */ gboolean -gmyth_recorder_is_recording ( GMythRecorder *recorder ) -{ - gboolean ret = TRUE; - - g_return_val_if_fail( recorder != NULL, FALSE ); +gmyth_recorder_is_recording( GMythRecorder *recorder) { + gboolean ret= TRUE; - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + g_return_val_if_fail( recorder != NULL, FALSE ); - g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING")); + GMythStringList *str_list = gmyth_string_list_new(); + GString *message = g_string_new(""); - gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); + g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, + recorder->recorder_num); + gmyth_string_list_append_string(str_list, message); + gmyth_string_list_append_string(str_list, g_string_new("IS_RECORDING")); - if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) - { - GString *str = NULL; - if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) - { - gint is_rec = gmyth_string_list_get_int( str_list, 0 ); - if ( is_rec != 0 ) - ret = TRUE; - else - ret = FALSE; + gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list); + + if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) { + GString *str= NULL; + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad")!= 0) { + gint is_rec = gmyth_string_list_get_int( str_list, 0); + if ( is_rec != 0) + ret = TRUE; + else + ret = FALSE; + } } - } - gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); - //g_static_mutex_unlock (&mutex); + gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); + //g_static_mutex_unlock (&mutex); - if ( str_list != NULL ) + if ( str_list != NULL ) g_object_unref (str_list); - return ret; + return ret; } @@ -848,39 +853,37 @@ * @return true, if the recording had been actually closed. */ gboolean -gmyth_recorder_finish_recording ( GMythRecorder *recorder ) -{ - gboolean ret = TRUE; - - g_return_val_if_fail( recorder != NULL, FALSE ); +gmyth_recorder_finish_recording( GMythRecorder *recorder) { + gboolean ret= TRUE; - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + g_return_val_if_fail( recorder != NULL, FALSE ); - g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_string (str_list, g_string_new ("FINISH_RECORDING")); + GMythStringList *str_list = gmyth_string_list_new(); + GString *message = g_string_new(""); - gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); + g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, + recorder->recorder_num); + gmyth_string_list_append_string(str_list, message); + gmyth_string_list_append_string(str_list, g_string_new("FINISH_RECORDING")); - if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) - { - GString *str = NULL; - if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "ok" )!= 0 ) - { - gint is_rec = gmyth_string_list_get_int( str_list, 0 ); - if ( is_rec != 0 ) - ret = TRUE; - else - ret = FALSE; + gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list); + + if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) { + GString *str= NULL; + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "ok")!= 0) { + gint is_rec = gmyth_string_list_get_int( str_list, 0); + if ( is_rec != 0) + ret = TRUE; + else + ret = FALSE; + } } - } - gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); - //g_static_mutex_unlock (&mutex); + gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); + //g_static_mutex_unlock (&mutex); - if ( str_list != NULL ) + if ( str_list != NULL ) g_object_unref (str_list); - return ret; + return ret; } diff -r db17a60b9b42 -r 4d883f3edcdd gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Fri Mar 23 15:08:55 2007 +0000 +++ b/gmyth/src/gmyth_recorder.h Fri Mar 23 15:14:43 2007 +0000 @@ -74,6 +74,8 @@ gint recorder_num; GString *hostname; gint port; + + GSList* progs_info_list; }; typedef enum _GMythRecorderChannelChangeDirection {