NetSurf
|
core web search facilities implementation. More...
#include <stdlib.h>
#include <string.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/url.h"
#include "utils/nsoption.h"
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "desktop/searchweb.h"
#include "desktop/gui_internal.h"
Go to the source code of this file.
Data Structures | |
struct | search_provider |
struct | search_web_ctx_s |
Functions | |
static nserror | read_providers (const char *fname, char **providers_out, size_t *providers_size_out) |
Read providers file. More... | |
static nserror | parse_providers (char *providersd, size_t providers_size, struct search_provider **providers_out, size_t *providers_count) |
parse search providers from a memory block. More... | |
static nserror | make_search_nsurl (struct search_provider *provider, const char *term, nsurl **url_out) |
create a url for a search provider and a term More... | |
static nserror | search_web_ico_callback (hlcache_handle *ico, const hlcache_event *event, void *pw) |
callback for hlcache icon fetch events. More... | |
nserror | search_web_omni (const char *term, enum search_web_omni_flags flags, struct nsurl **url_out) |
Generate a nsurl from a search term. More... | |
nserror | search_web_get_provider_bitmap (struct bitmap **bitmap_out) |
obtain the current providers bitmap More... | |
nserror | search_web_select_provider (const char *selection) |
Change the currently selected web search provider. More... | |
static nserror | default_ico_callback (hlcache_handle *ico, const hlcache_event *event, void *pw) |
callback for hlcache icon fetch events. More... | |
ssize_t | search_web_iterate_providers (ssize_t iter, const char **name) |
Iterate the search providers, returning their names. More... | |
nserror | search_web_init (const char *provider_fname) |
Initialise the web search operations. More... | |
nserror | search_web_finalise (void) |
Finalise the web search operations freeing all resources. More... | |
Variables | |
static struct search_web_ctx_s | search_web_ctx |
static const char * | default_providers = "Google|www.google.com|https://www.google.com/search?q=%s|https://www.google.com/favicon.ico|\n" |
static const char * | default_search_icon_url = "resource:icons/search.png" |
core web search facilities implementation.
Definition in file searchweb.c.
|
static |
callback for hlcache icon fetch events.
Definition at line 468 of file searchweb.c.
References content_get_bitmap(), CONTENT_MSG_DONE, CONTENT_MSG_ERROR, search_web_ctx_s::current, hlcache_event::data, search_web_ctx_s::default_ico_handle, content_msg_data::errordata, content_msg_data::errormsg, guit, hlcache_handle_get_url(), hlcache_handle_release(), search_provider::ico_handle, search_provider::name, NSERROR_OK, NSLOG, nsurl_access(), gui_search_web_table::provider_update, search_web_ctx_s::providers, netsurf_table::search_web, search_web_ctx, and hlcache_event::type.
Referenced by search_web_init().
|
static |
create a url for a search provider and a term
provider | The provider to use. |
term | The term being searched for. |
url_out | The resulting url. |
Definition at line 231 of file searchweb.c.
References NSERROR_NOMEM, NSERROR_OK, nsurl_create(), search_provider::searchstring, and url_escape().
Referenced by search_web_omni().
|
static |
parse search providers from a memory block.
providersd | The provider info data. |
providers_size | The size of the provider data. |
providers_out | The resulting provider array. |
providers_count | The number of providers in the output array. |
Definition at line 139 of file searchweb.c.
References search_provider::hostname, search_provider::ico, search_provider::ico_handle, search_provider::name, NSERROR_INVALID, NSERROR_NOMEM, NSERROR_OK, and search_provider::searchstring.
Referenced by search_web_init().
|
static |
Read providers file.
Allocates storage of sufficient size for the providers file and reads the entire file in.
fname | The filename to read. |
providers_out | A pointer to place the result buffer in. |
providers_size_out | Size of buffer. |
Definition at line 73 of file searchweb.c.
References NSERROR_BAD_PARAMETER, NSERROR_BAD_SIZE, NSERROR_INVALID, NSERROR_NOMEM, NSERROR_NOT_FOUND, and NSERROR_OK.
Referenced by search_web_init().
nserror search_web_finalise | ( | void | ) |
Finalise the web search operations freeing all resources.
Definition at line 582 of file searchweb.c.
References search_web_ctx_s::default_ico_handle, hlcache_handle_release(), search_provider::ico_handle, search_provider::name, NSERROR_INIT_FAILED, NSERROR_OK, search_web_ctx_s::providers, search_web_ctx_s::providers_count, and search_web_ctx.
Referenced by netsurf_exit(), and nsbeos_scaffolding_dispatch_event().
obtain the current providers bitmap
obtain the icon representing the current web search provider
bitmap_out | recives the resulting bitmap which may be NULL |
Definition at line 370 of file searchweb.c.
References content_get_bitmap(), search_web_ctx_s::current, search_web_ctx_s::default_ico_handle, search_provider::ico_handle, NSERROR_INIT_FAILED, NSERROR_OK, search_web_ctx_s::providers, and search_web_ctx.
Referenced by make_toolbar_item_websearch().
|
static |
callback for hlcache icon fetch events.
Definition at line 284 of file searchweb.c.
References content_get_bitmap(), CONTENT_MSG_DONE, CONTENT_MSG_ERROR, hlcache_event::data, content_msg_data::errordata, content_msg_data::errormsg, guit, hlcache_handle_get_url(), hlcache_handle_release(), search_provider::ico, search_provider::ico_handle, search_provider::name, NSERROR_OK, NSLOG, nsurl_access(), gui_search_web_table::provider_update, netsurf_table::search_web, and hlcache_event::type.
Referenced by search_web_select_provider().
nserror search_web_init | ( | const char * | provider_fname | ) |
Initialise the web search operations.
provider_fname | Path to web search providers file. |
Definition at line 525 of file searchweb.c.
References CONTENT_IMAGE, default_ico_callback(), search_web_ctx_s::default_ico_handle, default_providers, default_search_icon_url, hlcache_handle_retrieve(), NSERROR_NOMEM, NSERROR_OK, nsurl_create(), nsurl_unref(), parse_providers(), search_web_ctx_s::providers, search_web_ctx_s::providers_count, read_providers(), and search_web_ctx.
Referenced by main(), nsbeos_scaffolding_dispatch_event(), and nsgtk_setup().
ssize_t search_web_iterate_providers | ( | ssize_t | iter, |
const char ** | name | ||
) |
Iterate the search providers, returning their names.
from | Index to start iteration from. Use -1 to begin iteration. Use the value returned from search_web_iterate_providers to continue an iteration. |
name | Pointer to fill in with the search provider name requested. |
* ssize_t iter = -1; * const char *name; * ... * iter = search_web_iterate_providers(iter, &name); * while(iter !=-1) { * do_something_with(name); * iter = search_web_iterate_providers(iter, &name); * } *
Definition at line 506 of file searchweb.c.
References search_provider::name, search_web_ctx_s::providers, search_web_ctx_s::providers_count, and search_web_ctx.
Referenced by ami_gui_opts_websearch(), nsgtk_preferences_comboSearch_changed(), and nsgtk_preferences_comboSearch_realize().
nserror search_web_omni | ( | const char * | term, |
enum search_web_omni_flags | flags, | ||
struct nsurl ** | url_out | ||
) |
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:
term | The search term. |
flags | Flags to control operation. |
url_out | The ourput url on success. |
Definition at line 318 of file searchweb.c.
References search_web_ctx_s::current, make_search_nsurl(), NSERROR_BAD_URL, NSERROR_INIT_FAILED, NSERROR_NOMEM, NSERROR_OK, nsoption_bool, nsurl_create(), search_web_ctx_s::providers, search_web_ctx, SEARCH_WEB_OMNI_SEARCHONLY, and SLEN.
Referenced by ami_gui_event(), nsbeos_scaffolding_dispatch_event(), nsgtk_completion_match_select(), ro_gui_dialog_openurl_apply(), ro_gui_window_launch_url(), url_entry_activate_cb(), and websearch_entry_activate_cb().
nserror search_web_select_provider | ( | const char * | selection | ) |
Change the currently selected web search provider.
selection | Name of the search provider to select or NULL to reselect the current provider |
Definition at line 397 of file searchweb.c.
References content_get_bitmap(), CONTENT_IMAGE, search_web_ctx_s::current, search_web_ctx_s::default_ico_handle, guit, hlcache_handle_retrieve(), search_provider::ico, search_provider::ico_handle, search_provider::name, NSERROR_INIT_FAILED, NSERROR_OK, nsurl_create(), nsurl_unref(), gui_search_web_table::provider_update, search_web_ctx_s::providers, search_web_ctx_s::providers_count, netsurf_table::search_web, search_web_ctx, and search_web_ico_callback().
Referenced by ami_gui_event(), ami_gui_opts_use(), gui_init2(), nsgtk_preferences_comboSearch_changed(), and nsgtk_setup().
|
static |
Definition at line 56 of file searchweb.c.
Referenced by search_web_init().
|
static |
Definition at line 58 of file searchweb.c.
Referenced by search_web_init().
|
static |