Esempio n. 1
0
static void download_finished(WebKitDownload *download,
               gpointer        user_data)
{
    const gchar * url;
    url = webkit_uri_request_get_uri(webkit_download_get_request(download));
    const guint64 size = webkit_download_get_received_data_length(download);
    printf("!!!!!!!!!!!!!!!%s: %"G_GUINT64_FORMAT"\n", url, size);

}
Esempio n. 2
0
static void download_proc(WebKitDownload *download,
               guint64         data_length,
               gpointer        user_data)
{
    const gchar * url;
    printf("dwonload proc\n");
    url = webkit_uri_request_get_uri(webkit_download_get_request(download));
    printf("%s: %"G_GUINT64_FORMAT"\n", url, data_length);

}
Esempio n. 3
0
 static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, DownloadTest* test)
 {
     g_assert(webkit_download_get_request(download));
     test->started(download);
     g_signal_connect(download, "notify::response", G_CALLBACK(receivedResponseCallback), test);
     g_signal_connect(download, "created-destination", G_CALLBACK(createdDestinationCallback), test);
     g_signal_connect(download, "received-data", G_CALLBACK(receivedDataCallback), test);
     g_signal_connect(download, "finished", G_CALLBACK(finishedCallback), test);
     g_signal_connect(download, "failed", G_CALLBACK(failedCallback), test);
     g_signal_connect(download, "decide-destination", G_CALLBACK(decideDestinationCallback), test);
 }
Esempio n. 4
0
File: main.c Progetto: macrat/rusk
gboolean decideDownloadDestination(WebKitDownload *download, const gchar *suggest, RuskWindow *rusk)
{
	GtkWidget *dialog;

	dialog = gtk_file_chooser_dialog_new("Save File", rusk->window, GTK_FILE_CHOOSER_ACTION_SAVE,
										  "_Cancel", GTK_RESPONSE_CANCEL,
										  "_Save", GTK_RESPONSE_ACCEPT,
										  NULL);

	gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);

	char *buf = g_strdup_printf("%s%s", g_get_home_dir(), suggest);
	gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), buf);
	g_free(buf);

	if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		char *filename;

		filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));

		printf("download %s\n", webkit_uri_request_get_uri(webkit_download_get_request(download)));
		printf("suggest: %s\n", suggest);
		printf("save to: %s\n", filename);

		startDownload(
			webkit_uri_request_get_uri(webkit_download_get_request(download)),
			filename
		);

		g_free(filename);
	}

	gtk_widget_destroy(dialog);

	return TRUE;
}
Esempio n. 5
0
/**
 * ephy_download_new_for_download:
 * @download: a #WebKitDownload to wrap
 *
 * Wraps @download in an #EphyDownload.
 *
 * Returns: an #EphyDownload.
 **/
EphyDownload *
ephy_download_new_for_download (WebKitDownload *download)
{
  EphyDownload *ephy_download;
#ifdef HAVE_WEBKIT2
  WebKitURIRequest *request;
#endif

  g_return_val_if_fail (WEBKIT_IS_DOWNLOAD (download), NULL);

  ephy_download = ephy_download_new ();

#ifdef HAVE_WEBKIT2
  g_signal_connect (download, "decide-destination",
                    G_CALLBACK (download_decide_destination_cb),
                    ephy_download);
  g_signal_connect (download, "created-destination",
                    G_CALLBACK (download_created_destination_cb),
                    ephy_download);
  g_signal_connect (download, "finished",
                    G_CALLBACK (download_finished_cb),
                    ephy_download);
  g_signal_connect (download, "failed",
                    G_CALLBACK (download_failed_cb),
                    ephy_download);
#else
  g_signal_connect (download, "notify::status",
                    G_CALLBACK (download_status_changed_cb),
                    ephy_download);
  g_signal_connect (download, "error",
                    G_CALLBACK (download_error_cb),
                    ephy_download);
#endif

  ephy_download->priv->download = g_object_ref (download);
#ifdef HAVE_WEBKIT2
  request = webkit_download_get_request (download);
  ephy_download->priv->source = g_strdup (webkit_uri_request_get_uri (request));
#else
  ephy_download->priv->source = g_strdup (webkit_download_get_uri (download));
#endif

#ifdef HAVE_WEBKIT2
  /* In WebKit2 the download has already started */
  ephy_embed_shell_add_download (embed_shell, ephy_download);
#endif

  return ephy_download;
}