summaryrefslogtreecommitdiff
path: root/desktop/searchweb.h
blob: 612e9bdd128cb805ad2c0f95bfb7300a098c23b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
 *
 * 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/>.
 */

/**
 * \file desktop/searchweb.h
 * \brief core web search facilities interface.
 */

#ifndef _NETSURF_DESKTOP_SEARCH_WEB_H_
#define _NETSURF_DESKTOP_SEARCH_WEB_H_

struct bitmap;

/**
 * Graphical user interface browser web search function table.
 *
 */
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);
};

/**
 * Flags which alter the behaviour of the omin search.
 */
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.
					 */
};

/**
 * 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.
 */
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out);

/**
 * 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.
 */
nserror search_web_select_provider(int selection);

/**
 * Initialise the web search operations.
 *
 * \param provider_fname Path to web search providers file.
 * \return NSERROR_OK on successful initialisation or appropriate error code.
 */
nserror search_web_init(const char *provider_fname);

/**
 * Finalise the web search operations freeing all resources.
 *
 * \return NSERROR_OK on success or appropriate error code.
 */
nserror search_web_finalise(void);

#endif