# HG changeset patch # User rosfran # Date 1172880094 0 # Node ID 060c3ceb43a0c5c3f51f6dde5538847640c1d021 # Parent 4071ea7f32e6393227e83c68dc44aef8ca5e0922 [svn r389] Some improvements on recorded file detection. diff -r 4071ea7f32e6 -r 060c3ceb43a0 gmyth/src/gmyth_backendinfo.c --- a/gmyth/src/gmyth_backendinfo.c Fri Mar 02 21:25:50 2007 +0000 +++ b/gmyth/src/gmyth_backendinfo.c Sat Mar 03 00:01:34 2007 +0000 @@ -145,7 +145,7 @@ gmyth_backend_info_set_db_name (backend_info, path_parts != NULL && path_parts[0] != NULL && strlen( path_parts[0] ) > 0 ? g_strstrip( g_strdup( g_strdelimit( path_parts[0], "/?", ' ' ) ) ) : gmyth_uri_get_path( backend_info->uri ) ); - gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( backend_info->uri ) ); + gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port( backend_info->uri ) ); g_strfreev( path_parts ); diff -r 4071ea7f32e6 -r 060c3ceb43a0 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Fri Mar 02 21:25:50 2007 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Sat Mar 03 00:01:34 2007 +0000 @@ -481,7 +481,7 @@ query = g_string_new (GMYTHTV_QUERY_HEADER); g_string_append_printf (query, "%d", transfer->file_id); - myth_control_acquire_context( transfer, TRUE ); + /* myth_control_acquire_context( transfer, TRUE ); */ gmyth_string_list_append_string( strlist, query ); gmyth_string_list_append_char_array( strlist, "SEEK" ); @@ -501,7 +501,7 @@ gmyth_debug ( "[%s] got reading position pointer from the streaming = %lld\n", __FUNCTION__, retval ); - myth_control_release_context( transfer ); + /* myth_control_release_context( transfer ); */ return retval; } diff -r 4071ea7f32e6 -r 060c3ceb43a0 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Fri Mar 02 21:25:50 2007 +0000 +++ b/gmyth/src/gmyth_util.c Sat Mar 03 00:01:34 2007 +0000 @@ -458,6 +458,68 @@ return res; } +gboolean +gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, + const gchar* filename, gchar** current_dir) +{ + GMythSocket *socket; + gboolean res; + + *current_dir = NULL; + + socket = gmyth_socket_new (); + res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, + backend_info->port, TRUE); + + if (res == TRUE) { + GMythStringList *slist; + GMythProgramInfo *program = NULL; + + program = gmyth_program_info_new(); + program->pathname = g_string_new (filename); + + slist = gmyth_string_list_new (); + gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE"); + + gmyth_program_info_to_string_list (program, slist); + + gmyth_socket_sendreceive_stringlist (socket, slist); + + res = (gmyth_string_list_get_int (slist, 0) == 1); + + if ( ( gmyth_string_list_length( slist ) > 1 ) && + gmyth_string_list_get_char_array (slist, 1) != NULL ) + *current_dir = g_strdup( gmyth_string_list_get_char_array (slist, 1) ); + + g_object_unref (program); + + g_object_unref (slist); + + gmyth_socket_close_connection (socket); + } + g_object_unref (socket); + return res; +} + +gchar* +gmyth_util_create_filename( const gint chan_id, const GTimeVal* start_time ) +{ + gchar* basename = NULL; + + g_return_val_if_fail( start_time != NULL, NULL ); + + gchar *isodate = gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y%m%d%H%M%S", + start_time ); + + basename = g_strdup_printf( "%d_%s", chan_id, isodate ); + + gmyth_debug ("Basename (from chan_id and start_time): %s", basename); + + if (isodate) + g_free(isodate); + + return basename; +} #if !GLIB_CHECK_VERSION (2, 10, 0) diff -r 4071ea7f32e6 -r 060c3ceb43a0 gmyth/src/gmyth_util.h --- a/gmyth/src/gmyth_util.h Fri Mar 02 21:25:50 2007 +0000 +++ b/gmyth/src/gmyth_util.h Sat Mar 03 00:01:34 2007 +0000 @@ -61,6 +61,11 @@ gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info, const gchar* filename); +gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, + const gchar* filename, gchar** current_dir); + +gchar* gmyth_util_create_filename( const gint chan_id, const GTimeVal* start_time ); + G_END_DECLS #endif /*GMYTH_UTIL_H_*/