From 018da9c95a2bfdd9aaef8a5d02e94265c6bcae1f Mon Sep 17 00:00:00 2001 From: short <> Date: Mon, 1 Sep 2003 14:55:50 +0000 Subject: [PATCH] Store 'HttpFileHandle' into 'GnomeVFSMethodHandle' by indirect. - Permits us to close&create new 'HttpFileHandle' in the meantime. --- modules/http-method.c | 52 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/modules/http-method.c b/modules/http-method.c index c2b3dc7..0c4d49e 100644 --- a/modules/http-method.c +++ b/modules/http-method.c @@ -1654,6 +1654,10 @@ http_handle_close (HttpFileHandle *handle, ANALYZE_HTTP ("==> -http_handle_close"); } +typedef struct { + HttpFileHandle *http_file_handle; + } GnomeVFSHttpMethodHandle; + static GnomeVFSResult do_open (GnomeVFSMethod *method, GnomeVFSMethodHandle **method_handle, @@ -1662,6 +1666,7 @@ do_open (GnomeVFSMethod *method, GnomeVFSContext *context) { HttpFileHandle *handle; + GnomeVFSHttpMethodHandle *http_method_handle; GnomeVFSResult result = GNOME_VFS_OK; g_return_val_if_fail (uri->parent == NULL, GNOME_VFS_ERROR_INVALID_URI); @@ -1680,7 +1685,9 @@ do_open (GnomeVFSMethod *method, handle = http_file_handle_new(NULL, uri); /* shrug */ } if (result == GNOME_VFS_OK) { - *method_handle = (GnomeVFSMethodHandle *) handle; + http_method_handle = g_new (GnomeVFSHttpMethodHandle, 1); + http_method_handle->http_file_handle = handle; + *method_handle = (GnomeVFSMethodHandle *) http_method_handle; } else { *method_handle = NULL; } @@ -1775,6 +1782,7 @@ do_close (GnomeVFSMethod *method, GnomeVFSMethodHandle *method_handle, GnomeVFSContext *context) { + GnomeVFSHttpMethodHandle *http_method_handle; HttpFileHandle *old_handle; HttpFileHandle *new_handle; GnomeVFSResult result; @@ -1782,8 +1790,10 @@ do_close (GnomeVFSMethod *method, ANALYZE_HTTP ("==> +do_close"); DEBUG_HTTP (("+Close handle:0x%08x", (unsigned int)method_handle)); - old_handle = (HttpFileHandle *) method_handle; - + http_method_handle = (GnomeVFSHttpMethodHandle *) method_handle; + old_handle = http_method_handle->http_file_handle; + g_free (http_method_handle); + /* if the handle was opened in write mode then: * 1) there won't be a connection open, and * 2) there will be data to_be_written... @@ -1843,7 +1853,7 @@ do_write (GnomeVFSMethod *method, DEBUG_HTTP (("+Write handle:0x%08x", (unsigned int)method_handle)); - handle = (HttpFileHandle *) method_handle; + handle = ((GnomeVFSHttpMethodHandle *) method_handle)->http_file_handle; if(handle->to_be_written == NULL) { handle->to_be_written = g_byte_array_new(); @@ -1871,7 +1881,7 @@ do_read (GnomeVFSMethod *method, ANALYZE_HTTP ("==> +do_read"); DEBUG_HTTP (("+Read handle=0x%08x", (unsigned int) method_handle)); - handle = (HttpFileHandle *) method_handle; + handle = ((GnomeVFSHttpMethodHandle *) method_handle)->http_file_handle; if (handle->file_info->flags & GNOME_VFS_FILE_INFO_FIELDS_SIZE) { GnomeVFSFileSize max_bytes; @@ -2203,9 +2213,14 @@ make_propfind_request (HttpFileHandle **handle_return, if (result == GNOME_VFS_OK) { do { - result = do_read (NULL, (GnomeVFSMethodHandle *) *handle_return, + GnomeVFSHttpMethodHandle *http_method_handle; + + http_method_handle = g_new (GnomeVFSHttpMethodHandle, 1); + http_method_handle->http_file_handle = *handle_return; + result = do_read (NULL, (GnomeVFSMethodHandle *) http_method_handle, buffer, num_bytes, &bytes_read, context); - + g_free (http_method_handle); + if (result != GNOME_VFS_OK ) { break; } @@ -2321,6 +2336,7 @@ do_open_directory(GnomeVFSMethod *method, HttpFileHandle *handle = NULL; GnomeVFSFileInfo * file_info_cached; GList *child_file_info_cached_list = NULL; + GnomeVFSHttpMethodHandle *http_method_handle; ANALYZE_HTTP ("==> +do_open_directory"); DEBUG_HTTP (("+Open_Directory options: %d URI: '%s'", options, gnome_vfs_uri_to_string (uri, 0))); @@ -2374,8 +2390,11 @@ do_open_directory(GnomeVFSMethod *method, handle = NULL; } } - - *method_handle = (GnomeVFSMethodHandle *)handle; + + http_method_handle = g_new (GnomeVFSHttpMethodHandle, 1); + http_method_handle->http_file_handle = handle; + + *method_handle = (GnomeVFSMethodHandle *)http_method_handle; error: DEBUG_HTTP (("-Open_Directory (%d) handle:0x%08x", result, (unsigned int)handle)); @@ -2390,11 +2409,14 @@ do_close_directory (GnomeVFSMethod *method, GnomeVFSContext *context) { HttpFileHandle *handle; + GnomeVFSHttpMethodHandle *http_method_handle; DEBUG_HTTP (("+Close_Directory")); - - handle = (HttpFileHandle *) method_handle; - + + http_method_handle = (GnomeVFSHttpMethodHandle *) method_handle; + handle = http_method_handle->http_file_handle; + g_free (http_method_handle); + http_handle_close(handle, context); DEBUG_HTTP (("-Close_Directory (0) handle:0x%08x", (unsigned int) method_handle)); @@ -2413,7 +2435,7 @@ do_read_directory (GnomeVFSMethod *method, DEBUG_HTTP (("+Read_Directory handle:0x%08x", (unsigned int) method_handle)); - handle = (HttpFileHandle *) method_handle; + handle = ((GnomeVFSHttpMethodHandle *) method_handle)->http_file_handle; if (handle->files && g_list_length (handle->files)) { GnomeVFSFileInfo *original_info = g_list_nth_data (handle->files, 0); @@ -2551,8 +2573,8 @@ do_get_file_info_from_handle (GnomeVFSMethod *method, DEBUG_HTTP (("+Get_File_Info_From_Handle")); - handle = (HttpFileHandle *) method_handle; - + handle = ((GnomeVFSHttpMethodHandle *) method_handle)->http_file_handle; + gnome_vfs_file_info_copy (file_info, handle->file_info); DEBUG_HTTP (("-Get_File_Info_From_Handle")); -- 1.8.3.1