SUMMARY="Network transparent access to files and data"
DESCRIPTION="This framework implements almost all the file management \
functions you will ever need. In fact, the KDE file manager (Dolphin) and the \
KDE file dialog also uses this to provide its network-enabled file management.

It supports accessing files locally as well as via HTTP and FTP out of the \
box and can be extended by plugins to support other protocols as well. \
There is a variety of plugins available, e.g. to support access via SSH.

The framework can also be used to bridge a native protocol to a file-based \
interface. This makes the data accessible in all applications using the KDE \
file dialog or any other KIO enabled infrastructure."
HOMEPAGE="https://github.com/KDE/kio/"
COPYRIGHT="2010-2021 KDE Organisation"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="https://github.com/KDE/kio/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="5fd50e508d621f82710600fc3315fd95fa9e3e64378267b91194bda122c39cc0"
PATCHES="kio-$portVersion.patchset"

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

GLOBAL_WRITABLE_FILES="
	settings/xdg/accept-languages.codes keep-old
	settings/xdg/kshorturifilterrc keep-old
	"

PROVIDES="
	kio$secondaryArchSuffix = $portVersion
	cmd:kcookiejar5$secondaryArchSuffix = $portVersion
	cmd:ktelnetservice5$secondaryArchSuffix = $portVersion
	cmd:ktrash5$secondaryArchSuffix = $portVersion
	cmd:protocoltojson$secondaryArchSuffix = $portVersion
	lib:libKF5KIOCore$secondaryArchSuffix = $portVersion compat >= 5
	lib:libKF5KIOFileWidgets$secondaryArchSuffix = $portVersion compat >= 5
	lib:libKF5KIOGui$secondaryArchSuffix = $portVersion compat >= 5
	lib:libKF5KIONTLM$secondaryArchSuffix = $portVersion compat >= 5
	lib:libKF5KIOWidgets$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libKF5Archive$secondaryArchSuffix
	lib:libKF5Auth$secondaryArchSuffix
	lib:libKF5Bookmarks$secondaryArchSuffix
	lib:libKF5Codecs$secondaryArchSuffix
	lib:libKF5Completion$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5ConfigGui$secondaryArchSuffix
	lib:libKF5ConfigWidgets$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5Crash$secondaryArchSuffix
	lib:libKF5DBusAddons$secondaryArchSuffix
	lib:libKF5GuiAddons$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libKF5IconThemes$secondaryArchSuffix
	lib:libKF5ItemViews$secondaryArchSuffix
	lib:libKF5JobWidgets$secondaryArchSuffix
	lib:libKF5Service$secondaryArchSuffix
	lib:libKF5Solid$secondaryArchSuffix
	lib:libKF5SonnetUi$secondaryArchSuffix
	lib:libKF5TextWidgets$secondaryArchSuffix
	lib:libKF5WidgetsAddons$secondaryArchSuffix
	lib:libKF5WindowSystem$secondaryArchSuffix
	lib:libKF5XmlGui$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	"

PROVIDES_devel="
	kio${secondaryArchSuffix}_devel = $portVersion
	devel:libKF5KIOCore$secondaryArchSuffix = $portVersion compat >= 5
	devel:libKF5KIOFileWidgets$secondaryArchSuffix = $portVersion compat >= 5
	devel:libKF5KIOGui$secondaryArchSuffix = $portVersion compat >= 5
	devel:libKF5KIONTLM$secondaryArchSuffix = $portVersion compat >= 5
	devel:libKF5KIOWidgets$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES_devel="
	kio$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix >= $portVersion
#	devel:libacl$secondaryArchSuffix
	devel:libKF5Archive$secondaryArchSuffix == $portVersion
	devel:libKF5Auth$secondaryArchSuffix == $portVersion
	devel:libKF5Bookmarks$secondaryArchSuffix == $portVersion
	devel:libKF5Codecs$secondaryArchSuffix == $portVersion
	devel:libKF5Completion$secondaryArchSuffix == $portVersion
	devel:libKF5ConfigCore$secondaryArchSuffix == $portVersion
	devel:libKF5ConfigGui$secondaryArchSuffix == $portVersion
	devel:libKF5ConfigWidgets$secondaryArchSuffix == $portVersion
	devel:libKF5CoreAddons$secondaryArchSuffix == $portVersion
	devel:libKF5Crash$secondaryArchSuffix == $portVersion
	devel:libKF5DBusAddons$secondaryArchSuffix == $portVersion
	devel:libKF5GuiAddons$secondaryArchSuffix == $portVersion
#	devel:libKF5DocTools$secondaryArchSuffix == $portVersion
	devel:libKF5I18n$secondaryArchSuffix == $portVersion
	devel:libKF5IconThemes$secondaryArchSuffix == $portVersion
	devel:libKF5ItemViews$secondaryArchSuffix == $portVersion
	devel:libKF5JobWidgets$secondaryArchSuffix == $portVersion
	devel:libKF5Notifications$secondaryArchSuffix == $portVersion
	devel:libKF5Service$secondaryArchSuffix == $portVersion
	devel:libKF5Solid$secondaryArchSuffix == $portVersion
	devel:libkf5sonnetcore$secondaryArchSuffix == $portVersion
	devel:libKF5TextWidgets$secondaryArchSuffix == $portVersion
	devel:libKF5Wallet$secondaryArchSuffix == $portVersion
	devel:libKF5WidgetsAddons$secondaryArchSuffix == $portVersion
	devel:libKF5WindowSystem$secondaryArchSuffix == $portVersion
	devel:libKF5XmlGui$secondaryArchSuffix == $portVersion
	devel:libQt5Concurrent$secondaryArchSuffix >= 5.7
	devel:libQt5Core$secondaryArchSuffix >= 5.7
	devel:libQt5DBus$secondaryArchSuffix >= 5.7
	devel:libQt5Gui$secondaryArchSuffix >= 5.7
	devel:libQt5Network$secondaryArchSuffix >= 5.7
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:python2
	"

TEST_REQUIRES="
	qthaikuplugins$secondaryArchSuffix #it opens windows during the tests, maybe we don't want that on the buildbots.
	"

BUILD()
{
	mkdir -p build
	cd build

	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DKDE_INSTALL_PLUGINDIR=$addOnsDir/Qt5 \
		-DKAUTH_HELPER_INSTALL_DIR:PATH=$addOnsDir/Qt5/kauth/helper \
		-DECM_MKSPECS_INSTALL_DIR=$dataDir/Qt5/mkspecs \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DBUILD_TESTING=ON
	make $jobArgs
}

INSTALL()
{
	# disable docs generation until libxml package is fixed
	sed -i s/add/#add/g docs/CMakeLists.txt
	sed -i s/kdoctools/#kdoctool/g CMakeLists.txt

	cd build
	make $jobArgs install

	prepareInstalledDevelLibs \
		libKF5KIOCore \
		libKF5KIOFileWidgets \
		libKF5KIOGui \
		libKF5KIONTLM \
		libKF5KIOWidgets

	packageEntries devel \
		$libDir/cmake \
		$dataDir/Qt5/mkspecs \
		$developDir
}

TEST()
{
	export LIBRARY_PATH="$sourceDir/build/bin${LIBRARY_PATH:+:$LIBRARY_PATH}"
	cd build
	make test
}
