From 7fea7853a8217a78829e0b7e31b6798556054dd1 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Sun, 23 Sep 2018 23:41:17 +1000 Subject: [PATCH] Telegram: bump version --- ...elegram_desktop-1.3.16-libtgvoip.patchset} | 804 ++++---- ...=> telegram_desktop-1.3.16-systemqt.patch} | 93 +- ...chset => telegram_desktop-1.3.16.patchset} | 1759 ++++------------- ....recipe => telegram_desktop-1.3.16.recipe} | 20 +- 4 files changed, 873 insertions(+), 1803 deletions(-) rename net-im/telegram-desktop/patches/{telegram_desktop-1.3.14-libtgvoip.patchset => telegram_desktop-1.3.16-libtgvoip.patchset} (64%) rename net-im/telegram-desktop/patches/{telegram_desktop-1.3.14-systemqt.patch => telegram_desktop-1.3.16-systemqt.patch} (90%) rename net-im/telegram-desktop/patches/{telegram_desktop-1.3.14.patchset => telegram_desktop-1.3.16.patchset} (57%) rename net-im/telegram-desktop/{telegram_desktop-1.3.14.recipe => telegram_desktop-1.3.16.recipe} (86%) diff --git a/net-im/telegram-desktop/patches/telegram_desktop-1.3.14-libtgvoip.patchset b/net-im/telegram-desktop/patches/telegram_desktop-1.3.16-libtgvoip.patchset similarity index 64% rename from net-im/telegram-desktop/patches/telegram_desktop-1.3.14-libtgvoip.patchset rename to net-im/telegram-desktop/patches/telegram_desktop-1.3.16-libtgvoip.patchset index ea073ee3e..220585afa 100644 --- a/net-im/telegram-desktop/patches/telegram_desktop-1.3.14-libtgvoip.patchset +++ b/net-im/telegram-desktop/patches/telegram_desktop-1.3.16-libtgvoip.patchset @@ -1,15 +1,174 @@ -From 957b6bc19b971d44f878a458c441301bd3215185 Mon Sep 17 00:00:00 2001 +From 15130ecca47fcbfd3e15c9ace71b00a669042202 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 30 Aug 2018 20:14:24 +1000 -Subject: Add Haiku platform +Date: Sun, 10 Jun 2018 11:08:42 +1000 +Subject: Fix for using external opus lib -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.cpp +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusDecoder.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusDecoder.h +index 6425c97..848b930 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusDecoder.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusDecoder.h +@@ -9,7 +9,7 @@ + + + #include "MediaStreamItf.h" +-#include "opus.h" ++#include + #include "threading.h" + #include "BlockingQueue.h" + #include "Buffers.h" +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusEncoder.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusEncoder.h +index 4726f6b..92d8c33 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusEncoder.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/OpusEncoder.h +@@ -9,7 +9,7 @@ + + + #include "MediaStreamItf.h" +-#include "opus.h" ++#include + #include "threading.h" + #include "BlockingQueue.h" + #include "Buffers.h" +-- +2.16.4 + + +From b4be4f2018dcc71fee9682e1f20f2a75799d9902 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 10 Jun 2018 11:10:12 +1000 +Subject: Add haiku modules + + +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/VoIPController.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/VoIPController.cpp +index 6d266a5..d08296a 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/VoIPController.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/VoIPController.cpp +@@ -8,6 +8,9 @@ + #include + #include + #endif ++#ifdef __HAIKU__ ++#include ++#endif + #include + #include + #include +@@ -2404,6 +2407,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/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioInput.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioInput.cpp +index 062ca06..887889e 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioInput.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioInput.cpp +@@ -22,6 +22,8 @@ + #elif defined(__linux__) + #include "../os/linux/AudioInputALSA.h" + #include "../os/linux/AudioInputPulse.h" ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioInputHaiku.h" + #else + #error "Unsupported operating system" + #endif +@@ -64,6 +66,8 @@ AudioInput *AudioInput::Create(std::string deviceID, void* platformSpecific){ + LOGW("in: PulseAudio available but not working; trying ALSA"); + } + return new AudioInputALSA(deviceID); ++#elif defined(__HAIKU__) ++ return new AudioInputHaiku(deviceID); + #endif + } + +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioOutput.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioOutput.cpp +index 109d24d..c3cc014 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioOutput.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/audio/AudioOutput.cpp +@@ -25,6 +25,8 @@ + #elif defined(__linux__) + #include "../os/linux/AudioOutputALSA.h" + #include "../os/linux/AudioOutputPulse.h" ++#elif defined(__HAIKU__) ++#include "../os/haiku/AudioOutputHaiku.h" + #else + #error "Unsupported operating system" + #endif +@@ -59,6 +61,9 @@ std::unique_ptr AudioOutput::Create(std::string deviceID, void* pla + LOGW("out: PulseAudio available but not working; trying ALSA"); + } + return std::unique_ptr(new AudioOutputALSA(deviceID)); ++#elif defined(__HAIKU__) ++ LOGW("out: MediaKitAudio enabled"); ++ return std::unique_ptr(new AudioOutputHaiku(deviceID)); + #endif + } + +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/libtgvoip.gyp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/libtgvoip.gyp +index f236987..24f017b 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/libtgvoip.gyp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/libtgvoip.gyp +@@ -100,6 +100,14 @@ + '<(tgvoip_src_loc)/os/linux/PulseAudioLoader.cpp', + '<(tgvoip_src_loc)/os/linux/PulseAudioLoader.h', + ++ # Haiku ++ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.cpp', ++ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.h', ++ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.cpp', ++ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.h', ++ '<(tgvoip_src_loc)/os/haiku/RingBuffer.cpp', ++ '<(tgvoip_src_loc)/os/haiku/RingBuffer.h', ++ + # POSIX + '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.cpp', + '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.h', +@@ -253,6 +261,11 @@ + 'sources/': [['exclude', '<(tgvoip_src_loc)/os/posix/']], + }, + ], ++ [ ++ '"<(OS)" != "haiku"', { ++ 'sources/': [['exclude', '<(tgvoip_src_loc)/os/haiku/']], ++ }, ++ ], + [ + '"<(OS)" != "mac"', { + 'sources/': [['exclude', '<(tgvoip_src_loc)/os/darwin/']], +@@ -378,6 +391,21 @@ + }, + ], + [ ++ '"<(OS)" == "haiku"', { ++ 'defines': [ ++ 'WEBRTC_POSIX', ++ ], ++ 'cflags_cc': [ ++ '-msse2', ++ '-std=gnu++14', ++ ], ++ 'direct_dependent_settings': { ++ 'libraries': [ ++ ++ ], ++ }, ++ }, ++ ], [ + '"<(OS)" == "linux"', { + 'defines': [ + 'WEBRTC_POSIX', +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp new file mode 100644 -index 0000000..1bfbfad +index 0000000..ce54b6e --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.cpp -@@ -0,0 +1,272 @@ ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp +@@ -0,0 +1,198 @@ +// +// libtgvoip is free and unencumbered public domain software. +// For more information, see http://unlicense.org or the UNLICENSE file @@ -22,108 +181,36 @@ index 0000000..1bfbfad +#include +#include "AudioInputHaiku.h" +#include "../../logging.h" -+#include "../../audio/Resampler.h" +#include "../../VoIPController.h" + +#include "RingBuffer.h" + ++#define BUFFER_SIZE 960 ++ +using namespace tgvoip::audio; + -+void RecordData(void* cookie, bigtime_t timestamp, void* data, size_t size, const media_format &format) ++void RecordFile(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); ++ AudioInputHaiku *obj = (AudioInputHaiku*)cookie; ++ if (!obj->IsRecording()) + return; ++ if (format.u.raw_audio.channel_count == 1) { ++ obj->fRingBuffer->Write((unsigned char*)data, size); ++ } else if (format.u.raw_audio.channel_count == 2) { ++ unsigned char *s = (unsigned char*)data; ++ for (int i=0; ifRingBuffer->Write(s, 2); + } -+ -+ 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, ...) ++void NotifyRecordFile(void * cookie, BMediaRecorder::notification code, ...) +{ -+ AudioInputHaiku *audioInput = (AudioInputHaiku*)cookie; + if (code == BMediaRecorder::B_WILL_STOP) { -+ if (audioInput->IsRecording()) { -+ audioInput->Stop(); -+ } + } +} + -+AudioInputHaiku::AudioInputHaiku() ++AudioInputHaiku::AudioInputHaiku(std::string devID) +{ + fRecorder = NULL; + fRingBuffer = NULL; @@ -200,7 +287,7 @@ index 0000000..1bfbfad + } + fRecordFormat.type = B_MEDIA_RAW_AUDIO; + -+ error = fRecorder->SetHooks(RecordData, NotifyRecordData, this); ++ error = fRecorder->SetHooks(RecordFile, NotifyRecordFile, this); + if (error < B_OK) { + failed=true; + return; @@ -235,9 +322,7 @@ index 0000000..1bfbfad +} + +void AudioInputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ -+ tgFrameRate = sampleRate; -+ tgChannelsCount = channels; -+ tgBytesPerSample = bitsPerSample / 8; ++ +} + +bool AudioInputHaiku::IsRecording(){ @@ -282,12 +367,12 @@ index 0000000..1bfbfad + snooze(100); + } +} -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.h b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.h +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h new file mode 100644 -index 0000000..2425666 +index 0000000..80573df --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioInputHaiku.h -@@ -0,0 +1,66 @@ ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h +@@ -0,0 +1,57 @@ +// +// libtgvoip is free and unencumbered public domain software. +// For more information, see http://unlicense.org or the UNLICENSE file @@ -312,29 +397,20 @@ index 0000000..2425666 + +#include "RingBuffer.h" + -+#define BUFFER_SIZE 960 -+ +namespace tgvoip{ +namespace audio{ + +class AudioInputHaiku : public AudioInput{ + +public: -+ AudioInputHaiku(); ++ AudioInputHaiku(std::string devID); + virtual ~AudioInputHaiku(); + virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); + virtual void Start(); + virtual void Stop(); + virtual bool IsRecording(); -+ -+ RingBuffer *fRingBuffer; -+ int16_t workBuffer[BUFFER_SIZE * 16]; -+ int16_t convertBuffer[BUFFER_SIZE * 16]; -+ -+ uint32 tgFrameRate; -+ uint32 tgChannelsCount; -+ uint32 tgBytesPerSample; -+ ++ ++ RingBuffer *fRingBuffer; +private: + void RunThread(void* arg); + @@ -346,20 +422,20 @@ index 0000000..2425666 + media_format fRecordFormat; + media_node fAudioInputNode; + media_node fAudioMixerNode; -+ ++ + Thread* thread; +}; + +} +} + -+#endif //LIBTGVOIP_AUDIOINPUTHAIKU_H -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp ++#endif //LIBTGVOIP_AUDIOINPUTALSA_H +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp new file mode 100644 -index 0000000..533128d +index 0000000..4454323 --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp -@@ -0,0 +1,102 @@ ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp +@@ -0,0 +1,101 @@ +// +// libtgvoip is free and unencumbered public domain software. +// For more information, see http://unlicense.org or the UNLICENSE file @@ -384,7 +460,7 @@ index 0000000..533128d +} + + -+AudioOutputHaiku::AudioOutputHaiku(){ ++AudioOutputHaiku::AudioOutputHaiku(std::string devID){ + soundPlayer = NULL; + isPlaying = false; + isConfigured = false; @@ -406,7 +482,7 @@ index 0000000..533128d + (uint32)channels, + media_raw_audio_format::B_AUDIO_SHORT, + B_MEDIA_LITTLE_ENDIAN, -+ (uint32)BUFFER_SIZE * (bitsPerSample / 8) * channels ++ (uint32)BUFFER_SIZE * 2 * channels + }; + + switch (bitsPerSample) { @@ -430,7 +506,6 @@ index 0000000..533128d + delete soundPlayer; + soundPlayer = NULL; + isPlaying = false; -+ failed = true; + return; + } + @@ -462,11 +537,11 @@ index 0000000..533128d +float AudioOutputHaiku::GetLevel(){ + return 0; +} -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h new file mode 100644 -index 0000000..0ea8230 +index 0000000..6880709 --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h @@ -0,0 +1,36 @@ +// +// libtgvoip is free and unencumbered public domain software. @@ -487,7 +562,7 @@ index 0000000..0ea8230 + +class AudioOutputHaiku : public AudioOutput{ +public: -+ AudioOutputHaiku(); ++ AudioOutputHaiku(std::string devID); + virtual ~AudioOutputHaiku(); + virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); + virtual void Start(); @@ -503,12 +578,12 @@ index 0000000..0ea8230 +} +} + -+#endif //LIBTGVOIP_AUDIOOUTPUTHAIKU_H -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.cpp ++#endif //LIBTGVOIP_AudioOutputHaiku_H +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.cpp new file mode 100644 index 0000000..43236d3 --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.cpp @@ -0,0 +1,130 @@ +#include +#include @@ -640,11 +715,11 @@ index 0000000..43236d3 +{ + return initialized?B_OK:B_ERROR; +} -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.h b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.h +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.h new file mode 100644 index 0000000..4715632 --- /dev/null -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/RingBuffer.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/RingBuffer.h @@ -0,0 +1,31 @@ +#ifndef __RING_BUFFER_H__ +#define __RING_BUFFER_H__ @@ -677,163 +752,38 @@ index 0000000..4715632 +}; + +#endif --- -2.16.4 - - -From 753b20ad62db41d0041b352dac9c9a45ecd3009b Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 30 Aug 2018 20:15:02 +1000 -Subject: Fix Haiku build - - -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/VoIPController.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/VoIPController.cpp -index b82899e..700b0cd 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/VoIPController.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/VoIPController.cpp -@@ -8,6 +8,9 @@ - #include - #include - #endif -+#ifdef __HAIKU__ -+#include -+#endif - #include - #include - #include -@@ -2052,6 +2055,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/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioIO.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioIO.cpp -index 06beea7..bae4d64 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioIO.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioIO.cpp -@@ -37,6 +37,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 -@@ -62,6 +65,8 @@ shared_ptr AudioIO::Create(){ - return std::make_shared>(inputDevice, outputDevice); - #endif - return std::make_shared>(inputDevice, outputDevice); -+#elif defined(__HAIKU__) -+ return std::make_shared>(); - #elif defined(__linux__) - #ifndef WITHOUT_ALSA - #ifndef WITHOUT_PULSE -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioInput.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioInput.cpp -index 3e3ccb9..a3e4c06 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioInput.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioInput.cpp -@@ -31,6 +31,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/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioOutput.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioOutput.cpp -index 938c1aa..36900a8 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioOutput.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/audio/AudioOutput.cpp -@@ -35,6 +35,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/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/libtgvoip.gyp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/libtgvoip.gyp -index 0cf04ea..4f21d1e 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/libtgvoip.gyp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/libtgvoip.gyp -@@ -104,6 +104,14 @@ - '<(tgvoip_src_loc)/os/linux/AudioPulse.cpp', - '<(tgvoip_src_loc)/os/linux/AudioPulse.h', +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/posix/NetworkSocketPosix.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/posix/NetworkSocketPosix.cpp +index 05ddbb9..fcf7580 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/posix/NetworkSocketPosix.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/posix/NetworkSocketPosix.cpp +@@ -47,6 +47,7 @@ NetworkSocketPosix::~NetworkSocketPosix(){ + } -+ # Haiku -+ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.cpp', -+ '<(tgvoip_src_loc)/os/haiku/AudioInputHaiku.h', -+ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.cpp', -+ '<(tgvoip_src_loc)/os/haiku/AudioOutputHaiku.h', -+ '<(tgvoip_src_loc)/os/haiku/RingBuffer.cpp', -+ '<(tgvoip_src_loc)/os/haiku/RingBuffer.h', -+ - # POSIX - '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.cpp', - '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.h', -@@ -257,6 +265,11 @@ - 'sources/': [['exclude', '<(tgvoip_src_loc)/os/posix/']], - }, - ], -+ [ -+ '"<(OS)" != "haiku"', { -+ 'sources/': [['exclude', '<(tgvoip_src_loc)/os/haiku/']], -+ }, -+ ], - [ - '"<(OS)" != "mac"', { - 'sources/': [['exclude', '<(tgvoip_src_loc)/os/darwin/']], -@@ -382,6 +395,21 @@ - }, - ], - [ -+ '"<(OS)" == "haiku"', { -+ 'defines': [ -+ 'WEBRTC_POSIX', -+ ], -+ 'cflags_cc': [ -+ '-msse2', -+ '-std=gnu++14', -+ ], -+ 'direct_dependent_settings': { -+ 'libraries': [ -+ -+ ], -+ }, -+ }, -+ ], [ - '"<(OS)" == "linux"', { - 'defines': [ - 'WEBRTC_POSIX', -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/posix/NetworkSocketPosix.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/posix/NetworkSocketPosix.cpp -index ef8d2cb..da39a17 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/posix/NetworkSocketPosix.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/posix/NetworkSocketPosix.cpp -@@ -202,12 +202,13 @@ void NetworkSocketPosix::Open(){ - } - int flag=0; - int res=setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag)); + void NetworkSocketPosix::SetMaxPriority(){ +#ifndef __HAIKU__ + #ifdef __APPLE__ + int prio=NET_SERVICE_TYPE_VO; + int res=setsockopt(fd, SOL_SOCKET, SO_NET_SERVICE_TYPE, &prio, sizeof(prio)); +@@ -65,6 +66,7 @@ void NetworkSocketPosix::SetMaxPriority(){ + LOGE("error setting ip tos: %d / %s", errno, strerror(errno)); + } + #endif ++#endif //__HAIKU__ + } + + void NetworkSocketPosix::Send(NetworkPacket *packet){ +@@ -196,8 +198,10 @@ void NetworkSocketPosix::Open(){ + int res=setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag)); if(res<0){ LOGE("error enabling dual stack socket: %d / %s", errno, strerror(errno)); ++#ifndef __HAIKU__ failed=true; return; - } -- +#endif - SetMaxPriority(); + } - int tries=0; -@@ -353,6 +354,8 @@ std::string NetworkSocketPosix::GetLocalInterfaceInfo(IPv4Address *v4addr, IPv6A + SetMaxPriority(); +@@ -345,6 +349,8 @@ std::string NetworkSocketPosix::GetLocalInterfaceInfo(IPv4Address *v4addr, IPv6A if(didAttach){ sharedJVM->DetachCurrentThread(); } @@ -842,10 +792,10 @@ index ef8d2cb..da39a17 100644 #else struct ifaddrs* interfaces; if(!getifaddrs(&interfaces)){ -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/threading.h b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/threading.h -index 0bcf7c3..af86ef2 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/threading.h -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/threading.h +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/threading.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/threading.h +index 0b4933c..87ea3b7 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/threading.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/threading.h @@ -33,7 +33,7 @@ namespace tgvoip{ }; } @@ -855,17 +805,15 @@ index 0bcf7c3..af86ef2 100644 #include #include -@@ -115,6 +115,7 @@ namespace tgvoip{ +@@ -94,11 +94,13 @@ namespace tgvoip{ static void* ActualEntryPoint(void* arg){ Thread* self=reinterpret_cast(arg); if(self->name){ +#ifndef __HAIKU__ - #if !defined(__APPLE__) && !defined(__gnu_hurd__) + #ifndef __APPLE__ pthread_setname_np(self->thread, self->name); - #elif !defined(__gnu_hurd__) -@@ -123,6 +124,7 @@ namespace tgvoip{ - DarwinSpecific::SetCurrentThreadPriority(DarwinSpecific::THREAD_PRIO_USER_INTERACTIVE); - } + #else + pthread_setname_np(self->name); #endif +#endif //__HAKIU__ } @@ -875,72 +823,230 @@ index 0bcf7c3..af86ef2 100644 2.16.4 -From 1bf1510ada4edb23b04da953284b5d1decca9bd0 Mon Sep 17 00:00:00 2001 +From 4dbfc02248dde7ae10d29d81f25575942f204c89 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 30 Aug 2018 23:52:44 +1000 -Subject: Remove GetLevel function +Date: Sun, 10 Jun 2018 22:01:28 +1000 +Subject: Add mix and resample for haiku audio input -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp -index 533128d..3dc052c 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.cpp -@@ -96,7 +96,3 @@ void AudioOutputHaiku::Stop(){ - bool AudioOutputHaiku::IsPlaying(){ - return isPlaying; - } +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp +index ce54b6e..d7cc39a 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.cpp +@@ -10,32 +10,104 @@ + #include + #include "AudioInputHaiku.h" + #include "../../logging.h" ++#include "../../audio/Resampler.h" + #include "../../VoIPController.h" + + #include "RingBuffer.h" + +-#define BUFFER_SIZE 960 - --float AudioOutputHaiku::GetLevel(){ -- return 0; --} -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h -index 0ea8230..91f2521 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/os/haiku/AudioOutputHaiku.h -@@ -23,7 +23,6 @@ public: + using namespace tgvoip::audio; + +-void RecordFile(void* cookie, bigtime_t timestamp, void* data, size_t size, const media_format &format) ++void RecordData(void* cookie, bigtime_t timestamp, void* data, size_t size, const media_format &format) + { +- AudioInputHaiku *obj = (AudioInputHaiku*)cookie; +- if (!obj->IsRecording()) ++ 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; +- if (format.u.raw_audio.channel_count == 1) { +- obj->fRingBuffer->Write((unsigned char*)data, size); +- } else if (format.u.raw_audio.channel_count == 2) { +- unsigned char *s = (unsigned char*)data; +- for (int i=0; ifRingBuffer->Write(s, 2); + } +- ++ ++ 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 NotifyRecordFile(void * cookie, BMediaRecorder::notification code, ...) ++void NotifyRecordData(void * cookie, BMediaRecorder::notification code, ...) + { ++ AudioInputHaiku *audioInput = (AudioInputHaiku*)cookie; + if (code == BMediaRecorder::B_WILL_STOP) { ++ if (audioInput->IsRecording()) { ++ audioInput->Stop(); ++ } + } + } + +@@ -116,7 +188,7 @@ AudioInputHaiku::AudioInputHaiku(std::string devID) + } + fRecordFormat.type = B_MEDIA_RAW_AUDIO; + +- error = fRecorder->SetHooks(RecordFile, NotifyRecordFile, this); ++ error = fRecorder->SetHooks(RecordData, NotifyRecordData, this); + if (error < B_OK) { + failed=true; + return; +@@ -151,7 +223,9 @@ AudioInputHaiku::~AudioInputHaiku(){ + } + + void AudioInputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){ +- ++ tgFrameRate = sampleRate; ++ tgChannelsCount = channels; ++ tgBytesPerSample = bitsPerSample / 8; + } + + bool AudioInputHaiku::IsRecording(){ +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h +index 80573df..746d7df 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioInputHaiku.h +@@ -22,6 +22,8 @@ + + #include "RingBuffer.h" + ++#define BUFFER_SIZE 960 ++ + namespace tgvoip{ + namespace audio{ + +@@ -34,8 +36,15 @@ public: virtual void Start(); virtual void Stop(); - virtual bool IsPlaying() override; -- virtual float GetLevel() override; + virtual bool IsRecording(); +- +- RingBuffer *fRingBuffer; ++ ++ RingBuffer *fRingBuffer; ++ int16_t workBuffer[BUFFER_SIZE * 16]; ++ int16_t convertBuffer[BUFFER_SIZE * 16]; ++ ++ uint32 tgFrameRate; ++ uint32 tgChannelsCount; ++ uint32 tgBytesPerSample; ++ private: - bool isPlaying; - bool isConfigured; --- -2.16.4 - - -From 50540bcbe0cd11cf96cf6b095d99e2ed5ab36d30 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 30 Aug 2018 23:53:16 +1000 -Subject: Fix opus includes - - -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusDecoder.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusDecoder.cpp -index 87a48eb..545113a 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusDecoder.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusDecoder.cpp -@@ -10,7 +10,7 @@ - #include - #include - #include --#ifdef HAVE_CONFIG_H -+#if defined(HAVE_CONFIG_H) || defined(__HAIKU__) - #include - #else - #include "opus.h" -diff --git a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusEncoder.cpp b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusEncoder.cpp -index e30f814..c31aee2 100644 ---- a/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusEncoder.cpp -+++ b/libtgvoip-bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34/OpusEncoder.cpp -@@ -8,7 +8,7 @@ - #include - #include "logging.h" - #include "VoIPServerConfig.h" --#ifdef HAVE_CONFIG_H -+#if defined(HAVE_CONFIG_H) || defined(__HAIKU__) - #include - #else - #include "opus.h" + void RunThread(void* arg); + +@@ -47,11 +56,11 @@ private: + media_format fRecordFormat; + media_node fAudioInputNode; + media_node fAudioMixerNode; +- ++ + Thread* thread; + }; + + } + } + +-#endif //LIBTGVOIP_AUDIOINPUTALSA_H ++#endif //LIBTGVOIP_AUDIOINPUTHAIKU_H +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp +index 4454323..11650da 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.cpp +@@ -44,7 +44,7 @@ void AudioOutputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, ui + (uint32)channels, + media_raw_audio_format::B_AUDIO_SHORT, + B_MEDIA_LITTLE_ENDIAN, +- (uint32)BUFFER_SIZE * 2 * channels ++ (uint32)BUFFER_SIZE * (bitsPerSample / 8) * channels + }; + + switch (bitsPerSample) { +@@ -68,6 +68,7 @@ void AudioOutputHaiku::Configure(uint32_t sampleRate, uint32_t bitsPerSample, ui + delete soundPlayer; + soundPlayer = NULL; + isPlaying = false; ++ failed = true; + return; + } + +diff --git a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h +index 6880709..6a463fa 100644 +--- a/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h ++++ b/libtgvoip-697eea96aa90205db4fc368df4127eef56b2a5c6/os/haiku/AudioOutputHaiku.h +@@ -33,4 +33,4 @@ private: + } + } + +-#endif //LIBTGVOIP_AudioOutputHaiku_H ++#endif //LIBTGVOIP_AUDIOOUTPUTHAIKU_H -- 2.16.4 diff --git a/net-im/telegram-desktop/patches/telegram_desktop-1.3.14-systemqt.patch b/net-im/telegram-desktop/patches/telegram_desktop-1.3.16-systemqt.patch similarity index 90% rename from net-im/telegram-desktop/patches/telegram_desktop-1.3.14-systemqt.patch rename to net-im/telegram-desktop/patches/telegram_desktop-1.3.16-systemqt.patch index ecd441df2..237d55d8e 100644 --- a/net-im/telegram-desktop/patches/telegram_desktop-1.3.14-systemqt.patch +++ b/net-im/telegram-desktop/patches/telegram_desktop-1.3.16-systemqt.patch @@ -1,5 +1,10 @@ +From: Giovanni Santini +Date: Sun, 02 Sep 2018 11:28:00 +0200 +Subject: [PATCH] Linux "clean" build +This patch is a refreshed version of the patch usually applied +during ArchLinux builds of Telegram Desktop. diff --git a/Telegram/Resources/qrc/telegram_linux.qrc b/Telegram/Resources/qrc/telegram_linux.qrc -index 0554fa1..3ea0274 100644 +index 0554fa179..3ea027406 100644 --- a/Telegram/Resources/qrc/telegram_linux.qrc +++ b/Telegram/Resources/qrc/telegram_linux.qrc @@ -1,5 +1,4 @@ @@ -9,10 +14,10 @@ index 0554fa1..3ea0274 100644 diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp -index 2078858..1a70da9 100644 +index d4bdadc17..8a420c74b 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp -@@ -37,9 +37,10 @@ void Launcher::init() { +@@ -39,9 +39,10 @@ void Launcher::init() { QCoreApplication::setApplicationName(qsl("TelegramDesktop")); @@ -25,7 +30,7 @@ index 2078858..1a70da9 100644 initHook(); } -@@ -57,6 +58,13 @@ int Launcher::exec() { +@@ -59,6 +60,13 @@ int Launcher::exec() { Logs::start(this); // must be started before Platform is started Platform::start(); // must be started before QApplication is created @@ -40,7 +45,7 @@ index 2078858..1a70da9 100644 DEBUG_LOG(("Telegram finished, result: %1").arg(result)); diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.h b/Telegram/SourceFiles/platform/linux/linux_libs.h -index 6f93d69..df185d5 100644 +index 6f93d69cd..df185d5a2 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libs.h +++ b/Telegram/SourceFiles/platform/linux/linux_libs.h @@ -17,7 +17,7 @@ extern "C" { @@ -54,7 +59,7 @@ index 6f93d69..df185d5 100644 diff --git a/Telegram/SourceFiles/qt_functions.cpp b/Telegram/SourceFiles/qt_functions.cpp new file mode 100644 -index 00000000..4a722b8d +index 000000000..4a722b8d7 --- /dev/null +++ b/Telegram/SourceFiles/qt_functions.cpp @@ -0,0 +1,94 @@ @@ -153,7 +158,7 @@ index 00000000..4a722b8d + flags |= QTextItem::StrikeOut; +} diff --git a/Telegram/SourceFiles/qt_static_plugins.cpp b/Telegram/SourceFiles/qt_static_plugins.cpp -index e29f348..122ff0f 100644 +index e29f348c8..122ff0f5d 100644 --- a/Telegram/SourceFiles/qt_static_plugins.cpp +++ b/Telegram/SourceFiles/qt_static_plugins.cpp @@ -15,13 +15,4 @@ Q_IMPORT_PLUGIN(QWebpPlugin) @@ -171,7 +176,7 @@ index e29f348..122ff0f 100644 -Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) #endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp -index 944f584..887c198 100644 +index 944f58479..887c1982f 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -1750,11 +1750,11 @@ private: @@ -190,7 +195,7 @@ index 944f584..887c198 100644 auto blockIndex = _lineStartBlock; auto currentBlock = _t->_blocks[blockIndex].get(); diff --git a/Telegram/SourceFiles/ui/text/text_block.cpp b/Telegram/SourceFiles/ui/text/text_block.cpp -index 2959cec..04ad006 100644 +index 2959cec77..04ad00645 100644 --- a/Telegram/SourceFiles/ui/text/text_block.cpp +++ b/Telegram/SourceFiles/ui/text/text_block.cpp @@ -332,6 +332,9 @@ TextBlock::TextBlock(const style::font &font, const QString &str, QFixed minResi @@ -204,10 +209,10 @@ index 2959cec..04ad006 100644 CrashReports::ClearAnnotationRef("CrashString"); } diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp -index 0f610cb..b005589 100644 +index 71f318229..461f52278 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp -@@ -227,9 +227,9 @@ void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton +@@ -233,9 +233,9 @@ void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton , button , QGuiApplication::mouseButtons() | button , QGuiApplication::keyboardModifiers() @@ -220,7 +225,7 @@ index 0f610cb..b005589 100644 ev.setTimestamp(getms()); QGuiApplication::sendEvent(windowHandle, &ev); diff --git a/Telegram/gyp/PrecompiledHeader.cmake b/Telegram/gyp/PrecompiledHeader.cmake -index a0e1e04..bd9bce0 100644 +index a0e1e0489..223113081 100644 --- a/Telegram/gyp/PrecompiledHeader.cmake +++ b/Telegram/gyp/PrecompiledHeader.cmake @@ -114,7 +114,7 @@ function(add_precompiled_header _target _input) @@ -228,7 +233,7 @@ index a0e1e04..bd9bce0 100644 add_custom_command( OUTPUT "${_output_c}" - COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} -x c-header -o "${_output_c}" -c "${_pchfile}" -+ COMMAND "${CMAKE_C_COMPILER}" "$(C_DEFINES)" "$(C_INCLUDES)" "$(C_FLAGS)" -x c-header -o "${_output_c}" -c "${_pchfile}" ++ COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} "$(C_DEFINES)" "$(C_INCLUDES)" "$(C_FLAGS)" -x c-header -o "${_output_c}" -c "${_pchfile}" DEPENDS "${_pchfile}" "${_pch_c_flags_file}" IMPLICIT_DEPENDS C "${_pch_header}" COMMENT "Precompiling ${_name} for ${_target} (C)") @@ -237,48 +242,32 @@ index a0e1e04..bd9bce0 100644 add_custom_command( OUTPUT "${_output_cxx}" - COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output_cxx}" -c "${_pchfile}" -+ COMMAND "${CMAKE_CXX_COMPILER}" "$(CXX_DEFINES)" "$(CXX_INCLUDES)" "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}" ++ COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} "$(CXX_DEFINES)" "$(CXX_INCLUDES)" "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}" DEPENDS "${_pchfile}" "${_pch_cpp_flags_file}" IMPLICIT_DEPENDS CXX "${_pch_header}" COMMENT "Precompiling header ${_name} for ${_target} (C++)") diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp -index 65917d9..d91e55c 100644 +index 1cab5ae29..2c6ef58cb 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp -@@ -74,14 +74,12 @@ +@@ -75,7 +75,6 @@ 'codegen.gyp:codegen_numbers', 'codegen.gyp:codegen_style', 'tests/tests.gyp:tests', - 'utils.gyp:Updater', '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip', 'crl.gyp:crl', - 'lib_export.gyp:lib_export', + 'lib_base.gyp:lib_base', +@@ -84,7 +83,6 @@ ], 'defines': [ - 'AL_LIBTYPE_STATIC', 'AL_ALEXT_PROTOTYPES', 'TGVOIP_USE_CXX11_LIB', - ' /dev/null --libs <@(pkgconfig_libs))', ], 'cflags_cc': [ -@@ -87,16 +79,14 @@ - }, - }, - 'conditions': [ -- [ '" -Date: Sun, 10 Jun 2018 10:41:50 +1000 -Subject: Add haiku support +Date: Sun, 23 Sep 2018 23:33:52 +1000 +Subject: Add Haiku support diff --git a/Telegram/Resources/etc/qt_haiku.conf b/Telegram/Resources/etc/qt_haiku.conf @@ -12,18 +12,6 @@ index 0000000..6d80862 @@ -0,0 +1,2 @@ +[Paths] +Libraries=:/gui/art -diff --git a/Telegram/Resources/qrc/telegram_emoji.qrc b/Telegram/Resources/qrc/telegram_emoji.qrc -index bb9ce0a..47a0c05 100644 ---- a/Telegram/Resources/qrc/telegram_emoji.qrc -+++ b/Telegram/Resources/qrc/telegram_emoji.qrc -@@ -2,7 +2,5 @@ - - ../art/emoji.webp - ../art/emoji_125x.webp -- ../art/emoji_150x.webp -- ../art/emoji_200x.webp - - diff --git a/Telegram/Resources/qrc/telegram_emoji2.qrc b/Telegram/Resources/qrc/telegram_emoji2.qrc new file mode 100644 index 0000000..e1ddb8d @@ -47,204 +35,12 @@ index 0000000..33115f9 + ../etc/qt_haiku.conf + + -diff --git a/Telegram/SourceFiles/base/algorithm_tests.cpp b/Telegram/SourceFiles/base/algorithm_tests.cpp -index 9e3df82..3092663 100644 ---- a/Telegram/SourceFiles/base/algorithm_tests.cpp -+++ b/Telegram/SourceFiles/base/algorithm_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include "base/index_based_iterator.h" - -@@ -47,4 +51,4 @@ TEST_CASE("index_based_iterator tests", "[base::algorithm]") { - auto expected = std::vector { 5 }; - REQUIRE(v == expected); - } --} -\ No newline at end of file -+} -diff --git a/Telegram/SourceFiles/base/build_config.h b/Telegram/SourceFiles/base/build_config.h -index 4640bce..20c3088 100644 ---- a/Telegram/SourceFiles/base/build_config.h -+++ b/Telegram/SourceFiles/base/build_config.h -@@ -17,13 +17,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - #define OS_LINUX 1 - #elif defined(_WIN32) // __APPLE__ || __linux__ - #define OS_WIN 1 -+#elif defined(__HAIKU__) -+#define OS_HAIKU 1 - #else // __APPLE__ || __linux__ || _WIN32 - #error Please add support for your platform in base/build_config.h - #endif // else for __APPLE__ || __linux__ || _WIN32 - - // For access to standard POSIXish features, use OS_POSIX instead of a - // more specific macro. --#if defined(OS_MAC) || defined(OS_LINUX) -+#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_HAIKU) - #define OS_POSIX 1 - #endif // OS_MAC || OS_LINUX - -diff --git a/Telegram/SourceFiles/base/flags_tests.cpp b/Telegram/SourceFiles/base/flags_tests.cpp -index 786dc49..b1ed887 100644 ---- a/Telegram/SourceFiles/base/flags_tests.cpp -+++ b/Telegram/SourceFiles/base/flags_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include "base/flags.h" - -diff --git a/Telegram/SourceFiles/base/flat_map_tests.cpp b/Telegram/SourceFiles/base/flat_map_tests.cpp -index 8f1ddb1..e4f0a4e 100644 ---- a/Telegram/SourceFiles/base/flat_map_tests.cpp -+++ b/Telegram/SourceFiles/base/flat_map_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include "base/flat_map.h" - #include -diff --git a/Telegram/SourceFiles/base/flat_set_tests.cpp b/Telegram/SourceFiles/base/flat_set_tests.cpp -index a73f1d2..77d98a6 100644 ---- a/Telegram/SourceFiles/base/flat_set_tests.cpp -+++ b/Telegram/SourceFiles/base/flat_set_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include "base/flat_set.h" - -diff --git a/Telegram/SourceFiles/base/tests_main.cpp b/Telegram/SourceFiles/base/tests_main.cpp -index dfc7fa0..38c6308 100644 ---- a/Telegram/SourceFiles/base/tests_main.cpp -+++ b/Telegram/SourceFiles/base/tests_main.cpp -@@ -6,8 +6,12 @@ For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ - #define CATCH_CONFIG_RUNNER -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" - #include "reporters/catch_reporter_compact.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - #include - - namespace base { -diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp -index 872cebb..a6c90e5 100644 ---- a/Telegram/SourceFiles/core/launcher.cpp -+++ b/Telegram/SourceFiles/core/launcher.cpp -@@ -61,6 +61,10 @@ int Launcher::exec() { - - // I don't know why path is not in QT_PLUGIN_PATH by default - QCoreApplication::addLibraryPath("/usr/lib/qt/plugins"); -+#if defined(Q_OS_HAIKU) -+ QCoreApplication::addLibraryPath("/boot/system/add-ons/Qt5"); -+ QCoreApplication::addLibraryPath("/boot/system/add-ons/x86/Qt5"); -+#endif - // without this Telegram doesn't start on Ubuntu 17.04 due GTK errors - setenv("QT_STYLE_OVERRIDE", "qwerty", false); - // Telegram doesn't start when extraordinary theme is set, see launchpad.net/bugs/1680943 -@@ -141,6 +145,9 @@ void Launcher::prepareSettings() { - case dbipMacOld: - gPlatformString = qsl("MacOSold"); - break; -+ case dbipHaiku: -+ gPlatformString = qsl("HaikuDepot"); -+ break; - case dbipLinux64: - gPlatformString = qsl("Linux64bit"); - break; -diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp -index 6b4a324..cc19eb8 100644 ---- a/Telegram/SourceFiles/core/update_checker.cpp -+++ b/Telegram/SourceFiles/core/update_checker.cpp -@@ -633,6 +633,7 @@ bool ParseCommonMap( - case dbipWindows: return "win"; - case dbipMac: return "mac"; - case dbipMacOld: return "mac32"; -+ case dbipHaiku: return "haiku"; - case dbipLinux64: return "linux"; - case dbipLinux32: return "linux32"; - } -diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h -index bdc258e..493452b 100644 ---- a/Telegram/SourceFiles/core/utils.h -+++ b/Telegram/SourceFiles/core/utils.h -@@ -432,6 +432,7 @@ enum DBIPlatform { - dbipLinux64 = 2, - dbipLinux32 = 3, - dbipMacOld = 4, -+ dbipHaiku = 5, - }; - - enum DBIPeerReportSpamStatus { -diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp -index 74edb3e..bcf4875 100644 ---- a/Telegram/SourceFiles/logs.cpp -+++ b/Telegram/SourceFiles/logs.cpp -@@ -333,7 +333,7 @@ void start(not_null launcher) { - if (cBetaVersion()) { - SetDebugEnabled(true); - workingDirChosen = true; --#if defined Q_OS_MAC || defined Q_OS_LINUX -+#if defined Q_OS_MAC || defined Q_OS_LINUX || defined Q_OS_HAIKU - } else { - #ifdef _DEBUG - cForceWorkingDir(cExeDir()); -diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp -index d7b2e48..746af58 100644 ---- a/Telegram/SourceFiles/media/media_audio.cpp -+++ b/Telegram/SourceFiles/media/media_audio.cpp -@@ -86,6 +86,7 @@ void EnumeratePlaybackDevices() { - void EnumerateCaptureDevices() { - auto deviceNames = QStringList(); - auto devices = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER); -+#ifndef __HAIKU__ - Assert(devices != nullptr); - while (*devices != 0) { - auto deviceName8Bit = QByteArray(devices); -@@ -94,7 +95,7 @@ void EnumerateCaptureDevices() { - devices += deviceName8Bit.size() + 1; - } - LOG(("Audio Capture Devices: %1").arg(deviceNames.join(';'))); -- -+#endif - if (auto device = alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) { - LOG(("Audio Capture Default Device: %1").arg(QString::fromLocal8Bit(device))); - } else { 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..5777c2c +index 0000000..58bc1c3 --- /dev/null +++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp -@@ -0,0 +1,137 @@ +@@ -0,0 +1,138 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org @@ -350,8 +146,9 @@ index 0000000..5777c2c + +} // namespace + -+bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) { -+ return ::FileDialog::internal::GetDefault(files, remoteContent, caption, filter, type, startFile); ++bool Get(QPointer parent, QStringList &files, QByteArray &remoteContent, const QString &caption, \ ++ const QString &filter, Type type, QString startFile) { ++ return ::FileDialog::internal::GetDefault(parent, files, remoteContent, caption, filter, type, startFile); +} + +namespace internal { @@ -581,7 +378,7 @@ index 0000000..e76c8fe +} // 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..b861841 +index 0000000..a7bea21 --- /dev/null +++ b/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp @@ -0,0 +1,59 @@ @@ -630,7 +427,7 @@ index 0000000..b861841 +} + +QString SystemVersion() { -+ return "Haiku" ++ return "Haiku"; +} + +} // namespace @@ -900,12 +697,77 @@ index 0000000..56cc497 +}; + +} // 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..bf9c7be +--- /dev/null ++++ b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp +@@ -0,0 +1,40 @@ ++#include ++ ++#include ++#include ++ ++#define APPSIGNATURE "application/x-vnd.tg-notify-gate" ++ ++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) { ++ FILE *out=fopen("/tmp/tg_notify","wt"); ++ fprintf(out,"%s\n", argv[1]); ++ fclose(out); ++ } ++} ++ ++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..b3d186a +index 0000000..8a75ed7 --- /dev/null +++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp -@@ -0,0 +1,82 @@ +@@ -0,0 +1,214 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org @@ -926,74 +788,206 @@ index 0000000..b3d186a +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org +*/ ++ ++#include ++#include ++#include ++#include ++ +#include "platform/haiku/notifications_manager_haiku.h" + +#include "window/notifications_utilities.h" +#include "lang/lang_keys.h" +#include "history/history.h" + ++#include ++#include ++#include ++#include ++#include ++ +namespace Platform { +namespace Notifications { +namespace { + -+bool LibNotifyLoaded() { -+ return false; -+} -+ -+QString escapeHtml(const QString &text) { -+ auto result = QString(); -+ auto copyFrom = 0, textSize = text.size(); -+ auto data = text.constData(); -+ for (auto i = 0; i != textSize; ++i) { -+ auto ch = data[i]; -+ if (ch == '<' || ch == '>' || ch == '&') { -+ if (!copyFrom) { -+ result.reserve(textSize * 5); -+ } -+ if (i > copyFrom) { -+ result.append(data + copyFrom, i - copyFrom); -+ } -+ switch (ch.unicode()) { -+ case '<': result.append(qstr("<")); break; -+ case '>': result.append(qstr(">")); break; -+ case '&': result.append(qstr("&")); break; -+ } -+ copyFrom = i + 1; -+ } -+ } -+ if (copyFrom > 0) { -+ result.append(data + copyFrom, textSize - copyFrom); -+ return result; -+ } -+ return text; -+} -+ -+ -+ +} // namespace + +bool Supported() { -+ return false; ++ return true; +} + +std::unique_ptr Create(Window::Notifications::System *system) { ++ if (Global::NativeNotifications() && Supported()) { ++ auto result = std::make_unique(system); ++ if (result->init()) { ++ return std::move(result); ++ } ++ } + return nullptr; +} + +void Finish() { -+ +} + ++NotifyReader::NotifyReader() ++{ ++ unlink(NOTIFY_FIFO_NAME); ++ mkfifo(NOTIFY_FIFO_NAME, 0666); ++} + ++NotifyReader::~NotifyReader() ++{ ++ unlink(NOTIFY_FIFO_NAME); ++} ++ ++void NotifyReader::run() ++{ ++ char line[256]; ++ size_t n; ++ ++ for(;;) { ++ FILE *in=fopen(NOTIFY_FIFO_NAME, "rt"); ++ fgets(line, sizeof line, in); ++ if (line[strlen(line)-1] == '\n') { ++ uint64 peerid = 0; ++ int32 msgid = 0; ++ QString paramsString = QString(line); ++ QStringList paramsList = paramsString.split(' '); ++ if (paramsList.count() == 2) { ++ bool peerStatus, msgStatus; ++ peerid = paramsList[0].toULongLong(&peerStatus, 16); ++ msgid = paramsList[1].toInt(&msgStatus, 16); ++ if (peerStatus & msgStatus) ++ notificationActivated(peerid, msgid); ++ } ++ } ++ fclose(in); ++ } ++} ++ ++Manager::Private::Private(Manager *instance, Type type) ++: _guarded(std::make_shared(instance)) ++, _cachedUserpics(type) { ++ _weak = _guarded; ++} ++ ++bool Manager::Private::init() { ++ pipeReaderThread = new QThread; ++ pipeReader = new NotifyReader(); ++ pipeReader->moveToThread(pipeReaderThread); ++ connect(pipeReaderThread, SIGNAL(started()), pipeReader, SLOT(run())); ++ qRegisterMetaType("PeerId"); ++ qRegisterMetaType("MsgId"); ++ connect(pipeReader, SIGNAL(notificationActivated(PeerId, MsgId)), \ ++ this, SLOT(notificationActivatedSlot(PeerId, MsgId))); ++ pipeReaderThread->start(); ++ return true; ++} ++ ++Manager::Private::~Private() { ++ clearAll(); ++} ++ ++void Manager::Private::clearAll() { ++} ++ ++void Manager::Private::clearFromHistory(History *history) { ++} ++ ++void Manager::Private::beforeNotificationActivated(PeerId peerId, MsgId msgId) { ++} ++ ++void Manager::Private::afterNotificationActivated(PeerId peerId, MsgId msgId) { ++} ++ ++void Manager::Private::clearNotification(PeerId peerId, MsgId msgId) { ++} ++ ++bool Manager::Private::showNotification(PeerData *peer, MsgId msgId, const QString &title, \ ++ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { ++ auto titleText = title; ++ auto subtitleText = subtitle; ++ auto msgText = msg; ++ ++ StorageKey key; ++ if (hideNameAndPhoto) { ++ key = StorageKey(0, 0); ++ } else { ++ key = peer->userpicUniqueKey(); ++ } ++ ++ auto userpicPath = _cachedUserpics.get(key, peer); ++ ++ QString program = "/bin/notify"; ++ QStringList arguments; ++ arguments << "--icon" << userpicPath; ++ arguments << "--group" << "Telegram"; ++ arguments << "--title" << titleText; ++ arguments << "--onClickFile" << NOTIFY_GATE_NAME; ++ arguments << "--onClickArgv" << QString("0x%1 0x%2").arg(peer->id, 0, 16).arg(msgId, 0, 16); ++ arguments << msgText; ++ ++ QProcess *notifyProcess = new QProcess(); ++ notifyProcess->start(program, arguments); ++ ++ return true; ++} ++ ++void Manager::Private::notificationActivatedSlot(PeerId _peerId, MsgId _msgId) ++{ ++ qDebug() << _peerId << _msgId; ++ performOnMainQueue([peerId = _peerId, msgId = _msgId](Manager *manager) { ++ manager->notificationActivated(peerId, msgId); ++ }); ++} ++ ++Manager::Manager(Window::Notifications::System *system) : NativeManager(system) ++, _private(std::make_unique(this, Private::Type::Rounded)) { ++} ++ ++bool Manager::init() { ++ return _private->init(); ++} ++ ++void Manager::clearNotification(PeerId peerId, MsgId msgId) { ++ _private->clearNotification(peerId, msgId); ++} ++ ++Manager::~Manager() = default; ++ ++void Manager::doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, \ ++ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { ++ _private->showNotification(peer, msgId, title, subtitle, msg, hideNameAndPhoto, hideReplyButton); ++} ++ ++void Manager::doClearAllFast() { ++ _private->clearAll(); ++} ++ ++void Manager::doClearFromHistory(History *history) { ++ _private->clearFromHistory(history); ++} ++ ++void Manager::onBeforeNotificationActivated(PeerId peerId, MsgId msgId) { ++ _private->beforeNotificationActivated(peerId, msgId); ++} ++ ++void Manager::onAfterNotificationActivated(PeerId peerId, MsgId msgId) { ++ _private->afterNotificationActivated(peerId, msgId); ++} ++ ++bool Manager::hasActionsSupport() const { ++ return _private->hasActionsSupport(); ++} + +} // namespace Notifications +} // namespace Platform diff --git a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h new file mode 100644 -index 0000000..d70bcff +index 0000000..53491b6 --- /dev/null +++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h -@@ -0,0 +1,63 @@ +@@ -0,0 +1,126 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org @@ -1017,6 +1011,14 @@ index 0000000..d70bcff +#pragma once + +#include "platform/platform_notifications_manager.h" ++#include "window/notifications_utilities.h" ++ ++#include ++#include ++#include ++ ++#define NOTIFY_FIFO_NAME "/tmp/tg_notify" ++#define NOTIFY_GATE_NAME "/bin/tg-notify-gate" + +namespace Platform { +namespace Notifications { @@ -1034,35 +1036,90 @@ index 0000000..d70bcff + +void Finish(); + ++class NotifyReader:public QObject { ++ Q_OBJECT ++public: ++ NotifyReader(); ++ ~NotifyReader(); ++public slots: ++ void run(); ++signals: ++ void notificationActivated(PeerId peerId, MsgId msgId); ++private: ++ int pipeFD; ++}; ++ ++ +class Manager : public Window::Notifications::NativeManager { +public: + Manager(Window::Notifications::System *system); + ++ bool init(); ++ + void clearNotification(PeerId peerId, MsgId msgId); -+ bool hasPoorSupport() const; -+ bool hasActionsSupport() const; + + ~Manager(); + +protected: -+ void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; ++ void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, \ ++ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; + void doClearAllFast() override; + void doClearFromHistory(History *history) override; ++ void onBeforeNotificationActivated(PeerId peerId, MsgId msgId) override; ++ void onAfterNotificationActivated(PeerId peerId, MsgId msgId) override; ++ ++ bool hasActionsSupport() const; + +private: + class Private; + const std::unique_ptr _private; ++}; + ++class Manager::Private : public QObject { ++ Q_OBJECT ++public: ++ using Type = Window::Notifications::CachedUserpics::Type; ++ explicit Private(Manager *instance, Type type); ++ bool init(); ++ ++ bool showNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, \ ++ const QString &msg, bool hideNameAndPhoto, bool hideReplyButton); ++ void clearAll(); ++ void clearFromHistory(History *history); ++ void beforeNotificationActivated(PeerId peerId, MsgId msgId); ++ void afterNotificationActivated(PeerId peerId, MsgId msgId); ++ void clearNotification(PeerId peerId, MsgId msgId); ++ ++ bool hasActionsSupport() const { ++ return true; ++ } ++ ++ void performOnMainQueue(FnMut task) { ++ const auto weak = _weak; ++ crl::on_main(weak, [=, task = std::move(task)]() mutable { ++ task(*weak.lock()); ++ }); ++ } ++ ++ ~Private(); ++public slots: ++ void notificationActivatedSlot(PeerId peerId, MsgId msgId); ++private: ++ Window::Notifications::CachedUserpics _cachedUserpics; ++ std::shared_ptr _guarded; ++ std::weak_ptr _weak; ++ QThread *pipeReaderThread; ++ NotifyReader *pipeReader; +}; + +} // 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..b303e1d +index 0000000..4ce6ac6 --- /dev/null +++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -@@ -0,0 +1,397 @@ +@@ -0,0 +1,404 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org @@ -1392,6 +1449,10 @@ index 0000000..b303e1d + return false; +} + ++bool IsApplicationActive() { ++ return static_cast(QApplication::instance())->activeWindow() != nullptr; ++} ++ +QString SystemCountry() { + return QString(); +} @@ -1400,6 +1461,9 @@ index 0000000..b303e1d + return QString(); +} + ++void RegisterCustomScheme() { ++} ++ +namespace ThirdParty { + +void start() { @@ -1430,7 +1494,7 @@ index 0000000..b303e1d +} + +void psNewVersion() { -+ psRegisterCustomScheme(); ++ Platform::RegisterCustomScheme(); +} + +bool _execUpdater(bool update = true, const QString &crashreport = QString()) { @@ -1586,379 +1650,52 @@ index 0000000..99d13d5 +bool linuxMoveFile(const char *from, const char *to); + +bool psLaunchMaps(const LocationCoords &coords); -diff --git a/Telegram/SourceFiles/platform/platform_audio.h b/Telegram/SourceFiles/platform/platform_audio.h -index 7705b2e..cfc1fc9 100644 ---- a/Telegram/SourceFiles/platform/platform_audio.h -+++ b/Telegram/SourceFiles/platform/platform_audio.h -@@ -19,7 +19,7 @@ void DeInit(); - - // Platform dependent implementations. - --#if defined Q_OS_MAC || defined Q_OS_LINUX -+#if defined Q_OS_MAC || defined Q_OS_LINUX || defined(Q_OS_HAIKU) - namespace Platform { - namespace Audio { - -diff --git a/Telegram/SourceFiles/platform/platform_file_utilities.h b/Telegram/SourceFiles/platform/platform_file_utilities.h -index 68b1058..2839790 100644 ---- a/Telegram/SourceFiles/platform/platform_file_utilities.h -+++ b/Telegram/SourceFiles/platform/platform_file_utilities.h -@@ -47,6 +47,8 @@ bool Get( - #include "platform/mac/file_utilities_mac.h" - #elif defined Q_OS_LINUX // Q_OS_MAC - #include "platform/linux/file_utilities_linux.h" -+#elif defined Q_OS_HAIKU // Q_OS_LINUX -+#include "platform/haiku/file_utilities_haiku.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX - #include "platform/win/file_utilities_win.h" - #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN -diff --git a/Telegram/SourceFiles/platform/platform_launcher.h b/Telegram/SourceFiles/platform/platform_launcher.h -index 27180d0..953b47f 100644 ---- a/Telegram/SourceFiles/platform/platform_launcher.h -+++ b/Telegram/SourceFiles/platform/platform_launcher.h -@@ -25,6 +25,8 @@ namespace Platform { - #include "platform/mac/launcher_mac.h" - #elif defined Q_OS_LINUX // Q_OS_MAC - #include "platform/linux/launcher_linux.h" -+#elif defined Q_OS_HAIKU -+#include "platform/haiku/launcher_haiku.h" - #elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX - #include "platform/win/launcher_win.h" - #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN -diff --git a/Telegram/SourceFiles/platform/platform_main_window.h b/Telegram/SourceFiles/platform/platform_main_window.h -index 33277c9..4e28b24 100644 ---- a/Telegram/SourceFiles/platform/platform_main_window.h -+++ b/Telegram/SourceFiles/platform/platform_main_window.h -@@ -21,6 +21,8 @@ class MainWindow; - #include "platform/mac/main_window_mac.h" - #elif defined Q_OS_LINUX // Q_OS_MAC - #include "platform/linux/main_window_linux.h" --#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX -+#elif defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_LINUX -+#include "platform/haiku/main_window_haiku.h" -+#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_HAIKU - #include "platform/win/main_window_win.h" - #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN -diff --git a/Telegram/SourceFiles/platform/platform_notifications_manager.h b/Telegram/SourceFiles/platform/platform_notifications_manager.h -index 692f4b4..a40f830 100644 ---- a/Telegram/SourceFiles/platform/platform_notifications_manager.h -+++ b/Telegram/SourceFiles/platform/platform_notifications_manager.h -@@ -28,6 +28,8 @@ void FlashBounce(); - #include "platform/mac/notifications_manager_mac.h" - #elif defined Q_OS_LINUX // Q_OS_MAC - #include "platform/linux/notifications_manager_linux.h" -+#elif defined Q_OS_HAIKU // Q_OS_LINUX -+#include "platform/haiku/notifications_manager_haiku.h" - #elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX - #include "platform/win/notifications_manager_win.h" - #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN -diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h -index bd3b2f9..7c14335 100644 ---- a/Telegram/SourceFiles/platform/platform_specific.h -+++ b/Telegram/SourceFiles/platform/platform_specific.h -@@ -35,6 +35,8 @@ void finish(); - #include "platform/mac/specific_mac.h" - #elif defined Q_OS_LINUX // Q_OS_MAC - #include "platform/linux/specific_linux.h" --#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX -+#elif defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_LINUX -+#include "platform/haiku/specific_haiku.h" -+#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_HAIKU - #include "platform/win/specific_win.h" - #endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN -diff --git a/Telegram/SourceFiles/platform/platform_window_title.h b/Telegram/SourceFiles/platform/platform_window_title.h -index 7aed20b..dc0212c 100644 ---- a/Telegram/SourceFiles/platform/platform_window_title.h -+++ b/Telegram/SourceFiles/platform/platform_window_title.h -@@ -25,7 +25,7 @@ void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRe - #include "platform/mac/window_title_mac.h" - #elif defined Q_OS_WIN // Q_OS_MAC - #include "platform/win/window_title_win.h" --#elif defined Q_OS_WINRT || defined Q_OS_LINUX // Q_OS_MAC || Q_OS_WIN -+#elif defined Q_OS_WINRT || defined Q_OS_LINUX || defined Q_OS_HAIKU // Q_OS_MAC || Q_OS_WIN - - namespace Platform { - -diff --git a/Telegram/SourceFiles/rpl/operators_tests.cpp b/Telegram/SourceFiles/rpl/operators_tests.cpp -index bd3b739..5735e12 100644 ---- a/Telegram/SourceFiles/rpl/operators_tests.cpp -+++ b/Telegram/SourceFiles/rpl/operators_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include - #include -diff --git a/Telegram/SourceFiles/rpl/producer_tests.cpp b/Telegram/SourceFiles/rpl/producer_tests.cpp -index 0267f92..0e783b0 100644 ---- a/Telegram/SourceFiles/rpl/producer_tests.cpp -+++ b/Telegram/SourceFiles/rpl/producer_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include - #include -diff --git a/Telegram/SourceFiles/rpl/variable_tests.cpp b/Telegram/SourceFiles/rpl/variable_tests.cpp -index 9c697fc..36ddf56 100644 ---- a/Telegram/SourceFiles/rpl/variable_tests.cpp -+++ b/Telegram/SourceFiles/rpl/variable_tests.cpp -@@ -5,7 +5,11 @@ the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ -+#if !defined(Q_OS_HAIKU) - #include "catch.hpp" -+#else -+#include "../ThirdParty/variant/test/include/catch.hpp" -+#endif - - #include - #include -diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp -index 680f347..cb0d5a3 100644 ---- a/Telegram/SourceFiles/settings.cpp -+++ b/Telegram/SourceFiles/settings.cpp -@@ -77,6 +77,8 @@ DBIPlatform gPlatform = dbipWindows; - DBIPlatform gPlatform = dbipMacOld; - #elif defined Q_OS_MAC - DBIPlatform gPlatform = dbipMac; -+#elif defined Q_OS_HAIKU -+DBIPlatform gPlatform = dbipHaiku; - #elif defined Q_OS_LINUX64 - DBIPlatform gPlatform = dbipLinux64; - #elif defined Q_OS_LINUX32 -diff --git a/Telegram/ThirdParty/minizip/ioapi.c b/Telegram/ThirdParty/minizip/ioapi.c -index 7f5c191..649255c 100644 ---- a/Telegram/ThirdParty/minizip/ioapi.c -+++ b/Telegram/ThirdParty/minizip/ioapi.c -@@ -14,7 +14,7 @@ - #define _CRT_SECURE_NO_WARNINGS - #endif - --#if defined(__APPLE__) || defined(IOAPI_NO_64) -+#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) - // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions - #define FOPEN_FUNC(filename, mode) fopen(filename, mode) - #define FTELLO_FUNC(stream) ftello(stream) -diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp -index 1460aca..2810a1b 100644 ---- a/Telegram/gyp/Telegram.gyp -+++ b/Telegram/gyp/Telegram.gyp -@@ -61,6 +61,7 @@ - 'telegram_win.gypi', - 'telegram_mac.gypi', - 'telegram_linux.gypi', -+ 'telegram_haiku.gypi', - 'qt.gypi', - 'qt_moc.gypi', - 'qt_rcc.gypi', -@@ -88,11 +89,12 @@ +diff --git a/Telegram/SourceFiles/storage/storage_encrypted_file_tests.cpp b/Telegram/SourceFiles/storage/storage_encrypted_file_tests.cpp +index 4d522a9..1ca7dd0 100644 +--- a/Telegram/SourceFiles/storage/storage_encrypted_file_tests.cpp ++++ b/Telegram/SourceFiles/storage/storage_encrypted_file_tests.cpp +@@ -188,6 +188,7 @@ TEST_CASE("two process encrypted file", "[storage_encrypted_file]") { + constexpr auto kMaxPath = 1024; + char result[kMaxPath] = { 0 }; + uint32_t size = kMaxPath; ++#ifndef Q_OS_HAIKU + #ifdef Q_OS_MAC + if (_NSGetExecutablePath(result, &size) == 0) { + return result; +@@ -198,6 +199,7 @@ TEST_CASE("two process encrypted file", "[storage_encrypted_file]") { + return result; + } + #endif // Q_OS_MAC ++#endif // Q_OS_HAIKU + return "tests_storage"; + #endif // Q_OS_WIN + }(); +diff --git a/Telegram/gyp/lib_base.gyp b/Telegram/gyp/lib_base.gyp +index 1f3e9c3..d96dedd 100644 +--- a/Telegram/gyp/lib_base.gyp ++++ b/Telegram/gyp/lib_base.gyp +@@ -38,7 +38,7 @@ 'include_dirs': [ '<(src_loc)', '<(SHARED_INTERMEDIATE_DIR)', -- '/usr/include/minizip', -+ '<(minizip_loc)', - '<(emoji_suggestions_loc)', +- '<(libs_loc)/range-v3/include', ++ '<(submodules_loc)/range/include', '<(submodules_loc)/GSL/include', '<(submodules_loc)/variant/include', '<(submodules_loc)/crl/src', +diff --git a/Telegram/gyp/lib_storage.gyp b/Telegram/gyp/lib_storage.gyp +index 5277135..63996cf 100644 +--- a/Telegram/gyp/lib_storage.gyp ++++ b/Telegram/gyp/lib_storage.gyp +@@ -43,7 +43,7 @@ + 'include_dirs': [ + '<(src_loc)', + '<(SHARED_INTERMEDIATE_DIR)', +- '<(libs_loc)/range-v3/include', + '<(submodules_loc)/range/include', - ], - 'sources': [ - '<@(qrc_files)', -diff --git a/Telegram/gyp/common.gypi b/Telegram/gyp/common.gypi -index 8b453a9..9a5866b 100644 ---- a/Telegram/gyp/common.gypi -+++ b/Telegram/gyp/common.gypi -@@ -8,6 +8,7 @@ - 'includes': [ - 'settings_win.gypi', - 'settings_mac.gypi', -+ 'settings_haiku.gypi', - 'settings_linux.gypi', - ], - 'variables': { -@@ -29,6 +30,11 @@ - }, { - 'build_mac': 0, - }], -+ [ 'build_os == "haiku"', { -+ 'build_haiku': 1, -+ }, { -+ 'build_haiku': 0, -+ }], - [ 'build_os == "linux"', { - 'build_linux': 1, - }, { -@@ -40,11 +46,13 @@ - 'build_win%': '<(build_win)', - 'build_mac%': '<(build_mac)', - 'build_linux%': '<(build_linux)', -+ 'build_haiku%': '<(build_haiku)', - }, - 'build_os%': '<(build_os)', - 'build_win%': '<(build_win)', - 'build_mac%': '<(build_mac)', - 'build_linux%': '<(build_linux)', -+ 'build_haiku%': '<(build_haiku)', - - 'official_build_target%': '', - }, -@@ -52,6 +60,7 @@ - 'build_win%': '<(build_win)', - 'build_mac%': '<(build_mac)', - 'build_linux%': '<(build_linux)', -+ 'build_haiku%': '<(build_haiku)', - 'official_build_target%': '<(official_build_target)', - - # GYP does not support per-configuration libraries :( -diff --git a/Telegram/gyp/list_sources.py b/Telegram/gyp/list_sources.py -index 9efee62..d978ed6 100644 ---- a/Telegram/gyp/list_sources.py -+++ b/Telegram/gyp/list_sources.py -@@ -113,6 +113,8 @@ if input_path != '': - platform_rules[file_path] = [ 'mac' ] - elif '/platform/linux/' in file_path: - platform_rules[file_path] = [ 'linux' ] -+ elif '/platform/haiku/' in file_path: -+ platform_rules[file_path] = [ 'haiku' ] - - for replace in replaces: - replace_parts = replace.split('=', 1) -diff --git a/Telegram/gyp/qt.gypi b/Telegram/gyp/qt.gypi -index 3f91776..8f3e531 100644 ---- a/Telegram/gyp/qt.gypi -+++ b/Telegram/gyp/qt.gypi -@@ -14,7 +14,7 @@ - [ 'build_macold', { - 'qt_version%': '5.3.2', - }, { -- 'qt_version%': ' /dev/null --libs <@(pkgconfig_libs))', + ], @@ -2127,771 +1865,6 @@ index 0000000..96b6190 + 'cmake_precompiled_header_script': 'PrecompiledHeader.cmake', + }]], +} -diff --git a/Telegram/gyp/telegram_qrc.gypi b/Telegram/gyp/telegram_qrc.gypi -index 77b126d..6c27563 100644 ---- a/Telegram/gyp/telegram_qrc.gypi -+++ b/Telegram/gyp/telegram_qrc.gypi -@@ -9,6 +9,7 @@ - 'qrc_files': [ - '<(res_loc)/qrc/telegram.qrc', - '<(res_loc)/qrc/telegram_emoji.qrc', -+ '<(res_loc)/qrc/telegram_emoji2.qrc', - '<(res_loc)/qrc/telegram_emoji_large.qrc', - '<(res_loc)/qrc/telegram_sounds.qrc', - ], -@@ -21,6 +22,13 @@ - ], - } - }], -+ [ 'build_haiku', { -+ 'variables': { -+ 'qrc_files': [ -+ '<(res_loc)/qrc/telegram_haiku.qrc', -+ ], -+ } -+ }], - [ 'build_mac', { - 'variables': { - 'qrc_files': [ -diff --git a/Telegram/gyp/telegram_sources.txt b/Telegram/gyp/telegram_sources.txt -index 397d2a2..ed4097a 100644 ---- a/Telegram/gyp/telegram_sources.txt -+++ b/Telegram/gyp/telegram_sources.txt -@@ -507,6 +507,18 @@ - <(src_loc)/platform/linux/notifications_manager_linux.h - <(src_loc)/platform/linux/specific_linux.cpp - <(src_loc)/platform/linux/specific_linux.h -+<(src_loc)/platform/haiku/file_utilities_haiku.cpp -+<(src_loc)/platform/haiku/file_utilities_haiku.h -+<(src_loc)/platform/haiku/haiku_desktop_environment.cpp -+<(src_loc)/platform/haiku/haiku_desktop_environment.h -+<(src_loc)/platform/haiku/launcher_haiku.cpp -+<(src_loc)/platform/haiku/launcher_haiku.h -+<(src_loc)/platform/haiku/notifications_manager_haiku.cpp -+<(src_loc)/platform/haiku/notifications_manager_haiku.h -+<(src_loc)/platform/haiku/main_window_haiku.cpp -+<(src_loc)/platform/haiku/main_window_haiku.h -+<(src_loc)/platform/haiku/specific_haiku.cpp -+<(src_loc)/platform/haiku/specific_haiku.h - <(src_loc)/platform/mac/file_utilities_mac.mm - <(src_loc)/platform/mac/file_utilities_mac.h - <(src_loc)/platform/mac/launcher_mac.mm -diff --git a/Telegram/gyp/utils.gyp b/Telegram/gyp/utils.gyp -index 622462e..e3ba800 100644 ---- a/Telegram/gyp/utils.gyp -+++ b/Telegram/gyp/utils.gyp -@@ -82,6 +82,13 @@ - 'lzma', - ], - }], -+ [ 'build_haiku', { -+ 'libraries': [ -+ 'ssl', -+ 'crypto', -+ 'lzma', -+ ], -+ }], - [ 'build_mac', { - 'include_dirs': [ - '<(libs_loc)/openssl/include' -- -2.16.4 - - -From 5912a51cb8db843b75e99e7aea1612ee6d5ed512 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sun, 10 Jun 2018 14:50:46 +1000 -Subject: Adapt code to new API - - -diff --git a/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp -index 5777c2c..58bc1c3 100644 ---- a/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp -+++ b/Telegram/SourceFiles/platform/haiku/file_utilities_haiku.cpp -@@ -103,8 +103,9 @@ bool PreviewSupported() { - - } // namespace - --bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) { -- return ::FileDialog::internal::GetDefault(files, remoteContent, caption, filter, type, startFile); -+bool Get(QPointer parent, QStringList &files, QByteArray &remoteContent, const QString &caption, \ -+ const QString &filter, Type type, QString startFile) { -+ return ::FileDialog::internal::GetDefault(parent, files, remoteContent, caption, filter, type, startFile); - } - - namespace internal { -diff --git a/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp b/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp -index b861841..a7bea21 100644 ---- a/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp -+++ b/Telegram/SourceFiles/platform/haiku/launcher_haiku.cpp -@@ -43,7 +43,7 @@ QString DeviceModel() { - } - - QString SystemVersion() { -- return "Haiku" -+ return "Haiku"; - } - - } // namespace -diff --git a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -index b303e1d..1928257 100644 ---- a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -+++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -@@ -335,6 +335,9 @@ QString SystemLanguage() { - return QString(); - } - -+void RegisterCustomScheme() { -+} -+ - namespace ThirdParty { - - void start() { -@@ -365,7 +368,7 @@ void psRegisterCustomScheme() { - } - - void psNewVersion() { -- psRegisterCustomScheme(); -+ Platform::RegisterCustomScheme(); - } - - bool _execUpdater(bool update = true, const QString &crashreport = QString()) { --- -2.16.4 - - -From 9ea33b942ed72a8dcaf2c63cd02f0db2925c4b89 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Thu, 28 Jun 2018 00:02:04 +1000 -Subject: Fix range include path - - -diff --git a/Telegram/gyp/lib_export.gyp b/Telegram/gyp/lib_export.gyp -index 2d1ac6c..d26d7c4 100644 ---- a/Telegram/gyp/lib_export.gyp -+++ b/Telegram/gyp/lib_export.gyp -@@ -48,7 +48,7 @@ - 'include_dirs': [ - '<(src_loc)', - '<(SHARED_INTERMEDIATE_DIR)', -- '<(libs_loc)/range-v3/include', -+ '<(submodules_loc)/range/include', - '<(submodules_loc)/GSL/include', - '<(submodules_loc)/variant/include', - '<(submodules_loc)/crl/src', --- -2.16.4 - - -From 5d20154caa716393e5ae89ecd3114173743abdc5 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Mon, 2 Jul 2018 17:24:39 +1000 -Subject: gcc7 segfault on this code. export is broken now. - - -diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp -index f835dc2..cb8cd96 100644 ---- a/Telegram/SourceFiles/export/data/export_data_types.cpp -+++ b/Telegram/SourceFiles/export/data/export_data_types.cpp -@@ -210,6 +210,8 @@ Image ParseMaxImage( - const MTPVector &data, - const QString &suggestedPath) { - auto result = Image(); -+// GCC7 Segmentation violation for Haiku -+#ifndef __HAIKU__ - result.file.suggestedPath = suggestedPath; - - auto maxArea = int64(0); -@@ -232,6 +234,7 @@ Image ParseMaxImage( - } - }); - } -+#endif - return result; - } - -diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp -index b618937..272f1dc 100644 ---- a/Telegram/SourceFiles/export/export_api_wrap.cpp -+++ b/Telegram/SourceFiles/export/export_api_wrap.cpp -@@ -708,6 +708,8 @@ void ApiWrap::requestUserpics( - void ApiWrap::handleUserpicsSlice(const MTPphotos_Photos &result) { - Expects(_userpicsProcess != nullptr); - -+// GCC7 Segmentation violation for Haiku -+#ifndef __HAIKU__ - result.match([&](const auto &data) { - if constexpr (MTPDphotos_photos::Is()) { - _userpicsProcess->lastSlice = true; -@@ -716,6 +718,7 @@ void ApiWrap::handleUserpicsSlice(const MTPphotos_Photos &result) { - data.vphotos, - _userpicsProcess->processed)); - }); -+#endif - } - - void ApiWrap::loadUserpicsFiles(Data::UserpicsSlice &&slice) { -@@ -1129,7 +1132,8 @@ void ApiWrap::appendChatsSlice( - - void ApiWrap::requestMessagesSlice() { - Expects(_chatProcess != nullptr); -- -+// GCC7 Segmentation violation for Haiku -+#ifndef __HAIKU__ - requestChatMessages( - _chatProcess->info.splits[_chatProcess->localSplitIndex], - _chatProcess->largestIdPlusOne, -@@ -1152,6 +1156,7 @@ void ApiWrap::requestMessagesSlice() { - _chatProcess->info.relativePath)); - }); - }); -+#endif - } - - void ApiWrap::requestChatMessages( --- -2.16.4 - - -From f34764e69791334618186bc5413cccd3152e371f Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 28 Jul 2018 15:08:08 +1000 -Subject: gcc7 segfault on this code. export is broken now. - - -diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp -index cb8cd96..2cb86b9 100644 ---- a/Telegram/SourceFiles/export/data/export_data_types.cpp -+++ b/Telegram/SourceFiles/export/data/export_data_types.cpp -@@ -389,6 +389,7 @@ Document ParseDocument( - const MTPDocument &data, - const QString &suggestedFolder) { - auto result = Document(); -+#ifndef __HAIKU__ - data.match([&](const MTPDdocument &data) { - result.id = data.vid.v; - result.date = data.vdate.v; -@@ -425,6 +426,7 @@ Document ParseDocument( - }, [&](const MTPDdocumentEmpty &data) { - result.id = data.vid.v; - }); -+#endif - return result; - } - -@@ -1018,6 +1020,7 @@ Message ParseMessage( - const MTPMessage &data, - const QString &mediaFolder) { - auto result = Message(); -+#ifndef __HAIKU__ - data.match([&](const auto &data) { - result.id = data.vid.v; - if constexpr (!MTPDmessageEmpty::Is()) { -@@ -1104,6 +1107,7 @@ Message ParseMessage( - }, [&](const MTPDmessageEmpty &data) { - result.id = data.vid.v; - }); -+#endif - return result; - } - --- -2.16.4 - - -From 18e78b2819f9e23b56844aefa4844cce23c799f6 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 28 Jul 2018 20:58:12 +1000 -Subject: Add updater paths for haiku - - -diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp -index cc19eb8..2725edd 100644 ---- a/Telegram/SourceFiles/core/update_checker.cpp -+++ b/Telegram/SourceFiles/core/update_checker.cpp -@@ -2069,6 +2069,9 @@ bool checkReadyUpdate() { - #elif defined Q_OS_LINUX // Q_OS_MAC - QString curUpdater = (cExeDir() + qsl("Updater")); - QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Updater")); -+#elif defined Q_OS_HAIKU // Q_OS_LINUX -+ QString curUpdater = (cExeDir() + qsl("Updater")); -+ QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Updater")); - #endif // Q_OS_LINUX - if (!updater.exists()) { - QFileInfo current(curUpdater); --- -2.16.4 - - -From 14d4c9c645a1b1b3cabbff9dad7f9e8fef4a85e9 Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 28 Jul 2018 20:59:18 +1000 -Subject: Add lzma library - - -diff --git a/Telegram/gyp/telegram_haiku.gypi b/Telegram/gyp/telegram_haiku.gypi -index 96b6190..171c216 100644 ---- a/Telegram/gyp/telegram_haiku.gypi -+++ b/Telegram/gyp/telegram_haiku.gypi -@@ -45,6 +45,7 @@ - 'minizip', - 'opus', - 'network', -+ 'lzma', - 'z', - # ' /dev/null --libs <@(pkgconfig_libs))', - ], --- -2.16.4 - - -From ddfc648224733852fddc43ece708e7356248853f Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Sat, 18 Aug 2018 15:45:49 +1000 -Subject: Add IsApplicationActive function for Haiku platform - - -diff --git a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -index 1928257..4ce6ac6 100644 ---- a/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -+++ b/Telegram/SourceFiles/platform/haiku/specific_haiku.cpp -@@ -327,6 +327,10 @@ bool TranslucentWindowsSupported(QPoint globalPosition) { - return false; - } - -+bool IsApplicationActive() { -+ return static_cast(QApplication::instance())->activeWindow() != nullptr; -+} -+ - QString SystemCountry() { - return QString(); - } --- -2.16.4 - - -From 95c36a14498a6ede405420d45bbeeb46df5d8d7e Mon Sep 17 00:00:00 2001 -From: Gerasim Troeglazov <3dEyes@gmail.com> -Date: Tue, 4 Sep 2018 22:57:02 +1000 -Subject: Add native notifations - - -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..bf9c7be ---- /dev/null -+++ b/Telegram/SourceFiles/platform/haiku/notifications_haiku_gate.cpp -@@ -0,0 +1,40 @@ -+#include -+ -+#include -+#include -+ -+#define APPSIGNATURE "application/x-vnd.tg-notify-gate" -+ -+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) { -+ FILE *out=fopen("/tmp/tg_notify","wt"); -+ fprintf(out,"%s\n", argv[1]); -+ fclose(out); -+ } -+} -+ -+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 -index b3d186a..8a75ed7 100644 ---- a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp -+++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.cpp -@@ -18,65 +18,197 @@ to link the code of portions of this program with the OpenSSL library. - Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE - Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org - */ -+ -+#include -+#include -+#include -+#include -+ - #include "platform/haiku/notifications_manager_haiku.h" - - #include "window/notifications_utilities.h" - #include "lang/lang_keys.h" - #include "history/history.h" - -+#include -+#include -+#include -+#include -+#include -+ - namespace Platform { - namespace Notifications { - namespace { - --bool LibNotifyLoaded() { -- return false; --} -- --QString escapeHtml(const QString &text) { -- auto result = QString(); -- auto copyFrom = 0, textSize = text.size(); -- auto data = text.constData(); -- for (auto i = 0; i != textSize; ++i) { -- auto ch = data[i]; -- if (ch == '<' || ch == '>' || ch == '&') { -- if (!copyFrom) { -- result.reserve(textSize * 5); -- } -- if (i > copyFrom) { -- result.append(data + copyFrom, i - copyFrom); -- } -- switch (ch.unicode()) { -- case '<': result.append(qstr("<")); break; -- case '>': result.append(qstr(">")); break; -- case '&': result.append(qstr("&")); break; -- } -- copyFrom = i + 1; -+} // namespace -+ -+bool Supported() { -+ return true; -+} -+ -+std::unique_ptr Create(Window::Notifications::System *system) { -+ if (Global::NativeNotifications() && Supported()) { -+ auto result = std::make_unique(system); -+ if (result->init()) { -+ return std::move(result); - } - } -- if (copyFrom > 0) { -- result.append(data + copyFrom, textSize - copyFrom); -- return result; -+ return nullptr; -+} -+ -+void Finish() { -+} -+ -+NotifyReader::NotifyReader() -+{ -+ unlink(NOTIFY_FIFO_NAME); -+ mkfifo(NOTIFY_FIFO_NAME, 0666); -+} -+ -+NotifyReader::~NotifyReader() -+{ -+ unlink(NOTIFY_FIFO_NAME); -+} -+ -+void NotifyReader::run() -+{ -+ char line[256]; -+ size_t n; -+ -+ for(;;) { -+ FILE *in=fopen(NOTIFY_FIFO_NAME, "rt"); -+ fgets(line, sizeof line, in); -+ if (line[strlen(line)-1] == '\n') { -+ uint64 peerid = 0; -+ int32 msgid = 0; -+ QString paramsString = QString(line); -+ QStringList paramsList = paramsString.split(' '); -+ if (paramsList.count() == 2) { -+ bool peerStatus, msgStatus; -+ peerid = paramsList[0].toULongLong(&peerStatus, 16); -+ msgid = paramsList[1].toInt(&msgStatus, 16); -+ if (peerStatus & msgStatus) -+ notificationActivated(peerid, msgid); -+ } -+ } -+ fclose(in); -+ } -+} -+ -+Manager::Private::Private(Manager *instance, Type type) -+: _guarded(std::make_shared(instance)) -+, _cachedUserpics(type) { -+ _weak = _guarded; -+} -+ -+bool Manager::Private::init() { -+ pipeReaderThread = new QThread; -+ pipeReader = new NotifyReader(); -+ pipeReader->moveToThread(pipeReaderThread); -+ connect(pipeReaderThread, SIGNAL(started()), pipeReader, SLOT(run())); -+ qRegisterMetaType("PeerId"); -+ qRegisterMetaType("MsgId"); -+ connect(pipeReader, SIGNAL(notificationActivated(PeerId, MsgId)), \ -+ this, SLOT(notificationActivatedSlot(PeerId, MsgId))); -+ pipeReaderThread->start(); -+ return true; -+} -+ -+Manager::Private::~Private() { -+ clearAll(); -+} -+ -+void Manager::Private::clearAll() { -+} -+ -+void Manager::Private::clearFromHistory(History *history) { -+} -+ -+void Manager::Private::beforeNotificationActivated(PeerId peerId, MsgId msgId) { -+} -+ -+void Manager::Private::afterNotificationActivated(PeerId peerId, MsgId msgId) { -+} -+ -+void Manager::Private::clearNotification(PeerId peerId, MsgId msgId) { -+} -+ -+bool Manager::Private::showNotification(PeerData *peer, MsgId msgId, const QString &title, \ -+ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { -+ auto titleText = title; -+ auto subtitleText = subtitle; -+ auto msgText = msg; -+ -+ StorageKey key; -+ if (hideNameAndPhoto) { -+ key = StorageKey(0, 0); -+ } else { -+ key = peer->userpicUniqueKey(); - } -- return text; -+ -+ auto userpicPath = _cachedUserpics.get(key, peer); -+ -+ QString program = "/bin/notify"; -+ QStringList arguments; -+ arguments << "--icon" << userpicPath; -+ arguments << "--group" << "Telegram"; -+ arguments << "--title" << titleText; -+ arguments << "--onClickFile" << NOTIFY_GATE_NAME; -+ arguments << "--onClickArgv" << QString("0x%1 0x%2").arg(peer->id, 0, 16).arg(msgId, 0, 16); -+ arguments << msgText; -+ -+ QProcess *notifyProcess = new QProcess(); -+ notifyProcess->start(program, arguments); -+ -+ return true; -+} -+ -+void Manager::Private::notificationActivatedSlot(PeerId _peerId, MsgId _msgId) -+{ -+ qDebug() << _peerId << _msgId; -+ performOnMainQueue([peerId = _peerId, msgId = _msgId](Manager *manager) { -+ manager->notificationActivated(peerId, msgId); -+ }); - } - -+Manager::Manager(Window::Notifications::System *system) : NativeManager(system) -+, _private(std::make_unique(this, Private::Type::Rounded)) { -+} - -+bool Manager::init() { -+ return _private->init(); -+} - --} // namespace -+void Manager::clearNotification(PeerId peerId, MsgId msgId) { -+ _private->clearNotification(peerId, msgId); -+} - --bool Supported() { -- return false; -+Manager::~Manager() = default; -+ -+void Manager::doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, \ -+ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { -+ _private->showNotification(peer, msgId, title, subtitle, msg, hideNameAndPhoto, hideReplyButton); - } - --std::unique_ptr Create(Window::Notifications::System *system) { -- return nullptr; -+void Manager::doClearAllFast() { -+ _private->clearAll(); - } - --void Finish() { -+void Manager::doClearFromHistory(History *history) { -+ _private->clearFromHistory(history); -+} - -+void Manager::onBeforeNotificationActivated(PeerId peerId, MsgId msgId) { -+ _private->beforeNotificationActivated(peerId, msgId); - } - -+void Manager::onAfterNotificationActivated(PeerId peerId, MsgId msgId) { -+ _private->afterNotificationActivated(peerId, msgId); -+} - -+bool Manager::hasActionsSupport() const { -+ return _private->hasActionsSupport(); -+} - - } // namespace Notifications - } // namespace Platform -diff --git a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h -index d70bcff..53491b6 100644 ---- a/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h -+++ b/Telegram/SourceFiles/platform/haiku/notifications_manager_haiku.h -@@ -21,6 +21,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org - #pragma once - - #include "platform/platform_notifications_manager.h" -+#include "window/notifications_utilities.h" -+ -+#include -+#include -+#include -+ -+#define NOTIFY_FIFO_NAME "/tmp/tg_notify" -+#define NOTIFY_GATE_NAME "/bin/tg-notify-gate" - - namespace Platform { - namespace Notifications { -@@ -38,25 +46,80 @@ inline void FlashBounce() { - - void Finish(); - -+class NotifyReader:public QObject { -+ Q_OBJECT -+public: -+ NotifyReader(); -+ ~NotifyReader(); -+public slots: -+ void run(); -+signals: -+ void notificationActivated(PeerId peerId, MsgId msgId); -+private: -+ int pipeFD; -+}; -+ -+ - class Manager : public Window::Notifications::NativeManager { - public: - Manager(Window::Notifications::System *system); - -+ bool init(); -+ - void clearNotification(PeerId peerId, MsgId msgId); -- bool hasPoorSupport() const; -- bool hasActionsSupport() const; - - ~Manager(); - - protected: -- void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; -+ void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, \ -+ const QString &subtitle, const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; - void doClearAllFast() override; - void doClearFromHistory(History *history) override; -+ void onBeforeNotificationActivated(PeerId peerId, MsgId msgId) override; -+ void onAfterNotificationActivated(PeerId peerId, MsgId msgId) override; -+ -+ bool hasActionsSupport() const; - - private: - class Private; - const std::unique_ptr _private; -+}; - -+class Manager::Private : public QObject { -+ Q_OBJECT -+public: -+ using Type = Window::Notifications::CachedUserpics::Type; -+ explicit Private(Manager *instance, Type type); -+ bool init(); -+ -+ bool showNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, \ -+ const QString &msg, bool hideNameAndPhoto, bool hideReplyButton); -+ void clearAll(); -+ void clearFromHistory(History *history); -+ void beforeNotificationActivated(PeerId peerId, MsgId msgId); -+ void afterNotificationActivated(PeerId peerId, MsgId msgId); -+ void clearNotification(PeerId peerId, MsgId msgId); -+ -+ bool hasActionsSupport() const { -+ return true; -+ } -+ -+ void performOnMainQueue(FnMut task) { -+ const auto weak = _weak; -+ crl::on_main(weak, [=, task = std::move(task)]() mutable { -+ task(*weak.lock()); -+ }); -+ } -+ -+ ~Private(); -+public slots: -+ void notificationActivatedSlot(PeerId peerId, MsgId msgId); -+private: -+ Window::Notifications::CachedUserpics _cachedUserpics; -+ std::shared_ptr _guarded; -+ std::weak_ptr _weak; -+ QThread *pipeReaderThread; -+ NotifyReader *pipeReader; - }; - - } // namespace Notifications -diff --git a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp -index 62bbe64..f0c06f9 100644 ---- a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp -+++ b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp -@@ -69,7 +69,7 @@ void NotificationsWidget::createNotificationsControls() { - if (Platform::Notifications::Supported()) { - #ifdef Q_OS_WIN - nativeNotificationsLabel = lang(lng_settings_use_windows); --#elif defined Q_OS_LINUX64 || defined Q_OS_LINUX32 // Q_OS_WIN -+#elif defined Q_OS_LINUX64 || defined Q_OS_LINUX32 || defined Q_OS_HAIKU // Q_OS_WIN - nativeNotificationsLabel = lang(lng_settings_use_native_notifications); - #endif // Q_OS_WIN || Q_OS_LINUX64 || Q_OS_LINUX32 - } --- -2.16.4 +2.19.0 diff --git a/net-im/telegram-desktop/telegram_desktop-1.3.14.recipe b/net-im/telegram-desktop/telegram_desktop-1.3.16.recipe similarity index 86% rename from net-im/telegram-desktop/telegram_desktop-1.3.14.recipe rename to net-im/telegram-desktop/telegram_desktop-1.3.16.recipe index 9f49a5f49..dd4ab6624 100644 --- a/net-im/telegram-desktop/telegram_desktop-1.3.14.recipe +++ b/net-im/telegram-desktop/telegram_desktop-1.3.16.recipe @@ -5,12 +5,12 @@ COPYRIGHT="2013-2018 Telegram" LICENSE="GNU GPL v3" REVISION="1" SOURCE_URI="https://github.com/telegramdesktop/tdesktop/archive/v$portVersion.tar.gz" -CHECKSUM_SHA256="83daeded641f79bd370b5e83be88242ab57520e7754f1371a9e5c1f3d9863f2a" +CHECKSUM_SHA256="0ebb775dc6535eb3fef290d292b528073e02b4777068425c31f735091902d966" SOURCE_FILENAME="tdesktop-$portVersion.tar.gz" SOURCE_DIR="tdesktop-$portVersion" -srcGitRev_2="bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34" +srcGitRev_2="697eea96aa90205db4fc368df4127eef56b2a5c6" SOURCE_URI_2="https://github.com/telegramdesktop/libtgvoip/archive/$srcGitRev_2.tar.gz" -CHECKSUM_SHA256_2="74cf9046687e88ab6074e8f8946da53d95b11abb34a51db1f042ab0ae14f1b91" +CHECKSUM_SHA256_2="1a7c7b7b3757a6eaec6ab283a0203426690775b2564b2ab5f5a26ab0518fe579" SOURCE_FILENAME_2="libtgvoip-$srcGitRev_2.tar.gz" srcGitRev_3="550ac2f159ca883d360c196149b466955c77a573" SOURCE_URI_3="https://github.com/mapbox/variant/archive/$srcGitRev_3.tar.gz" @@ -24,14 +24,18 @@ srcGitRev_5="5ca44b68721833ae3731802ed99af67c6f38a53a" SOURCE_URI_5="https://github.com/philsquared/Catch/archive/$srcGitRev_5.tar.gz" CHECKSUM_SHA256_5="d24e6d9df2b8aa5739d3b9077c6b0ff0ef4d5ef8acc52c3a57e32893854d8d18" SOURCE_FILENAME_5="Catch-$srcGitRev_5.tar.gz" -srcGitRev_6="527ad273b683d52c5adf5b45b73c6466aa0d0cf0" +srcGitRev_6="4291015efab76bda5886a56b5007f4531be17d46" SOURCE_URI_6="https://github.com/telegramdesktop/crl/archive/$srcGitRev_6.tar.gz" -CHECKSUM_SHA256_6="d7e64fc8a2e284a5be8c0b0c6e7bfbaf951751081919829cb3bb290544c732e8" +CHECKSUM_SHA256_6="aee42a2fe003888d0d0133cd208a1524f5d95af6af506c1cd7e07e268d0d9081" SOURCE_FILENAME_6="crl-$srcGitRev_6.tar.gz" srcGitRev_7="4b10be9cbadd7d0880437f48f875185589fd86d3" SOURCE_URI_7="https://github.com/ericniebler/range-v3/archive/$srcGitRev_7.tar.gz" CHECKSUM_SHA256_7="86f6b8a2e2d8196d62312042af1953d0b16935550130a73ae0ec69f623b0b947" SOURCE_FILENAME_7="range-$srcGitRev_7.tar.gz" +srcGitRev_8="7cc9639699f64b750c0b82333dced9ea77e8436e" +SOURCE_URI_8="https://github.com/Cyan4973/xxHash/archive/$srcGitRev_8.tar.gz" +CHECKSUM_SHA256_8="0d1e2b4ae15f98acc49084e23ba94853dba2b0f654865ecedb1072b3959421bf" +SOURCE_FILENAME_8="xxHash-$srcGitRev_8.tar.gz" PATCHES=" telegram_desktop-$portVersion-systemqt.patch telegram_desktop-$portVersion.patchset @@ -107,14 +111,18 @@ PATCH() BUILD() { +# sed -i "s|@HAIKU_HEADERS@|/system/$relativeIncludeDir|" Telegram/gyp/telegram_haiku.gypi +# sed -i "s|@HAIKU_HEADERS@|/system/$relativeIncludeDir|" Telegram/gyp/qt.gypi +# sed -i "s|@HAIKU_LIBS@|/system/$relativeLibDir|" Telegram/gyp/telegram_haiku.gypi # link submodules - rm -rf Telegram/ThirdParty/{libtgvoip,variant,GSL,Catch,crl,range} + rm -rf Telegram/ThirdParty/{libtgvoip,variant,GSL,Catch,crl,range,xxHash} ln -sfn $sourceDir2/libtgvoip-$srcGitRev_2 Telegram/ThirdParty/libtgvoip ln -sfn $sourceDir3/variant-$srcGitRev_3 Telegram/ThirdParty/variant ln -sfn $sourceDir4/GSL-$srcGitRev_4 Telegram/ThirdParty/GSL ln -sfn $sourceDir5/Catch2-$srcGitRev_5 Telegram/ThirdParty/Catch ln -sfn $sourceDir6/crl-$srcGitRev_6 Telegram/ThirdParty/crl ln -sfn $sourceDir7/range-v3-$srcGitRev_7 Telegram/ThirdParty/range + ln -sfn $sourceDir8/xxHash-$srcGitRev_8 Telegram/ThirdParty/xxHash Telegram/gyp/refresh.sh ; cd out/Release # multi-job takes too much memory