Commit b1aa2326 authored by Darin Adler's avatar Darin Adler

Updated for new GNOME VFS.

	* libnautilus/nautilus-directory.c
	(read_some_metafile_data), (metafile_read_start),
	(metafile_write_create_callback), (metafile_write_start),
	(nautilus_directory_monitor_files_ref):
	* libnautilus/gdk-pixbuf-extensions.c
	(nautilus_gdk_pixbuf_load_async):
	* src/ntl-uri-map.c (got_metadata_callback):
	* components/html/ntl-web-browser.c (browser_vfs_callback),
	(do_vfs_load):
	Update for the new GNOME VFS which doesn't return an immediate error
	code when doing an async. call.
parent d7f2206f
2000-04-13 Darin Adler <darin@eazel.com>
Updated for new GNOME VFS.
* libnautilus/nautilus-directory.c
(read_some_metafile_data), (metafile_read_start),
(metafile_write_create_callback), (metafile_write_start),
(nautilus_directory_monitor_files_ref):
* libnautilus/gdk-pixbuf-extensions.c
(nautilus_gdk_pixbuf_load_async):
* src/ntl-uri-map.c (got_metadata_callback):
* components/html/ntl-web-browser.c (browser_vfs_callback),
(do_vfs_load):
Update for the new GNOME VFS which doesn't return an immediate error
code when doing an async. call.
2000-04-12 Andy Hertzfeld <andy@eazel.com>
* src/ntl-window-msgs.c:
improved the title of uri's not handled by gnome-vfs; instead of "Nautilus" use the text
after the colon, if there is any
improved the title of uri's not handled by gnome-vfs; instead of
"Nautilus" use the text after the colon, if there is any
* components/services/startup/nautilus-service-startup-view.c:
used Gene's escaping routine in gnome-vfs to escape http parameters as necessary
used Gene's escaping routine in gnome-vfs to escape http
parameters as necessary
* libnautilus/nautilus-directory.c:
weakened assert in metadata callback to allow non-vfs uris to continue to work
weakened assert in metadata callback to allow non-vfs uris to
continue to work
2000-04-12 Andy Hertzfeld <andy@eazel.com>
......
......@@ -367,22 +367,18 @@ browser_vfs_callback(GnomeVFSAsyncHandle *h, GnomeVFSResult res, gpointer data)
}
else
{
res = gnome_vfs_async_read(h, vfs_read_buf, sizeof(vfs_read_buf), browser_vfs_read_callback, vfsh);
g_message("Did read, result was %s", gnome_vfs_result_to_string(res));
gnome_vfs_async_read(h, vfs_read_buf, sizeof(vfs_read_buf), browser_vfs_read_callback, vfsh);
}
}
static void
do_vfs_load(VFSHandle *vfsh)
{
GnomeVFSResult res;
GnomeVFSAsyncHandle *ah;
g_warning("Falling back to gnome-vfs for %s", vfsh->url);
res = gnome_vfs_async_open(&ah, vfsh->url, GNOME_VFS_OPEN_READ, browser_vfs_callback, vfsh);
return;
gnome_vfs_async_open(&ah, vfsh->url, GNOME_VFS_OPEN_READ, browser_vfs_callback, vfsh);
}
static void
......
......@@ -109,6 +109,7 @@ static void metafile_read_failed
static void metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
gpointer callback_data);
static void metafile_read_some (NautilusDirectory *directory);
static void metafile_read_start (NautilusDirectory *directory);
static void metafile_write (NautilusDirectory *directory);
static void metafile_write_callback (GnomeVFSAsyncHandle *handle,
......@@ -143,7 +144,6 @@ static GnomeVFSDirectoryListPosition nautilus_gnome_vfs_directory_list_get_next_
GnomeVFSDirectoryListPosition position);
static void nautilus_gnome_vfs_file_info_list_free (GList *list);
static void nautilus_gnome_vfs_file_info_list_unref (GList *list);
static void read_some_metafile_data (NautilusDirectory *directory);
static void schedule_dequeue_pending (NautilusDirectory *directory);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
......@@ -490,7 +490,7 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
* check. I don't want to stop until the end of the file.
*/
if (bytes_read == bytes_requested && result == GNOME_VFS_OK) {
read_some_metafile_data (directory);
metafile_read_some (directory);
return;
}
......@@ -502,23 +502,18 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
}
static void
read_some_metafile_data (NautilusDirectory *directory)
metafile_read_some (NautilusDirectory *directory)
{
GnomeVFSResult result;
directory->details->read_state->buffer = g_realloc
(directory->details->read_state->buffer,
directory->details->read_state->bytes_read + READ_CHUNK_SIZE);
result = gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
}
static void
......@@ -536,26 +531,21 @@ metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
return;
}
read_some_metafile_data (directory);
metafile_read_some (directory);
}
static void
metafile_read_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
result = gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
}
static void
......@@ -650,38 +640,30 @@ metafile_write_create_callback (GnomeVFSAsyncHandle *handle,
return;
}
result = gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
}
static void
metafile_write_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
directory->details->write_state->write_again = FALSE;
/* Open the file. */
result = gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
}
static void
......@@ -898,8 +880,6 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback callback,
gpointer callback_data)
{
GnomeVFSResult result;
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (callback != NULL);
......@@ -926,7 +906,7 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
g_assert (directory->details->uri->text != NULL);
directory->details->directory_load_list_last_handled
= GNOME_VFS_DIRECTORY_LIST_POSITION_NONE;
result = gnome_vfs_async_load_directory_uri
gnome_vfs_async_load_directory_uri
(&directory->details->directory_load_in_progress, /* handle */
directory->details->uri, /* uri */
(GNOME_VFS_FILE_INFO_GETMIMETYPE /* options */
......
......@@ -142,21 +142,16 @@ nautilus_gdk_pixbuf_load_async (const char *uri,
gpointer callback_data)
{
NautilusPixbufLoadHandle *handle;
GnomeVFSResult result;
handle = g_new0 (NautilusPixbufLoadHandle, 1);
handle->callback = callback;
handle->callback_data = callback_data;
result = gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
if (result != GNOME_VFS_OK) {
load_done (handle, result, NULL);
return NULL;
}
gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
return handle;
}
......
......@@ -109,6 +109,7 @@ static void metafile_read_failed
static void metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
gpointer callback_data);
static void metafile_read_some (NautilusDirectory *directory);
static void metafile_read_start (NautilusDirectory *directory);
static void metafile_write (NautilusDirectory *directory);
static void metafile_write_callback (GnomeVFSAsyncHandle *handle,
......@@ -143,7 +144,6 @@ static GnomeVFSDirectoryListPosition nautilus_gnome_vfs_directory_list_get_next_
GnomeVFSDirectoryListPosition position);
static void nautilus_gnome_vfs_file_info_list_free (GList *list);
static void nautilus_gnome_vfs_file_info_list_unref (GList *list);
static void read_some_metafile_data (NautilusDirectory *directory);
static void schedule_dequeue_pending (NautilusDirectory *directory);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
......@@ -490,7 +490,7 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
* check. I don't want to stop until the end of the file.
*/
if (bytes_read == bytes_requested && result == GNOME_VFS_OK) {
read_some_metafile_data (directory);
metafile_read_some (directory);
return;
}
......@@ -502,23 +502,18 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
}
static void
read_some_metafile_data (NautilusDirectory *directory)
metafile_read_some (NautilusDirectory *directory)
{
GnomeVFSResult result;
directory->details->read_state->buffer = g_realloc
(directory->details->read_state->buffer,
directory->details->read_state->bytes_read + READ_CHUNK_SIZE);
result = gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
}
static void
......@@ -536,26 +531,21 @@ metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
return;
}
read_some_metafile_data (directory);
metafile_read_some (directory);
}
static void
metafile_read_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
result = gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
}
static void
......@@ -650,38 +640,30 @@ metafile_write_create_callback (GnomeVFSAsyncHandle *handle,
return;
}
result = gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
}
static void
metafile_write_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
directory->details->write_state->write_again = FALSE;
/* Open the file. */
result = gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
}
static void
......@@ -898,8 +880,6 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback callback,
gpointer callback_data)
{
GnomeVFSResult result;
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (callback != NULL);
......@@ -926,7 +906,7 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
g_assert (directory->details->uri->text != NULL);
directory->details->directory_load_list_last_handled
= GNOME_VFS_DIRECTORY_LIST_POSITION_NONE;
result = gnome_vfs_async_load_directory_uri
gnome_vfs_async_load_directory_uri
(&directory->details->directory_load_in_progress, /* handle */
directory->details->uri, /* uri */
(GNOME_VFS_FILE_INFO_GETMIMETYPE /* options */
......
......@@ -142,21 +142,16 @@ nautilus_gdk_pixbuf_load_async (const char *uri,
gpointer callback_data)
{
NautilusPixbufLoadHandle *handle;
GnomeVFSResult result;
handle = g_new0 (NautilusPixbufLoadHandle, 1);
handle->callback = callback;
handle->callback_data = callback_data;
result = gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
if (result != GNOME_VFS_OK) {
load_done (handle, result, NULL);
return NULL;
}
gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
return handle;
}
......
......@@ -109,6 +109,7 @@ static void metafile_read_failed
static void metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
gpointer callback_data);
static void metafile_read_some (NautilusDirectory *directory);
static void metafile_read_start (NautilusDirectory *directory);
static void metafile_write (NautilusDirectory *directory);
static void metafile_write_callback (GnomeVFSAsyncHandle *handle,
......@@ -143,7 +144,6 @@ static GnomeVFSDirectoryListPosition nautilus_gnome_vfs_directory_list_get_next_
GnomeVFSDirectoryListPosition position);
static void nautilus_gnome_vfs_file_info_list_free (GList *list);
static void nautilus_gnome_vfs_file_info_list_unref (GList *list);
static void read_some_metafile_data (NautilusDirectory *directory);
static void schedule_dequeue_pending (NautilusDirectory *directory);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
......@@ -490,7 +490,7 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
* check. I don't want to stop until the end of the file.
*/
if (bytes_read == bytes_requested && result == GNOME_VFS_OK) {
read_some_metafile_data (directory);
metafile_read_some (directory);
return;
}
......@@ -502,23 +502,18 @@ metafile_read_callback (GnomeVFSAsyncHandle *handle,
}
static void
read_some_metafile_data (NautilusDirectory *directory)
metafile_read_some (NautilusDirectory *directory)
{
GnomeVFSResult result;
directory->details->read_state->buffer = g_realloc
(directory->details->read_state->buffer,
directory->details->read_state->bytes_read + READ_CHUNK_SIZE);
result = gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_read (directory->details->read_state->handle,
(char *) directory->details->read_state->buffer
+ directory->details->read_state->bytes_read,
READ_CHUNK_SIZE,
metafile_read_callback,
directory);
}
static void
......@@ -536,26 +531,21 @@ metafile_read_open_callback (GnomeVFSAsyncHandle *handle,
return;
}
read_some_metafile_data (directory);
metafile_read_some (directory);
}
static void
metafile_read_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
result = gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_read_failed (directory, result);
}
gnome_vfs_async_open_uri (&directory->details->read_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_READ,
metafile_read_open_callback,
directory);
}
static void
......@@ -650,38 +640,30 @@ metafile_write_create_callback (GnomeVFSAsyncHandle *handle,
return;
}
result = gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_write (directory->details->write_state->handle,
directory->details->write_state->buffer,
directory->details->write_state->size,
metafile_write_callback,
directory);
}
static void
metafile_write_start (NautilusDirectory *directory)
{
GnomeVFSResult result;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
directory->details->write_state->write_again = FALSE;
/* Open the file. */
result = gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
if (result != GNOME_VFS_OK) {
metafile_write_failed (directory, result);
}
gnome_vfs_async_create_uri (&directory->details->write_state->handle,
directory->details->use_alternate_metafile
? directory->details->alternate_metafile_uri
: directory->details->metafile_uri,
GNOME_VFS_OPEN_WRITE,
FALSE,
METAFILE_PERMISSIONS,
metafile_write_create_callback,
directory);
}
static void
......@@ -898,8 +880,6 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback callback,
gpointer callback_data)
{
GnomeVFSResult result;
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (callback != NULL);
......@@ -926,7 +906,7 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
g_assert (directory->details->uri->text != NULL);
directory->details->directory_load_list_last_handled
= GNOME_VFS_DIRECTORY_LIST_POSITION_NONE;
result = gnome_vfs_async_load_directory_uri
gnome_vfs_async_load_directory_uri
(&directory->details->directory_load_in_progress, /* handle */
directory->details->uri, /* uri */
(GNOME_VFS_FILE_INFO_GETMIMETYPE /* options */
......
......@@ -142,21 +142,16 @@ nautilus_gdk_pixbuf_load_async (const char *uri,
gpointer callback_data)
{
NautilusPixbufLoadHandle *handle;
GnomeVFSResult result;
handle = g_new0 (NautilusPixbufLoadHandle, 1);
handle->callback = callback;
handle->callback_data = callback_data;
result = gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
if (result != GNOME_VFS_OK) {
load_done (handle, result, NULL);
return NULL;
}
gnome_vfs_async_open (&handle->vfs_handle,
uri,
GNOME_VFS_OPEN_READ,
file_opened_callback,
handle);
return handle;
}
......
......@@ -423,26 +423,17 @@ got_metadata_callback (NautilusDirectory *directory,
gpointer callback_data)
{
NautilusNavigationInfo *info;
GnomeVFSResult result;
info = callback_data;
g_assert (info->directory == directory);
result = gnome_vfs_async_get_file_info (&info->ah,
info->navinfo.requested_uri,
(GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS),
NULL,
my_notify_when_ready,
info);
if (result != GNOME_VFS_OK) {
/* Note: Not sure if or when this case ever occurs. result == GNOME_VFS_OK
* for normally-handled uris, for non-existent uris, and for uris for which
* Nautilus has no content viewer.
*/
my_notify_when_ready (NULL, result, NULL, info);
}
gnome_vfs_async_get_file_info (&info->ah,
info->navinfo.requested_uri,
(GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS),
NULL,
my_notify_when_ready,
info);
}
/* NautilusNavigationInfo */
......
......@@ -423,26 +423,17 @@ got_metadata_callback (NautilusDirectory *directory,
gpointer callback_data)
{
NautilusNavigationInfo *info;
GnomeVFSResult result;
info = callback_data;
g_assert (info->directory == directory);
result = gnome_vfs_async_get_file_info (&info->ah,
info->navinfo.requested_uri,
(GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS),
NULL,
my_notify_when_ready,
info);
if (result != GNOME_VFS_OK) {
/* Note: Not sure if or when this case ever occurs. result == GNOME_VFS_OK
* for normally-handled uris, for non-existent uris, and for uris for which
* Nautilus has no content viewer.
*/
my_notify_when_ready (NULL, result, NULL, info);
}
gnome_vfs_async_get_file_info (&info->ah,
info->navinfo.requested_uri,
(GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS),
NULL,
my_notify_when_ready,
info);
}
/* NautilusNavigationInfo */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment