From a6d3ceae0ee7cee85020a70b716586425a042900 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 25 May 2014 00:57:48 +0100 Subject: Completely re-write web search provider handling --- desktop/searchweb.h | 96 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 40 deletions(-) (limited to 'desktop/searchweb.h') diff --git a/desktop/searchweb.h b/desktop/searchweb.h index 3920f3c6e..612e9bdd1 100644 --- a/desktop/searchweb.h +++ b/desktop/searchweb.h @@ -1,5 +1,5 @@ /* - * Copyright 2009 Mark Benjamin + * Copyright 2014 Vincent Sanders * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -16,65 +16,81 @@ * along with this program. If not, see . */ -#ifndef _NETSURF_DESKTOP_SEARCH_WEB_H_ -#define _NETSURF_DESKTOP_SEARCH_WEB_H_ - -#include -#include -#include - -struct browser_window; -struct hlcache_handle; - -extern char *search_engines_file_location; -extern char *search_default_ico_location; - /** - * open new tab/window for web search term + * \file desktop/searchweb.h + * \brief core web search facilities interface. */ -bool search_web_new_window(struct browser_window *bw, const char *searchterm); -/** - * retrieve full search url from unencoded search term - */ -char *search_web_from_term(const char *searchterm); +#ifndef _NETSURF_DESKTOP_SEARCH_WEB_H_ +#define _NETSURF_DESKTOP_SEARCH_WEB_H_ + +struct bitmap; /** - * retrieve full search url from encoded web search term + * Graphical user interface browser web search function table. + * */ -char *search_web_get_url(const char *encsearchterm); +struct gui_search_web_table { + /** + * called when the search provider details are updated. + * + * \param provider_name The name of the provider. + * \param ico_bitmap The bitmap of the search icon may be NULL + * if no icon is yet available. + */ + nserror (*provider_update)(const char *provider_name, struct bitmap *ico_bitmap); +}; /** - * cache details of web search provider from file + * Flags which alter the behaviour of the omin search. */ -void search_web_provider_details(int reference); +enum search_web_omni_flags { + SEARCH_WEB_OMNI_NONE = 0, /**< no changes to default operation */ + SEARCH_WEB_OMNI_SEARCHONLY = 1, /**< The search does not attempt to + * interpret the url as a url before + * using it as a search term. + */ +}; /** - * retrieve name of web search provider + * Generate a nsurl from a search term. + * + * This interface obtains a url appropriate for the given search + * term. The flags allow control over the operation. By default the + * operations are: + * - interpret the \a term as a url + * - if missing a scheme as a http: url + * - combined with the search providers url into a url for that provider. + * + * \param term The search term. + * \param flags Flags to control operation. + * \param url_out The ourput url on success. + * \return NSERROR_OK on success or appropriate error code. */ -char *search_web_provider_name(void); +nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out); /** - * retrieve hostname of web search provider + * Change the currently selected web search provider. + * + * \param selection Index of the search provider to select or -1 to + * reselect the current provider + * \return NSERROR_OK on success or appropriate error code. */ -char *search_web_provider_host(void); +nserror search_web_select_provider(int selection); /** - * retrieve name of .ico for search bar + * Initialise the web search operations. + * + * \param provider_fname Path to web search providers file. + * \return NSERROR_OK on successful initialisation or appropriate error code. */ -char *search_web_ico_name(void); +nserror search_web_init(const char *provider_fname); /** - * check whether an URL is in fact a search term - * \param url the url being checked - * \return true for url, false for search + * Finalise the web search operations freeing all resources. + * + * \return NSERROR_OK on success or appropriate error code. */ -bool search_is_url(const char *url); - -void search_web_retrieve_ico(bool localdefault); - -struct hlcache_handle *search_web_ico(void); - -void search_web_cleanup(void); +nserror search_web_finalise(void); #endif -- cgit v1.2.3