summaryrefslogtreecommitdiff
path: root/desktop/searchweb.c
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/searchweb.c')
-rw-r--r--desktop/searchweb.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index c07cac9d5..361860190 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -17,11 +17,12 @@
*/
/**
- * \file desktop/searchweb.c
+ * \file
* \brief core web search facilities implementation.
*/
#include <stdlib.h>
+#include <string.h>
#include "utils/utils.h"
#include "utils/log.h"
@@ -52,7 +53,7 @@ static struct search_web_ctx_s {
} search_web_ctx;
-static const char *default_providers = "Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|\n";
+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";
@@ -298,10 +299,8 @@ search_web_ico_callback(hlcache_handle *ico,
case CONTENT_MSG_ERROR:
NSLOG(netsurf, INFO, "icon %s error: %s",
nsurl_access(hlcache_handle_get_url(ico)),
- event->data.error);
- /* fall through */
+ event->data.errordata.errormsg);
- case CONTENT_MSG_ERRORCODE:
hlcache_handle_release(ico);
/* clear reference to released handle */
provider->ico_handle = NULL;
@@ -334,11 +333,11 @@ search_web_omni(const char *term,
}
/* try with adding default scheme */
- eterm = malloc(strlen(term) + SLEN("http://") + 1);
+ eterm = malloc(strlen(term) + SLEN("https://") + 1);
if (eterm == NULL) {
return NSERROR_NOMEM;
}
- sprintf(eterm, "http://%s", term);
+ sprintf(eterm, "https://%s", term);
ret = nsurl_create(eterm, &url);
free(eterm);
if (ret == NSERROR_OK) {
@@ -368,6 +367,33 @@ search_web_omni(const char *term,
}
/* exported interface documented in desktop/searchweb.h */
+nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out)
+{
+ struct search_provider *provider;
+ struct bitmap *ico_bitmap = NULL;
+
+ /* must be initialised */
+ if (search_web_ctx.providers == NULL) {
+ return NSERROR_INIT_FAILED;
+ }
+
+ provider = &search_web_ctx.providers[search_web_ctx.current];
+
+ /* set the icon now (if we can) at least to the default */
+ if (provider->ico_handle != NULL) {
+ ico_bitmap = content_get_bitmap(provider->ico_handle);
+ }
+ if ((ico_bitmap == NULL) &&
+ (search_web_ctx.default_ico_handle != NULL)) {
+ ico_bitmap = content_get_bitmap(search_web_ctx.default_ico_handle);
+ }
+
+ *bitmap_out = ico_bitmap;
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in desktop/searchweb.h */
nserror search_web_select_provider(int selection)
{
struct search_provider *provider;
@@ -458,10 +484,8 @@ default_ico_callback(hlcache_handle *ico,
case CONTENT_MSG_ERROR:
NSLOG(netsurf, INFO, "icon %s error: %s",
nsurl_access(hlcache_handle_get_url(ico)),
- event->data.error);
- /* fall through */
+ event->data.errordata.errormsg);
- case CONTENT_MSG_ERRORCODE:
hlcache_handle_release(ico);
/* clear reference to released handle */
ctx->default_ico_handle = NULL;
@@ -524,10 +548,14 @@ nserror search_web_init(const char *provider_fname)
}
/* get default search icon */
- ret = hlcache_handle_retrieve(icon_nsurl, 0, NULL, NULL,
+ ret = hlcache_handle_retrieve(icon_nsurl,
+ 0,
+ NULL,
+ NULL,
default_ico_callback,
&search_web_ctx,
- NULL, CONTENT_IMAGE,
+ NULL,
+ CONTENT_IMAGE,
&search_web_ctx.default_ico_handle);
nsurl_unref(icon_nsurl);
if (ret != NSERROR_OK) {