2014-01-16 17:24:14 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Vincent Sanders <vince@netsurf-browser.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/>.
|
|
|
|
*/
|
2014-01-11 18:20:30 +04:00
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-04-19 01:04:16 +03:00
|
|
|
#include "utils/config.h"
|
2015-04-14 01:19:04 +03:00
|
|
|
#include "utils/errors.h"
|
|
|
|
#include "utils/file.h"
|
2016-05-27 01:01:03 +03:00
|
|
|
#include "netsurf/bitmap.h"
|
2014-01-30 01:35:53 +04:00
|
|
|
#include "content/hlcache.h"
|
2014-03-08 18:40:09 +04:00
|
|
|
#include "content/backing_store.h"
|
|
|
|
|
2014-10-27 02:49:18 +03:00
|
|
|
#include "desktop/save_pdf.h"
|
2014-01-30 01:35:53 +04:00
|
|
|
#include "desktop/download.h"
|
2014-05-25 03:57:48 +04:00
|
|
|
#include "desktop/searchweb.h"
|
2016-05-30 13:15:58 +03:00
|
|
|
#include "netsurf/download.h"
|
2016-05-30 13:29:39 +03:00
|
|
|
#include "netsurf/fetch.h"
|
2016-05-30 13:23:32 +03:00
|
|
|
#include "netsurf/misc.h"
|
2016-05-30 13:01:40 +03:00
|
|
|
#include "netsurf/window.h"
|
2016-05-30 12:57:22 +03:00
|
|
|
#include "netsurf/search.h"
|
2016-05-30 13:04:32 +03:00
|
|
|
#include "netsurf/clipboard.h"
|
2016-05-30 13:20:15 +03:00
|
|
|
#include "netsurf/utf8.h"
|
2016-05-30 13:31:35 +03:00
|
|
|
#include "netsurf/layout.h"
|
2016-05-30 13:51:10 +03:00
|
|
|
#include "netsurf/netsurf.h"
|
2014-01-11 18:20:30 +04:00
|
|
|
|
2014-10-16 12:48:09 +04:00
|
|
|
/**
|
|
|
|
* The global interface table.
|
|
|
|
*/
|
2014-05-10 13:22:10 +04:00
|
|
|
struct netsurf_table *guit = NULL;
|
2014-01-11 18:20:30 +04:00
|
|
|
|
|
|
|
|
2014-01-12 14:27:41 +04:00
|
|
|
static void gui_default_window_set_title(struct gui_window *g, const char *title)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-03 01:30:45 +03:00
|
|
|
static nserror gui_default_window_set_url(struct gui_window *g, struct nsurl *url)
|
2014-01-12 14:27:41 +04:00
|
|
|
{
|
2014-10-29 03:17:11 +03:00
|
|
|
return NSERROR_OK;
|
2014-01-12 14:27:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_start_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_stop_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static bool gui_default_window_drag_start(struct gui_window *g,
|
|
|
|
gui_drag_type type,
|
|
|
|
const struct rect *rect)
|
2014-01-12 21:07:34 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-04 02:05:59 +03:00
|
|
|
static nserror gui_default_window_save_link(struct gui_window *g,
|
|
|
|
nsurl *url,
|
2014-01-13 02:55:26 +04:00
|
|
|
const char *title)
|
2014-01-12 21:07:34 +04:00
|
|
|
{
|
2014-11-04 02:05:59 +03:00
|
|
|
return NSERROR_OK;
|
2014-01-12 21:07:34 +04:00
|
|
|
}
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static void gui_default_window_set_icon(struct gui_window *g,
|
|
|
|
hlcache_handle *icon)
|
2014-01-12 21:07:34 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static void gui_default_window_new_content(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static bool gui_default_window_scroll_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
static void gui_default_window_set_pointer(struct gui_window *g,
|
|
|
|
gui_pointer_shape shape)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_set_status(struct gui_window *g,
|
|
|
|
const char *text)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_place_caret(struct gui_window *g,
|
|
|
|
int x, int y, int height,
|
|
|
|
const struct rect *clip)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_remove_caret(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
2014-01-13 02:55:26 +04:00
|
|
|
|
2014-10-24 23:45:21 +04:00
|
|
|
static void gui_default_window_create_form_select_menu(struct gui_window *g,
|
|
|
|
struct form_control *control)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-14 02:54:19 +04:00
|
|
|
static void gui_default_window_file_gadget_open(struct gui_window *g,
|
|
|
|
hlcache_handle *hl,
|
|
|
|
struct form_control *gadget)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_drag_save_object(struct gui_window *g,
|
|
|
|
hlcache_handle *c,
|
|
|
|
gui_save_type type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_drag_save_selection(struct gui_window *g,
|
|
|
|
const char *selection)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_start_selection(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
/** verify window table is valid */
|
|
|
|
static nserror verify_window_register(struct gui_window_table *gwt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gwt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gwt->create == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->destroy == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2017-04-19 18:23:08 +03:00
|
|
|
if (gwt->invalidate == NULL) {
|
2014-01-13 03:50:54 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-13 05:08:15 +04:00
|
|
|
if (gwt->get_scroll == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->set_scroll == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-13 15:38:35 +04:00
|
|
|
if (gwt->get_dimensions == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->update_extent == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
|
|
|
|
/* fill in the optional entries with defaults */
|
|
|
|
if (gwt->set_title == NULL) {
|
|
|
|
gwt->set_title = gui_default_window_set_title;
|
|
|
|
}
|
|
|
|
if (gwt->set_url == NULL) {
|
|
|
|
gwt->set_url = gui_default_window_set_url;
|
|
|
|
}
|
2014-01-13 18:51:27 +04:00
|
|
|
if (gwt->set_icon == NULL) {
|
|
|
|
gwt->set_icon = gui_default_window_set_icon;
|
|
|
|
}
|
|
|
|
if (gwt->set_status == NULL) {
|
|
|
|
gwt->set_status = gui_default_window_set_status;
|
|
|
|
}
|
|
|
|
if (gwt->set_pointer == NULL) {
|
|
|
|
gwt->set_pointer = gui_default_window_set_pointer;
|
|
|
|
}
|
|
|
|
if (gwt->place_caret == NULL) {
|
|
|
|
gwt->place_caret = gui_default_window_place_caret;
|
|
|
|
}
|
|
|
|
if (gwt->remove_caret == NULL) {
|
|
|
|
gwt->remove_caret = gui_default_window_remove_caret;
|
|
|
|
}
|
2014-01-12 21:07:34 +04:00
|
|
|
if (gwt->start_throbber == NULL) {
|
|
|
|
gwt->start_throbber = gui_default_window_start_throbber;
|
|
|
|
}
|
|
|
|
if (gwt->stop_throbber == NULL) {
|
|
|
|
gwt->stop_throbber = gui_default_window_stop_throbber;
|
|
|
|
}
|
|
|
|
if (gwt->drag_start == NULL) {
|
|
|
|
gwt->drag_start = gui_default_window_drag_start;
|
|
|
|
}
|
|
|
|
if (gwt->save_link == NULL) {
|
|
|
|
gwt->save_link = gui_default_window_save_link;
|
|
|
|
}
|
2014-01-13 02:55:26 +04:00
|
|
|
if (gwt->new_content == NULL) {
|
|
|
|
gwt->new_content = gui_default_window_new_content;
|
|
|
|
}
|
|
|
|
if (gwt->scroll_start == NULL) {
|
|
|
|
gwt->scroll_start = gui_default_window_scroll_start;
|
|
|
|
}
|
2014-10-24 23:45:21 +04:00
|
|
|
if (gwt->create_form_select_menu == NULL) {
|
|
|
|
gwt->create_form_select_menu =
|
|
|
|
gui_default_window_create_form_select_menu;
|
|
|
|
}
|
2014-01-14 02:54:19 +04:00
|
|
|
if (gwt->file_gadget_open == NULL) {
|
|
|
|
gwt->file_gadget_open = gui_default_window_file_gadget_open;
|
|
|
|
}
|
|
|
|
if (gwt->drag_save_object == NULL) {
|
|
|
|
gwt->drag_save_object = gui_default_window_drag_save_object;
|
|
|
|
}
|
|
|
|
if (gwt->drag_save_selection == NULL) {
|
|
|
|
gwt->drag_save_selection = gui_default_window_drag_save_selection;
|
|
|
|
}
|
|
|
|
if (gwt->start_selection == NULL) {
|
|
|
|
gwt->start_selection = gui_default_window_start_selection;
|
|
|
|
}
|
2014-01-12 21:07:34 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-14 20:04:02 +04:00
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
|
2014-01-14 20:04:02 +04:00
|
|
|
static struct gui_download_window *
|
|
|
|
gui_default_download_create(download_context *ctx, struct gui_window *parent)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nserror gui_default_download_data(struct gui_download_window *dw,
|
|
|
|
const char *data, unsigned int size)
|
|
|
|
{
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_download_error(struct gui_download_window *dw,
|
|
|
|
const char *error_msg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_download_done(struct gui_download_window *dw)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-10-27 02:49:18 +03:00
|
|
|
static struct gui_download_table default_download_table = {
|
|
|
|
.create = gui_default_download_create,
|
|
|
|
.data = gui_default_download_data,
|
|
|
|
.error = gui_default_download_error,
|
|
|
|
.done = gui_default_download_done,
|
|
|
|
};
|
2014-01-14 20:04:02 +04:00
|
|
|
|
|
|
|
/** verify download window table is valid */
|
|
|
|
static nserror verify_download_register(struct gui_download_table *gdt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gdt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all enties are mandantory */
|
|
|
|
if (gdt->create == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gdt->data == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gdt->error == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gdt->done == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
static void gui_default_get_clipboard(char **buffer, size_t *length)
|
|
|
|
{
|
|
|
|
*buffer = NULL;
|
|
|
|
*length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_set_clipboard(const char *buffer, size_t length,
|
|
|
|
nsclipboard_styles styles[], int n_styles)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-02 02:17:36 +04:00
|
|
|
static struct gui_clipboard_table default_clipboard_table = {
|
|
|
|
.get = gui_default_get_clipboard,
|
|
|
|
.set = gui_default_set_clipboard,
|
|
|
|
};
|
|
|
|
|
2014-01-16 17:24:14 +04:00
|
|
|
/** verify clipboard table is valid */
|
2014-01-15 23:37:05 +04:00
|
|
|
static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gct == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* optional operations */
|
|
|
|
if (gct->get == NULL) {
|
|
|
|
gct->get = gui_default_get_clipboard;
|
|
|
|
}
|
|
|
|
if (gct->set == NULL) {
|
|
|
|
gct->set = gui_default_set_clipboard;
|
|
|
|
}
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-02 02:17:36 +04:00
|
|
|
/**
|
|
|
|
* The default utf8 conversion implementation.
|
|
|
|
*
|
|
|
|
* The default implementation assumes the local encoding is utf8
|
|
|
|
* allowing the conversion to be a simple copy.
|
|
|
|
*
|
|
|
|
* @param [in] string The source string.
|
|
|
|
* @param [in] len The \a string length or 0 to compute it.
|
|
|
|
* @param [out] result A pointer to the converted string.
|
|
|
|
* @result NSERROR_OK or NSERROR_NOMEM if memory could not be allocated.
|
|
|
|
*/
|
|
|
|
static nserror gui_default_utf8(const char *string, size_t len, char **result)
|
|
|
|
{
|
|
|
|
assert(string && result);
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
len = strlen(string);
|
|
|
|
|
|
|
|
*result = strndup(string, len);
|
|
|
|
if (!(*result))
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gui_utf8_table default_utf8_table = {
|
|
|
|
.utf8_to_local = gui_default_utf8,
|
|
|
|
.local_to_utf8 = gui_default_utf8,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** verify clipboard table is valid */
|
|
|
|
static nserror verify_utf8_register(struct gui_utf8_table *gut)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gut == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mandantory operations */
|
|
|
|
if (gut->utf8_to_local == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gut->local_to_utf8 == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-03-19 02:32:52 +04:00
|
|
|
static void gui_default_status(bool found, void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_hourglass(bool active, void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_add_recent(const char *string, void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_forward_state(bool active, void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_back_state(bool active, void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gui_search_table default_search_table = {
|
|
|
|
.status = gui_default_status,
|
|
|
|
.hourglass = gui_default_hourglass,
|
|
|
|
.add_recent = gui_default_add_recent,
|
|
|
|
.forward_state = gui_default_forward_state,
|
|
|
|
.back_state = gui_default_back_state,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** verify search table is valid */
|
|
|
|
static nserror verify_search_register(struct gui_search_table *gst)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gst == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill in the optional entries with defaults */
|
|
|
|
if (gst->status == NULL) {
|
|
|
|
gst->status = default_search_table.status;
|
|
|
|
}
|
|
|
|
if (gst->hourglass == NULL) {
|
|
|
|
gst->hourglass = default_search_table.hourglass;
|
|
|
|
}
|
|
|
|
if (gst->add_recent == NULL) {
|
|
|
|
gst->add_recent = default_search_table.add_recent;
|
|
|
|
}
|
|
|
|
if (gst->forward_state == NULL) {
|
|
|
|
gst->forward_state = default_search_table.forward_state;
|
|
|
|
}
|
|
|
|
if (gst->back_state == NULL) {
|
|
|
|
gst->back_state = default_search_table.back_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-25 03:57:48 +04:00
|
|
|
static nserror
|
|
|
|
gui_default_provider_update(const char *provider_name,
|
|
|
|
struct bitmap *provider_bitmap)
|
|
|
|
{
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gui_search_web_table default_search_web_table = {
|
|
|
|
.provider_update = gui_default_provider_update,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** verify search table is valid */
|
|
|
|
static nserror verify_search_web_register(struct gui_search_web_table *gswt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gswt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mandantory operations */
|
|
|
|
if (gswt->provider_update == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-03-08 18:40:09 +04:00
|
|
|
/** verify low level cache persistant backing store table is valid */
|
|
|
|
static nserror verify_llcache_register(struct gui_llcache_table *glt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (glt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mandantory operations */
|
|
|
|
if (glt->store == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (glt->fetch == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (glt->invalidate == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-11-21 01:28:19 +03:00
|
|
|
if (glt->release == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-03-08 18:40:09 +04:00
|
|
|
if (glt->initialise == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (glt->finalise == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
static nsurl *gui_default_get_resource_url(const char *path)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-01-15 23:37:05 +04:00
|
|
|
|
2015-06-17 11:26:05 +03:00
|
|
|
static nserror gui_default_get_resource_data(const char *path, const uint8_t **data, size_t *data_len)
|
|
|
|
{
|
|
|
|
return NSERROR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nserror gui_default_release_resource_data(const uint8_t *data)
|
|
|
|
{
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
static char *gui_default_mimetype(const char *path)
|
2014-01-14 20:04:02 +04:00
|
|
|
{
|
2014-01-23 03:19:57 +04:00
|
|
|
return strdup(guit->fetch->filetype(path));
|
2014-01-14 20:04:02 +04:00
|
|
|
}
|
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
/** verify fetch table is valid */
|
|
|
|
static nserror verify_fetch_register(struct gui_fetch_table *gft)
|
2014-01-14 20:04:02 +04:00
|
|
|
{
|
2014-01-23 03:19:57 +04:00
|
|
|
/* check table is present */
|
|
|
|
if (gft == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gft->filetype == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill in the optional entries with defaults */
|
|
|
|
if (gft->get_resource_url == NULL) {
|
|
|
|
gft->get_resource_url = gui_default_get_resource_url;
|
|
|
|
}
|
2015-06-17 11:26:05 +03:00
|
|
|
if (gft->get_resource_data == NULL) {
|
|
|
|
gft->get_resource_data = gui_default_get_resource_data;
|
|
|
|
}
|
|
|
|
if (gft->release_resource_data == NULL) {
|
|
|
|
gft->release_resource_data = gui_default_release_resource_data;
|
|
|
|
}
|
2014-01-23 03:19:57 +04:00
|
|
|
if (gft->mimetype == NULL) {
|
|
|
|
gft->mimetype = gui_default_mimetype;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2014-01-14 20:04:02 +04:00
|
|
|
}
|
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/** verify file table is valid */
|
|
|
|
static nserror verify_file_register(struct gui_file_table *gft)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gft == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gft->mkpath == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gft->basename == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-06-05 15:06:47 +04:00
|
|
|
if (gft->nsurl_to_path == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gft->path_to_nsurl == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gft->mkdir_all == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-05-07 19:14:18 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
/**
|
|
|
|
* verify bitmap table is valid
|
|
|
|
*
|
|
|
|
* \param gbt The bitmap table to verify.
|
|
|
|
* \return NSERROR_OK if teh table is valid else NSERROR_BAD_PARAMETER.
|
|
|
|
*/
|
|
|
|
static nserror verify_bitmap_register(struct gui_bitmap_table *gbt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gbt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gbt->create == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->destroy == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->set_opaque == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_opaque == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->test_opaque == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_buffer == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_rowstride == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_width == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_height == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->get_bpp == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->save == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbt->modified == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2015-04-23 01:13:24 +03:00
|
|
|
if (gbt->render == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
/**
|
|
|
|
* verify layout table is valid
|
|
|
|
*
|
|
|
|
* \param glt The layout table to verify.
|
|
|
|
* \return NSERROR_OK if the table is valid else NSERROR_BAD_PARAMETER.
|
|
|
|
*/
|
|
|
|
static nserror verify_layout_register(struct gui_layout_table *glt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (glt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (glt->width == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glt->position == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glt->split == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
static void gui_default_quit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-15 03:31:54 +04:00
|
|
|
|
2014-05-28 02:52:35 +04:00
|
|
|
static nserror gui_default_launch_url(struct nsurl *url)
|
2014-01-15 03:31:54 +04:00
|
|
|
{
|
2014-05-28 02:52:35 +04:00
|
|
|
return NSERROR_NO_FETCH_HANDLER;
|
2014-01-15 03:31:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 03:24:57 +03:00
|
|
|
static nserror gui_default_cert_verify(nsurl *url,
|
2014-01-15 03:31:54 +04:00
|
|
|
const struct ssl_cert_info *certs,
|
|
|
|
unsigned long num,
|
|
|
|
nserror (*cb)(bool proceed, void *pw),
|
|
|
|
void *cbpw)
|
|
|
|
{
|
2016-07-31 03:24:57 +03:00
|
|
|
return NSERROR_NOT_IMPLEMENTED;
|
2014-01-15 03:31:54 +04:00
|
|
|
}
|
|
|
|
|
2018-08-13 18:50:17 +03:00
|
|
|
static nserror gui_default_401login_open(nsurl *url, const char *realm,
|
|
|
|
const char *username, const char *password,
|
|
|
|
nserror (*cb)(const char *username,
|
|
|
|
const char *password,
|
|
|
|
void *pw),
|
|
|
|
void *cbpw)
|
2014-01-16 04:52:17 +04:00
|
|
|
{
|
2018-08-13 18:50:17 +03:00
|
|
|
return NSERROR_NOT_IMPLEMENTED;
|
2014-01-16 04:52:17 +04:00
|
|
|
}
|
|
|
|
|
2014-10-27 02:49:18 +03:00
|
|
|
static void
|
|
|
|
gui_default_pdf_password(char **owner_pass, char **user_pass, char *path)
|
|
|
|
{
|
|
|
|
*owner_pass = NULL;
|
|
|
|
save_pdf(path);
|
|
|
|
}
|
2014-02-02 02:17:36 +04:00
|
|
|
|
2016-04-16 00:50:28 +03:00
|
|
|
/** verify misc table is valid */
|
|
|
|
static nserror verify_misc_register(struct gui_misc_table *gmt)
|
2014-01-15 23:37:05 +04:00
|
|
|
{
|
|
|
|
/* check table is present */
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt == NULL) {
|
2014-01-15 23:37:05 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->schedule == NULL) {
|
2014-03-08 18:13:27 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2016-04-26 01:11:55 +03:00
|
|
|
if (gmt->warning == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-03-08 18:13:27 +04:00
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
/* fill in the optional entries with defaults */
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->quit == NULL) {
|
|
|
|
gmt->quit = gui_default_quit;
|
2014-01-15 23:37:05 +04:00
|
|
|
}
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->launch_url == NULL) {
|
|
|
|
gmt->launch_url = gui_default_launch_url;
|
2014-01-15 23:37:05 +04:00
|
|
|
}
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->cert_verify == NULL) {
|
|
|
|
gmt->cert_verify = gui_default_cert_verify;
|
2014-01-15 23:37:05 +04:00
|
|
|
}
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->login == NULL) {
|
|
|
|
gmt->login = gui_default_401login_open;
|
2014-01-16 04:52:17 +04:00
|
|
|
}
|
2016-04-16 00:50:28 +03:00
|
|
|
if (gmt->pdf_password == NULL) {
|
|
|
|
gmt->pdf_password = gui_default_pdf_password;
|
2014-10-27 02:49:18 +03:00
|
|
|
}
|
2014-01-15 23:37:05 +04:00
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-30 13:51:10 +03:00
|
|
|
/* exported interface documented in netsurf/netsurf.h */
|
2014-10-16 12:48:09 +04:00
|
|
|
nserror netsurf_register(struct netsurf_table *gt)
|
2014-01-11 18:20:30 +04:00
|
|
|
{
|
2014-01-12 21:07:34 +04:00
|
|
|
nserror err;
|
|
|
|
|
2014-01-11 18:20:30 +04:00
|
|
|
/* ensure not already initialised */
|
|
|
|
if (guit != NULL) {
|
|
|
|
return NSERROR_INIT_FAILED;
|
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
/* check table is present */
|
|
|
|
if (gt == NULL) {
|
2014-01-11 18:20:30 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-12 21:07:34 +04:00
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
/* mandantory tables */
|
|
|
|
|
2016-04-16 00:50:28 +03:00
|
|
|
/* miscellaneous table */
|
|
|
|
err = verify_misc_register(gt->misc);
|
2014-01-15 23:37:05 +04:00
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* window table */
|
2014-01-12 21:07:34 +04:00
|
|
|
err = verify_window_register(gt->window);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
2014-01-12 02:34:12 +04:00
|
|
|
}
|
2014-01-15 23:37:05 +04:00
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
/* fetch table */
|
|
|
|
err = verify_fetch_register(gt->fetch);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
/* bitmap table */
|
|
|
|
err = verify_bitmap_register(gt->bitmap);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
/* layout table */
|
|
|
|
err = verify_layout_register(gt->layout);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* optional tables */
|
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/* file table */
|
|
|
|
if (gt->file == NULL) {
|
|
|
|
gt->file = default_file_table;
|
|
|
|
}
|
|
|
|
err = verify_file_register(gt->file);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
/* download table */
|
2014-01-14 20:04:02 +04:00
|
|
|
if (gt->download == NULL) {
|
|
|
|
/* set default download table */
|
|
|
|
gt->download = &default_download_table;
|
|
|
|
}
|
|
|
|
err = verify_download_register(gt->download);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
2014-01-12 21:07:34 +04:00
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
/* clipboard table */
|
|
|
|
if (gt->clipboard == NULL) {
|
|
|
|
/* set default clipboard table */
|
|
|
|
gt->clipboard = &default_clipboard_table;
|
2014-01-15 03:31:54 +04:00
|
|
|
}
|
2014-01-15 23:37:05 +04:00
|
|
|
err = verify_clipboard_register(gt->clipboard);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
2014-01-15 03:31:54 +04:00
|
|
|
}
|
2014-01-11 18:20:30 +04:00
|
|
|
|
2014-02-02 02:17:36 +04:00
|
|
|
/* utf8 table */
|
|
|
|
if (gt->utf8 == NULL) {
|
2014-03-19 02:32:52 +04:00
|
|
|
/* set default utf8 table */
|
2014-02-02 02:17:36 +04:00
|
|
|
gt->utf8 = &default_utf8_table;
|
|
|
|
}
|
|
|
|
err = verify_utf8_register(gt->utf8);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-03-19 02:32:52 +04:00
|
|
|
/* search table */
|
|
|
|
if (gt->search == NULL) {
|
|
|
|
/* set default search table */
|
|
|
|
gt->search = &default_search_table;
|
|
|
|
}
|
|
|
|
err = verify_search_register(gt->search);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-05-25 03:57:48 +04:00
|
|
|
/* web search table */
|
|
|
|
if (gt->search_web == NULL) {
|
|
|
|
/* set default search table */
|
|
|
|
gt->search_web = &default_search_web_table;
|
|
|
|
}
|
|
|
|
err = verify_search_web_register(gt->search_web);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-03-08 18:40:09 +04:00
|
|
|
/* llcache table */
|
|
|
|
if (gt->llcache == NULL) {
|
|
|
|
/* set default backing store table */
|
|
|
|
gt->llcache = null_llcache_table;
|
|
|
|
}
|
|
|
|
err = verify_llcache_register(gt->llcache);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-01-11 18:20:30 +04:00
|
|
|
guit = gt;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|