[svn r461] code rewrite trunk
authorrenatofilho
Tue Mar 27 15:36:22 2007 +0100 (2007-03-27)
branchtrunk
changeset 45696a51561bed6
parent 455 10c21aebb0ff
child 457 4a65804a0a5f
[svn r461] code rewrite
libgnomevfs2-mythtv/modules/mythtv-method.c
     1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c	Tue Mar 27 15:35:49 2007 +0100
     1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c	Tue Mar 27 15:36:22 2007 +0100
     1.3 @@ -50,6 +50,21 @@
     1.4  /* maximum number of bytes to be requested to the MythTV backend ( 64 Kbytes ) */
     1.5  #define MYTHTV_MAX_REQUEST_SIZE                     64*1024
     1.6  
     1.7 +typedef struct {
     1.8 +	GMythFileTransfer *file_transfer;
     1.9 +	GMythLiveTV *livetv;
    1.10 +    GMythBackendInfo *backend_info;
    1.11 +    GMythURI *gmyth_uri;
    1.12 +    GMythRecorder *live_recorder;
    1.13 +    gint64 offset;
    1.14 +
    1.15 +	gchar *channel_name;
    1.16 +
    1.17 +	gint mythtv_version;
    1.18 +	gboolean configured;
    1.19 +} MythtvHandle;
    1.20 +
    1.21 +
    1.22  static GnomeVFSResult do_read (GnomeVFSMethod * method,
    1.23  			       GnomeVFSMethodHandle * method_handle,
    1.24  			       gpointer buffer,
    1.25 @@ -57,29 +72,230 @@
    1.26  			       GnomeVFSFileSize * bytes_read,
    1.27  			       GnomeVFSContext * context);
    1.28  
    1.29 -typedef struct {
    1.30 -	GMythFileTransfer *file_transfer;
    1.31 -	GMythLiveTV *livetv;
    1.32 -	gchar *channel_name;
    1.33 +static GnomeVFSResult   myth_connection_start   (MythtvHandle * method_handle);
    1.34 +static void             myth_destroy_handle     (MythtvHandle * method_handle);
    1.35 +static GnomeVFSResult   myth_handle_new         (GnomeVFSURI * uri,
    1.36 +                                                 MythtvHandle ** method_handle);
    1.37 +static GnomeVFSResult   myth_get_file_info      (MythtvHandle * myth_handle,
    1.38 +                                                 GnomeVFSURI * uri,
    1.39 +                                                 GnomeVFSFileInfo * info);
    1.40  
    1.41 -	gint mythtv_version;
    1.42 -	gint64 content_size;
    1.43 -	guint64 bytes_read;
    1.44 -
    1.45 -	GByteArray *buffer;
    1.46 -	gsize buffer_remain;
    1.47 -	gboolean is_livetv;
    1.48 -
    1.49 -	gboolean configured;
    1.50 -
    1.51 -} MythtvHandle;
    1.52 -
    1.53 -//static MythtvHandle *myth_handle = NULL;
    1.54  #ifdef DEBUG
    1.55  static FILE *fpout = NULL;
    1.56  static gboolean first = TRUE;
    1.57  #endif
    1.58  
    1.59 +static GnomeVFSResult 
    1.60 +myth_handle_new (GnomeVFSURI * uri,
    1.61 +                 MythtvHandle ** method_handle)
    1.62 +{   
    1.63 +    gchar *tmp_str1;
    1.64 +    gchar *tmp_str2;
    1.65 +
    1.66 +    _GNOME_VFS_METHOD_PARAM_CHECK (*method_handle == NULL);
    1.67 +    
    1.68 +	if (gnome_vfs_uri_get_host_name (uri) == NULL) {
    1.69 +		return GNOME_VFS_ERROR_INVALID_HOST_NAME;
    1.70 +	}
    1.71 +
    1.72 +    *method_handle = g_new0 (MythtvHandle, 1);
    1.73 +    (*method_handle)->mythtv_version = MYTHTV_VERSION_DEFAULT;
    1.74 +        
    1.75 +    tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
    1.76 +    tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
    1.77 +
    1.78 +    (*method_handle)->backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
    1.79 +    (*method_handle)->gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
    1.80 +    g_free (tmp_str1);
    1.81 +    g_free (tmp_str2);
    1.82 +
    1.83 +    return GNOME_VFS_OK;
    1.84 +}   
    1.85 +
    1.86 +static void
    1.87 +myth_destroy_handle (MythtvHandle * method_handle)
    1.88 +{
    1.89 +    //TODO: abort if in tranfer state
    1.90 +    
    1.91 +    if (method_handle->backend_info != NULL) {
    1.92 +        g_object_unref (method_handle->backend_info);
    1.93 +        method_handle->backend_info = NULL;
    1.94 +    }
    1.95 +    
    1.96 +    if (method_handle->channel_name != NULL) {
    1.97 +        g_free (method_handle->channel_name);
    1.98 +        method_handle->channel_name = NULL;
    1.99 +    }
   1.100 +
   1.101 +    if (method_handle->livetv != NULL) {
   1.102 +        g_object_unref (method_handle->livetv);
   1.103 +        method_handle->livetv = NULL;
   1.104 +    }
   1.105 +
   1.106 +    if (method_handle->file_transfer != NULL) {
   1.107 +        g_object_unref (method_handle->file_transfer);
   1.108 +        method_handle->file_transfer = NULL;
   1.109 +    }
   1.110 +
   1.111 +    if (method_handle->gmyth_uri != NULL) {
   1.112 +        g_object_unref (method_handle->gmyth_uri);
   1.113 +        method_handle->gmyth_uri = NULL;
   1.114 +    }
   1.115 +
   1.116 +    g_free (method_handle);
   1.117 +}
   1.118 +
   1.119 +static GnomeVFSResult
   1.120 +myth_get_file_info (MythtvHandle * myth_handle,
   1.121 +                    GnomeVFSURI * uri,
   1.122 +                    GnomeVFSFileInfo * info)
   1.123 +{
   1.124 +    GMythURI *gmyth_uri;
   1.125 +    GMythBackendInfo *backend_info;
   1.126 +    
   1.127 +    _GNOME_VFS_METHOD_PARAM_CHECK (info != NULL);
   1.128 +
   1.129 +    if (myth_handle == NULL) {
   1.130 +        gchar *tmp_str1;
   1.131 +        gchar *tmp_str2;
   1.132 +        
   1.133 +        tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
   1.134 +        tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
   1.135 +
   1.136 +        backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
   1.137 +        gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
   1.138 +        
   1.139 +        g_free (tmp_str1);
   1.140 +        g_free (tmp_str2);
   1.141 +    } else {
   1.142 +        backend_info = g_object_ref (myth_handle->backend_info);
   1.143 +        gmyth_uri = g_object_ref (myth_handle->gmyth_uri);
   1.144 +    }
   1.145 +
   1.146 +    info->valid_fields = 0;
   1.147 +	info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE | 
   1.148 +        GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE | 
   1.149 +        GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS;
   1.150 +    
   1.151 +	info->type = GNOME_VFS_FILE_TYPE_REGULAR;
   1.152 +    
   1.153 +	/* fixme: get from file extension? */
   1.154 +	info->mime_type = g_strdup ("video/x-nuv");
   1.155 +	info->permissions = GNOME_VFS_PERM_USER_READ | 
   1.156 +        GNOME_VFS_PERM_OTHER_READ | 
   1.157 +        GNOME_VFS_PERM_GROUP_READ;
   1.158 +
   1.159 +   
   1.160 +	info->name = g_strdup (gmyth_uri_get_path (gmyth_uri));
   1.161 +
   1.162 +    /* file size for remote files */
   1.163 +    if (gmyth_uri_is_livetv (gmyth_uri) == FALSE) {
   1.164 +        GMythFileTransfer *file_transfer = gmyth_file_transfer_new (backend_info);
   1.165 +        
   1.166 +        /* Verifies if the file exists */
   1.167 +        if (!gmyth_util_file_exists (backend_info, 
   1.168 +                    gmyth_uri_get_path (gmyth_uri))) {
   1.169 +            g_object_unref (backend_info);
   1.170 +            g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
   1.171 +            return GNOME_VFS_ERROR_NOT_FOUND;
   1.172 +		}
   1.173 +	
   1.174 +		info->size = gmyth_file_transfer_get_filesize (file_transfer);
   1.175 +        info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE;
   1.176 +		g_object_unref (file_transfer);
   1.177 +	}
   1.178 +
   1.179 +    g_object_unref (backend_info);
   1.180 +    g_object_unref (gmyth_uri);
   1.181 +    
   1.182 +    return GNOME_VFS_OK;
   1.183 +}
   1.184 +
   1.185 +static GnomeVFSResult
   1.186 +myth_connection_start (MythtvHandle * method_handle)
   1.187 +{
   1.188 +    GnomeVFSResult result = GNOME_VFS_OK;
   1.189 +
   1.190 +    _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
   1.191 +    _GNOME_VFS_METHOD_PARAM_CHECK (method_handle->backend_info != NULL);
   1.192 +
   1.193 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.194 +    
   1.195 +	/* Connect to the backend */
   1.196 +	if (gmyth_uri_is_livetv (method_handle->gmyth_uri) == TRUE) {
   1.197 +        
   1.198 +        g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.199 +        
   1.200 +		method_handle->livetv = gmyth_livetv_new (method_handle->backend_info);
   1.201 +		method_handle->channel_name = gmyth_uri_get_channel_name (method_handle->gmyth_uri);
   1.202 +        
   1.203 +		g_debug ("[%s] Channel name = %s\n", __FUNCTION__, 
   1.204 +                method_handle->channel_name);
   1.205 +        
   1.206 +		if (method_handle->channel_name != NULL) {
   1.207 +		    if (gmyth_livetv_channel_name_setup (method_handle->livetv, 
   1.208 +                    method_handle->channel_name) == FALSE) {
   1.209 +                result = GNOME_VFS_ERROR_INVALID_URI;
   1.210 +    			goto error;
   1.211 +			}
   1.212 +		} else if (gmyth_livetv_setup (method_handle->livetv) == FALSE) {
   1.213 +                result = GNOME_VFS_ERROR_INVALID_URI;
   1.214 +                goto error;
   1.215 +		}
   1.216 +        
   1.217 +        g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.218 +
   1.219 +    	method_handle->file_transfer = 
   1.220 +            gmyth_livetv_create_file_transfer (method_handle->livetv);
   1.221 +
   1.222 +        if (method_handle->file_transfer == NULL) {
   1.223 +            result = GNOME_VFS_ERROR_INVALID_URI;
   1.224 +    		g_debug ("MythTV FileTransfer is NULL!\n");
   1.225 +            goto error;
   1.226 +        }
   1.227 +
   1.228 +	    if (!gmyth_file_transfer_open (method_handle->file_transfer,
   1.229 +                                        method_handle->livetv->uri != NULL ? 
   1.230 +                                        gmyth_uri_get_path (method_handle->livetv->uri) :
   1.231 +                                        method_handle->livetv->proginfo->pathname->str)) {
   1.232 +        
   1.233 +            g_debug ("Couldn't open MythTV FileTransfer is NULL!\n");
   1.234 +            result = GNOME_VFS_ERROR_NOT_OPEN;
   1.235 +            goto error;
   1.236 +        }
   1.237 +    }
   1.238 +    else {
   1.239 +        method_handle->file_transfer = 
   1.240 +            gmyth_file_transfer_new (method_handle->backend_info);
   1.241 +
   1.242 +		/* Verifies if the file exists */
   1.243 +		if (!gmyth_util_file_exists (method_handle->backend_info, 
   1.244 +                    gmyth_uri_get_path (method_handle->gmyth_uri))) {
   1.245 +
   1.246 +            g_debug ("NOT FOUND %s/%d", __FUNCTION__, __LINE__);
   1.247 +		    result = GNOME_VFS_ERROR_NOT_FOUND;
   1.248 +            goto error;
   1.249 +		}
   1.250 +
   1.251 +		/* sets the Playback monitor connection */
   1.252 +		result = gmyth_file_transfer_open (method_handle->file_transfer,
   1.253 +                  					    gmyth_uri_get_path (method_handle->gmyth_uri));
   1.254 +	} /* if - LiveTV or not? */
   1.255 +
   1.256 +	method_handle->configured = TRUE;    
   1.257 +
   1.258 +    if (method_handle->file_transfer == NULL) {
   1.259 +        result = GNOME_VFS_ERROR_NOT_OPEN;
   1.260 +        goto error;
   1.261 +    }
   1.262 +	g_return_val_if_fail (method_handle->file_transfer != NULL, 
   1.263 +            GNOME_VFS_ERROR_NOT_OPEN);
   1.264 +
   1.265 +error:
   1.266 +    
   1.267 +    return result; 
   1.268 +}
   1.269 +
   1.270  static GnomeVFSResult
   1.271  do_open (GnomeVFSMethod * method,
   1.272  	 GnomeVFSMethodHandle ** method_handle,
   1.273 @@ -87,484 +303,240 @@
   1.274  	 GnomeVFSOpenMode mode, GnomeVFSContext * context)
   1.275  {
   1.276  	MythtvHandle *myth_handle = NULL;
   1.277 -	GMythBackendInfo *backend_info = NULL;
   1.278 -	GMythURI *gmyth_uri = NULL;
   1.279 -	gboolean ret = TRUE;
   1.280 -    gchar *tmp_str1;
   1.281 -    gchar *tmp_str2;
   1.282 +    GnomeVFSResult result = GNOME_VFS_OK;
   1.283 +
   1.284 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.285  
   1.286  	_GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
   1.287  	_GNOME_VFS_METHOD_PARAM_CHECK (uri != NULL);
   1.288  
   1.289  	if (mode & GNOME_VFS_OPEN_WRITE) {
   1.290 -		return GNOME_VFS_ERROR_NOT_PERMITTED;
   1.291 +		return GNOME_VFS_ERROR_INVALID_OPEN_MODE;
   1.292  	}
   1.293  
   1.294 -	if (gnome_vfs_uri_get_host_name (uri) == NULL) {
   1.295 -		return GNOME_VFS_ERROR_INVALID_HOST_NAME;
   1.296 -	}
   1.297 +    result = myth_handle_new (uri, &myth_handle);
   1.298 +    if (result != GNOME_VFS_OK) 
   1.299 +        return result;
   1.300  
   1.301 -    // FIXME: myth_handle is always NULL here
   1.302 -	if ((NULL == myth_handle) || !myth_handle->configured) {
   1.303 -        myth_handle = g_new0 (MythtvHandle, 1);
   1.304 -        
   1.305 -        myth_handle->configured = FALSE;        
   1.306 -        myth_handle->is_livetv = FALSE;
   1.307 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.308 +    result = myth_connection_start (myth_handle);
   1.309 +    if (result != GNOME_VFS_OK) {
   1.310 +        myth_destroy_handle (myth_handle);
   1.311 +        myth_handle = NULL;
   1.312 +        return result;
   1.313 +    }
   1.314 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.315  
   1.316 -		/* Initialize mythtv handler */
   1.317 -        myth_handle->file_transfer = NULL;
   1.318 -        myth_handle->livetv = NULL;
   1.319 -        myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT;
   1.320 -        myth_handle->bytes_read = 0;
   1.321 -        myth_handle->content_size = (GnomeVFSFileSize) - 1;
   1.322 -        
   1.323 -		/* Creates and fills out the backend info structure */
   1.324 -        tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
   1.325 -        tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
   1.326 +    *method_handle = (GnomeVFSMethodHandle *) myth_handle;
   1.327 +    
   1.328 +    return result;
   1.329 +}
   1.330  
   1.331 -        backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
   1.332 +static GnomeVFSResult
   1.333 +do_create (GnomeVFSMethod	 *method,
   1.334 +	   GnomeVFSMethodHandle **method_handle,
   1.335 +	   GnomeVFSURI 		 *uri,
   1.336 +	   GnomeVFSOpenMode 	  mode,
   1.337 +	   gboolean 		  exclusive,
   1.338 +	   guint 		  perm,
   1.339 +	   GnomeVFSContext 	 *context)
   1.340 +{
   1.341 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.342 +}
   1.343  
   1.344 -        g_free (tmp_str1);
   1.345 -        g_free (tmp_str2);
   1.346 -   
   1.347 -		/* creates an instance of  */
   1.348 -        tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
   1.349 -        tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
   1.350 +static GnomeVFSResult
   1.351 +do_close (GnomeVFSMethod * method,
   1.352 +        GnomeVFSMethodHandle * method_handle, 
   1.353 +        GnomeVFSContext * context)
   1.354 +{
   1.355 +	MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
   1.356  
   1.357 -		gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
   1.358 -
   1.359 -        g_free (tmp_str1);
   1.360 -        g_free (tmp_str2);
   1.361 -
   1.362 -		myth_handle->is_livetv = gmyth_uri_is_livetv (gmyth_uri);
   1.363 -
   1.364 -		/* Connect to the backend */
   1.365 -		if (gmyth_uri != NULL && myth_handle->is_livetv == TRUE) {
   1.366 -
   1.367 -			if (NULL == myth_handle->livetv) {
   1.368 -				myth_handle->livetv = gmyth_livetv_new (backend_info);
   1.369 -
   1.370 -				myth_handle->channel_name =
   1.371 -				    gmyth_uri_get_channel_name (gmyth_uri);
   1.372 -
   1.373 -				g_debug ("[%s] Channel name = %s\n",
   1.374 -					 __FUNCTION__,
   1.375 -					 myth_handle->channel_name);
   1.376 -
   1.377 -				if (myth_handle->channel_name != NULL) {
   1.378 -					if (gmyth_livetv_channel_name_setup (myth_handle->livetv,
   1.379 -    					     myth_handle->channel_name) == FALSE) {
   1.380 -						g_object_unref (gmyth_uri);
   1.381 -						ret = FALSE;
   1.382 -					}
   1.383 -				} else {
   1.384 -					if (gmyth_livetv_setup (myth_handle->livetv) == FALSE) {
   1.385 -						g_object_unref (gmyth_uri);
   1.386 -						ret = FALSE;
   1.387 -					}
   1.388 -				}
   1.389 -			}
   1.390 -
   1.391 -			if (NULL == myth_handle->file_transfer) {
   1.392 -				myth_handle->file_transfer =
   1.393 -				    gmyth_livetv_create_file_transfer (myth_handle->livetv);
   1.394 -
   1.395 -				if (NULL == myth_handle->file_transfer) {
   1.396 -					ret = FALSE;
   1.397 -					g_debug ("MythTV FileTransfer is NULL!\n");
   1.398 -					return GNOME_VFS_ERROR_NOT_OPEN;
   1.399 -				}
   1.400 -
   1.401 -				if (!gmyth_file_transfer_open (myth_handle->file_transfer,
   1.402 -                      				     myth_handle->livetv->uri != NULL ?
   1.403 -                      				     gmyth_uri_get_path (myth_handle->livetv->uri) :
   1.404 -                    				     myth_handle->livetv->proginfo->pathname->str)) {
   1.405 -					g_debug ("Couldn't open MythTV FileTransfer is NULL!\n");
   1.406 -					g_object_unref (myth_handle->file_transfer);
   1.407 -					myth_handle->file_transfer = NULL;
   1.408 -					ret = FALSE;
   1.409 -				}
   1.410 -			} /* if - FileTransfer is NULL, or not */
   1.411 -		} else {
   1.412 -			if (NULL == myth_handle->file_transfer) {
   1.413 -
   1.414 -				myth_handle->file_transfer =
   1.415 -				    gmyth_file_transfer_new (backend_info);
   1.416 -
   1.417 -				/* Verifies if the file exists */
   1.418 -				if (!gmyth_util_file_exists (backend_info,
   1.419 -    				     gmyth_uri_get_path (gmyth_uri))) {
   1.420 -					g_object_unref (backend_info);
   1.421 -					ret = FALSE;
   1.422 -				}
   1.423 -
   1.424 -				/* sets the Playback monitor connection */
   1.425 -				ret = gmyth_file_transfer_open (myth_handle->file_transfer,
   1.426 -                       					      gmyth_uri_get_path (gmyth_uri));
   1.427 -			}
   1.428 -		} /* if - LiveTV or not? */
   1.429 -
   1.430 -		if (ret == FALSE) {
   1.431 -			g_debug ("MythTV FileTransfer open error.\n");
   1.432 -			return GNOME_VFS_ERROR_NOT_OPEN;
   1.433 -		}
   1.434 -
   1.435 -		myth_handle->configured = TRUE;
   1.436 -
   1.437 -		g_object_unref (backend_info);
   1.438 -
   1.439 -		if (gmyth_uri != NULL)
   1.440 -			g_object_unref (gmyth_uri);
   1.441 -
   1.442 -		myth_handle->buffer =
   1.443 -		    g_byte_array_sized_new (MYTHTV_BUFFER_SIZE);
   1.444 -		myth_handle->buffer_remain = 0;
   1.445 -
   1.446 -		g_return_val_if_fail (myth_handle->file_transfer != NULL,
   1.447 -				      GNOME_VFS_ERROR_NOT_OPEN);
   1.448 -
   1.449 -		if ( /*myth_handle->file_transfer->filesize <= 0 && */
   1.450 -		    myth_handle->is_livetv) {
   1.451 -			myth_handle->content_size =
   1.452 -			    gmyth_recorder_get_file_position (myth_handle->livetv->recorder);
   1.453 -		} else {
   1.454 -			myth_handle->content_size =
   1.455 -			    myth_handle->file_transfer->filesize;
   1.456 -		}
   1.457 -
   1.458 -	}
   1.459 -	/* if - configured or not? */
   1.460 -	*method_handle = (GnomeVFSMethodHandle *) myth_handle;
   1.461 -
   1.462 +    myth_destroy_handle (myth_handle);
   1.463 +    
   1.464  	return GNOME_VFS_OK;
   1.465  }
   1.466  
   1.467 +
   1.468  static GnomeVFSResult
   1.469  do_read (GnomeVFSMethod * method,
   1.470  	 GnomeVFSMethodHandle * method_handle,
   1.471  	 gpointer buffer,
   1.472  	 GnomeVFSFileSize num_bytes,
   1.473  	 GnomeVFSFileSize * bytes_read, 
   1.474 -     GnomeVFSContext * context)
   1.475 +         GnomeVFSContext * context)
   1.476  {
   1.477 -	MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
   1.478 -	GnomeVFSFileSize bytes_to_read = num_bytes;
   1.479 +    GnomeVFSResult result;
   1.480 +    MythtvHandle *myth_handle;
   1.481 +    gint64 total_read = 0;
   1.482 +    GByteArray *myth_buffer = g_byte_array_new ();
   1.483  
   1.484 -	if (!myth_handle->is_livetv
   1.485 -	    && (myth_handle->bytes_read >= myth_handle->content_size))
   1.486 -		return GNOME_VFS_ERROR_EOF;
   1.487 +    _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
   1.488  
   1.489 -	/* fixme: change this to min math function */
   1.490 -	if ((myth_handle->content_size > 0)) {
   1.491 -		if (!myth_handle->is_livetv &&
   1.492 -		    (num_bytes >
   1.493 -		     (myth_handle->content_size -
   1.494 -		      myth_handle->bytes_read))) {
   1.495 -			bytes_to_read =
   1.496 -			    myth_handle->content_size -
   1.497 -			    myth_handle->bytes_read;
   1.498 -		}
   1.499 -	}
   1.500 +    
   1.501 +    myth_handle = (MythtvHandle *) method_handle;
   1.502 +    result = GNOME_VFS_OK;
   1.503  
   1.504 -	/* Loop sending the Myth File Transfer request:
   1.505 -	 * Retry whilst authentication fails and we supply it. */
   1.506 -	if ((myth_handle->buffer_remain =
   1.507 -	     myth_handle->buffer->len) < bytes_to_read) {
   1.508 -		gint buffer_size;
   1.509 +    g_debug ("Reading %"G_GUINT64_FORMAT" bytes", num_bytes);
   1.510 +    
   1.511 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.512  
   1.513 -		while (MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain) {
   1.514 -			/* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */
   1.515 -			if ((MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain) <=
   1.516 -    			    MYTHTV_MAX_REQUEST_SIZE)
   1.517 -				buffer_size = MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain;
   1.518 -			else
   1.519 -				buffer_size = MYTHTV_MAX_REQUEST_SIZE;
   1.520 +    total_read = gmyth_file_transfer_read (myth_handle->file_transfer,
   1.521 +                              		   myth_buffer,
   1.522 +                         		   num_bytes, gmyth_uri_is_livetv (myth_handle->gmyth_uri));
   1.523  
   1.524 -			GByteArray *tmp_buffer = g_byte_array_new ();
   1.525  
   1.526 -			g_debug ("Asking %d bytes (there is %d bytes in the buffer)\n",
   1.527 -			     buffer_size, myth_handle->buffer_remain);
   1.528 +    g_debug ("total read %"G_GINT64_FORMAT, total_read);
   1.529  
   1.530 -			gint len = gmyth_file_transfer_read (myth_handle->file_transfer,
   1.531 -                    					         tmp_buffer,
   1.532 -					                             buffer_size, TRUE);
   1.533 +    if (total_read == -1) {
   1.534 +        result = GNOME_VFS_ERROR_IO;
   1.535 +        total_read = 0;
   1.536 +    }
   1.537  
   1.538 -			if ( !myth_handle->is_livetv ) {
   1.539 -				if ( len < 0 ) {
   1.540 -					g_byte_array_free (tmp_buffer, TRUE);
   1.541 -					g_debug ("Fail to read bytes");
   1.542 -					return GNOME_VFS_ERROR_IO;
   1.543 -				} else if ( len == 0 ) {
   1.544 -				   g_byte_array_free (tmp_buffer, TRUE);
   1.545 -				   g_warning ("End of file probably achieved");
   1.546 -				   return GNOME_VFS_ERROR_EOF;
   1.547 -			   }
   1.548 -			} /* if */
   1.549 -			
   1.550 -			myth_handle->buffer =
   1.551 -			    g_byte_array_append (myth_handle->buffer,
   1.552 -						 tmp_buffer->data, len);
   1.553 +    if (total_read < num_bytes) {
   1.554 +        result = GNOME_VFS_ERROR_EOF;
   1.555 +    }
   1.556  
   1.557 -			myth_handle->buffer_remain += len;
   1.558 +    g_debug ("F: %s L: %d", __FUNCTION__, __LINE__);
   1.559  
   1.560 -			if (tmp_buffer != NULL) {
   1.561 -				g_byte_array_free (tmp_buffer, TRUE);
   1.562 -				tmp_buffer = NULL;
   1.563 -			}
   1.564 -		}		/* while - iterates until fills the internal buffer */
   1.565 +    
   1.566 +    if (total_read > 0) {
   1.567 +	g_memmove (buffer, myth_buffer->data, total_read);
   1.568 +        g_byte_array_free (myth_buffer, TRUE);
   1.569 +        myth_handle->offset += total_read;
   1.570 +    } else {
   1.571 +        g_debug ("Nao leu nada");
   1.572 +    }
   1.573  
   1.574 -	}
   1.575 -        
   1.576 -	/* if - got from the network, or not */
   1.577 -	bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ? 
   1.578 -                        myth_handle->buffer_remain : bytes_to_read;
   1.579 -	/* gets the first buffer_size bytes from the byte array buffer variable */
   1.580  
   1.581 -	g_memmove (buffer, myth_handle->buffer->data, bytes_to_read);
   1.582 +    *bytes_read = (GnomeVFSFileSize) total_read;
   1.583  
   1.584 -	myth_handle->bytes_read += bytes_to_read;
   1.585 -	myth_handle->buffer_remain -= bytes_to_read;
   1.586 -
   1.587 -	/* flushs the newly buffer got from byte array */
   1.588 -	myth_handle->buffer =
   1.589 -	    g_byte_array_remove_range (myth_handle->buffer, 0,
   1.590 -				       bytes_to_read);
   1.591 -	g_debug
   1.592 -	    ("Got from %llu bytes from internal buffer. (there are %d bytes in the buffer, from a total of %llu dispatched.)\n",
   1.593 -	     bytes_to_read, myth_handle->buffer_remain,
   1.594 -	     myth_handle->bytes_read);
   1.595 -
   1.596 -	*bytes_read = bytes_to_read;
   1.597 -
   1.598 -	return GNOME_VFS_OK;
   1.599 +	return result;
   1.600  }
   1.601  
   1.602  static GnomeVFSResult
   1.603 -do_close (GnomeVFSMethod * method,
   1.604 -	  GnomeVFSMethodHandle * method_handle, GnomeVFSContext * context)
   1.605 +do_write (GnomeVFSMethod 	*method,
   1.606 +	  GnomeVFSMethodHandle  *method_handle,
   1.607 +	  gconstpointer 	 buffer,
   1.608 +	  GnomeVFSFileSize 	 num_bytes,
   1.609 +	  GnomeVFSFileSize 	*bytes_written,
   1.610 +	  GnomeVFSContext 	*context)
   1.611  {
   1.612 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.613 +}
   1.614  
   1.615 -	MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
   1.616 +static GnomeVFSResult
   1.617 +do_seek (GnomeVFSMethod	      *method,
   1.618 +	 GnomeVFSMethodHandle *method_handle,
   1.619 +	 GnomeVFSSeekPosition  whence,
   1.620 +	 GnomeVFSFileOffset    offset,
   1.621 +	 GnomeVFSContext      *context)
   1.622 +{
   1.623 +	MythtvHandle *myth_handle;
   1.624 +    guint64 whence_p = 0;
   1.625 +    gint64 new_offset =0;
   1.626  
   1.627 -	//if ( NULL == myth_handle || myth_handle->configured ) {
   1.628 +     _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
   1.629  
   1.630 -	if (myth_handle->is_livetv && myth_handle->livetv != NULL) {
   1.631 -		g_object_unref (myth_handle->livetv);
   1.632 -		myth_handle->livetv = NULL;
   1.633 -	}
   1.634 -   
   1.635 -	if (myth_handle->file_transfer != NULL) {
   1.636 -		g_object_unref (myth_handle->file_transfer);
   1.637 -		myth_handle->file_transfer = NULL;
   1.638 -	}
   1.639 +     myth_handle = (MythtvHandle *) method_handle;    
   1.640 +    
   1.641 +    g_debug ("seek offset%"G_GINT64_FORMAT" whence %d", offset, whence);
   1.642  
   1.643 -	if (myth_handle->buffer) {
   1.644 -		g_byte_array_free (myth_handle->buffer, TRUE);
   1.645 -		myth_handle->buffer = NULL;
   1.646 -	}
   1.647 +    if (gmyth_uri_is_livetv (myth_handle->gmyth_uri))
   1.648 +        return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.649 +    
   1.650 +    switch (whence)
   1.651 +    {
   1.652 +        case GNOME_VFS_SEEK_START:
   1.653 +            whence_p = 0;
   1.654 +            break;
   1.655 +        case GNOME_VFS_SEEK_CURRENT:
   1.656 +            whence_p = myth_handle->offset;
   1.657 +            break;
   1.658 +        case GNOME_VFS_SEEK_END:
   1.659 +            return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.660 +    }
   1.661 +    
   1.662 +    new_offset = gmyth_file_transfer_seek (myth_handle->file_transfer, offset, whence_p);
   1.663 +    if (new_offset != 0) {
   1.664 +        myth_handle->offset = new_offset;
   1.665 +        return GNOME_VFS_OK;
   1.666 +    }
   1.667  
   1.668 -	myth_handle->configured = FALSE;
   1.669 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.670 +}
   1.671  
   1.672 -	g_free (myth_handle->channel_name);
   1.673 +static GnomeVFSResult
   1.674 +do_tell (GnomeVFSMethod       *method,
   1.675 +	 GnomeVFSMethodHandle *method_handle,
   1.676 +	 GnomeVFSFileSize   *offset_return)
   1.677 +{
   1.678 +	MythtvHandle *myth_handle = NULL;
   1.679      
   1.680 -	g_free (myth_handle);
   1.681 +     _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
   1.682 +     
   1.683 +    myth_handle = (MythtvHandle *) method_handle;
   1.684 +    *offset_return = myth_handle->offset;
   1.685  
   1.686 -	myth_handle = NULL;
   1.687 +    return GNOME_VFS_OK;
   1.688 +}
   1.689  
   1.690 -	// }
   1.691 +static GnomeVFSResult
   1.692 +do_truncate_handle (GnomeVFSMethod *method,
   1.693 +		    GnomeVFSMethodHandle *method_handle,
   1.694 +		    GnomeVFSFileSize where,
   1.695 +		    GnomeVFSContext *context)
   1.696 +{
   1.697 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.698 +}
   1.699  
   1.700 -	return GNOME_VFS_OK;
   1.701 +static GnomeVFSResult
   1.702 +do_open_directory (GnomeVFSMethod 	    *method,
   1.703 +		   GnomeVFSMethodHandle    **method_handle,
   1.704 +		   GnomeVFSURI 		    *uri,
   1.705 +		   GnomeVFSFileInfoOptions   options,
   1.706 +		   GnomeVFSContext 	    *context) 
   1.707 +{
   1.708 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.709  }
   1.710  
   1.711  static GnomeVFSResult
   1.712 +do_close_directory (GnomeVFSMethod 	 *method,
   1.713 +		    GnomeVFSMethodHandle *method_handle,
   1.714 +		    GnomeVFSContext 	 *context) 
   1.715 +{
   1.716 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.717 +}
   1.718 +
   1.719 +static GnomeVFSResult
   1.720 +do_read_directory (GnomeVFSMethod 	*method,
   1.721 +       		   GnomeVFSMethodHandle *method_handle,
   1.722 +       		   GnomeVFSFileInfo 	*file_info,
   1.723 +		   GnomeVFSContext 	*context)
   1.724 +{
   1.725 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.726 +}
   1.727 +
   1.728 +
   1.729 +static GnomeVFSResult
   1.730  do_get_file_info (GnomeVFSMethod * method,
   1.731  		  GnomeVFSURI * uri,
   1.732  		  GnomeVFSFileInfo * file_info,
   1.733  		  GnomeVFSFileInfoOptions options,
   1.734  		  GnomeVFSContext * context)
   1.735  {
   1.736 -	GMythFileTransfer *file_transfer = NULL;
   1.737 -	GMythRecorder *recorder = NULL;
   1.738 -	GMythTVChain *tvchain = NULL;
   1.739 -	GMythBackendInfo *backend_info = NULL;
   1.740 -	GMythURI *gmyth_uri = NULL;
   1.741 -	GMythSocket *socket = NULL;
   1.742 -	gboolean is_livetv = FALSE;
   1.743 -    gchar *tmp_str1;
   1.744 -    gchar *tmp_str2;
   1.745 +    return myth_get_file_info (NULL, uri, file_info);
   1.746 +}
   1.747  
   1.748 -	gboolean ret = TRUE;
   1.749 -	gboolean res = TRUE;
   1.750 +static GnomeVFSResult
   1.751 +do_get_file_info_from_handle (GnomeVFSMethod 		*method,
   1.752 +            			      GnomeVFSMethodHandle 	*method_handle,
   1.753 +			                  GnomeVFSFileInfo 		*file_info,
   1.754 +            			      GnomeVFSFileInfoOptions    options,
   1.755 +			                  GnomeVFSContext 		*context)
   1.756 +{
   1.757 +	MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
   1.758  
   1.759 -	/* Creates and fills out the backend info structure */        
   1.760 -    tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
   1.761 -    tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
   1.762 -
   1.763 -	backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
   1.764 -    g_free (tmp_str1);
   1.765 -    g_free (tmp_str2);
   1.766 -
   1.767 -	/* creates an instance of */
   1.768 -    tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
   1.769 -    tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
   1.770 -
   1.771 -	gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
   1.772 -    g_free (tmp_str1);
   1.773 -    g_free (tmp_str2);
   1.774 -
   1.775 -	is_livetv = gmyth_uri_is_livetv (gmyth_uri);
   1.776 -
   1.777 -    file_info->valid_fields = 0;
   1.778 -	file_info->valid_fields = file_info->valid_fields
   1.779 -	    | GNOME_VFS_FILE_INFO_FIELDS_TYPE
   1.780 -	    | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE
   1.781 -	    | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS;
   1.782 -	file_info->type = GNOME_VFS_FILE_TYPE_REGULAR;
   1.783 -	/* fixme: get from file extension? */
   1.784 -	file_info->mime_type = g_strdup ("video/x-nuv");
   1.785 -	file_info->permissions =
   1.786 -	    GNOME_VFS_PERM_USER_READ |
   1.787 -	    GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_GROUP_READ;
   1.788 -
   1.789 -	g_debug ("gnome_vfs_uri == %s | gmyth_uri == %s.\n",
   1.790 -		 gnome_vfs_uri_get_path (uri),
   1.791 -		 gmyth_uri_get_path (gmyth_uri));
   1.792 -
   1.793 -	/* Connect to the backend */
   1.794 -	if (gmyth_uri != NULL && is_livetv == TRUE) {
   1.795 -
   1.796 -		/* start to get file info from LiveTV remote encoder */
   1.797 -		socket = gmyth_socket_new ();
   1.798 -
   1.799 -		/* FIME: Implement this at gmyth_socket */
   1.800 -		res =
   1.801 -		    gmyth_socket_connect_to_backend (socket,
   1.802 -						     backend_info->hostname,
   1.803 -						     backend_info->port,
   1.804 -						     TRUE);
   1.805 -		if (!res) {
   1.806 -			g_debug ("[%s] LiveTV can not connect to backend",  __FUNCTION__);
   1.807 -			res = FALSE;
   1.808 -			goto error;
   1.809 -		}
   1.810 -
   1.811 -		if (gmyth_remote_util_get_free_recorder_count (socket) <= 0) {
   1.812 -			g_debug ("No free remote encoder available.");
   1.813 -			res = FALSE;
   1.814 -			goto error;
   1.815 -		}
   1.816 -
   1.817 -		/* Gets the recorder num */
   1.818 -		recorder = remote_request_next_free_recorder (socket, -1);
   1.819 -
   1.820 -		if (socket != NULL)
   1.821 -			g_object_unref (socket);
   1.822 -
   1.823 -		if (recorder == NULL) {
   1.824 -			g_debug ("[%s] None remote encoder available", __FUNCTION__);
   1.825 -			res = FALSE;
   1.826 -			goto error;
   1.827 -		}
   1.828 -
   1.829 -		/* Init remote encoder. Opens its control socket. */
   1.830 -		res = gmyth_recorder_setup (recorder);
   1.831 -		if (!res) {
   1.832 -			g_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
   1.833 -			res = FALSE;
   1.834 -			goto error;
   1.835 -		}
   1.836 -
   1.837 -		/* Creates livetv chain handler */
   1.838 -		tvchain = gmyth_tvchain_new ();
   1.839 -		gmyth_tvchain_initialize (tvchain, backend_info);
   1.840 -
   1.841 -		if (tvchain == NULL || tvchain->tvchain_id == NULL) {
   1.842 -			res = FALSE;
   1.843 -			goto error;
   1.844 -		}
   1.845 -		/* Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) */
   1.846 -		res = gmyth_recorder_spawntv (recorder, gmyth_tvchain_get_id(tvchain));
   1.847 -		if (!res) {
   1.848 -			g_warning ("[%s] Fail while spawn tv\n",
   1.849 -				   __FUNCTION__);
   1.850 -			res = FALSE;
   1.851 -			goto error;
   1.852 -		}
   1.853 -		
   1.854 -		sleep(1);
   1.855 -
   1.856 -		/* DEBUG message */
   1.857 -		GMythProgramInfo *prog_info =
   1.858 -		    gmyth_recorder_get_current_program_info (recorder);
   1.859 -
   1.860 -		if (prog_info != NULL) {
   1.861 -
   1.862 -			g_debug ("path = %s", prog_info->pathname->str);
   1.863 -
   1.864 -			file_info->name =
   1.865 -			    g_strdup (g_strrstr
   1.866 -				      (prog_info->pathname->str, "/"));
   1.867 -
   1.868 -		} else {
   1.869 -			file_info->name = g_strdup ("LiveTV.nuv");
   1.870 -            /* Size being overrided below ... */
   1.871 -			//file_info->size = gmyth_recorder_get_file_position (recorder);
   1.872 -		}
   1.873 -
   1.874 -		if (recorder != NULL)
   1.875 -			g_object_unref (recorder);
   1.876 -
   1.877 -		if (prog_info != NULL)
   1.878 -			g_object_unref (prog_info);
   1.879 -
   1.880 -		if (tvchain != NULL)
   1.881 -			g_object_unref (tvchain);
   1.882 -
   1.883 -		//file_info->size = (GnomeVFSFileSize) - 1;
   1.884 -
   1.885 -	} else {
   1.886 -
   1.887 -        /* start to get file info from remote file encoder */
   1.888 -        file_transfer = gmyth_file_transfer_new (backend_info);
   1.889 -
   1.890 -		/* Verifies if the file exists */
   1.891 -    	if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) {
   1.892 -            g_object_unref (backend_info);
   1.893 -            return GNOME_VFS_ERROR_NOT_FOUND;
   1.894 -		}
   1.895 -
   1.896 -		/* sets the Playback monitor connection */
   1.897 -		ret = gmyth_file_transfer_open (file_transfer,
   1.898 -					      gmyth_uri_get_path (gmyth_uri));
   1.899 -
   1.900 -		file_info->name = g_strdup (gnome_vfs_uri_get_path (uri));
   1.901 -
   1.902 -	} /* if - LiveTV or not? */
   1.903 -
   1.904 -	if (ret == FALSE) {
   1.905 -		g_debug ("MythTV FileTransfer open error\n");
   1.906 -		return GNOME_VFS_ERROR_NOT_OPEN;
   1.907 -	}
   1.908 -
   1.909 -    /* Just for recorded content */
   1.910 -	if (ret == TRUE && file_transfer != NULL) {
   1.911 -		file_info->size =
   1.912 -		    gmyth_file_transfer_get_filesize (file_transfer);
   1.913 -
   1.914 -        file_info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE;
   1.915 -        
   1.916 -		if (file_transfer)
   1.917 -			g_object_unref (file_transfer);
   1.918 -	}
   1.919 -
   1.920 -error:
   1.921 -	if (backend_info)
   1.922 -		g_object_unref (backend_info);
   1.923 -
   1.924 -	if (!res)
   1.925 -		return GNOME_VFS_ERROR_IO;
   1.926 -
   1.927 -	return GNOME_VFS_OK;
   1.928 +    return myth_get_file_info (myth_handle, NULL, file_info);
   1.929  }
   1.930  
   1.931  static gboolean
   1.932 @@ -573,34 +545,146 @@
   1.933  	return FALSE;
   1.934  }
   1.935  
   1.936 +static GnomeVFSResult
   1.937 +do_make_directory (GnomeVFSMethod  *method, 
   1.938 +		            GnomeVFSURI     *uri,
   1.939 +                    guint 	    perm, 
   1.940 +		            GnomeVFSContext *context) 
   1.941 +{
   1.942 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.943 +}
   1.944 +
   1.945 +static GnomeVFSResult 
   1.946 +do_remove_directory (GnomeVFSMethod  *method, 
   1.947 +		             GnomeVFSURI     *uri, 
   1.948 +		             GnomeVFSContext *context) 
   1.949 +{
   1.950 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.951 +}
   1.952 +
   1.953 +static GnomeVFSResult
   1.954 +do_move (GnomeVFSMethod  *method,
   1.955 +	 GnomeVFSURI 	 *old_uri,
   1.956 +	 GnomeVFSURI 	 *new_uri,
   1.957 +	 gboolean         force_replace,
   1.958 +	 GnomeVFSContext *context)
   1.959 +{
   1.960 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.961 +}
   1.962 +
   1.963 +static GnomeVFSResult 
   1.964 +do_unlink (GnomeVFSMethod  *method,
   1.965 +	   GnomeVFSURI 	   *uri,
   1.966 +	   GnomeVFSContext *context)
   1.967 +{
   1.968 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.969 +}
   1.970 +
   1.971 +static GnomeVFSResult 
   1.972 +do_check_same_fs (GnomeVFSMethod  *method,
   1.973 +		  GnomeVFSURI 	  *a,
   1.974 +		  GnomeVFSURI 	  *b,
   1.975 +		  gboolean 	  *same_fs_return,
   1.976 +		  GnomeVFSContext *context)
   1.977 +{
   1.978 +    return GNOME_VFS_ERROR_NOT_SUPPORTED;
   1.979 +}
   1.980 +
   1.981 +static GnomeVFSResult
   1.982 +do_set_file_info (GnomeVFSMethod 		*method,
   1.983 +		  GnomeVFSURI 			*uri,
   1.984 +		  const GnomeVFSFileInfo 	*info,
   1.985 +		  GnomeVFSSetFileInfoMask 	 mask,
   1.986 +		  GnomeVFSContext 		*context)
   1.987 +{
   1.988 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.989 +}
   1.990 +
   1.991 +static GnomeVFSResult
   1.992 +do_truncate (GnomeVFSMethod *method,
   1.993 +	     GnomeVFSURI *uri,
   1.994 +	     GnomeVFSFileSize where,
   1.995 +	     GnomeVFSContext *context)
   1.996 +{
   1.997 +    return GNOME_VFS_ERROR_READ_ONLY;
   1.998 +}
   1.999 +
  1.1000 +static GnomeVFSResult
  1.1001 +do_find_directory (GnomeVFSMethod *method,
  1.1002 +		   GnomeVFSURI *near_uri,
  1.1003 +		   GnomeVFSFindDirectoryKind kind,
  1.1004 +		   GnomeVFSURI **result_uri,
  1.1005 +		   gboolean create_if_needed,
  1.1006 +		   gboolean find_if_needed,
  1.1007 +		   guint permissions,
  1.1008 +		   GnomeVFSContext *context)
  1.1009 +{
  1.1010 +	return GNOME_VFS_ERROR_NOT_SUPPORTED;
  1.1011 +}
  1.1012 +
  1.1013 +static GnomeVFSResult
  1.1014 +do_create_symbolic_link (GnomeVFSMethod *method,
  1.1015 +			 GnomeVFSURI *uri,
  1.1016 +			 const char *target_reference,
  1.1017 +			 GnomeVFSContext *context)
  1.1018 +{
  1.1019 +    return GNOME_VFS_ERROR_READ_ONLY;
  1.1020 +}
  1.1021 +
  1.1022 +static GnomeVFSResult
  1.1023 +do_monitor_add (GnomeVFSMethod *method,
  1.1024 +		GnomeVFSMethodHandle **method_handle_return,
  1.1025 +		GnomeVFSURI *uri,
  1.1026 +		GnomeVFSMonitorType monitor_type)
  1.1027 +{
  1.1028 +	return GNOME_VFS_ERROR_NOT_SUPPORTED;
  1.1029 +}
  1.1030 +
  1.1031 +static GnomeVFSResult
  1.1032 +do_monitor_cancel (GnomeVFSMethod *method,
  1.1033 +		   GnomeVFSMethodHandle *method_handle)
  1.1034 +{
  1.1035 +	return GNOME_VFS_ERROR_NOT_SUPPORTED;
  1.1036 +}
  1.1037 +
  1.1038 +static GnomeVFSResult
  1.1039 +do_file_control (GnomeVFSMethod *method,
  1.1040 +		 GnomeVFSMethodHandle *method_handle,
  1.1041 +		 const char *operation,
  1.1042 +		 gpointer operation_data,
  1.1043 +		 GnomeVFSContext *context)
  1.1044 +{
  1.1045 +	return GNOME_VFS_ERROR_NOT_SUPPORTED;
  1.1046 +}
  1.1047 +
  1.1048  static GnomeVFSMethod method = {
  1.1049  	sizeof (GnomeVFSMethod),
  1.1050 -	do_open,
  1.1051 -	NULL,
  1.1052 +	do_open, 
  1.1053 +	do_create,
  1.1054  	do_close,
  1.1055 -	do_read,
  1.1056 -	NULL,
  1.1057 -	NULL,
  1.1058 -	NULL,
  1.1059 -	NULL,
  1.1060 -	NULL,
  1.1061 -	NULL,
  1.1062 -	NULL,
  1.1063 +	do_read, 
  1.1064 +	do_write,
  1.1065 +	do_seek,
  1.1066 +	do_tell,
  1.1067 +	do_truncate_handle, 
  1.1068 +	do_open_directory,
  1.1069 +	do_close_directory,
  1.1070 +	do_read_directory,
  1.1071  	do_get_file_info,
  1.1072 -	NULL,
  1.1073 -	do_is_local,
  1.1074 -	NULL,
  1.1075 -	NULL,
  1.1076 -	NULL,
  1.1077 -	NULL,
  1.1078 -	NULL,
  1.1079 -	NULL,
  1.1080 -	NULL,
  1.1081 -	NULL,
  1.1082 -	NULL,
  1.1083 -	NULL,
  1.1084 -	NULL,
  1.1085 -	NULL,
  1.1086 +	do_get_file_info_from_handle,
  1.1087 +	do_is_local, 
  1.1088 +	do_make_directory, 
  1.1089 +	do_remove_directory,
  1.1090 +	do_move,
  1.1091 +	do_unlink,
  1.1092 +	do_check_same_fs,
  1.1093 +	do_set_file_info,
  1.1094 +	do_truncate, 
  1.1095 +	do_find_directory, 
  1.1096 +	do_create_symbolic_link,  
  1.1097 +	do_monitor_add,  
  1.1098 +	do_monitor_cancel,  
  1.1099 +	do_file_control 	
  1.1100  };
  1.1101  
  1.1102