summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/401login.c3
-rw-r--r--monkey/401login.h9
-rw-r--r--monkey/browser.c142
-rw-r--r--monkey/browser.h4
-rw-r--r--monkey/cert.c6
-rw-r--r--monkey/cert.h4
-rw-r--r--monkey/download.c17
-rw-r--r--monkey/main.c65
-rw-r--r--monkey/poll.c2
-rw-r--r--monkey/poll.h2
-rw-r--r--monkey/utils.c38
11 files changed, 153 insertions, 139 deletions
diff --git a/monkey/401login.c b/monkey/401login.c
index 605a21aa9..8b4d33d7d 100644
--- a/monkey/401login.c
+++ b/monkey/401login.c
@@ -16,12 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
#include "utils/ring.h"
#include <stdlib.h>
#include <stdio.h>
+#include "monkey/401login.h"
+
typedef struct monkey401 {
struct monkey401 *r_next, *r_prev;
uint32_t num;
diff --git a/monkey/401login.h b/monkey/401login.h
new file mode 100644
index 000000000..e78355ea2
--- /dev/null
+++ b/monkey/401login.h
@@ -0,0 +1,9 @@
+
+#include <stdbool.h>
+
+#include "utils/nsurl.h"
+#include "utils/errors.h"
+
+
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
diff --git a/monkey/browser.c b/monkey/browser.c
index 73549f36a..85e25d9ea 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -87,9 +87,10 @@ monkey_kill_browser_windows(void)
}
}
-struct gui_window *
-gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone, bool new_tab)
+static struct gui_window *
+gui_window_create(struct browser_window *bw,
+ struct browser_window *clone,
+ bool new_tab)
{
struct gui_window *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@@ -111,7 +112,7 @@ gui_create_browser_window(struct browser_window *bw,
return ret;
}
-void
+static void
gui_window_destroy(struct gui_window *g)
{
fprintf(stdout, "WINDOW DESTROY WIN %u\n", g->win_num);
@@ -119,19 +120,19 @@ gui_window_destroy(struct gui_window *g)
free(g);
}
-void
+static void
gui_window_set_title(struct gui_window *g, const char *title)
{
fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
}
-void
+static void
gui_window_redraw_window(struct gui_window *g)
{
fprintf(stdout, "WINDOW REDRAW WIN %u\n", g->win_num);
}
-void
+static void
gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
@@ -141,31 +142,31 @@ gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
*height = g->height;
}
-void
+static void
gui_window_new_content(struct gui_window *g)
{
fprintf(stdout, "WINDOW NEW_CONTENT WIN %u\n", g->win_num);
}
-void
+static void
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
fprintf(stdout, "WINDOW NEW_ICON WIN %u\n", g->win_num);
}
-void
+static void
gui_window_start_throbber(struct gui_window *g)
{
fprintf(stdout, "WINDOW START_THROBBER WIN %u\n", g->win_num);
}
-void
+static void
gui_window_stop_throbber(struct gui_window *g)
{
fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num);
}
-void
+static void
gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
g->scrollx = sx;
@@ -173,7 +174,7 @@ gui_window_set_scroll(struct gui_window *g, int sx, int sy)
fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
}
-void
+static void
gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
fprintf(stdout, "WINDOW UPDATE_BOX WIN %u X %d Y %d WIDTH %d HEIGHT %d\n",
@@ -182,7 +183,7 @@ gui_window_update_box(struct gui_window *g, const struct rect *rect)
}
-void
+static void
gui_window_update_extent(struct gui_window *g)
{
if (!g->bw->current_content)
@@ -194,13 +195,13 @@ gui_window_update_extent(struct gui_window *g)
content_get_height(g->bw->current_content));
}
-void
+static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fprintf(stdout, "WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
}
-void
+static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
const char *ptr_name = "UNKNOWN";
@@ -269,20 +270,13 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
}
-void
+static void
gui_window_set_url(struct gui_window *g, const char *url)
{
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url);
}
-void
-gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
- /* Ignore? */
-}
-
-bool
+static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
fprintf(stdout, "WINDOW GET_SCROLL WIN %u X %d Y %d\n",
@@ -292,7 +286,7 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-bool
+static bool
gui_window_scroll_start(struct gui_window *g)
{
fprintf(stdout, "WINDOW SCROLL_START WIN %u\n", g->win_num);
@@ -300,12 +294,7 @@ gui_window_scroll_start(struct gui_window *g)
return true;
}
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
-}
-
-void
+static void
gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
@@ -313,46 +302,7 @@ gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
g->win_num, x0, y0, x1, y1);
}
-void
-gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
-
-void
-gui_start_selection(struct gui_window *g)
-{
-}
-
-void
-gui_clear_selection(struct gui_window *g)
-{
-}
-
-/**
- * Core asks front end for clipboard contents.
- *
- * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
- * \param length Byte length of UTF-8 text in buffer
- */
-void gui_get_clipboard(char **buffer, size_t *length)
-{
-}
-
-
-/**
- * Core tells front end to put given text in clipboard
- *
- * \param buffer UTF-8 text, owned by core
- * \param length Byte length of UTF-8 text in buffer
- * \param styles Array of styles given to text runs, owned by core, or NULL
- * \param n_styles Number of text run styles in array
- */
-void gui_set_clipboard(const char *buffer, size_t length,
- nsclipboard_styles styles[], int n_styles)
-{
-}
-
-void
+static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
@@ -360,13 +310,13 @@ gui_window_place_caret(struct gui_window *g, int x, int y, int height,
g->win_num, x, y, height);
}
-void
+static void
gui_window_remove_caret(struct gui_window *g)
{
fprintf(stdout, "WINDOW REMOVE_CARET WIN %u\n", g->win_num);
}
-bool
+static bool
gui_window_drag_start(struct gui_window *g, gui_drag_type type,
const struct rect *rect)
{
@@ -374,15 +324,7 @@ gui_window_drag_start(struct gui_window *g, gui_drag_type type,
return false;
}
-void
-gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- fprintf(stdout, "WINDOW SELECT_MENU WIN %u\n",
- bw->window->win_num);
-}
-
-void
+static void
gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
@@ -390,12 +332,6 @@ gui_window_save_link(struct gui_window *g, const char *url,
g->win_num, url, title);
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
-{
- LOG(("File open dialog rquest for %p/%p", g, gadget));
- /* browser_window_set_gadget_filename(bw, gadget, "filename"); */
-}
/**** Handlers ****/
@@ -566,3 +502,31 @@ monkey_window_handle_command(int argc, char **argv)
}
}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .drag_start = gui_window_drag_start,
+ .save_link = gui_window_save_link,
+ .scroll_visible = gui_window_scroll_visible,
+ .scroll_start = gui_window_scroll_start,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *monkey_window_table = &window_table;
diff --git a/monkey/browser.h b/monkey/browser.h
index 3ccbe7a91..959c6a1e6 100644
--- a/monkey/browser.h
+++ b/monkey/browser.h
@@ -22,6 +22,9 @@
#include "desktop/browser.h"
#include "content/hlcache.h"
+extern struct gui_window_table *monkey_window_table;
+extern struct gui_download_table *monkey_download_table;
+
struct gui_window {
struct gui_window *r_next;
struct gui_window *r_prev;
@@ -42,4 +45,5 @@ void monkey_window_process_reformats(void);
void monkey_window_handle_command(int argc, char **argv);
void monkey_kill_browser_windows(void);
+
#endif /* NETSURF_MONKEY_BROWSER_H */
diff --git a/monkey/cert.c b/monkey/cert.c
index 0aa01f3a7..48359e8c2 100644
--- a/monkey/cert.c
+++ b/monkey/cert.c
@@ -16,11 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+#include <stdio.h>
+
#include "desktop/gui.h"
#include "utils/ring.h"
-#include <stdlib.h>
-#include <stdio.h>
+#include "monkey/cert.h"
typedef struct monkey_cert {
struct monkey_cert *r_next, *r_prev;
diff --git a/monkey/cert.h b/monkey/cert.h
new file mode 100644
index 000000000..2780f4f57
--- /dev/null
+++ b/monkey/cert.h
@@ -0,0 +1,4 @@
+void
+gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+ unsigned long num, nserror (*cb)(bool proceed, void *pw),
+ void *cbpw);
diff --git a/monkey/download.c b/monkey/download.c
index d706dd6e0..d2e3b4b24 100644
--- a/monkey/download.c
+++ b/monkey/download.c
@@ -34,7 +34,7 @@ struct gui_download_window {
static struct gui_download_window *dw_ring = NULL;
-struct gui_download_window *
+static struct gui_download_window *
gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
@@ -52,7 +52,7 @@ gui_download_window_create(download_context *ctx,
return ret;
}
-nserror
+static nserror
gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
@@ -61,7 +61,7 @@ gui_download_window_data(struct gui_download_window *dw,
return NSERROR_OK;
}
-void
+static void
gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
@@ -69,7 +69,7 @@ gui_download_window_error(struct gui_download_window *dw,
dw->dwin_num, error_msg);
}
-void
+static void
gui_download_window_done(struct gui_download_window *dw)
{
fprintf(stdout, "DOWNLOAD_WINDOW DONE DWIN %u\n",
@@ -77,3 +77,12 @@ gui_download_window_done(struct gui_download_window *dw)
RING_REMOVE(dw_ring, dw);
free(dw);
}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *monkey_download_table = &download_table;
diff --git a/monkey/main.c b/monkey/main.c
index 95432e3c7..b6f5c434d 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -25,6 +25,8 @@
#include "monkey/poll.h"
#include "monkey/dispatch.h"
#include "monkey/browser.h"
+#include "monkey/cert.h"
+#include "monkey/401login.h"
#include "content/urldb.h"
#include "content/fetchers/resource.h"
@@ -55,7 +57,7 @@ nsmonkey_init_resource(const char *resource_path)
return respath;
}
-void gui_quit(void)
+static void monkey_quit(void)
{
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
@@ -64,7 +66,7 @@ void gui_quit(void)
gtk_fetch_filetype_fin();
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
char *raw;
@@ -79,7 +81,7 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-void
+static void
gui_launch_url(const char *url)
{
fprintf(stdout, "GENERIC LAUNCH URL %s\n", url);
@@ -113,6 +115,56 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
+static struct gui_browser_table monkey_browser_table = {
+ .poll = monkey_poll,
+ .quit = monkey_quit,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
int
main(int argc, char **argv)
{
@@ -120,6 +172,11 @@ main(int argc, char **argv)
char *options;
char buf[PATH_MAX];
nserror ret;
+ struct gui_table monkey_gui_table = {
+ .browser = &monkey_browser_table,
+ .window = monkey_window_table,
+ .download = monkey_download_table,
+ };
/* Unbuffer stdin/out/err */
setbuf(stdin, NULL);
@@ -146,7 +203,7 @@ main(int argc, char **argv)
/* common initialisation */
messages = filepath_find(respaths, "Messages");
- ret = netsurf_init(messages);
+ ret = netsurf_init(messages, &monkey_gui_table);
free(messages);
if (ret != NSERROR_OK) {
die("NetSurf failed to initialise");
diff --git a/monkey/poll.c b/monkey/poll.c
index 024005b89..414d458bd 100644
--- a/monkey/poll.c
+++ b/monkey/poll.c
@@ -88,7 +88,7 @@ monkey_prepare_input(void)
}
void
-gui_poll(bool active)
+monkey_poll(bool active)
{
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
diff --git a/monkey/poll.h b/monkey/poll.h
index 1aebe6856..4195958c9 100644
--- a/monkey/poll.h
+++ b/monkey/poll.h
@@ -21,4 +21,6 @@
void monkey_prepare_input(void);
+void monkey_poll(bool active);
+
#endif /* NETSURF_MONKEY_POLL_H */
diff --git a/monkey/utils.c b/monkey/utils.c
index 3e09106f7..aa7245533 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -70,44 +70,6 @@ char *url_to_path(const char *url)
return respath;
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
-}
void warn_user(const char *warning, const char *detail)
{