1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Thu Apr 05 15:26:47 2007 +0100
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Apr 25 01:07:56 2007 +0100
1.3 @@ -29,7 +29,9 @@
1.4 #include <libgnomevfs/gnome-vfs-module.h>
1.5 #include <libgnomevfs/gnome-vfs-utils.h>
1.6
1.7 +#include <gmyth/gmyth_file.h>
1.8 #include <gmyth/gmyth_file_transfer.h>
1.9 +#include <gmyth/gmyth_file_local.h>
1.10 #include <gmyth/gmyth_livetv.h>
1.11 #include <gmyth/gmyth_uri.h>
1.12 #include <gmyth/gmyth_recorder.h>
1.13 @@ -51,7 +53,7 @@
1.14 #define MYTHTV_MAX_REQUEST_SIZE 64*1024
1.15
1.16 typedef struct {
1.17 - GMythFileTransfer *file_transfer;
1.18 + GMythFile *file;
1.19 GMythLiveTV *livetv;
1.20 GMythBackendInfo *backend_info;
1.21 GMythURI *gmyth_uri;
1.22 @@ -128,9 +130,9 @@
1.23 method_handle->livetv = NULL;
1.24 }
1.25
1.26 - if (method_handle->file_transfer != NULL) {
1.27 - g_object_unref (method_handle->file_transfer);
1.28 - method_handle->file_transfer = NULL;
1.29 + if (method_handle->file != NULL) {
1.30 + g_object_unref (method_handle->file);
1.31 + method_handle->file = NULL;
1.32 }
1.33
1.34 if (method_handle->gmyth_uri != NULL) {
1.35 @@ -187,27 +189,37 @@
1.36
1.37 /* file size for remote files */
1.38 if (gmyth_uri_is_livetv (gmyth_uri) == FALSE) {
1.39 - GMythFileTransfer *file_transfer = gmyth_file_transfer_new (backend_info);
1.40 -
1.41 + GMythFile *file = NULL;
1.42 + gboolean ret = FALSE;
1.43 +
1.44 /* Verifies if the file exists */
1.45 if (!gmyth_util_file_exists (backend_info,
1.46 gmyth_uri_get_path (gmyth_uri))) {
1.47 - g_object_unref (file_transfer);
1.48 + g_object_unref (file);
1.49 g_object_unref (backend_info);
1.50 g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
1.51 return GNOME_VFS_ERROR_NOT_FOUND;
1.52 }
1.53
1.54 - if (!gmyth_file_transfer_open (file_transfer, gmyth_uri_get_path (gmyth_uri))) {
1.55 - g_object_unref (file_transfer);
1.56 + if ( gmyth_uri_is_local_file(gmyth_uri) )
1.57 + {
1.58 + file = GMYTH_FILE( gmyth_file_local_new(backend_info) );
1.59 + ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( file ) );
1.60 + } else {
1.61 + file = GMYTH_FILE( gmyth_file_transfer_new(backend_info) );
1.62 + ret = gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(file), gmyth_uri_get_path (gmyth_uri));
1.63 + }
1.64 +
1.65 + if (!ret) {
1.66 + g_object_unref (file);
1.67 g_object_unref (backend_info);
1.68 g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
1.69 return GNOME_VFS_ERROR_NOT_FOUND;
1.70 }
1.71
1.72 - info->size = gmyth_file_transfer_get_filesize (file_transfer);
1.73 + info->size = gmyth_file_get_filesize (file);
1.74 info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE;
1.75 - g_object_unref (file_transfer);
1.76 + g_object_unref (file);
1.77 }
1.78
1.79 g_object_unref (backend_info);
1.80 @@ -241,16 +253,16 @@
1.81 }
1.82
1.83
1.84 - method_handle->file_transfer =
1.85 - gmyth_livetv_create_file_transfer (method_handle->livetv);
1.86 + method_handle->file =
1.87 + GMYTH_FILE( gmyth_livetv_create_file_transfer (method_handle->livetv) );
1.88
1.89 - if (method_handle->file_transfer == NULL) {
1.90 + if (method_handle->file == NULL) {
1.91 result = GNOME_VFS_ERROR_INVALID_URI;
1.92 g_debug ("MythTV FileTransfer is NULL!\n");
1.93 goto error;
1.94 }
1.95
1.96 - if (!gmyth_file_transfer_open (method_handle->file_transfer,
1.97 + if (!gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(method_handle->file),
1.98 method_handle->livetv->uri != NULL ?
1.99 gmyth_uri_get_path (method_handle->livetv->uri) :
1.100 method_handle->livetv->proginfo->pathname->str)) {
1.101 @@ -261,9 +273,7 @@
1.102 }
1.103 }
1.104 else {
1.105 - method_handle->file_transfer =
1.106 - gmyth_file_transfer_new (method_handle->backend_info);
1.107 -
1.108 + gboolean ret = TRUE;
1.109 /* Verifies if the file exists */
1.110 if (!gmyth_util_file_exists (method_handle->backend_info,
1.111 gmyth_uri_get_path (method_handle->gmyth_uri))) {
1.112 @@ -271,10 +281,19 @@
1.113 g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
1.114 goto error;
1.115 }
1.116 +
1.117 + if ( gmyth_uri_is_local_file(method_handle->gmyth_uri) )
1.118 + {
1.119 + method_handle->file = GMYTH_FILE( gmyth_file_local_new(method_handle->backend_info) );
1.120 + ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( method_handle->file ) );
1.121 + } else {
1.122 + method_handle->file = GMYTH_FILE( gmyth_file_transfer_new(method_handle->backend_info) );
1.123 + ret = gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(method_handle->file),
1.124 + gmyth_uri_get_path (method_handle->gmyth_uri));
1.125 + }
1.126
1.127 /* sets the Playback monitor connection */
1.128 - if (!gmyth_file_transfer_open (method_handle->file_transfer,
1.129 - gmyth_uri_get_path (method_handle->gmyth_uri))) {
1.130 + if (!ret) {
1.131
1.132 g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
1.133 result = GNOME_VFS_ERROR_NOT_FOUND;
1.134 @@ -284,7 +303,7 @@
1.135
1.136 method_handle->configured = TRUE;
1.137
1.138 - if (method_handle->file_transfer == NULL) {
1.139 + if (method_handle->file == NULL) {
1.140 result = GNOME_VFS_ERROR_NOT_OPEN;
1.141 }
1.142
1.143 @@ -360,22 +379,27 @@
1.144 {
1.145 GnomeVFSResult retval = GNOME_VFS_OK;
1.146 MythtvHandle *myth_handle;
1.147 - GMythFileTransferReadResult result;
1.148 + GMythFileReadResult result;
1.149 GByteArray *myth_buffer = g_byte_array_new ();
1.150
1.151 _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
1.152
1.153 myth_handle = (MythtvHandle *) method_handle;
1.154 - result = gmyth_file_transfer_read (myth_handle->file_transfer,
1.155 + if ( gmyth_uri_is_local_file(myth_handle->gmyth_uri) )
1.156 + result = gmyth_file_local_read ( GMYTH_FILE_LOCAL(myth_handle->file),
1.157 + myth_buffer,
1.158 + num_bytes, gmyth_uri_is_livetv (myth_handle->gmyth_uri));
1.159 + else
1.160 + result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(myth_handle->file),
1.161 myth_buffer,
1.162 num_bytes, gmyth_uri_is_livetv (myth_handle->gmyth_uri));
1.163
1.164
1.165 - if (result == GMYTH_FILE_TRANSFER_READ_ERROR) {
1.166 + if (result == GMYTH_FILE_READ_ERROR) {
1.167 retval = GNOME_VFS_ERROR_IO;
1.168 }
1.169
1.170 - if (result == GMYTH_FILE_TRANSFER_READ_EOF) {
1.171 + if (result == GMYTH_FILE_READ_EOF) {
1.172 retval = GNOME_VFS_ERROR_EOF;
1.173 }
1.174
1.175 @@ -433,7 +457,7 @@
1.176 return GNOME_VFS_ERROR_NOT_SUPPORTED;
1.177 }
1.178
1.179 - new_offset = gmyth_file_transfer_seek (myth_handle->file_transfer, offset, whence_p);
1.180 + new_offset = gmyth_file_transfer_seek (myth_handle->file, offset, whence_p);
1.181 if (new_offset != 0) {
1.182 myth_handle->offset = new_offset;
1.183 return GNOME_VFS_OK;