[svn r298] Fixes problem with the get_file_info method, ehich takes the gnomvfs plug-in to do invalid g_free.
1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Jan 24 14:51:46 2007 +0000
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Jan 24 18:53:43 2007 +0000
1.3 @@ -53,7 +53,7 @@
1.4 gint channel_num;
1.5
1.6 gint mythtv_version;
1.7 - guint64 content_size;
1.8 + gint64 content_size;
1.9 guint64 bytes_read;
1.10
1.11 GByteArray *buffer;
1.12 @@ -91,7 +91,7 @@
1.13 myth_handle->livetv = NULL;
1.14 myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT;
1.15 myth_handle->bytes_read = 0;
1.16 - myth_handle->content_size = -1;
1.17 + myth_handle->content_size = 0;
1.18
1.19 /* Creates and fills out the backend info structure */
1.20 backend_info = gmyth_backend_info_new_with_uri (
1.21 @@ -100,9 +100,11 @@
1.22 /* creates an instance of */
1.23 gmyth_uri = gmyth_uri_new_with_value(
1.24 gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) );
1.25 -
1.26 +
1.27 + is_livetv = gmyth_uri_is_livetv( gmyth_uri );
1.28 +
1.29 /* Connect to the backend */
1.30 - if ( gmyth_uri != NULL && ( is_livetv = gmyth_uri_is_livetv( gmyth_uri ) ) == TRUE ) {
1.31 + if ( gmyth_uri != NULL && is_livetv == TRUE ) {
1.32 myth_handle->livetv = gmyth_livetv_new ();
1.33
1.34 myth_handle->channel_num = gmyth_uri_get_channel_num( gmyth_uri );
1.35 @@ -126,21 +128,18 @@
1.36 ret = FALSE;
1.37 }
1.38
1.39 - if ( gmyth_uri != NULL )
1.40 - g_object_unref( gmyth_uri );
1.41 -
1.42 } else {
1.43
1.44 myth_handle->file_transfer = gmyth_file_transfer_new (backend_info);
1.45
1.46 /* Verifies if the file exists */
1.47 - if (!gmyth_util_file_exists (backend_info, gnome_vfs_uri_get_path (uri))) {
1.48 + if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) {
1.49 g_object_unref (backend_info);
1.50 return GNOME_VFS_ERROR_NOT_FOUND;
1.51 }
1.52
1.53 /* sets the Playback monitor connection */
1.54 - ret = gmyth_file_transfer_open ( myth_handle->file_transfer, gnome_vfs_uri_get_path (uri) );
1.55 + ret = gmyth_file_transfer_open ( myth_handle->file_transfer, gmyth_uri_get_path (gmyth_uri) );
1.56
1.57 } /* if - LiveTV or not? */
1.58
1.59 @@ -150,8 +149,11 @@
1.60 }
1.61
1.62 g_object_unref (backend_info);
1.63 -
1.64 - g_return_val_if_fail (myth_handle->file_transfer != NULL, GNOME_VFS_ERROR_NOT_OPEN);
1.65 +
1.66 + //if ( gmyth_uri != NULL )
1.67 + // g_object_unref( gmyth_uri );
1.68 +
1.69 + g_return_val_if_fail (myth_handle->file_transfer != NULL, GNOME_VFS_ERROR_NOT_OPEN);
1.70
1.71 myth_handle->content_size = myth_handle->file_transfer->filesize;
1.72
1.73 @@ -243,6 +245,7 @@
1.74 }
1.75
1.76 if (myth_handle->livetv) {
1.77 + gmyth_livetv_stop_playing(myth_handle->livetv);
1.78 g_object_unref (myth_handle->livetv);
1.79 myth_handle->livetv = NULL;
1.80 }
1.81 @@ -265,35 +268,86 @@
1.82 GnomeVFSContext *context)
1.83 {
1.84 GMythFileTransfer *file_transfer = NULL;
1.85 - GMythBackendInfo *backend_info = NULL;
1.86 + GMythLiveTV *livetv = NULL;
1.87 + GMythBackendInfo *backend_info = NULL;
1.88 + GMythURI *gmyth_uri = NULL;
1.89 + gboolean is_livetv = FALSE;
1.90 + gboolean ret = FALSE;
1.91 +
1.92 + /* Creates and fills out the backend info structure */
1.93 + backend_info = gmyth_backend_info_new_with_uri (
1.94 + gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) );
1.95 +
1.96 + /* creates an instance of */
1.97 + gmyth_uri = gmyth_uri_new_with_value(
1.98 + gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) );
1.99
1.100 - file_info->name = g_strdup (gnome_vfs_uri_get_path (uri));
1.101 + is_livetv = gmyth_uri_is_livetv( gmyth_uri );
1.102 +
1.103 + file_info->name = g_strdup (gmyth_uri_get_path (gmyth_uri));
1.104 file_info->valid_fields = file_info->valid_fields
1.105 | GNOME_VFS_FILE_INFO_FIELDS_TYPE
1.106 | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE
1.107 | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS;
1.108 file_info->type = GNOME_VFS_FILE_TYPE_REGULAR;
1.109 - // fixme: get from file extension?
1.110 + /* fixme: get from file extension? */
1.111 file_info->mime_type = g_strdup ("video/x-nuv");
1.112 file_info->permissions =
1.113 GNOME_VFS_PERM_USER_READ |
1.114 GNOME_VFS_PERM_OTHER_READ |
1.115 GNOME_VFS_PERM_GROUP_READ;
1.116
1.117 - backend_info = gmyth_backend_info_new_full (gnome_vfs_uri_get_host_name (uri),
1.118 - gnome_vfs_uri_get_user_name (uri),
1.119 - gnome_vfs_uri_get_password (uri),
1.120 - NULL,
1.121 - gnome_vfs_uri_get_host_port (uri));
1.122 + /* Connect to the backend */
1.123 + if ( gmyth_uri != NULL && is_livetv == TRUE ) {
1.124 + livetv = gmyth_livetv_new ();
1.125 +
1.126 + gint channel_num = gmyth_uri_get_channel_num( gmyth_uri );
1.127 +
1.128 + if ( channel_num != -1 ) {
1.129 + if (gmyth_livetv_channel_setup (livetv, channel_num,
1.130 + backend_info) == FALSE) {
1.131 + g_object_unref( gmyth_uri );
1.132 + ret = FALSE;
1.133 + }
1.134 + } else {
1.135 + if ( gmyth_livetv_setup (livetv, backend_info) == FALSE ) {
1.136 + g_object_unref( gmyth_uri );
1.137 + ret = FALSE;
1.138 + }
1.139 + }
1.140 +
1.141 + file_transfer = gmyth_livetv_create_file_transfer (livetv);
1.142 +
1.143 + if (NULL == file_transfer) {
1.144 + ret = FALSE;
1.145 + }
1.146 +
1.147 + } else {
1.148 +
1.149 + file_transfer = gmyth_file_transfer_new (backend_info);
1.150 +
1.151 + /* Verifies if the file exists */
1.152 + if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) {
1.153 + g_object_unref (backend_info);
1.154 + return GNOME_VFS_ERROR_NOT_FOUND;
1.155 + }
1.156 +
1.157 + /* sets the Playback monitor connection */
1.158 + ret = gmyth_file_transfer_open ( file_transfer, gmyth_uri_get_path (gmyth_uri) );
1.159 +
1.160 + } /* if - LiveTV or not? */
1.161 +
1.162 + if (ret == FALSE) {
1.163 + g_warning ("MythTV FileTransfer open error\n");
1.164 + return GNOME_VFS_ERROR_NOT_OPEN;
1.165 + }
1.166
1.167 - file_transfer = gmyth_file_transfer_new (backend_info);
1.168 - if (gmyth_file_transfer_open (file_transfer, gnome_vfs_uri_get_path (uri)) == TRUE) {
1.169 - file_info->size = gmyth_file_transfer_get_filesize (file_transfer);
1.170 - file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
1.171 - file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE;
1.172 - }
1.173 -
1.174 + file_info->size = gmyth_file_transfer_get_filesize (file_transfer);
1.175 + file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
1.176 + file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE;
1.177 +
1.178 g_object_unref (file_transfer);
1.179 + g_object_unref (livetv);
1.180 g_object_unref (backend_info);
1.181 return GNOME_VFS_OK;
1.182 }