# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit desktop xdg-utils

DESCRIPTION="A client software for quality voice communication via the internet"
HOMEPAGE="https://www.teamspeak.com/"
SRC_URI="https://files.teamspeak-services.com/pre_releases/client/${PV/_/-}/teamspeak-client.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}"

LICENSE="teamspeak6 || ( GPL-2 GPL-3 LGPL-3 )"
SLOT="6"
KEYWORDS="-* ~amd64"

RDEPEND="
    sys-libs/glibc sys-devel/gcc
    dev-libs/libffi app-crypt/argon2 sys-libs/zlib dev-libs/expat dev-libs/gmp app-arch/bzip2 dev-libs/libunistring dev-libs/libtasn1 sys-libs/libcap dev-libs/json-c x11-libs/pixman media-gfx/graphite2 dev-libs/nspr media-libs/alsa-lib dev-libs/libpcre2 dev-libs/nettle net-dns/libidn2 x11-libs/libXau media-libs/libpng dev-libs/fribidi dev-libs/nss x11-libs/libXdmcp x11-libs/libxcb x11-libs/libX11 x11-libs/libxkbcommon x11-libs/libXext x11-libs/libXfixes x11-libs/libXrender x11-libs/libXrandr x11-libs/libXi x11-libs/libXcomposite x11-libs/libXdamage sys-fs/lvm2 sys-apps/util-linux sys-fs/cryptsetup net-libs/gnutls sys-apps/systemd app-crypt/p11-kit sys-apps/dbus dev-libs/glib net-print/cups x11-libs/libdrm app-accessibility/at-spi2-core media-libs/mesa media-libs/freetype media-libs/fontconfig x11-libs/cairo media-libs/harfbuzz x11-libs/pango
    dev-libs/wayland media-libs/libjpeg-turbo media-libs/libepoxy x11-libs/libXcursor x11-libs/libXScrnSaver x11-libs/libXtst x11-libs/gdk-pixbuf x11-libs/libnotify x11-libs/gtk+
"

RESTRICT="bindist mirror"

QA_PREBUILT="
    opt/teamspeak6-client/libolm.so.3
    opt/teamspeak6-client/patcher
    opt/teamspeak6-client/libalsa_linux_amd64.so
    opt/teamspeak6-client/libGLESv2.so
    opt/teamspeak6-client/chrome-sandbox
    opt/teamspeak6-client/libEGL.so
    opt/teamspeak6-client/TeamSpeak
    opt/teamspeak6-client/soundbackends/libalsa_linux_amd64.so
    opt/teamspeak6-client/libtschat_client_lib_export.so
    opt/teamspeak6-client/libtschat_client_lib.so
    opt/teamspeak6-client/libcef.so
"

src_prepare() {
	default
}

src_install() {
	exeinto /opt/teamspeak6-client
	doexe TeamSpeak chrome-sandbox lib*.so lib*.so.* patcher soundbackends/*.so

	insinto /opt/teamspeak6-client
	doins *.bin *.dat *.pak
	doins -r html licenses locales soundbackends

	dodir /opt/bin
	dosym /opt/teamspeak6-client/TeamSpeak /opt/bin/ts6client

	for iconsize in 48 128 256; do
		newicon -s ${iconsize} logo-${iconsize}.png teamspeak6.png
	done

	make_desktop_entry \
		/opt/bin/ts6client "Teamspeak 6 Client" \
		"teamspeak6" "Audio;AudioVideo;Network"

	dodoc docs/*
}

pkg_postinst() {
	xdg_desktop_database_update
	xdg_icon_cache_update
	xdg_mimeinfo_database_update
}

pkg_postrm() {
	xdg_desktop_database_update
	xdg_icon_cache_update
	xdg_mimeinfo_database_update
}
