From 862593c122b5cc72cd0f4c6c0e7a2896501d344a Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 10 Nov 2021 20:10:33 +1000 Subject: [PATCH] Kotatogram: add recipe --- .../kotatogram_desktop.rdef.in | 42 + .../kotatogram_desktop-1.4.4.recipe | 326 +++++++ .../patches/cmake_helpers-1.4.4.patchset | 39 + .../patches/kotatogram_desktop-1.4.4.patchset | 600 ++++++++++++ .../patches/lib_base-1.4.4.patchset | 170 ++++ .../patches/lib_ui-1.4.4.patchset | 40 + .../patches/lib_webrtc-1.4.4.patchset | 41 + .../patches/libtgvoip-1.4.4.patchset | 887 ++++++++++++++++++ .../patches/tgcalls-1.4.4.patchset | 44 + 9 files changed, 2189 insertions(+) create mode 100644 net-im/kotatogram-desktop/additional-files/kotatogram_desktop.rdef.in create mode 100644 net-im/kotatogram-desktop/kotatogram_desktop-1.4.4.recipe create mode 100644 net-im/kotatogram-desktop/patches/cmake_helpers-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/kotatogram_desktop-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/lib_base-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/lib_ui-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/lib_webrtc-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/libtgvoip-1.4.4.patchset create mode 100644 net-im/kotatogram-desktop/patches/tgcalls-1.4.4.patchset diff --git a/net-im/kotatogram-desktop/additional-files/kotatogram_desktop.rdef.in b/net-im/kotatogram-desktop/additional-files/kotatogram_desktop.rdef.in new file mode 100644 index 000000000..95a8d0205 --- /dev/null +++ b/net-im/kotatogram-desktop/additional-files/kotatogram_desktop.rdef.in @@ -0,0 +1,42 @@ + +resource app_flags B_MULTIPLE_LAUNCH; + +resource app_version { + major = @MAJOR@, + middle = @MIDDLE@, + minor = @MINOR@, + + variety = B_APPV_FINAL, + internal = 0, + + short_info = "Kotatogram", + long_info = "@LONG_INFO@" +}; + +resource app_signature "@APP_SIGNATURE@"; + +resource("QT:QPA_FLAGS") "Q_KILL_ON_EXIT|Q_REF_TO_ARGV"; + +resource vector_icon { + $"6E636966040200060239C33A3D8036BD9F1D39E4714ACB9348D35600C8B3FFFF" + $"5A478B02000602B221D73BFF6EBC9FA0B2CC6A4A8C2B4A3DAB00FFFFFFFFD2BA" + $"FF050004016802000EBEC5B41FBEC5B41FC0A2B3F6C442B501C289B443C6EEB6" + $"21CA48BAFAC921B851CAEABC6DCB37BF98CB3EBE03CB42C13FCA2BC464CADAC2" + $"E4C94EC641C63DC907C7EFC7DFC518C9D1C274CAB8C3CDCA62C0CACB1EBD5DCA" + $"C9BF09CB26BB49CA58B7CEC7D4B95458B5D9C5FBB455C0BDB49AC36AB453C04E" + $"B446BF71B441BFE1B44CBE85B4A3BCB4B468BD99B527BAA7B7CBB74CB645B8C3" + $"B9AAB57BBEC5B41FBC2CB457BEC5B41F021AC07EBD1A4036C0B1BD7AC157BE0B" + $"C0F5BDD6C189BE27C1FBBE2FC1C2BE2EC287BE30C390BE8FC313BE4FC404BEC8" + $"C4CCBF6AC468BF1AC563BFE4C6C8C084C60EC04BC739C0A8C825C087C7B4C0AB" + $"C8ABC05EC99ABFCCC921C010C93FC07CC838C1A6C8C5C11CC77DC25DC587C30B" + $"C68EC2E8C489C324C29CC28DC382C2FFC1FFC243C0E8C176C177C1D8C07FC12E" + $"BF7EC108C002C0EFBEEEC124BE03C1D9BE7AC188BD43C266BB79C2FEBC68C2D8" + $"BB07C316BA1DC310BA91C312B93BC2FCB7B5C20DB865C299B708C183B607C018" + $"B679C0D5B5F8C000B5E0BFCCB5ECBFE6B691C032B821C0A0B74BC0B2B8C9C091" + $"B9F4BFEEB964C042BA9CBF89BBD2BE9BBB23BEF5BC59BE50BD8DBE2EBCF4BE2F" + $"BDCBBE2FBE3BBDFCBE08BE1EBE98BDBEBF09BCFDBED7BD5F4036403640364036" + $"050A030100023F4D7C0000000000003DC8104744E74A31B40A020100123F3BB4" + $"0000000000003F7D354490EE45036301178500040A000100023F3BB400000000" + $"00003F7D354490EE4503630A02010112402E08000000000000403200C3568A40" + $"996E01178422040A01010102402E08000000000000403200C3568A40996E" +}; diff --git a/net-im/kotatogram-desktop/kotatogram_desktop-1.4.4.recipe b/net-im/kotatogram-desktop/kotatogram_desktop-1.4.4.recipe new file mode 100644 index 000000000..1cf4234c5 --- /dev/null +++ b/net-im/kotatogram-desktop/kotatogram_desktop-1.4.4.recipe @@ -0,0 +1,326 @@ +SUMMARY="Experimental Telegram Desktop fork" +DESCRIPTION="Kotatogram Desktop, being based on Telegram Desktop, has all \ +its features, but it also has some more useful and cosmetic features." +HOMEPAGE="https://kotatogram.github.io/" +COPYRIGHT="2013-2021 Telegram + 2021 Kotatogram Team" +LICENSE="GNU GPL v3" +REVISION="1" +SOURCE_URI="https://github.com/kotatogram/kotatogram-desktop/archive/refs/tags/k$portVersion.tar.gz" +CHECKSUM_SHA256="453b1fb7ed280fd4c05d922553343cef7f06b408bfd1cfb24e7e7d1faf5d82ba" +SOURCE_FILENAME="kotatogram-$portVersion.tar.gz" +SOURCE_DIR="kotatogram-desktop-k$portVersion" +#libtgvoip +srcGitRev_2="373e41668b265864f8976b83bb66dd6e9a583915" +SOURCE_URI_2="https://github.com/telegramdesktop/libtgvoip/archive/$srcGitRev_2.tar.gz" +CHECKSUM_SHA256_2="6bdf3af434004617018988decd47e0eeb839fbff26574f5adaf129410d5463ce" +SOURCE_FILENAME_2="libtgvoip-$srcGitRev_2.tar.gz" +SOURCE_DIR_2="libtgvoip-$srcGitRev_2" +#rlottie +srcGitRev_3="cbd43984ebdf783e94c8303c41385bf82aa36d5b" +SOURCE_URI_3="https://github.com/desktop-app/rlottie/archive/$srcGitRev_3.tar.gz" +CHECKSUM_SHA256_3="0946541630edf1b4172a59b1fb167468f52945a9c0d5076a698c916c8488e5bd" +SOURCE_FILENAME_3="rlottie-$srcGitRev_3.tar.gz" +SOURCE_DIR_3="rlottie-$srcGitRev_3" +#lib_crl +srcGitRev_4="ec103d6bccaa59b56537c8658c9e41415bb9ccaf" +SOURCE_URI_4="https://github.com/desktop-app/lib_crl/archive/$srcGitRev_4.tar.gz" +CHECKSUM_SHA256_4="64edbf9083c9ce7f6e98e741596e47dafc9dbcc818e45b3288186c9668fad153" +SOURCE_FILENAME_4="lib_crl-$srcGitRev_4.tar.gz" +SOURCE_DIR_4="lib_crl-$srcGitRev_4" +#lib_rpl +srcGitRev_5="df721be3fa14a27dfc230d2e3c42bb1a7c9d0617" +SOURCE_URI_5="https://github.com/desktop-app/lib_rpl/archive/$srcGitRev_5.tar.gz" +CHECKSUM_SHA256_5="574a680d488bb25402463c3ef5f263df76635a805cfb00da87b59ab8c39c198d" +SOURCE_FILENAME_5="lib_rpl-$srcGitRev_5.tar.gz" +SOURCE_DIR_5="lib_rpl-$srcGitRev_5" +#lib_base +srcGitRev_6="e5a3b470d6524cdeb3e2deb92f04b0d290ceec24" +SOURCE_URI_6="https://github.com/desktop-app/lib_base/archive/$srcGitRev_6.tar.gz" +CHECKSUM_SHA256_6="579b60f2ea4c0a6874b7d0c383ec46896e56e4dc2d44156a5eb7c75187924313" +SOURCE_FILENAME_6="lib_base-$srcGitRev_6.tar.gz" +SOURCE_DIR_6="lib_base-$srcGitRev_6" +#codegen +srcGitRev_7="15026c5b6c5be43edae5c7737dbc011eec486e16" +SOURCE_URI_7="https://github.com/desktop-app/codegen/archive/$srcGitRev_7.tar.gz" +CHECKSUM_SHA256_7="435f2d18ec0916028a1611b4439ad7f69f2df16c6ea0d5303ba84227d7ec0af2" +SOURCE_FILENAME_7="codegen-$srcGitRev_7.tar.gz" +SOURCE_DIR_7="codegen-$srcGitRev_7" +#lib_ui +srcGitRev_8="eb86d2dc51aedc0a53188f1f2beb932e19442f9b" +SOURCE_URI_8="https://github.com/kotatogram/lib_ui/archive/$srcGitRev_8.tar.gz" +CHECKSUM_SHA256_8="c4e9eab8d179ef5a9304e863877f5e5b35121826d1eff862a14777dec652eea9" +SOURCE_FILENAME_8="lib_ui-$srcGitRev_8.tar.gz" +SOURCE_DIR_8="lib_ui-$srcGitRev_8" +#lib_rlottie +srcGitRev_9="0671bf70547381effcf442ec9618e04502a8adbc" +SOURCE_URI_9="https://github.com/desktop-app/lib_rlottie/archive/$srcGitRev_9.tar.gz" +CHECKSUM_SHA256_9="28b68af080b03bf0dd66bab5f9dceb712e0b3203fd5ad7f8096050272234941b" +SOURCE_FILENAME_9="lib_rlottie-$srcGitRev_9.tar.gz" +SOURCE_DIR_9="lib_rlottie-$srcGitRev_9" +#lib_lottie +srcGitRev_10="6fe29a2dfe8904559d31e3c9df5d51e9ed123011" +SOURCE_URI_10="https://github.com/desktop-app/lib_lottie/archive/$srcGitRev_10.tar.gz" +CHECKSUM_SHA256_10="f14a09b03a7d2402a531790cab01b601c80e4ab3dd6ce6eafd4a03614e6114bb" +SOURCE_FILENAME_10="lib_lottie-$srcGitRev_10.tar.gz" +SOURCE_DIR_10="lib_lottie-$srcGitRev_10" +#lib_tl +srcGitRev_11="45faed44e7f4d11fec79b7a70e4a35dc91ef3fdb" +SOURCE_URI_11="https://github.com/desktop-app/lib_tl/archive/$srcGitRev_11.tar.gz" +CHECKSUM_SHA256_11="1db86a372f9c5d87b836a60ee16bf6a69dd343840498bc0121118ac9fc2b80e1" +SOURCE_FILENAME_11="lib_tl-$srcGitRev_11.tar.gz" +SOURCE_DIR_11="lib_tl-$srcGitRev_11" +#lib_spellcheck +srcGitRev_12="212d660cbbb49592103de7a98fcb1c0f16efc36b" +SOURCE_URI_12="https://github.com/desktop-app/lib_spellcheck/archive/$srcGitRev_12.tar.gz" +CHECKSUM_SHA256_12="29b76026b4da7f146b238f25909b5f6acbbc6e233ecd861b1d98f3974e065ab8" +SOURCE_FILENAME_12="lib_spellcheck-$srcGitRev_12.tar.gz" +SOURCE_DIR_12="lib_spellcheck-$srcGitRev_12" +#lib_storage +srcGitRev_13="73d57840ac603107381e0e6b22d5b3bdcae492c6" +SOURCE_URI_13="https://github.com/desktop-app/lib_storage/archive/$srcGitRev_13.tar.gz" +CHECKSUM_SHA256_13="ce440ae1cbfc35a4e1f04adfe14497991a9347045970620b199abfd3f162b65b" +SOURCE_FILENAME_13="lib_storage-$srcGitRev_13.tar.gz" +SOURCE_DIR_13="lib_storage-$srcGitRev_13" +#cmake_helpers +srcGitRev_14="dfd1ab4b4959b943bb0236046d8f89bdacaaa266" +SOURCE_URI_14="https://github.com/kotatogram/cmake_helpers/archive/$srcGitRev_14.tar.gz" +CHECKSUM_SHA256_14="4ef8882f6575a2dbcc9c56cc45de63dc48cb186946419e71df372f36ae0bd342" +SOURCE_FILENAME_14="cmake_helpers-$srcGitRev_14.tar.gz" +SOURCE_DIR_14="cmake_helpers-$srcGitRev_14" +#QR-Code-generator +srcGitRev_15="67c62461d380352500fc39557fd9f046b7fe1d18" +SOURCE_URI_15="https://github.com/nayuki/QR-Code-generator/archive/$srcGitRev_15.tar.gz" +CHECKSUM_SHA256_15="1f1218c0a0abfc420cbc651675434d971b5e672b54428860339c51ecdf1958fc" +SOURCE_FILENAME_15="QR-Code-generator-$srcGitRev_15.tar.gz" +SOURCE_DIR_15="QR-Code-generator-$srcGitRev_15" +#lib_qr +srcGitRev_16="2b08c71c6edcfc3e31f7d7f518cc963493b6e189" +SOURCE_URI_16="https://github.com/desktop-app/lib_qr/archive/$srcGitRev_16.tar.gz" +CHECKSUM_SHA256_16="f1aee181ebbcec2e8b8f4d8321d966f8a51ee0f015153602987e88113d6816e9" +SOURCE_FILENAME_16="lib_qr-$srcGitRev_16.tar.gz" +SOURCE_DIR_16="lib_qr-$srcGitRev_16" +#lib_webrtc +srcGitRev_17="29d51317915ca43db45d436cba8eac3f40dea36b" +SOURCE_URI_17="https://github.com/desktop-app/lib_webrtc/archive/$srcGitRev_17.tar.gz" +CHECKSUM_SHA256_17="c5488b1d32d8509df2053413388f3b4e3adeb6da573552ac540d83a1edb6a63c" +SOURCE_FILENAME_17="lib_webrtc-$srcGitRev_17.tar.gz" +SOURCE_DIR_17="lib_webrtc-$srcGitRev_17" +#tgcalls +srcGitRev_18="f76a9290fa502a8df473dd872aedf9a553b089cc" +SOURCE_URI_18="https://github.com/TelegramMessenger/tgcalls/archive/$srcGitRev_18.tar.gz" +CHECKSUM_SHA256_18="6d5e4505e10c1be5ed1674ddb3a314bc8274cd216090a5f02cdc86c3c276a1b1" +SOURCE_FILENAME_18="tgcalls-$srcGitRev_18.tar.gz" +SOURCE_DIR_18="tgcalls-$srcGitRev_18" +#lib_webview +srcGitRev_19="0a3584b8d8e37f9745a0cb0fae725e8e8ea0d989" +SOURCE_URI_19="https://github.com/desktop-app/lib_webview/archive/$srcGitRev_19.tar.gz" +CHECKSUM_SHA256_19="16122bd4c13fc47ae19c10b7a2af6c9138b4cdd8a0b6e472148d7ce659d88b33" +SOURCE_FILENAME_19="lib_webview-$srcGitRev_19.tar.gz" +SOURCE_DIR_19="lib_webview-$srcGitRev_19" +#expected +srcGitRev_20="1d9c5d8c0da84b8ddc54bd3d90d632eec95c1f13" +SOURCE_URI_20="https://github.com/TartanLlama/expected/archive/$srcGitRev_20.tar.gz" +CHECKSUM_SHA256_20="95b82e57a6214ca84105016670eb7f080ad54f71290d8169fcaa969cb6dfc6c8" +SOURCE_FILENAME_20="expected-$srcGitRev_20.tar.gz" +SOURCE_DIR_20="expected-$srcGitRev_20" +#GSL +srcGitRev_21="1999b48a519196711f0d03af3b7eedd49fcc6db3" +SOURCE_URI_21="https://github.com/Microsoft/GSL/archive/$srcGitRev_21.tar.gz" +CHECKSUM_SHA256_21="486d9c18da2303e212165bee7e14fbe5565084b30b1ad7810e26a8a64059492f" +SOURCE_FILENAME_21="GSL-$srcGitRev_21.tar.gz" +SOURCE_DIR_21="GSL-$srcGitRev_21" +#APIKEY +srcGitRev_22="2b383fe05f8ae78ac99470b9a2b9ea22b3ee5a92" +SOURCE_URI_22="https://salsa.debian.org/debian/telegram-desktop/-/raw/$srcGitRev_22/debian/rules#noarchive" +CHECKSUM_SHA256_22="613e7e357518739e1f7d035337f37c344b248283fd4d916ddc95df73c2ff84ad" + +PATCHES="kotatogram_desktop-$portVersion.patchset" +PATCHES_2="libtgvoip-$portVersion.patchset" +PATCHES_6="lib_base-$portVersion.patchset" +PATCHES_8="lib_ui-$portVersion.patchset" +PATCHES_14="cmake_helpers-$portVersion.patchset" +PATCHES_17="lib_webrtc-$portVersion.patchset" +PATCHES_18="tgcalls-$portVersion.patchset" + +ADDITIONAL_FILES="kotatogram_desktop.rdef.in" + +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="x86" + +PROVIDES=" + kotatogram_desktop$secondaryArchSuffix = $portVersion + app:Kotatogram + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libabsl_strings$secondaryArchSuffix + lib:libabsl_throw_delegate$secondaryArchSuffix + lib:libatomic$secondaryArchSuffix + lib:libavcodec$secondaryArchSuffix + lib:libavformat$secondaryArchSuffix + lib:libavutil$secondaryArchSuffix + lib:libcrypto$secondaryArchSuffix + lib:libgiomm_2.4$secondaryArchSuffix + lib:libglib_2.0$secondaryArchSuffix + lib:libglibmm_2.4$secondaryArchSuffix + lib:libgthread_2.0$secondaryArchSuffix + lib:libhunspell_1.7$secondaryArchSuffix + lib:libintl$secondaryArchSuffix + lib:libjpeg$secondaryArchSuffix + lib:liblz4$secondaryArchSuffix + lib:liblzma$secondaryArchSuffix + lib:libminizip$secondaryArchSuffix + lib:libopenal$secondaryArchSuffix + lib:libopus$secondaryArchSuffix + lib:libQt5Core$secondaryArchSuffix + lib:libQt5Gui$secondaryArchSuffix + lib:libQt5Network$secondaryArchSuffix + lib:libQt5Widgets$secondaryArchSuffix + lib:librnnoise$secondaryArchSuffix + lib:libsigc_2.0$secondaryArchSuffix + lib:libswresample$secondaryArchSuffix + lib:libswscale$secondaryArchSuffix + lib:libxxhash$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libabsl_strings$secondaryArchSuffix + devel:libabsl_throw_delegate$secondaryArchSuffix + devel:libavcodec$secondaryArchSuffix + devel:libavformat$secondaryArchSuffix + devel:libavutil$secondaryArchSuffix + devel:libcrypto$secondaryArchSuffix + devel:libglib_2.0$secondaryArchSuffix + devel:libglibmm_2.4$secondaryArchSuffix + devel:libgthread_2.0$secondaryArchSuffix + devel:libhunspell_1.7$secondaryArchSuffix + devel:libjpeg$secondaryArchSuffix + devel:liblz4$secondaryArchSuffix + devel:liblzma$secondaryArchSuffix + devel:libminizip$secondaryArchSuffix + devel:libopenal$secondaryArchSuffix + devel:libopus$secondaryArchSuffix + devel:libqrcodegen$secondaryArchSuffix + devel:libQt5Core$secondaryArchSuffix + devel:libQt5Gui$secondaryArchSuffix + devel:libQt5Network$secondaryArchSuffix + devel:libQt5Widgets$secondaryArchSuffix + devel:librapidjson$secondaryArchSuffix + devel:librnnoise$secondaryArchSuffix + devel:libswresample$secondaryArchSuffix + devel:libswscale$secondaryArchSuffix + devel:libtg_owt$secondaryArchSuffix + devel:libxxhash$secondaryArchSuffix + devel:libz$secondaryArchSuffix + devel:range_v3$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:cmake + cmd:gawk + cmd:gcc$secondaryArchSuffix + cmd:lrelease$secondaryArchSuffix >= 5 + cmd:make + cmd:pkg_config$secondaryArchSuffix + cmd:python + cmd:sed + cmd:yasm + " + +BUILD() +{ + export DISABLE_ASLR=1 + + # get API_ID and API_HASH from Debian + local TELEGRAM_API_ID=`sed -n "/TDESKTOP_API_ID/p" $sourceDir22/rules | cut -d'=' -f2 | cut -d' ' -f1` + local TELEGRAM_API_HASH=`sed -n "/TDESKTOP_API_HASH/p" $sourceDir22/rules | cut -d'=' -f2 | cut -d' ' -f1` + + if [ -z $TELEGRAM_API_ID ] || [ -z $TELEGRAM_API_HASH ]; then + TELEGRAM_API_ID="17349" + TELEGRAM_API_HASH="344583e45741c457fe1862106095a5eb" + echo -e "\e[91m***************************************************************************\e[39m" + echo -e "\e[91m Use demo API_ID = $TELEGRAM_API_ID and API_HASH = $TELEGRAM_API_HASH \e[39m" + echo -e "\e[91m***************************************************************************\e[39m" + else + echo -e "\e[32m***************************************************************************\e[39m" + echo -e "\e[32m Use custom API_ID = $TELEGRAM_API_ID and API_HASH = $TELEGRAM_API_HASH \e[39m" + echo -e "\e[32m***************************************************************************\e[39m" + fi + + # link submodules + rm -rf $sourceDir/cmake + rm -rf $sourceDir/Telegram/ThirdParty/{libtgvoip,rlottie,QR,tgcalls,expected,GSL} + rm -rf $sourceDir/Telegram/{lib_crl,lib_rpl,lib_base,codegen,lib_ui,lib_lottie,lib_rlottie} + rm -rf $sourceDir/Telegram/{lib_tl,lib_spellcheck,lib_storage,lib_qr,lib_webrtc,lib_webview} + + ln -sf $sourceDir2 $sourceDir/Telegram/ThirdParty/libtgvoip + ln -sf $sourceDir3 $sourceDir/Telegram/ThirdParty/rlottie + ln -sf $sourceDir4 $sourceDir/Telegram/lib_crl + ln -sf $sourceDir5 $sourceDir/Telegram/lib_rpl + ln -sf $sourceDir6 $sourceDir/Telegram/lib_base + ln -sf $sourceDir7 $sourceDir/Telegram/codegen + ln -sf $sourceDir8 $sourceDir/Telegram/lib_ui + ln -sf $sourceDir9 $sourceDir/Telegram/lib_rlottie + ln -sf $sourceDir10 $sourceDir/Telegram/lib_lottie + ln -sf $sourceDir11 $sourceDir/Telegram/lib_tl + ln -sf $sourceDir12 $sourceDir/Telegram/lib_spellcheck + ln -sf $sourceDir13 $sourceDir/Telegram/lib_storage + ln -sf $sourceDir14 $sourceDir/cmake + ln -sf $sourceDir15 $sourceDir/Telegram/ThirdParty/QR + ln -sf $sourceDir16 $sourceDir/Telegram/lib_qr + ln -sf $sourceDir17 $sourceDir/Telegram/lib_webrtc + ln -sf $sourceDir18 $sourceDir/Telegram/ThirdParty/tgcalls + ln -sf $sourceDir19 $sourceDir/Telegram/lib_webview + ln -sf $sourceDir20 $sourceDir/Telegram/ThirdParty/expected + ln -sf $sourceDir21 $sourceDir/Telegram/ThirdParty/GSL + + # build telegram + mkdir -p build + cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DTDESKTOP_API_TEST=OFF \ + -DTDESKTOP_DISABLE_GTK_INTEGRATION=ON \ + -DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON \ + -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION=ON \ + -DDESKTOP_APP_DISABLE_GTK_INTEGRATION=ON \ + -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=ON \ + -DDESKTOP_APP_DISABLE_X11_INTEGRATION=ON \ + -DDESKTOP_APP_DISABLE_AUTOUPDATE=ON \ + -DDESKTOP_APP_DISABLE_WEBKITGTK=ON \ + -DDESKTOP_APP_USE_PACKAGED_FONTS=OFF \ + -DDESKTOP_APP_USE_HUNSPELL_ONLY=ON \ + -DTDESKTOP_USE_PACKAGED_TGVOIP=OFF \ + -DLIBTGVOIP_DISABLE_ALSA=ON \ + -DLIBTGVOIP_DISABLE_PULSEAUDIO=ON \ + -DTDESKTOP_API_ID=$TELEGRAM_API_ID \ + -DTDESKTOP_API_HASH=$TELEGRAM_API_HASH + + make $jobArgs +} + +INSTALL() +{ + mkdir -p $appsDir + cp build/bin/Kotatogram $appsDir + strip $appsDir/Kotatogram + + local APP_SIGNATURE="application/x-vnd.kotatogram" + 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/kotatogram_desktop.rdef.in > build/kotatogram_desktop.rdef + + addResourcesToBinaries build/kotatogram_desktop.rdef $appsDir/Kotatogram + addAppDeskbarSymlink $appsDir/Kotatogram +} diff --git a/net-im/kotatogram-desktop/patches/cmake_helpers-1.4.4.patchset b/net-im/kotatogram-desktop/patches/cmake_helpers-1.4.4.patchset new file mode 100644 index 000000000..20df14ba4 --- /dev/null +++ b/net-im/kotatogram-desktop/patches/cmake_helpers-1.4.4.patchset @@ -0,0 +1,39 @@ +From 3d7f45b060924521b13a80acd670fc32fbeabc28 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:21:03 +1000 +Subject: Fixes for Haiku + + +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index 58ba80a..fe98397 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -37,7 +37,7 @@ if (add_hunspell_library) + add_checked_subdirectory(hunspell) + endif() + add_checked_subdirectory(iconv) +-if (LINUX) ++if (LINUX AND NOT HAIKU) + add_checked_subdirectory(jemalloc) + endif() + add_checked_subdirectory(jpeg) +diff --git a/options_linux.cmake b/options_linux.cmake +index 2797c7b..26368f2 100644 +--- a/options_linux.cmake ++++ b/options_linux.cmake +@@ -45,10 +45,12 @@ if (DESKTOP_APP_SPECIAL_TARGET) + target_link_options(common_options INTERFACE $,,-g -flto -fuse-linker-plugin>) + endif() + ++if (NOT HAIKU) + target_link_libraries(common_options + INTERFACE + desktop-app::external_jemalloc + ) ++endif() + + if (DESKTOP_APP_USE_ALLOCATION_TRACER) + target_link_options(common_options +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/kotatogram_desktop-1.4.4.patchset b/net-im/kotatogram-desktop/patches/kotatogram_desktop-1.4.4.patchset new file mode 100644 index 000000000..1f7215f4c --- /dev/null +++ b/net-im/kotatogram-desktop/patches/kotatogram_desktop-1.4.4.patchset @@ -0,0 +1,600 @@ +From 116afdf52d051c7eec50258c47885b93e8c9d2ed Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 19:31:53 +1000 +Subject: Add Haiku support + + +diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt +index 6567be6..f9d7122 100644 +--- a/Telegram/CMakeLists.txt ++++ b/Telegram/CMakeLists.txt +@@ -89,6 +89,15 @@ PRIVATE + desktop-app::external_xxhash + ) + ++if (HAIKU) ++ target_link_libraries(Telegram ++ PRIVATE ++ be ++ jpeg ++ translation ++ ) ++endif() ++ + target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h) + nice_target_sources(Telegram ${src_loc} + PRIVATE +@@ -1182,6 +1191,16 @@ else() + ) + endif() + ++if (HAIKU) ++ remove_target_sources(Telegram ${src_loc} ++ platform/linux/notifications_manager_linux_dummy.cpp ++ ) ++ nice_target_sources(Telegram ${src_loc} ++ PRIVATE ++ platform/linux/notifications_manager_haiku.cpp ++ ) ++endif() ++ + if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + remove_target_sources(Telegram ${src_loc} + platform/linux/linux_wayland_integration.cpp +@@ -1311,7 +1330,7 @@ else() + endif() + + set(bundle_identifier "io.github.kotatogram") +-if (LINUX AND DESKTOP_APP_USE_PACKAGED) ++if (LINUX AND NOT HAIKU AND DESKTOP_APP_USE_PACKAGED) + set(output_name "kotatogram-desktop") + else() + set(output_name "Kotatogram") +diff --git a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp +index 0fdaf4c..ea0f606 100644 +--- a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp ++++ b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp +@@ -583,6 +583,7 @@ void FillMenu( + real->recordStartDateValue(), + handler)); + } ++#ifndef Q_OS_HAIKU + if (addScreenCast) { + const auto sharing = call->isSharingScreen(); + const auto toggle = [=] { +@@ -600,6 +601,7 @@ void FillMenu( + : tr::lng_group_call_screen_share_start(tr::now)), + toggle); + } ++#endif + menu->addAction(tr::lng_group_call_settings(tr::now), [=] { + if (const auto strong = weak.get()) { + showBox(Box(SettingsBox, strong)); +diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +index c71c522..2c3d1dc 100644 +--- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp ++++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +@@ -1935,7 +1935,9 @@ void Panel::updateButtonsGeometry() { + const auto muteSize = _mute->innerSize().width() + 2 * addSkip; + const auto skip = st::groupCallButtonSkipSmall; + const auto fullWidth = (_video->width() + skip) ++#ifndef Q_OS_HAIKU + + (_screenShare->width() + skip) ++#endif + + (muteSize + skip) + + (_settings ->width() + skip) + + _hangup->width(); +@@ -1946,9 +1948,13 @@ void Panel::updateButtonsGeometry() { + - membersWidth + - membersSkip + - fullWidth) / 2; ++#ifndef Q_OS_HAIKU + toggle(_screenShare, !hidden); + _screenShare->moveToLeft(left, buttonsTop); + left += _screenShare->width() + skip; ++#else ++ toggle(_screenShare, false); ++#endif + toggle(_video, !hidden); + _video->moveToLeft(left, buttonsTop); + left += _video->width() + skip; +diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h +index 9b896a5..2eb6523 100644 +--- a/Telegram/SourceFiles/core/core_settings.h ++++ b/Telegram/SourceFiles/core/core_settings.h +@@ -707,7 +707,7 @@ private: + rpl::variable _dialogsWidthRatio; // per-window + rpl::variable _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w + bool _notifyFromAll = true; +- rpl::variable _nativeWindowFrame = Platform::IsLinux(); ++ rpl::variable _nativeWindowFrame = true; + rpl::variable> _systemDarkMode = std::nullopt; + rpl::variable _systemDarkModeEnabled = false; + WindowPosition _windowPosition; // per-window +diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +index 453ccfd..c8374f9 100644 +--- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +@@ -14,6 +14,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + #include "platform/linux/linux_xdp_open_with_dialog.h" + #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + ++#ifdef Q_OS_HAIKU ++#include ++#include ++#include ++#include ++#include ++#include ++#endif ++ + #include + #include + +@@ -48,6 +57,23 @@ void UnsafeOpenEmailLink(const QString &email) { + } + + bool UnsafeShowOpenWith(const QString &filepath) { ++#ifdef Q_OS_HAIKU ++ BMessenger trackerMessenger("application/x-vnd.Be-TRAK"); ++ if (trackerMessenger.IsValid()) { ++ update_mime_info(filepath.toUtf8().data(), false, true, false); ++ ++ BEntry fileEntry(filepath.toUtf8().data()); ++ entry_ref fileRef; ++ if (fileEntry.GetRef(&fileRef) == B_OK) { ++ BMessage openCommand(B_REFS_RECEIVED); ++ openCommand.AddRef("refs", &fileRef); ++ openCommand.AddInt32("launchUsingSelector", 0); ++ if (trackerMessenger.SendMessage(&openCommand) == B_OK) ++ return true; ++ } ++ } ++#endif ++ + #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION + if (internal::ShowXDPOpenWithDialog(filepath)) { + return true; +diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +index 5fb5fbb..52b7711 100644 +--- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +@@ -935,11 +935,17 @@ bool MainWindow::hasTrayIcon() const { + + bool MainWindow::isActiveForTrayMenu() { + updateIsActive(); ++#ifdef Q_OS_HAIKU ++ return isVisible(); ++#else + return Platform::IsWayland() ? isVisible() : isActive(); ++#endif + } + + void MainWindow::psShowTrayMenu() { ++#ifndef Q_OS_HAIKU + _trayIconMenuXEmbed->popup(QCursor::pos()); ++#endif + } + + void MainWindow::psTrayMenuUpdated() { +@@ -971,7 +977,9 @@ void MainWindow::psSetupTrayIcon() { + if (!trayIcon) { + trayIcon = new QSystemTrayIcon(this); + trayIcon->setIcon(TrayIconGen(counter, muted)); +- ++#ifdef Q_OS_HAIKU ++ trayIcon->setContextMenu(trayIconMenu); ++#endif + attachToTrayIcon(trayIcon); + } + updateIconCounters(); +@@ -1063,8 +1071,10 @@ void MainWindow::updateIconCounters() { + } + + void MainWindow::initTrayMenuHook() { ++#ifndef Q_OS_HAIKU + _trayIconMenuXEmbed.emplace(nullptr, trayIconMenu); + _trayIconMenuXEmbed->deleteOnHide(false); ++#endif + } + + void MainWindow::createGlobalMenu() { +diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp +new file mode 100644 +index 0000000..72bda83 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp +@@ -0,0 +1,270 @@ ++/* ++This file is part of Telegram Desktop for Haiku, ++ ++For license and copyright information please follow this link: ++https://github.com/desktop-app/legal/blob/master/LEGAL ++ ++Copyright (c) 2018-2021 Gerasim Troeglazov, 3dEyes@gmail.com ++*/ ++ ++ ++#include ++#include ++#include ++#include ++ ++#include "platform/linux/notifications_manager_linux.h" ++ ++#include "window/notifications_utilities.h" ++#include "history/history.h" ++#include "lang/lang_keys.h" ++#include "core/application.h" ++#include "core/core_settings.h" ++#include "main/main_session.h" ++ ++#define USE_HAIKU_UINT64 ++#include "base/haiku_types.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define NOTIFY_MESSAGE_DEEP 16 ++#define NOTIFY_PORT_NAME "tg_notify" ++#define NOTIFY_GATE_NAME "/bin/qnotify" ++#define NOTIFY_MESSAGE 'QNTF' ++ ++#include ++#include ++#include ++#include ++ ++namespace Platform { ++namespace Notifications { ++ ++bool Supported() { ++ return true; ++} ++ ++void Finish() { ++} ++ ++bool SkipAudio() { ++ return false; ++} ++ ++bool SkipToast() { ++ return false; ++} ++ ++bool SkipFlashBounce() { ++ return false; ++} ++ ++bool SkipAudioForCustom() { ++ return false; ++} ++ ++bool SkipToastForCustom() { ++ return false; ++} ++ ++bool SkipFlashBounceForCustom() { ++ return false; ++} ++ ++bool Enforced() { ++ return false; ++} ++ ++bool ByDefault() { ++ return true; ++} ++ ++void Create(Window::Notifications::System *system) { ++ if (Core::App().settings().nativeNotifications() && Supported()) { ++ auto result = std::make_unique(system); ++ system->setManager(std::move(result)); ++ return; ++ } ++ system->setManager(nullptr); ++} ++ ++class Manager::Private : public QObject { ++ ++public: ++ using Type = Window::Notifications::CachedUserpics::Type; ++ explicit Private(not_null manager, Type type); ++ ++ void showNotification( ++ not_null peer, ++ std::shared_ptr &userpicView, ++ MsgId msgId, ++ const QString &title, ++ const QString &subtitle, ++ const QString &msg, ++ bool hideNameAndPhoto, ++ bool hideReplyButton); ++ ++ ~Private(); ++ ++private: ++ void CheckNotificationAction(); ++ ++ QTimer *_checkNotificationTimer; ++ Window::Notifications::CachedUserpics _cachedUserpics; ++ const not_null _manager; ++ int32 _portId; ++}; ++ ++Manager::Private::Private(not_null manager, Type type) ++: _cachedUserpics(type) ++, _manager(manager) { ++ _portId = create_port(NOTIFY_MESSAGE_DEEP, NOTIFY_PORT_NAME); ++ _checkNotificationTimer = new QTimer(this); ++ connect(_checkNotificationTimer, &QTimer::timeout, this, &Manager::Private::CheckNotificationAction); ++ _checkNotificationTimer->start(250); ++} ++ ++Manager::Private::~Private() { ++ delete _checkNotificationTimer; ++ if (_portId > 0) ++ delete_port(_portId); ++} ++ ++void Manager::Private::CheckNotificationAction() ++{ ++ ssize_t msgSize; ++ ++ do { ++ msgSize = port_buffer_size_etc(_portId, B_RELATIVE_TIMEOUT, 0); ++ } while (msgSize == B_INTERRUPTED); ++ ++ if (msgSize < 0) ++ return; ++ ++ char* buffer = new(std::nothrow) char[msgSize]; ++ if (!buffer) ++ return; ++ ++ int32 code; ++ status_t result; ++ do { ++ result = read_port(_portId, &code, buffer, msgSize); ++ } while (result == B_INTERRUPTED); ++ ++ BMessage message; ++ ++ if (result < 0 || code != NOTIFY_MESSAGE) { ++ delete[] buffer; ++ return; ++ } ++ ++ if (message.Unflatten(buffer) == B_OK) { ++ uint64 sessionId = message.GetUInt64("session", 0); ++ uint64 peerId = message.GetUInt64("peer", 0); ++ int32 messageId = message.GetInt32("message", 0); ++ ++ const auto key = FullPeer{ ++ .sessionId = sessionId, ++ .peerId = PeerId(peerId) ++ }; ++ const auto notificationId = NotificationId{ .full = key, .msgId = messageId }; ++ ++ crl::on_main(this, [=] { ++ _manager->notificationActivated(notificationId); ++ }); ++ } ++ delete[] buffer; ++} ++ ++void Manager::Private::showNotification( ++ not_null peer, ++ std::shared_ptr &userpicView, ++ MsgId msgId, ++ const QString &title, ++ const QString &subtitle, ++ const QString &msg, ++ bool hideNameAndPhoto, ++ bool hideReplyButton) { ++ auto titleText = title; ++ auto subtitleText = subtitle; ++ auto msgText = msg; ++ ++ const auto key = hideNameAndPhoto ++ ? InMemoryKey() ++ : peer->userpicUniqueKey(userpicView); ++ ++ auto userpicPath = _cachedUserpics.get(key, peer, userpicView); ++ BBitmap *icon = BTranslationUtils::GetBitmapFile(userpicPath.toUtf8().data()); ++ QString args = QString( ++ "mode:port " ++ "target:tg_notify " ++ "session:uint64:%1 " ++ "peer:uint64:%2 " ++ "message:int32:%3") ++ .arg(peer->session().uniqueId()).arg(peer->id.value).arg(msgId); ++ BNotification notify(B_INFORMATION_NOTIFICATION); ++ if (icon) ++ notify.SetIcon(icon); ++ notify.SetGroup("Telegram"); ++ notify.SetTitle(titleText.toUtf8().data()); ++ notify.SetContent(msgText.toUtf8().data()); ++ entry_ref ref; ++ BEntry entry(NOTIFY_GATE_NAME); ++ entry.GetRef(&ref); ++ notify.SetOnClickFile(&ref); ++ notify.AddOnClickArg(BString(args.toUtf8().data())); ++ notify.Send(); ++} ++ ++Manager::Manager(not_null system) ++: NativeManager(system) ++, _private(std::make_unique(this, Private::Type::Rounded)) { ++} ++ ++Manager::~Manager() = default; ++ ++void Manager::doShowNativeNotification( ++ not_null peer, ++ std::shared_ptr &userpicView, ++ MsgId msgId, ++ const QString &title, ++ const QString &subtitle, ++ const QString &msg, ++ bool hideNameAndPhoto, ++ bool hideReplyButton) { ++ _private->showNotification( ++ peer, ++ userpicView, ++ msgId, ++ title, ++ subtitle, ++ msg, ++ hideNameAndPhoto, ++ hideReplyButton); ++} ++ ++void Manager::doClearAllFast() { } ++ ++void Manager::doClearFromHistory(not_null history) { } ++ ++void Manager::doClearFromSession(not_null session) { } ++ ++bool Manager::doSkipAudio() const { ++ return false; ++} ++ ++bool Manager::doSkipToast() const { ++ return false; ++} ++ ++bool Manager::doSkipFlashBounce() const { ++ return false; ++} ++ ++} // namespace Notifications ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +index dcdb784..7529ac6 100644 +--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +@@ -38,6 +38,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + #include "webview/platform/linux/webview_linux_webkit2gtk.h" + #endif // !DESKTOP_APP_DISABLE_WEBKITGTK + ++#ifdef Q_OS_HAIKU ++#include ++#endif ++ + #include + #include + #include +@@ -49,7 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + + #ifdef Q_OS_FREEBSD + #include +-#else // Q_OS_FREEBSD ++#elif !defined (Q_OS_HAIKU) // Q_OS_FREEBSD + #include + #endif // Q_OS_FREEBSD + +@@ -591,7 +595,7 @@ void psActivateProcess(uint64 pid) { + + namespace { + +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + void HaikuAutostart(bool start) { + const auto home = QDir::homePath(); + if (home.isEmpty()) { +@@ -616,7 +620,7 @@ void HaikuAutostart(bool start) { + file.remove(); + } + } +-#endif // __HAIKU__ ++#endif // Q_OS_HAIKU + + } // namespace + +@@ -635,7 +639,11 @@ QString psAppDataPath() { + } + */ + +- return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; ++#ifdef Q_OS_HAIKU ++ return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + '/'; ++#else ++ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; ++#endif + } + + void psDoCleanup() { +@@ -663,8 +671,9 @@ namespace Platform { + + void start() { + auto backgroundThread = true; ++#ifndef Q_OS_HAIKU + mallctl("background_thread", nullptr, nullptr, &backgroundThread, sizeof(bool)); +- ++#endif + // Prevent any later calls into setlocale() by Qt + QCoreApplicationPrivate::initLocale(); + +@@ -796,7 +805,7 @@ bool OpenSystemSettings(SystemSettingsType type) { + } else if (DesktopEnvironment::IsMATE()) { + add("mate-volume-control"); + } +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + add("Media"); + #endif // __ HAIKU__ + add("pavucontrol-qt"); +diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake +index f332b18..73c1930 100644 +--- a/Telegram/cmake/lib_tgvoip.cmake ++++ b/Telegram/cmake/lib_tgvoip.cmake +@@ -123,6 +123,14 @@ if (NOT TGVOIP_FOUND) + os/linux/AudioPulse.cpp + os/linux/AudioPulse.h + ++ # Haiku ++ os/haiku/AudioInputHaiku.cpp ++ os/haiku/AudioInputHaiku.h ++ os/haiku/AudioOutputHaiku.cpp ++ os/haiku/AudioOutputHaiku.h ++ os/haiku/RingBuffer.cpp ++ os/haiku/RingBuffer.h ++ + # POSIX + os/posix/NetworkSocketPosix.cpp + os/posix/NetworkSocketPosix.h +@@ -160,6 +168,25 @@ if (NOT TGVOIP_FOUND) + TGVOIP_NO_OSX_PRIVATE_API + ) + endif() ++ elseif (HAIKU) ++ target_compile_definitions(lib_tgvoip_bundled ++ PUBLIC ++ WEBRTC_POSIX ++ WEBRTC_HAIKU ++ ) ++ target_compile_options(lib_tgvoip_bundled ++ PRIVATE ++ -Wno-unknown-pragmas ++ -Wno-error=sequence-point ++ -Wno-error=unused-result ++ -mmmx ++ -msse2 ++ ) ++ target_link_libraries(lib_tgvoip_bundled ++ PRIVATE ++ network ++ media ++ ) + else() + add_library(lib_tgvoip_bundled_options INTERFACE) + target_compile_options(lib_tgvoip_bundled_options +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/lib_base-1.4.4.patchset b/net-im/kotatogram-desktop/patches/lib_base-1.4.4.patchset new file mode 100644 index 000000000..8e49b0e2e --- /dev/null +++ b/net-im/kotatogram-desktop/patches/lib_base-1.4.4.patchset @@ -0,0 +1,170 @@ +From 00c1e5974b4d6d6cbafe5ae42ab70766370b8580 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:14:13 +1000 +Subject: Fixes for Haiku + + +diff --git a/base/haiku_types.h b/base/haiku_types.h +new file mode 100644 +index 0000000..3a57ce2 +--- /dev/null ++++ b/base/haiku_types.h +@@ -0,0 +1,24 @@ ++#pragma once ++ ++#ifdef Q_OS_HAIKU ++ ++#define _SUPPORT_DEFS_H ++ ++#ifdef __x86_64__ ++#define int64 __haiku_int64 ++#ifdef USE_HAIKU_UINT64 ++#define uint64 __haiku_uint64 ++#endif ++#else ++#define int32 __haiku_int32 ++#define uint32 __haiku_uint32 ++#endif ++ ++typedef int32 status_t; ++typedef uint32 type_code; ++typedef uint32 perform_code; ++ ++typedef int64 bigtime_t; ++typedef int64 nanotime_t; ++ ++#endif +diff --git a/base/platform/linux/base_file_utilities_linux.cpp b/base/platform/linux/base_file_utilities_linux.cpp +index b3ba5f3..a481e3b 100644 +--- a/base/platform/linux/base_file_utilities_linux.cpp ++++ b/base/platform/linux/base_file_utilities_linux.cpp +@@ -27,8 +27,58 @@ + #include + #include + ++#ifdef Q_OS_HAIKU ++#include ++#include ++#include ++#endif ++ + namespace base::Platform { + namespace { ++ ++#ifdef Q_OS_HAIKU ++bool HaikuShowInFolder(const QString &filepath) { ++ try { ++ BMessenger trackerMessenger("application/x-vnd.Be-TRAK"); ++ if (!trackerMessenger.IsValid()) ++ return false; ++ ++ BEntry fileEntry(filepath.toUtf8().data()); ++ entry_ref fileRef; ++ if (fileEntry.GetRef(&fileRef) != B_OK) ++ return false; ++ ++ if (!fileEntry.Exists()) ++ return false; ++ ++ BEntry folderEntry; ++ if (fileEntry.GetParent(&folderEntry) != B_OK) ++ return false; ++ ++ entry_ref folderRef; ++ if (folderEntry.GetRef(&folderRef) != B_OK) ++ return false; ++ ++ BMessage openCommand(B_REFS_RECEIVED); ++ openCommand.AddRef("refs", &folderRef); ++ node_ref fileNodeRef; ++ if (fileEntry.GetNodeRef(&fileNodeRef) == B_OK) { ++ openCommand.AddData("nodeRefToSelect", B_RAW_TYPE, ++ static_cast(&fileNodeRef), sizeof(node_ref)); ++ } ++ if (trackerMessenger.SendMessage(&openCommand) == B_OK) { ++ snooze(300000); ++ BMessage selectCommand('Tsel'); ++ selectCommand.AddRef("refs", &fileRef); ++ trackerMessenger.SendMessage(&selectCommand); ++ return true; ++ } ++ } catch (...) { ++ } ++ ++ return false; ++} ++#endif + + #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION + bool PortalShowInFolder(const QString &filepath) { +@@ -152,6 +202,12 @@ bool ShowInFolder(const QString &filepath) { + return true; + } + ++#ifdef Q_OS_HAIKU ++ if (HaikuShowInFolder(filepath)) { ++ return true; ++ } ++#endif ++ + if (ProcessShowInFolder(filepath)) { + return true; + } +diff --git a/base/platform/linux/base_last_input_linux.cpp b/base/platform/linux/base_last_input_linux.cpp +index 1021c85..fd6e541 100644 +--- a/base/platform/linux/base_last_input_linux.cpp ++++ b/base/platform/linux/base_last_input_linux.cpp +@@ -24,6 +24,11 @@ + #include + #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION + ++#ifdef Q_OS_HAIKU ++#include ++#include ++#endif ++ + namespace base::Platform { + namespace { + +@@ -184,9 +189,23 @@ std::optional MutterDBusLastUserInputTime() { + } + #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + ++#ifdef Q_OS_HAIKU ++std::optional HaikuLastUserInputTime() { ++ const auto idle = idle_time() / 1000; ++ return (crl::now() - static_cast(idle)); ++} ++#endif ++ + } // namespace + + std::optional LastUserInputTime() { ++#ifdef Q_OS_HAIKU ++ const auto haikuResult = HaikuLastUserInputTime(); ++ if (haikuResult.has_value()) { ++ return haikuResult; ++ } ++#endif ++ + #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION + if (::Platform::IsX11()) { + const auto xcbResult = XCBLastUserInputTime(); +diff --git a/base/platform/linux/base_url_scheme_linux.cpp b/base/platform/linux/base_url_scheme_linux.cpp +index 20aed5e..61d46fc 100644 +--- a/base/platform/linux/base_url_scheme_linux.cpp ++++ b/base/platform/linux/base_url_scheme_linux.cpp +@@ -13,6 +13,10 @@ + #include "base/platform/linux/base_linux_glibmm_helper.h" + #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + ++#ifdef Q_OS_HAIKU ++#include ++#endif ++ + #include + #include + #include +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/lib_ui-1.4.4.patchset b/net-im/kotatogram-desktop/patches/lib_ui-1.4.4.patchset new file mode 100644 index 000000000..95baa18a6 --- /dev/null +++ b/net-im/kotatogram-desktop/patches/lib_ui-1.4.4.patchset @@ -0,0 +1,40 @@ +From 4abc5f9628b9b0e9a82aec9de03a0a43abf3618e Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:18:12 +1000 +Subject: Fixes for Haiku + + +diff --git a/ui/platform/linux/ui_utility_linux.cpp b/ui/platform/linux/ui_utility_linux.cpp +index 87c3c04..9d1ef4f 100644 +--- a/ui/platform/linux/ui_utility_linux.cpp ++++ b/ui/platform/linux/ui_utility_linux.cpp +@@ -612,7 +612,7 @@ TitleControls::Layout TitleControlsLayout() { + } + #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + return TitleControls::Layout{ + .left = { + TitleControls::Control::Close, +@@ -622,7 +622,7 @@ TitleControls::Layout TitleControlsLayout() { + TitleControls::Control::Maximize, + } + }; +-#else // __HAIKU__ ++#else // Q_OS_HAIKU + return TitleControls::Layout{ + .right = { + TitleControls::Control::Minimize, +@@ -630,7 +630,7 @@ TitleControls::Layout TitleControlsLayout() { + TitleControls::Control::Close, + } + }; +-#endif // !__HAIKU__ ++#endif // !Q_OS_HAIKU + } + + } // namespace Platform +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/lib_webrtc-1.4.4.patchset b/net-im/kotatogram-desktop/patches/lib_webrtc-1.4.4.patchset new file mode 100644 index 000000000..2b5538e4a --- /dev/null +++ b/net-im/kotatogram-desktop/patches/lib_webrtc-1.4.4.patchset @@ -0,0 +1,41 @@ +From d65252fda59ee58fc8e913be59358b42b34e3a32 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:19:20 +1000 +Subject: Fixes for Haiku + + +diff --git a/webrtc/details/webrtc_openal_adm.cpp b/webrtc/details/webrtc_openal_adm.cpp +index 8aa87d7..19deeff 100644 +--- a/webrtc/details/webrtc_openal_adm.cpp ++++ b/webrtc/details/webrtc_openal_adm.cpp +@@ -4,6 +4,11 @@ + // For license and copyright information please follow this link: + // https://github.com/desktop-app/legal/blob/master/LEGAL + // ++ ++#ifdef Q_OS_HAIKU ++#include ++#endif ++ + #include "webrtc/details/webrtc_openal_adm.h" + + #include "base/timer.h" +diff --git a/webrtc/webrtc_audio_input_tester.cpp b/webrtc/webrtc_audio_input_tester.cpp +index 092b667..204e259 100644 +--- a/webrtc/webrtc_audio_input_tester.cpp ++++ b/webrtc/webrtc_audio_input_tester.cpp +@@ -4,6 +4,11 @@ + // For license and copyright information please follow this link: + // https://github.com/desktop-app/legal/blob/master/LEGAL + // ++ ++#ifdef Q_OS_HAIKU ++#include ++#endif ++ + #include "webrtc/webrtc_audio_input_tester.h" + + #include "webrtc/webrtc_create_adm.h" +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/libtgvoip-1.4.4.patchset b/net-im/kotatogram-desktop/patches/libtgvoip-1.4.4.patchset new file mode 100644 index 000000000..836cc76a8 --- /dev/null +++ b/net-im/kotatogram-desktop/patches/libtgvoip-1.4.4.patchset @@ -0,0 +1,887 @@ +From 4f1be262da4a9901dc7129c5340290c9f6770dec Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:14:40 +1000 +Subject: Add Haiku support + + +diff --git a/VoIPController.cpp b/VoIPController.cpp +index 22978e3..264cbee 100644 +--- a/VoIPController.cpp ++++ b/VoIPController.cpp +@@ -8,6 +8,9 @@ + #include + #include + #endif ++#ifdef __HAIKU__ ++#include ++#endif + #include + #include + #include +@@ -3009,6 +3012,10 @@ double VoIPController::GetCurrentTime(){ + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec+(double)ts.tv_nsec/1000000000.0; ++#elif defined(__HAIKU__) ++ struct timeval tm; ++ gettimeofday(&tm, NULL); ++ return tm.tv_sec+(double)tm.tv_usec/1000000.0; + #elif defined(__APPLE__) + static pthread_once_t token = PTHREAD_ONCE_INIT; + pthread_once(&token, &initMachTimestart); +diff --git a/audio/AudioIO.cpp b/audio/AudioIO.cpp +index 29d5ad9..994d938 100644 +--- a/audio/AudioIO.cpp ++++ b/audio/AudioIO.cpp +@@ -39,6 +39,9 @@ + #ifndef WITHOUT_PULSE + #include "../os/linux/AudioPulse.h" + #endif ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioInputHaiku.h" ++#include "../os/haiku/AudioOutputHaiku.h" + #else + #error "Unsupported operating system" + #endif +@@ -65,6 +68,8 @@ AudioIO* AudioIO::Create(std::string inputDevice, std::string outputDevice){ + return new ContextlessAudioIO(inputDevice, outputDevice); + #endif + return new ContextlessAudioIO(inputDevice, outputDevice); ++#elif defined(__HAIKU__) ++ return new ContextlessAudioIO(); + #elif defined(__linux__) || defined(__FreeBSD__) + #ifndef WITHOUT_ALSA + #ifndef WITHOUT_PULSE +diff --git a/audio/AudioInput.cpp b/audio/AudioInput.cpp +index efdc535..12fbc5a 100644 +--- a/audio/AudioInput.cpp ++++ b/audio/AudioInput.cpp +@@ -33,6 +33,8 @@ + #ifndef WITHOUT_PULSE + #include "../os/linux/AudioPulse.h" + #endif ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioInputHaiku.h" + #else + #error "Unsupported operating system" + #endif +diff --git a/audio/AudioOutput.cpp b/audio/AudioOutput.cpp +index 3f88799..97820b6 100644 +--- a/audio/AudioOutput.cpp ++++ b/audio/AudioOutput.cpp +@@ -37,6 +37,8 @@ + #include "../os/linux/AudioOutputPulse.h" + #include "../os/linux/AudioPulse.h" + #endif ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioOutputHaiku.h" + #else + #error "Unsupported operating system" + #endif +diff --git a/os/haiku/AudioInputHaiku.cpp b/os/haiku/AudioInputHaiku.cpp +new file mode 100644 +index 0000000..7cce3e3 +--- /dev/null ++++ b/os/haiku/AudioInputHaiku.cpp +@@ -0,0 +1,276 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++#include ++#include ++#include ++#include ++#include "AudioInputHaiku.h" ++#include "../../logging.h" ++#include "../../audio/Resampler.h" ++#include "../../VoIPController.h" ++ ++#include "RingBuffer.h" ++ ++using namespace tgvoip::audio; ++ ++void RecordData(void* cookie, bigtime_t timestamp, void* data, size_t size, const media_format &format) ++{ ++ AudioInputHaiku *audioInput = (AudioInputHaiku*)cookie; ++ if (!audioInput->IsRecording()) ++ return; ++ ++ if (format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_SHORT && ++ format.u.raw_audio.channel_count == 1) { ++ audioInput->fRingBuffer->Write((unsigned char*)data, size); ++ return; ++ } ++ ++ uint32 bytesPerSample = 2; ++ switch (format.u.raw_audio.format) { ++ case media_raw_audio_format::B_AUDIO_CHAR: ++ bytesPerSample = 1; ++ break; ++ case media_raw_audio_format::B_AUDIO_SHORT: ++ bytesPerSample = 2; ++ break; ++ case media_raw_audio_format::B_AUDIO_INT: ++ bytesPerSample = 4; ++ break; ++ case media_raw_audio_format::B_AUDIO_FLOAT: ++ bytesPerSample = 4; ++ break; ++ default: ++ break; ++ } ++ ++ int frames = size / (format.u.raw_audio.channel_count * bytesPerSample); ++ int16_t *dst = audioInput->workBuffer; ++ ++ if (format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_CHAR) { ++ unsigned char* src=reinterpret_cast(data); ++ for (int n=0; n < frames; n++) { ++ int32_t value = 0; ++ for (int j=0; j < format.u.raw_audio.channel_count; j++, src++) { ++ value += ((int32_t)(*src) - INT8_MAX) * UINT8_MAX; ++ } ++ value /= format.u.raw_audio.channel_count; ++ dst[n] = (int16_t)value; ++ } ++ } else if (format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_SHORT) { ++ int16_t* src=reinterpret_cast(data); ++ for (int n=0; n < frames; n++) { ++ int32_t value = 0; ++ for (int j=0; j < format.u.raw_audio.channel_count; j++, src++) { ++ value += *src; ++ } ++ value /= format.u.raw_audio.channel_count; ++ dst[n] = (int16_t)value; ++ } ++ } else if (format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_INT) { ++ int32_t* src=reinterpret_cast(data); ++ for (int n=0; n < frames; n++) { ++ int64_t value = 0; ++ for (int j=0; j < format.u.raw_audio.channel_count; j++, src++) { ++ value += (int64_t)(*src); ++ } ++ value /= format.u.raw_audio.channel_count; ++ dst[n] = (int16_t)(value / (UINT16_MAX + 1)); ++ } ++ } else if (format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_FLOAT) { ++ float* src=reinterpret_cast(data); ++ for (int n=0; n < frames; n++) { ++ float value = 0; ++ for (int j=0; j < format.u.raw_audio.channel_count; j++, src++) { ++ value += *src; ++ } ++ value /= format.u.raw_audio.channel_count; ++ dst[n] = (int16_t)(value*INT16_MAX); ++ } ++ } ++ ++ if(format.u.raw_audio.frame_rate != audioInput->tgFrameRate) { ++ size_t len = tgvoip::audio::Resampler::Convert(dst, audioInput->convertBuffer, ++ frames, frames, audioInput->tgFrameRate, format.u.raw_audio.frame_rate) * audioInput->tgBytesPerSample; ++ audioInput->fRingBuffer->Write((unsigned char*)audioInput->convertBuffer, len); ++ } else { ++ audioInput->fRingBuffer->Write((unsigned char*)dst, frames * audioInput->tgBytesPerSample); ++ } ++} ++ ++void NotifyRecordData(void * cookie, BMediaRecorder::notification code, ...) ++{ ++ AudioInputHaiku *audioInput = (AudioInputHaiku*)cookie; ++ if (code == BMediaRecorder::B_WILL_STOP) { ++ if (audioInput->IsRecording()) { ++ audioInput->Stop(); ++ } ++ } ++} ++ ++AudioInputHaiku::AudioInputHaiku() ++{ ++ fRecorder = NULL; ++ fRingBuffer = NULL; ++ isRecording = false; ++ ++ tgFrameRate = 48000; ++ tgChannelsCount = 1; ++ tgBytesPerSample = 2; ++ ++ status_t error; ++ ++ fRoster = BMediaRoster::Roster(&error); ++ if (!fRoster) { ++ failed=true; ++ return; ++ } ++ error = fRoster->GetAudioInput(&fAudioInputNode); ++ if (error < B_OK) { ++ failed=true; ++ return; ++ } ++ error = fRoster->GetAudioMixer(&fAudioMixerNode); ++ if (error < B_OK) { ++ failed=true; ++ return; ++ } ++ fRecorder = new BMediaRecorder("Telegram", B_MEDIA_RAW_AUDIO); ++ if (fRecorder->InitCheck() < B_OK) { ++ failed=true; ++ return; ++ } ++ media_format output_format; ++ output_format.type = B_MEDIA_RAW_AUDIO; ++ output_format.u.raw_audio = media_raw_audio_format::wildcard; ++ output_format.u.raw_audio.channel_count = 1; ++ fRecorder->SetAcceptedFormat(output_format); ++ ++ const int maxInputCount = 64; ++ dormant_node_info dni[maxInputCount]; ++ ++ int32 real_count = maxInputCount; ++ ++ error = fRoster->GetDormantNodes(dni, &real_count, 0, &output_format, 0, B_BUFFER_PRODUCER | B_PHYSICAL_INPUT); ++ if (real_count > maxInputCount) ++ real_count = maxInputCount; ++ char selected_name[B_MEDIA_NAME_LENGTH] = "Default input"; ++ ++ for (int i = 0; i < real_count; i++) { ++ media_node_id ni[12]; ++ int32 ni_count = 12; ++ error = fRoster->GetInstancesFor(dni[i].addon, dni[i].flavor_id, ni, &ni_count); ++ if (error == B_OK) { ++ for (int j = 0; j < ni_count; j++) { ++ if (ni[j] == fAudioInputNode.node) { ++ strcpy(selected_name, dni[i].name); ++ break; ++ } ++ } ++ } ++ } ++ ++ media_output audioOutput; ++ if (!fRecorder->IsConnected()) { ++ int32 count = 0; ++ error = fRoster->GetFreeOutputsFor(fAudioInputNode, &audioOutput, 1, &count, B_MEDIA_RAW_AUDIO); ++ if (error < B_OK) { ++ failed=true; ++ return; ++ } ++ ++ if (count < 1) { ++ failed=true; ++ return; ++ } ++ fRecordFormat.u.raw_audio = audioOutput.format.u.raw_audio; ++ } else { ++ fRecordFormat.u.raw_audio = fRecorder->AcceptedFormat().u.raw_audio; ++ } ++ fRecordFormat.type = B_MEDIA_RAW_AUDIO; ++ ++ error = fRecorder->SetHooks(RecordData, NotifyRecordData, this); ++ if (error < B_OK) { ++ failed=true; ++ return; ++ } ++ ++ if (!fRecorder->IsConnected()) { ++ error = fRecorder->Connect(fAudioInputNode, &audioOutput, &fRecordFormat); ++ if (error < B_OK) { ++ fRecorder->SetHooks(NULL, NULL, NULL); ++ failed=true; ++ return; ++ } ++ } ++ ++ fRingBuffer = new RingBuffer(BUFFER_SIZE * 2 * 3); ++ if (fRingBuffer->InitCheck() != B_OK) { ++ failed=true; ++ return; ++ } ++} ++ ++AudioInputHaiku::~AudioInputHaiku(){ ++ if (fRecorder != NULL) { ++ if (fRecorder->InitCheck() == B_OK) { ++ if (fRecorder->IsConnected()) ++ fRecorder->Disconnect(); ++ } ++ delete fRecorder; ++ } ++ if (fRingBuffer != NULL) ++ delete fRingBuffer; ++} ++ ++void AudioInputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ ++ tgFrameRate = sampleRate; ++ tgChannelsCount = channels; ++ tgBytesPerSample = bitsPerSample / 8; ++} ++ ++bool AudioInputHaiku::IsRecording(){ ++ return isRecording; ++} ++ ++void AudioInputHaiku::Start(){ ++ if(failed || isRecording) ++ return; ++ ++ isRecording=true; ++ ++ thread = new Thread(std::bind(&AudioInputHaiku::RunThread, this)); ++ thread->SetName("AudioInputHaiku"); ++ thread->Start(); ++ ++ fRecorder->Start(); ++} ++ ++void AudioInputHaiku::Stop(){ ++ if(!isRecording) ++ return; ++ ++ isRecording=false; ++ ++ fRecorder->Stop(); ++ ++ thread->Join(); ++ delete thread; ++ thread=NULL; ++} ++ ++void AudioInputHaiku::RunThread(){ ++ unsigned char buffer[BUFFER_SIZE*2]; ++ while (isRecording){ ++ if (fRingBuffer->GetReadAvailable() >= sizeof(buffer)) { ++ int readed = fRingBuffer->Read(buffer, sizeof(buffer)); ++ if (readed < sizeof(buffer)) ++ memset(buffer + readed, 0, sizeof(buffer) - readed); ++ InvokeCallback(buffer, sizeof(buffer)); ++ } else ++ snooze(100); ++ } ++} +diff --git a/os/haiku/AudioInputHaiku.h b/os/haiku/AudioInputHaiku.h +new file mode 100644 +index 0000000..1c63afe +--- /dev/null ++++ b/os/haiku/AudioInputHaiku.h +@@ -0,0 +1,66 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++#ifndef LIBTGVOIP_AUDIOINPUTHAIKU_H ++#define LIBTGVOIP_AUDIOINPUTHAIKU_H ++ ++#include "../../audio/AudioInput.h" ++#include "../../threading.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "RingBuffer.h" ++ ++#define BUFFER_SIZE 960 ++ ++namespace tgvoip{ ++namespace audio{ ++ ++class AudioInputHaiku : public AudioInput{ ++ ++public: ++ AudioInputHaiku(); ++ virtual ~AudioInputHaiku(); ++ virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); ++ virtual void Start(); ++ virtual void Stop(); ++ virtual bool IsRecording(); ++ ++ RingBuffer *fRingBuffer; ++ int16_t workBuffer[BUFFER_SIZE * 64]; ++ int16_t convertBuffer[BUFFER_SIZE * 64]; ++ ++ uint32 tgFrameRate; ++ uint32 tgChannelsCount; ++ uint32 tgBytesPerSample; ++ ++private: ++ void RunThread(); ++ ++ bool isConfigured; ++ bool isRecording; ++ ++ BMediaRoster * fRoster; ++ BMediaRecorder * fRecorder; ++ media_format fRecordFormat; ++ media_node fAudioInputNode; ++ media_node fAudioMixerNode; ++ ++ Thread* thread; ++}; ++ ++} ++} ++ ++#endif //LIBTGVOIP_AUDIOINPUTHAIKU_H +diff --git a/os/haiku/AudioOutputHaiku.cpp b/os/haiku/AudioOutputHaiku.cpp +new file mode 100644 +index 0000000..2fca8a1 +--- /dev/null ++++ b/os/haiku/AudioOutputHaiku.cpp +@@ -0,0 +1,99 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++ ++#include ++#include ++#include "AudioOutputHaiku.h" ++#include "../../logging.h" ++#include "../../VoIPController.h" ++ ++#define BUFFER_SIZE 960 ++ ++using namespace tgvoip::audio; ++ ++static void playerProc(void *cookie, void *buffer, size_t len, const media_raw_audio_format &format) ++{ ++ AudioOutputHaiku *obj = (AudioOutputHaiku*)cookie; ++ obj->InvokeCallback((unsigned char*)buffer, len); ++} ++ ++ ++AudioOutputHaiku::AudioOutputHaiku(){ ++ soundPlayer = NULL; ++ isPlaying = false; ++ isConfigured = false; ++ Configure(48000, 16, 1); ++ return; ++} ++ ++AudioOutputHaiku::~AudioOutputHaiku(){ ++ if (isConfigured) { ++ if (soundPlayer != NULL) { ++ soundPlayer->Stop(); ++ delete soundPlayer; ++ } ++ } ++} ++ ++void AudioOutputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ ++ media_raw_audio_format mediaKitFormat = { ++ (float)sampleRate, ++ (uint32)channels, ++ media_raw_audio_format::B_AUDIO_SHORT, ++ B_MEDIA_LITTLE_ENDIAN, ++ (uint32)BUFFER_SIZE * (bitsPerSample / 8) * channels ++ }; ++ ++ switch (bitsPerSample) { ++ case 8: ++ mediaKitFormat.format = media_raw_audio_format::B_AUDIO_CHAR; ++ break; ++ case 16: ++ mediaKitFormat.format = media_raw_audio_format::B_AUDIO_SHORT; ++ break; ++ case 32: ++ mediaKitFormat.format = media_raw_audio_format::B_AUDIO_INT; ++ break; ++ default: ++ mediaKitFormat.format = media_raw_audio_format::B_AUDIO_SHORT; ++ break; ++ } ++ ++ soundPlayer = new BSoundPlayer(&mediaKitFormat, "Telegram", playerProc, NULL, (void*)this); ++ ++ if(soundPlayer->InitCheck() != B_OK) { ++ delete soundPlayer; ++ soundPlayer = NULL; ++ isPlaying = false; ++ failed = true; ++ return; ++ } ++ ++ isConfigured = true; ++} ++ ++void AudioOutputHaiku::Start(){ ++ if(soundPlayer == NULL || isPlaying) ++ return; ++ ++ soundPlayer->Start(); ++ soundPlayer->SetHasData(true); ++ ++ isPlaying=true; ++} ++ ++void AudioOutputHaiku::Stop(){ ++ if(!isPlaying) ++ return; ++ ++ soundPlayer->Stop(); ++ isPlaying=false; ++} ++ ++bool AudioOutputHaiku::IsPlaying(){ ++ return isPlaying; ++} +diff --git a/os/haiku/AudioOutputHaiku.h b/os/haiku/AudioOutputHaiku.h +new file mode 100644 +index 0000000..91f2521 +--- /dev/null ++++ b/os/haiku/AudioOutputHaiku.h +@@ -0,0 +1,35 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++#ifndef LIBTGVOIP_AUDIOOUTPUTHAIKU_H ++#define LIBTGVOIP_AUDIOOUTPUTHAIKU_H ++ ++#include "../../audio/AudioOutput.h" ++#include "../../threading.h" ++ ++#include ++ ++namespace tgvoip{ ++namespace audio{ ++ ++class AudioOutputHaiku : public AudioOutput{ ++public: ++ AudioOutputHaiku(); ++ virtual ~AudioOutputHaiku(); ++ virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); ++ virtual void Start(); ++ virtual void Stop(); ++ virtual bool IsPlaying() override; ++private: ++ bool isPlaying; ++ bool isConfigured; ++ BSoundPlayer *soundPlayer; ++}; ++ ++} ++} ++ ++#endif //LIBTGVOIP_AUDIOOUTPUTHAIKU_H +diff --git a/os/haiku/RingBuffer.cpp b/os/haiku/RingBuffer.cpp +new file mode 100644 +index 0000000..6c94933 +--- /dev/null ++++ b/os/haiku/RingBuffer.cpp +@@ -0,0 +1,136 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++#include ++#include ++#include ++#include ++ ++#include "RingBuffer.h" ++ ++RingBuffer::RingBuffer( int size ) ++{ ++ initialized = false; ++ Buffer = new unsigned char[size]; ++ if(Buffer!=NULL) { ++ memset( Buffer, 0, size ); ++ BufferSize = size; ++ } else { ++ BufferSize = 0; ++ } ++ reader = 0; ++ writer = 0; ++ writeBytesAvailable = size; ++ if((locker=create_sem(1,"locker")) >= B_OK) { ++ initialized = true; ++ } else { ++ if(Buffer!=NULL) { ++ delete[] Buffer; ++ } ++ } ++} ++ ++RingBuffer::~RingBuffer( ) ++{ ++ if(initialized) { ++ delete[] Buffer; ++ delete_sem(locker); ++ } ++} ++ ++bool ++RingBuffer::Empty( void ) ++{ ++ memset( Buffer, 0, BufferSize ); ++ reader = 0; ++ writer = 0; ++ writeBytesAvailable = BufferSize; ++ return true; ++} ++ ++int ++RingBuffer::Read( unsigned char *data, int size ) ++{ ++ acquire_sem(locker); ++ ++ if( data == 0 || size <= 0 || writeBytesAvailable == BufferSize ) { ++ release_sem(locker); ++ return 0; ++ } ++ ++ int readBytesAvailable = BufferSize - writeBytesAvailable; ++ ++ if( size > readBytesAvailable ) { ++ size = readBytesAvailable; ++ } ++ ++ if(size > BufferSize - reader) { ++ int len = BufferSize - reader; ++ memcpy(data, Buffer + reader, len); ++ memcpy(data + len, Buffer, size-len); ++ } else { ++ memcpy(data, Buffer + reader, size); ++ } ++ ++ reader = (reader + size) % BufferSize; ++ writeBytesAvailable += size; ++ ++ release_sem(locker); ++ return size; ++} ++ ++int ++RingBuffer::Write( unsigned char *data, int size ) ++{ ++ acquire_sem(locker); ++ ++ if( data == 0 || size <= 0 || writeBytesAvailable == 0 ) { ++ release_sem(locker); ++ return 0; ++ } ++ ++ if( size > writeBytesAvailable ) { ++ size = writeBytesAvailable; ++ } ++ ++ if(size > BufferSize - writer) { ++ int len = BufferSize - writer; ++ memcpy(Buffer + writer, data, len); ++ memcpy(Buffer, data+len, size-len); ++ } else { ++ memcpy(Buffer + writer, data, size); ++ } ++ ++ writer = (writer + size) % BufferSize; ++ writeBytesAvailable -= size; ++ ++ release_sem(locker); ++ return size; ++} ++ ++int ++RingBuffer::GetSize( void ) ++{ ++ return BufferSize; ++} ++ ++int ++RingBuffer::GetWriteAvailable( void ) ++{ ++ return writeBytesAvailable; ++} ++ ++int ++RingBuffer::GetReadAvailable( void ) ++{ ++ return BufferSize - writeBytesAvailable; ++} ++ ++status_t ++RingBuffer::InitCheck( void ) ++{ ++ return initialized?B_OK:B_ERROR; ++} +diff --git a/os/haiku/RingBuffer.h b/os/haiku/RingBuffer.h +new file mode 100644 +index 0000000..01f6096 +--- /dev/null ++++ b/os/haiku/RingBuffer.h +@@ -0,0 +1,37 @@ ++// ++// libtgvoip is free and unencumbered public domain software. ++// For more information, see http://unlicense.org or the UNLICENSE file ++// you should have received with this source code distribution. ++// ++ ++#ifndef __RING_BUFFER_H__ ++#define __RING_BUFFER_H__ ++ ++#include ++ ++class RingBuffer { ++ ++public: ++ RingBuffer(int size); ++ ~RingBuffer(); ++ int Read( unsigned char* dataPtr, int numBytes ); ++ int Write( unsigned char *dataPtr, int numBytes ); ++ ++ bool Empty( void ); ++ int GetSize( ); ++ int GetWriteAvailable( ); ++ int GetReadAvailable( ); ++ status_t InitCheck( ); ++private: ++ unsigned char *Buffer; ++ int BufferSize; ++ int reader; ++ int writer; ++ int writeBytesAvailable; ++ ++ sem_id locker; ++ ++ bool initialized; ++}; ++ ++#endif +diff --git a/os/posix/NetworkSocketPosix.cpp b/os/posix/NetworkSocketPosix.cpp +index 78e0583..81bf9fc 100644 +--- a/os/posix/NetworkSocketPosix.cpp ++++ b/os/posix/NetworkSocketPosix.cpp +@@ -248,12 +248,13 @@ void NetworkSocketPosix::Open(){ + } + int flag=0; + int res=setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag)); ++#ifndef __HAIKU__ + if(res<0){ + LOGE("error enabling dual stack socket: %d / %s", errno, strerror(errno)); + failed=true; + return; + } +- ++#endif + SetMaxPriority(); + fcntl(fd, F_SETFL, O_NONBLOCK); + +@@ -403,6 +404,8 @@ std::string NetworkSocketPosix::GetLocalInterfaceInfo(IPv4Address *v4addr, IPv6A + if(didAttach){ + sharedJVM->DetachCurrentThread(); + } ++#elif defined(__HAIKU__) ++ return name; + #else + struct ifaddrs* interfaces; + if(!getifaddrs(&interfaces)){ +diff --git a/threading.h b/threading.h +old mode 100755 +new mode 100644 +index 37de500..2017b83 +--- a/threading.h ++++ b/threading.h +@@ -9,7 +9,7 @@ + + #include + +-#if defined(_POSIX_THREADS) || defined(_POSIX_VERSION) || defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) ++#if defined(_POSIX_THREADS) || defined(_POSIX_VERSION) || defined(__unix__) || defined(__unix) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) + + #include + #include +@@ -95,6 +95,7 @@ namespace tgvoip{ + static void* ActualEntryPoint(void* arg){ + Thread* self=reinterpret_cast(arg); + if(self->name){ ++#ifndef __HAIKU__ + #if defined(__linux__) || defined(__FreeBSD__) + pthread_setname_np(self->thread, self->name); + #elif defined(__APPLE__) +@@ -103,6 +104,7 @@ namespace tgvoip{ + DarwinSpecific::SetCurrentThreadPriority(DarwinSpecific::THREAD_PRIO_USER_INTERACTIVE); + } + #endif ++#endif //__HAIKU__ + } + self->entry(); + return NULL; +diff --git a/webrtc_dsp/rtc_base/logging_webrtc.cc b/webrtc_dsp/rtc_base/logging_webrtc.cc +old mode 100755 +new mode 100644 +index a8d1522..991241b +--- a/webrtc_dsp/rtc_base/logging_webrtc.cc ++++ b/webrtc_dsp/rtc_base/logging_webrtc.cc +@@ -28,6 +28,10 @@ + static const int kMaxLogLineSize = 1024 - 60; + #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) || WEBRTC_ANDROID + ++#if defined(WEBRTC_HAIKU) ++#include ++#endif ++ + #include + #include + #include +@@ -120,7 +124,12 @@ LogMessage::LogMessage(const char* file, + + if (thread_) { + PlatformThreadId id = CurrentThreadId(); ++#if defined(WEBRTC_HAIKU) ++ thread_id tid = get_pthread_thread_id(id); ++ print_stream_ << "[" << tid << "] "; ++#else + print_stream_ << "[" << id << "] "; ++#endif + } + + if (file != nullptr) { +diff --git a/webrtc_dsp/rtc_base/platform_file.h b/webrtc_dsp/rtc_base/platform_file.h +old mode 100755 +new mode 100644 +diff --git a/webrtc_dsp/rtc_base/platform_thread_types.cc b/webrtc_dsp/rtc_base/platform_thread_types.cc +index cf7d478..f27b9a1 100644 +--- a/webrtc_dsp/rtc_base/platform_thread_types.cc ++++ b/webrtc_dsp/rtc_base/platform_thread_types.cc +@@ -20,6 +20,8 @@ namespace rtc { + PlatformThreadId CurrentThreadId() { + #if defined(WEBRTC_WIN) + return GetCurrentThreadId(); ++#elif defined(WEBRTC_HAIKU) ++ return pthread_self(); + #elif defined(WEBRTC_POSIX) + #if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) + return pthread_mach_thread_np(pthread_self()); +diff --git a/webrtc_dsp/rtc_base/platform_thread_types.h b/webrtc_dsp/rtc_base/platform_thread_types.h +index 0bc42eb..c87cde9 100644 +--- a/webrtc_dsp/rtc_base/platform_thread_types.h ++++ b/webrtc_dsp/rtc_base/platform_thread_types.h +@@ -35,6 +35,9 @@ typedef DWORD PlatformThreadRef; + #elif defined(WEBRTC_FUCHSIA) + typedef zx_handle_t PlatformThreadId; + typedef zx_handle_t PlatformThreadRef; ++#elif defined(WEBRTC_HAIKU) ++typedef pthread_t PlatformThreadId; ++typedef pthread_t PlatformThreadRef; + #elif defined(WEBRTC_POSIX) + typedef pid_t PlatformThreadId; + typedef pthread_t PlatformThreadRef; +-- +2.30.2 + diff --git a/net-im/kotatogram-desktop/patches/tgcalls-1.4.4.patchset b/net-im/kotatogram-desktop/patches/tgcalls-1.4.4.patchset new file mode 100644 index 000000000..a813ba39f --- /dev/null +++ b/net-im/kotatogram-desktop/patches/tgcalls-1.4.4.patchset @@ -0,0 +1,44 @@ +From d709b1c94721cae577710164b7640d1d42b7cda4 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Wed, 10 Nov 2021 18:11:20 +1000 +Subject: Fixes for Haiku + + +diff --git a/tgcalls/MediaManager.cpp b/tgcalls/MediaManager.cpp +index fd81ab1..73cdc47 100644 +--- a/tgcalls/MediaManager.cpp ++++ b/tgcalls/MediaManager.cpp +@@ -964,7 +964,7 @@ void MediaManager::fillCallStats(CallStats &callStats) { + } + + void MediaManager::setAudioInputDevice(std::string id) { +-#if defined(WEBRTC_IOS) ++#if defined(WEBRTC_IOS) || defined(__HAIKU__) + #else + SetAudioInputDeviceById(_audioDeviceModule.get(), id); + #endif +diff --git a/tgcalls/group/GroupInstanceCustomImpl.cpp b/tgcalls/group/GroupInstanceCustomImpl.cpp +index b3fcaea..6a7ac01 100644 +--- a/tgcalls/group/GroupInstanceCustomImpl.cpp ++++ b/tgcalls/group/GroupInstanceCustomImpl.cpp +@@ -2791,7 +2791,7 @@ public: + } + + void setAudioOutputDevice(const std::string &id) { +-#ifndef WEBRTC_IOS ++#if !defined(WEBRTC_IOS) && !defined(__HAIKU__) + _threads->getWorkerThread()->Invoke(RTC_FROM_HERE, [&] { + SetAudioOutputDeviceById(_audioDeviceModule.get(), id); + }); +@@ -2799,7 +2799,7 @@ public: + } + + void setAudioInputDevice(const std::string &id) { +-#ifndef WEBRTC_IOS ++#if !defined(WEBRTC_IOS) && !defined(__HAIKU__) + _threads->getWorkerThread()->Invoke(RTC_FROM_HERE, [&] { + SetAudioInputDeviceById(_audioDeviceModule.get(), id); + }); +-- +2.30.2 +