2024-03-28 18:02 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002402NetSurfBeOS-specificpublic2016-02-16 14:11
ReporterPulkoMandy 
Assigned ToVincent Sanders 
SeverityminorReproducibilityalways 
StatusclosedResolutionfixed 
Product Version3.3 
Target VersionFixed in Version3.4 
Summary0002402: [PATCH] Add search bar for Haiku
DescriptionThe Haiku port lacked a search bar and had only an address bar. This patch fixes it: https://gist.github.com/AdrianArroyoCalle/94dfd412645e0e5c449a
TagsNo tags attached.
Fixed in CI build #3271
Reported in CI build #
URL of problem page
Attached Files
  • patch file icon 0002-SearchEngines-for-Haiku.patch (2,857 bytes) 2015-12-27 09:29 -
    From 3b508be9f9990492f8ef30c2a83590624c8ceb7e Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Adri=C3=A1n=20Arroyo=20Calle?=
     <adrian.arroyocalle@gmail.com>
    Date: Thu, 24 Dec 2015 14:13:50 +0100
    Subject: [PATCH 2/3] SearchEngines for Haiku
    
    ---
     beos/res/SearchEngines | 20 ++++++++++++++++++++
     1 file changed, 20 insertions(+)
     create mode 100644 beos/res/SearchEngines
    
    diff --git a/beos/res/SearchEngines b/beos/res/SearchEngines
    new file mode 100644
    index 0000000..38e7795
    --- /dev/null
    +++ b/beos/res/SearchEngines
    @@ -0,0 +1,20 @@
    +Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|
    +Yahoo|search.yahoo.com|http://search.yahoo.com/search?p=%s|http://www.yahoo.com/favicon.ico|
    +Bing|www.bing.com|http://www.bing.com/search?q=%s|http://www.bing.com/favicon.ico|
    +Business.com|www.business.com|http://www.business.com/search/rslt_default.asp?query=%s|http://www.business.com/favicon.ico|
    +Omgili|www.omgili.com|http://www.omgili.com/AAAAA/%s.html|http://omgili.com/public/images/favicon.ico|
    +BBC News|search.bbc.co.uk|http://search.bbc.co.uk/search?q=%s&tab=ns|http://www.bbc.co.uk/favicon.ico|
    +Ubuntu Packages|packages.ubuntu.com|http://packages.ubuntu.com/search?keywords=%s|http://packages.ubuntu.com/favicon.ico|
    +Creative Commons|creativecommons.org|http://creativecommons.org/?s=%s|http://creativecommons.org/favicon.ico|fixme:favicon does not work as it is served as x-icon and is a png
    +Ask.com|www.ask.com|http://www.ask.com/web?q=%s|http://sp.uk.ask.com/sh/i/a14/favicon/favicon.ico|fixme:favicon is served as text/plain
    +Dictionary.com|dictionary.reference.com|http://dictionary.reference.com/browse/%s?jss=0|http://dictionary.reference.com/favicon.ico|
    +Youtube|www.youtube.com|http://www.youtube.com/results?search_query=%s|http://www.youtube.com/favicon.ico|
    +AOL|search.aol.com|http://search.aol.com/aol/search?query=%s|http://www.aol.com/favicon.ico|
    +Baidu|www.baidu.com|http://www.baidu.com/s?wd=%s|http://www.baidu.com/favicon.ico|
    +Amazon|www.amazon.com|http://www.amazon.com/s/ref=nb_ss_gw?field-keywords=%s|http://www.amazon.com/favicon.ico|
    +Ebay|shop.ebay.com|http://shop.ebay.com/items/%s|http://www.ebay.com/favicon.ico|
    +IMDB|www.imdb.com|http://www.imdb.com/find?q=%s|http://www.imdb.com/favicon.ico|
    +ESPN|search.espn.go.com|http://search.espn.go.com/%s/|http://www.espn.go.com/favicon.ico|
    +Wikipedia|en.wikipedia.org|http://en.wikipedia.org/w/index.php?title=Special%%3ASearch&search=%s|http://en.wikipedia.org/favicon.ico|
    +DuckDuckGo|www.duckduckgo.com|http://www.duckduckgo.com/html/?q=%s|http://www.duckduckgo.com/favicon.ico|fixme:Their ico upsets the current implementation
    +Seeks|www.seeks-project.info|https://www.seeks-project.info/search.php/search?q=%s|http://www.seeks-project.info/search.php/public/images/seek_icon_32x32_transparent.png|fixme:they have no icon
    -- 
    2.6.4
    
    
    patch file icon 0002-SearchEngines-for-Haiku.patch (2,857 bytes) 2015-12-27 09:29 +
  • patch file icon 0003-Cookie-Manager-for-Haiku.patch (14,756 bytes) 2015-12-27 09:29 -
    From 739784309d6bee1a86defe4701f0f9b22a3461c1 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Adri=C3=A1n=20Arroyo=20Calle?=
     <adrian.arroyocalle@gmail.com>
    Date: Thu, 24 Dec 2015 14:21:25 +0100
    Subject: [PATCH 3/3] Cookie Manager for Haiku
    
    ---
     beos/Makefile.target |   5 +-
     beos/cookies.cpp     | 416 +++++++++++++++++++++++++++++++++++++++++++++++++++
     beos/cookies.h       |  24 +++
     beos/scaffolding.cpp |  20 ++-
     4 files changed, 452 insertions(+), 13 deletions(-)
     create mode 100644 beos/cookies.cpp
     create mode 100644 beos/cookies.h
    
    diff --git a/beos/Makefile.target b/beos/Makefile.target
    index d762c52..88177cd 100644
    --- a/beos/Makefile.target
    +++ b/beos/Makefile.target
    @@ -57,7 +57,7 @@ else
         NETLDFLAGS := -lnetwork
     endif
     
    -LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS)
    +LDFLAGS += -lbe -ltranslation -ltracker -lcolumnlistview $(NETLDFLAGS)
     ifeq ($(CC_MAJOR),2)
         LDFLAGS += -lstdc++.r4
     else
    @@ -85,7 +85,8 @@ endif
     # ----------------------------------------------------------------------------
     
     # S_BEOS are sources purely for the BeOS build
    -S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
    +S_BEOS := about.cpp bitmap.cpp cookies.cpp \
    +	download.cpp fetch_rsrc.cpp filetype.cpp \
     	font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp		\
     	scaffolding.cpp search.cpp schedule.cpp throbber.cpp window.cpp
     S_BEOS := $(addprefix beos/,$(S_BEOS))
    diff --git a/beos/cookies.cpp b/beos/cookies.cpp
    new file mode 100644
    index 0000000..acd0ac1
    --- /dev/null
    +++ b/beos/cookies.cpp
    @@ -0,0 +1,416 @@
    +/*
    + * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
    + *
    + * 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/>.
    + */
    +
    +#define __STDBOOL_H__	1
    +#include <stdio.h>
    +#include <stdlib.h>
    +#include <string.h>
    +extern "C" {
    +#include "desktop/mouse.h"
    +#include "utils/log.h"
    +#include "desktop/cookie_manager.h"
    +#include "desktop/plotters.h"
    +#include "desktop/tree.h"
    +#include "desktop/textinput.h"
    +#include "content/urldb.h"
    +}
    +#include "beos/cookies.h"
    +
    +#include <Application.h>
    +#include <InterfaceKit.h>
    +#include <String.h>
    +#include <Button.h>
    +#include <Catalog.h>
    +#include <private/interface/ColumnListView.h>
    +#include <private/interface/ColumnTypes.h>
    +#include <GroupLayoutBuilder.h>
    +#include <NetworkCookieJar.h>
    +#include <OutlineListView.h>
    +#include <ScrollView.h>
    +#include <StringView.h>
    +
    +#include <vector>
    +
    +static std::vector<struct cookie_data*> cookieJar;
    +
    +class CookieWindow : public BWindow {
    +public:
    +								CookieWindow(BRect frame);
    +	virtual	void				MessageReceived(BMessage* message);
    +	virtual void				Show();
    +	virtual	bool				QuitRequested();
    +
    +private:
    +			void				_BuildDomainList();
    +			BStringItem*		_AddDomain(BString domain, bool fake);
    +			void				_ShowCookiesForDomain(BString domain);
    +			void				_DeleteCookies();
    +
    +private:
    +	BOutlineListView*			fDomains;
    +	BColumnListView*			fCookies;
    +	BStringView*				fHeaderView;
    +};
    +
    +enum {
    +	COOKIE_IMPORT = 'cimp',
    +	COOKIE_EXPORT = 'cexp',
    +	COOKIE_DELETE = 'cdel',
    +	COOKIE_REFRESH = 'rfsh',
    +
    +	DOMAIN_SELECTED = 'dmsl'
    +};
    +
    +
    +class CookieDateColumn: public BDateColumn
    +{
    +public:
    +	CookieDateColumn(const char* title, float width)
    +		:
    +		BDateColumn(title, width, width / 2, width * 2)
    +	{
    +	}
    +
    +	void DrawField(BField* field, BRect rect, BView* parent) {
    +		BDateField* dateField = (BDateField*)field;
    +		if (dateField->UnixTime() == -1) {
    +			DrawString("Session cookie", parent, rect);
    +		} else {
    +			BDateColumn::DrawField(field, rect, parent);
    +		}
    +	}
    +};
    +
    +
    +class CookieRow: public BRow
    +{
    +public:
    +	CookieRow(BColumnListView* list, struct cookie_data& cookie)
    +		:
    +		BRow(),
    +		fCookie(cookie)
    +	{
    +		list->AddRow(this);
    +		SetField(new BStringField(cookie.name), 0);
    +		SetField(new BStringField(cookie.path), 1);
    +		time_t expiration = cookie.expires;
    +		SetField(new BDateField(&expiration), 2);
    +		SetField(new BStringField(cookie.value), 3);
    +
    +		BString flags;
    +		if (cookie.secure)
    +			flags = "https ";
    +		if (cookie.http_only)
    +			flags = "http ";
    +
    +		SetField(new BStringField(flags.String()), 4);
    +	}
    +
    +public:
    +	struct cookie_data	fCookie;
    +};
    +
    +
    +class DomainItem: public BStringItem
    +{
    +public:
    +	DomainItem(BString text, bool empty)
    +		:
    +		BStringItem(text),
    +		fEmpty(empty)
    +	{
    +	}
    +
    +public:
    +	bool	fEmpty;
    +};
    +
    +
    +CookieWindow::CookieWindow(BRect frame)
    +	:
    +	BWindow(frame,"Cookie manager", B_TITLED_WINDOW,
    +		B_NORMAL_WINDOW_FEEL,
    +		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
    +{
    +	BGroupLayout* root = new BGroupLayout(B_HORIZONTAL, 0.0);
    +	SetLayout(root);
    +
    +	fDomains = new BOutlineListView("domain list");
    +	root->AddView(new BScrollView("scroll", fDomains, 0, false, true), 1);
    +
    +	fHeaderView = new BStringView("label","The cookie jar is empty!");
    +	fCookies = new BColumnListView("cookie list", B_WILL_DRAW, B_FANCY_BORDER,
    +		false);
    +
    +	float em = fCookies->StringWidth("M");
    +	float flagsLength = fCookies->StringWidth("Mhttps hostOnly" B_UTF8_ELLIPSIS);
    +
    +	fCookies->AddColumn(new BStringColumn("Name",
    +		20 * em, 10 * em, 50 * em, 0), 0);
    +	fCookies->AddColumn(new BStringColumn("Path",
    +		10 * em, 10 * em, 50 * em, 0), 1);
    +	fCookies->AddColumn(new CookieDateColumn("Expiration",
    +		fCookies->StringWidth("88/88/8888 88:88:88 AM")), 2);
    +	fCookies->AddColumn(new BStringColumn("Value",
    +		20 * em, 10 * em, 50 * em, 0), 3);
    +	fCookies->AddColumn(new BStringColumn("Flags",
    +		flagsLength, flagsLength, flagsLength, 0), 4);
    +
    +	root->AddItem(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
    +		.SetInsets(5, 5, 5, 5)
    +		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
    +			.Add(fHeaderView)
    +			.AddGlue()
    +		.End()
    +		.Add(fCookies)
    +		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
    +			.SetInsets(5, 5, 5, 5)
    +			.AddGlue()
    +			.Add(new BButton("delete", "Delete",
    +				new BMessage(COOKIE_DELETE))), 3);
    +
    +	fDomains->SetSelectionMessage(new BMessage(DOMAIN_SELECTED));
    +}
    +
    +
    +void
    +CookieWindow::MessageReceived(BMessage* message)
    +{
    +	switch(message->what) {
    +		case DOMAIN_SELECTED:
    +		{
    +			int32 index = message->FindInt32("index");
    +			BStringItem* item = (BStringItem*)fDomains->ItemAt(index);
    +			if (item != NULL) {
    +				BString domain = item->Text();
    +				_ShowCookiesForDomain(domain);
    +			}
    +			return;
    +		}
    +
    +		case COOKIE_REFRESH:
    +			_BuildDomainList();
    +			return;
    +
    +		case COOKIE_DELETE:
    +			_DeleteCookies();
    +			return;
    +	}
    +	BWindow::MessageReceived(message);
    +}
    +
    +
    +void
    +CookieWindow::Show()
    +{
    +	BWindow::Show();
    +	if (IsHidden())
    +		return;
    +
    +	PostMessage(COOKIE_REFRESH);
    +}
    +
    +
    +bool
    +CookieWindow::QuitRequested()
    +{
    +	if (!IsHidden())
    +		Hide();
    +	cookieJar.clear();
    +	return false;
    +}
    +
    +
    +void
    +CookieWindow::_BuildDomainList()
    +{
    +	// Empty the domain list (TODO should we do this when hiding instead?)
    +	for (int i = fDomains->FullListCountItems() - 1; i >= 1; i--) {
    +		delete fDomains->FullListItemAt(i);
    +	}
    +	fDomains->MakeEmpty();
    +
    +	// BOutlineListView does not handle parent = NULL in many methods, so let's
    +	// make sure everything always has a parent.
    +	DomainItem* rootItem = new DomainItem("", true);
    +	fDomains->AddItem(rootItem);
    +
    +	// Populate the domain list - TODO USE STL VECTOR
    +
    +
    +	for(std::vector<struct cookie_data*>::iterator it = cookieJar.begin(); it != cookieJar.end(); ++it) {
    +		_AddDomain((*it)->domain, false);
    +	}
    +
    +	int i = 1;
    +	while (i < fDomains->FullListCountItems())
    +	{
    +		DomainItem* item = (DomainItem*)fDomains->FullListItemAt(i);
    +		// Detach items from the fake root
    +		item->SetOutlineLevel(item->OutlineLevel() - 1);
    +		i++;
    +	}
    +	fDomains->RemoveItem(rootItem);
    +	delete rootItem;
    +
    +	i = 0;
    +	int firstNotEmpty = i;
    +	// Collapse empty items to keep the list short
    +	while (i < fDomains->FullListCountItems())
    +	{
    +		DomainItem* item = (DomainItem*)fDomains->FullListItemAt(i);
    +		if (item->fEmpty == true) {
    +			if (fDomains->CountItemsUnder(item, true) == 1) {
    +				// The item has no cookies, and only a single child. We can
    +				// remove it and move its child one level up in the tree.
    +
    +				int count = fDomains->CountItemsUnder(item, false);
    +				int index = fDomains->FullListIndexOf(item) + 1;
    +				for (int j = 0; j < count; j++) {
    +					BListItem* child = fDomains->FullListItemAt(index + j);
    +					child->SetOutlineLevel(child->OutlineLevel() - 1);
    +				}
    +
    +				fDomains->RemoveItem(item);
    +				delete item;
    +
    +				// The moved child is at the same index the removed item was.
    +				// We continue the loop without incrementing i to process it.
    +				continue;
    +			} else {
    +				// The item has no cookies, but has multiple children. Mark it
    +				// as disabled so it is not selectable.
    +				item->SetEnabled(false);
    +				if (i == firstNotEmpty)
    +					firstNotEmpty++;
    +			}
    +		}
    +
    +		i++;
    +	}
    +
    +	fDomains->Select(firstNotEmpty);
    +}
    +
    +
    +BStringItem*
    +CookieWindow::_AddDomain(BString domain, bool fake)
    +{
    +	BStringItem* parent = NULL;
    +	int firstDot = domain.FindFirst('.');
    +	if (firstDot >= 0) {
    +		BString parentDomain(domain);
    +		parentDomain.Remove(0, firstDot + 1);
    +		parent = _AddDomain(parentDomain, true);
    +	} else {
    +		parent = (BStringItem*)fDomains->FullListItemAt(0);
    +	}
    +
    +	BListItem* existing;
    +	int i = 0;
    +	// check that we aren't already there
    +	while ((existing = fDomains->ItemUnderAt(parent, true, i++)) != NULL) {
    +		DomainItem* stringItem = (DomainItem*)existing;
    +		if (stringItem->Text() == domain) {
    +			if (fake == false)
    +				stringItem->fEmpty = false;
    +			return stringItem;
    +		}
    +	}
    +
    +	// Insert the new item, keeping the list alphabetically sorted
    +	BStringItem* domainItem = new DomainItem(domain, fake);
    +	domainItem->SetOutlineLevel(parent->OutlineLevel() + 1);
    +	BStringItem* sibling = NULL;
    +	int siblingCount = fDomains->CountItemsUnder(parent, true);
    +	for (i = 0; i < siblingCount; i++) {
    +		sibling = (BStringItem*)fDomains->ItemUnderAt(parent, true, i);
    +		if (strcmp(sibling->Text(), domainItem->Text()) > 0) {
    +			fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling));
    +			return domainItem;
    +		}
    +	}
    +
    +	if (sibling) {
    +		// There were siblings, but all smaller than what we try to insert.
    +		// Insert after the last one (and its subitems)
    +		fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling)
    +			+ fDomains->CountItemsUnder(sibling, false) + 1);
    +	} else {
    +		// There were no siblings, insert right after the parent
    +		fDomains->AddItem(domainItem, fDomains->FullListIndexOf(parent) + 1);
    +	}
    +
    +	return domainItem;
    +}
    +
    +
    +void
    +CookieWindow::_ShowCookiesForDomain(BString domain)
    +{
    +	BString label;
    +	label.SetToFormat("Cookies for %s", domain.String());
    +	fHeaderView->SetText(label);
    +
    +	// Empty the cookie list
    +	fCookies->Clear();
    +
    +	// Populate the domain list
    +
    +	for(std::vector<struct cookie_data*>::iterator it = cookieJar.begin(); it != cookieJar.end(); ++it) {
    +		if((*it)->domain == domain) {
    +			new CookieRow(fCookies,**it);
    +		}
    +	}
    +}
    +
    +static bool nsbeos_cookie_parser(const struct cookie_data* data)
    +{
    +	cookieJar.push_back((struct cookie_data*)data);
    +	return true;
    +}
    +
    +void
    +CookieWindow::_DeleteCookies()
    +{
    +	// TODO shall we handle multiple selection here?
    +	CookieRow* row = (CookieRow*)fCookies->CurrentSelection();
    +	if (row == NULL) {
    +		// TODO see if a domain is selected in the domain list, and delete all
    +		// cookies for that domain
    +		return;
    +	}
    +
    +	fCookies->RemoveRow(row);
    +
    +	urldb_delete_cookie(row->fCookie.domain, row->fCookie.path, row->fCookie.name);
    +	cookieJar.clear();
    +	urldb_iterate_cookies(&nsbeos_cookie_parser);
    +
    +	delete row;
    +}
    +
    +/**
    + * Creates the Cookie Manager
    + */
    +void nsbeos_cookies_init(void)
    +{
    +	CookieWindow* cookWin=new CookieWindow(BRect(100,100,400,400));
    +	cookWin->Show();
    +	urldb_iterate_cookies(&nsbeos_cookie_parser);
    +}
    diff --git a/beos/cookies.h b/beos/cookies.h
    new file mode 100644
    index 0000000..977ccd2
    --- /dev/null
    +++ b/beos/cookies.h
    @@ -0,0 +1,24 @@
    +/*
    + * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
    + *
    + * 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/>.
    + */
    +
    +#ifndef __BEOS_COOKIES_H__
    +#define __BEOS_COOKIES_H__
    +
    +void nsbeos_cookies_init();
    +
    +#endif /* __BEOS_ABOUT_H__ */
    diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
    index 392bfde..3e14973 100644
    --- a/beos/scaffolding.cpp
    +++ b/beos/scaffolding.cpp
    @@ -81,6 +81,7 @@ extern "C" {
     #include "beos/window.h"
     #include "beos/schedule.h"
     //#include "beos/download.h"
    +#include "beos/cookies.h"
     
     #define TOOLBAR_HEIGHT 32
     #define DRAGGER_WIDTH 8
    @@ -1191,9 +1192,15 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
     		case HOTLIST_SHOW:
     			break;
     		case COOKIES_SHOW:
    +		{
    +			nsbeos_cookie_init();
     			break;
    +		}
     		case COOKIES_DELETE:
    +		{
    +			nsbeos_cookie_init();
     			break;
    +		}
     		case BROWSER_PAGE:
     			break;
     		case BROWSER_PAGE_INFO:
    @@ -1976,18 +1983,9 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
     		item = make_menu_item("HistGlobal", message);
     		submenu->AddItem(item);
     
    -
    -		submenu = new BMenu(messages_get("Cookies"));
    -		menu->AddItem(submenu);
    -
     		message = new BMessage(COOKIES_SHOW);
    -		item = make_menu_item("ShowCookies", message);
    -		submenu->AddItem(item);
    -
    -		message = new BMessage(COOKIES_DELETE);
    -		item = make_menu_item("DeleteCookies", message);
    -		submenu->AddItem(item);
    -
    +		item = make_menu_item("Cookie manager", message, true);
    +		menu->AddItem(item);
     
     		message = new BMessage(BROWSER_FIND_TEXT);
     		item = make_menu_item("FindText", message);
    -- 
    2.6.4
    
    
    patch file icon 0003-Cookie-Manager-for-Haiku.patch (14,756 bytes) 2015-12-27 09:29 +
  • patch file icon 0001-WebSearch-bar-for-Haiku.patch (6,626 bytes) 2015-12-27 09:30 -
    From b185fc84df4ea90363fa49540ba400cf5cba0052 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Adri=C3=A1n=20Arroyo=20Calle?=
     <adrian.arroyocalle@gmail.com>
    Date: Thu, 24 Dec 2015 14:12:42 +0100
    Subject: [PATCH 1/3] WebSearch bar for Haiku
    
    ---
     beos/Makefile.target |  3 ++-
     beos/gui.cpp         |  4 +++-
     beos/gui.h           |  2 ++
     beos/scaffolding.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
     4 files changed, 65 insertions(+), 2 deletions(-)
    
    diff --git a/beos/Makefile.target b/beos/Makefile.target
    index 8759d08..d762c52 100644
    --- a/beos/Makefile.target
    +++ b/beos/Makefile.target
    @@ -99,7 +99,7 @@ RDEF_IMP_BEOS := $(addprefix $(OBJROOT)/,$(subst /,_,$(RDEF_IMP_BEOS)))
     RDEP_BEOS := \
     	adblock.css beosdefault.css default.css internal.css quirks.css	\
     	netsurf.png favicon.png ca-bundle.txt \
    -	credits.html licence.html welcome.html maps.html
    +	credits.html licence.html welcome.html maps.html SearchEngines
     RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS))			\
     	$(wildcard beos/res/icons/*.png)						\
     	$(wildcard beos/res/??/*)								\
    @@ -147,6 +147,7 @@ install-beos:
     	@cp -vRL beos/res/default.css $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
     	@cp -vRL beos/res/beosdefault.css $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
     	@cp -vRL gtk/res/license $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
    +	@cp -vRL beos/res/SearchEngines $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
     #	@cp -vRL beos/res/throbber/*.png $(DESTDIR)$(NETSURF_BEOS_RESOURCES)throbber
     
     # ----------------------------------------------------------------------------
    diff --git a/beos/gui.cpp b/beos/gui.cpp
    index cfd026b..1e653a0 100644
    --- a/beos/gui.cpp
    +++ b/beos/gui.cpp
    @@ -1,4 +1,5 @@
     /*
    + * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
      * Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
      * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
      *
    @@ -137,6 +138,7 @@ NSBrowserApplication::MessageReceived(BMessage *message)
     		case 'home':
     		case 'urlc':
     		case 'urle':
    +		case 'sear':
     		case 'menu':
     		// NetPositive messages
     		case B_NETPOSITIVE_OPEN_URL:
    @@ -254,7 +256,7 @@ image_id nsbeos_find_app_path(char *path)
      * \param  def      default to return if file not found
      * \return path to resource.
      */
    -static char *find_resource(char *buf, const char *filename, const char *def)
    +char *find_resource(char *buf, const char *filename, const char *def)
     {
     	const char *cdir = NULL;
     	status_t err;
    diff --git a/beos/gui.h b/beos/gui.h
    index 215cda8..b9f560e 100644
    --- a/beos/gui.h
    +++ b/beos/gui.h
    @@ -1,4 +1,5 @@
     /*
    + * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
      * Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
      * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
      *
    @@ -65,6 +66,7 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
     
     void nsbeos_gui_view_source(struct hlcache_handle *content);
     image_id nsbeos_find_app_path(char *path);
    +char *find_resource(char *buf, const char *filename, const char *def);
     
     void nsbeos_update_system_ui_colors(void);
     
    diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
    index 2c5d4e9..392bfde 100644
    --- a/beos/scaffolding.cpp
    +++ b/beos/scaffolding.cpp
    @@ -1,4 +1,5 @@
     /*
    + * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
      * Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
      * Copyright 2006 Rob Kendrick <rjek@rjek.com>
      *
    @@ -56,6 +57,8 @@ extern "C" {
     #include "desktop/browser.h"
     #include "desktop/netsurf.h"
     #include "desktop/version.h"
    +#include "desktop/searchweb.h"
    +#include "desktop/search.h"
     #include "desktop/plotters.h"
     #include "utils/nsoption.h"
     #include "desktop/textinput.h"
    @@ -111,6 +114,7 @@ struct beos_scaffolding {
     	BControl		*home_button;
     
     	NSIconTextControl	*url_bar;
    +	NSIconTextControl	*search_bar;
     	//BMenuField	*url_bar_completion;
     
     	NSThrobber		*throbber;
    @@ -478,6 +482,7 @@ NSBaseView::MessageReceived(BMessage *message)
     		case 'home':
     		case 'urlc':
     		case 'urle':
    +		case 'sear':
     		case 'menu':
     		case NO_ACTION:
     		case HELP_OPEN_CONTENTS:
    @@ -653,6 +658,7 @@ NSBaseView::AllAttached()
     	g->home_button->SetTarget(this);
     
     	g->url_bar->SetTarget(this);
    +	g->search_bar->SetTarget(this);
     
     	rgb_color c = ui_color(B_PANEL_BACKGROUND_COLOR);
     	SetViewColor(c);
    @@ -669,6 +675,7 @@ NSBaseView::AllAttached()
     	g->home_button->SetViewColor(c);
     	g->home_button->SetLowColor(c);
     	g->url_bar->SetViewColor(c);
    +	g->search_bar->SetViewColor(c);
     	g->throbber->SetViewColor(c);
     	g->scroll_view->SetViewColor(c);
     
    @@ -806,6 +813,7 @@ static void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
     	g->reload_button->SetViewColor(c);
     	g->home_button->SetViewColor(c);
     	g->url_bar->SetViewColor(c);
    +	g->search_bar->SetViewColor(c);
     	g->throbber->SetViewColor(c);
     	g->scroll_view->SetViewColor(c);
     
    @@ -1073,6 +1081,41 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
     			//nsbeos_completion_update(text.String());
     			break;
     		}
    +		case 'sear':
    +		{
    +			nserror ret;
    +			nsurl* url;
    +			BString text;
    +			if (!scaffold->search_bar->LockLooper())
    +				break;
    +			text = scaffold->search_bar->Text();
    +			scaffold->search_bar->UnlockLooper();
    +			
    +			char t[PATH_MAX];
    +			find_resource(t,"SearchEngines","./beos/res/SearchEngines");
    +			
    +			search_web_init();
    +			
    +			ret = search_web_omni(text.String(),SEARCH_WEB_OMNI_SEARCHONLY
    +				,&url);
    +			if (ret == NSERROR_OK) {
    +				ret = browser_window_create(
    +					(browser_window_create_flags)(BW_CREATE_HISTORY | BW_CREATE_TAB),
    +					url,
    +					NULL,
    +					bw,
    +					NULL);
    +				nsurl_unref(url);
    +			}
    +			
    +			if (ret != NSERROR_OK) {
    +				warn_user(messages_get_errorcode(ret), 0);
    +			}
    +			
    +			search_web_finalise();
    +			
    +			break;
    +		}
     /*
     		case 'menu':
     		{
    @@ -2113,6 +2156,21 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
     	g->url_bar->TextView()->SetTextRect(rect);
     	g->tool_bar->AddChild(g->url_bar);
     
    +	// search bar
    +	
    +	rect = g->tool_bar->Bounds();
    +	rect.left += TOOLBAR_HEIGHT * nButtons + (g->url_bar->Bounds().right - g->url_bar->Bounds().left);
    +	rect.right -= TOOLBAR_HEIGHT * 1;
    +	rect.InsetBy(5,5);
    +	message = new BMessage('sear');
    +	message->AddPointer("scaffolding", g);
    +	g->search_bar = new NSIconTextControl(rect,"search_bar","","Search...",message,
    +		B_FOLLOW_RIGHT);
    +	g->search_bar->SetDivider(0);
    +	rect = g->search_bar->TextView()->TextRect();
    +	rect.left += 0;
    +	g->search_bar->TextView()->TextRect();
    +	g->tool_bar->AddChild(g->search_bar);
     
     	// throbber
     	rect.Set(0, 0, 24, 24);
    -- 
    2.6.4
    
    
    patch file icon 0001-WebSearch-bar-for-Haiku.patch (6,626 bytes) 2015-12-27 09:30 +

-Relationships
+Relationships

-Notes
Vincent Sanders

~0001157

Vincent Sanders (administrator)

applied patch
Vincent Sanders

~0001243

Vincent Sanders (administrator)

Confirmed fixed in 3.4 release
+Notes

-Issue History
Date Modified Username Field Change
2015-12-19 21:17 PulkoMandy New Issue
2015-12-27 09:29 PulkoMandy File Added: 0002-SearchEngines-for-Haiku.patch
2015-12-27 09:29 PulkoMandy File Added: 0003-Cookie-Manager-for-Haiku.patch
2015-12-27 09:30 PulkoMandy File Added: 0001-WebSearch-bar-for-Haiku.patch
2016-01-19 14:11 Vincent Sanders Fixed in CI build # => 3271
2016-01-19 14:11 Vincent Sanders Note Added: 0001157
2016-01-19 14:11 Vincent Sanders Assigned To => Vincent Sanders
2016-01-19 14:11 Vincent Sanders Status new => resolved
2016-01-19 14:11 Vincent Sanders Resolution open => fixed
2016-01-19 14:11 Vincent Sanders Fixed in Version => 3.4
2016-02-16 14:11 Vincent Sanders Note Added: 0001243
2016-02-16 14:11 Vincent Sanders Status resolved => closed
+Issue History