# HG changeset patch
# User renatofilho
# Date 1175010300 -3600
# Node ID 0683ea324debc0af9d69659da0c38162f341cf97
# Parent  cde4aad8577a43676296fcbc79073f1c75790df7
[svn r466] fixed remote files read

diff -r cde4aad8577a -r 0683ea324deb libgnomevfs2-mythtv/modules/mythtv-method.c
--- a/libgnomevfs2-mythtv/modules/mythtv-method.c	Tue Mar 27 16:12:15 2007 +0100
+++ b/libgnomevfs2-mythtv/modules/mythtv-method.c	Tue Mar 27 16:45:00 2007 +0100
@@ -149,6 +149,7 @@
     GMythBackendInfo *backend_info;
     
     _GNOME_VFS_METHOD_PARAM_CHECK (info != NULL);
+    
 
     if (myth_handle == NULL) {
         gchar *tmp_str1;
@@ -190,10 +191,18 @@
         /* Verifies if the file exists */
         if (!gmyth_util_file_exists (backend_info, 
                     gmyth_uri_get_path (gmyth_uri))) {
+            g_object_unref (file_transfer);
             g_object_unref (backend_info);
             g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
             return GNOME_VFS_ERROR_NOT_FOUND;
 		}
+
+        if (!gmyth_file_transfer_open (file_transfer, gmyth_uri_get_path (gmyth_uri))) {
+            g_object_unref (file_transfer);
+            g_object_unref (backend_info);
+            g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
+            return GNOME_VFS_ERROR_NOT_FOUND;
+        }
 	
 		info->size = gmyth_file_transfer_get_filesize (file_transfer);
         info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE;
@@ -214,11 +223,8 @@
     _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
     _GNOME_VFS_METHOD_PARAM_CHECK (method_handle->backend_info != NULL);
 
-    
 	/* Connect to the backend */
 	if (gmyth_uri_is_livetv (method_handle->gmyth_uri) == TRUE) {
-        
-        
 		method_handle->livetv = gmyth_livetv_new (method_handle->backend_info);
 		method_handle->channel_name = gmyth_uri_get_channel_name (method_handle->gmyth_uri);
         
@@ -265,23 +271,24 @@
                     gmyth_uri_get_path (method_handle->gmyth_uri))) {
 
             g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
-		    result = GNOME_VFS_ERROR_NOT_FOUND;
             goto error;
 		}
 
 		/* sets the Playback monitor connection */
-		result = gmyth_file_transfer_open (method_handle->file_transfer,
-                  					    gmyth_uri_get_path (method_handle->gmyth_uri));
+		if (!gmyth_file_transfer_open (method_handle->file_transfer,
+                  					    gmyth_uri_get_path (method_handle->gmyth_uri))) {
+
+            g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
+		    result = GNOME_VFS_ERROR_NOT_FOUND;
+            goto error;
+        }
 	} /* if - LiveTV or not? */
 
 	method_handle->configured = TRUE;    
 
     if (method_handle->file_transfer == NULL) {
         result = GNOME_VFS_ERROR_NOT_OPEN;
-        goto error;
     }
-	g_return_val_if_fail (method_handle->file_transfer != NULL, 
-            GNOME_VFS_ERROR_NOT_OPEN);
 
 error:
     
@@ -314,6 +321,7 @@
         myth_handle = NULL;
         return result;
     }
+
     *method_handle = (GnomeVFSMethodHandle *) myth_handle;
     
     return result;
@@ -359,7 +367,6 @@
 
     _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
 
-    
     myth_handle = (MythtvHandle *) method_handle;
     result = GNOME_VFS_OK;
 
@@ -382,7 +389,7 @@
         g_byte_array_free (myth_buffer, TRUE);
         myth_handle->offset += total_read;
     } 
-
+    
     *bytes_read = (GnomeVFSFileSize) total_read;
 
 	return result;