summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-08-26 17:59:19 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-08-26 17:59:19 +0100
commitb7b70a3ca89f2bce90dac363967b31477794b157 (patch)
treed964670aae908aa9c471433fefc36bccd3945faa
parent5bed515e68b22024992fe1cda336c7b8afa78c6f (diff)
parent2eb86b9096add2523d1c3a46264abfa420ff6a88 (diff)
downloadnetsurf-b7b70a3ca89f2bce90dac363967b31477794b157.tar.gz
netsurf-b7b70a3ca89f2bce90dac363967b31477794b157.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
-rw-r--r--amiga/context_menu.c2
-rw-r--r--amiga/drag.c2
-rw-r--r--amiga/gui.c1
-rw-r--r--content/fetch.c2
-rw-r--r--content/fetchers.h21
-rw-r--r--desktop/version.c4
-rw-r--r--gtk/gui.c1
-rw-r--r--gtk/scaffolding.c26
-rw-r--r--gtk/scaffolding.h5
-rw-r--r--javascript/Makefile4
-rw-r--r--javascript/fetcher.c238
-rw-r--r--javascript/fetcher.h28
-rw-r--r--utils/corestrings.c3
-rw-r--r--utils/corestrings.h1
14 files changed, 306 insertions, 32 deletions
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index f4fd09272..b85824f2c 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -988,7 +988,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
nserror ret;
nsurl *url;
- ret = search_web_omni(sel, SEARCH_WEB_OMNI_NONE, &url);
+ ret = search_web_omni(sel, SEARCH_WEB_OMNI_SEARCHONLY, &url);
free(sel);
if (ret == NSERROR_OK) {
ret = browser_window_navigate(gwin->bw,
diff --git a/amiga/drag.c b/amiga/drag.c
index 09df0d0c4..c7c5f4b77 100644
--- a/amiga/drag.c
+++ b/amiga/drag.c
@@ -55,6 +55,8 @@ void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
{
const char *filetype = NULL;
+ /* Check we are running on Workbench */
+ if(nsoption_charp(pubscreen_name) == NULL) return;
if(strcmp(nsoption_charp(pubscreen_name), "Workbench")) return;
switch(type)
diff --git a/amiga/gui.c b/amiga/gui.c
index c3c469d50..2faf42008 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3918,6 +3918,7 @@ static void gui_window_destroy(struct gui_window *g)
g->shared->tabs--;
ami_switch_tab(g->shared,true);
+ ami_schedule(0, ami_gui_refresh_favicon, g->shared);
if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
ami_toggletabbar(g->shared, false);
diff --git a/content/fetch.c b/content/fetch.c
index 6948fcbea..e10f0abcb 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -57,6 +57,7 @@
#include "content/fetchers/curl.h"
#include "content/fetchers/data.h"
#include "content/fetchers/file.h"
+#include "javascript/fetcher.h"
#include "content/urldb.h"
/* Define this to turn on verbose fetch logging */
@@ -291,6 +292,7 @@ nserror fetcher_init(void)
fetch_file_register();
fetch_resource_register();
fetch_about_register();
+ fetch_javascript_register();
return NSERROR_OK;
}
diff --git a/content/fetchers.h b/content/fetchers.h
index d123de986..95034bbff 100644
--- a/content/fetchers.h
+++ b/content/fetchers.h
@@ -16,7 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file content/fetchers.h
+/**
+ * \file content/fetchers.h
+ *
* Interface for fetchers factory.
*/
@@ -34,6 +36,15 @@ struct fetch;
* Fetcher operations API
*
* These are the operations a fetcher must implement.
+ *
+ * Each fetcher is called once for initialisaion and finalisation.
+ * The poll entry point will be called to allow all active fetches to progress.
+ * The flow of a fetch operation is:
+ * URL is checked for aceptability.
+ * setup with all applicable data.
+ * start is called before teh first poll
+ * after completion or abort it is freed
+ *
*/
struct fetcher_operation_table {
/**
@@ -44,7 +55,7 @@ struct fetcher_operation_table {
bool (*initialise)(lwc_string *scheme);
/**
- * can this fetcher accept a url.
+ * Can this fetcher accept a url.
*
* \param url the URL to check
* \return true if the fetcher can handle the url else false.
@@ -80,7 +91,7 @@ struct fetcher_operation_table {
void (*poll)(lwc_string *scheme);
/**
- * finalise the fetcher.
+ * Finalise the fetcher.
*/
void (*finalise)(lwc_string *scheme);
};
@@ -97,9 +108,9 @@ nserror fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *op
/**
- * Initialise the fetchers.
+ * Initialise all registered fetchers.
*
- * @return NSERROR_OK or error code
+ * \return NSERROR_OK or error code
*/
nserror fetcher_init(void);
diff --git a/desktop/version.c b/desktop/version.c
index 99929e79f..44d58715f 100644
--- a/desktop/version.c
+++ b/desktop/version.c
@@ -1,10 +1,10 @@
#include "testament.h"
-const char * const netsurf_version = "3.2 (Dev"
+const char * const netsurf_version = "3.3 (Dev"
#if defined(CI_BUILD)
" CI #" CI_BUILD
#endif
")"
;
const int netsurf_version_major = 3;
-const int netsurf_version_minor = 2;
+const int netsurf_version_minor = 3;
diff --git a/gtk/gui.c b/gtk/gui.c
index bbe6cbaf2..6fb2a4125 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -539,7 +539,6 @@ static void gui_quit(void)
LOG(("Quitting GUI"));
/* Ensure all scaffoldings are destroyed before we go into exit */
- nsgtk_scaffolding_destroy();
nsgtk_download_destroy();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index b57db3b69..93cd7f768 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -265,20 +265,6 @@ static gboolean scaffolding_window_delete_event(GtkWidget *widget,
return TRUE;
}
-/* exported interface documented in gtk_scaffold.h */
-void nsgtk_scaffolding_destroy(void)
-{
- struct nsgtk_scaffolding *gs;
-
- gs = scaf_list;
- while (gs != NULL) {
- LOG(("destroying scaffold: %p", gs));
- if (gtk_widget_in_destruction(GTK_WIDGET(gs->window)) != TRUE) {
- gtk_widget_destroy(GTK_WIDGET(gs->window));
- }
- }
-}
-
/**
* Update the back and forward button sensitivity.
*/
@@ -918,8 +904,16 @@ MULTIHANDLER(closewindow)
MULTIHANDLER(quit)
{
- if (nsgtk_check_for_downloads(g->window) == false)
- netsurf_quit = true;
+ struct nsgtk_scaffolding *gs;
+
+ if (nsgtk_check_for_downloads(g->window) == false) {
+ gs = scaf_list;
+ while (gs != NULL) {
+ gtk_widget_destroy(GTK_WIDGET(gs->window));
+ gs = gs->next;
+ }
+ }
+
return TRUE;
}
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index fcf6d3c9b..e7d945ebc 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -193,11 +193,6 @@ void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g)
void nsgtk_scaffolding_set_top_level(struct gui_window *g);
/**
- * Destroy all scaffolds.
- */
-void nsgtk_scaffolding_destroy(void);
-
-/**
* update the sensitivity of context sensitive UI elements
*
* widgets altered in arrays:
diff --git a/javascript/Makefile b/javascript/Makefile
index 693ed6541..04eed66b6 100644
--- a/javascript/Makefile
+++ b/javascript/Makefile
@@ -54,12 +54,12 @@ ifeq ($(WANT_JS_SOURCE),YES)
S_JSAPI :=
-S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
+S_JAVASCRIPT += content.c jsapi.c fetcher.c $(addprefix jsapi/,$(S_JSAPI))
$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).h,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi)))
else
-S_JAVASCRIPT += none.c
+S_JAVASCRIPT += none.c fetcher.c
endif
S_JAVASCRIPT := $(addprefix javascript/,$(S_JAVASCRIPT)) $(S_JSAPI_BINDING) \ No newline at end of file
diff --git a/javascript/fetcher.c b/javascript/fetcher.c
new file mode 100644
index 000000000..690751cd3
--- /dev/null
+++ b/javascript/fetcher.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince@kyllikki.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * implementation for javascript scheme fetcher
+ *
+ * This fetcher implements http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#javascript-protocol
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include <string.h>
+#include <strings.h>
+#include <time.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <limits.h>
+#include <stdarg.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "utils/config.h"
+#include "utils/errors.h"
+#include "utils/corestrings.h"
+#include "utils/nsoption.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/ring.h"
+#include "desktop/gui_factory.h"
+
+#include "content/fetch.h"
+#include "content/fetchers.h"
+#include "javascript/fetcher.h"
+#include "content/urldb.h"
+
+/** Context for an resource fetch */
+struct fetch_javascript_context {
+ struct fetch_javascript_context *r_next, *r_prev;
+
+ struct fetch *fetchh; /**< Handle for this fetch */
+
+ bool aborted; /**< Flag indicating fetch has been aborted */
+ bool locked; /**< Flag indicating entry is already entered */
+
+ nsurl *url;
+};
+
+static struct fetch_javascript_context *ring = NULL;
+
+
+/** issue fetch callbacks with locking */
+static inline bool fetch_javascript_send_callback(const fetch_msg *msg,
+ struct fetch_javascript_context *ctx)
+{
+ ctx->locked = true;
+ fetch_send_callback(msg, ctx->fetchh);
+ ctx->locked = false;
+
+ return ctx->aborted;
+}
+
+
+/**
+ * called from poll to progress fetch.
+ *
+ * \todo This is currently completely unimplemented and just returns 204
+ */
+static bool fetch_javascript_handler(struct fetch_javascript_context *ctx)
+{
+ fetch_msg msg;
+ int code = 204;
+
+ /* content is going to return error code */
+ fetch_set_http_code(ctx->fetchh, code);
+
+ msg.type = FETCH_FINISHED;
+ fetch_javascript_send_callback(&msg, ctx);
+
+ return true;
+}
+
+
+
+/** callback to initialise the resource fetcher. */
+static bool fetch_javascript_initialise(lwc_string *scheme)
+{
+ return true;
+}
+
+/** callback to finalise the resource fetcher. */
+static void fetch_javascript_finalise(lwc_string *scheme)
+{
+}
+
+static bool fetch_javascript_can_fetch(const nsurl *url)
+{
+ return true;
+}
+
+/** callback to set up a resource fetch context. */
+static void *
+fetch_javascript_setup(struct fetch *fetchh,
+ nsurl *url,
+ bool only_2xx,
+ bool downgrade_tls,
+ const char *post_urlenc,
+ const struct fetch_multipart_data *post_multipart,
+ const char **headers)
+{
+ struct fetch_javascript_context *ctx;
+
+ ctx = calloc(1, sizeof(*ctx));
+ if (ctx == NULL)
+ return NULL;
+
+ ctx->url = nsurl_ref(url);
+
+ ctx->fetchh = fetchh;
+
+ RING_INSERT(ring, ctx);
+
+ return ctx;
+}
+
+/** callback to free a resource fetch */
+static void fetch_javascript_free(void *ctx)
+{
+ struct fetch_javascript_context *c = ctx;
+ if (c->url != NULL) {
+ nsurl_unref(c->url);
+ }
+ RING_REMOVE(ring, c);
+ free(ctx);
+}
+
+/** callback to start a resource fetch */
+static bool fetch_javascript_start(void *ctx)
+{
+ return true;
+}
+
+/** callback to abort a resource fetch */
+static void fetch_javascript_abort(void *ctx)
+{
+ struct fetch_javascript_context *c = ctx;
+
+ /* To avoid the poll loop having to deal with the fetch context
+ * disappearing from under it, we simply flag the abort here.
+ * The poll loop itself will perform the appropriate cleanup.
+ */
+ c->aborted = true;
+}
+
+
+/** callback to poll for additional resource fetch contents */
+static void fetch_javascript_poll(lwc_string *scheme)
+{
+ struct fetch_javascript_context *c, *next;
+
+ if (ring == NULL) return;
+
+ /* Iterate over ring, processing each pending fetch */
+ c = ring;
+ do {
+ /* Ignore fetches that have been flagged as locked.
+ * This allows safe re-entrant calls to this function.
+ * Re-entrancy can occur if, as a result of a callback,
+ * the interested party causes fetch_poll() to be called
+ * again.
+ */
+ if (c->locked == true) {
+ next = c->r_next;
+ continue;
+ }
+
+ /* Only process non-aborted fetches */
+ if (c->aborted == false) {
+ /* resource fetches can be processed in one go */
+ fetch_javascript_handler(c);
+ }
+
+ /* Compute next fetch item at the last possible moment
+ * as processing this item may have added to the ring
+ */
+ next = c->r_next;
+
+ fetch_remove_from_queues(c->fetchh);
+ fetch_free(c->fetchh);
+
+ /* Advance to next ring entry, exiting if we've reached
+ * the start of the ring or the ring has become empty
+ */
+ } while ( (c = next) != ring && ring != NULL);
+}
+
+/**
+ * Register javascript scheme fetcher with fetcher factory.
+ *
+ * \return NSERROR_OK on success or appropriate error code on faliure.
+*/
+nserror fetch_javascript_register(void)
+{
+ lwc_string *scheme = lwc_string_ref(corestring_lwc_javascript);
+ const struct fetcher_operation_table fetcher_ops = {
+ .initialise = fetch_javascript_initialise,
+ .acceptable = fetch_javascript_can_fetch,
+ .setup = fetch_javascript_setup,
+ .start = fetch_javascript_start,
+ .abort = fetch_javascript_abort,
+ .free = fetch_javascript_free,
+ .poll = fetch_javascript_poll,
+ .finalise = fetch_javascript_finalise
+ };
+
+ return fetcher_add(scheme, &fetcher_ops);
+}
diff --git a/javascript/fetcher.h b/javascript/fetcher.h
new file mode 100644
index 000000000..f39714089
--- /dev/null
+++ b/javascript/fetcher.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf.
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * javascript scheme handler
+ */
+
+#ifndef NETSURF_JAVASCRIPT_FETCHER_H
+#define NETSURF_JAVASCRIPT_FETCHER_H
+
+nserror fetch_javascript_register(void);
+
+#endif
diff --git a/utils/corestrings.c b/utils/corestrings.c
index db6d72e13..cb340e9a6 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -69,6 +69,7 @@ lwc_string *corestring_lwc_iframe;
lwc_string *corestring_lwc_image;
lwc_string *corestring_lwc_img;
lwc_string *corestring_lwc_input;
+lwc_string *corestring_lwc_javascript;
lwc_string *corestring_lwc_justify;
lwc_string *corestring_lwc_left;
lwc_string *corestring_lwc_li;
@@ -327,6 +328,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(image);
CSS_LWC_STRING_UNREF(img);
CSS_LWC_STRING_UNREF(input);
+ CSS_LWC_STRING_UNREF(javascript);
CSS_LWC_STRING_UNREF(justify);
CSS_LWC_STRING_UNREF(left);
CSS_LWC_STRING_UNREF(li);
@@ -610,6 +612,7 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(image);
CSS_LWC_STRING_INTERN(img);
CSS_LWC_STRING_INTERN(input);
+ CSS_LWC_STRING_INTERN(javascript);
CSS_LWC_STRING_INTERN(justify);
CSS_LWC_STRING_INTERN(left);
CSS_LWC_STRING_INTERN(li);
diff --git a/utils/corestrings.h b/utils/corestrings.h
index 2a1f88b09..b41d1f859 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -74,6 +74,7 @@ extern lwc_string *corestring_lwc_iframe;
extern lwc_string *corestring_lwc_image;
extern lwc_string *corestring_lwc_img;
extern lwc_string *corestring_lwc_input;
+extern lwc_string *corestring_lwc_javascript;
extern lwc_string *corestring_lwc_justify;
extern lwc_string *corestring_lwc_left;
extern lwc_string *corestring_lwc_li;