SUMMARY="A Bittorrent client"
DESCRIPTION="The qBittorrent project aims to provide an open-source software \
alternative to µTorrent for decentralized peer-to-peer file sharing.

Some of qBittorrent's main features:

* No Ads
* Well-integrated and extensible search engine
* Many Bittorrent extensions supported (Magnet links, DHT, PEX, LSD, Private \
torrents, encrypted connections
* Remote control through Web user interface, written with AJAX
* Sequential downloading (download in order)
* Bandwidth scheduler
* Torrent creation tool
* IP Filtering (eMule & PeerGuardian format compatible)
* UPnP / NAT-PMP port forwarding support

qBittorrent is based on the Qt toolkit and libtorrent-rasterbar library."
HOMEPAGE="https://www.qbittorrent.org/"
COPYRIGHT="2006-2020 The qBittorrent project"
LICENSE="MIT"
REVISION="3"
SOURCE_URI="https://github.com/qbittorrent/qBittorrent/archive/release-$portVersion.tar.gz"
CHECKSUM_SHA256="4428ed710cfbcc48e75c4cdb014b803ea3f67311f55f4cba0d148987986bd6c8"
SOURCE_DIR="qBittorrent-release-$portVersion"
PATCHES="qbittorrent-$portVersion.patchset"
ADDITIONAL_FILES="qbittorrent.rdef.in"

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

PROVIDES="
	qbittorrent$secondaryArchSuffix = $portVersion
	app:qBittorrent = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libtorrent_rasterbar$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libexecinfo$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtorrent_rasterbar$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:cut
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix
	"

BUILD()
{
	bootstrap.sh
	BOOST_CPPFLAGS="-I/system/$relativeHeadersDir" runConfigure \
		./configure --with-boost-libdir=/system/$relativeLibDir \
		--disable-qt-dbus
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $appsDir/qBittorrent/translations
	cp dist/qt-translations/*.qm $appsDir/qBittorrent/translations
	mv $prefix/bin/qbittorrent $appsDir/qBittorrent/qBittorrent
	rm -r $prefix/{bin,data,documentation}
	strip $appsDir/qBittorrent/qBittorrent

	APP_SIGNATURE="application/x-vnd.qt5-qbittorrent"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	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/qbittorrent.rdef.in > qbittorrent.rdef

	addResourcesToBinaries qbittorrent.rdef $appsDir/qBittorrent/qBittorrent
	addAppDeskbarSymlink $appsDir/qBittorrent/qBittorrent
}
