[GNOME VFS] problem with async-xfer
josh lucas <[email protected]>
| Newsgroups | gmane.comp.gnome.vfs |
|---|---|
| Message-ID | <1024764314.1511.19.camel@che> |
At the suggestion of Jacob, I looked to use the async-xfer function. From the various apps which use it, I think I'm using the code correctly but unfortunately, I'm getting the below output.. lucas@che tmp > ./test-uri uri:http://www.weblogs.com/changes.xml opening len of src_list: 1 len of target_list: 1 opening main loop running A I'm attaching my code. I admit it's ugly but hopefully one can see what I'm doing wrong. thanks, josh
test-uri.c
(text/x-c, 2.1 KB)
#include <libgnomevfs/gnome-vfs.h>
#include <glib/gmain.h>
static GMainLoop *main_loop;
gboolean download_in_progress = TRUE;
static int
async_update (GnomeVFSAsyncHandle *handle, GnomeVFSXferProgressInfo *info, gpointer data)
{
g_print ("%" GNOME_VFS_SIZE_FORMAT_STR "\n", info->bytes_copied);
if (info->status == GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR) {
g_message ("there was an error........");
return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
}
if (info->source_name) {
g_print ("source: %s\n", info->source_name);
}
if (info->target_name) {
g_print ("target: %s\n", info->target_name);
}
if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
g_print ("all done with the transfer\n");
download_in_progress = FALSE;
}
return download_in_progress;
}
int
main (int argc, char **argv)
{
gchar *uri, *dest_file;
GnomeVFSAsyncHandle *handle;
GList *src_list = NULL;
GList *target_list = NULL;
uri = g_strdup_printf("http://www.weblogs.com/changes.xml");
dest_file = g_strdup_printf("file://changes.xml");
printf ("uri:%s\n", uri);
gnome_vfs_init();
printf ("opening\n");
src_list = g_list_append(src_list,gnome_vfs_uri_new(uri));
target_list = g_list_append(target_list, gnome_vfs_uri_new(dest_file));
g_print("len of src_list: %d\n",g_list_length(src_list));
g_print("len of target_list: %d\n",g_list_length(target_list));
printf ("opening\n");
download_in_progress = TRUE;
gnome_vfs_async_xfer (
&handle,
src_list,
target_list,
GNOME_VFS_XFER_DEFAULT,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
GNOME_VFS_PRIORITY_DEFAULT,
async_update, NULL, NULL, NULL);
printf("main loop running\n");
main_loop = g_main_loop_new (NULL, TRUE);
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
while (1)
;
return 0;
}