From 746177ee39482cfa7ea2e2fe66efd383a16b5379 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 29 Apr 2016 10:53:31 +0100 Subject: [PATCH] stop monkey frontend using depricated warn_user API --- monkey/browser.c | 49 +++++++++++++++++++++++++++++------------------- monkey/browser.h | 2 ++ monkey/main.c | 6 ------ 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/monkey/browser.c b/monkey/browser.c index 85b3c62ed..0b850d9a2 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -37,6 +37,13 @@ static uint32_t win_ctr = 0; static struct gui_window *gw_ring = NULL; +/* exported function documented in monkey/browser.h */ +nserror monkey_warn_user(const char *warning, const char *detail) +{ + fprintf(stderr, "WARN %s %s\n", warning, detail); + return NSERROR_OK; +} + struct gui_window * monkey_find_window_by_num(uint32_t win_num) { @@ -366,6 +373,9 @@ static void monkey_window_handle_go(int argc, char **argv) { struct gui_window *gw; + nsurl *url; + nsurl *ref_url = NULL; + nserror error; if (argc < 4 || argc > 5) { fprintf(stdout, "ERROR WINDOW GO ARGS BAD\n"); @@ -376,31 +386,32 @@ monkey_window_handle_go(int argc, char **argv) if (gw == NULL) { fprintf(stdout, "ERROR WINDOW NUM BAD\n"); - } else { - nsurl *url; - nsurl *ref_url = NULL; - nserror error; + return; + } - error = nsurl_create(argv[3], &url); - if (error != NSERROR_OK) { - warn_user(messages_get_errorcode(error), 0); - } else { - if (argc == 5) { - error = nsurl_create(argv[4], &ref_url); - } + error = nsurl_create(argv[3], &url); + if (error == NSERROR_OK) { + if (argc == 5) { + error = nsurl_create(argv[4], &ref_url); + } - browser_window_navigate(gw->bw, - url, - ref_url, - BW_NAVIGATE_HISTORY, - NULL, - NULL, - NULL); - nsurl_unref(url); + if (error == NSERROR_OK) { + error = browser_window_navigate(gw->bw, + url, + ref_url, + BW_NAVIGATE_HISTORY, + NULL, + NULL, + NULL); if (ref_url != NULL) { nsurl_unref(ref_url); } } + nsurl_unref(url); + } + + if (error != NSERROR_OK) { + monkey_warn_user(messages_get_errorcode(error), 0); } } diff --git a/monkey/browser.h b/monkey/browser.h index 7fe7c5390..32572742a 100644 --- a/monkey/browser.h +++ b/monkey/browser.h @@ -43,4 +43,6 @@ void monkey_window_process_reformats(void); void monkey_window_handle_command(int argc, char **argv); void monkey_kill_browser_windows(void); +nserror monkey_warn_user(const char *warning, const char *detail); + #endif /* NETSURF_MONKEY_BROWSER_H */ diff --git a/monkey/main.c b/monkey/main.c index 7b38a3880..ff70bda71 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -223,12 +223,6 @@ static nserror set_defaults(struct nsoption_s *defaults) return NSERROR_OK; } -static nserror monkey_warn_user(const char *warning, const char *detail) -{ - fprintf(stderr, "WARN %s %s\n", warning, detail); - return NSERROR_OK; -} - /** * Ensures output logging stream is correctly configured