예제 #1
0
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1webkit_1download_1get_1uri)
	(JNIEnv *env, jclass that, jintLong arg0)
{
	jintLong rc = 0;
	WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1download_1get_1uri_FUNC);
	rc = (jintLong)webkit_download_get_uri((WebKitDownload *)arg0);
	WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1download_1get_1uri_FUNC);
	return rc;
}
예제 #2
0
파일: surf.c 프로젝트: bobrippling/bin
gboolean
initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
	Arg arg;

	updatewinid(c);
	arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o));
	spawn(c, &arg);
	return FALSE;
}
예제 #3
0
파일: uzbl.c 프로젝트: DuClare/uzbl
static gboolean
download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
    (void) web_view;
    (void) user_data;
    if (uzbl.behave.download_handler) {
        const gchar* uri = webkit_download_get_uri ((WebKitDownload*)download);
        printf("Download -> %s\n",uri);
        run_command_async(uzbl.behave.download_handler, uri);
    }
    return (FALSE);
}
예제 #4
0
static VALUE
Download_uri(VALUE self)
{
  VALUE __p_retval = Qnil;
  WebKitDownload *_self = ((WebKitDownload*)RVAL2GOBJ(self));

#line 242 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
  do { __p_retval =  rb_str_new2(webkit_download_get_uri(_self)); goto out; } while(0);
out:
  return __p_retval;
}
예제 #5
0
파일: Kioskit.c 프로젝트: webkopf/kioskit
static gboolean downloadRequested(WebKitWebView* webView,
		WebKitDownload* download, GtkEntry* entry) {
	const char* uri = webkit_download_get_uri(download);
	int r = 0;
	r = fork();
	if (r == 0) {
		execl("/usr/local/bin/kwebhelper.py", "kwebhelper.py", dl_command, uri,
				NULL);
	}
	return FALSE;
}
예제 #6
0
/* on_download_requested */
static gboolean _on_download_requested(WebKitWebView * view,
		WebKitDownload * download, gpointer data)
{
	GHtml * ghtml;
	char const * url;
	char const * suggested;

	ghtml = g_object_get_data(G_OBJECT(data), "ghtml");
	url = webkit_download_get_uri(download);
	suggested = webkit_download_get_suggested_filename(download);
	surfer_download(ghtml->surfer, url, suggested);
	webkit_download_cancel(download);
	return FALSE;
}
예제 #7
0
파일: main.c 프로젝트: mahiso/JudoShiai
gboolean download_req(WebKitWebView* webView, WebKitDownload *download, gboolean *handled)
{
    const gchar *uri = webkit_download_get_uri(download);
    char *p = strrchr(uri, '/');
    if (!p)
	return FALSE;

    gchar *dest = g_strdup_printf("file:///%s/%s", video_dir, p+1);
    webkit_download_set_destination_uri(download, dest);
    g_free(dest);

    cur_download = download;
    return TRUE;
}
예제 #8
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;
}
예제 #9
0
파일: webview.c 프로젝트: bradparks/luakit
static gboolean
download_request_cb(WebKitWebView *v, GObject *dl, widget_t *w)
{
    (void) v;
    const gchar *uri = webkit_download_get_uri((WebKitDownload *) dl);
    const gchar *filename = webkit_download_get_suggested_filename((WebKitDownload *) dl);

    lua_State *L = globalconf.L;
    luaH_object_push(L, w->ref);
    lua_pushstring(L, uri);
    lua_pushstring(L, filename);
    luaH_object_emit_signal(L, -3, "download-request", 2, 0);
    lua_pop(L, 1);

    return FALSE;
}
예제 #10
0
파일: download.c 프로젝트: Alexis-D/luakit
/**
 * Pushes the given download onto the Lua stack.
 *
 * Obtains a GTK reference on the \c WebKitDownload.
 *
 * \param L The Lua VM state.
 * \param d The \c WebKitDownload to push onto the stack.
 *
 * \luastack
 * \lreturn A \c download object.
 */
gint
luaH_download_push(lua_State *L, WebKitDownload *d)
{
    download_class.allocator(L);
    download_t *download = luaH_checkdownload(L, -1);

    /* steal webkit download */
    download->uri = g_strdup(webkit_download_get_uri(d));
    download->webkit_download = d;
    g_object_ref(G_OBJECT(download->webkit_download));

    /* raise error signal on error */
    g_signal_connect(G_OBJECT(download->webkit_download), "error",
            G_CALLBACK(error_cb), download);

    /* return download */
    return 1;
}
예제 #11
0
파일: surf.c 프로젝트: theappleman/surf
gboolean
initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
	const gchar *filename;
	gchar *uri, *html;

	stop(c, NULL);
	c->download = o;
	filename = webkit_download_get_suggested_filename(o);
	uri = g_strconcat("file://", dldir, "/", filename, NULL);
	webkit_download_set_destination_uri(c->download, uri);
	c->progress = 0;
	g_free(uri);
	html = g_strdup_printf("Download <b>%s</b>...", filename);
	webkit_web_view_load_html_string(c->view, html,
			webkit_download_get_uri(c->download));
	g_signal_connect(c->download, "notify::progress", G_CALLBACK(download), c);
	g_signal_connect(c->download, "notify::status", G_CALLBACK(download), c);
	webkit_download_start(c->download);
	
	c->title = copystr(&c->title, filename);
	update(c);
	g_free(html);
	return TRUE;
}
예제 #12
0
파일: callbacks.c 프로젝트: phddoom/uzbl
gboolean
download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_data) {
    (void) web_view; (void) user_data;

    /* get the URI being downloaded */
    const gchar *uri = webkit_download_get_uri(download);

    /* get the destination path, if specified.
     * this is only intended to be set when this function is trigger by an
     * explicit download using uzbl's 'download' action. */
    const gchar *destination = user_data;

    if (uzbl.state.verbose)
        printf("Download requested -> %s\n", uri);

    if (!uzbl.behave.download_handler) {
        webkit_download_cancel(download);
        return FALSE; /* reject downloads when there's no download handler */
    }

    /* get a reasonable suggestion for a filename */
    const gchar *suggested_filename;
#ifdef USE_WEBKIT2
    WebKitURIResponse *response;
    g_object_get(download, "network-response", &response, NULL);
#if WEBKIT_CHECK_VERSION (1, 9, 90)
    g_object_get(response, "suggested-filename", &suggested_filename, NULL);
#else
    suggested_filename = webkit_uri_response_get_suggested_filename(respose);
#endif
#elif WEBKIT_CHECK_VERSION (1, 9, 6)
    WebKitNetworkResponse *response;
    g_object_get(download, "network-response", &response, NULL);
    g_object_get(response, "suggested-filename", &suggested_filename, NULL);
#else
    g_object_get(download, "suggested-filename", &suggested_filename, NULL);
#endif

    /* get the mimetype of the download */
    const gchar *content_type = NULL;
    WebKitNetworkResponse *r  = webkit_download_get_network_response(download);
    /* downloads can be initiated from the context menu, in that case there is
       no network response yet and trying to get one would crash. */
    if(WEBKIT_IS_NETWORK_RESPONSE(r)) {
        SoupMessage        *m = webkit_network_response_get_message(r);
        SoupMessageHeaders *h = NULL;
        g_object_get(m, "response-headers", &h, NULL);
        if(h) /* some versions of libsoup don't have "response-headers" here */
            content_type = soup_message_headers_get_one(h, "Content-Type");
    }

    if(!content_type)
        content_type = "application/octet-stream";

    /* get the filesize of the download, as given by the server.
       (this may be inaccurate, there's nothing we can do about that.)  */
    unsigned int total_size = webkit_download_get_total_size(download);

    GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*));
    const CommandInfo *c = parse_command_parts(uzbl.behave.download_handler, a);
    if(!c) {
        webkit_download_cancel(download);
        g_array_free(a, TRUE);
        return FALSE;
    }

    g_array_append_val(a, uri);
    g_array_append_val(a, suggested_filename);
    g_array_append_val(a, content_type);
    gchar *total_size_s = g_strdup_printf("%d", total_size);
    g_array_append_val(a, total_size_s);

    if(destination)
        g_array_append_val(a, destination);

    GString *result = g_string_new ("");
    run_parsed_command(c, a, result);

    g_free(total_size_s);
    g_array_free(a, TRUE);

    /* no response, cancel the download */
    if(result->len == 0) {
        webkit_download_cancel(download);
        return FALSE;
    }

    /* we got a response, it's the path we should download the file to */
    gchar *destination_path = result->str;
    g_string_free(result, FALSE);

    /* presumably people don't need newlines in their filenames. */
    char *p = strchr(destination_path, '\n');
    if ( p != NULL ) *p = '\0';

    /* set up progress callbacks */
    g_signal_connect(download, "notify::status",   G_CALLBACK(download_status_cb),   NULL);
    g_signal_connect(download, "notify::progress", G_CALLBACK(download_progress_cb), NULL);

    /* convert relative path to absolute path */
    if(destination_path[0] != '/') {
        gchar *rel_path = destination_path;
        gchar *cwd = g_get_current_dir();
        destination_path = g_strconcat(cwd, "/", destination_path, NULL);
        g_free(cwd);
        g_free(rel_path);
    }

    send_event(DOWNLOAD_STARTED, NULL, TYPE_STR, destination_path, NULL);

    /* convert absolute path to file:// URI */
    gchar *destination_uri = g_strconcat("file://", destination_path, NULL);
    g_free(destination_path);

    webkit_download_set_destination_uri(download, destination_uri);
    g_free(destination_uri);

    return TRUE;
}