From ad8d0b33507ebfe684c86e12d123ae4aa9f1c43f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 14 Apr 2010 23:03:49 +0000 Subject: Handle llcache queries (GTK only for now) svn path=/trunk/netsurf/; revision=10403 --- desktop/401login.h | 10 +++++----- desktop/gui.h | 5 +++-- desktop/netsurf.c | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 9 deletions(-) (limited to 'desktop') diff --git a/desktop/401login.h b/desktop/401login.h index 8b5a0a778..dec3fa5e1 100644 --- a/desktop/401login.h +++ b/desktop/401login.h @@ -19,12 +19,12 @@ #ifndef NETSURF_DESKTOP_401LOGIN_H #define NETSURF_DESKTOP_401LOGIN_H -#include "utils/config.h" +#include -struct hlcache_handle; -struct browser_window; +#include "utils/config.h" +#include "utils/errors.h" -void gui_401login_open(struct browser_window *bw, struct hlcache_handle *c, - const char *realm); +void gui_401login_open(const char *url, const char *realm, + nserror (*cb)(bool proceed, void *pw), void *cbpw); #endif diff --git a/desktop/gui.h b/desktop/gui.h index 80ba33cc8..5c53cf694 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -134,7 +134,8 @@ bool gui_search_term_highlighted(struct gui_window *g, struct ssl_cert_info; -void gui_cert_verify(struct browser_window *bw, hlcache_handle *c, - const struct ssl_cert_info *certs, unsigned long num); +void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, + unsigned long num, nserror (*cb)(bool proceed, void *pw), + void *cbpw); #endif diff --git a/desktop/netsurf.c b/desktop/netsurf.c index f19632026..2ce1012c2 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -36,6 +36,7 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "desktop/netsurf.h" +#include "desktop/401login.h" #include "desktop/browser.h" #include "desktop/gui.h" #include "desktop/options.h" @@ -53,6 +54,35 @@ static void *netsurf_lwc_alloc(void *ptr, size_t len, void *pw) return realloc(ptr, len); } +/** + * Dispatch a low-level cache query to the frontend + * + * \param query Query descriptor + * \param pw Private data + * \param cb Continuation callback + * \param cbpw Private data for continuation + * \return NSERROR_OK + */ +static nserror netsurf_llcache_query_handler(const llcache_query *query, + void *pw, llcache_query_response cb, void *cbpw) +{ + switch (query->type) { + case LLCACHE_QUERY_AUTH: + gui_401login_open(query->url, query->data.auth.realm, cb, cbpw); + break; + case LLCACHE_QUERY_REDIRECT: + /** \todo Need redirect query dialog */ + /* For now, do nothing, as this query type isn't emitted yet */ + break; + case LLCACHE_QUERY_SSL: + gui_cert_verify(query->url, query->data.ssl.certs, + query->data.ssl.num, cb, cbpw); + break; + } + + return NSERROR_OK; +} + /** * Initialise components used by gui NetSurf. */ @@ -124,8 +154,7 @@ nserror netsurf_init(int *pargc, fetch_init(); - /** \todo The frontend needs to provide the llcache_query_handler */ - llcache_initialise(NULL, NULL); + llcache_initialise(netsurf_llcache_query_handler, NULL); return NSERROR_OK; } -- cgit v1.2.3