diff --git a/net-im/telegram-desktop/additional-files/logo_256_no_margin.png b/net-im/telegram-desktop/additional-files/logo_256_no_margin.png deleted file mode 100644 index 82b67376f..000000000 Binary files a/net-im/telegram-desktop/additional-files/logo_256_no_margin.png and /dev/null differ diff --git a/net-im/telegram-desktop/patches/libtgvoip-2.6.1.patchset b/net-im/telegram-desktop/patches/libtgvoip-2.6.1.patchset new file mode 100644 index 000000000..c1c16ab06 --- /dev/null +++ b/net-im/telegram-desktop/patches/libtgvoip-2.6.1.patchset @@ -0,0 +1,954 @@ +From fa203d769199d21dd4b007d2f9d60479972e58de Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Thu, 25 Feb 2021 17:18:39 +1000 +Subject: Add Haiku support + + +diff --git a/Telegram/ThirdParty/libtgvoip/VoIPController.cpp b/Telegram/ThirdParty/libtgvoip/VoIPController.cpp +index d0b0038..c2c258b 100644 +--- a/Telegram/ThirdParty/libtgvoip/VoIPController.cpp ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp +index 2c16ca7..e00c731 100644 +--- a/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp ++++ b/Telegram/ThirdParty/libtgvoip/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__) + #ifndef WITHOUT_ALSA + #ifndef WITHOUT_PULSE +diff --git a/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp +index 674cd34..83a6dbb 100644 +--- a/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp +index 14ab0be..44c615e 100644 +--- a/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.cpp +new file mode 100644 +index 0000000..7cce3e3 +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.h b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.h +new file mode 100644 +index 0000000..1c63afe +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.cpp +new file mode 100644 +index 0000000..2fca8a1 +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.h b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.h +new file mode 100644 +index 0000000..91f2521 +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.cpp +new file mode 100644 +index 0000000..6c94933 +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.h b/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.h +new file mode 100644 +index 0000000..01f6096 +--- /dev/null ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp b/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp +index 78e0583..81bf9fc 100644 +--- a/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/threading.h b/Telegram/ThirdParty/libtgvoip/threading.h +old mode 100755 +new mode 100644 +index 81c577c..1ccf029 +--- a/Telegram/ThirdParty/libtgvoip/threading.h ++++ b/Telegram/ThirdParty/libtgvoip/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 +@@ -92,6 +92,7 @@ namespace tgvoip{ + static void* ActualEntryPoint(void* arg){ + Thread* self=reinterpret_cast(arg); + if(self->name){ ++#ifndef __HAIKU__ + #if !defined(__APPLE__) && !defined(__gnu_hurd__) + pthread_setname_np(self->thread, self->name); + #elif !defined(__gnu_hurd__) +@@ -100,6 +101,7 @@ namespace tgvoip{ + DarwinSpecific::SetCurrentThreadPriority(DarwinSpecific::THREAD_PRIO_USER_INTERACTIVE); + } + #endif ++#endif //__HAIKU__ + } + self->entry(); + return NULL; +diff --git a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc +old mode 100755 +new mode 100644 +index a8d1522..991241b +--- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_file.h b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_file.h +old mode 100755 +new mode 100644 +diff --git a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc +index cf7d478..f27b9a1 100644 +--- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc ++++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h +index 0bc42eb..c87cde9 100644 +--- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h ++++ b/Telegram/ThirdParty/libtgvoip/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; +diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake +index 74d4f26..79f5023 100644 +--- a/Telegram/cmake/lib_tgvoip.cmake ++++ b/Telegram/cmake/lib_tgvoip.cmake +@@ -120,6 +120,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 +@@ -157,6 +165,38 @@ 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 ++ be ++ network ++ media ++ ) ++ remove_target_sources(lib_tgvoip_bundled ${tgvoip_loc} ++ os/linux/AudioInputALSA.cpp ++ os/linux/AudioInputALSA.h ++ os/linux/AudioOutputALSA.cpp ++ os/linux/AudioOutputALSA.h ++ os/linux/AudioOutputPulse.cpp ++ os/linux/AudioOutputPulse.h ++ os/linux/AudioInputPulse.cpp ++ os/linux/AudioInputPulse.h ++ os/linux/AudioPulse.cpp ++ os/linux/AudioPulse.h ++ ) + else() + target_compile_options(lib_tgvoip_bundled + PRIVATE +@@ -179,7 +219,7 @@ if (NOT TGVOIP_FOUND) + desktop-app::external_opus + ) + +- if (LINUX) ++ if (LINUX AND NOT HAIKU) + find_package(PkgConfig REQUIRED) + find_package(ALSA REQUIRED) + pkg_check_modules(PULSE REQUIRED libpulse) +-- +2.30.0 + diff --git a/net-im/telegram-desktop/patches/telegram_desktop-2.5.9-owt.patchset b/net-im/telegram-desktop/patches/telegram_desktop-2.5.9-owt.patchset deleted file mode 100644 index 7cfb661d8..000000000 --- a/net-im/telegram-desktop/patches/telegram_desktop-2.5.9-owt.patchset +++ /dev/null @@ -1,822 +0,0 @@ -From c7cf52d0deb5c65488d287ba89fe58026011a000 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 30 Jan 2021 21:16:28 +1000 -Subject: Add Haiku support - - -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/CMakeLists.txt b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/CMakeLists.txt -index 7a5bb2c..24db2ef 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/CMakeLists.txt -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/CMakeLists.txt -@@ -58,7 +58,7 @@ include(cmake/libusrsctp.cmake) - include(cmake/libvpx.cmake) - include(cmake/libwebrtcbuild.cmake) - include(cmake/libyuv.cmake) --if (NOT WIN32 AND NOT APPLE) -+if (NOT WIN32 AND NOT APPLE AND NOT HAIKU) - include(cmake/libevent.cmake) - endif() - if (APPLE) -@@ -127,7 +127,7 @@ PRIVATE - ${libopenh264_yasm_objects} - ) - --if (NOT WIN32 AND NOT APPLE) -+if (NOT WIN32 AND NOT APPLE AND NOT HAIKU) - target_link_libraries(tg_owt PRIVATE tg_owt::libevent) - endif() - if (APPLE) -@@ -410,6 +410,8 @@ PRIVATE - rtc_base/task_queue.cc - rtc_base/task_queue_gcd.cc - rtc_base/task_queue_gcd.h -+ rtc_base/task_queue_stdlib.cc -+ rtc_base/task_queue_stdlib.h - rtc_base/task_queue_libevent.cc - rtc_base/task_queue_libevent.h - rtc_base/task_queue_win.cc -@@ -489,6 +491,7 @@ PRIVATE - api/stats_types.cc - api/task_queue/default_task_queue_factory.h - api/task_queue/default_task_queue_factory_gcd.cc -+ api/task_queue/default_task_queue_factory_stdlib.cc - api/task_queue/default_task_queue_factory_libevent.cc - api/task_queue/default_task_queue_factory_win.cc - api/task_queue/task_queue_base.cc -@@ -1410,6 +1413,8 @@ PRIVATE - modules/video_capture/device_info_impl.cc - modules/video_capture/linux/device_info_linux.cc - modules/video_capture/linux/video_capture_linux.cc -+ modules/video_capture/haiku/device_info_haiku.cc -+ modules/video_capture/haiku/video_capture_haiku.cc - modules/video_capture/windows/device_info_ds.cc - modules/video_capture/windows/device_info_ds.h - modules/video_capture/windows/help_functions_ds.cc -@@ -2105,7 +2110,7 @@ else() - ) - endif() - --if (WIN32 OR APPLE) -+if (WIN32 OR APPLE OR HAIKU) - remove_target_sources(tg_owt ${webrtc_loc} - rtc_base/task_queue_libevent.cc - rtc_base/task_queue_libevent.h -@@ -2121,7 +2126,7 @@ else() - endif() - - set(platform_export) --if (NOT WIN32 AND NOT APPLE) -+if (NOT WIN32 AND NOT APPLE AND NOT HAIKU) - set(platform_export - libevent - ) -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libusrsctp.cmake b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libusrsctp.cmake -index f652679..0c00f10 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libusrsctp.cmake -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libusrsctp.cmake -@@ -25,6 +25,11 @@ elseif (APPLE) - PRIVATE - -U__APPLE__ - ) -+elseif (HAIKU) -+ target_compile_definitions(libusrsctp -+ PRIVATE -+ __Userspace_os_Haiku -+ ) - else() - target_compile_definitions(libusrsctp - PRIVATE -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libwebrtcbuild.cmake b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libwebrtcbuild.cmake -index d79049e..bad89f0 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libwebrtcbuild.cmake -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/libwebrtcbuild.cmake -@@ -17,8 +17,8 @@ INTERFACE - WEBRTC_USE_H264 - WEBRTC_LIBRARY_IMPL - WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1 -- WEBRTC_ENABLE_LINUX_ALSA -- WEBRTC_ENABLE_LINUX_PULSE -+# WEBRTC_ENABLE_LINUX_ALSA -+# WEBRTC_ENABLE_LINUX_PULSE - HAVE_WEBRTC_VIDEO - RTC_ENABLE_VP9 - ) -@@ -34,6 +34,12 @@ elseif (APPLE) - WEBRTC_POSIX - WEBRTC_MAC - ) -+elseif (HAIKU) -+ target_compile_definitions(libwebrtcbuild -+ INTERFACE -+ WEBRTC_POSIX -+ WEBRTC_HAIKU -+ ) - else() - target_compile_definitions(libwebrtcbuild - INTERFACE -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/nice_target_sources.cmake b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/nice_target_sources.cmake -index cfc6aeb..699d0e6 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/nice_target_sources.cmake -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/cmake/nice_target_sources.cmake -@@ -15,6 +15,7 @@ function(nice_target_sources target_name src_loc) - set(not_win_sources "") - set(not_mac_sources "") - set(not_linux_sources "") -+ set(not_haiku_sources "") - foreach (entry ${list}) - if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") - set(writing_now ${entry}) -@@ -23,12 +24,19 @@ function(nice_target_sources target_name src_loc) - if (${entry} MATCHES "(^|/)win/" OR ${entry} MATCHES "(^|/)winrc/" OR ${entry} MATCHES "(^|/)windows/" OR ${entry} MATCHES "[_\\/]win\\.") - list(APPEND not_mac_sources ${full_name}) - list(APPEND not_linux_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)mac/" OR ${entry} MATCHES "(^|/)darwin/" OR ${entry} MATCHES "(^|/)osx/" OR ${entry} MATCHES "[_\\/]mac\\." OR ${entry} MATCHES "[_\\/]darwin\\." OR ${entry} MATCHES "[_\\/]osx\\.") - list(APPEND not_win_sources ${full_name}) - list(APPEND not_linux_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)linux/" OR ${entry} MATCHES "[_\\/]linux\\.") - list(APPEND not_win_sources ${full_name}) - list(APPEND not_mac_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) -+ elseif (${entry} MATCHES "(^|/)haiku/" OR ${entry} MATCHES "[_\\/]haiku\\.") -+ list(APPEND not_win_sources ${full_name}) -+ list(APPEND not_mac_sources ${full_name}) -+ list(APPEND not_linux_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)posix/" OR ${entry} MATCHES "[_\\/]posix\\.") - list(APPEND not_win_sources ${full_name}) - endif() -@@ -64,6 +72,9 @@ function(nice_target_sources target_name src_loc) - elseif (APPLE) - set_source_files_properties(${not_mac_sources} PROPERTIES HEADER_FILE_ONLY TRUE) - set_source_files_properties(${not_mac_sources} PROPERTIES SKIP_AUTOGEN TRUE) -+ elseif (HAIKU) -+ set_source_files_properties(${not_haiku_sources} PROPERTIES HEADER_FILE_ONLY TRUE) -+ set_source_files_properties(${not_haiku_sources} PROPERTIES SKIP_AUTOGEN TRUE) - else() - set_source_files_properties(${not_linux_sources} PROPERTIES HEADER_FILE_ONLY TRUE) - set_source_files_properties(${not_linux_sources} PROPERTIES SKIP_AUTOGEN TRUE) -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/api/task_queue/BUILD.gn b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/api/task_queue/BUILD.gn -index 1072057..745f5b7 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/api/task_queue/BUILD.gn -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/api/task_queue/BUILD.gn -@@ -82,7 +82,7 @@ rtc_library("default_task_queue_factory") { - sources = [ "default_task_queue_factory.h" ] - deps = [ ":task_queue" ] - -- if (rtc_enable_libevent) { -+ if (rtc_enable_libevent && !is_haiku) { - sources += [ "default_task_queue_factory_libevent.cc" ] - deps += [ "../../rtc_base:rtc_task_queue_libevent" ] - } else if (is_mac || is_ios) { -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.cc -new file mode 100644 -index 0000000..6f1c551 ---- /dev/null -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.cc -@@ -0,0 +1,69 @@ -+#include "modules/video_capture/haiku/device_info_haiku.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "modules/video_capture/video_capture.h" -+#include "modules/video_capture/video_capture_defines.h" -+#include "modules/video_capture/video_capture_impl.h" -+#include "rtc_base/logging.h" -+ -+namespace webrtc { -+namespace videocapturemodule { -+VideoCaptureModule::DeviceInfo* VideoCaptureImpl::CreateDeviceInfo() { -+ return new videocapturemodule::DeviceInfoHaiku(); -+} -+ -+DeviceInfoHaiku::DeviceInfoHaiku() : DeviceInfoImpl() {} -+ -+int32_t DeviceInfoHaiku::Init() { -+ return 0; -+} -+ -+DeviceInfoHaiku::~DeviceInfoHaiku() {} -+ -+uint32_t DeviceInfoHaiku::NumberOfDevices() { -+ return 0; -+} -+ -+int32_t DeviceInfoHaiku::GetDeviceName(uint32_t deviceNumber, -+ char* deviceNameUTF8, -+ uint32_t deviceNameLength, -+ char* deviceUniqueIdUTF8, -+ uint32_t deviceUniqueIdUTF8Length, -+ char* /*productUniqueIdUTF8*/, -+ uint32_t /*productUniqueIdUTF8Length*/) { -+ return -1; -+} -+ -+int32_t DeviceInfoHaiku::CreateCapabilityMap(const char* deviceUniqueIdUTF8) { -+ return -1; -+} -+ -+int32_t DeviceInfoHaiku::DisplayCaptureSettingsDialogBox( -+ const char* /*deviceUniqueIdUTF8*/, -+ const char* /*dialogTitleUTF8*/, -+ void* /*parentWindow*/, -+ uint32_t /*positionX*/, -+ uint32_t /*positionY*/) { -+ return -1; -+} -+ -+bool DeviceInfoHaiku::IsDeviceNameMatches(const char* name, -+ const char* deviceUniqueIdUTF8) { -+ return false; -+} -+ -+int32_t DeviceInfoHaiku::FillCapabilities(int fd) { -+ return -1; -+} -+ -+} // namespace videocapturemodule -+} // namespace webrtc -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.h -new file mode 100644 -index 0000000..96352fa ---- /dev/null -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/device_info_haiku.h -@@ -0,0 +1,36 @@ -+#ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_DEVICE_INFO_HAIKU_H_ -+#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_DEVICE_INFO_HAIKU_H_ -+ -+#include -+ -+#include "modules/video_capture/device_info_impl.h" -+ -+namespace webrtc { -+namespace videocapturemodule { -+class DeviceInfoHaiku : public DeviceInfoImpl { -+ public: -+ DeviceInfoHaiku(); -+ ~DeviceInfoHaiku() override; -+ uint32_t NumberOfDevices() override; -+ int32_t GetDeviceName(uint32_t deviceNumber, -+ char* deviceNameUTF8, -+ uint32_t deviceNameLength, -+ char* deviceUniqueIdUTF8, -+ uint32_t deviceUniqueIdUTF8Length, -+ char* productUniqueIdUTF8 = 0, -+ uint32_t productUniqueIdUTF8Length = 0) override; -+ int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) override; -+ int32_t DisplayCaptureSettingsDialogBox(const char*, -+ const char*, -+ void*, -+ uint32_t, -+ uint32_t) override; -+ int32_t FillCapabilities(int fd); -+ int32_t Init() override; -+ -+ private: -+ bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8); -+}; -+} // namespace videocapturemodule -+} // namespace webrtc -+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_DEVICE_INFO_HAIKU_H_ -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.cc -new file mode 100644 -index 0000000..94a79df ---- /dev/null -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.cc -@@ -0,0 +1,29 @@ -+#include "modules/video_capture/haiku/video_capture_haiku.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "api/scoped_refptr.h" -+#include "media/base/video_common.h" -+#include "modules/video_capture/video_capture.h" -+#include "rtc_base/logging.h" -+#include "rtc_base/ref_counted_object.h" -+ -+namespace webrtc { -+namespace videocapturemodule { -+rtc::scoped_refptr VideoCaptureImpl::Create( -+ const char* deviceUniqueId) { -+ return nullptr; -+} -+} // namespace videocapturemodule -+} // namespace webrtc -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h -new file mode 100644 -index 0000000..55a27fc ---- /dev/null -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h -@@ -0,0 +1,20 @@ -+#ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_VIDEO_CAPTURE_HAIKU_H_ -+#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_VIDEO_CAPTURE_HAIKU_H_ -+ -+#include -+#include -+ -+#include -+ -+#include "modules/video_capture/video_capture_defines.h" -+#include "modules/video_capture/video_capture_impl.h" -+#include "rtc_base/critical_section.h" -+#include "rtc_base/platform_thread.h" -+ -+namespace webrtc { -+namespace videocapturemodule { -+ -+} // namespace videocapturemodule -+} // namespace webrtc -+ -+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_HAIKU_VIDEO_CAPTURE_HAIKU_H_ -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/BUILD.gn b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/BUILD.gn -index c4f4d32..d5d82d1 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/BUILD.gn -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/BUILD.gn -@@ -489,7 +489,7 @@ rtc_source_set("rtc_operations_chain") { - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] - } - --if (rtc_enable_libevent) { -+if (rtc_enable_libevent && !is_haiku) { - rtc_library("rtc_task_queue_libevent") { - visibility = [ "../api/task_queue:default_task_queue_factory" ] - sources = [ -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/ip_address.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/ip_address.cc -index 9dd534c..aadf0fd 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/ip_address.cc -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/ip_address.cc -@@ -11,6 +11,9 @@ - #if defined(WEBRTC_POSIX) - #include - #include -+#if defined(WEBRTC_HAIKU) -+#include -+#endif - #ifdef OPENBSD - #include - #endif -@@ -32,6 +35,15 @@ - namespace rtc { - - // Prefixes used for categorizing IPv6 addresses. -+#if defined(WEBRTC_HAIKU) -+static const in6_addr kV4MappedPrefix = { -+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0}}; -+static const in6_addr k6To4Prefix = {{0x20, 0x02, 0}}; -+static const in6_addr kTeredoPrefix = {{0x20, 0x01, 0x00, 0x00}}; -+static const in6_addr kV4CompatibilityPrefix = {{0}}; -+static const in6_addr k6BonePrefix = {{0x3f, 0xfe, 0}}; -+static const in6_addr kPrivateNetworkPrefix = {{0xFD}}; -+#else - static const in6_addr kV4MappedPrefix = { - {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0}}}; - static const in6_addr k6To4Prefix = {{{0x20, 0x02, 0}}}; -@@ -39,6 +51,7 @@ static const in6_addr kTeredoPrefix = {{{0x20, 0x01, 0x00, 0x00}}}; - static const in6_addr kV4CompatibilityPrefix = {{{0}}}; - static const in6_addr k6BonePrefix = {{{0x3f, 0xfe, 0}}}; - static const in6_addr kPrivateNetworkPrefix = {{{0xFD}}}; -+#endif - - static bool IPIsHelper(const IPAddress& ip, - const in6_addr& tomatch, -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/logging.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/logging.cc -index 13a5f02..8362c3e 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/logging.cc -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/logging.cc -@@ -122,7 +122,11 @@ LogMessage::LogMessage(const char* file, - - if (thread_) { - PlatformThreadId id = CurrentThreadId(); -+#ifdef WEBRTC_HAIKU -+ print_stream_ << "[" << (uint64_t)id << "] "; -+#else - print_stream_ << "[" << id << "] "; -+#endif - } - - if (file != nullptr) { -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/network.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/network.cc -index 07c39ae..a2c077a 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/network.cc -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/network.cc -@@ -524,7 +524,7 @@ void BasicNetworkManager::ConvertIfAddrs(struct ifaddrs* interfaces, - continue; - } - // Skip ones which are down. -- if (!(cursor->ifa_flags & IFF_RUNNING)) { -+ if (!(cursor->ifa_flags & IFF_LINK)) { - continue; - } - // Skip unknown family. -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/physical_socket_server.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/physical_socket_server.cc -index 3cb7c20..ee1b674 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/physical_socket_server.cc -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/physical_socket_server.cc -@@ -69,7 +69,7 @@ typedef void* SockOptArg; - - #endif // WEBRTC_POSIX - --#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__) -+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(WEBRTC_HAIKU) && !defined(__native_client__) - - int64_t GetSocketRecvTimestamp(int socket) { - struct timeval tv_ioctl; -@@ -332,7 +332,7 @@ int PhysicalSocket::SetOption(Option opt, int value) { - value <<= 2; - #endif - } --#if defined(WEBRTC_POSIX) -+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_HAIKU) - if (sopt == IPV6_TCLASS) { - // Set the IPv4 option in all cases to support dual-stack sockets. - // Don't bother checking the return code, as this is expected to fail if -@@ -574,7 +574,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) { - #elif defined(WEBRTC_MAC) || defined(BSD) || defined(__native_client__) - RTC_LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported."; - return -1; --#elif defined(WEBRTC_POSIX) -+#elif defined(WEBRTC_POSIX) && !defined(WEBRTC_HAIKU) - *slevel = IPPROTO_IP; - *sopt = IP_MTU_DISCOVER; - break; -@@ -592,7 +592,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) { - *sopt = TCP_NODELAY; - break; - case OPT_DSCP: --#if defined(WEBRTC_POSIX) -+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_HAIKU) - if (family_ == AF_INET6) { - *slevel = IPPROTO_IPV6; - *sopt = IPV6_TCLASS; -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/platform_thread_types.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/platform_thread_types.h -index 6b9101e..0ae52e5 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/platform_thread_types.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/platform_thread_types.h -@@ -38,6 +38,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; -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export.h -index d1eb60a..9dc761d 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export.h -@@ -28,7 +28,7 @@ - - #else // WEBRTC_WIN - --#if __has_attribute(visibility) && defined(WEBRTC_LIBRARY_IMPL) -+#if defined(WEBRTC_LIBRARY_IMPL) - #define RTC_EXPORT __attribute__((visibility("default"))) - #endif - -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export_template.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export_template.h -index 4ac7043..5fe950f 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export_template.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/rtc_base/system/rtc_export_template.h -@@ -185,7 +185,7 @@ - - RTC_EXPORT_TEMPLATE_TEST(DEFAULT, ); // NOLINT - RTC_EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default")))); --RTC_EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport)); -+//RTC_EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport)); - RTC_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); - - #undef RTC_EXPORT_TEMPLATE_TEST -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/base/options.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/base/options.h -index 230bf1e..6e1b9e5 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/base/options.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/base/options.h -@@ -100,7 +100,7 @@ - // User code should not inspect this macro. To check in the preprocessor if - // absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY. - --#define ABSL_OPTION_USE_STD_ANY 2 -+#define ABSL_OPTION_USE_STD_ANY 0 - - - // ABSL_OPTION_USE_STD_OPTIONAL -@@ -127,7 +127,7 @@ - // absl::optional is a typedef of std::optional, use the feature macro - // ABSL_USES_STD_OPTIONAL. - --#define ABSL_OPTION_USE_STD_OPTIONAL 2 -+#define ABSL_OPTION_USE_STD_OPTIONAL 0 - - - // ABSL_OPTION_USE_STD_STRING_VIEW -@@ -154,7 +154,7 @@ - // absl::string_view is a typedef of std::string_view, use the feature macro - // ABSL_USES_STD_STRING_VIEW. - --#define ABSL_OPTION_USE_STD_STRING_VIEW 2 -+#define ABSL_OPTION_USE_STD_STRING_VIEW 0 - - // ABSL_OPTION_USE_STD_VARIANT - // -@@ -180,7 +180,7 @@ - // absl::variant is a typedef of std::variant, use the feature macro - // ABSL_USES_STD_VARIANT. - --#define ABSL_OPTION_USE_STD_VARIANT 2 -+#define ABSL_OPTION_USE_STD_VARIANT 0 - - - // ABSL_OPTION_USE_INLINE_NAMESPACE -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.cc b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.cc -index 8127cb0..40a23b6 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.cc -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.cc -@@ -19,22 +19,5 @@ - namespace absl { - ABSL_NAMESPACE_BEGIN - --bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2) { -- return (piece1.size() == piece2.size() && -- 0 == absl::strings_internal::memcasecmp(piece1.data(), piece2.data(), -- piece1.size())); -- // memcasecmp uses absl::ascii_tolower(). --} -- --bool StartsWithIgnoreCase(absl::string_view text, absl::string_view prefix) { -- return (text.size() >= prefix.size()) && -- EqualsIgnoreCase(text.substr(0, prefix.size()), prefix); --} -- --bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix) { -- return (text.size() >= suffix.size()) && -- EqualsIgnoreCase(text.substr(text.size() - suffix.size()), suffix); --} -- - ABSL_NAMESPACE_END - } // namespace absl -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.h -index 90fca98..53ada13 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/abseil-cpp/absl/strings/match.h -@@ -35,7 +35,9 @@ - - #include - -+#include "absl/strings/match.h" - #include "absl/strings/string_view.h" -+#include "absl/strings/internal/memutil.h" - - namespace absl { - ABSL_NAMESPACE_BEGIN -@@ -70,19 +72,30 @@ inline bool EndsWith(absl::string_view text, absl::string_view suffix) { - // - // Returns whether given ASCII strings `piece1` and `piece2` are equal, ignoring - // case in the comparison. --bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2); -+inline bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2) { -+ return (piece1.size() == piece2.size() && -+ 0 == absl::strings_internal::memcasecmp(piece1.data(), piece2.data(), -+ piece1.size())); -+ // memcasecmp uses absl::ascii_tolower(). -+} - - // StartsWithIgnoreCase() - // - // Returns whether a given ASCII string `text` starts with `prefix`, - // ignoring case in the comparison. --bool StartsWithIgnoreCase(absl::string_view text, absl::string_view prefix); -+inline bool StartsWithIgnoreCase(absl::string_view text, absl::string_view prefix) { -+ return (text.size() >= prefix.size()) && -+ EqualsIgnoreCase(text.substr(0, prefix.size()), prefix); -+} - - // EndsWithIgnoreCase() - // - // Returns whether a given ASCII string `text` ends with `suffix`, ignoring - // case in the comparison. --bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix); -+inline bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix) { -+ return (text.size() >= suffix.size()) && -+ EqualsIgnoreCase(text.substr(text.size() - suffix.size()), suffix); -+} - - ABSL_NAMESPACE_END - } // namespace absl -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/openh264/src/codec/common/src/WelsThreadLib.cpp b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/openh264/src/codec/common/src/WelsThreadLib.cpp -index 8aa67f1..5c2b6e1 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/openh264/src/codec/common/src/WelsThreadLib.cpp -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/openh264/src/codec/common/src/WelsThreadLib.cpp -@@ -48,7 +48,7 @@ - #include - #include - #include --#ifndef __Fuchsia__ -+#if !defined(__Fuchsia__) && !defined(__HAIKU__) - #include - #endif - #ifdef __APPLE__ -@@ -244,7 +244,7 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_ - err = pthread_attr_init (&at); - if (err) - return err; --#if !defined(__ANDROID__) && !defined(__Fuchsia__) -+#if !defined(__ANDROID__) && !defined(__Fuchsia__) && !defined(__HAIKU__) - err = pthread_attr_setscope (&at, PTHREAD_SCOPE_SYSTEM); - if (err) - return err; -@@ -517,6 +517,10 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p - - return WELS_THREAD_ERROR_OK; - -+#elif defined(__HAIKU__) -+ pInfo->ProcessorCount = 1; -+ return WELS_THREAD_ERROR_OK; -+ - #elif defined(__EMSCRIPTEN__) - - // There is not yet a way to determine CPU count in emscripten JS environment. -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h -index 9847624..82409dd 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h -@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $ - #ifndef _NETINET_SCTP_H_ - #define _NETINET_SCTP_H_ - --#if (defined(__APPLE__) || defined(__Userspace_os_Linux) || defined(__Userspace_os_Darwin)) -+#if (defined(__APPLE__) || defined(__Userspace_os_Linux) || defined(__Userspace_os_Darwin) || defined(__Userspace_os_Haiku)) - #include - #endif - -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c -index 5afe781..e1d99a7 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c -@@ -6304,7 +6304,7 @@ sctp_input(i_pak, va_alist) - #if defined(__Windows__) - NTOHS(ip->ip_len); - #endif --#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) -+#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Haiku) - ip->ip_len = ntohs(ip->ip_len); - #endif - #if defined(__FreeBSD__) -@@ -6316,7 +6316,7 @@ sctp_input(i_pak, va_alist) - #elif defined(__APPLE__) - length = ip->ip_len + iphlen; - #elif defined(__Userspace__) --#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) -+#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Haiku) - length = ip->ip_len; - #else - length = ip->ip_len + iphlen; -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h -index f09cb8d..c26fad1 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h -@@ -277,7 +277,7 @@ typedef char* caddr_t; - - #else /* !defined(Userspace_os_Windows) */ - #include --#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_Fuchsia) -+#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_Fuchsia) || defined(__Userspace_os_Haiku) - #include - #endif - typedef pthread_mutex_t userland_mutex_t; -@@ -1155,7 +1155,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a - - #define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0) - --#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) -+#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) || defined(__Userspace_os_Haiku) - int - timingsafe_bcmp(const void *, const void *, size_t); - #endif -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c -index 28922b6..dba15fd 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c -@@ -94,7 +94,7 @@ sctp_userspace_set_threadname(const char *name) - #endif - } - --#if !defined(_WIN32) && !defined(__Userspace_os_NaCl) -+#if !defined(_WIN32) && !defined(__Userspace_os_NaCl) && !defined(__Userspace_os_Haiku) - int - sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) - { -@@ -118,7 +118,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) - } - #endif - --#if defined(__Userspace_os_NaCl) -+#if defined(__Userspace_os_NaCl) || defined(__Userspace_os_Haiku) - int - sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) - { -@@ -126,7 +126,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) - } - #endif - --#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) -+#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) || defined(__Userspace_os_Haiku) - int - timingsafe_bcmp(const void *b1, const void *b2, size_t n) - { -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c -index 146a6d9..63a6240 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c -@@ -50,6 +50,9 @@ - #if defined(__Userspace_os_Linux) - #define __FAVOR_BSD /* (on Ubuntu at least) enables UDP header field names like BSD in RFC 768 */ - #endif -+#if defined(__Userspace_os_Haiku) -+#define UIO_MAXIOV _SC_IOV_MAX -+#endif - #if !defined (__Userspace_os_Windows) - #if defined INET || defined INET6 - #include -@@ -1068,7 +1071,7 @@ userspace_sctp_recvmsg(struct socket *so, - if (error) { - if ((auio.uio_resid != ulen) && - (error == EINTR || --#if !defined(__Userspace_os_NetBSD) -+#if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Haiku) - error == ERESTART || - #endif - error == EWOULDBLOCK)) { -@@ -1161,7 +1164,7 @@ usrsctp_recvv(struct socket *so, - if (errno) { - if ((auio.uio_resid != ulen) && - (errno == EINTR || --#if !defined(__Userspace_os_NetBSD) -+#if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Haiku) - errno == ERESTART || - #endif - errno == EWOULDBLOCK)) { -@@ -2117,7 +2120,7 @@ int user_connect(struct socket *so, struct sockaddr *sa) - error = pthread_cond_wait(SOCK_COND(so), SOCK_MTX(so)); - #endif - if (error) { --#if defined(__Userspace_os_NetBSD) -+#if defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Haiku) - if (error == EINTR) { - #else - if (error == EINTR || error == ERESTART) { -@@ -2137,7 +2140,7 @@ bad: - if (!interrupted) { - so->so_state &= ~SS_ISCONNECTING; - } --#if !defined(__Userspace_os_NetBSD) -+#if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Haiku) - if (error == ERESTART) { - error = EINTR; - } --- -2.30.0 - - -From 489b7fbcdf3eb5f9ea7e80bc3aab944be19c3001 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 30 Jan 2021 22:18:47 +1000 -Subject: Fix build - - -diff --git a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h -index 55a27fc..ac60bb0 100644 ---- a/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h -+++ b/tg_owt-be23804afce3bb2e80a1d57a7c1318c71b82b7de/src/modules/video_capture/haiku/video_capture_haiku.h -@@ -8,8 +8,8 @@ - - #include "modules/video_capture/video_capture_defines.h" - #include "modules/video_capture/video_capture_impl.h" --#include "rtc_base/critical_section.h" - #include "rtc_base/platform_thread.h" -+#include "rtc_base/synchronization/mutex.h" - - namespace webrtc { - namespace videocapturemodule { --- -2.30.0 - diff --git a/net-im/telegram-desktop/patches/telegram_desktop-2.5.9.patchset b/net-im/telegram-desktop/patches/telegram_desktop-2.5.9.patchset deleted file mode 100644 index 0822fe1b2..000000000 --- a/net-im/telegram-desktop/patches/telegram_desktop-2.5.9.patchset +++ /dev/null @@ -1,3405 +0,0 @@ -From 8d6196668c8a25cdd359fda508973d0b07fec133 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 18 Feb 2021 09:41:18 +1000 -Subject: Add Haiku support - - -diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt -index 85f8277..03e3292 100644 ---- a/Telegram/CMakeLists.txt -+++ b/Telegram/CMakeLists.txt -@@ -908,6 +908,18 @@ PRIVATE - platform/win/windows_dlls.h - platform/win/windows_event_filter.cpp - platform/win/windows_event_filter.h -+ platform/haiku/file_utilities_haiku.cpp -+ platform/haiku/file_utilities_haiku.h -+ platform/haiku/launcher_haiku.cpp -+ platform/haiku/launcher_haiku.h -+ platform/haiku/main_window_haiku.cpp -+ platform/haiku/main_window_haiku.h -+ platform/haiku/notifications_manager_haiku.cpp -+ platform/haiku/notifications_manager_haiku.h -+ platform/haiku/window_title_haiku.cpp -+ platform/haiku/window_title_haiku.h -+ platform/haiku/specific_haiku.cpp -+ platform/haiku/specific_haiku.h - platform/platform_audio.h - platform/platform_file_utilities.h - platform/platform_launcher.h -@@ -1121,7 +1133,7 @@ PRIVATE - stdafx.h - ) - --if (NOT LINUX) -+if (NOT LINUX AND NOT HAIKU) - remove_target_sources(Telegram ${src_loc} - window/window_title_qt.cpp - window/window_title_qt.h -diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h -index 76320ad..e2f3147 100644 ---- a/Telegram/SourceFiles/core/core_settings.h -+++ b/Telegram/SourceFiles/core/core_settings.h -@@ -599,7 +599,7 @@ private: - rpl::variable _dialogsWidthRatio; // per-window - rpl::variable _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w - bool _notifyFromAll = true; -- rpl::variable _nativeWindowFrame = false; -+ rpl::variable _nativeWindowFrame = true; - rpl::variable> _systemDarkMode = std::nullopt; - rpl::variable _systemDarkModeEnabled = false; - rpl::variable _windowControlsLayout; -diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp -index 850e153..3bd14db 100644 ---- a/Telegram/SourceFiles/core/update_checker.cpp -+++ b/Telegram/SourceFiles/core/update_checker.cpp -@@ -1553,7 +1553,7 @@ bool checkReadyUpdate() { - ClearAll(); - return false; - } --#elif defined Q_OS_UNIX // Q_OS_MAC -+#elif defined Q_OS_UNIX && !defined Q_OS_HAIKU // Q_OS_MAC - if (!linuxMoveFile(QFile::encodeName(updater.absoluteFilePath()).constData(), QFile::encodeName(curUpdater).constData())) { - ClearAll(); - return false; -diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp -index bcc4392..6e838e6 100644 ---- a/Telegram/SourceFiles/data/data_session.cpp -+++ b/Telegram/SourceFiles/data/data_session.cpp -@@ -237,7 +237,7 @@ Session::Session(not_null session) - _cache->open(_session->local().cacheKey()); - _bigFileCache->open(_session->local().cacheBigFileKey()); - -- if constexpr (Platform::IsLinux()) { -+ if constexpr (Platform::IsLinux() || Platform::IsHaiku()) { - const auto wasVersion = _session->local().oldMapVersion(); - if (wasVersion >= 1007011 && wasVersion < 1007015) { - _bigFileCache->clear(); -diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp -index 7607cd2..f906b23 100644 ---- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp -+++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp -@@ -374,7 +374,7 @@ OverlayWidget::OverlayWidget() - - hide(); - createWinId(); -- if (Platform::IsLinux()) { -+ if (Platform::IsLinux() || Platform::IsHaiku()) { - windowHandle()->setTransientParent(App::wnd()->windowHandle()); - setWindowModality(Qt::WindowModal); - } -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..c0784ff ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp -@@ -0,0 +1,34 @@ -+/* -+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-2019 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "platform/haiku/file_utilities_haiku.h" -+ -+#include "core/application.h" -+#include "mainwindow.h" -+#include "boxes/abstract_box.h" -+#include "base/platform/base_platform_file_utilities.h" -+#include "storage/localstorage.h" -+#include "facades.h" -+ -+#include -+ -+namespace Platform { -+namespace File { -+ -+void UnsafeShowInFolder(const QString &filepath) { -+ Ui::hideLayer(anim::type::instant); -+ base::Platform::ShowInFolder(filepath); -+} -+ -+void UnsafeOpenUrl(const QString &url) { -+ QDesktopServices::openUrl(url); -+} -+ -+} // namespace File -+} // 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..429f17a ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.h -@@ -0,0 +1,66 @@ -+/* -+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-2019 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "platform/platform_file_utilities.h" -+ -+namespace Platform { -+namespace File { -+ -+inline QString UrlToLocal(const QUrl &url) { -+ return ::File::internal::UrlToLocalDefault(url); -+} -+ -+inline void UnsafeOpenEmailLink(const QString &email) { -+ return ::File::internal::UnsafeOpenEmailLinkDefault(email); -+} -+ -+inline bool UnsafeShowOpenWith(const QString &filepath) { -+ return false; -+} -+inline bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) { -+ 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(); -+} -+ -+inline bool Get( -+ QPointer parent, -+ QStringList &files, -+ QByteArray &remoteContent, -+ const QString &caption, -+ const QString &filter, -+ ::FileDialog::internal::Type type, -+ QString startFile) { -+ return ::FileDialog::internal::GetDefault( -+ parent, -+ files, -+ remoteContent, -+ caption, -+ filter, -+ type, -+ startFile); -+} -+ -+} // namespace FileDialog -+} // namespace Platform -diff --git a/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp b/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp -new file mode 100644 -index 0000000..9796438 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp -@@ -0,0 +1,32 @@ -+/* -+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 "platform/haiku/launcher_haiku.h" -+ -+#include "base/platform/base_platform_info.h" -+#include "core/crash_reports.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+namespace Platform { -+ -+Launcher::Launcher(int argc, char *argv[]) -+: Core::Launcher(argc, argv) { -+} -+ -+bool Launcher::launchUpdater(UpdaterLaunch action) { -+ return false; -+} -+ -+} // namespace -diff --git a/Telegram/SourceFiles/platform/haiku/launcher_haiku.h b/Telegram/SourceFiles/platform/haiku/launcher_haiku.h -new file mode 100644 -index 0000000..45d4cf8 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/launcher_haiku.h -@@ -0,0 +1,25 @@ -+/* -+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-2019 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "core/launcher.h" -+ -+namespace Platform { -+ -+class Launcher : public Core::Launcher { -+public: -+ Launcher(int argc, char *argv[]); -+ -+private: -+ bool launchUpdater(UpdaterLaunch action) override; -+ -+}; -+ -+} // 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..e30d9ba ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp -@@ -0,0 +1,95 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "platform/haiku/main_window_haiku.h" -+ -+#include "styles/style_window.h" -+#include "platform/platform_notifications_manager.h" -+#include "window/notifications_manager.h" -+#include "mainwindow.h" -+#include "base/crc32hash.h" -+#include "core/application.h" -+#include "lang/lang_keys.h" -+#include "storage/localstorage.h" -+#include "ui/widgets/popup_menu.h" -+#include "window/themes/window_theme.h" -+#include "history/history.h" -+#include "facades.h" -+#include "app.h" -+ -+#include -+ -+namespace Platform { -+ -+MainWindow::MainWindow(not_null controller) -+: Window::MainWindow(controller) { -+} -+ -+bool MainWindow::hasTrayIcon() const { -+ return true; -+} -+ -+void MainWindow::psShowTrayMenu() { -+} -+ -+bool MainWindow::isActiveForTrayMenu() { -+ return isVisible(); -+} -+ -+void MainWindow::psTrayMenuUpdated() { -+ if (trayIcon && trayIconMenu -+ && trayIcon->contextMenu() != trayIconMenu) { -+ trayIcon->setContextMenu(trayIconMenu); -+ } -+} -+ -+void MainWindow::psSetupTrayIcon() { -+ if (!trayIcon) { -+ trayIcon = new QSystemTrayIcon(this); -+ auto icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin())); -+ trayIcon->setIcon(icon); -+ attachToTrayIcon(trayIcon); -+ } -+ updateIconCounters(); -+ trayIcon->show(); -+} -+ -+void MainWindow::workmodeUpdated(DBIWorkMode mode) { -+ psSetupTrayIcon(); -+ if (mode == dbiwmWindowOnly) { -+ if (trayIcon) { -+ trayIcon->setContextMenu(0); -+ delete trayIcon; -+ trayIcon = nullptr; -+ } -+ } -+} -+ -+void MainWindow::unreadCounterChangedHook() { -+ setWindowTitle(titleText()); -+ updateIconCounters(); -+} -+ -+void MainWindow::updateIconCounters() { -+ const auto counter = Core::App().unreadBadge(); -+ const auto muted = Core::App().unreadBadgeMuted(); -+ auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); -+ auto &fg = st::trayCounterFg; -+ if (trayIcon) { -+ QIcon icon; -+ icon.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(16, counter, bg, fg, true))); -+ icon.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(32, counter, bg, fg, true))); -+ trayIcon->setIcon(icon); -+ } -+} -+ -+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..cd3e888 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h -@@ -0,0 +1,54 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "platform/platform_main_window.h" -+#include "ui/widgets/popup_menu.h" -+#include "base/flags.h" -+ -+#include -+ -+namespace Platform { -+ -+class MainWindow : public Window::MainWindow { -+ Q_OBJECT -+ -+public: -+ explicit MainWindow(not_null controller); -+ -+ virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0; -+ -+ bool isActiveForTrayMenu() override; -+ -+ ~MainWindow(); -+ -+public slots: -+ void psShowTrayMenu(); -+ -+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(); -+}; -+ -+} // namespace Platform -diff --git a/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp -new file mode 100644 -index 0000000..d567f10 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp -@@ -0,0 +1,64 @@ -+/* -+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-2019 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include -+#include -+ -+#include -+#include -+ -+#define APPSIGNATURE "application/x-vnd.tg-notify-gate" -+#define NOTIFY_PORT_NAME "tg_notify" -+#define NOTIFY_MESSAGE 'TGNF' -+ -+typedef struct notify_msg -+{ -+ uint64 sessionId; -+ uint64 peerId; -+ int32 msgId; -+} notify_msg; -+ -+class SimpleLauncherApp : public BApplication { -+ public: -+ SimpleLauncherApp(int argc, char **argv); -+ void ArgvReceived(int32 argc, char **argv); -+ virtual void ReadyToRun(); -+}; -+ -+SimpleLauncherApp::SimpleLauncherApp(int argc, char **argv) : BApplication(APPSIGNATURE) -+{ -+} -+ -+void -+SimpleLauncherApp::ArgvReceived(int32 argc, char **argv) -+{ -+ if (argc == 2) { -+ notify_msg message; -+ sscanf(argv[1], "%lld %lld %d", &message.sessionId, &message.peerId, &message.msgId); -+ if (message.peerId != 0 && message.msgId != 0) { -+ port_id portId = find_port(NOTIFY_PORT_NAME); -+ if (portId > 0) { -+ write_port(portId, NOTIFY_MESSAGE, &message, sizeof(message)); -+ } -+ } -+ } -+} -+ -+void -+SimpleLauncherApp::ReadyToRun() -+{ -+ Quit(); -+} -+ -+int main(int argc, char **argv) -+{ -+ SimpleLauncherApp application(argc, argv); -+ application.Run(); -+ return 0; -+} -diff --git a/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.rdef b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.rdef -new file mode 100644 -index 0000000..b6f3490 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.rdef -@@ -0,0 +1,13 @@ -+resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP; -+ -+resource app_version { -+ major = 0, -+ middle = 0, -+ minor = 1, -+ variety = B_APPV_FINAL, -+ internal = 0, -+ short_info = "tg-notify-gate", -+ long_info = "Telegram native notifications gate" -+}; -+ -+resource app_signature "application/x-vnd.tg-notify-gate"; -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..e77c32e ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp -@@ -0,0 +1,202 @@ -+/* -+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 -+*/ -+ -+#ifdef __x86_64__ -+#define int64 XXX -+#define uint64 YYY -+#else -+#define int32 XXX -+#define uint32 YYY -+#endif -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "platform/haiku/notifications_manager_haiku.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 DeclareReadOnlyVar(Type, Name) const Type &Name(); -+#define DeclareRefVar(Type, Name) DeclareReadOnlyVar(Type, Name) \ -+ Type &Ref##Name(); -+#define DeclareVar(Type, Name) DeclareRefVar(Type, Name) \ -+ void Set##Name(const Type &Name); -+ -+#include -+#include -+#include -+#include -+#include -+ -+namespace Platform { -+namespace Notifications { -+namespace { -+ -+} // namespace -+ -+bool Supported() { -+ 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); -+} -+ -+void Finish() { -+} -+ -+NotifyReader::NotifyReader() -+{ -+ portId = create_port(NOTIFY_MESSAGE_DEEP, NOTIFY_PORT_NAME); -+} -+ -+NotifyReader::~NotifyReader() -+{ -+ if (portId >= B_OK) -+ delete_port(portId); -+} -+ -+void NotifyReader::run() -+{ -+ notify_msg message; -+ int32 code; -+ -+ while (true) { -+ ssize_t bytesRead = read_port(portId, &code, &message, sizeof(message)); -+ if (bytesRead == B_BAD_PORT_ID) -+ break; -+ if (bytesRead < (ssize_t)sizeof(message) || code != NOTIFY_MESSAGE) -+ continue; -+ if (message.peerId != 0 && message.msgId != 0) -+ notificationActivated(message.sessionId, message.peerId, message.msgId); -+ } -+} -+ -+Manager::Private::Private(not_null manager, Type type) -+: _cachedUserpics(type) -+, _manager(manager) { -+ portReaderThread = new QThread; -+ portReader = new NotifyReader(); -+ portReader->moveToThread(portReaderThread); -+ connect(portReaderThread, SIGNAL(started()), portReader, SLOT(run())); -+ qRegisterMetaType("PeerId"); -+ qRegisterMetaType("MsgId"); -+ connect( -+ portReader, -+ SIGNAL(notificationActivated(PeerId, PeerId, MsgId)), -+ this, -+ SLOT(notificationActivatedSlot(PeerId, PeerId, MsgId))); -+ portReaderThread->start(); -+} -+ -+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("%1 %2 %3").arg(peer->session().uniqueId()).arg(peer->id).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(); -+} -+ -+void -+Manager::Private::notificationActivatedSlot(PeerId _sessionId, PeerId _peerId, MsgId _msgId) { -+ const auto manager = _manager; -+ const auto my = Window::Notifications::Manager::NotificationId{ -+ .full = Manager::FullPeer{ -+ .sessionId = _sessionId, -+ .peerId = _peerId -+ }, -+ .msgId = _msgId -+ }; -+ crl::on_main(manager, [=] { -+ manager->notificationActivated(my); -+ }); -+} -+ -+Manager::Manager(Window::Notifications::System *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) { -+} -+ -+} // 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..52adcb0 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h -@@ -0,0 +1,123 @@ -+/* -+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-2019 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "platform/platform_notifications_manager.h" -+#include "window/notifications_utilities.h" -+ -+#include -+#include -+#include -+ -+#define NOTIFY_MESSAGE_DEEP 16 -+#define NOTIFY_PORT_NAME "tg_notify" -+#define NOTIFY_GATE_NAME "/bin/tg-notify-gate" -+#define NOTIFY_MESSAGE 'TGNF' -+ -+typedef struct notify_msg -+{ -+ uint64 sessionId; -+ uint64 peerId; -+ int32 msgId; -+} notify_msg; -+ -+namespace Platform { -+namespace Notifications { -+ -+inline bool SkipAudio() { -+ return false; -+} -+ -+inline bool SkipToast() { -+ return false; -+} -+ -+inline bool SkipFlashBounce() { -+ return false; -+} -+ -+inline bool Enforced() { -+ return false; -+} -+ -+inline bool ByDefault() { -+ return true; -+} -+ -+void Finish(); -+ -+class NotifyReader:public QObject { -+ Q_OBJECT -+public: -+ NotifyReader(); -+ ~NotifyReader(); -+public slots: -+ void run(); -+signals: -+ void notificationActivated(PeerId sessionId, PeerId peerId, MsgId msgId); -+private: -+ int32 portId; -+}; -+ -+ -+class Manager : public Window::Notifications::NativeManager, public base::has_weak_ptr { -+public: -+ Manager(Window::Notifications::System *system); -+ ~Manager(); -+ -+protected: -+ void doShowNativeNotification( -+ not_null peer, -+ std::shared_ptr &userpicView, -+ MsgId msgId, -+ const QString &title, -+ const QString &subtitle, -+ const QString &msg, -+ bool hideNameAndPhoto, -+ bool hideReplyButton) override; -+ void doClearAllFast() override; -+ void doClearFromHistory(not_null history) override; -+ void doClearFromSession(not_null session) override; -+ -+private: -+ class Private; -+ const std::unique_ptr _private; -+}; -+ -+class Manager::Private : public QObject { -+ Q_OBJECT -+ -+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); -+ -+public slots: -+ void notificationActivatedSlot(PeerId sessionId, PeerId peerId, MsgId msgId); -+ -+private: -+ Window::Notifications::CachedUserpics _cachedUserpics; -+ base::weak_ptr _manager; -+ -+ QThread *portReaderThread; -+ NotifyReader *portReader; -+}; -+ -+} // 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..6383199 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -@@ -0,0 +1,264 @@ -+/* -+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 "platform/haiku/specific_haiku.h" -+ -+#include "base/platform/base_platform_info.h" -+#include "base/qt_adapters.h" -+#include "platform/haiku/file_utilities_haiku.h" -+#include "lang/lang_keys.h" -+#include "mainwidget.h" -+#include "mainwindow.h" -+#include "storage/localstorage.h" -+#include "window/window_controller.h" -+#include "core/update_checker.h" -+#include "core/application.h" -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+using namespace Platform; -+ -+namespace Platform { -+namespace DesktopEnvironment { -+enum class Type { -+ Other -+}; -+Type Get() { -+ return Type::Other; -+} -+} -+ -+QString CurrentExecutablePath(int argc, char *argv[]) { -+ return argc ? QFile::decodeName(argv[0]) : QString(); -+} -+ -+QString SingleInstanceLocalServerName(const QString &hash) { -+ return QStandardPaths::writableLocation(QStandardPaths::TempLocation) -+ + '/' + hash + '-' + cGUIDStr(); -+} -+ -+bool AutostartSupported() { -+ return true; -+} -+ -+bool TrayIconSupported() { -+ return true; -+} -+ -+bool SetWindowExtents(QWindow *window, const QMargins &extents) { -+ return false; -+} -+ -+bool UnsetWindowExtents(QWindow *window) { -+ return false; -+} -+ -+std::optional IsDarkMode() { -+ return std::nullopt; -+} -+ -+Window::ControlsLayout WindowControlsLayout() { -+ Window::ControlsLayout controls; -+ controls.left = { -+ Window::Control::Close, -+ }; -+ -+ controls.right = { -+ Window::Control::Minimize, -+ Window::Control::Maximize, -+ }; -+ -+ return controls; -+} -+ -+} // namespace Platform -+ -+namespace { -+ -+QRect _monitorRect; -+auto _monitorLastGot = 0LL; -+ -+} // namespace -+ -+QRect psDesktopRect() { -+ auto tnow = crl::now(); -+ if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) { -+ _monitorLastGot = tnow; -+ _monitorRect = QApplication::desktop()->availableGeometry(App::wnd()); -+ } -+ return _monitorRect; -+} -+ -+void psWriteDump() { -+} -+ -+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); -+} -+ -+void psActivateProcess(uint64 pid) { -+} -+ -+QString psAppDataPath() { -+ return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + '/'; -+} -+ -+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() { -+} -+ -+void RegisterCustomScheme(bool force) { -+} -+ -+void SetApplicationIcon(const QIcon &icon) { -+ qApp->setWindowIcon(icon); -+} -+ -+PermissionStatus GetPermissionStatus(PermissionType type){ -+ return PermissionStatus::Granted; -+} -+ -+void RequestPermission(PermissionType type, Fn resultCallback){ -+ resultCallback(PermissionStatus::Granted); -+} -+ -+void OpenSystemSettingsForPermission(PermissionType type){ -+} -+ -+bool OpenSystemSettings(SystemSettingsType type) { -+ if (type == SystemSettingsType::Audio) { -+ auto options = std::vector(); -+ const auto add = [&](const char *option) { -+ options.emplace_back(option); -+ }; -+ add("Media"); -+ return ranges::find_if(options, [](const QString &command) { -+ return QProcess::startDetached(command); -+ }) != end(options); -+ } -+ return true; -+} -+ -+namespace ThirdParty { -+ -+void start() { -+} -+ -+void finish() { -+} -+ -+} // namespace ThirdParty -+ -+} // namespace Platform -+ -+void psNewVersion() { -+ Platform::RegisterCustomScheme(); -+} -+ -+bool psShowOpenWithMenu(int x, int y, const QString &file) { -+ return false; -+} -+ -+void psAutoStart(bool start, bool silent) { -+ auto home = QDir::homePath(); -+ if (home.isEmpty()) -+ return; -+ -+ QFile file(home + "/config/settings/boot/launch/telegram-desktop"); -+ if (start) { -+ if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { -+ QTextStream out(&file); -+ out << "#!/bin/bash" << endl -+ << "cd /system/apps" << endl -+ << "./Telegram -autostart" << " &" << endl; -+ file.close(); -+ file.setPermissions(file.permissions() -+ | QFileDevice::ExeOwner -+ | QFileDevice::ExeGroup -+ | QFileDevice::ExeOther); -+ } -+ } else { -+ file.remove(); -+ } -+} -+ -+void psSendToMenu(bool send, bool silent) { -+} -+ -+bool psLaunchMaps(const Data::LocationPoint &point) { -+ 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..ceda709 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.h -@@ -0,0 +1,133 @@ -+/* -+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 -+*/ -+ -+#pragma once -+ -+#include -+#include "platform/platform_specific.h" -+ -+namespace Data { -+class LocationPoint; -+} // namespace Data -+ -+namespace Platform { -+ -+inline void SetWatchingMediaKeys(bool watching) { -+} -+ -+inline void IgnoreApplicationActivationRightNow() { -+} -+ -+inline std::optional LastUserInputTime() { -+ return std::nullopt; -+} -+ -+inline void FallbackFontConfigCheckBegin() { -+} -+ -+inline void FallbackFontConfigCheckEnd() { -+} -+ -+inline QImage GetImageFromClipboard() { -+ return {}; -+} -+ -+inline bool StartSystemMove(QWindow *window) { -+ return false; -+} -+ -+inline bool StartSystemResize(QWindow *window, Qt::Edges edges) { -+ return false; -+} -+ -+inline bool ShowWindowMenu(QWindow *window) { -+ return false; -+} -+ -+inline bool WindowsNeedShadow() { -+ return false; -+} -+ -+inline bool SkipTaskbarSupported() { -+ return false; -+} -+ -+inline bool InFlatpak() { -+ return false; -+} -+ -+inline bool InSnap() { -+ return false; -+} -+ -+inline void InstallLauncher(bool force = false) { -+}; -+ -+} // namespace Platform -+ -+inline void psCheckLocalSocket(const QString &serverName) { -+ QFile address(serverName); -+ if (address.exists()) { -+ address.remove(); -+ } -+} -+ -+void psWriteDump(); -+ -+void psDeleteDir(const QString &dir); -+ -+QStringList psInitLogs(); -+void psClearInitLogs(); -+ -+void psActivateProcess(uint64 pid = 0); -+QString psLocalServerPrefix(); -+QString psAppDataPath(); -+void psAutoStart(bool start, bool silent = false); -+void psSendToMenu(bool send, bool silent = false); -+ -+QRect psDesktopRect(); -+ -+int psCleanup(); -+int psFixPrevious(); -+ -+void psNewVersion(); -+ -+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(); -+ } -+ -+}; -+ -+//ool linuxMoveFile(const char *from, const char *to); -+ -+bool psLaunchMaps(const Data::LocationPoint &point); -diff --git a/Telegram/SourceFiles/platform/haiku/window_title_haiku.cpp b/Telegram/SourceFiles/platform/haiku/window_title_haiku.cpp -new file mode 100644 -index 0000000..6987284 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/window_title_haiku.cpp -@@ -0,0 +1,33 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "platform/haiku/window_title_haiku.h" -+ -+#include "base/platform/base_platform_info.h" -+ -+namespace Platform { -+namespace { -+ -+bool SystemMoveResizeSupported() { -+ return true; -+} -+ -+} // namespace -+ -+bool AllowNativeWindowFrameToggle() { -+ return SystemMoveResizeSupported(); -+} -+ -+object_ptr CreateTitleWidget(QWidget *parent) { -+ return SystemMoveResizeSupported() -+ ? object_ptr(parent) -+ : object_ptr{ nullptr }; -+} -+ -+} // namespace Platform -diff --git a/Telegram/SourceFiles/platform/haiku/window_title_haiku.h b/Telegram/SourceFiles/platform/haiku/window_title_haiku.h -new file mode 100644 -index 0000000..86431b6 ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/window_title_haiku.h -@@ -0,0 +1,41 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "platform/platform_window_title.h" -+#include "base/object_ptr.h" -+ -+namespace Window { -+namespace Theme { -+ -+int DefaultPreviewTitleHeight(); -+void DefaultPreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth); -+ -+} // namespace Theme -+} // namespace Window -+ -+namespace Platform { -+ -+bool AllowNativeWindowFrameToggle(); -+object_ptr CreateTitleWidget(QWidget *parent); -+ -+inline bool NativeTitleRequiresShadow() { -+ return false; -+} -+ -+inline int PreviewTitleHeight() { -+ return Window::Theme::DefaultPreviewTitleHeight(); -+} -+ -+inline void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth) { -+ return Window::Theme::DefaultPreviewWindowFramePaint(preview, palette, body, outerWidth); -+} -+ -+} // namespace Platform -diff --git a/Telegram/SourceFiles/platform/platform_file_utilities.h b/Telegram/SourceFiles/platform/platform_file_utilities.h -index ad229d2..d37e402 100644 ---- a/Telegram/SourceFiles/platform/platform_file_utilities.h -+++ b/Telegram/SourceFiles/platform/platform_file_utilities.h -@@ -45,6 +45,8 @@ bool Get( - - #ifdef Q_OS_MAC - #include "platform/mac/file_utilities_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/file_utilities_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "platform/linux/file_utilities_linux.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/SourceFiles/platform/platform_launcher.h b/Telegram/SourceFiles/platform/platform_launcher.h -index d79aea6..53a1b91 100644 ---- a/Telegram/SourceFiles/platform/platform_launcher.h -+++ b/Telegram/SourceFiles/platform/platform_launcher.h -@@ -23,6 +23,8 @@ namespace Platform { - - #ifdef Q_OS_MAC - #include "platform/mac/launcher_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/launcher_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "platform/linux/launcher_linux.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/SourceFiles/platform/platform_main_window.h b/Telegram/SourceFiles/platform/platform_main_window.h -index 4bdb939..88bfaf6 100644 ---- a/Telegram/SourceFiles/platform/platform_main_window.h -+++ b/Telegram/SourceFiles/platform/platform_main_window.h -@@ -19,6 +19,8 @@ class MainWindow; - - #ifdef Q_OS_MAC - #include "platform/mac/main_window_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/main_window_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "platform/linux/main_window_linux.h" - #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/SourceFiles/platform/platform_notifications_manager.h b/Telegram/SourceFiles/platform/platform_notifications_manager.h -index eb3efbd..783d442 100644 ---- a/Telegram/SourceFiles/platform/platform_notifications_manager.h -+++ b/Telegram/SourceFiles/platform/platform_notifications_manager.h -@@ -28,6 +28,8 @@ void Create(Window::Notifications::System *system); - - #ifdef Q_OS_MAC - #include "platform/mac/notifications_manager_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/notifications_manager_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "platform/linux/notifications_manager_linux.h" - #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h -index 45fafae..4c11a0d 100644 ---- a/Telegram/SourceFiles/platform/platform_specific.h -+++ b/Telegram/SourceFiles/platform/platform_specific.h -@@ -65,6 +65,8 @@ void finish(); - - #ifdef Q_OS_MAC - #include "platform/mac/specific_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/specific_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "platform/linux/specific_linux.h" - #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/SourceFiles/platform/platform_window_title.h b/Telegram/SourceFiles/platform/platform_window_title.h -index cd6b3a6..e08f0bd 100644 ---- a/Telegram/SourceFiles/platform/platform_window_title.h -+++ b/Telegram/SourceFiles/platform/platform_window_title.h -@@ -27,6 +27,8 @@ void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRe - - #ifdef Q_OS_MAC - #include "platform/mac/window_title_mac.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/window_title_haiku.h" - #elif defined Q_OS_WIN // Q_OS_MAC - #include "platform/win/window_title_win.h" - #elif defined Q_OS_UNIX // Q_OS_MAC || Q_OS_WIN -diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp -index 6ed2698..56259f4 100644 ---- a/Telegram/SourceFiles/window/main_window.cpp -+++ b/Telegram/SourceFiles/window/main_window.cpp -@@ -118,7 +118,7 @@ QIcon CreateOfficialIcon(Main::Session *session) { - - QIcon CreateIcon(Main::Session *session) { - auto result = CreateOfficialIcon(session); --#if defined Q_OS_UNIX && !defined Q_OS_MAC -+#if defined Q_OS_UNIX && !defined Q_OS_MAC && !defined Q_OS_HAIKU - return QIcon::fromTheme(Platform::GetIconName(), result); - #endif - return result; -diff --git a/Telegram/ThirdParty/libtgvoip/VoIPController.cpp b/Telegram/ThirdParty/libtgvoip/VoIPController.cpp -index d0b0038..c2c258b 100644 ---- a/Telegram/ThirdParty/libtgvoip/VoIPController.cpp -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp -index 2c16ca7..e00c731 100644 ---- a/Telegram/ThirdParty/libtgvoip/audio/AudioIO.cpp -+++ b/Telegram/ThirdParty/libtgvoip/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__) - #ifndef WITHOUT_ALSA - #ifndef WITHOUT_PULSE -diff --git a/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp -index 674cd34..83a6dbb 100644 ---- a/Telegram/ThirdParty/libtgvoip/audio/AudioInput.cpp -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp b/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp -index 14ab0be..44c615e 100644 ---- a/Telegram/ThirdParty/libtgvoip/audio/AudioOutput.cpp -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.cpp -new file mode 100644 -index 0000000..7cce3e3 ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.h b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioInputHaiku.h -new file mode 100644 -index 0000000..1c63afe ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.cpp -new file mode 100644 -index 0000000..2fca8a1 ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.h b/Telegram/ThirdParty/libtgvoip/os/haiku/AudioOutputHaiku.h -new file mode 100644 -index 0000000..91f2521 ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.cpp b/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.cpp -new file mode 100644 -index 0000000..6c94933 ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.h b/Telegram/ThirdParty/libtgvoip/os/haiku/RingBuffer.h -new file mode 100644 -index 0000000..01f6096 ---- /dev/null -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp b/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp -index 78e0583..81bf9fc 100644 ---- a/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/threading.h b/Telegram/ThirdParty/libtgvoip/threading.h -old mode 100755 -new mode 100644 -index 81c577c..1ccf029 ---- a/Telegram/ThirdParty/libtgvoip/threading.h -+++ b/Telegram/ThirdParty/libtgvoip/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 -@@ -92,6 +92,7 @@ namespace tgvoip{ - static void* ActualEntryPoint(void* arg){ - Thread* self=reinterpret_cast(arg); - if(self->name){ -+#ifndef __HAIKU__ - #if !defined(__APPLE__) && !defined(__gnu_hurd__) - pthread_setname_np(self->thread, self->name); - #elif !defined(__gnu_hurd__) -@@ -100,6 +101,7 @@ namespace tgvoip{ - DarwinSpecific::SetCurrentThreadPriority(DarwinSpecific::THREAD_PRIO_USER_INTERACTIVE); - } - #endif -+#endif //__HAIKU__ - } - self->entry(); - return NULL; -diff --git a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc -old mode 100755 -new mode 100644 -index a8d1522..991241b ---- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/logging_webrtc.cc -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_file.h b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_file.h -old mode 100755 -new mode 100644 -diff --git a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc -index cf7d478..f27b9a1 100644 ---- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.cc -+++ b/Telegram/ThirdParty/libtgvoip/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/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h b/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h -index 0bc42eb..c87cde9 100644 ---- a/Telegram/ThirdParty/libtgvoip/webrtc_dsp/rtc_base/platform_thread_types.h -+++ b/Telegram/ThirdParty/libtgvoip/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; -diff --git a/Telegram/cmake/lib_tgcalls.cmake b/Telegram/cmake/lib_tgcalls.cmake -index 7a7e68e..7619a4e 100644 ---- a/Telegram/cmake/lib_tgcalls.cmake -+++ b/Telegram/cmake/lib_tgcalls.cmake -@@ -132,6 +132,11 @@ if (WIN32) - PRIVATE - WEBRTC_WIN - ) -+elseif (HAIKU) -+ target_compile_definitions(lib_tgcalls -+ PRIVATE -+ WEBRTC_HAIKU -+ ) - elseif (APPLE) - target_compile_options(lib_tgcalls - PRIVATE -diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake -index 74d4f26..ec89ac7 100644 ---- a/Telegram/cmake/lib_tgvoip.cmake -+++ b/Telegram/cmake/lib_tgvoip.cmake -@@ -120,6 +120,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 -@@ -157,6 +165,20 @@ 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 -+ ) - else() - target_compile_options(lib_tgvoip_bundled - PRIVATE -diff --git a/Telegram/lib_base/CMakeLists.txt b/Telegram/lib_base/CMakeLists.txt -index 6330f68..79b4d51 100644 ---- a/Telegram/lib_base/CMakeLists.txt -+++ b/Telegram/lib_base/CMakeLists.txt -@@ -69,6 +69,20 @@ PRIVATE - base/platform/win/base_windows_safe_library.cpp - base/platform/win/base_windows_safe_library.h - base/platform/win/wrl/wrl_implements_h.h -+ base/platform/haiku/base_file_utilities_haiku.cpp -+ base/platform/haiku/base_file_utilities_haiku.h -+ base/platform/haiku/base_global_shortcuts_haiku.cpp -+ base/platform/haiku/base_global_shortcuts_haiku.h -+ base/platform/haiku/base_info_haiku.cpp -+ base/platform/haiku/base_info_haiku.h -+ base/platform/haiku/base_last_input_haiku.cpp -+ base/platform/haiku/base_last_input_haiku.h -+ base/platform/haiku/base_layout_switch_haiku.cpp -+ base/platform/haiku/base_layout_switch_haiku.h -+ base/platform/haiku/base_process_haiku.cpp -+ base/platform/haiku/base_process_haiku.h -+ base/platform/haiku/base_url_scheme_haiku.cpp -+ base/platform/haiku/base_url_scheme_haiku.h - base/platform/base_platform_global_shortcuts.h - base/platform/base_platform_info.h - base/platform/base_platform_last_input.h -diff --git a/Telegram/lib_base/base/crash_report_writer.cpp b/Telegram/lib_base/base/crash_report_writer.cpp -index 0552958..202b6ae 100644 ---- a/Telegram/lib_base/base/crash_report_writer.cpp -+++ b/Telegram/lib_base/base/crash_report_writer.cpp -@@ -111,6 +111,8 @@ const char *PlatformString() { - return "Linux32Bit"; - } else if (Platform::IsLinux64Bit()) { - return "Linux64bit"; -+ } else if (Platform::IsHaiku()) { -+ return "Haiku"; - } - Unexpected("Platform in CrashReports::PlatformString."); - } -@@ -247,7 +249,7 @@ void SignalHandler(int signum) { - ReportingThreadId = nullptr; - } - --bool SetSignalHandlers = Platform::IsLinux() || Platform::IsMac(); -+bool SetSignalHandlers = Platform::IsLinux() || Platform::IsMac() || Platform::IsHaiku(); - bool CrashLogged = false; - - #ifdef USE_BREAKPAD -diff --git a/Telegram/lib_base/base/platform/base_platform_file_utilities.h b/Telegram/lib_base/base/platform/base_platform_file_utilities.h -index 1b63b2a..00a9900 100644 ---- a/Telegram/lib_base/base/platform/base_platform_file_utilities.h -+++ b/Telegram/lib_base/base/platform/base_platform_file_utilities.h -@@ -26,6 +26,8 @@ void FlushFileData(QFile &file); - - #ifdef Q_OS_MAC - #include "base/platform/mac/base_file_utilities_mac.h" -+#elif defined Q_OS_HAIKU -+#include "base/platform/haiku/base_file_utilities_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "base/platform/linux/base_file_utilities_linux.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/lib_base/base/platform/base_platform_info.h b/Telegram/lib_base/base/platform/base_platform_info.h -index f5b319f..3051caf 100644 ---- a/Telegram/lib_base/base/platform/base_platform_info.h -+++ b/Telegram/lib_base/base/platform/base_platform_info.h -@@ -60,6 +60,8 @@ enum class OutdateReason { - [[nodiscard]] QString GetLibcName(); - [[nodiscard]] QString GetLibcVersion(); - -+[[nodiscard]] constexpr bool IsHaiku(); -+ - void Start(QJsonObject settings); - void Finish(); - -@@ -67,6 +69,8 @@ void Finish(); - - #ifdef Q_OS_MAC - #include "base/platform/mac/base_info_mac.h" -+#elif defined Q_OS_HAIKU -+#include "base/platform/haiku/base_info_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "base/platform/linux/base_info_linux.h" - #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.cpp -new file mode 100644 -index 0000000..0facb49 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.cpp -@@ -0,0 +1,84 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_file_utilities_haiku.h" -+ -+#include "base/platform/base_platform_file_utilities.h" -+#include "base/algorithm.h" -+ -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+namespace base::Platform { -+ -+bool ShowInFolder(const QString &filepath) { -+ const auto absolutePath = QFileInfo(filepath).absoluteFilePath(); -+ QProcess process; -+ auto command = QString("open"); -+ auto arguments = QStringList(); -+ arguments << QFileInfo(filepath).absoluteDir().absolutePath(); -+ return process.startDetached(command, arguments); -+} -+ -+QString CurrentExecutablePath(int argc, char *argv[]) { -+ return argc ? QFile::decodeName(argv[0]) : QString(); -+} -+ -+void RemoveQuarantine(const QString &path) { -+} -+ -+bool DeleteDirectory(QString path) { -+ if (path.endsWith('/')) { -+ path.chop(1); -+ } -+ const auto pathRaw = QFile::encodeName(path); -+ const auto d = opendir(pathRaw.constData()); -+ if (!d) { -+ return false; -+ } -+ -+ while (struct dirent *p = readdir(d)) { -+ if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) -+ continue; -+ const auto fname = path + '/' + p->d_name; -+ const auto encoded = QFile::encodeName(fname); -+ struct stat statbuf; -+ if (!stat(encoded.constData(), &statbuf)) { -+ if (S_ISDIR(statbuf.st_mode)) { -+ if (!DeleteDirectory(fname)) { -+ closedir(d); -+ return false; -+ } -+ } else { -+ if (unlink(encoded.constData())) { -+ closedir(d); -+ return false; -+ } -+ } -+ } -+ } -+ closedir(d); -+ -+ return !rmdir(pathRaw.constData()); -+} -+ -+void FlushFileData(QFile &file) { -+ file.flush(); -+ if (const auto descriptor = file.handle()) { -+ fsync(descriptor); -+ } -+} -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.h b/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.h -new file mode 100644 -index 0000000..6700d58 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_file_utilities_haiku.h -@@ -0,0 +1,27 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include -+#include -+ -+namespace base::Platform { -+ -+inline QString FileNameFromUserString(QString name) { -+ return name; -+} -+ -+inline bool RenameWithOverwrite(const QString &from, const QString &to) { -+ const auto fromPath = QFile::encodeName(from); -+ const auto toPath = QFile::encodeName(to); -+ return (rename(fromPath.constData(), toPath.constData()) == 0); -+} -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.cpp -new file mode 100644 -index 0000000..d08aa27 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.cpp -@@ -0,0 +1,39 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_global_shortcuts_haiku.h" -+ -+namespace base::Platform::GlobalShortcuts { -+namespace { -+ -+Fn ProcessCallback; -+ -+} // namespace -+ -+bool Available() { -+ return false; -+} -+ -+bool Allowed() { -+ return false; -+} -+ -+void Start(Fn process) { -+ ProcessCallback = nullptr; -+} -+ -+void Stop() { -+ ProcessCallback = nullptr; -+} -+ -+QString KeyName(GlobalShortcutKeyGeneric descriptor) { -+ return QString(); -+} -+ -+} // namespace base::Platform::GlobalShortcuts -diff --git a/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.h b/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.h -new file mode 100644 -index 0000000..465e668 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_global_shortcuts_haiku.h -@@ -0,0 +1,13 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "base/global_shortcuts.h" -+#include "base/platform/base_platform_global_shortcuts.h" -diff --git a/Telegram/lib_base/base/platform/haiku/base_info_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_info_haiku.cpp -new file mode 100644 -index 0000000..20dcf3e ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_info_haiku.cpp -@@ -0,0 +1,67 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_info_haiku.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+namespace Platform { -+ -+QString DeviceModelPretty() { -+ const auto cpuArch = QSysInfo::buildCpuArchitecture(); -+ -+ if (cpuArch == qstr("x86_64")) { -+ return "PC 64bit"; -+ } else if (cpuArch == qstr("i386")) { -+ return "PC 32bit"; -+ } -+ -+ return "PC " + cpuArch; -+} -+ -+QString SystemVersionPretty() { -+ return "Haiku"; -+} -+ -+QString SystemCountry() { -+ return QLocale::system().name().split('_').last(); -+} -+ -+QString SystemLanguage() { -+ const auto system = QLocale::system(); -+ const auto languages = system.uiLanguages(); -+ return languages.isEmpty() -+ ? system.name().split('_').first() -+ : languages.front(); -+} -+ -+QDate WhenSystemBecomesOutdated() { -+ return QDate(); -+} -+ -+int AutoUpdateVersion() { -+ return 2; -+} -+ -+QString AutoUpdateKey() { -+ return "haiku"; -+} -+ -+void Start(QJsonObject options) { -+} -+ -+void Finish() { -+} -+ -+} // namespace Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_info_haiku.h b/Telegram/lib_base/base/platform/haiku/base_info_haiku.h -new file mode 100644 -index 0000000..9e49e7c ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_info_haiku.h -@@ -0,0 +1,45 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "base/platform/base_platform_info.h" -+ -+namespace Platform { -+ -+inline constexpr bool IsHaiku() { return true;} -+ -+inline constexpr bool IsLinux() { return false;} -+inline constexpr bool IsLinux32Bit() { return false; } -+inline constexpr bool IsLinux64Bit() { return false; } -+inline constexpr bool IsWindows() { return false; } -+inline constexpr bool IsWindows32Bit() { return false; } -+inline constexpr bool IsWindows64Bit() { return false; } -+inline constexpr bool IsWindowsStoreBuild() { return false; } -+inline bool IsWindowsXPOrGreater() { return false; } -+inline bool IsWindowsVistaOrGreater() { return false; } -+inline bool IsWindows7OrGreater() { return false; } -+inline bool IsWindows8OrGreater() { return false; } -+inline bool IsWindows8Point1OrGreater() { return false; } -+inline bool IsWindows10OrGreater() { return false; } -+inline constexpr bool IsMac() { return false; } -+inline constexpr bool IsOSXBuild() { return false; } -+inline constexpr bool IsMacStoreBuild() { return false; } -+inline bool IsMac10_6OrGreater() { return false; } -+inline bool IsMac10_7OrGreater() { return false; } -+inline bool IsMac10_8OrGreater() { return false; } -+inline bool IsMac10_9OrGreater() { return false; } -+inline bool IsMac10_10OrGreater() { return false; } -+inline bool IsMac10_11OrGreater() { return false; } -+inline bool IsMac10_12OrGreater() { return false; } -+inline bool IsMac10_13OrGreater() { return false; } -+inline bool IsMac10_14OrGreater() { return false; } -+inline bool IsWayland() { return false; } -+ -+} // namespace Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.cpp -new file mode 100644 -index 0000000..8fa3e9f ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.cpp -@@ -0,0 +1,20 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_last_input_haiku.h" -+ -+#include -+ -+namespace base::Platform { -+ -+std::optional LastUserInputTime() { -+ return std::nullopt; -+} -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.h b/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.h -new file mode 100644 -index 0000000..a24adad ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_last_input_haiku.h -@@ -0,0 +1,11 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -diff --git a/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.cpp -new file mode 100644 -index 0000000..533b8ea ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.cpp -@@ -0,0 +1,18 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_layout_switch_haiku.h" -+ -+namespace base::Platform { -+ -+bool SwitchKeyboardLayoutToEnglish() { -+ return false; -+} -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.h b/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.h -new file mode 100644 -index 0000000..a24adad ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_layout_switch_haiku.h -@@ -0,0 +1,11 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -diff --git a/Telegram/lib_base/base/platform/haiku/base_process_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_process_haiku.cpp -new file mode 100644 -index 0000000..6e88f99 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_process_haiku.cpp -@@ -0,0 +1,20 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_process_haiku.h" -+ -+namespace base::Platform { -+ -+void ActivateProcessWindow(int64 pid, WId windowId) { -+} -+ -+void ActivateThisProcessWindow(WId windowId) { -+} -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_process_haiku.h b/Telegram/lib_base/base/platform/haiku/base_process_haiku.h -new file mode 100644 -index 0000000..4d0bce3 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_process_haiku.h -@@ -0,0 +1,12 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "base/platform/base_platform_process.h" -diff --git a/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.cpp b/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.cpp -new file mode 100644 -index 0000000..ca200de ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.cpp -@@ -0,0 +1,21 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "base/platform/haiku/base_url_scheme_haiku.h" -+ -+namespace base::Platform { -+ -+bool CheckUrlScheme(const UrlSchemeDescriptor &descriptor) { -+ return false; -+} -+ -+void RegisterUrlScheme(const UrlSchemeDescriptor &descriptor) { } -+void UnregisterUrlScheme(const UrlSchemeDescriptor &descriptor) { } -+ -+} // namespace base::Platform -diff --git a/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.h b/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.h -new file mode 100644 -index 0000000..6402509 ---- /dev/null -+++ b/Telegram/lib_base/base/platform/haiku/base_url_scheme_haiku.h -@@ -0,0 +1,12 @@ -+/* -+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-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "base/platform/base_platform_url_scheme.h" -diff --git a/Telegram/lib_crl/CMakeLists.txt b/Telegram/lib_crl/CMakeLists.txt -index 91e32ec..7991e08 100644 ---- a/Telegram/lib_crl/CMakeLists.txt -+++ b/Telegram/lib_crl/CMakeLists.txt -@@ -33,6 +33,7 @@ PRIVATE - crl/dispatch/crl_dispatch_semaphore.h - crl/mac/crl_mac_time.cpp - crl/linux/crl_linux_time.cpp -+ crl/haiku/crl_haiku_time.cpp - crl/qt/crl_qt_async.cpp - crl/qt/crl_qt_async.h - crl/qt/crl_qt_guards.h -diff --git a/Telegram/lib_crl/crl/haiku/crl_haiku_time.cpp b/Telegram/lib_crl/crl/haiku/crl_haiku_time.cpp -new file mode 100644 -index 0000000..f682740 ---- /dev/null -+++ b/Telegram/lib_crl/crl/haiku/crl_haiku_time.cpp -@@ -0,0 +1,44 @@ -+// This file is part of Desktop App Toolkit, -+// a set of libraries for developing nice desktop applications. -+// -+// For license and copyright information please follow this link: -+// https://github.com/desktop-app/legal/blob/master/LEGAL -+// -+#include -+ -+#ifdef CRL_USE_LINUX_TIME -+ -+#include -+ -+namespace crl::details { -+ -+void init() { -+} -+ -+inner_time_type current_value() { -+ timespec ts; -+ clock_gettime(CLOCK_MONOTONIC, &ts); -+ const auto seconds = inner_time_type(ts.tv_sec); -+ const auto milliseconds = inner_time_type(ts.tv_nsec) / 1000000; -+ return seconds * 1000 + milliseconds; -+} -+ -+time convert(inner_time_type value) { -+ return time(value); -+} -+ -+inner_profile_type current_profile_value() { -+ timespec ts; -+ clock_gettime(CLOCK_MONOTONIC, &ts); -+ const auto seconds = inner_profile_type(ts.tv_sec); -+ const auto milliseconds = inner_profile_type(ts.tv_nsec) / 1000; -+ return seconds * 1000000 + milliseconds; -+} -+ -+profile_time convert_profile(inner_profile_type value) { -+ return profile_time(value); -+} -+ -+} // namespace crl::details -+ -+#endif // CRL_USE_LINUX_TIME -diff --git a/Telegram/lib_ui/CMakeLists.txt b/Telegram/lib_ui/CMakeLists.txt -index b48b8f9..579b66a 100644 ---- a/Telegram/lib_ui/CMakeLists.txt -+++ b/Telegram/lib_ui/CMakeLists.txt -@@ -97,6 +97,10 @@ PRIVATE - ui/platform/win/ui_window_win.h - ui/platform/win/ui_utility_win.cpp - ui/platform/win/ui_utility_win.h -+ ui/platform/haiku/ui_window_haiku.cpp -+ ui/platform/haiku/ui_window_haiku.h -+ ui/platform/haiku/ui_utility_haiku.cpp -+ ui/platform/haiku/ui_utility_haiku.h - ui/platform/ui_platform_window_title.cpp - ui/platform/ui_platform_window_title.h - ui/platform/ui_platform_window.cpp -diff --git a/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.cpp b/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.cpp -new file mode 100644 -index 0000000..62cdebf ---- /dev/null -+++ b/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.cpp -@@ -0,0 +1,41 @@ -+/* -+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) 2019-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "ui/platform/haiku/ui_utility_haiku.h" -+#include "ui/platform/ui_platform_window_title.h" -+#include "base/platform/base_platform_info.h" -+ -+#include -+ -+namespace Ui { -+namespace Platform { -+ -+bool IsApplicationActive() { -+ return QApplication::activeWindow() != nullptr; -+} -+ -+bool TranslucentWindowsSupported(QPoint globalPosition) { -+ return false; -+} -+ -+void IgnoreAllActivation(not_null widget) { -+} -+ -+TitleControls::Layout TitleControlsLayout() { -+ return TitleControls::Layout{ -+ .right = { -+ TitleControls::Control::Minimize, -+ TitleControls::Control::Maximize, -+ TitleControls::Control::Close, -+ } -+ }; -+} -+ -+} // namespace Platform -+} // namespace Ui -diff --git a/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.h b/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.h -new file mode 100644 -index 0000000..97eab8f ---- /dev/null -+++ b/Telegram/lib_ui/ui/platform/haiku/ui_utility_haiku.h -@@ -0,0 +1,60 @@ -+/* -+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) 2019-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+class QPainter; -+class QPaintEvent; -+ -+namespace Ui { -+namespace Platform { -+ -+inline void StartTranslucentPaint(QPainter &p, const QRegion ®ion) { -+} -+ -+inline void InitOnTopPanel(not_null panel) { -+} -+ -+inline void DeInitOnTopPanel(not_null panel) { -+} -+ -+inline void ReInitOnTopPanel(not_null panel) { -+} -+ -+inline void UpdateOverlayed(not_null widget) { -+} -+ -+inline void ShowOverAll(not_null widget, bool canFocus) { -+} -+ -+inline void BringToBack(not_null widget) { -+} -+ -+inline bool WindowExtentsSupported() { -+ return false; -+} -+ -+inline bool SetWindowExtents(QWindow *window, const QMargins &extents) { -+ return false; -+} -+ -+inline bool UnsetWindowExtents(QWindow *window) { -+ return false; -+} -+ -+inline bool ShowWindowMenu(QWindow *window) { -+ return false; -+} -+ -+inline constexpr bool UseMainQueueGeneric() { -+ return true; -+} -+ -+} // namespace Platform -+} // namespace Ui -diff --git a/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.cpp b/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.cpp -new file mode 100644 -index 0000000..bce8d37 ---- /dev/null -+++ b/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.cpp -@@ -0,0 +1,21 @@ -+/* -+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) 2019-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#include "ui/platform/haiku/ui_window_haiku.h" -+ -+namespace Ui { -+namespace Platform { -+ -+std::unique_ptr CreateSpecialWindowHelper( -+ not_null window) { -+ return nullptr; -+} -+ -+} // namespace Platform -+} // namespace Ui -diff --git a/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.h b/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.h -new file mode 100644 -index 0000000..ecb1277 ---- /dev/null -+++ b/Telegram/lib_ui/ui/platform/haiku/ui_window_haiku.h -@@ -0,0 +1,12 @@ -+/* -+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) 2019-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+*/ -+ -+#pragma once -+ -+#include "ui/platform/ui_platform_window.h" -diff --git a/Telegram/lib_ui/ui/platform/ui_platform_utility.h b/Telegram/lib_ui/ui/platform/ui_platform_utility.h -index e8629a1..01cff34 100644 ---- a/Telegram/lib_ui/ui/platform/ui_platform_utility.h -+++ b/Telegram/lib_ui/ui/platform/ui_platform_utility.h -@@ -45,6 +45,8 @@ bool ShowWindowMenu(QWindow *window); - - #ifdef Q_OS_MAC - #include "ui/platform/mac/ui_utility_mac.h" -+#elif defined Q_OS_HAIKU -+#include "ui/platform/haiku/ui_utility_haiku.h" - #elif defined Q_OS_UNIX // Q_OS_MAC - #include "ui/platform/linux/ui_utility_linux.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX -diff --git a/Telegram/lib_ui/ui/style/style_core_custom_font.cpp b/Telegram/lib_ui/ui/style/style_core_custom_font.cpp -index 570d169..8644d20 100644 ---- a/Telegram/lib_ui/ui/style/style_core_custom_font.cpp -+++ b/Telegram/lib_ui/ui/style/style_core_custom_font.cpp -@@ -44,7 +44,10 @@ QFont ResolveFont(uint32 flags, int size) { - const auto point = good.isEmpty() ? size : good.front(); - result = Database.font(custom.family, custom.style, point); - } else { -+// Don't override fonts for Haiku -+#ifndef __HAIKU__ - result.setFamily(GetFontOverride(flags)); -+#endif - if (bold) { - #ifdef DESKTOP_APP_USE_PACKAGED_FONTS - result.setWeight(QFont::DemiBold); -diff --git a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp -index 410deb3..4ed5195 100644 ---- a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp -+++ b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp -@@ -4,6 +4,14 @@ - // For license and copyright information please follow this link: - // https://github.com/desktop-app/legal/blob/master/LEGAL - // -+ -+// Don't include SupportDefs.h -+#ifdef __HAIKU__ -+#define _SUPPORT_DEFS_H -+typedef int32 status_t; -+typedef uint32 type_code; -+#endif -+ - #include "webrtc/details/webrtc_openal_adm.h" - - #include "base/timer.h" -diff --git a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp -index 092b667..a681b03 100644 ---- a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp -+++ b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp -@@ -6,6 +6,13 @@ - // - #include "webrtc/webrtc_audio_input_tester.h" - -+// Don't include SupportDefs.h -+#ifdef __HAIKU__ -+#define _SUPPORT_DEFS_H -+typedef int32 status_t; -+typedef uint32 type_code; -+#endif -+ - #include "webrtc/webrtc_create_adm.h" - #include "media/engine/webrtc_media_engine.h" - #include "api/task_queue/default_task_queue_factory.h" -diff --git a/cmake/external/webrtc/CMakeLists.txt b/cmake/external/webrtc/CMakeLists.txt -index 477fc6f..2d93d07 100644 ---- a/cmake/external/webrtc/CMakeLists.txt -+++ b/cmake/external/webrtc/CMakeLists.txt -@@ -7,7 +7,7 @@ - add_library(external_webrtc INTERFACE IMPORTED GLOBAL) - add_library(desktop-app::external_webrtc ALIAS external_webrtc) - --if (DESKTOP_APP_USE_PACKAGED) -+if (DESKTOP_APP_USE_PACKAGED AND NOT HAIKU) - find_package(tg_owt REQUIRED) - target_link_libraries(external_webrtc INTERFACE tg_owt::tg_owt) - else() -@@ -43,6 +43,11 @@ else() - INTERFACE - WEBRTC_MAC - ) -+ elseif (HAIKU) -+ target_compile_definitions(external_webrtc -+ INTERFACE -+ WEBRTC_HAIKU -+ ) - else() - target_compile_definitions(external_webrtc - INTERFACE -diff --git a/cmake/nice_target_sources.cmake b/cmake/nice_target_sources.cmake -index 81f9a7b..3b55109 100644 ---- a/cmake/nice_target_sources.cmake -+++ b/cmake/nice_target_sources.cmake -@@ -15,6 +15,7 @@ function(nice_target_sources target_name src_loc) - set(not_win_sources "") - set(not_mac_sources "") - set(not_linux_sources "") -+ set(not_haiku_sources "") - foreach (entry ${list}) - if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") - set(writing_now ${entry}) -@@ -23,12 +24,19 @@ function(nice_target_sources target_name src_loc) - if (${entry} MATCHES "(^|/)win/" OR ${entry} MATCHES "(^|/)winrc/" OR ${entry} MATCHES "(^|/)windows/" OR ${entry} MATCHES "[_\\/]win\\.") - list(APPEND not_mac_sources ${full_name}) - list(APPEND not_linux_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)mac/" OR ${entry} MATCHES "(^|/)darwin/" OR ${entry} MATCHES "(^|/)osx/" OR ${entry} MATCHES "[_\\/]mac\\." OR ${entry} MATCHES "[_\\/]darwin\\." OR ${entry} MATCHES "[_\\/]osx\\.") - list(APPEND not_win_sources ${full_name}) - list(APPEND not_linux_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)linux/" OR ${entry} MATCHES "[_\\/]linux\\.") - list(APPEND not_win_sources ${full_name}) - list(APPEND not_mac_sources ${full_name}) -+ list(APPEND not_haiku_sources ${full_name}) -+ elseif (${entry} MATCHES "(^|/)haiku/" OR ${entry} MATCHES "[_\\/]haiku\\.") -+ list(APPEND not_win_sources ${full_name}) -+ list(APPEND not_mac_sources ${full_name}) -+ list(APPEND not_linux_sources ${full_name}) - elseif (${entry} MATCHES "(^|/)posix/" OR ${entry} MATCHES "[_\\/]posix\\.") - list(APPEND not_win_sources ${full_name}) - endif() -@@ -64,6 +72,9 @@ function(nice_target_sources target_name src_loc) - elseif (APPLE) - set_source_files_properties(${not_mac_sources} PROPERTIES HEADER_FILE_ONLY TRUE) - set_source_files_properties(${not_mac_sources} PROPERTIES SKIP_AUTOGEN TRUE) -+ elseif (HAIKU) -+ set_source_files_properties(${not_haiku_sources} PROPERTIES HEADER_FILE_ONLY TRUE) -+ set_source_files_properties(${not_haiku_sources} PROPERTIES SKIP_AUTOGEN TRUE) - elseif (LINUX) - set_source_files_properties(${not_linux_sources} PROPERTIES HEADER_FILE_ONLY TRUE) - set_source_files_properties(${not_linux_sources} PROPERTIES SKIP_AUTOGEN TRUE) -diff --git a/cmake/options.cmake b/cmake/options.cmake -index 28521b2..c162955 100644 ---- a/cmake/options.cmake -+++ b/cmake/options.cmake -@@ -79,6 +79,8 @@ if (WIN32) - include(cmake/options_win.cmake) - elseif (APPLE) - include(cmake/options_mac.cmake) -+elseif (HAIKU) -+ include(cmake/options_haiku.cmake) - elseif (LINUX) - include(cmake/options_linux.cmake) - else() -diff --git a/cmake/options_haiku.cmake b/cmake/options_haiku.cmake -new file mode 100644 -index 0000000..718f37a ---- /dev/null -+++ b/cmake/options_haiku.cmake -@@ -0,0 +1,34 @@ -+# 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) 2019-2020 Gerasim Troeglazov, 3dEyes@gmail.com -+ -+target_compile_options(common_options -+INTERFACE -+ $,,-fno-strict-aliasing> -+ -fPIC -+ -mmmx -+ -msse2 -+ -Wno-unused-variable -+ -Wno-unused-parameter -+ -Wno-unused-function -+ -Wno-switch -+ -Wno-comment -+ -Wno-unused-but-set-variable -+ -Wno-missing-field-initializers -+ -Wno-sign-compare -+ -Wno-attributes -+ -Wno-parentheses -+ -Wno-stringop-overflow -+ -Wno-maybe-uninitialized -+ -Wno-error=class-memaccess -+ -Wno-deprecated-declarations -+) -+ -+target_link_libraries(common_options -+INTERFACE -+ be -+ network -+ media -+ translation -+) -diff --git a/cmake/validate_special_target.cmake b/cmake/validate_special_target.cmake -index 97f61be..f08430d 100644 ---- a/cmake/validate_special_target.cmake -+++ b/cmake/validate_special_target.cmake -@@ -31,7 +31,7 @@ elseif (APPLE) - AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "mac") - report_bad_special_target() - endif() --else() -+elseif (LINUX) - set(LINUX 1) - if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "linux" - AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "linux32") -diff --git a/cmake/variables.cmake b/cmake/variables.cmake -index e429c00..f2b6689 100644 ---- a/cmake/variables.cmake -+++ b/cmake/variables.cmake -@@ -62,6 +62,7 @@ set(build_winstore 0) # 32 or 64 bit - set(build_linux32 0) - set(build_win64 0) # normal or uwp - set(build_winstore64 0) -+set(build_haiku 0) - - if (WIN32) - if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "win64") -@@ -79,6 +80,12 @@ elseif (APPLE) - elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "macstore") - set(build_macstore 1) - endif() -+elseif (HAIKU) -+ set(build_haiku 1) -+ set(DESKTOP_APP_USE_GLIBC_WRAPS OFF) -+ set(CMAKE_AR gcc-ar) -+ set(CMAKE_RANLIB gcc-ranlib) -+ set(CMAKE_NM gcc-nm) - else() - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - set(build_linux32 1) --- -2.30.0 - diff --git a/net-im/telegram-desktop/patches/telegram_desktop-2.6.1.patchset b/net-im/telegram-desktop/patches/telegram_desktop-2.6.1.patchset new file mode 100644 index 000000000..da37d0d48 --- /dev/null +++ b/net-im/telegram-desktop/patches/telegram_desktop-2.6.1.patchset @@ -0,0 +1,742 @@ +From 5fff21fdc96b36c3eb24ca31b8ce3c81b3817029 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Thu, 25 Feb 2021 17:20:48 +1000 +Subject: Add haiku support + + +diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt +index c5ba8fd..19037d3 100644 +--- a/Telegram/CMakeLists.txt ++++ b/Telegram/CMakeLists.txt +@@ -1137,6 +1137,18 @@ if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) + ) + endif() + ++if (HAIKU) ++ remove_target_sources(Telegram ${src_loc} ++ platform/linux/notifications_manager_linux.h ++ platform/linux/notifications_manager_linux_dummy.cpp ++ ) ++ nice_target_sources(Telegram ${src_loc} ++ PRIVATE ++ platform/linux/notifications_manager_haiku.h ++ 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) + nice_target_sources(Telegram ${src_loc} PRIVATE platform/linux/linux_wayland_integration_dummy.cpp) +@@ -1263,7 +1275,7 @@ elseif (build_osx) + else() + set(bundle_identifier "com.tdesktop.Telegram$<$:Debug>") + set(bundle_entitlements "Telegram.entitlements") +- if (LINUX AND DESKTOP_APP_USE_PACKAGED) ++ if (LINUX AND NOT HAIKU AND DESKTOP_APP_USE_PACKAGED) + set(output_name "telegram-desktop") + else() + set(output_name "Telegram") +diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h +index 732f75b..138608f 100644 +--- a/Telegram/SourceFiles/core/core_settings.h ++++ b/Telegram/SourceFiles/core/core_settings.h +@@ -586,7 +586,7 @@ private: + rpl::variable _dialogsWidthRatio; // per-window + rpl::variable _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w + bool _notifyFromAll = true; +- rpl::variable _nativeWindowFrame = false; ++ rpl::variable _nativeWindowFrame = true; + rpl::variable> _systemDarkMode = std::nullopt; + rpl::variable _systemDarkModeEnabled = false; + WindowPosition _windowPosition; // per-window +diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +index 9796164..947f7fc 100644 +--- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +@@ -620,14 +620,26 @@ 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() { ++#ifdef Q_OS_HAIKU ++ if (trayIcon && trayIconMenu ++ && trayIcon->contextMenu() != trayIconMenu) { ++ trayIcon->setContextMenu(trayIconMenu); ++ } ++#endif + } + + #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +@@ -893,8 +905,10 @@ void MainWindow::updateIconCounters() { + } + + void MainWindow::initTrayMenuHook() { ++#ifndef Q_OS_HAIKU + _trayIconMenuXEmbed.emplace(nullptr, trayIconMenu); + _trayIconMenuXEmbed->deleteOnHide(false); ++#endif + } + + #ifdef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +diff --git a/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.cpp b/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.cpp +new file mode 100644 +index 0000000..d567f10 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.cpp +@@ -0,0 +1,64 @@ ++/* ++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-2019 Gerasim Troeglazov, 3dEyes@gmail.com ++*/ ++ ++#include ++#include ++ ++#include ++#include ++ ++#define APPSIGNATURE "application/x-vnd.tg-notify-gate" ++#define NOTIFY_PORT_NAME "tg_notify" ++#define NOTIFY_MESSAGE 'TGNF' ++ ++typedef struct notify_msg ++{ ++ uint64 sessionId; ++ uint64 peerId; ++ int32 msgId; ++} notify_msg; ++ ++class SimpleLauncherApp : public BApplication { ++ public: ++ SimpleLauncherApp(int argc, char **argv); ++ void ArgvReceived(int32 argc, char **argv); ++ virtual void ReadyToRun(); ++}; ++ ++SimpleLauncherApp::SimpleLauncherApp(int argc, char **argv) : BApplication(APPSIGNATURE) ++{ ++} ++ ++void ++SimpleLauncherApp::ArgvReceived(int32 argc, char **argv) ++{ ++ if (argc == 2) { ++ notify_msg message; ++ sscanf(argv[1], "%lld %lld %d", &message.sessionId, &message.peerId, &message.msgId); ++ if (message.peerId != 0 && message.msgId != 0) { ++ port_id portId = find_port(NOTIFY_PORT_NAME); ++ if (portId > 0) { ++ write_port(portId, NOTIFY_MESSAGE, &message, sizeof(message)); ++ } ++ } ++ } ++} ++ ++void ++SimpleLauncherApp::ReadyToRun() ++{ ++ Quit(); ++} ++ ++int main(int argc, char **argv) ++{ ++ SimpleLauncherApp application(argc, argv); ++ application.Run(); ++ return 0; ++} +diff --git a/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.rdef b/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.rdef +new file mode 100644 +index 0000000..b6f3490 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.rdef +@@ -0,0 +1,13 @@ ++resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP; ++ ++resource app_version { ++ major = 0, ++ middle = 0, ++ minor = 1, ++ variety = B_APPV_FINAL, ++ internal = 0, ++ short_info = "tg-notify-gate", ++ long_info = "Telegram native notifications gate" ++}; ++ ++resource app_signature "application/x-vnd.tg-notify-gate"; +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..e36b747 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp +@@ -0,0 +1,202 @@ ++/* ++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 ++*/ ++ ++#ifdef __x86_64__ ++#define int64 __haiku_int64 ++#define uint64 __haiku_uint64 ++#else ++#define int32 __haiku_int32 ++#define uint32 __haiku_uint32 ++#endif ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "platform/linux/notifications_manager_haiku.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 DeclareReadOnlyVar(Type, Name) const Type &Name(); ++#define DeclareRefVar(Type, Name) DeclareReadOnlyVar(Type, Name) \ ++ Type &Ref##Name(); ++#define DeclareVar(Type, Name) DeclareRefVar(Type, Name) \ ++ void Set##Name(const Type &Name); ++ ++#include ++#include ++#include ++#include ++#include ++ ++namespace Platform { ++namespace Notifications { ++namespace { ++ ++} // namespace ++ ++bool Supported() { ++ 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); ++} ++ ++void Finish() { ++} ++ ++NotifyReader::NotifyReader() ++{ ++ portId = create_port(NOTIFY_MESSAGE_DEEP, NOTIFY_PORT_NAME); ++} ++ ++NotifyReader::~NotifyReader() ++{ ++ if (portId >= B_OK) ++ delete_port(portId); ++} ++ ++void NotifyReader::run() ++{ ++ notify_msg message; ++ int32 code; ++ ++ while (true) { ++ ssize_t bytesRead = read_port(portId, &code, &message, sizeof(message)); ++ if (bytesRead == B_BAD_PORT_ID) ++ break; ++ if (bytesRead < (ssize_t)sizeof(message) || code != NOTIFY_MESSAGE) ++ continue; ++ if (message.peerId != 0 && message.msgId != 0) ++ notificationActivated(message.sessionId, message.peerId, message.msgId); ++ } ++} ++ ++Manager::Private::Private(not_null manager, Type type) ++: _cachedUserpics(type) ++, _manager(manager) { ++ portReaderThread = new QThread; ++ portReader = new NotifyReader(); ++ portReader->moveToThread(portReaderThread); ++ connect(portReaderThread, SIGNAL(started()), portReader, SLOT(run())); ++ qRegisterMetaType("PeerId"); ++ qRegisterMetaType("MsgId"); ++ connect( ++ portReader, ++ SIGNAL(notificationActivated(PeerId, PeerId, MsgId)), ++ this, ++ SLOT(notificationActivatedSlot(PeerId, PeerId, MsgId))); ++ portReaderThread->start(); ++} ++ ++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("%1 %2 %3").arg(peer->session().uniqueId()).arg(peer->id).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(); ++} ++ ++void ++Manager::Private::notificationActivatedSlot(PeerId _sessionId, PeerId _peerId, MsgId _msgId) { ++ const auto manager = _manager; ++ const auto my = Window::Notifications::Manager::NotificationId{ ++ .full = Manager::FullPeer{ ++ .sessionId = _sessionId, ++ .peerId = _peerId ++ }, ++ .msgId = _msgId ++ }; ++ crl::on_main(manager, [=] { ++ manager->notificationActivated(my); ++ }); ++} ++ ++Manager::Manager(Window::Notifications::System *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) { ++} ++ ++} // namespace Notifications ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.h b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.h +new file mode 100644 +index 0000000..1f80b62 +--- /dev/null ++++ b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.h +@@ -0,0 +1,123 @@ ++/* ++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 ++*/ ++ ++#pragma once ++ ++#include "platform/platform_notifications_manager.h" ++#include "window/notifications_utilities.h" ++ ++#include ++#include ++#include ++ ++#define NOTIFY_MESSAGE_DEEP 16 ++#define NOTIFY_PORT_NAME "tg_notify" ++#define NOTIFY_GATE_NAME "/bin/tg-notify-gate" ++#define NOTIFY_MESSAGE 'TGNF' ++ ++typedef struct notify_msg ++{ ++ uint64 sessionId; ++ uint64 peerId; ++ int32 msgId; ++} notify_msg; ++ ++namespace Platform { ++namespace Notifications { ++ ++inline bool SkipAudio() { ++ return false; ++} ++ ++inline bool SkipToast() { ++ return false; ++} ++ ++inline bool SkipFlashBounce() { ++ return false; ++} ++ ++inline bool Enforced() { ++ return false; ++} ++ ++inline bool ByDefault() { ++ return true; ++} ++ ++void Finish(); ++ ++class NotifyReader:public QObject { ++ Q_OBJECT ++public: ++ NotifyReader(); ++ ~NotifyReader(); ++public slots: ++ void run(); ++signals: ++ void notificationActivated(PeerId sessionId, PeerId peerId, MsgId msgId); ++private: ++ int32 portId; ++}; ++ ++ ++class Manager : public Window::Notifications::NativeManager, public base::has_weak_ptr { ++public: ++ Manager(Window::Notifications::System *system); ++ ~Manager(); ++ ++protected: ++ void doShowNativeNotification( ++ not_null peer, ++ std::shared_ptr &userpicView, ++ MsgId msgId, ++ const QString &title, ++ const QString &subtitle, ++ const QString &msg, ++ bool hideNameAndPhoto, ++ bool hideReplyButton) override; ++ void doClearAllFast() override; ++ void doClearFromHistory(not_null history) override; ++ void doClearFromSession(not_null session) override; ++ ++private: ++ class Private; ++ const std::unique_ptr _private; ++}; ++ ++class Manager::Private : public QObject { ++ Q_OBJECT ++ ++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); ++ ++public slots: ++ void notificationActivatedSlot(PeerId sessionId, PeerId peerId, MsgId msgId); ++ ++private: ++ Window::Notifications::CachedUserpics _cachedUserpics; ++ base::weak_ptr _manager; ++ ++ QThread *portReaderThread; ++ NotifyReader *portReader; ++}; ++ ++} // namespace Notifications ++} // namespace Platform +diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +index 386de2e..7bd4dff 100644 +--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +@@ -618,7 +618,7 @@ QString GetHomeDir() { + return home; + } + +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + void HaikuAutostart(bool start) { + const auto home = GetHomeDir(); + if (home.isEmpty()) { +@@ -643,7 +643,7 @@ void HaikuAutostart(bool start) { + file.remove(); + } + } +-#endif // __HAIKU__ ++#endif // Q_OS_HAIKU + + } // namespace + +@@ -660,8 +660,11 @@ QString psAppDataPath() { + return oldPath; + } + } +- ++#ifdef Q_OS_HAIKU ++ return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + '/'; ++#else + return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; ++#endif + } + + void psDoCleanup() { +@@ -895,7 +898,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"); +@@ -958,17 +961,17 @@ void finish() { + } // namespace Platform + + void psNewVersion() { +-#ifndef __HAIKU__ ++#ifndef Q_OS_HAIKU + Platform::InstallLauncher(); +-#endif // __HAIKU__ ++#endif // Q_OS_HAIKU + Platform::RegisterCustomScheme(); + } + + void psAutoStart(bool start, bool silent) { +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + HaikuAutostart(start); + return; +-#endif // __HAIKU__ ++#endif // Q_OS_HAIKU + + if (InFlatpak()) { + #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +diff --git a/Telegram/SourceFiles/platform/platform_notifications_manager.h b/Telegram/SourceFiles/platform/platform_notifications_manager.h +index eb3efbd..2cd3ca1 100644 +--- a/Telegram/SourceFiles/platform/platform_notifications_manager.h ++++ b/Telegram/SourceFiles/platform/platform_notifications_manager.h +@@ -28,8 +28,10 @@ void Create(Window::Notifications::System *system); + + #ifdef Q_OS_MAC + #include "platform/mac/notifications_manager_mac.h" +-#elif defined Q_OS_UNIX // Q_OS_MAC ++#elif defined Q_OS_HAIKU // Q_OS_MAC ++#include "platform/linux/notifications_manager_haiku.h" ++#elif defined Q_OS_UNIX // Q_OS_MAC || Q_OS_HAIKU + #include "platform/linux/notifications_manager_linux.h" +-#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX ++#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX || Q_OS_HAIKU + #include "platform/win/notifications_manager_win.h" +-#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN ++#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN || Q_OS_HAIKU +diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake +index 79f5023..b1f82ab 100644 +--- a/Telegram/cmake/lib_tgvoip.cmake ++++ b/Telegram/cmake/lib_tgvoip.cmake +@@ -181,7 +181,6 @@ if (NOT TGVOIP_FOUND) + ) + target_link_libraries(lib_tgvoip_bundled + PRIVATE +- be + network + media + ) +diff --git a/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp b/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp +index 80f2ffa..268a0bd 100644 +--- a/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp ++++ b/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp +@@ -296,7 +296,7 @@ TitleControls::Layout TitleControlsLayout() { + return *gtkResult; + } + +-#ifdef __HAIKU__ ++#ifdef Q_OS_HAIKU + return TitleControls::Layout{ + .left = { + TitleControls::Control::Close, +@@ -306,7 +306,7 @@ TitleControls::Layout TitleControlsLayout() { + TitleControls::Control::Maximize, + } + }; +-#else // __HAIKU__ ++#else // Q_OS_HAIKU + return TitleControls::Layout{ + .right = { + TitleControls::Control::Minimize, +@@ -314,7 +314,7 @@ TitleControls::Layout TitleControlsLayout() { + TitleControls::Control::Close, + } + }; +-#endif // !__HAIKU__ ++#endif // !Q_OS_HAIKU + } + + } // namespace Platform +diff --git a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp +index 410deb3..e0ec769 100644 +--- a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp ++++ b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp +@@ -4,6 +4,13 @@ + // For license and copyright information please follow this link: + // https://github.com/desktop-app/legal/blob/master/LEGAL + // ++ ++#ifdef __HAIKU__ ++#define _SUPPORT_DEFS_H ++typedef int32 status_t; ++typedef uint32 type_code; ++#endif ++ + #include "webrtc/details/webrtc_openal_adm.h" + + #include "base/timer.h" +diff --git a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp +index 092b667..e594a22 100644 +--- a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp ++++ b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp +@@ -4,6 +4,13 @@ + // For license and copyright information please follow this link: + // https://github.com/desktop-app/legal/blob/master/LEGAL + // ++ ++#ifdef __HAIKU__ ++#define _SUPPORT_DEFS_H ++typedef int32 status_t; ++typedef uint32 type_code; ++#endif ++ + #include "webrtc/webrtc_audio_input_tester.h" + + #include "webrtc/webrtc_create_adm.h" +diff --git a/cmake/nice_target_sources.cmake b/cmake/nice_target_sources.cmake +index 81f9a7b..38d81f9 100644 +--- a/cmake/nice_target_sources.cmake ++++ b/cmake/nice_target_sources.cmake +@@ -15,6 +15,7 @@ function(nice_target_sources target_name src_loc) + set(not_win_sources "") + set(not_mac_sources "") + set(not_linux_sources "") ++ set(not_haiku_sources "") + foreach (entry ${list}) + if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") + set(writing_now ${entry}) +@@ -23,12 +24,18 @@ function(nice_target_sources target_name src_loc) + if (${entry} MATCHES "(^|/)win/" OR ${entry} MATCHES "(^|/)winrc/" OR ${entry} MATCHES "(^|/)windows/" OR ${entry} MATCHES "[_\\/]win\\.") + list(APPEND not_mac_sources ${full_name}) + list(APPEND not_linux_sources ${full_name}) ++ list(APPEND not_haiku_sources ${full_name}) + elseif (${entry} MATCHES "(^|/)mac/" OR ${entry} MATCHES "(^|/)darwin/" OR ${entry} MATCHES "(^|/)osx/" OR ${entry} MATCHES "[_\\/]mac\\." OR ${entry} MATCHES "[_\\/]darwin\\." OR ${entry} MATCHES "[_\\/]osx\\.") + list(APPEND not_win_sources ${full_name}) + list(APPEND not_linux_sources ${full_name}) ++ list(APPEND not_haiku_sources ${full_name}) + elseif (${entry} MATCHES "(^|/)linux/" OR ${entry} MATCHES "[_\\/]linux\\.") + list(APPEND not_win_sources ${full_name}) + list(APPEND not_mac_sources ${full_name}) ++ elseif (${entry} MATCHES "(^|/)haiku/" OR ${entry} MATCHES "[_\\/]haiku\\.") ++ list(APPEND not_win_sources ${full_name}) ++ list(APPEND not_mac_sources ${full_name}) ++ list(APPEND not_linux_sources ${full_name}) + elseif (${entry} MATCHES "(^|/)posix/" OR ${entry} MATCHES "[_\\/]posix\\.") + list(APPEND not_win_sources ${full_name}) + endif() +@@ -64,6 +71,9 @@ function(nice_target_sources target_name src_loc) + elseif (APPLE) + set_source_files_properties(${not_mac_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + set_source_files_properties(${not_mac_sources} PROPERTIES SKIP_AUTOGEN TRUE) ++ elseif (HAIKU) ++ set_source_files_properties(${not_haiku_sources} PROPERTIES HEADER_FILE_ONLY TRUE) ++ set_source_files_properties(${not_haiku_sources} PROPERTIES SKIP_AUTOGEN TRUE) + elseif (LINUX) + set_source_files_properties(${not_linux_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + set_source_files_properties(${not_linux_sources} PROPERTIES SKIP_AUTOGEN TRUE) +diff --git a/cmake/options_linux.cmake b/cmake/options_linux.cmake +index d586e79..ef8b213 100644 +--- a/cmake/options_linux.cmake ++++ b/cmake/options_linux.cmake +@@ -60,3 +60,11 @@ if (ATOMIC_LIBRARY) + ${ATOMIC_LIBRARY} + ) + endif() ++ ++if (HAIKU) ++ target_link_libraries(common_options ++ INTERFACE ++ be ++ translation ++ ) ++endif() +-- +2.30.0 + diff --git a/net-im/telegram-desktop/telegram_desktop-2.5.9.recipe b/net-im/telegram-desktop/telegram_desktop-2.6.1.recipe similarity index 64% rename from net-im/telegram-desktop/telegram_desktop-2.5.9.recipe rename to net-im/telegram-desktop/telegram_desktop-2.6.1.recipe index 2d7615876..1ba0a0dce 100644 --- a/net-im/telegram-desktop/telegram_desktop-2.5.9.recipe +++ b/net-im/telegram-desktop/telegram_desktop-2.6.1.recipe @@ -5,32 +5,18 @@ COPYRIGHT="2013-2021 Telegram" LICENSE="GNU GPL v3" REVISION="1" SOURCE_URI="https://github.com/telegramdesktop/tdesktop/releases/download/v$portVersion/tdesktop-$portVersion-full.tar.gz" -CHECKSUM_SHA256="82eefd342d8ba380e08a8606ac59a34bfacfb2f501408a0385884696966a218c" +CHECKSUM_SHA256="c7878c4d7c621a175b3b27895b3fb8c20a56319214d5030d734b2768390a8b73" SOURCE_FILENAME="tdesktop-$portVersion-full.tar.gz" SOURCE_DIR="tdesktop-$portVersion-full" -srcGitRev_2="be23804afce3bb2e80a1d57a7c1318c71b82b7de" -SOURCE_URI_2="https://github.com/desktop-app/tg_owt/archive/$srcGitRev_2.tar.gz" -CHECKSUM_SHA256_2="b0bcf4f982fe955d41d30c2d2ccab65a9f7fc587dc334c03219aba0c4dd3d13e" -SOURCE_FILENAME_2="tg_owt-$srcGitRev_2.tar.gz" -srcGitRev_3="ebb5ffc1d462c70dfb2283a5c7afcb75288c7692" -SOURCE_URI_3="https://github.com/webmproject/libvpx/archive/$srcGitRev_3.tar.gz" -CHECKSUM_SHA256_3="a7adf6a905fe7e51caf45ef16c2c4b80fff253db08d49633a045310e0fd3793c" -SOURCE_FILENAME_3="libvpx-$srcGitRev_3.tar.gz" -srcGitRev_4="19d71f6b351fe992ae34b114eebd872c383a6bdb" -SOURCE_URI_4="https://github.com/lemenkov/libyuv/archive/$srcGitRev_4.tar.gz" -CHECKSUM_SHA256_4="64a277a20a85f38ac963a9434ec7faa261bf66d2f9268c24461476c8b3d9b39f" -SOURCE_FILENAME_4="libyuv-$srcGitRev_4.tar.gz" -srcGitRev_5="2b383fe05f8ae78ac99470b9a2b9ea22b3ee5a92" -SOURCE_URI_5="https://salsa.debian.org/debian/telegram-desktop/-/raw/$srcGitRev_5/debian/rules#noarchive" -CHECKSUM_SHA256_5="613e7e357518739e1f7d035337f37c344b248283fd4d916ddc95df73c2ff84ad" +srcGitRev_2="2b383fe05f8ae78ac99470b9a2b9ea22b3ee5a92" +SOURCE_URI_2="https://salsa.debian.org/debian/telegram-desktop/-/raw/$srcGitRev_2/debian/rules#noarchive" +CHECKSUM_SHA256_2="613e7e357518739e1f7d035337f37c344b248283fd4d916ddc95df73c2ff84ad" -PATCHES="telegram_desktop-$portVersion.patchset" -PATCHES_2="telegram_desktop-$portVersion-owt.patchset" - -ADDITIONAL_FILES=" - telegram_desktop.rdef.in - logo_256_no_margin.png +PATCHES=" + libtgvoip-$portVersion.patchset + telegram_desktop-$portVersion.patchset " +ADDITIONAL_FILES="telegram_desktop.rdef.in" ARCHITECTURES="!x86_gcc2 x86_64" SECONDARY_ARCHITECTURES="x86" @@ -42,6 +28,7 @@ PROVIDES=" " REQUIRES=" haiku$secondaryArchSuffix + lib:libatomic$secondaryArchSuffix lib:libavcodec$secondaryArchSuffix lib:libavformat$secondaryArchSuffix lib:libavutil$secondaryArchSuffix @@ -49,6 +36,7 @@ REQUIRES=" lib:libglib_2.0$secondaryArchSuffix lib:libgthread_2.0$secondaryArchSuffix lib:libhunspell_1.7$secondaryArchSuffix + lib:libintl$secondaryArchSuffix lib:libjpeg$secondaryArchSuffix lib:liblz4$secondaryArchSuffix lib:liblzma$secondaryArchSuffix @@ -88,6 +76,7 @@ BUILD_REQUIRES=" devel:librapidjson$secondaryArchSuffix devel:libswresample$secondaryArchSuffix devel:libswscale$secondaryArchSuffix + devel:libtg_owt$secondaryArchSuffix devel:libxxhash$secondaryArchSuffix devel:libz$secondaryArchSuffix devel:range_v3$secondaryArchSuffix @@ -103,38 +92,13 @@ BUILD_PREREQUIRES=" cmd:yasm " -PATCH() -{ - cp -f $sourceDir/../../../additional-files/logo_256_no_margin.png Telegram/Resources/art -} - BUILD() { export DISABLE_ASLR=1 - #link submodules - mkdir -p $sourceDir/../Libraries - ln -sfn $sourceDir2/tg_owt-$srcGitRev_2 $sourceDir/../Libraries/tg_owt - rm -rf $sourceDir2/tg_owt-$srcGitRev_2/src/third_party/libvpx/source/libvpx - ln -sfn $sourceDir3/libvpx-$srcGitRev_3 $sourceDir2/tg_owt-$srcGitRev_2/src/third_party/libvpx/source/libvpx - rm -rf $sourceDir2/tg_owt-$srcGitRev_2/src/third_party/libyuv - ln -sfn $sourceDir4/libyuv-$srcGitRev_4 $sourceDir2/tg_owt-$srcGitRev_2/src/third_party/libyuv - - # build webrtc - mkdir -p $sourceDir/../Libraries/tg_owt/out/Release - cd $sourceDir/../Libraries/tg_owt/out/Release - cmake ../.. \ - -DCMAKE_BUILD_TYPE=Release \ - -DTG_OWT_SPECIAL_TARGET=haiku \ - -DTG_OWT_LIBJPEG_INCLUDE_PATH=/system/$relativeIncludeDir \ - -DTG_OWT_OPENSSL_INCLUDE_PATH=/system/$relativeIncludeDir \ - -DTG_OWT_OPUS_INCLUDE_PATH=/system/$relativeIncludeDir/opus \ - -DTG_OWT_FFMPEG_INCLUDE_PATH=/system/$relativeIncludeDir - make $jobArgs - # get API_ID and API_HASH from Debian - local TELEGRAM_API_ID=`sed -n 's/TELEGRAM_API_ID = \(.*\)/\1/p' < $sourceDir5/rules` - local TELEGRAM_API_HASH=`sed -n 's/TELEGRAM_API_HASH = \(.*\)/\1/p' < $sourceDir5/rules` + local TELEGRAM_API_ID=`sed -n "/TDESKTOP_API_ID/p" $sourceDir2/rules | cut -d'=' -f2 | cut -d' ' -f1` + local TELEGRAM_API_HASH=`sed -n "/TDESKTOP_API_HASH/p" $sourceDir2/rules | cut -d'=' -f2 | cut -d' ' -f1` if [ -z $TELEGRAM_API_ID ] || [ -z $TELEGRAM_API_HASH ]; then TELEGRAM_API_ID="17349" @@ -149,26 +113,30 @@ BUILD() fi # build telegram - mkdir -p $sourceDir/build - cd $sourceDir/build + mkdir -p build + cd build cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON \ -DTDESKTOP_API_TEST=OFF \ -DTDESKTOP_DISABLE_GTK_INTEGRATION=ON \ - -DDESKTOP_APP_DISABLE_AUTOUPDATE=ON \ + -DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON \ -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION=ON \ - -DDESKTOP_APP_USE_PACKAGED_FONTS=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_USE_PACKAGED_FONTS=OFF \ -DDESKTOP_APP_USE_HUNSPELL_ONLY=ON \ -DTDESKTOP_USE_PACKAGED_TGVOIP=OFF \ -DTDESKTOP_API_ID=$TELEGRAM_API_ID \ -DTDESKTOP_API_HASH=$TELEGRAM_API_HASH + make $jobArgs #build notify gate tool - gcc -o tg-notify-gate $sourceDir/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp -lbe - rc -o tg-notify-gate.rsrc $sourceDir/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.rdef + gcc -o tg-notify-gate $sourceDir/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.cpp -lbe + rc -o tg-notify-gate.rsrc $sourceDir/Telegram/SourceFiles/platform/linux/notifications_haiku_gate.rdef xres -o tg-notify-gate tg-notify-gate.rsrc mimeset --all tg-notify-gate }