# HG changeset patch # User rosfran # Date 1170873015 0 # Node ID f32837103d171723840560cac6ec54d7918461cc # Parent e0ae971dc16e16ca94ae5bab200734198c504dad [svn r333] Fixed bug on do_get_file_info. diff -r e0ae971dc16e -r f32837103d17 libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 07 18:29:38 2007 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 07 18:30:15 2007 +0000 @@ -285,13 +285,12 @@ GnomeVFSContext *context) { GMythFileTransfer *file_transfer = NULL; - //GMythLiveTV *livetv = NULL; + GMythLiveTV *livetv = NULL; GMythBackendInfo *backend_info = NULL; GMythURI *gmyth_uri = NULL; gboolean is_livetv = FALSE; gboolean ret = TRUE; - file_info->size = (GnomeVFSFileSize) - 1; /* Creates and fills out the backend info structure */ backend_info = gmyth_backend_info_new_with_uri ( gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) ); @@ -302,7 +301,6 @@ is_livetv = gmyth_uri_is_livetv( gmyth_uri ); - file_info->name = g_strdup (gmyth_uri_get_path (gmyth_uri)); file_info->valid_fields = file_info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_TYPE | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE @@ -314,16 +312,19 @@ GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_GROUP_READ; + + g_print( "gnome_vfs_uri == %s | gmyth_uri == %s.", + gnome_vfs_uri_get_path (uri), + gmyth_uri_get_path (gmyth_uri) ); /* Connect to the backend */ if ( gmyth_uri != NULL && is_livetv == TRUE ) { - /* livetv = gmyth_livetv_new (); - gint channel_num = gmyth_uri_get_channel_num( gmyth_uri ); + gchar* channel_name = gmyth_uri_get_channel_name( gmyth_uri ); - if ( channel_num != -1 ) { - if (gmyth_livetv_channel_setup (livetv, channel_num, + if ( channel_name != NULL ) { + if (gmyth_livetv_channel_name_setup (livetv, channel_name, backend_info) == FALSE) { g_object_unref( gmyth_uri ); ret = FALSE; @@ -334,14 +335,18 @@ ret = FALSE; } } + + g_print( "path = %s", gmyth_uri_get_path (livetv->uri) ); file_transfer = gmyth_livetv_create_file_transfer (livetv); if (NULL == file_transfer) { ret = FALSE; } - */ + g_print( "path = %s", gmyth_uri_get_path (livetv->uri) ); + file_info->name = g_strdup ( gmyth_uri_get_path (livetv->uri) ); + } else { file_transfer = gmyth_file_transfer_new (backend_info); @@ -354,6 +359,8 @@ /* sets the Playback monitor connection */ ret = gmyth_file_transfer_open ( file_transfer, gmyth_uri_get_path (gmyth_uri) ); + + file_info->name = g_strdup ( gnome_vfs_uri_get_path (uri) ); } /* if - LiveTV or not? */ @@ -365,23 +372,46 @@ */ if ( is_livetv ) { - /* - GMythProgramInfo *prog_info = gmyth_recorder_get_current_program_info ( GMythRecorder *recorder ) + gint64 size = 0; if ( file_transfer->filesize < 0 ) - file_info->size = gmyth_recorder_get_file_position( livetv->recorder ); + { + size = gmyth_recorder_get_file_position( livetv->recorder ); + if( size < 0 ) { + GMythProgramInfo *prog_info = gmyth_recorder_get_current_program_info ( livetv->recorder ); + size = prog_info->filesize; + + if ( prog_info ) + g_object_unref( prog_info ); + } + } + else if ( file_transfer != NULL ) + size = gmyth_file_transfer_get_filesize (file_transfer); + + if ( size < 0 ) + file_info->size =(GnomeVFSFileSize) - 1; else - */ - file_info->size =(GnomeVFSFileSize) - 1; - } else { + file_info->size = size; + + /*if ( file_transfer != NULL) + g_object_unref (file_transfer);*/ + + if ( livetv != NULL ) + g_object_unref (livetv); + + /*if ( file_transfer != NULL) + g_object_unref (file_transfer);*/ + + } else if ( ret == TRUE && file_transfer != NULL ) { file_info->size = gmyth_file_transfer_get_filesize (file_transfer); - } + if ( file_transfer ) + g_object_unref (file_transfer); + } + + file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT; + file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE; - file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT; - file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE; - - g_object_unref (backend_info); - g_object_unref (file_transfer); - //g_object_unref (livetv); + if (backend_info) + g_object_unref (backend_info); return GNOME_VFS_OK; }