linux - C Web Browser Download File -


webkitgtk+ api reference

what i'm trying run html5 app on linux way & users can still use app without relying on internet connection.

my problem when go download zip file. download doesn't execute because there isn't adequate url file save (like desktop). therefore doesn't download.

thus question relies onto how suppose adequate url download file when it's executed dynamically via jszip. (it works fine in chrome, not in app). terminal says...

source.c:35:3: warning: ‘return’ value, in function returning void [enabled default] return true; ^

any appreciated.

here's code:

/*   save file main.c , compile using command   (those backticks, not single quotes):     gcc -wall -g -o source source.c `pkg-config --cflags --libs gtk+-2.0 webkit-1.0` -export-dynamic    execute using:   ./source    if can't compile chances don't have gcc installed.   install gcc/c following terminal command. (this command debian based linux distros)     sudo apt-get install libgtk2.0-dev libgtk2.0-doc libglib2.0-doc    webkit requires libraries aquire, configure, , compile. can libraries issuing following command in terminal:     sudo apt-get install subversion gtk-doc-tools autoconf automake libtool libgtk2.0-dev libpango1.0-dev libicu-dev libxslt-dev libsoup2.4-dev libsqlite3-dev gperf bison flex libjpeg62-dev libpng12-dev libxt-dev autotools-dev libgstreamer-plugins-base0.10-dev libenchant-dev libgail-dev    webkitgtk+ api reference: http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitdownload.html    ubuntu webkit information - https://help.ubuntu.com/community/webkit     sudo apt-get install libwebkitgtk-dev python-webkit-dev python-webkit    required dependencies build: (if installed above not needed)     sudo apt-get install libgtk2.0-dev libgtk2.0-doc libglib2.0-doc subversion gtk-doc-tools autoconf automake libtool libgtk2.0-dev libpango1.0-dev libicu-dev libxslt-dev libsoup2.4-dev libsqlite3-dev gperf bison flex libjpeg62-dev libpng12-dev libxt-dev autotools-dev libgstreamer-plugins-base0.10-dev libenchant-dev libgail-dev libwebkitgtk-dev */  #include <gtk/gtk.h> #include <webkit/webkit.h>  static void destroy_cb(gtkwidget* widget, gpointer data) {   gtk_main_quit(); }  static void download_requested_cb(webkitwebview *web_view, webkitdownload *download) {   const gchar* dest = g_strdup_printf("%s", "file:///home/michael/downloads/test.zip");   //set destination uri (eg, send file downloads folder)   webkit_download_set_destination_uri(download, dest);   webkit_download_start();    return true; }  int main(int argc, char* argv[]) {   gtkwidget* window;   webkitwebview* web_view;    gtk_init(&argc, &argv);    window = gtk_window_new(gtk_window_toplevel);   gtk_widget_set_name (window, "appname");   gtk_window_set_default_size(gtk_window(window), 600, 600);   //gtk_window_set_icon_from_file(window, "app/logo.png", null);   g_signal_connect(window, "destroy", g_callback(destroy_cb), null);    web_view = webkit_web_view(webkit_web_view_new());    /* register callback gets invoked each time download requested */   g_object_connect(web_view, "download-requested", g_callback(download_requested_cb), null);    char uri[path_max];   char cwd[path_max];    getcwd(cwd, sizeof(cwd));    if (argc > 1)       snprintf(uri, sizeof(uri), "%s", argv[1]);   else       snprintf(uri, sizeof(uri), "file://%s/app/index.html", cwd);    webkit_web_view_open (web_view, uri);    gtk_container_add(gtk_container(window), gtk_widget(web_view));   gtk_widget_grab_focus(gtk_widget(web_view));   gtk_widget_show_all(window);   gtk_main();   return 0; } 

1) basic premise sound:

file:///home/michael/downloads/test.zip // syntax should allow "upload" local file on hard drve

2) compile warning (not error). in theory, ignore it:

source.c:35:3: warning: ‘return’ value, in function returning void [enabled default] return true; ^ 

3) problem:

static void download_requested_cb(webkitwebview *web_view, ...    ...       return true; // delete line.  can't return "void" function! } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -