2009-12-18 02:55:02 +03:00
|
|
|
/*
|
2014-05-25 03:57:48 +04:00
|
|
|
* Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
|
2009-12-18 02:55:02 +03:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* \file desktop/searchweb.h
|
|
|
|
* \brief core web search facilities interface.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
|
|
|
|
2014-05-25 03:57:48 +04:00
|
|
|
#ifndef _NETSURF_DESKTOP_SEARCH_WEB_H_
|
|
|
|
#define _NETSURF_DESKTOP_SEARCH_WEB_H_
|
|
|
|
|
|
|
|
struct bitmap;
|
2014-11-22 19:39:31 +03:00
|
|
|
struct nsurl;
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* Graphical user interface browser web search function table.
|
|
|
|
*
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
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);
|
|
|
|
};
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* Flags which alter the behaviour of the omin search.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
enum search_web_omni_flags {
|
2014-11-10 19:05:22 +03:00
|
|
|
/** no changes to default operation */
|
|
|
|
SEARCH_WEB_OMNI_NONE = 0,
|
|
|
|
|
|
|
|
/** The search does not attempt to interpret the url as a url
|
|
|
|
* before using it as a search term.
|
|
|
|
*/
|
|
|
|
SEARCH_WEB_OMNI_SEARCHONLY = 1,
|
2014-05-25 03:57:48 +04:00
|
|
|
};
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* 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.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out);
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* 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.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
nserror search_web_select_provider(int selection);
|
2009-12-18 02:55:02 +03:00
|
|
|
|
2014-06-03 18:40:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate the search providers, returning their names.
|
|
|
|
*
|
|
|
|
* \param from Index to start iteration from. Use 0 to begin iteration.
|
|
|
|
* Use the value returned from search_web_iterate_providers to
|
|
|
|
* continue an iteration.
|
|
|
|
* \param name Pointer to fill in with the search provider name requested.
|
|
|
|
* \return -1 if there are no more, otherwise the iterator for the next item.
|
|
|
|
*
|
2014-11-10 19:05:22 +03:00
|
|
|
* \verbatim
|
2014-06-03 18:40:28 +04:00
|
|
|
* ssize_t iter;
|
|
|
|
* const char *name;
|
|
|
|
* ...
|
|
|
|
* for (iter = search_web_iterate_providers(0, &name);
|
|
|
|
* iter != -1;
|
|
|
|
* iter = search_web_iterate_providers(iter, &name)) {
|
|
|
|
* do_something_with(name);
|
|
|
|
* }
|
2014-11-10 19:05:22 +03:00
|
|
|
* \endverbatim
|
2014-06-03 18:40:28 +04:00
|
|
|
*/
|
|
|
|
ssize_t search_web_iterate_providers(ssize_t from, const char **name);
|
|
|
|
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* Initialise the web search operations.
|
|
|
|
*
|
|
|
|
* \param provider_fname Path to web search providers file.
|
|
|
|
* \return NSERROR_OK on successful initialisation or appropriate error code.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
nserror search_web_init(const char *provider_fname);
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/**
|
2014-05-25 03:57:48 +04:00
|
|
|
* Finalise the web search operations freeing all resources.
|
|
|
|
*
|
|
|
|
* \return NSERROR_OK on success or appropriate error code.
|
2009-12-18 02:55:02 +03:00
|
|
|
*/
|
2014-05-25 03:57:48 +04:00
|
|
|
nserror search_web_finalise(void);
|
2011-01-20 16:51:41 +03:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
#endif
|