#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>

static void gfile_progress_callback (goffset current_num_bytes, goffset total_num_bytes, gpointer self) {
        g_print ("current: %"G_GOFFSET_MODIFIER"d, total: %"G_GOFFSET_MODIFIER"d\n", current_num_bytes, total_num_bytes);
}

gboolean download_idle(gpointer user_data)
{
        gchar* uri;
        GFile* remote;
        GFile* local;

        uri = g_strdup ("http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/amd64/viostor.cat");
        remote = g_file_new_for_uri (uri);
        local = g_file_new_for_path ("/tmp/viostor.cat");
        g_file_copy (remote, local, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA, NULL, gfile_progress_callback, NULL, NULL);
        g_object_unref (local);
        g_object_unref (remote);
        g_free (uri);

        return FALSE;
}


int main (int argc, char ** argv) {
        GMainLoop *loop;

        g_type_init ();

        loop = g_main_loop_new(NULL, FALSE);
        g_idle_add(download_idle, NULL);
        g_main_loop_run(loop);

        return 0;
}
