From 355799ce0bbb078237dfc1ae9874bbc5342acbc4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 17 Dec 2009 23:55:02 +0000 Subject: Merge branches/MarkieB/gtkmain to trunk. svn path=/trunk/netsurf/; revision=9729 --- amiga/download.c | 2 +- amiga/fetch_file.c | 26 +- amiga/gui.c | 19 +- amiga/gui.h | 2 + amiga/menu.c | 2 +- amiga/save_complete.c | 843 ++++---------------------------------------------- amiga/search.c | 803 ++++++++++++----------------------------------- 7 files changed, 298 insertions(+), 1399 deletions(-) (limited to 'amiga') diff --git a/amiga/download.c b/amiga/download.c index 48f719a60..baba92bd3 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -29,13 +29,13 @@ #include "amiga/download.h" #include "amiga/object.h" #include "amiga/options.h" -#include "amiga/save_complete.h" #include "amiga/bitmap.h" #include "amiga/iff_dr2d.h" #include "content/fetch.h" #include "desktop/selection.h" +#include "desktop/save_complete.h" #include "utils/messages.h" #include "utils/utils.h" diff --git a/amiga/fetch_file.c b/amiga/fetch_file.c index acc0d4724..953478423 100755 --- a/amiga/fetch_file.c +++ b/amiga/fetch_file.c @@ -215,11 +215,11 @@ void ami_fetch_file_free(void *vf) static void ami_fetch_file_send_callback(fetch_msg msg, struct ami_file_fetch_info *fetch, const void *data, - unsigned long size) + unsigned long size, fetch_error_code errorcode) { fetch->locked = true; /* LOG(("ami file fetcher callback %ld",msg)); */ - fetch_send_callback(msg,fetch->fetch_handle,data,size); + fetch_send_callback(msg,fetch->fetch_handle,data,size,errorcode); fetch->locked = false; } @@ -234,6 +234,7 @@ void ami_fetch_file_poll(const char *scheme_ignored) struct nsObject *node; struct nsObject *nnode; struct ami_file_fetch_info *fetch; + fetch_error_code errorcode; if(IsMinListEmpty(ami_file_fetcher_list)) return; @@ -241,6 +242,7 @@ void ami_fetch_file_poll(const char *scheme_ignored) do { + errorcode = FETCH_ERROR_NO_ERROR; nnode=(struct nsObject *)GetSucc((struct Node *)node); fetch = (struct ami_file_fetch_info *)node->objstruct; @@ -255,13 +257,19 @@ void ami_fetch_file_poll(const char *scheme_ignored) len = FRead(fetch->fh,ami_file_fetcher_buffer,1,1024); - ami_fetch_file_send_callback(FETCH_DATA, - fetch,ami_file_fetcher_buffer,len); + if (len == (ULONG)-1) + errorcode = FETCH_ERROR_MISC; + else if (len > 0) + ami_fetch_file_send_callback( + FETCH_DATA, fetch, + ami_file_fetcher_buffer, + len, errorcode); if((len<1024) && (!fetch->aborted)) { ami_fetch_file_send_callback(FETCH_FINISHED, - fetch, &fetch->cachedata, 0); + fetch, &fetch->cachedata, 0, + errorcode); fetch->aborted = true; } @@ -284,7 +292,8 @@ void ami_fetch_file_poll(const char *scheme_ignored) LOG(("mimetype %s len %ld",fetch->mimetype,fetch->len)); ami_fetch_file_send_callback(FETCH_TYPE, - fetch, fetch->mimetype, (ULONG)fetch->len); + fetch, fetch->mimetype, (ULONG)fetch->len, + errorcode); } else { @@ -292,8 +301,11 @@ void ami_fetch_file_poll(const char *scheme_ignored) errorstring = ASPrintf("%s %s",messages_get("FileError"),fetch->path); fetch_set_http_code(fetch->fetch_handle,404); + + errorcode = FETCH_ERROR_HTTP_NOT2; ami_fetch_file_send_callback(FETCH_ERROR, fetch, - errorstring, 0); + errorstring, 0, + errorcode); fetch->aborted = true; FreeVec(errorstring); } diff --git a/amiga/gui.c b/amiga/gui.c index bd8d4cb28..ebd5d6657 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -47,6 +47,7 @@ #include "amiga/menu.h" #include "amiga/options.h" #include +#include "desktop/save_complete.h" #include "desktop/textinput.h" #include #include @@ -66,7 +67,6 @@ #include "amiga/cookies.h" #include "amiga/clipboard.h" #include -#include "amiga/save_complete.h" #include "amiga/fetch_file.h" #include "amiga/fetch_mailto.h" #include "amiga/search.h" @@ -3410,6 +3410,23 @@ void gui_window_stop_throbber(struct gui_window *g) // g->shared->throbber_frame = 0; } +/** + * function to add retrieved favicon to gui + */ +void gui_window_set_icon(struct gui_window *g, struct content *icon) +{ +} + +/** + * set gui display of a retrieved favicon representing the search + * provider + * \param ico may be NULL for local calls; then access current cache from + * search_web_ico() + */ +void gui_window_set_search_ico(struct content *ico) +{ +} + void ami_update_throbber(struct gui_window_2 *g,bool redraw) { struct IBox *bbox; diff --git a/amiga/gui.h b/amiga/gui.h index ddf1dc9b2..47aace0db 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -56,6 +56,8 @@ enum GID_NEXT, GID_PREV, GID_SEARCHSTRING, + GID_SHOWALL, + GID_CASE, GID_HSCROLL, GID_LAST }; diff --git a/amiga/menu.c b/amiga/menu.c index f80907ccd..7ceb9191d 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -30,13 +30,13 @@ #include "amiga/save_pdf.h" #include "desktop/save_text.h" #include "desktop/save_pdf/pdf_plotters.h" +#include "desktop/save_complete.h" #include #include "amiga/tree.h" #include "amiga/history.h" #include "amiga/cookies.h" #include #include "amiga/arexx.h" -#include "amiga/save_complete.h" #include "utils/url.h" #include #include "desktop/textinput.h" diff --git a/amiga/save_complete.c b/amiga/save_complete.c index 29b58ba3b..1cadc2030 100755 --- a/amiga/save_complete.c +++ b/amiga/save_complete.c @@ -2,6 +2,7 @@ * Copyright 2004 John M Bell * Copyright 2004-2007 James Bursa * Copyright 2008 Chris Young + * Copyright 2009 Mark Benjamin * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -18,807 +19,97 @@ * along with this program. If not, see . */ -/** \file - * Save HTML document with dependencies (implementation). - */ - -#include "utils/config.h" -//#define _GNU_SOURCE /* for strndup */ -#include #include -#include #include #include -#include -#include #include -#include -#include "utils/config.h" -#include "css/css.h" -#include "render/box.h" -#include "amiga/save_complete.h" -#include "utils/log.h" -#include "utils/url.h" +#include "desktop/save_complete.h" #include "utils/utils.h" -#include #include #include - -regex_t save_complete_import_re; - -/** An entry in save_complete_list. */ -struct save_complete_entry { - struct content *content; - struct save_complete_entry *next; /**< Next entry in list */ -}; - -/** List of urls seen and saved so far. */ -static struct save_complete_entry *save_complete_list = 0; - -static bool save_complete_html(struct content *c, const char *path, - bool index); -static bool save_imported_sheets(struct content *c, const char *path); -static char * rewrite_stylesheet_urls(const char *source, unsigned int size, - int *osize, const char *base); -static bool rewrite_document_urls(xmlDoc *doc, const char *base); -static bool rewrite_urls(xmlNode *n, const char *base); -static bool rewrite_url(xmlNode *n, const char *attr, const char *base); -static bool save_complete_list_add(struct content *content); -static struct content * save_complete_list_find(const char *url); -static bool save_complete_list_check(struct content *content); -/* static void save_complete_list_dump(void); */ -static bool save_complete_inventory(const char *path); +#include "content/content.h" /** - * Save an HTML page with all dependencies. - * - * \param c CONTENT_HTML to save - * \param path directory to save to (must exist) - * \return true on success, false on error and error reported - */ - -bool save_complete(struct content *c, const char *path) -{ - bool result; - - result = save_complete_html(c, path, true); - - if (result) - result = save_complete_inventory(path); - - /* free save_complete_list */ - while (save_complete_list) { - struct save_complete_entry *next = save_complete_list->next; - free(save_complete_list); - save_complete_list = next; - } - - return result; -} - - -/** - * Save an HTML page with all dependencies, recursing through imported pages. - * - * \param c CONTENT_HTML to save - * \param path directory to save to (must exist) - * \param index true to save as "index" - * \return true on success, false on error and error reported - */ - -bool save_complete_html(struct content *c, const char *path, bool index) -{ - char spath[256]; - unsigned int i; - htmlParserCtxtPtr parser; - BPTR fh = 0; - - if (c->type != CONTENT_HTML) - return false; - - if (save_complete_list_check(c)) - return true; - - /* save stylesheets, ignoring the base and adblocking sheets */ - for (i = STYLESHEET_START; i != c->data.html.stylesheet_count; i++) { - struct content *css = c->data.html.stylesheets[i].c; - char *source; - int source_len; - bool is_style; - - if (!css) - continue; - if (save_complete_list_check(css)) - continue; - - is_style = (strcmp(css->url, c->data.html.base_url) == 0); - - if (is_style == false) { - if (!save_complete_list_add(css)) { - warn_user("NoMemory", 0); - return false; - } - } - - if (!save_imported_sheets(css, path)) - return false; - - if (is_style) - continue; /* don't save