/*--------------------------------------------------------------------------*/ static void download_files( GnomeVFSURI *uri, GList *list, gint n ) { GnomeVFSFileInfo *info; GnomeVFSURI *file_uri; DownloadCallbackData *data; gint total_bytes; GList *p; gchar *status_string; gb_debug (DEBUG_UPDATE, "START"); if ( list ) { status_string = g_strdup_printf( _("Downloading redemption tables...") ); gtk_label_set_text( GTK_LABEL(status_label), status_string ); g_free( status_string ); total_bytes = 0; for ( p=list; p!=NULL; p=p->next ) { info = (GnomeVFSFileInfo *)p->data; total_bytes += info->size; } data = g_new0( DownloadCallbackData, 1 ); data->i = 0; data->n = n; data->total_bytes_read = 0; data->total_bytes = total_bytes; data->list = list; data->p = list; data->uri = uri; data->buffer = g_malloc0( 4096 ); data->buffer_length = 4096; data->line_buffer = g_malloc0( 4096 ); data->local_handle = NULL; info = (GnomeVFSFileInfo *)data->p->data; gb_debug (DEBUG_UPDATE, "Opening %s", info->name ); file_uri = gnome_vfs_uri_append_file_name( data->uri, info->name ); gb_debug (DEBUG_UPDATE, " URI = %s", gnome_vfs_uri_to_string (file_uri, 0) ); gnome_vfs_async_open_uri (&remote_file_handle, file_uri, GNOME_VFS_OPEN_READ, 0, open_remote_file_callback, data); } else { no_download(); } gb_debug (DEBUG_UPDATE, "END"); }
/* Set up the read handle and start reading. */ static GnomeVFSAsyncHandle * test_read_file_async (GnomeVFSURI *uri) { GnomeVFSAsyncHandle *result; gnome_vfs_async_open_uri (&result, uri, GNOME_VFS_OPEN_READ, 0, test_read_file_open_callback, NULL); return result; }
/*--------------------------------------------------------------------------*/ static void close_remote_file_callback( GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer callback_data ) { DownloadCallbackData *data = (DownloadCallbackData *)callback_data; GnomeVFSFileInfo *info; GnomeVFSURI *file_uri; gb_debug (DEBUG_UPDATE, "START"); if ( data->local_handle ) { gnome_vfs_close( data->local_handle ); data->local_handle = NULL; } if ( update_cancel_flag ) { gtk_widget_destroy( update_window ); update_window = NULL; gb_debug (DEBUG_UPDATE, "END -- CANCEL"); return; } if (result != GNOME_VFS_OK) { g_warning( "Close failed: %s", gnome_vfs_result_to_string(result) ); } data->i++; data->p = data->p->next; if ( data->p ) { info = (GnomeVFSFileInfo *)data->p->data; gb_debug (DEBUG_UPDATE, "Opening %s", info->name ); file_uri = gnome_vfs_uri_append_file_name( data->uri, info->name ); gb_debug (DEBUG_UPDATE, " URI = %s", gnome_vfs_uri_to_string (file_uri, 0) ); gnome_vfs_async_cancel (handle); gnome_vfs_async_open_uri (&remote_file_handle, file_uri, GNOME_VFS_OPEN_READ, 0, open_remote_file_callback, data); } else { download_done( data ); } gb_debug (DEBUG_UPDATE, "END"); }
static void peacock_file_save_async_real (PeacockFile *file) { GnomeVFSAsyncHandle *handle; #ifdef PEACOCK_FILE_DEBUG g_warning ("peacock_file_save_async(): Saving URI - %s.\n", peacock_file_get_uri (file)); #endif gnome_vfs_async_open_uri (&handle, file->priv->uri, GNOME_VFS_OPEN_WRITE, GNOME_VFS_PRIORITY_DEFAULT, peacock_file_save_async_open_cb, (gpointer) file); return; }
static void peacock_file_load_from_uri (PeacockFile *file) { GnomeVFSAsyncHandle *handle; #ifdef PEACOCK_FILE_DEBUG g_warning ("peacock_file_load_from_uri(): Loading URI - %s.\n", peacock_file_get_uri (file)); #endif /* Check if file at URI is readonly. Set file->priv->readonly.*/ /* FIXME: Someone write this test. */ gnome_vfs_async_open_uri (&handle, file->priv->uri, GNOME_VFS_OPEN_READ, GNOME_VFS_PRIORITY_DEFAULT, peacock_file_load_async_open_cb, (gpointer) file); return; }
static void view_text (GtkWidget *window, GnomeVFSURI *uri) { GtkWidget *view, *swin; GtkTextBuffer *buffer; GnomeVFSAsyncHandle *handle; g_return_if_fail (window); swin = gtk_scrolled_window_new (NULL, NULL); if (!swin) goto error; gtk_container_add (GTK_CONTAINER(window), swin); gtk_widget_show (swin); view = gtk_text_view_new (); if (!view) goto error; g_object_set (G_OBJECT(view), "editable", FALSE, "cursor-visible", FALSE, NULL); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(view)); gtk_text_buffer_set_text (buffer, "", 1); gtk_container_add (GTK_CONTAINER(swin), view); gnome_vfs_async_open_uri (&handle, uri, GNOME_VFS_OPEN_READ, GFM_VFS_PRIORITY_LISTER, text_open_callback, buffer); g_object_set_data_full (G_OBJECT(view), "async-handle", handle, (GDestroyNotify) gnome_vfs_async_cancel); gtk_widget_show (view); gtk_widget_show (window); return; error: g_object_unref (G_OBJECT(window)); }