diff --git a/net-im/telegram-desktop/additional-files/tdesktop.rdef.in b/net-im/telegram-desktop/additional-files/tdesktop.rdef.in new file mode 100644 index 000000000..8e47b824c --- /dev/null +++ b/net-im/telegram-desktop/additional-files/tdesktop.rdef.in @@ -0,0 +1,43 @@ + +resource app_flags B_SINGLE_LAUNCH | B_ARGV_ONLY; + +resource app_version { + major = @MAJOR@, + middle = @MIDDLE@, + minor = @MINOR@, + + variety = B_APPV_FINAL, + internal = 0, + + short_info = "Telegram", + long_info = "@LONG_INFO@" +}; + +resource app_signature "@APP_SIGNATURE@"; + +resource vector_icon { + $"6E63696604031D93CF03EBF5FB03C1D7E9039DBFD605000BBF08B41EBF08B41E" + $"C1B3B3EDC68BB65DC46AB4C2C883B7D2CAAABC47C9FBB9EECB6CBEC4CA41C3E7" + $"CB43C183C936C673C4B9C9C9C732C893C2BDCABDBE4ACAD8C079CB24BC4CCA99" + $"B8C8C899BA5FC9D3B70FC74AB4FDC374B5BCC57CB450C196B473BD98B41BBF8D" + $"B4E7BAD4B8A2B68BB670B846BA74B51ABF08B41EBCB6B43DBF08B41E020FC499" + $"BA94C4DBBA77C0DABBFCB963BED9BD20BD70B90FBEF9B86DBF44B8BABF17B81B" + $"BF6AB87FC00DB828BFF5B984C068BB90C11ABA87C0C9BBF6C249BCB6C4ACBC4E" + $"C37EBCC7C4D0BD05C50CBCD4C50DBD05C50CBD04C526BD04C526BD4FC528BDB0" + $"C4BBBD7DC4E7BE37C442BF4D49BEC0C3C9C035C3FEC200C555C11AC4A9C23BC5" + $"7FC2CFC598C283C5B2C31AC586C344C4F4C333C536C404C203C52FBC0CC4B1BF" + $"0CC53CBBA84EBADEC55BBB44C53FBA8F0212C499BA94C0DABBFCC4DBBA774EBA" + $"DEC53FBA8FC55BBB44C52FBC0CC53CBBA8C4B1BF0CC344C4F4C404C203C333C5" + $"36C2CFC598C31AC586C283C5B2C200C555C23BC57FC11AC4A9BF4D49C035C3FE" + $"BEACC2DDBD69C1F2BE0EC264BD89C1B2BDFAC15ABDC9C18BBF04C05EC11FBE70" + $"C015BF6BC1AFBDFCC2BBBCF9C228BD6CC2E0BCD2C31EBC76C31EBCB3C2D9BC76" + $"C26CBCC3C2A3BCA1C09CBDEFBCF9C03FBEC9BF14BC80C086BB90C11ABC10C0DE" + $"BA87C0C9B87FC00DB984C068B828BFF5B86DBF44B81BBF6AB8BABF17B963BED9" + $"B90FBEF9BD20BD70020AC26CBCC3C09CBDEFC2A3BCA1C31EBC76C2D9BC76C31E" + $"BCB3C2BBBCF9C2E0BCD2C228BD6CC11FBE70C1AFBDFCC015BF6BBDFAC15ABF04" + $"C05EBDC9C18BBD69C1F2BD89C1B2BD35C2F8BD05C50CBD21C404BCD4C50DBCB6" + $"C4ACBCC7C4D0BC4EC37EBB90C11ABBF6C249BC10C0DEBCF9C03FBC80C086BEC9" + $"BF140205BD69C1F2BD35C2F8BE0EC264BF4D49BEACC2DDBEC0C3C9BDB0C4BBBE" + $"37C442BD7DC4E7BD04C526BD4FC528BD04C526BD05C50CBD05C50CBD21C40404" + $"0A00020001000A010102000A020103000A03010400" +}; diff --git a/net-im/telegram-desktop/patches/tdesktop-1.1.23-libtgvoip.patchset b/net-im/telegram-desktop/patches/tdesktop-1.1.23-libtgvoip.patchset new file mode 100644 index 000000000..1ac7884ee --- /dev/null +++ b/net-im/telegram-desktop/patches/tdesktop-1.1.23-libtgvoip.patchset @@ -0,0 +1,452 @@ +From ec7bde5fd17969a08b8149785445ecb69b09c729 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:18:56 +1000 +Subject: Fix opus header path + + +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusDecoder.h b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusDecoder.h +index 51bbbac..31c8b29 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusDecoder.h ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusDecoder.h +@@ -9,7 +9,11 @@ + + + #include "MediaStreamItf.h" ++#ifdef __HAIKU__ ++#include ++#else + #include "opus.h" ++#endif + #include "threading.h" + #include "BlockingQueue.h" + #include "BufferPool.h" +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusEncoder.h b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusEncoder.h +index 9329f89..b2a9305 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusEncoder.h ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/OpusEncoder.h +@@ -9,7 +9,11 @@ + + + #include "MediaStreamItf.h" ++#ifdef __HAIKU__ ++#include ++#else + #include "opus.h" ++#endif + #include "threading.h" + #include "BlockingQueue.h" + #include "BufferPool.h" +-- +2.13.1 + + +From 11ec9121c35bcf4127ff2e982329ba2c354d0259 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:22:31 +1000 +Subject: Add haiku + + +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioInput.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioInput.cpp +index 674b955..6021425 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioInput.cpp ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioInput.cpp +@@ -23,6 +23,8 @@ + #elif defined(__linux__) + #include "../os/linux/AudioInputALSA.h" + #include "../os/linux/AudioInputPulse.h" ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioInputHaiku.h" + #else + #error "Unsupported operating system" + #endif +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioOutput.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioOutput.cpp +index 4f5fdfa..a0409e6 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioOutput.cpp ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/audio/AudioOutput.cpp +@@ -24,6 +24,8 @@ + #elif defined(__linux__) + #include "../os/linux/AudioOutputALSA.h" + #include "../os/linux/AudioOutputPulse.h" ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioOutputHaiku.h" + #else + #error "Unsupported operating system" + #endif +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/libtgvoip.gyp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/libtgvoip.gyp +index 52fbea1..6a44ab3 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/libtgvoip.gyp ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/libtgvoip.gyp +@@ -81,18 +81,12 @@ + '<(tgvoip_src_loc)/os/darwin/AudioOutputAudioUnitOSX.h', + '<(tgvoip_src_loc)/os/darwin/DarwinSpecific.mm', + '<(tgvoip_src_loc)/os/darwin/DarwinSpecific.h', +- +- # Linux +- '<(tgvoip_src_loc)/os/linux/AudioInputALSA.cpp', +- '<(tgvoip_src_loc)/os/linux/AudioInputALSA.h', +- '<(tgvoip_src_loc)/os/linux/AudioOutputALSA.cpp', +- '<(tgvoip_src_loc)/os/linux/AudioOutputALSA.h', +- '<(tgvoip_src_loc)/os/linux/AudioOutputPulse.cpp', +- '<(tgvoip_src_loc)/os/linux/AudioOutputPulse.h', +- '<(tgvoip_src_loc)/os/linux/AudioInputPulse.cpp', +- '<(tgvoip_src_loc)/os/linux/AudioInputPulse.h', +- '<(tgvoip_src_loc)/os/linux/PulseAudioLoader.cpp', +- '<(tgvoip_src_loc)/os/linux/PulseAudioLoader.h', ++ ++ # Haiku ++ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.cpp', ++ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.h', ++ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.cpp', ++ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.h', + + # POSIX + '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.cpp', +@@ -253,6 +247,11 @@ + }, + ], + [ ++ '"<(OS)" != "haiku"', { ++ 'sources/': [['exclude', '<(tgvoip_src_loc)/os/haiku/']], ++ }, ++ ], ++ [ + '"<(OS)" != "linux"', { + 'sources/': [['exclude', '<(tgvoip_src_loc)/os/linux/']], + }, +@@ -371,6 +370,22 @@ + }, + ], + [ ++ '"<(OS)" == "haiku"', { ++ 'defines': [ ++ 'WEBRTC_POSIX', ++ ], ++ 'cflags_cc': [ ++ '-std=gnu11', ++ '-std=gnu++14', ++ ], ++ 'direct_dependent_settings': { ++ 'libraries': [ ++ ++ ], ++ }, ++ }, ++ ], ++ [ + '"<(OS)" == "linux"', { + 'defines': [ + 'WEBRTC_POSIX', +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.cpp +new file mode 100644 +index 0000000..0bf2433 +--- /dev/null ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.cpp +@@ -0,0 +1,52 @@ ++// ++// 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 "../../VoIPController.h" ++ ++using namespace tgvoip::audio; ++ ++ ++AudioInputHaiku::AudioInputHaiku(std::string devID){ ++ isRecording=false; ++ failed=true; ++ return; ++} ++ ++AudioInputHaiku::~AudioInputHaiku(){ ++} ++ ++void AudioInputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ ++ ++} ++ ++void AudioInputHaiku::Start(){ ++ if(failed || isRecording) ++ return; ++ ++ isRecording=true; ++} ++ ++void AudioInputHaiku::Stop(){ ++ if(!isRecording) ++ return; ++ ++ isRecording=false; ++} ++ ++void AudioInputHaiku::RunThread(){ ++} ++ ++void AudioInputHaiku::SetCurrentDevice(std::string devID){ ++} ++ ++void AudioInputHaiku::EnumerateDevices(std::vector& devs){ ++} +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.h b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.h +new file mode 100644 +index 0000000..e268ee5 +--- /dev/null ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioInputHaiku.h +@@ -0,0 +1,36 @@ ++// ++// 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" ++ ++namespace tgvoip{ ++namespace audio{ ++ ++class AudioInputHaiku : public AudioInput{ ++ ++public: ++ AudioInputHaiku(std::string devID); ++ virtual ~AudioInputHaiku(); ++ virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); ++ virtual void Start(); ++ virtual void Stop(); ++ virtual void SetCurrentDevice(std::string devID); ++ static void EnumerateDevices(std::vector& devs); ++ ++private: ++ void RunThread(); ++ tgvoip_thread_t thread; ++ bool isRecording; ++}; ++ ++} ++} ++ ++#endif //LIBTGVOIP_AUDIOINPUTALSA_H +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.cpp +new file mode 100644 +index 0000000..c5d88b4 +--- /dev/null ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.cpp +@@ -0,0 +1,54 @@ ++// ++// 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" ++ ++using namespace tgvoip::audio; ++ ++AudioOutputHaiku::AudioOutputHaiku(std::string devID){ ++ isPlaying=false; ++ failed=true; ++ return; ++} ++ ++AudioOutputHaiku::~AudioOutputHaiku(){ ++} ++ ++void AudioOutputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ ++ ++} ++ ++void AudioOutputHaiku::Start(){ ++ if(failed || isPlaying) ++ return; ++ ++ isPlaying=true; ++} ++ ++void AudioOutputHaiku::Stop(){ ++ if(!isPlaying) ++ return; ++ ++ isPlaying=false; ++} ++ ++bool AudioOutputHaiku::IsPlaying(){ ++ return isPlaying; ++} ++ ++void AudioOutputHaiku::RunThread(){ ++} ++ ++void AudioOutputHaiku::SetCurrentDevice(std::string devID){ ++} ++ ++void AudioOutputHaiku::EnumerateDevices(std::vector& devs){ ++} +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.h b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.h +new file mode 100644 +index 0000000..759e867 +--- /dev/null ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/haiku/AudioOutputHaiku.h +@@ -0,0 +1,36 @@ ++// ++// 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" ++ ++namespace tgvoip{ ++namespace audio{ ++ ++class AudioOutputHaiku : public AudioOutput{ ++public: ++ AudioOutputHaiku(std::string devID); ++ virtual ~AudioOutputHaiku(); ++ virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); ++ virtual void Start(); ++ virtual void Stop(); ++ virtual bool IsPlaying(); ++ virtual void SetCurrentDevice(std::string devID); ++ static void EnumerateDevices(std::vector& devs); ++ ++private: ++ void RunThread(); ++ tgvoip_thread_t thread; ++ bool isPlaying; ++}; ++ ++} ++} ++ ++#endif //LIBTGVOIP_AudioOutputHaiku_H +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/posix/NetworkSocketPosix.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/posix/NetworkSocketPosix.cpp +index 7fa7063..0b90f8a 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/posix/NetworkSocketPosix.cpp ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/os/posix/NetworkSocketPosix.cpp +@@ -39,6 +39,7 @@ NetworkSocketPosix::~NetworkSocketPosix(){ + } + + void NetworkSocketPosix::SetMaxPriority(){ ++#ifndef __HAIKU__ + #ifdef __APPLE__ + int prio=NET_SERVICE_TYPE_VO; + int res=setsockopt(fd, SOL_SOCKET, SO_NET_SERVICE_TYPE, &prio, sizeof(prio)); +@@ -57,6 +58,7 @@ void NetworkSocketPosix::SetMaxPriority(){ + LOGE("error setting ip tos: %d / %s", errno, strerror(errno)); + } + #endif ++#endif + } + + void NetworkSocketPosix::Send(NetworkPacket *packet){ +@@ -295,6 +297,10 @@ void NetworkSocketPosix::OnActiveInterfaceChanged(){ + } + + std::string NetworkSocketPosix::GetLocalInterfaceInfo(IPv4Address *v4addr, IPv6Address *v6addr){ ++#ifdef __HAIKU__ ++ std::string name=""; ++ return name; ++#else + struct ifconf ifc; + struct ifreq* ifr; + char buf[16384]; +@@ -344,6 +350,7 @@ std::string NetworkSocketPosix::GetLocalInterfaceInfo(IPv4Address *v4addr, IPv6A + } + close(sd); + return name; ++#endif + } + + uint16_t NetworkSocketPosix::GetLocalPort(){ +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/threading.h b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/threading.h +index 8a6f438..c45d3fb 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/threading.h ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/threading.h +@@ -7,7 +7,7 @@ + #ifndef __THREADING_H + #define __THREADING_H + +-#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(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__) + + #include + #include +@@ -19,7 +19,7 @@ typedef pthread_cond_t tgvoip_lock_t; + + #define start_thread(ref, entry, arg) pthread_create(&ref, NULL, entry, arg) + #define join_thread(thread) pthread_join(thread, NULL) +-#ifndef __APPLE__ ++#if !defined(__APPLE__) && !defined(__HAIKU__) + #define set_thread_name(thread, name) pthread_setname_np(thread, name) + #else + #define set_thread_name(thread, name) +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/webrtc_dsp/webrtc/common_audio/signal_processing/spl_init.c b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/webrtc_dsp/webrtc/common_audio/signal_processing/spl_init.c +index c9c4e65..9d93596 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/webrtc_dsp/webrtc/common_audio/signal_processing/spl_init.c ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/webrtc_dsp/webrtc/common_audio/signal_processing/spl_init.c +@@ -99,7 +99,12 @@ static void once(void (*func)(void)) { + static pthread_once_t lock = PTHREAD_ONCE_INIT; + pthread_once(&lock, func); + } +- ++#elif defined(__HAIKU__) ++#include ++static void once(void (*func)(void)) { ++ static pthread_once_t lock = PTHREAD_ONCE_INIT; ++ pthread_once(&lock, func); ++} + #elif defined(_WIN32) + #include + +-- +2.13.1 + + +From 7e861e2b3c0d02e0fabdab46b9e5f88b56585716 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Mon, 18 Sep 2017 22:05:53 +1000 +Subject: Fix for crash when calls + + +diff --git a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/VoIPController.cpp b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/VoIPController.cpp +index 78e9e4b..a9c34b7 100644 +--- a/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/VoIPController.cpp ++++ b/libtgvoip-757a5d8ec31aadcf387ac3cb135256152c18de1c/VoIPController.cpp +@@ -276,6 +276,7 @@ VoIPController::~VoIPController(){ + sendQueue->Put(PendingOutgoingPacket{0}); + if(openingTcpSocket) + openingTcpSocket->Close(); ++#ifndef __HAIKU__ + LOGD("before join sendThread"); + join_thread(sendThread); + LOGD("before join recvThread"); +@@ -284,6 +285,7 @@ VoIPController::~VoIPController(){ + join_thread(tickThread); + free_mutex(sendBufferMutex); + LOGD("before close socket"); ++#endif + if(udpSocket) + delete udpSocket; + if(udpSocket!=realUdpSocket) +-- +2.13.1 + diff --git a/net-im/telegram-desktop/patches/tdesktop-1.1.23.patchset b/net-im/telegram-desktop/patches/tdesktop-1.1.23.patchset new file mode 100644 index 000000000..af65b2d12 --- /dev/null +++ b/net-im/telegram-desktop/patches/tdesktop-1.1.23.patchset @@ -0,0 +1,2536 @@ +From 6633953aa4444f43780107edcb5923690d781fdf Mon Sep 17 00:00:00 2001 +From: Sergei Reznikov +Date: Sat, 9 Sep 2017 02:14:52 +0300 +Subject: Haiku fixes + + +diff --git a/Telegram/SourceFiles/autoupdater.cpp b/Telegram/SourceFiles/autoupdater.cpp +index a6aa4c2..45ba0ed 100644 +--- a/Telegram/SourceFiles/autoupdater.cpp ++++ b/Telegram/SourceFiles/autoupdater.cpp +@@ -534,7 +534,7 @@ bool checkReadyUpdate() { + #elif defined Q_OS_MAC // Q_OS_WIN + QString curUpdater = (cExeDir() + cExeName() + qsl("/Contents/Frameworks/Updater")); + QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Telegram.app/Contents/Frameworks/Updater")); +-#elif defined Q_OS_LINUX // Q_OS_MAC ++#elif defined Q_OS_LINUX || defined Q_OS_HAIKU // Q_OS_MAC + QString curUpdater = (cExeDir() + qsl("Updater")); + QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Updater")); + #endif // Q_OS_LINUX +diff --git a/Telegram/SourceFiles/base/build_config.h b/Telegram/SourceFiles/base/build_config.h +index 1731630..3a93c27 100644 +--- a/Telegram/SourceFiles/base/build_config.h ++++ b/Telegram/SourceFiles/base/build_config.h +@@ -30,13 +30,15 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + #define OS_LINUX 1 + #elif defined(_WIN32) // __APPLE__ || __linux__ + #define OS_WIN 1 ++#elif defined(__HAIKU__) // __APPLE__ || __linux__ ++#define OS_HAIKU 1 + #else // __APPLE__ || __linux__ || _WIN32 + #error Please add support for your platform in base/build_config.h + #endif // else for __APPLE__ || __linux__ || _WIN32 + + // For access to standard POSIXish features, use OS_POSIX instead of a + // more specific macro. +-#if defined(OS_MAC) || defined(OS_LINUX) ++#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_HAIKU) + #define OS_POSIX 1 + #endif // OS_MAC || OS_LINUX + +diff --git a/Telegram/SourceFiles/base/flags_tests.cpp b/Telegram/SourceFiles/base/flags_tests.cpp +index f2da24d..d19add1 100644 +--- a/Telegram/SourceFiles/base/flags_tests.cpp ++++ b/Telegram/SourceFiles/base/flags_tests.cpp +@@ -18,7 +18,7 @@ to link the code of portions of this program with the OpenSSL library. + Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE + Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + */ +-#include "catch.hpp" ++#include "../ThirdParty/variant/test/include/catch.hpp" + + #include "base/flags.h" + +diff --git a/Telegram/SourceFiles/base/flat_map_tests.cpp b/Telegram/SourceFiles/base/flat_map_tests.cpp +index 88a83a2..6551667 100644 +--- a/Telegram/SourceFiles/base/flat_map_tests.cpp ++++ b/Telegram/SourceFiles/base/flat_map_tests.cpp +@@ -18,7 +18,7 @@ to link the code of portions of this program with the OpenSSL library. + Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE + Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + */ +-#include "catch.hpp" ++#include "../ThirdParty/variant/test/include/catch.hpp" + + #include "base/flat_map.h" + #include +diff --git a/Telegram/SourceFiles/base/flat_set_tests.cpp b/Telegram/SourceFiles/base/flat_set_tests.cpp +index 675b0bd..735ab1b 100644 +--- a/Telegram/SourceFiles/base/flat_set_tests.cpp ++++ b/Telegram/SourceFiles/base/flat_set_tests.cpp +@@ -18,7 +18,7 @@ to link the code of portions of this program with the OpenSSL library. + Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE + Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + */ +-#include "catch.hpp" ++#include "../../ThirdParty/variant/test/include/catch.hpp" + + #include "base/flat_set.h" + +diff --git a/Telegram/SourceFiles/base/tests_main.cpp b/Telegram/SourceFiles/base/tests_main.cpp +index 0696e47..02bf016 100644 +--- a/Telegram/SourceFiles/base/tests_main.cpp ++++ b/Telegram/SourceFiles/base/tests_main.cpp +@@ -19,8 +19,8 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE + Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + */ + #define CATCH_CONFIG_RUNNER +-#include "catch.hpp" +-#include "reporters/catch_reporter_compact.hpp" ++#include "../ThirdParty/variant/test/include/catch.hpp" ++//#include "reporters/catch_reporter_compact.hpp" + #include + + namespace Catch { +diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h +index 633c4e4..0d09e7d 100644 +--- a/Telegram/SourceFiles/config.h ++++ b/Telegram/SourceFiles/config.h +@@ -272,6 +272,8 @@ inline const char *cApiDeviceModel() { + return "Mac"; + #elif defined Q_OS_LINUX + return "PC"; ++#elif defined Q_OS_HAIKU ++ return "PC"; + #endif + } + inline const char *cApiSystemVersion() { +@@ -281,6 +283,8 @@ inline const char *cApiSystemVersion() { + return "OS X"; + #elif defined Q_OS_LINUX + return "Linux"; ++#elif defined Q_OS_Haiku ++ return "Haiku"; + #endif + } + +diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp +index 6e85f27..4684e2a 100644 +--- a/Telegram/SourceFiles/main.cpp ++++ b/Telegram/SourceFiles/main.cpp +@@ -23,9 +23,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org + #include "storage/localstorage.h" + + int main(int argc, char *argv[]) { +-#ifndef Q_OS_MAC // Retina display support is working fine, others are not. ++#if !defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) ++ // Retina display support is working fine, others are not. + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); +-#endif // Q_OS_MAC ++#endif // not defined Q_OS_MAC and QT_VERSION >= 5.6.0 + QCoreApplication::setApplicationName(qsl("TelegramDesktop")); + + InitFromCommandLine(argc, argv); +@@ -39,6 +40,11 @@ int main(int argc, char *argv[]) { + Logs::start(); // must be started before Platform is started + Platform::start(); // must be started before QApplication is created + ++ // I don't know why path is not in QT_PLUGIN_PATH by default ++ QCoreApplication::addLibraryPath("/boot/system/add-ons/Qt"); ++ // without this Telegram doesn't start on Ubuntu 17.04 due GTK errors ++ setenv("QT_STYLE_OVERRIDE", "qwerty", false); ++ + int result = 0; + { + Application app(argc, argv); +diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.h b/Telegram/SourceFiles/platform/linux/linux_libs.h +index a8bf969..7559354 100644 +--- a/Telegram/SourceFiles/platform/linux/linux_libs.h ++++ b/Telegram/SourceFiles/platform/linux/linux_libs.h +@@ -29,7 +29,7 @@ extern "C" { + } // extern "C" + + #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION +-#include ++typedef void UnityLauncherEntry; + #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION + + namespace Platform { +diff --git a/Telegram/SourceFiles/platform/platform_file_utilities.h b/Telegram/SourceFiles/platform/platform_file_utilities.h +index 593ab28..c08f759 100644 +--- a/Telegram/SourceFiles/platform/platform_file_utilities.h ++++ b/Telegram/SourceFiles/platform/platform_file_utilities.h +@@ -51,8 +51,8 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, + + #ifdef Q_OS_MAC + #include "platform/mac/file_utilities_mac.h" +-#elif defined Q_OS_LINUX // Q_OS_MAC +-#include "platform/linux/file_utilities_linux.h" ++//#elif defined Q_OS_LINUX // Q_OS_MAC ++//#include "platform/linux/file_utilities_linux.h" + #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX + #include "platform/win/file_utilities_win.h" + #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN +diff --git a/Telegram/SourceFiles/platform/platform_main_window.h b/Telegram/SourceFiles/platform/platform_main_window.h +index b7b5334..66af0cd 100644 +--- a/Telegram/SourceFiles/platform/platform_main_window.h ++++ b/Telegram/SourceFiles/platform/platform_main_window.h +@@ -34,6 +34,8 @@ class MainWindow; + #include "platform/mac/main_window_mac.h" + #elif defined Q_OS_LINUX // Q_OS_MAC + #include "platform/linux/main_window_linux.h" +-#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX ++#elif defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_LINUX ++#include "platform/haiku/main_window_haiku.h" ++#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_HAIKU + #include "platform/win/main_window_win.h" + #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN +diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h +index 359b047..dca0c7e 100644 +--- a/Telegram/SourceFiles/platform/platform_specific.h ++++ b/Telegram/SourceFiles/platform/platform_specific.h +@@ -47,6 +47,8 @@ void finish(); + #include "platform/mac/specific_mac.h" + #elif defined Q_OS_LINUX // Q_OS_MAC + #include "platform/linux/specific_linux.h" +-#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX ++#elif defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_LINUX ++#include "platform/haiku/specific_haiku.h" ++#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_HAIKU + #include "platform/win/specific_win.h" + #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN +diff --git a/Telegram/SourceFiles/platform/platform_window_title.h b/Telegram/SourceFiles/platform/platform_window_title.h +index 1d0d892..285568c 100644 +--- a/Telegram/SourceFiles/platform/platform_window_title.h ++++ b/Telegram/SourceFiles/platform/platform_window_title.h +@@ -38,7 +38,7 @@ void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRe + #include "platform/mac/window_title_mac.h" + #elif defined Q_OS_WIN // Q_OS_MAC + #include "platform/win/window_title_win.h" +-#elif defined Q_OS_WINRT || defined Q_OS_LINUX // Q_OS_MAC || Q_OS_WIN ++#elif defined Q_OS_WINRT || defined Q_OS_LINUX || defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_WIN + + namespace Platform { + +diff --git a/Telegram/SourceFiles/qt_functions.cpp b/Telegram/SourceFiles/qt_functions.cpp +new file mode 100644 +index 0000000..4a722b8 +--- /dev/null ++++ b/Telegram/SourceFiles/qt_functions.cpp +@@ -0,0 +1,94 @@ ++/**************************************************************************** ++** ++** Copyright (C) 2015 The Qt Company Ltd. ++** Contact: http://www.qt.io/licensing/ ++** ++** This file contains some parts of the Qt Toolkit. ++** ++** $QT_BEGIN_LICENSE:LGPL21$ ++** Commercial License Usage ++** Licensees holding valid commercial Qt licenses may use this file in ++** accordance with the commercial license agreement provided with the ++** Software or, alternatively, in accordance with the terms contained in ++** a written agreement between you and The Qt Company. For licensing terms ++** and conditions see http://www.qt.io/terms-conditions. For further ++** information use the contact form at http://www.qt.io/contact-us. ++** ++** GNU Lesser General Public License Usage ++** Alternatively, this file may be used under the terms of the GNU Lesser ++** General Public License version 2.1 or version 3 as published by the Free ++** Software Foundation and appearing in the file LICENSE.LGPLv21 and ++** LICENSE.LGPLv3 included in the packaging of this file. Please review the ++** following information to ensure the GNU Lesser General Public License ++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ++** ++** As a special exception, The Qt Company gives you certain additional ++** rights. These rights are described in The Qt Company LGPL Exception ++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ++** ++** $QT_END_LICENSE$ ++** ++****************************************************************************/ ++ ++/* TODO: find a dynamic library with these symbols. */ ++ ++/* Debian maintainer: this function is taken from qfiledialog.cpp */ ++/* ++ Makes a list of filters from ;;-separated text. ++ Used by the mac and windows implementations ++*/ ++QStringList qt_make_filter_list(const QString &filter) ++{ ++ QString f(filter); ++ ++ if (f.isEmpty()) ++ return QStringList(); ++ ++ QString sep(QLatin1String(";;")); ++ int i = f.indexOf(sep, 0); ++ if (i == -1) { ++ if (f.indexOf(QLatin1Char('\n'), 0) != -1) { ++ sep = QLatin1Char('\n'); ++ i = f.indexOf(sep, 0); ++ } ++ } ++ ++ return f.split(sep); ++} ++ ++/* Debian maintainer: this constructor is taken from qtextengine.cpp for TextPainter::drawLine */ ++QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) ++ : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), ++ num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe) ++{ ++} ++ ++/* Debian maintainer: this method is also taken from qtextengine.cpp */ ++// Fix up flags and underlineStyle with given info ++void QTextItemInt::initWithScriptItem(const QScriptItem &si) ++{ ++ // explicitly initialize flags so that initFontAttributes can be called ++ // multiple times on the same TextItem ++ flags = 0; ++ if (si.analysis.bidiLevel %2) ++ flags |= QTextItem::RightToLeft; ++ ascent = si.ascent; ++ descent = si.descent; ++ ++ if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) { ++ underlineStyle = charFormat.underlineStyle(); ++ } else if (charFormat.boolProperty(QTextFormat::FontUnderline) ++ || f->d->underline) { ++ underlineStyle = QTextCharFormat::SingleUnderline; ++ } ++ ++ // compat ++ if (underlineStyle == QTextCharFormat::SingleUnderline) ++ flags |= QTextItem::Underline; ++ ++ if (f->d->overline || charFormat.fontOverline()) ++ flags |= QTextItem::Overline; ++ if (f->d->strikeOut || charFormat.fontStrikeOut()) ++ flags |= QTextItem::StrikeOut; ++} +diff --git a/Telegram/SourceFiles/qt_static_plugins.cpp b/Telegram/SourceFiles/qt_static_plugins.cpp +index b975c7a..f2f876b 100644 +--- a/Telegram/SourceFiles/qt_static_plugins.cpp ++++ b/Telegram/SourceFiles/qt_static_plugins.cpp +@@ -28,13 +28,4 @@ Q_IMPORT_PLUGIN(QWebpPlugin) + Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) + Q_IMPORT_PLUGIN(QGenericEnginePlugin) + #elif defined Q_OS_LINUX // Q_OS_WIN | Q_OS_MAC +-Q_IMPORT_PLUGIN(QWebpPlugin) +-Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) +-Q_IMPORT_PLUGIN(QConnmanEnginePlugin) +-Q_IMPORT_PLUGIN(QGenericEnginePlugin) +-Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) +-Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) + #endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX +diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp +index d18a8ea..2c58287 100644 +--- a/Telegram/SourceFiles/ui/text/text.cpp ++++ b/Telegram/SourceFiles/ui/text/text.cpp +@@ -1689,11 +1689,11 @@ private: + if (item == -1) + return; + +-#ifdef OS_MAC_OLD ++#if defined(OS_MAC_OLD) || QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + auto end = _e->findItem(line.from + line.length - 1); +-#else // OS_MAC_OLD ++#else + auto end = _e->findItem(line.from + line.length - 1, item); +-#endif // OS_MAC_OLD ++#endif + + auto blockIndex = _lineStartBlock; + auto currentBlock = _t->_blocks[blockIndex].get(); +diff --git a/Telegram/SourceFiles/ui/text/text_block.cpp b/Telegram/SourceFiles/ui/text/text_block.cpp +index f89644e..35230cf 100644 +--- a/Telegram/SourceFiles/ui/text/text_block.cpp ++++ b/Telegram/SourceFiles/ui/text/text_block.cpp +@@ -330,7 +330,7 @@ TextBlock::TextBlock(const style::font &font, const QString &str, QFixed minResi + SignalHandlers::setCrashAnnotationRef("CrashString", &part); + + QStackTextEngine engine(part, blockFont->f); +- QTextLayout layout(&engine); ++ QTextLayout layout(part, blockFont->f); + layout.beginLayout(); + layout.createLine(); + +diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp +index e9848ef..dcee47e 100644 +--- a/Telegram/SourceFiles/ui/twidget.cpp ++++ b/Telegram/SourceFiles/ui/twidget.cpp +@@ -191,9 +191,9 @@ void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton + , button + , QGuiApplication::mouseButtons() | button + , QGuiApplication::keyboardModifiers() +-#ifndef OS_MAC_OLD ++#if !defined(OS_MAC_OLD) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + , Qt::MouseEventSynthesizedByApplication +-#endif // OS_MAC_OLD ++#endif + ); + ev.setTimestamp(getms()); + QGuiApplication::sendEvent(windowHandle, &ev); +diff --git a/Telegram/ThirdParty/minizip/ioapi.c b/Telegram/ThirdParty/minizip/ioapi.c +index 7f5c191..649255c 100644 +--- a/Telegram/ThirdParty/minizip/ioapi.c ++++ b/Telegram/ThirdParty/minizip/ioapi.c +@@ -14,7 +14,7 @@ + #define _CRT_SECURE_NO_WARNINGS + #endif + +-#if defined(__APPLE__) || defined(IOAPI_NO_64) ++#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) + // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions + #define FOPEN_FUNC(filename, mode) fopen(filename, mode) + #define FTELLO_FUNC(stream) ftello(stream) +diff --git a/Telegram/gyp/PrecompiledHeader.cmake b/Telegram/gyp/PrecompiledHeader.cmake +index 5d6830e..c3f08d3 100644 +--- a/Telegram/gyp/PrecompiledHeader.cmake ++++ b/Telegram/gyp/PrecompiledHeader.cmake +@@ -112,7 +112,7 @@ function(add_precompiled_header _target _input) + set(_compiler_FLAGS "@${_pch_c_flags_file}") + add_custom_command( + OUTPUT "${_output_c}" +- COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} -x c-header -o "${_output_c}" -c "${_pchfile}" ++ COMMAND "${CMAKE_C_COMPILER}" "$(C_DEFINES)" "$(C_INCLUDES)" "$(C_FLAGS)" -x c-header -o "${_output_c}" -c "${_pchfile}" + DEPENDS "${_pchfile}" "${_pch_c_flags_file}" + IMPLICIT_DEPENDS C "${_pch_header}" + COMMENT "Precompiling ${_name} for ${_target} (C)") +@@ -123,7 +123,7 @@ function(add_precompiled_header _target _input) + set(_compiler_FLAGS "@${_pch_cpp_flags_file}") + add_custom_command( + OUTPUT "${_output_cxx}" +- COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output_cxx}" -c "${_pchfile}" ++ COMMAND "${CMAKE_CXX_COMPILER}" "$(CXX_DEFINES)" "$(CXX_INCLUDES)" "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}" + DEPENDS "${_pchfile}" "${_pch_cpp_flags_file}" + IMPLICIT_DEPENDS CXX "${_pch_header}" + COMMENT "Precompiling ${_name} for ${_target} (C++)") +diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp +index 0d1f38a..e716483 100644 +--- a/Telegram/gyp/Telegram.gyp ++++ b/Telegram/gyp/Telegram.gyp +@@ -69,6 +69,7 @@ + 'telegram_win.gypi', + 'telegram_mac.gypi', + 'telegram_linux.gypi', ++ 'telegram_haiku.gypi', + 'qt.gypi', + 'qt_rcc.gypi', + 'codegen_rules.gypi', +@@ -80,12 +81,10 @@ + 'codegen.gyp:codegen_numbers', + 'codegen.gyp:codegen_style', + 'tests/tests.gyp:tests', +- 'utils.gyp:Updater', +- '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip', ++# '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip', + ], + + 'defines': [ +- 'AL_LIBTYPE_STATIC', + 'AL_ALEXT_PROTOTYPES', + 'TGVOIP_USE_CXX11_LIB', + ' /dev/null --libs <@(pkgconfig_libs))', ++ ], ++ 'configurations': { ++ 'Release': { ++ 'cflags': [ ++ '-Ofast', ++ '-flto', ++ '-fno-strict-aliasing', ++ ], ++ 'cflags_cc': [ ++ '-Ofast', ++ '-flto', ++ '-fno-strict-aliasing', ++ ], ++ 'ldflags': [ ++ '-Ofast', ++ '-flto', ++ ], ++ }, ++ }, ++ 'cmake_precompiled_header': '<(src_loc)/stdafx.h', ++ 'cmake_precompiled_header_script': 'PrecompiledHeader.cmake', ++ }]], ++} +diff --git a/Telegram/gyp/telegram_qrc.gypi b/Telegram/gyp/telegram_qrc.gypi +index 4bf4033..8fdd119 100644 +--- a/Telegram/gyp/telegram_qrc.gypi ++++ b/Telegram/gyp/telegram_qrc.gypi +@@ -34,6 +34,13 @@ + ], + } + }], ++ [ 'build_haiku', { ++ 'variables': { ++ 'qrc_files': [ ++ '<(res_loc)/qrc/telegram_haiku.qrc', ++ ], ++ } ++ }], + [ 'build_mac', { + 'variables': { + 'qrc_files': [ +diff --git a/Telegram/gyp/telegram_sources.txt b/Telegram/gyp/telegram_sources.txt +index ef66965..58f2789 100644 +--- a/Telegram/gyp/telegram_sources.txt ++++ b/Telegram/gyp/telegram_sources.txt +@@ -302,6 +302,10 @@ + <(src_loc)/mtproto/type_utils.h + <(src_loc)/overview/overview_layout.cpp + <(src_loc)/overview/overview_layout.h ++<(src_loc)/platform/haiku/main_window_haiku.cpp ++<(src_loc)/platform/haiku/main_window_haiku.h ++<(src_loc)/platform/haiku/specific_haiku.cpp ++<(src_loc)/platform/haiku/specific_haiku.h + <(src_loc)/platform/linux/linux_desktop_environment.cpp + <(src_loc)/platform/linux/linux_desktop_environment.h + <(src_loc)/platform/linux/linux_gdk_helper.cpp +@@ -599,13 +603,7 @@ + <(emoji_suggestions_loc)/emoji_suggestions.h + + platforms: !win +-<(minizip_loc)/crypt.h +-<(minizip_loc)/ioapi.c +-<(minizip_loc)/ioapi.h +-<(minizip_loc)/zip.c +-<(minizip_loc)/zip.h +-<(minizip_loc)/unzip.c +-<(minizip_loc)/unzip.h ++<(src_loc)/qt_functions.cpp + + platforms: mac + <(sp_media_key_tap_loc)/SPMediaKeyTap.m +diff --git a/Telegram/gyp/utils.gyp b/Telegram/gyp/utils.gyp +index 209c737..07d7438 100644 +--- a/Telegram/gyp/utils.gyp ++++ b/Telegram/gyp/utils.gyp +@@ -91,6 +91,13 @@ + 'lzma', + ], + }], ++ [ 'build_haiku', { ++ 'libraries': [ ++ 'ssl', ++ 'crypto', ++ 'lzma', ++ ], ++ }], + [ 'build_mac', { + 'include_dirs': [ + '<(libs_loc)/openssl-xcode/include' +-- +2.13.1 + + +From ef4d838bf16701d96fe657ac422d1b5698019504 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:01:57 +1000 +Subject: Fix typo + + +diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h +index 0d09e7d..793310e 100644 +--- a/Telegram/SourceFiles/config.h ++++ b/Telegram/SourceFiles/config.h +@@ -283,7 +283,7 @@ inline const char *cApiSystemVersion() { + return "OS X"; + #elif defined Q_OS_LINUX + return "Linux"; +-#elif defined Q_OS_Haiku ++#elif defined Q_OS_HAIKU + return "Haiku"; + #endif + } +-- +2.13.1 + + +From 6fca2e8b3c67a4479cfa71bf735a1ba91835013b Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:05:59 +1000 +Subject: Add haiku platform modules + + +diff --git a/Telegram/Resources/etc/qt_haiku.conf b/Telegram/Resources/etc/qt_haiku.conf +new file mode 100644 +index 0000000..6d80862 +--- /dev/null ++++ b/Telegram/Resources/etc/qt_haiku.conf +@@ -0,0 +1,2 @@ ++[Paths] ++Libraries=:/gui/art +diff --git a/Telegram/Resources/qrc/telegram_haiku.qrc b/Telegram/Resources/qrc/telegram_haiku.qrc +new file mode 100644 +index 0000000..33115f9 +--- /dev/null ++++ b/Telegram/Resources/qrc/telegram_haiku.qrc +@@ -0,0 +1,5 @@ ++ ++ ++ ../etc/qt_haiku.conf ++ ++ +diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h +index 3c46326..dc5f1fe 100644 +--- a/Telegram/SourceFiles/core/utils.h ++++ b/Telegram/SourceFiles/core/utils.h +@@ -496,6 +496,7 @@ enum DBIPlatform { + dbipLinux64 = 2, + dbipLinux32 = 3, + dbipMacOld = 4, ++ dbipHaiku = 5, + }; + + enum DBIPeerReportSpamStatus { +diff --git a/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp +new file mode 100644 +index 0000000..1a8afbd +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp +@@ -0,0 +1,121 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#include "platform/haiku/file_utilities_haiku.h" ++ ++#include "messenger.h" ++#include "mainwindow.h" ++#include "storage/localstorage.h" ++ ++namespace Platform { ++namespace File { ++namespace internal { ++ ++QByteArray EscapeShell(const QByteArray &content) { ++ auto result = QByteArray(); ++ ++ auto b = content.constData(), e = content.constEnd(); ++ for (auto ch = b; ch != e; ++ch) { ++ if (*ch == ' ' || *ch == '"' || *ch == '\'' || *ch == '\\') { ++ if (result.isEmpty()) { ++ result.reserve(content.size() * 2); ++ } ++ if (ch > b) { ++ result.append(b, ch - b); ++ } ++ result.append('\\'); ++ b = ch; ++ } ++ } ++ if (result.isEmpty()) { ++ return content; ++ } ++ ++ if (e > b) { ++ result.append(b, e - b); ++ } ++ return result; ++} ++ ++} // namespace internal ++ ++void UnsafeShowInFolder(const QString &filepath) { ++ Ui::hideLayer(true); // Hide mediaview to make other apps visible. ++ auto absolutePath = QFileInfo(filepath).absoluteFilePath(); ++ QProcess process; ++ auto command = qsl("open"); ++ auto arguments = QStringList(); ++ arguments << QFileInfo(filepath).absoluteDir().absolutePath(); ++ if (!process.startDetached(command, arguments)) { ++ LOG(("Failed to launch '%1 %2'").arg(command).arg(arguments.join(' '))); ++ } ++} ++ ++} // namespace File ++ ++namespace FileDialog { ++namespace { ++ ++using Type = ::FileDialog::internal::Type; ++ ++bool NativeSupported() { ++ return false; ++} ++ ++bool PreviewSupported() { ++ return false; ++} ++ ++ ++ ++} // namespace ++ ++bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) { ++ return ::FileDialog::internal::GetDefault(files, remoteContent, caption, filter, type, startFile); ++} ++ ++namespace internal { ++ ++ ++ ++ ++namespace { ++ ++const char *filterRegExp = ++"^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; ++ ++// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" ++QStringList cleanFilterList(const QString &filter) { ++ QRegExp regexp(QString::fromLatin1(filterRegExp)); ++ Q_ASSERT(regexp.isValid()); ++ QString f = filter; ++ int i = regexp.indexIn(f); ++ if (i >= 0) ++ f = regexp.cap(2); ++ return f.split(QLatin1Char(' '), QString::SkipEmptyParts); ++} ++ ++} // namespace ++ ++ ++ ++} // namespace internal ++} // namespace FileDialog ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.h b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.h +new file mode 100644 +index 0000000..103ccb6 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.h +@@ -0,0 +1,75 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#pragma once ++ ++#include "platform/platform_file_utilities.h" ++ ++extern "C" { ++#undef signals ++#define signals public ++} // extern "C" ++ ++namespace Platform { ++namespace File { ++namespace internal { ++ ++QByteArray EscapeShell(const QByteArray &content); ++ ++} // namespace internal ++ ++inline QString UrlToLocal(const QUrl &url) { ++ return ::File::internal::UrlToLocalDefault(url); ++} ++ ++inline void UnsafeOpenEmailLink(const QString &email) { ++ return ::File::internal::UnsafeOpenEmailLinkDefault(email); ++} ++ ++inline bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) { ++ return false; ++} ++ ++inline bool UnsafeShowOpenWith(const QString &filepath) { ++ return false; ++} ++ ++inline void UnsafeLaunch(const QString &filepath) { ++ return ::File::internal::UnsafeLaunchDefault(filepath); ++} ++ ++inline void PostprocessDownloaded(const QString &filepath) { ++} ++ ++} // namespace File ++ ++namespace FileDialog { ++ ++inline void InitLastPath() { ++ ::FileDialog::internal::InitLastPathDefault(); ++} ++ ++namespace internal { ++ ++ ++ ++} // namespace internal ++} // namespace FileDialog ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.cpp b/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.cpp +new file mode 100644 +index 0000000..37474d0 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.cpp +@@ -0,0 +1,71 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#include "platform/haiku/haiku_desktop_environment.h" ++ ++namespace Platform { ++namespace DesktopEnvironment { ++namespace { ++ ++QString GetEnv(const char *name) { ++ auto result = getenv(name); ++ auto value = result ? QString::fromLatin1(result) : QString(); ++ LOG(("Getting DE, %1: '%2'").arg(name).arg(value)); ++ return value; ++} ++ ++Type Compute() { ++ return Type::Other; ++} ++ ++Type ComputeAndLog() { ++ auto result = Compute(); ++ auto name = [result]() -> QString { ++ switch (result) { ++ case Type::Other: return "Other"; ++ } ++ return QString::number(static_cast(result)); ++ }; ++ LOG(("DE: %1").arg(name())); ++ return result; ++} ++ ++} // namespace ++ ++// Thanks Chromium. ++Type Get() { ++ static const auto result = ComputeAndLog(); ++ return result; ++} ++ ++bool TryQtTrayIcon() { ++ return true; ++} ++ ++bool PreferAppIndicatorTrayIcon() { ++ return false; ++} ++ ++bool TryUnityCounter() { ++ return false; ++} ++ ++} // namespace DesktopEnvironment ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.h b/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.h +new file mode 100644 +index 0000000..e76c8fe +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/haiku_desktop_environment.h +@@ -0,0 +1,37 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#pragma once ++ ++namespace Platform { ++namespace DesktopEnvironment { ++ ++enum class Type { ++ Other ++}; ++ ++Type Get(); ++ ++bool TryQtTrayIcon(); ++bool PreferAppIndicatorTrayIcon(); ++bool TryUnityCounter(); ++ ++} // namespace DesktopEnvironment ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp +new file mode 100644 +index 0000000..dd3c644 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp +@@ -0,0 +1,135 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#include "platform/haiku/main_window_haiku.h" ++ ++#include "styles/style_window.h" ++#include "platform/haiku/haiku_desktop_environment.h" ++#include "mainwindow.h" ++#include "messenger.h" ++#include "application.h" ++#include "lang/lang_keys.h" ++#include "storage/localstorage.h" ++ ++namespace Platform { ++ ++MainWindow::MainWindow() { ++ connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck())); ++ _psCheckStatusIconTimer.setSingleShot(false); ++ ++ connect(&_psUpdateIndicatorTimer, SIGNAL(timeout()), this, SLOT(psUpdateIndicator())); ++ _psUpdateIndicatorTimer.setSingleShot(true); ++} ++ ++bool MainWindow::hasTrayIcon() const { ++ return true; ++} ++ ++void MainWindow::psStatusIconCheck() { ++ if (cSupportTray() || !--_psCheckStatusIconLeft) { ++ _psCheckStatusIconTimer.stop(); ++ return; ++ } ++} ++ ++void MainWindow::psShowTrayMenu() { ++} ++ ++void MainWindow::psTrayMenuUpdated() { ++} ++ ++void MainWindow::psSetupTrayIcon() { ++ if (!trayIcon) { ++ trayIcon = new QSystemTrayIcon(this); ++ ++ auto icon = QIcon(App::pixmapFromImageInPlace(Messenger::Instance().logoNoMargin())); ++ ++ trayIcon->setIcon(icon); ++ trayIcon->setToolTip(str_const_toString(AppName)); ++ connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection); ++ connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray())); ++ App::wnd()->updateTrayMenu(); ++ } ++ updateIconCounters(); ++ ++ trayIcon->show(); ++} ++ ++void MainWindow::workmodeUpdated(DBIWorkMode mode) { ++ psSetupTrayIcon(); ++ if (mode == dbiwmWindowOnly) { ++ if (trayIcon) { ++ trayIcon->setContextMenu(0); ++ delete trayIcon; ++ trayIcon = nullptr; ++ } ++ } ++} ++ ++ ++void MainWindow::psUpdateIndicator() { ++} ++ ++void MainWindow::unreadCounterChangedHook() { ++ setWindowTitle(titleText()); ++ updateIconCounters(); ++} ++ ++void MainWindow::updateIconCounters() { ++ auto counter = App::histories().unreadBadge(); ++ auto muted = App::histories().unreadOnlyMuted(); ++ auto iconSizeSmall = QSize(16, 16); ++ auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); ++ auto &fg = st::trayCounterFg; ++ auto iconSmallPixmap16 = App::pixmapFromImageInPlace(iconWithCounter(16, counter, bg, fg, true)); ++ QIcon iconSmall; ++ iconSmall.addPixmap(iconSmallPixmap16); ++ if (trayIcon) { ++ QIcon forTrayIcon; ++ forTrayIcon.addPixmap(iconSmallPixmap16); ++ trayIcon->setIcon(forTrayIcon); ++ } ++} ++ ++void MainWindow::LibsLoaded() { ++} ++ ++void MainWindow::psCreateTrayIcon() { ++ ++} ++ ++void MainWindow::psFirstShow() { ++ psCreateTrayIcon(); ++ psUpdateMargins(); ++ bool showShadows = true; ++ show(); ++ setPositionInited(); ++} ++ ++void MainWindow::psInitSysMenu() { ++} ++ ++void MainWindow::psUpdateMargins() { ++} ++ ++MainWindow::~MainWindow() { ++} ++ ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.h b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h +new file mode 100644 +index 0000000..56cc497 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h +@@ -0,0 +1,79 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#pragma once ++ ++#include "platform/platform_main_window.h" ++ ++namespace Platform { ++ ++class MainWindow : public Window::MainWindow { ++ Q_OBJECT ++ ++public: ++ MainWindow(); ++ ++ void psFirstShow(); ++ void psInitSysMenu(); ++ void psUpdateMargins(); ++ ++ void psRefreshTaskbarIcon() { ++ } ++ ++ virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0; ++ ++ static void LibsLoaded(); ++ ++ ~MainWindow(); ++ ++public slots: ++ void psShowTrayMenu(); ++ ++ void psStatusIconCheck(); ++ void psUpdateIndicator(); ++ ++protected: ++ void unreadCounterChangedHook() override; ++ ++ bool hasTrayIcon() const override; ++ ++ void workmodeUpdated(DBIWorkMode mode) override; ++ ++ QSystemTrayIcon *trayIcon = nullptr; ++ QMenu *trayIconMenu = nullptr; ++ ++ void psTrayMenuUpdated(); ++ void psSetupTrayIcon(); ++ ++ virtual void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) = 0; ++ ++private: ++ void updateIconCounters(); ++ void psCreateTrayIcon(); ++ ++ QTimer _psCheckStatusIconTimer; ++ int _psCheckStatusIconLeft = 100; ++ ++ QTimer _psUpdateIndicatorTimer; ++ TimeMs _psLastIndicatorUpdate = 0; ++ ++}; ++ ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp +new file mode 100644 +index 0000000..dc54c57 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp +@@ -0,0 +1,82 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#include "platform/haiku/notifications_manager_haiku.h" ++ ++#include "window/notifications_utilities.h" ++#include "lang/lang_keys.h" ++#include "base/task_queue.h" ++ ++namespace Platform { ++namespace Notifications { ++namespace { ++ ++bool LibNotifyLoaded() { ++ return false; ++} ++ ++QString escapeHtml(const QString &text) { ++ auto result = QString(); ++ auto copyFrom = 0, textSize = text.size(); ++ auto data = text.constData(); ++ for (auto i = 0; i != textSize; ++i) { ++ auto ch = data[i]; ++ if (ch == '<' || ch == '>' || ch == '&') { ++ if (!copyFrom) { ++ result.reserve(textSize * 5); ++ } ++ if (i > copyFrom) { ++ result.append(data + copyFrom, i - copyFrom); ++ } ++ switch (ch.unicode()) { ++ case '<': result.append(qstr("<")); break; ++ case '>': result.append(qstr(">")); break; ++ case '&': result.append(qstr("&")); break; ++ } ++ copyFrom = i + 1; ++ } ++ } ++ if (copyFrom > 0) { ++ result.append(data + copyFrom, textSize - copyFrom); ++ return result; ++ } ++ return text; ++} ++ ++ ++ ++} // namespace ++ ++bool Supported() { ++ return false; ++} ++ ++std::unique_ptr Create(Window::Notifications::System *system) { ++ return nullptr; ++} ++ ++void Finish() { ++ ++} ++ ++ ++ ++} // namespace Notifications ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h +new file mode 100644 +index 0000000..d70bcff +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h +@@ -0,0 +1,63 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++In addition, as a special exception, the copyright holders give permission ++to link the code of portions of this program with the OpenSSL library. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#pragma once ++ ++#include "platform/platform_notifications_manager.h" ++ ++namespace Platform { ++namespace Notifications { ++ ++inline bool SkipAudio() { ++ return false; ++} ++ ++inline bool SkipToast() { ++ return false; ++} ++ ++inline void FlashBounce() { ++} ++ ++void Finish(); ++ ++class Manager : public Window::Notifications::NativeManager { ++public: ++ Manager(Window::Notifications::System *system); ++ ++ void clearNotification(PeerId peerId, MsgId msgId); ++ bool hasPoorSupport() const; ++ bool hasActionsSupport() const; ++ ++ ~Manager(); ++ ++protected: ++ void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; ++ void doClearAllFast() override; ++ void doClearFromHistory(History *history) override; ++ ++private: ++ class Private; ++ const std::unique_ptr _private; ++ ++}; ++ ++} // namespace Notifications ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp +new file mode 100644 +index 0000000..ce9091a +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp +@@ -0,0 +1,416 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#include "platform/haiku/specific_haiku.h" ++ ++#include "lang/lang_keys.h" ++#include "application.h" ++#include "mainwidget.h" ++#include "mainwindow.h" ++#include "storage/localstorage.h" ++#include "platform/haiku/file_utilities_haiku.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include ++ ++using namespace Platform; ++ ++using Platform::File::internal::EscapeShell; ++ ++namespace Platform { ++ ++QString CurrentExecutablePath(int argc, char *argv[]) { ++ return argc ? QFile::decodeName(argv[0]) : QString(); ++} ++ ++} // namespace Platform ++ ++namespace { ++ ++class _PsEventFilter : public QAbstractNativeEventFilter { ++public: ++ bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { ++ //auto wnd = App::wnd(); ++ //if (!wnd) return false; ++ ++ return false; ++ } ++}; ++_PsEventFilter *_psEventFilter = nullptr; ++ ++QRect _monitorRect; ++auto _monitorLastGot = 0LL; ++ ++} // namespace ++ ++QRect psDesktopRect() { ++ auto tnow = getms(); ++ if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) { ++ _monitorLastGot = tnow; ++ _monitorRect = QApplication::desktop()->availableGeometry(App::wnd()); ++ } ++ return _monitorRect; ++} ++ ++void psShowOverAll(QWidget *w, bool canFocus) { ++ w->show(); ++} ++ ++void psBringToBack(QWidget *w) { ++ w->hide(); ++} ++ ++QAbstractNativeEventFilter *psNativeEventFilter() { ++ delete _psEventFilter; ++ _psEventFilter = new _PsEventFilter(); ++ return _psEventFilter; ++} ++ ++void psWriteDump() { ++} ++ ++QString demanglestr(const QString &mangled) { ++ if (mangled.isEmpty()) return mangled; ++ ++ QByteArray cmd = ("c++filt -n " + mangled).toUtf8(); ++ FILE *f = popen(cmd.constData(), "r"); ++ if (!f) return "BAD_SYMBOL_" + mangled; ++ ++ QString result; ++ char buffer[4096] = { 0 }; ++ while (!feof(f)) { ++ if (fgets(buffer, 4096, f) != NULL) { ++ result += buffer; ++ } ++ } ++ pclose(f); ++ return result.trimmed(); ++} ++ ++QStringList addr2linestr(uint64 *addresses, int count) { ++ QStringList result; ++ if (!count || cExeName().isEmpty()) return result; ++ ++ result.reserve(count); ++ QByteArray cmd = "addr2line -e " + EscapeShell(QFile::encodeName(cExeDir() + cExeName())); ++ for (int i = 0; i < count; ++i) { ++ if (addresses[i]) { ++ cmd += qsl(" 0x%1").arg(addresses[i], 0, 16).toUtf8(); ++ } ++ } ++ FILE *f = popen(cmd.constData(), "r"); ++ ++ QStringList addr2lineResult; ++ if (f) { ++ char buffer[4096] = {0}; ++ while (!feof(f)) { ++ if (fgets(buffer, 4096, f) != NULL) { ++ addr2lineResult.push_back(QString::fromUtf8(buffer)); ++ } ++ } ++ pclose(f); ++ } ++ for (int i = 0, j = 0; i < count; ++i) { ++ if (addresses[i]) { ++ if (j < addr2lineResult.size() && !addr2lineResult.at(j).isEmpty() && !addr2lineResult.at(j).startsWith(qstr("0x"))) { ++ QString res = addr2lineResult.at(j).trimmed(); ++ if (int index = res.indexOf(qstr("/Telegram/"))) { ++ if (index > 0) { ++ res = res.mid(index + qstr("/Telegram/").size()); ++ } ++ } ++ result.push_back(res); ++ } else { ++ result.push_back(QString()); ++ } ++ ++j; ++ } else { ++ result.push_back(QString()); ++ } ++ } ++ return result; ++} ++ ++QString psPrepareCrashDump(const QByteArray &crashdump, QString dumpfile) { ++ QString initial = QString::fromUtf8(crashdump), result; ++ QStringList lines = initial.split('\n'); ++ result.reserve(initial.size()); ++ int32 i = 0, l = lines.size(); ++ ++ while (i < l) { ++ uint64 addresses[1024] = { 0 }; ++ for (; i < l; ++i) { ++ result.append(lines.at(i)).append('\n'); ++ QString line = lines.at(i).trimmed(); ++ if (line == qstr("Backtrace:")) { ++ ++i; ++ break; ++ } ++ } ++ ++ int32 start = i; ++ for (; i < l; ++i) { ++ QString line = lines.at(i).trimmed(); ++ if (line.isEmpty()) break; ++ ++ QRegularExpressionMatch m1 = QRegularExpression(qsl("^(.+)\\(([^+]+)\\+([^\\)]+)\\)\\[(.+)\\]$")).match(line); ++ QRegularExpressionMatch m2 = QRegularExpression(qsl("^(.+)\\[(.+)\\]$")).match(line); ++ QString addrstr = m1.hasMatch() ? m1.captured(4) : (m2.hasMatch() ? m2.captured(2) : QString()); ++ if (!addrstr.isEmpty()) { ++ uint64 addr = addrstr.startsWith(qstr("0x")) ? addrstr.mid(2).toULongLong(0, 16) : addrstr.toULongLong(); ++ if (addr > 1) { ++ addresses[i - start] = addr; ++ } ++ } ++ } ++ ++ QStringList addr2line = addr2linestr(addresses, i - start); ++ for (i = start; i < l; ++i) { ++ QString line = lines.at(i).trimmed(); ++ if (line.isEmpty()) break; ++ ++ result.append(qsl("\n%1. ").arg(i - start)); ++ if (line.startsWith(qstr("ERROR: "))) { ++ result.append(line).append('\n'); ++ continue; ++ } ++ if (line == qstr("[0x1]")) { ++ result.append(qsl("(0x1 separator)\n")); ++ continue; ++ } ++ ++ QRegularExpressionMatch m1 = QRegularExpression(qsl("^(.+)\\(([^+]*)\\+([^\\)]+)\\)(.+)$")).match(line); ++ QRegularExpressionMatch m2 = QRegularExpression(qsl("^(.+)\\[(.+)\\]$")).match(line); ++ if (!m1.hasMatch() && !m2.hasMatch()) { ++ result.append(qstr("BAD LINE: ")).append(line).append('\n'); ++ continue; ++ } ++ ++ if (m1.hasMatch()) { ++ result.append(demanglestr(m1.captured(2))).append(qsl(" + ")).append(m1.captured(3)).append(qsl(" [")).append(m1.captured(1)).append(qsl("] ")); ++ if (!addr2line.at(i - start).isEmpty() && addr2line.at(i - start) != qsl("??:0")) { ++ result.append(qsl(" (")).append(addr2line.at(i - start)).append(qsl(")\n")); ++ } else { ++ result.append(m1.captured(4)).append(qsl(" (demangled)")).append('\n'); ++ } ++ } else { ++ result.append('[').append(m2.captured(1)).append(']'); ++ if (!addr2line.at(i - start).isEmpty() && addr2line.at(i - start) != qsl("??:0")) { ++ result.append(qsl(" (")).append(addr2line.at(i - start)).append(qsl(")\n")); ++ } else { ++ result.append(' ').append(m2.captured(2)).append('\n'); ++ } ++ } ++ } ++ } ++ return result; ++} ++ ++bool _removeDirectory(const QString &path) { // from http://stackoverflow.com/questions/2256945/removing-a-non-empty-directory-programmatically-in-c-or-c ++ QByteArray pathRaw = QFile::encodeName(path); ++ DIR *d = opendir(pathRaw.constData()); ++ if (!d) return false; ++ ++ while (struct dirent *p = readdir(d)) { ++ /* Skip the names "." and ".." as we don't want to recurse on them. */ ++ if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) continue; ++ ++ QString fname = path + '/' + p->d_name; ++ QByteArray fnameRaw = QFile::encodeName(fname); ++ struct stat statbuf; ++ if (!stat(fnameRaw.constData(), &statbuf)) { ++ if (S_ISDIR(statbuf.st_mode)) { ++ if (!_removeDirectory(fname)) { ++ closedir(d); ++ return false; ++ } ++ } else { ++ if (unlink(fnameRaw.constData())) { ++ closedir(d); ++ return false; ++ } ++ } ++ } ++ } ++ closedir(d); ++ ++ return !rmdir(pathRaw.constData()); ++} ++ ++void psDeleteDir(const QString &dir) { ++ _removeDirectory(dir); ++} ++ ++namespace { ++ ++auto _lastUserAction = 0LL; ++ ++} // namespace ++ ++void psUserActionDone() { ++ _lastUserAction = getms(true); ++} ++ ++bool psIdleSupported() { ++ return false; ++} ++ ++TimeMs psIdleTime() { ++ return getms(true) - _lastUserAction; ++} ++ ++void psActivateProcess(uint64 pid) { ++// objc_activateProgram(); ++} ++ ++namespace { ++ ++QString getHomeDir() { ++ struct passwd *pw = getpwuid(getuid()); ++ return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QFile::decodeName(pw->pw_dir) + '/') : QString(); ++} ++ ++} // namespace ++ ++QString psAppDataPath() { ++ // Previously we used ~/.TelegramDesktop, so look there first. ++ // If we find data there, we should still use it. ++ auto home = getHomeDir(); ++ if (!home.isEmpty()) { ++ auto oldPath = home + qsl(".TelegramDesktop/"); ++ auto oldSettingsBase = oldPath + qsl("tdata/settings"); ++ if (QFile(oldSettingsBase + '0').exists() || QFile(oldSettingsBase + '1').exists()) { ++ return oldPath; ++ } ++ } ++ ++ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; ++} ++ ++QString psDownloadPath() { ++ return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/'; ++} ++ ++void psDoCleanup() { ++ try { ++ psAutoStart(false, true); ++ psSendToMenu(false, true); ++ } catch (...) { ++ } ++} ++ ++int psCleanup() { ++ psDoCleanup(); ++ return 0; ++} ++ ++void psDoFixPrevious() { ++} ++ ++int psFixPrevious() { ++ psDoFixPrevious(); ++ return 0; ++} ++ ++namespace Platform { ++ ++void start() { ++} ++ ++void finish() { ++} ++ ++bool TranslucentWindowsSupported(QPoint globalPosition) { ++ return false; ++} ++ ++QString SystemCountry() { ++ return QString(); ++} ++ ++QString SystemLanguage() { ++ return QString(); ++} ++ ++namespace ThirdParty { ++ ++void start() { ++} ++ ++void finish() { ++} ++ ++} // namespace ThirdParty ++ ++} // namespace Platform ++ ++namespace { ++ ++bool _psRunCommand(const QByteArray &command) { ++ auto result = system(command.constData()); ++ if (result) { ++ DEBUG_LOG(("App Error: command failed, code: %1, command (in utf8): %2").arg(result).arg(command.constData())); ++ return false; ++ } ++ DEBUG_LOG(("App Info: command succeeded, command (in utf8): %1").arg(command.constData())); ++ return true; ++} ++ ++} // namespace ++ ++void psRegisterCustomScheme() { ++} ++ ++void psNewVersion() { ++ psRegisterCustomScheme(); ++} ++ ++bool _execUpdater(bool update = true, const QString &crashreport = QString()) { ++ return false; ++} ++ ++void psExecUpdater() { ++} ++ ++void psExecTelegram(const QString &crashreport) { ++ _execUpdater(false, crashreport); ++} ++ ++bool psShowOpenWithMenu(int x, int y, const QString &file) { ++ return false; ++} ++ ++void psAutoStart(bool start, bool silent) { ++} ++ ++void psSendToMenu(bool send, bool silent) { ++} ++ ++void psUpdateOverlayed(QWidget *widget) { ++} ++ ++bool psLaunchMaps(const LocationCoords &coords) { ++ return false; ++} +diff --git a/Telegram/SourceFiles/platform/haiku/specific_haiku.h b/Telegram/SourceFiles/platform/haiku/specific_haiku.h +new file mode 100644 +index 0000000..99d13d5 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.h +@@ -0,0 +1,120 @@ ++/* ++This file is part of Telegram Desktop, ++the official desktop version of Telegram messaging app, see https://telegram.org ++ ++Telegram Desktop is free software: you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation, either version 3 of the License, or ++(at your option) any later version. ++ ++It is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE ++Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org ++*/ ++#pragma once ++ ++//#include ++#include ++ ++namespace Platform { ++ ++inline void SetWatchingMediaKeys(bool watching) { ++} ++ ++inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) { ++} ++ ++inline void InitOnTopPanel(QWidget *panel) { ++} ++ ++inline void DeInitOnTopPanel(QWidget *panel) { ++} ++ ++inline void ReInitOnTopPanel(QWidget *panel) { ++} ++ ++QString CurrentExecutablePath(int argc, char *argv[]); ++ ++} // namespace Platform ++ ++inline QString psServerPrefix() { ++ return qsl("/tmp/"); ++} ++inline void psCheckLocalSocket(const QString &serverName) { ++ QFile address(serverName); ++ if (address.exists()) { ++ address.remove(); ++ } ++} ++ ++void psWriteDump(); ++QString psPrepareCrashDump(const QByteArray &crashdump, QString dumpfile); ++ ++void psDeleteDir(const QString &dir); ++ ++void psUserActionDone(); ++bool psIdleSupported(); ++TimeMs psIdleTime(); ++ ++QStringList psInitLogs(); ++void psClearInitLogs(); ++ ++void psActivateProcess(uint64 pid = 0); ++QString psLocalServerPrefix(); ++QString psAppDataPath(); ++QString psDownloadPath(); ++void psAutoStart(bool start, bool silent = false); ++void psSendToMenu(bool send, bool silent = false); ++ ++QRect psDesktopRect(); ++void psShowOverAll(QWidget *w, bool canFocus = true); ++void psBringToBack(QWidget *w); ++ ++int psCleanup(); ++int psFixPrevious(); ++ ++void psExecUpdater(); ++void psExecTelegram(const QString &arg = QString()); ++ ++QAbstractNativeEventFilter *psNativeEventFilter(); ++ ++void psNewVersion(); ++ ++void psUpdateOverlayed(QWidget *widget); ++inline QByteArray psDownloadPathBookmark(const QString &path) { ++ return QByteArray(); ++} ++inline QByteArray psPathBookmark(const QString &path) { ++ return QByteArray(); ++} ++inline void psDownloadPathEnableAccess() { ++} ++ ++class PsFileBookmark { ++public: ++ PsFileBookmark(const QByteArray &bookmark) { ++ } ++ bool check() const { ++ return true; ++ } ++ bool enable() const { ++ return true; ++ } ++ void disable() const { ++ } ++ const QString &name(const QString &original) const { ++ return original; ++ } ++ QByteArray bookmark() const { ++ return QByteArray(); ++ } ++ ++}; ++ ++bool linuxMoveFile(const char *from, const char *to); ++ ++bool psLaunchMaps(const LocationCoords &coords); +diff --git a/Telegram/SourceFiles/platform/platform_audio.h b/Telegram/SourceFiles/platform/platform_audio.h +index 516398a..3511402 100644 +--- a/Telegram/SourceFiles/platform/platform_audio.h ++++ b/Telegram/SourceFiles/platform/platform_audio.h +@@ -32,7 +32,7 @@ void DeInit(); + + // Platform dependent implementations. + +-#if defined Q_OS_MAC || defined Q_OS_LINUX ++#if defined Q_OS_MAC || defined Q_OS_LINUX || defined(Q_OS_HAIKU) + namespace Platform { + namespace Audio { + +diff --git a/Telegram/SourceFiles/platform/platform_file_utilities.h b/Telegram/SourceFiles/platform/platform_file_utilities.h +index c08f759..50d7418 100644 +--- a/Telegram/SourceFiles/platform/platform_file_utilities.h ++++ b/Telegram/SourceFiles/platform/platform_file_utilities.h +@@ -51,8 +51,10 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, + + #ifdef Q_OS_MAC + #include "platform/mac/file_utilities_mac.h" +-//#elif defined Q_OS_LINUX // Q_OS_MAC +-//#include "platform/linux/file_utilities_linux.h" ++#elif defined Q_OS_LINUX // Q_OS_MAC ++#include "platform/linux/file_utilities_linux.h" ++#elif defined Q_OS_HAIKU // Q_OS_LINUX ++#include "platform/haiku/file_utilities_haiku.h" + #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX + #include "platform/win/file_utilities_win.h" + #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN +diff --git a/Telegram/SourceFiles/platform/platform_notifications_manager.h b/Telegram/SourceFiles/platform/platform_notifications_manager.h +index e303272..1bd4c74 100644 +--- a/Telegram/SourceFiles/platform/platform_notifications_manager.h ++++ b/Telegram/SourceFiles/platform/platform_notifications_manager.h +@@ -41,6 +41,8 @@ void FlashBounce(); + #include "platform/mac/notifications_manager_mac.h" + #elif defined Q_OS_LINUX // Q_OS_MAC + #include "platform/linux/notifications_manager_linux.h" ++#elif defined Q_OS_HAIKU // Q_OS_LINUX ++#include "platform/haiku/notifications_manager_haiku.h" + #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX + #include "platform/win/notifications_manager_win.h" + #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN +-- +2.13.1 + + +From c183162abdec7dd3ddea85c7e637912076ab35f6 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:09:06 +1000 +Subject: Add haiku platform for settings + + +diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp +index 4306551..df713a3 100644 +--- a/Telegram/SourceFiles/settings.cpp ++++ b/Telegram/SourceFiles/settings.cpp +@@ -96,6 +96,8 @@ int32 gIntRetinaFactor = 1; + DBIPlatform gPlatform = dbipWindows; + #elif defined Q_OS_MAC + DBIPlatform gPlatform = dbipMac; ++#elif defined Q_OS_HAIKU ++DBIPlatform gPlatform = dbipHaiku; + #elif defined Q_OS_LINUX64 + DBIPlatform gPlatform = dbipLinux64; + #elif defined Q_OS_LINUX32 +@@ -230,6 +232,10 @@ void InitFromCommandLine(int argc, char *argv[]) { + gUpdateURL = QUrl(qsl("http://tdesktop.com/linux32/tupdates/current")); + gPlatformString = qsl("Linux32bit"); + break; ++ case dbipHaiku: ++ gUpdateURL = QUrl(); ++ gPlatformString = qsl("HaikuDepot"); ++ break; + } + + auto path = Platform::CurrentExecutablePath(argc, argv); +-- +2.13.1 + + +From df87885512c1377a2a056053f661f5e74397c5af Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:09:59 +1000 +Subject: Fix Qt plugins path + + +diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp +index 4684e2a..c65879b 100644 +--- a/Telegram/SourceFiles/main.cpp ++++ b/Telegram/SourceFiles/main.cpp +@@ -41,9 +41,7 @@ int main(int argc, char *argv[]) { + Platform::start(); // must be started before QApplication is created + + // I don't know why path is not in QT_PLUGIN_PATH by default +- QCoreApplication::addLibraryPath("/boot/system/add-ons/Qt"); +- // without this Telegram doesn't start on Ubuntu 17.04 due GTK errors +- setenv("QT_STYLE_OVERRIDE", "qwerty", false); ++ QCoreApplication::addLibraryPath("/boot/system/add-ons/Qt5"); + + int result = 0; + { +-- +2.13.1 + + +From 26f0a37bf988909edffff348f51e0a1b535bc4ac Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:10:59 +1000 +Subject: Fix crash + + +diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp +index b0a1ade..9c84a34 100644 +--- a/Telegram/SourceFiles/media/media_audio.cpp ++++ b/Telegram/SourceFiles/media/media_audio.cpp +@@ -98,6 +98,7 @@ void EnumeratePlaybackDevices() { + void EnumerateCaptureDevices() { + auto deviceNames = QStringList(); + auto devices = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER); ++#ifndef __HAIKU__ + Assert(devices != nullptr); + while (*devices != 0) { + auto deviceName8Bit = QByteArray(devices); +@@ -106,7 +107,7 @@ void EnumerateCaptureDevices() { + devices += deviceName8Bit.size() + 1; + } + LOG(("Audio Capture Devices: %1").arg(deviceNames.join(';'))); +- ++#endif + if (auto device = alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) { + LOG(("Audio Capture Default Device: %1").arg(QString::fromLocal8Bit(device))); + } else { +-- +2.13.1 + + +From ce1e1cfc24fac52864e13a95a974b3e588f0c204 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 15 Sep 2017 22:14:32 +1000 +Subject: Add haiku platform files to build + + +diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp +index e716483..05f88e1 100644 +--- a/Telegram/gyp/Telegram.gyp ++++ b/Telegram/gyp/Telegram.gyp +@@ -81,7 +81,7 @@ + 'codegen.gyp:codegen_numbers', + 'codegen.gyp:codegen_style', + 'tests/tests.gyp:tests', +-# '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip', ++ '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip', + ], + + 'defines': [ +diff --git a/Telegram/gyp/settings_haiku.gypi b/Telegram/gyp/settings_haiku.gypi +index 7b5161e..3e5f508 100644 +--- a/Telegram/gyp/settings_haiku.gypi ++++ b/Telegram/gyp/settings_haiku.gypi +@@ -41,6 +41,10 @@ + [ '" /dev/null --libs <@(pkgconfig_libs))', + ], +diff --git a/Telegram/gyp/telegram_sources.txt b/Telegram/gyp/telegram_sources.txt +index 58f2789..f86e6e6 100644 +--- a/Telegram/gyp/telegram_sources.txt ++++ b/Telegram/gyp/telegram_sources.txt +@@ -302,6 +302,10 @@ + <(src_loc)/mtproto/type_utils.h + <(src_loc)/overview/overview_layout.cpp + <(src_loc)/overview/overview_layout.h ++<(src_loc)/platform/haiku/file_utilities_haiku.cpp ++<(src_loc)/platform/haiku/file_utilities_haiku.h ++<(src_loc)/platform/haiku/notifications_manager_haiku.cpp ++<(src_loc)/platform/haiku/notifications_manager_haiku.h + <(src_loc)/platform/haiku/main_window_haiku.cpp + <(src_loc)/platform/haiku/main_window_haiku.h + <(src_loc)/platform/haiku/specific_haiku.cpp +-- +2.13.1 + + +From 28ec800e587b2a67e9797044cbcffb949329b59c Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sat, 16 Sep 2017 23:06:27 +1000 +Subject: Move working dir to user settings + + +diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp +index d916756..3d61a91 100644 +--- a/Telegram/SourceFiles/logs.cpp ++++ b/Telegram/SourceFiles/logs.cpp +@@ -311,7 +311,7 @@ namespace Logs { + QString initialWorkingDir = QDir(cWorkingDir()).absolutePath() + '/', moveOldDataFrom; + if (cBetaVersion()) { + cSetDebug(true); +-#if defined Q_OS_MAC || defined Q_OS_LINUX ++#if defined Q_OS_MAC || defined Q_OS_LINUX || defined Q_OS_HAIKU + } else { + #ifdef _DEBUG + cForceWorkingDir(cExeDir()); +diff --git a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp +index ce9091a..004017b 100644 +--- a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp ++++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp +@@ -285,28 +285,9 @@ void psActivateProcess(uint64 pid) { + // objc_activateProgram(); + } + +-namespace { +- +-QString getHomeDir() { +- struct passwd *pw = getpwuid(getuid()); +- return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QFile::decodeName(pw->pw_dir) + '/') : QString(); +-} +- +-} // namespace + + QString psAppDataPath() { +- // Previously we used ~/.TelegramDesktop, so look there first. +- // If we find data there, we should still use it. +- auto home = getHomeDir(); +- if (!home.isEmpty()) { +- auto oldPath = home + qsl(".TelegramDesktop/"); +- auto oldSettingsBase = oldPath + qsl("tdata/settings"); +- if (QFile(oldSettingsBase + '0').exists() || QFile(oldSettingsBase + '1').exists()) { +- return oldPath; +- } +- } +- +- return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; ++ return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + '/'; + } + + QString psDownloadPath() { +-- +2.13.1 + diff --git a/net-im/telegram-desktop/telegram-desktop-1.1.23.recipe b/net-im/telegram-desktop/telegram-desktop-1.1.23.recipe new file mode 100644 index 000000000..bbe34aa00 --- /dev/null +++ b/net-im/telegram-desktop/telegram-desktop-1.1.23.recipe @@ -0,0 +1,116 @@ +SUMMARY="Telegram Desktop Messenger" +DESCRIPTION="Official desktop version of Telegram messaging app." +HOMEPAGE="https://www.telegram.org/" +COPYRIGHT="2013-2017 Telegram" +LICENSE="GNU GPL v3" +REVISION="5" +SOURCE_URI="https://github.com/telegramdesktop/tdesktop/archive/v$portVersion.tar.gz" +CHECKSUM_SHA256="56b7fce84adf85a4af1c3174353169f32d0b0c052a4e7a284fc741fa96b04030" +COMMIT_2="757a5d8ec31aadcf387ac3cb135256152c18de1c" +SOURCE_URI_2="https://github.com/telegramdesktop/libtgvoip/archive/$COMMIT_2.zip" +CHECKSUM_SHA256_2="afd82dde02fb43c0e66e462a3da1d9e84ae76aa3e71d37e696c261aa151d3cdd" +COMMIT_3="550ac2f159ca883d360c196149b466955c77a573" +SOURCE_URI_3="https://github.com/mapbox/variant/archive/$COMMIT_3.zip" +CHECKSUM_SHA256_3="3676117c49db1ef1ff2818f6f70713c3a4469f0da8ecb5c98c157499322501fc" +COMMIT_4="c5851a8161938798c5594a66420cb814fea92711" +SOURCE_URI_4="https://github.com/Microsoft/GSL/archive/$COMMIT_4.zip" +CHECKSUM_SHA256_4="2fe4befdd1cd69de435797c8c50cd7ce749d140982f2260eead90f31721d2c95" +COMMIT_5="5ca44b68721833ae3731802ed99af67c6f38a53a" +SOURCE_URI_5="https://github.com/philsquared/Catch/archive/$COMMIT_5.zip" +CHECKSUM_SHA256_5="bec93e64dea2dd0c6662a75a81cdd1747a753ccd86025ef436b7d2fac3b408d2" + +ADDITIONAL_FILES="tdesktop.rdef.in" +PATCHES="tdesktop-$portVersion.patchset" +PATCHES_2="tdesktop-$portVersion-libtgvoip.patchset" + +ARCHITECTURES="!x86_gcc2 x86_64" +SECONDARY_ARCHITECTURES="?x86" + +PROVIDES=" + tdesktop$secondaryArchSuffix = $portVersion + app:Telegram$secondaryArchSuffix + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libavcodec$secondaryArchSuffix + lib:libavformat$secondaryArchSuffix + lib:libavutil$secondaryArchSuffix + lib:libcrypto$secondaryArchSuffix + lib:libglib_2.0$secondaryArchSuffix + lib:libgthread_2.0$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:libswresample$secondaryArchSuffix + lib:libswscale$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libavcodec$secondaryArchSuffix + devel:libavformat$secondaryArchSuffix + devel:libavutil$secondaryArchSuffix + devel:libcrypto$secondaryArchSuffix + devel:libglib_2.0$secondaryArchSuffix + devel:libgthread_2.0$secondaryArchSuffix + devel:liblzma$secondaryArchSuffix + devel:libminizip$secondaryArchSuffix + devel:libopenal$secondaryArchSuffix + devel:libopus$secondaryArchSuffix + devel:libQt5Core$secondaryArchSuffix + devel:libQt5Gui$secondaryArchSuffix + devel:libQt5Network$secondaryArchSuffix + devel:libQt5Widgets$secondaryArchSuffix + devel:libswresample$secondaryArchSuffix + devel:libswscale$secondaryArchSuffix + devel:libz$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:cmake + cmd:gyp >= 20160504 + cmd:gcc$secondaryArchSuffix + cmd:make + cmd:pkg_config$secondaryArchSuffix + " + +BUILD() +{ + # link submodules + rm -rf Telegram/ThirdParty/{libtgvoip,variant,GSL,Catch} + ln -sfn $sourceDir2/libtgvoip-$COMMIT_2 Telegram/ThirdParty/libtgvoip + ln -sfn $sourceDir3/variant-$COMMIT_3 Telegram/ThirdParty/variant + ln -sfn $sourceDir4/GSL-$COMMIT_4 Telegram/ThirdParty/GSL + ln -sfn $sourceDir5/Catch-$COMMIT_5 Telegram/ThirdParty/Catch + + Telegram/gyp/refresh.sh ; cd out/Release + # multi-job takes too much memory + make +} + +INSTALL() +{ + mkdir -p $appsDir + cp out/Release/Telegram $appsDir + strip $appsDir/Telegram + + local APP_SIGNATURE="application/x-vnd.telegram" + 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/tdesktop.rdef.in > tdesktop.rdef + + addResourcesToBinaries tdesktop.rdef $appsDir/Telegram + addAppDeskbarSymlink $appsDir/Telegram +}