diff options
-rw-r--r-- | content/fetchers/curl.c | 3 | ||||
-rw-r--r-- | desktop/browser.c | 11 | ||||
-rw-r--r-- | desktop/hotlist.c | 19 | ||||
-rw-r--r-- | desktop/save_complete.c | 20 | ||||
-rw-r--r-- | desktop/scrollbar.h | 6 | ||||
-rw-r--r-- | desktop/tree.c | 20 | ||||
-rw-r--r-- | render/box.c | 16 | ||||
-rw-r--r-- | render/form.c | 14 | ||||
-rw-r--r-- | render/html.c | 3 | ||||
-rw-r--r-- | render/search.c | 9 | ||||
-rw-r--r-- | test/llcache.c | 14 | ||||
-rw-r--r-- | test/urldbtest.c | 11 |
12 files changed, 69 insertions, 77 deletions
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index 7b9c5f0d7..b94a3f24f 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -53,6 +53,7 @@ #include "utils/file.h" #include "utils/string.h" #include "desktop/gui_fetch.h" +#include "desktop/gui_misc.h" #include "desktop/gui_internal.h" #include "content/fetch.h" @@ -1053,7 +1054,7 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) codem = curl_multi_perform(fetch_curl_multi, &running); if (codem != CURLM_OK && codem != CURLM_CALL_MULTI_PERFORM) { LOG("curl_multi_perform: %i %s", codem, curl_multi_strerror(codem)); - warn_user("MiscError", curl_multi_strerror(codem)); + guit->misc->warning("MiscError", curl_multi_strerror(codem)); return; } } while (codem == CURLM_CALL_MULTI_PERFORM); diff --git a/desktop/browser.c b/desktop/browser.c index 9316b771d..4cd017d57 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1205,7 +1205,7 @@ browser_window_callback_errorcode(hlcache_handle *c, /* Only warn the user about errors in top-level windows */ if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) { - warn_user(message, 0); + guit->misc->warning(message, NULL); } if (c == bw->loading_content) { @@ -1459,8 +1459,9 @@ static nserror browser_window_callback(hlcache_handle *c, browser_window_set_status(bw, event->data.error); /* Only warn the user about errors in top-level windows */ - if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) - warn_user(event->data.error, 0); + if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) { + guit->misc->warning(event->data.error, NULL); + } if (c == bw->loading_content) bw->loading_content = NULL; @@ -2073,7 +2074,7 @@ nserror browser_window_navigate(struct browser_window *bw, default: /* report error to user */ browser_window_set_status(bw, messages_get_errorcode(error)); /** @todo should the caller report the error? */ - warn_user(messages_get_errorcode(error), 0); + guit->misc->warning(messages_get_errorcode(error), NULL); break; } @@ -2814,7 +2815,7 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, if (target[0] != '_') { bw_target->name = strdup(target); if (!bw_target->name) - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", NULL); } return bw_target; } diff --git a/desktop/hotlist.c b/desktop/hotlist.c index e6e11e4ba..98d5f9c19 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -25,16 +25,19 @@ #include <dom/dom.h> #include <dom/bindings/hubbub/parser.h> -#include "content/urldb.h" -#include "desktop/hotlist.h" -#include "desktop/treeview.h" -#include "desktop/browser.h" #include "utils/corestrings.h" #include "utils/messages.h" #include "utils/utils.h" #include "utils/utf8.h" #include "utils/libdom.h" #include "utils/log.h" +#include "content/urldb.h" + +#include "desktop/gui_misc.h" +#include "desktop/gui_internal.h" +#include "desktop/hotlist.h" +#include "desktop/treeview.h" +#include "desktop/browser.h" #define N_DAYS 28 #define N_SEC_PER_DAY (60 * 60 * 24) @@ -799,7 +802,7 @@ static nserror hotlist_load(const char *path, bool *loaded) corestring_lwc_html); if (html == NULL) { dom_node_unref(document); - warn_user("TreeLoadError", "(<html> not found)"); + guit->misc->warning("TreeLoadError", "(<html> not found)"); return NSERROR_OK; } @@ -808,7 +811,7 @@ static nserror hotlist_load(const char *path, bool *loaded) if (body == NULL) { dom_node_unref(html); dom_node_unref(document); - warn_user("TreeLoadError", "(<html>...<body> not found)"); + guit->misc->warning("TreeLoadError", "(<html>...<body> not found)"); return NSERROR_OK; } @@ -818,7 +821,7 @@ static nserror hotlist_load(const char *path, bool *loaded) dom_node_unref(body); dom_node_unref(html); dom_node_unref(document); - warn_user("TreeLoadError", + guit->misc->warning("TreeLoadError", "(<html>...<body>...<ul> not found.)"); return NSERROR_OK; } @@ -843,7 +846,7 @@ static nserror hotlist_load(const char *path, bool *loaded) dom_node_unref(document); if (err != NSERROR_OK) { - warn_user("TreeLoadError", "(Failed building tree.)"); + guit->misc->warning("TreeLoadError", "(Failed building tree.)"); return NSERROR_OK; } diff --git a/desktop/save_complete.c b/desktop/save_complete.c index 635161dfb..98b0304f8 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -45,6 +45,8 @@ #include "render/box.h" #include "render/html.h" +#include "desktop/gui_misc.h" +#include "desktop/gui_internal.h" #include "desktop/save_complete.h" regex_t save_complete_import_re; @@ -150,7 +152,7 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx, ret = netsurf_mkpath(&fname, NULL, 2, ctx->path, leafname); if (ret != NSERROR_OK) { - warn_user(messages_get_errorcode(ret), 0); + guit->misc->warning(messages_get_errorcode(ret), 0); return false; } @@ -158,7 +160,7 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx, if (fp == NULL) { free(fname); LOG("fopen(): errno = %i", errno); - warn_user("SaveError", strerror(errno)); + guit->misc->warning("SaveError", strerror(errno)); return false; } @@ -316,7 +318,7 @@ static bool save_complete_save_stylesheet(save_complete_ctx *ctx, return true; if (save_complete_ctx_add_content(ctx, css) == false) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } @@ -329,7 +331,7 @@ static bool save_complete_save_stylesheet(save_complete_ctx *ctx, source = save_complete_rewrite_stylesheet_urls(ctx, css_data, css_size, hlcache_handle_get_url(css), &source_len); if (source == NULL) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } @@ -412,7 +414,7 @@ static bool save_complete_save_html_object(save_complete_ctx *ctx, return true; if (save_complete_ctx_add_content(ctx, obj) == false) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } @@ -1056,7 +1058,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx, ret = netsurf_mkpath(&fname, NULL, 2, ctx->path, filename); if (ret != NSERROR_OK) { - warn_user(messages_get_errorcode(ret), NULL); + guit->misc->warning(messages_get_errorcode(ret), NULL); return false; } @@ -1064,7 +1066,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx, if (fp == NULL) { free(fname); LOG("fopen(): errno = %i", errno); - warn_user("SaveError", strerror(errno)); + guit->misc->warning("SaveError", strerror(errno)); return false; } @@ -1077,7 +1079,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx, if (save_complete_libdom_treewalk((dom_node *) doc, save_complete_node_handler, ctx) == false) { free(fname); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); fclose(fp); return false; } @@ -1143,7 +1145,7 @@ static bool save_complete_inventory(save_complete_ctx *ctx) free(fname); if (fp == NULL) { LOG("fopen(): errno = %i", errno); - warn_user("SaveError", strerror(errno)); + guit->misc->warning("SaveError", strerror(errno)); return false; } diff --git a/desktop/scrollbar.h b/desktop/scrollbar.h index bfe90d9b5..d277be26c 100644 --- a/desktop/scrollbar.h +++ b/desktop/scrollbar.h @@ -73,10 +73,10 @@ typedef void(*scrollbar_client_callback)(void *client_data, * \param client_data data for the client callback * \param client_callback client callback for scrollbar events * \param s updated to point at the newly created scrollbar - * \return true if scrollbar has been created succesfully or false on - * memory exhaustion + * \return NSERROR_OK and s updated if scrollbar has been created + * succesfully or eror code and s set to NULL on faliure; */ -bool scrollbar_create(bool horizontal, int length, int full_size, +nserror scrollbar_create(bool horizontal, int length, int full_size, int visible_size, void *client_data, scrollbar_client_callback client_callback, struct scrollbar **s); diff --git a/desktop/tree.c b/desktop/tree.c index eac9201cf..c5bca61da 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -45,6 +45,8 @@ struct tree { void *client_data; /* User assigned data for the callbacks */ }; +#include "desktop/gui_misc.h" +#include "desktop/gui_internal.h" #include "desktop/treeview.h" #include "desktop/hotlist.h" #include "desktop/cookie_manager.h" @@ -139,24 +141,24 @@ static bool treeview_test_init(struct tree *tree) "sslcert viewers"); err = cookie_manager_init(&cw_t, (struct core_window *)tree); if (err != NSERROR_OK) - warn_user("Couldn't init new cookie manager.", 0); + guit->misc->warning("Couldn't init new cookie manager.", 0); break; case TREE_HISTORY: err = global_history_init(&cw_t, (struct core_window *)tree); if (err != NSERROR_OK) - warn_user("Couldn't init new global history.", 0); + guit->misc->warning("Couldn't init new global history.", 0); break; case TREE_HOTLIST: err = hotlist_init(&cw_t, (struct core_window *)tree, tree_hotlist_path); if (err != NSERROR_OK) - warn_user("Couldn't init new hotlist.", 0); + guit->misc->warning("Couldn't init new hotlist.", 0); break; case TREE_SSLCERT: err = sslcert_viewer_init(&cw_t, (struct core_window *)tree, ssl_current_session); if (err != NSERROR_OK) - warn_user("Couldn't init new sslcert viewer.", 0); + guit->misc->warning("Couldn't init new sslcert viewer.", 0); break; } @@ -171,17 +173,17 @@ static bool treeview_test_fini(struct tree *tree) case TREE_COOKIES: err = cookie_manager_fini(); if (err != NSERROR_OK) - warn_user("Couldn't finalise cookie manager.", 0); + guit->misc->warning("Couldn't finalise cookie manager.", 0); break; case TREE_HISTORY: err = global_history_fini(); if (err != NSERROR_OK) - warn_user("Couldn't finalise cookie manager.", 0); + guit->misc->warning("Couldn't finalise cookie manager.", 0); break; case TREE_HOTLIST: err = hotlist_fini(tree_hotlist_path); if (err != NSERROR_OK) - warn_user("Couldn't finalise hotlist.", 0); + guit->misc->warning("Couldn't finalise hotlist.", 0); break; case TREE_SSLCERT: assert(ssl_current_session != NULL && @@ -189,7 +191,7 @@ static bool treeview_test_fini(struct tree *tree) err = sslcert_viewer_fini(ssl_current_session); ssl_current_session = NULL; if (err != NSERROR_OK) - warn_user("Couldn't finalise sslcert viewer.", 0); + guit->misc->warning("Couldn't finalise sslcert viewer.", 0); break; } @@ -287,7 +289,7 @@ struct tree *tree_create(unsigned int flags, tree = calloc(sizeof(struct tree), 1); if (tree == NULL) { LOG("calloc failed"); - warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); + guit->misc->warning(messages_get_errorcode(NSERROR_NOMEM), 0); return NULL; } diff --git a/render/box.c b/render/box.c index 5a0735e24..bb1800b00 100644 --- a/render/box.c +++ b/render/box.c @@ -28,19 +28,23 @@ #include <stdio.h> #include <string.h> #include <dom/dom.h> + +#include "utils/nsoption.h" +#include "utils/log.h" +#include "utils/talloc.h" +#include "utils/utils.h" #include "content/content_protected.h" #include "content/hlcache.h" #include "css/css.h" #include "css/utils.h" #include "css/dump.h" #include "desktop/scrollbar.h" -#include "utils/nsoption.h" +#include "desktop/gui_misc.h" +#include "desktop/gui_internal.h" + #include "render/box.h" #include "render/form_internal.h" #include "render/html_internal.h" -#include "utils/log.h" -#include "utils/talloc.h" -#include "utils/utils.h" #define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \ box->type == BOX_FLOAT_RIGHT) @@ -1146,7 +1150,7 @@ bool box_handle_scrollbars(struct content *c, struct box *box, data = malloc(sizeof(struct html_scrollbar_data)); if (data == NULL) { LOG("malloc failed"); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } data->c = c; @@ -1167,7 +1171,7 @@ bool box_handle_scrollbars(struct content *c, struct box *box, data = malloc(sizeof(struct html_scrollbar_data)); if (data == NULL) { LOG("malloc failed"); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } data->c = c; diff --git a/render/form.c b/render/form.c index f53e9dece..dce906437 100644 --- a/render/form.c +++ b/render/form.c @@ -51,6 +51,8 @@ #include "desktop/plotters.h" #include "desktop/scrollbar.h" #include "desktop/textarea.h" +#include "desktop/gui_misc.h" +#include "desktop/gui_internal.h" #include "render/box.h" #include "render/font.h" @@ -1095,7 +1097,7 @@ bool form_open_select_menu(void *client_data, menu = calloc(1, sizeof (struct form_select_menu)); if (menu == NULL) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return false; } @@ -1710,7 +1712,7 @@ void form_submit(nsurl *page_url, struct browser_window *target, assert(form != NULL); if (form_successful_controls_dom(form, submit_button, &success) == false) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return; } @@ -1718,7 +1720,7 @@ void form_submit(nsurl *page_url, struct browser_window *target, if (nsurl_create(form->action, &action_url) != NSERROR_OK) { free(data); fetch_multipart_data_destroy(success); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return; } @@ -1727,7 +1729,7 @@ void form_submit(nsurl *page_url, struct browser_window *target, data = form_url_encode(form, success, true); if (data == NULL) { fetch_multipart_data_destroy(success); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return; } @@ -1737,7 +1739,7 @@ void form_submit(nsurl *page_url, struct browser_window *target, nsurl_unref(action_query); free(data); fetch_multipart_data_destroy(success); - warn_user(messages_get_errorcode(error), 0); + guit->misc->warning(messages_get_errorcode(error), 0); return; } @@ -1757,7 +1759,7 @@ void form_submit(nsurl *page_url, struct browser_window *target, data = form_url_encode(form, success, false); if (data == NULL) { fetch_multipart_data_destroy(success); - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); nsurl_unref(action_url); return; } diff --git a/render/html.c b/render/html.c index 68eb11cd2..c809ee159 100644 --- a/render/html.c +++ b/render/html.c @@ -51,6 +51,7 @@ #include "desktop/browser.h" #include "desktop/gui_utf8.h" #include "desktop/gui_layout.h" +#include "desktop/gui_misc.h" #include "desktop/gui_internal.h" #include "render/box.h" @@ -2078,7 +2079,7 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file) assert(ret != NSERROR_BAD_ENCODING); LOG("local to utf8 encoding failed"); free(buffer); - warn_user("NoMemory", NULL); + guit->misc->warning("NoMemory", NULL); return true; } diff --git a/render/search.c b/render/search.c index b586ff55f..f5e231ab0 100644 --- a/render/search.c +++ b/render/search.c @@ -34,6 +34,7 @@ #include "content/hlcache.h" #include "desktop/selection.h" #include "desktop/gui_search.h" +#include "desktop/gui_misc.h" #include "desktop/gui_internal.h" #include "render/box.h" @@ -85,13 +86,13 @@ struct search_context * search_create_context(struct content *c, context = malloc(sizeof(struct search_context)); if (context == NULL) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return NULL; } search_head = malloc(sizeof(struct list_entry)); if (search_head == NULL) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); free(context); return NULL; } @@ -282,7 +283,7 @@ static struct list_entry *add_entry(unsigned start_idx, unsigned end_idx, /* found string in box => add to list */ entry = calloc(1, sizeof(*entry)); if (!entry) { - warn_user("NoMemory", 0); + guit->misc->warning("NoMemory", 0); return NULL; } @@ -548,7 +549,7 @@ void search_step(struct search_context *context, search_flags_t flags, int i = 0; if (context == NULL) { - warn_user("SearchError", 0); + guit->misc->warning("SearchError", 0); return; } diff --git a/test/llcache.c b/test/llcache.c index 42abb24cb..850f0608c 100644 --- a/test/llcache.c +++ b/test/llcache.c @@ -37,20 +37,6 @@ bool verbose_log; /* utils/utils.h */ -void die(const char * const error) -{ - fprintf(stderr, "%s\n", error); - - exit(1); -} - -/* utils/utils.h */ -void warn_user(const char *warning, const char *detail) -{ - fprintf(stderr, "%s %s\n", warning, detail); -} - -/* utils/utils.h */ char *filename_from_path(char *path) { char *leafname; diff --git a/test/urldbtest.c b/test/urldbtest.c index aa3a2df5b..7a0337970 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -62,17 +62,6 @@ void cookie_manager_remove(const struct cookie_data *data) { } -void die(const char *error) -{ - printf("die: %s\n", error); - exit(1); -} - - -void warn_user(const char *warning, const char *detail) -{ - printf("WARNING: %s %s\n", warning, detail); -} void bitmap_destroy(void *bitmap) { |