Prepare support for WebKit 2

This commit is contained in:
Pierre Pronchery 2020-01-02 05:37:25 +01:00
parent c161f8de40
commit 352ab8186b
6 changed files with 1551 additions and 17 deletions

View File

@ -35,12 +35,18 @@
# include <gtk/gtkx.h>
#endif
#include <System.h>
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT)
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <arpa/inet.h>
# include <webkit/webkit.h>
#elif defined(WITH_WEBKIT2)
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <arpa/inet.h>
# include <webkit2/webkit2.h>
#else
# define GNET_EXPERIMENTAL
# include <gnet.h>
@ -80,7 +86,7 @@ struct _Download
struct timeval tv;
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
WebKitDownload * conn;
#else
FILE * fp;
@ -119,7 +125,7 @@ static int _download_set_proxy(Download * download, char const * http,
uint16_t http_port);
static void _download_refresh(Download * download);
#ifndef WITH_WEBKIT
#if !defined(WITH_WEBKIT) && !defined(WITH_WEBKIT2)
static int _download_write(Download * download);
#endif
@ -129,7 +135,7 @@ static void _download_on_cancel(gpointer data);
static gboolean _download_on_closex(gpointer data);
static void _download_on_embedded(gpointer data);
#ifndef WITH_WEBKIT
#if !defined(WITH_WEBKIT) && !defined(WITH_WEBKIT2)
static void _download_on_http(GConnHttp * conn, GConnHttpEvent * event,
gpointer data);
#endif
@ -333,7 +339,7 @@ void download_delete(Download * download)
{
if(download->timeout != 0)
g_source_remove(download->timeout);
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
if(download->conn != NULL)
{
webkit_download_cancel(download->conn);
@ -409,7 +415,7 @@ static int _download_error(Download * download, char const * message, int ret)
/* download_set_proxy */
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
# if WEBKIT_CHECK_VERSION(1, 1, 0)
static SoupURI * _set_proxy_address(struct addrinfo * ai);
# endif
@ -418,7 +424,7 @@ static SoupURI * _set_proxy_address(struct addrinfo * ai);
static int _download_set_proxy(Download * download, char const * http,
uint16_t http_port)
{
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
# if WEBKIT_CHECK_VERSION(1, 1, 0)
SoupSession * session;
struct addrinfo hints;
@ -459,7 +465,7 @@ static int _download_set_proxy(Download * download, char const * http,
#endif
}
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
# if WEBKIT_CHECK_VERSION(1, 1, 0)
static SoupURI * _set_proxy_address(struct addrinfo * ai)
{
@ -621,7 +627,7 @@ static void _refresh_unit(guint64 size, double * fraction, char const ** unit,
/* download_write */
#ifndef WITH_WEBKIT
#if !defined(WITH_WEBKIT) && !defined(WITH_WEBKIT2)
static int _download_write(Download * download)
{
gchar * buf;
@ -693,7 +699,7 @@ static void _download_on_embedded(gpointer data)
/* download_on_http */
#ifndef WITH_WEBKIT
#if !defined(WITH_WEBKIT) && !defined(WITH_WEBKIT2)
static void _http_connected(Download * download);
static void _http_error(GConnHttpEventError * event, Download * download);
static void _http_data_complete(GConnHttpEventData * event,
@ -837,7 +843,7 @@ static gboolean _download_on_idle(gpointer data)
{
Download * download = data;
DownloadPrefs * prefs = &download->prefs;
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
char * p = NULL;
char * cwd = NULL;
size_t len;
@ -894,7 +900,7 @@ static gboolean _download_on_timeout(gpointer data)
{
gboolean ret = TRUE;
Download * d = data;
#ifdef WITH_WEBKIT
#if defined(WITH_WEBKIT) || defined(WITH_WEBKIT2)
WebKitDownloadStatus status;
guint64 received = d->data_received;

1510
src/ghtml-webkit2.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,8 @@
# include "ghtml-gtktextview.c"
#elif defined(WITH_WEBKIT)
# include "ghtml-webkit.c"
#elif defined(WITH_WEBKIT2)
# include "ghtml-webkit2.c"
#else /* default */
# include "ghtml-gtkmozembed.c"
#endif

View File

@ -75,7 +75,8 @@ int main(int argc, char * argv[])
_error("setlocale", 1);
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
#if defined(WITH_GTKHTML) || defined(WITH_GTKTEXTVIEW) || defined(WITH_WEBKIT)
#if defined(WITH_GTKHTML) || defined(WITH_GTKTEXTVIEW) || defined(WITH_WEBKIT) \
|| defined(WITH_WEBKIT2)
if(g_thread_supported() == FALSE)
g_thread_init(NULL);
#endif

View File

@ -3,7 +3,7 @@ targets=download,surfer
#cppflags=-D EMBEDDED
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,callbacks.h,common.h,download.h,ghtml.h,surfer.h,ghtml-gtkhtml.c,ghtml-gtkmozembed.c,ghtml-gtktextview.c,ghtml-webkit.c
dist=Makefile,callbacks.h,common.h,download.h,ghtml.h,surfer.h,ghtml-gtkhtml.c,ghtml-gtkmozembed.c,ghtml-gtktextview.c,ghtml-webkit.c,ghtml-webkit2.c
[download]
type=binary
@ -14,6 +14,9 @@ cppflags=-D WITH_WEBKIT
#ldflags=`pkg-config --libs libSystem gtk+-2.0 webkit-1.0` -lintl
cflags=`pkg-config --cflags libSystem gtk+-x11-3.0 webkitgtk-3.0`
ldflags=`pkg-config --libs libSystem gtk+-x11-3.0 webkitgtk-3.0` -lintl
#cppflags=-D WITH_WEBKIT2
#cflags=`pkg-config --cflags libSystem gtk+-x11-3.0 webkit2gtk-4.0`
#ldflags=`pkg-config --libs libSystem gtk+-x11-3.0 webkit2gtk-4.0` -lintl
sources=download.c
install=$(BINDIR)
@ -37,6 +40,9 @@ cppflags=-D WITH_WEBKIT
#ldflags=`pkg-config --libs libDesktop webkit-1.0` -lintl
cflags=`pkg-config --cflags libDesktop webkitgtk-3.0`
ldflags=`pkg-config --libs libDesktop webkitgtk-3.0` -lintl
#cppflags=-D WITH_WEBKIT2
#cflags=`pkg-config --cflags libDesktop webkit2gtk-4.0`
#ldflags=`pkg-config --libs libDesktop webkit2gtk-4.0` -lintl
sources=surfer.c,ghtml.c,callbacks.c,main.c
install=$(BINDIR)
@ -44,7 +50,7 @@ install=$(BINDIR)
depends=surfer.h,ghtml.h,callbacks.h,../config.h
[ghtml.c]
depends=ghtml.h,ghtml-gtkhtml.c,ghtml-gtkmozembed.c,ghtml-gtktextview.c,ghtml-webkit.c,common/conn.c,common/history.c,common/url.c,../config.h
depends=ghtml.h,ghtml-gtkhtml.c,ghtml-gtkmozembed.c,ghtml-gtktextview.c,ghtml-webkit.c,ghtml-webkit2.c,common/conn.c,common/history.c,common/url.c,../config.h
cppflags=-D PREFIX=\"$(PREFIX)\"
[main.c]

View File

@ -32,6 +32,9 @@ type=binary
#WebKit/Gtk+ 3
cflags=`pkg-config --cflags webkitgtk-3.0`
ldflags=`pkg-config --libs webkitgtk-3.0`
#WebKit2
#cflags=`pkg-config --cflags webkit2gtk-4.0`
#ldflags=`pkg-config --libs webkit2gtk-4.0`
sources=ghtml-helper.c,helper.c,helper-main.c
install=$(BINDIR)
@ -39,14 +42,16 @@ install=$(BINDIR)
#cppflags=-D WITH_GTKMOZEMBED
#cppflags=-D WITH_GTKHTML
#cppflags=-D WITH_GTKTEXTVIEW
cppflags=-D WITH_WEBKIT
#cppflags=-D WITH_WEBKIT
cppflags=-D WITH_WEBKIT2
depends=../src/ghtml.h,../src/ghtml.c
[helper.c]
#cppflags=-D WITH_GTKMOZEMBED
#cppflags=-D WITH_GTKHTML
#cppflags=-D WITH_GTKTEXTVIEW
cppflags=-D WITH_WEBKIT
#cppflags=-D WITH_WEBKIT
cppflags=-D WITH_WEBKIT2
depends=../src/common/find.c,../src/surfer.h,../config.h,backend/contents.c,backend/gtkdoc.c,backend/manual.c,backend/search.c,helper.h
[helper-main.c]
@ -69,6 +74,9 @@ type=binary
#WebKit/Gtk+ 3
cflags=`pkg-config --cflags webkitgtk-3.0`
ldflags=`pkg-config --libs webkitgtk-3.0` $(OBJDIR)ghtml-helper.o
#WebKit2
#cflags=`pkg-config --cflags webkit2gtk-4.0`
#ldflags=`pkg-config --libs webkit2gtk-4.0` $(OBJDIR)ghtml-helper.o
depends=$(OBJDIR)ghtml-helper.o
sources=htmlapp.c
install=$(BINDIR)
@ -78,4 +86,5 @@ install=$(BINDIR)
#cppflags=-D WITH_GTKHTML
#cppflags=-D WITH_GTKTEXTVIEW
cppflags=-D WITH_WEBKIT
#cppflags=-D WITH_WEBKIT2
depends=../src/common/find.c,../src/surfer.h,../config.h