# HG changeset patch # User rosfran # Date 1169664823 0 # Node ID c81bc5ed0ccb0e63a295b2ad54c6073476c68f33 # Parent 346b67519f6dbbed3961d0c53ad892db1a43623f [svn r298] Fixes problem with the get_file_info method, ehich takes the gnomvfs plug-in to do invalid g_free. diff -r 346b67519f6d -r c81bc5ed0ccb libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Jan 24 14:51:46 2007 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Jan 24 18:53:43 2007 +0000 @@ -53,7 +53,7 @@ gint channel_num; gint mythtv_version; - guint64 content_size; + gint64 content_size; guint64 bytes_read; GByteArray *buffer; @@ -91,7 +91,7 @@ myth_handle->livetv = NULL; myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT; myth_handle->bytes_read = 0; - myth_handle->content_size = -1; + myth_handle->content_size = 0; /* Creates and fills out the backend info structure */ backend_info = gmyth_backend_info_new_with_uri ( @@ -100,9 +100,11 @@ /* creates an instance of */ gmyth_uri = gmyth_uri_new_with_value( gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) ); - + + is_livetv = gmyth_uri_is_livetv( gmyth_uri ); + /* Connect to the backend */ - if ( gmyth_uri != NULL && ( is_livetv = gmyth_uri_is_livetv( gmyth_uri ) ) == TRUE ) { + if ( gmyth_uri != NULL && is_livetv == TRUE ) { myth_handle->livetv = gmyth_livetv_new (); myth_handle->channel_num = gmyth_uri_get_channel_num( gmyth_uri ); @@ -126,21 +128,18 @@ ret = FALSE; } - if ( gmyth_uri != NULL ) - g_object_unref( gmyth_uri ); - } else { myth_handle->file_transfer = gmyth_file_transfer_new (backend_info); /* Verifies if the file exists */ - if (!gmyth_util_file_exists (backend_info, gnome_vfs_uri_get_path (uri))) { + if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) { g_object_unref (backend_info); return GNOME_VFS_ERROR_NOT_FOUND; } /* sets the Playback monitor connection */ - ret = gmyth_file_transfer_open ( myth_handle->file_transfer, gnome_vfs_uri_get_path (uri) ); + ret = gmyth_file_transfer_open ( myth_handle->file_transfer, gmyth_uri_get_path (gmyth_uri) ); } /* if - LiveTV or not? */ @@ -150,8 +149,11 @@ } g_object_unref (backend_info); - - g_return_val_if_fail (myth_handle->file_transfer != NULL, GNOME_VFS_ERROR_NOT_OPEN); + + //if ( gmyth_uri != NULL ) + // g_object_unref( gmyth_uri ); + + g_return_val_if_fail (myth_handle->file_transfer != NULL, GNOME_VFS_ERROR_NOT_OPEN); myth_handle->content_size = myth_handle->file_transfer->filesize; @@ -243,6 +245,7 @@ } if (myth_handle->livetv) { + gmyth_livetv_stop_playing(myth_handle->livetv); g_object_unref (myth_handle->livetv); myth_handle->livetv = NULL; } @@ -265,35 +268,86 @@ GnomeVFSContext *context) { GMythFileTransfer *file_transfer = NULL; - GMythBackendInfo *backend_info = NULL; + GMythLiveTV *livetv = NULL; + GMythBackendInfo *backend_info = NULL; + GMythURI *gmyth_uri = NULL; + gboolean is_livetv = FALSE; + gboolean ret = FALSE; + + /* 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 ), "" ) ); + + /* creates an instance of */ + gmyth_uri = gmyth_uri_new_with_value( + gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) ); - file_info->name = g_strdup (gnome_vfs_uri_get_path (uri)); + 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 | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS; file_info->type = GNOME_VFS_FILE_TYPE_REGULAR; - // fixme: get from file extension? + /* fixme: get from file extension? */ file_info->mime_type = g_strdup ("video/x-nuv"); file_info->permissions = GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_GROUP_READ; - backend_info = gmyth_backend_info_new_full (gnome_vfs_uri_get_host_name (uri), - gnome_vfs_uri_get_user_name (uri), - gnome_vfs_uri_get_password (uri), - NULL, - gnome_vfs_uri_get_host_port (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 ); + + if ( channel_num != -1 ) { + if (gmyth_livetv_channel_setup (livetv, channel_num, + backend_info) == FALSE) { + g_object_unref( gmyth_uri ); + ret = FALSE; + } + } else { + if ( gmyth_livetv_setup (livetv, backend_info) == FALSE ) { + g_object_unref( gmyth_uri ); + ret = FALSE; + } + } + + file_transfer = gmyth_livetv_create_file_transfer (livetv); + + if (NULL == file_transfer) { + ret = FALSE; + } + + } else { + + file_transfer = gmyth_file_transfer_new (backend_info); + + /* Verifies if the file exists */ + if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) { + g_object_unref (backend_info); + return GNOME_VFS_ERROR_NOT_FOUND; + } + + /* sets the Playback monitor connection */ + ret = gmyth_file_transfer_open ( file_transfer, gmyth_uri_get_path (gmyth_uri) ); + + } /* if - LiveTV or not? */ + + if (ret == FALSE) { + g_warning ("MythTV FileTransfer open error\n"); + return GNOME_VFS_ERROR_NOT_OPEN; + } - file_transfer = gmyth_file_transfer_new (backend_info); - if (gmyth_file_transfer_open (file_transfer, gnome_vfs_uri_get_path (uri)) == TRUE) { - file_info->size = gmyth_file_transfer_get_filesize (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->size = gmyth_file_transfer_get_filesize (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; + g_object_unref (file_transfer); + g_object_unref (livetv); g_object_unref (backend_info); return GNOME_VFS_OK; }