[svn r333] Fixed bug on do_get_file_info.
1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 07 18:29:38 2007 +0000
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 07 18:30:15 2007 +0000
1.3 @@ -285,13 +285,12 @@
1.4 GnomeVFSContext *context)
1.5 {
1.6 GMythFileTransfer *file_transfer = NULL;
1.7 - //GMythLiveTV *livetv = NULL;
1.8 + GMythLiveTV *livetv = NULL;
1.9 GMythBackendInfo *backend_info = NULL;
1.10 GMythURI *gmyth_uri = NULL;
1.11 gboolean is_livetv = FALSE;
1.12 gboolean ret = TRUE;
1.13
1.14 - file_info->size = (GnomeVFSFileSize) - 1;
1.15 /* Creates and fills out the backend info structure */
1.16 backend_info = gmyth_backend_info_new_with_uri (
1.17 gnome_vfs_unescape_string( gnome_vfs_uri_to_string( uri, GNOME_VFS_URI_HIDE_NONE ), "" ) );
1.18 @@ -302,7 +301,6 @@
1.19
1.20 is_livetv = gmyth_uri_is_livetv( gmyth_uri );
1.21
1.22 - file_info->name = g_strdup (gmyth_uri_get_path (gmyth_uri));
1.23 file_info->valid_fields = file_info->valid_fields
1.24 | GNOME_VFS_FILE_INFO_FIELDS_TYPE
1.25 | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE
1.26 @@ -314,16 +312,19 @@
1.27 GNOME_VFS_PERM_USER_READ |
1.28 GNOME_VFS_PERM_OTHER_READ |
1.29 GNOME_VFS_PERM_GROUP_READ;
1.30 +
1.31 + g_print( "gnome_vfs_uri == %s | gmyth_uri == %s.",
1.32 + gnome_vfs_uri_get_path (uri),
1.33 + gmyth_uri_get_path (gmyth_uri) );
1.34
1.35 /* Connect to the backend */
1.36 if ( gmyth_uri != NULL && is_livetv == TRUE ) {
1.37 - /*
1.38 livetv = gmyth_livetv_new ();
1.39
1.40 - gint channel_num = gmyth_uri_get_channel_num( gmyth_uri );
1.41 + gchar* channel_name = gmyth_uri_get_channel_name( gmyth_uri );
1.42
1.43 - if ( channel_num != -1 ) {
1.44 - if (gmyth_livetv_channel_setup (livetv, channel_num,
1.45 + if ( channel_name != NULL ) {
1.46 + if (gmyth_livetv_channel_name_setup (livetv, channel_name,
1.47 backend_info) == FALSE) {
1.48 g_object_unref( gmyth_uri );
1.49 ret = FALSE;
1.50 @@ -334,14 +335,18 @@
1.51 ret = FALSE;
1.52 }
1.53 }
1.54 +
1.55 + g_print( "path = %s", gmyth_uri_get_path (livetv->uri) );
1.56
1.57 file_transfer = gmyth_livetv_create_file_transfer (livetv);
1.58
1.59 if (NULL == file_transfer) {
1.60 ret = FALSE;
1.61 }
1.62 - */
1.63 + g_print( "path = %s", gmyth_uri_get_path (livetv->uri) );
1.64
1.65 + file_info->name = g_strdup ( gmyth_uri_get_path (livetv->uri) );
1.66 +
1.67 } else {
1.68
1.69 file_transfer = gmyth_file_transfer_new (backend_info);
1.70 @@ -354,6 +359,8 @@
1.71
1.72 /* sets the Playback monitor connection */
1.73 ret = gmyth_file_transfer_open ( file_transfer, gmyth_uri_get_path (gmyth_uri) );
1.74 +
1.75 + file_info->name = g_strdup ( gnome_vfs_uri_get_path (uri) );
1.76
1.77 } /* if - LiveTV or not? */
1.78
1.79 @@ -365,23 +372,46 @@
1.80 */
1.81 if ( is_livetv )
1.82 {
1.83 - /*
1.84 - GMythProgramInfo *prog_info = gmyth_recorder_get_current_program_info ( GMythRecorder *recorder )
1.85 + gint64 size = 0;
1.86 if ( file_transfer->filesize < 0 )
1.87 - file_info->size = gmyth_recorder_get_file_position( livetv->recorder );
1.88 + {
1.89 + size = gmyth_recorder_get_file_position( livetv->recorder );
1.90 + if( size < 0 ) {
1.91 + GMythProgramInfo *prog_info = gmyth_recorder_get_current_program_info ( livetv->recorder );
1.92 + size = prog_info->filesize;
1.93 +
1.94 + if ( prog_info )
1.95 + g_object_unref( prog_info );
1.96 + }
1.97 + }
1.98 + else if ( file_transfer != NULL )
1.99 + size = gmyth_file_transfer_get_filesize (file_transfer);
1.100 +
1.101 + if ( size < 0 )
1.102 + file_info->size =(GnomeVFSFileSize) - 1;
1.103 else
1.104 - */
1.105 - file_info->size =(GnomeVFSFileSize) - 1;
1.106 - } else {
1.107 + file_info->size = size;
1.108 +
1.109 + /*if ( file_transfer != NULL)
1.110 + g_object_unref (file_transfer);*/
1.111 +
1.112 + if ( livetv != NULL )
1.113 + g_object_unref (livetv);
1.114 +
1.115 + /*if ( file_transfer != NULL)
1.116 + g_object_unref (file_transfer);*/
1.117 +
1.118 + } else if ( ret == TRUE && file_transfer != NULL ) {
1.119 file_info->size = gmyth_file_transfer_get_filesize (file_transfer);
1.120 - }
1.121 + if ( file_transfer )
1.122 + g_object_unref (file_transfer);
1.123 + }
1.124 +
1.125 + file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
1.126 + file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE;
1.127
1.128 - file_info->block_count = GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
1.129 - file_info->io_block_size = GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE;
1.130 -
1.131 - g_object_unref (backend_info);
1.132 - g_object_unref (file_transfer);
1.133 - //g_object_unref (livetv);
1.134 + if (backend_info)
1.135 + g_object_unref (backend_info);
1.136
1.137 return GNOME_VFS_OK;
1.138 }