From d47fed45245ddcecfb69d1e951ce627bdb6a44ff Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 16 Jan 2014 00:52:17 +0000 Subject: move 401 login into operation table --- desktop/401login.h | 31 ------------------------------- desktop/browser.c | 1 - desktop/gui.h | 35 ++++++++++++++++++++--------------- desktop/gui_factory.c | 9 +++++++++ desktop/netsurf.c | 4 +--- 5 files changed, 30 insertions(+), 50 deletions(-) delete mode 100644 desktop/401login.h (limited to 'desktop') diff --git a/desktop/401login.h b/desktop/401login.h deleted file mode 100644 index 1c8140bae..000000000 --- a/desktop/401login.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2003 John M Bell - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef NETSURF_DESKTOP_401LOGIN_H -#define NETSURF_DESKTOP_401LOGIN_H - -#include - -#include "utils/config.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); - -#endif diff --git a/desktop/browser.c b/desktop/browser.c index d65033097..f66e27576 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -41,7 +41,6 @@ #include "content/fetch.h" #include "content/hlcache.h" #include "content/urldb.h" -#include "desktop/401login.h" #include "desktop/browser_private.h" #include "desktop/download.h" #include "desktop/frames.h" diff --git a/desktop/gui.h b/desktop/gui.h index 102aade45..cd116e9c1 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -301,6 +301,23 @@ struct gui_browser_table { */ void (*poll)(bool active); + /** + * 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); + + /** + * 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); /* Optional entries */ @@ -345,22 +362,10 @@ struct gui_browser_table { void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); /** - * 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); - - /** - * 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 + * Prompt user for login */ - bool (*path_add_part)(char *path, int length, const char *newpart); + void (*login)(nsurl *url, const char *realm, + nserror (*cb)(bool proceed, void *pw), void *cbpw); }; diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index cd5031b0d..1bd683df7 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -304,6 +304,12 @@ static void gui_default_cert_verify(nsurl *url, cb(false, cbpw); } +static void gui_default_401login_open(nsurl *url, const char *realm, + nserror (*cb)(bool proceed, void *pw), void *cbpw) +{ + cb(false, cbpw); +} + static nserror verify_browser_register(struct gui_browser_table *gbt) { @@ -343,6 +349,9 @@ static nserror verify_browser_register(struct gui_browser_table *gbt) if (gbt->cert_verify == NULL) { gbt->cert_verify = gui_default_cert_verify; } + if (gbt->login == NULL) { + gbt->login = gui_default_401login_open; + } return NSERROR_OK; } diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 5589f51a5..d294073ba 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -37,10 +37,8 @@ #include "image/image.h" #include "image/image_cache.h" #include "desktop/netsurf.h" -#include "desktop/401login.h" #include "desktop/browser.h" #include "desktop/system_colour.h" -#include "desktop/gui.h" #include "desktop/gui_factory.h" #include "utils/nsoption.h" #include "desktop/searchweb.h" @@ -96,7 +94,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, { switch (query->type) { case LLCACHE_QUERY_AUTH: - gui_401login_open(query->url, query->data.auth.realm, cb, cbpw); + guit->browser->login(query->url, query->data.auth.realm, cb, cbpw); break; case LLCACHE_QUERY_REDIRECT: /** \todo Need redirect query dialog */ -- cgit v1.2.3