SUMMARY="An open source client for Evernote"
DESCRIPTION="Evernote is a suite of software and services, designed for \
notetaking and archiving.
A 'note' can be a piece of formatted text, a full webpage or webpage excerpt, \
a photograph, a voice memo, or a handwritten 'ink' note. Notes can also have \
file attachments. Notes can be sorted into folders, then tagged, annotated, \
edited, given comments, searched, and exported as part of a notebook.

The application currently support:

* Synchronization with Evernote servers
* Local data caching
* Embbeded PDF documents preview with poppler
* Note printing and export to PDF, html or text file"
HOMEPAGE="https://github.com/Vytax/hippo/"
COPYRIGHT="2015-2018 Vytax"
LICENSE="GNU GPL v2"
REVISION="7"
srcGitRev="b62e1530f5c87611918168eef1f2071aed0c7e95"
SOURCE_URI="https://github.com/Vytax/hippo/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="ba3829daed1ed0b8f8a5e32adbe601311ca0ee3d9b596e7bc47f519d63a9c521"
SOURCE_DIR="hippo-$srcGitRev"
srcGitRev_2="866da331087c62dc4ff413535379ee5c6c763156"
SOURCE_URI_2="https://github.com/Vytax/CuteLogger/archive/$srcGitRev_2.tar.gz"
CHECKSUM_SHA256_2="d3ddcad99e060fd3bb395f26f0df7b1c77d88c3f2de3ecdba1d43734fba48d2b"
SOURCE_DIR_2="CuteLogger-$srcGitRev_2"
ADDITIONAL_FILES="hippo.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	hippo$secondaryArchSuffix = $portVersion
	app:Hippo$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGl$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libpoppler$secondaryArchSuffix
	lib:libpoppler_qt5$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGl$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libpoppler$secondaryArchSuffix
	devel:libpoppler_qt5$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	rm -rf $sourceDir/3rdparty/Cutelogger
	ln -s $sourceDir2 $sourceDir/3rdparty/Cutelogger

	sed -i "s|/usr/include/poppler/qt5|/system/$relativeIncludeDir/poppler/qt5|" $sourceDir/hippo.pro
	sed -i "s|-lhunspell|-lhunspell-1.7|" $sourceDir/3rdparty/spellcheck.pri
	sed -i "/QtWebKit/d" $sourceDir/mainwindow.ui

	qmake .
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir
	cp hippo "$appsDir/Hippo Notes"

	local APP_SIGNATURE="application/x-vnd.hipponotes"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2 | cut -d~ -f1`"
	local MINOR="0"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/hippo.rdef.in > hippo.rdef

	addResourcesToBinaries hippo.rdef \
		"$appsDir/Hippo Notes"

	addAppDeskbarSymlink "$appsDir/Hippo Notes"
}
