Files
haikuports/net-im/telegram-desktop/patches/telegram_desktop-4.15.0.patchset
Gerasim Troeglazov 747fe26523 Telegram: bump version
2024-02-25 20:06:14 +10:00

1154 lines
34 KiB
Plaintext

From 35197d2cbea6178c5e188df237184db0b0b2947d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 25 Feb 2024 08:15:25 +0000
Subject: Add haiku support
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abea2aa..91970bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,12 +27,12 @@ elseif (LINUX)
list(APPEND project_langs ASM)
endif()
-project(Telegram
- LANGUAGES ${project_langs}
- VERSION ${desktop_app_version_cmake}
- DESCRIPTION "Official Telegram Desktop messenger"
- HOMEPAGE_URL "https://desktop.telegram.org"
-)
+#project(Telegram
+# LANGUAGES ${project_langs}
+# VERSION ${desktop_app_version_cmake}
+# DESCRIPTION "Official Telegram Desktop messenger"
+# HOMEPAGE_URL "https://desktop.telegram.org"
+#)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Telegram)
get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH)
diff --git a/SendToAddon/Makefile b/SendToAddon/Makefile
new file mode 100644
index 0000000..5098366
--- /dev/null
+++ b/SendToAddon/Makefile
@@ -0,0 +1,12 @@
+NAME = Send\ to\ Telegram
+TYPE = SHARED
+APP_MIME_SIG = application/x-vnd.Telegram-SendTo
+SRCS = SendToTelegram.cpp
+LIBS = be
+OPTIMIZE := FULL
+WARNINGS = NONE
+RDEFS = resource.rdef
+
+DEVEL_DIRECTORY := \
+ $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY)
+include $(DEVEL_DIRECTORY)/etc/makefile-engine
diff --git a/SendToAddon/SendToTelegram.cpp b/SendToAddon/SendToTelegram.cpp
new file mode 100644
index 0000000..c68a21d
--- /dev/null
+++ b/SendToAddon/SendToTelegram.cpp
@@ -0,0 +1,44 @@
+#include <limits.h>
+
+#include <StorageKit.h>
+#include <SupportKit.h>
+#include <AppKit.h>
+
+#include <add-ons/tracker/TrackerAddOn.h>
+
+const char* kTelegramSignature = "application/x-vnd.Telegram";
+
+void
+process_refs(entry_ref base_ref, BMessage* message, void* reserved)
+{
+ char **argv = new char*[ARG_MAX];
+
+ int argc = 0;
+ argv[argc++] = strdup("-sendpath");
+ argv[argc] = NULL;
+
+ BEntry entry;
+ entry_ref ref;
+
+ int32 i;
+
+ for (i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
+ if (entry.SetTo(&ref, true) != B_OK)
+ continue;
+ if (entry.IsDirectory())
+ continue;
+
+ BPath path;
+ entry.GetPath(&path);
+ argv[argc++] = strdup(path.Path());
+ argv[argc] = NULL;
+ }
+
+ if (argc > 1)
+ be_roster->Launch(kTelegramSignature, argc, argv);
+
+ for(i = 0; argv[i] != NULL; i++)
+ free(argv[i]);
+
+ delete[] argv;
+}
diff --git a/SendToAddon/resource.rdef b/SendToAddon/resource.rdef
new file mode 100644
index 0000000..e5f8b64
--- /dev/null
+++ b/SendToAddon/resource.rdef
@@ -0,0 +1,36 @@
+resource app_signature "application/x-vnd.Telegram-SendTo";
+
+resource app_version {
+ major = 1,
+ middle = 0,
+ minor = 0,
+ variety = 0,
+ internal = 1,
+
+ short_info = "Send to Telegram",
+ long_info = "Send selected files to Telegram"
+};
+
+resource file_types message {
+ "types" = "application/octet-stream"
+};
+
+resource vector_icon {
+ $"6E6369660604005A0500020106023F2D01ABB6552BBE233F33AF499EC5487829"
+ $"0092B8EBFF1E5AA005F102000602BA6C443B6D6F3A833D398D6D4BD8904DC08F"
+ $"00888A85FFB0B2AE05C4070207375FB843CE80445764584E54CF55C9897460D3"
+ $"F9CA8775646E6873666B69656B6A6A5F6E3E773F773C77406FC039D28E346D02"
+ $"04B454C190B454C991B454B98FC2D2B312BAD1B312CAD3B312D150C190D150B9"
+ $"8FD150C991C2D2D00ECAD3D00EBAD1D00E0A08BD13B904D0EEBB14BF76C965BC"
+ $"40C6D5B582CA40B954C275BCD4C187BAF4BE820A03BB01BE6FD12FBB02BD2EB9"
+ $"250A03BBFEC63ABF76C93BD09BBB160A03D0C0BB40B971C27CB5A4CA110A03BA"
+ $"F4BE68BCDFC17AD0D9BB1D090A000100023EE9780000000000003EA3FE41B2B1"
+ $"4532B50A010101023F28320000000000003F1EC9C24BDB36864D0A020101023E"
+ $"EFE40000000000003EE67BB99B69420C9F0A030102023F5FC20000000000003F"
+ $"3403C2809BBB8D630A010102123F5FC20000000000003F3403C2809BBB8D6301"
+ $"178522040A030103023F5FC20000000000003F3403C2809BBB8D630A04010402"
+ $"3F5FC20000000000003F3403C2809BBB8D630A030105023F5FC2000000000000"
+ $"3F3403C2809BBB8D630A050106023F5FC20000000000003F3403C2809BBB8D63"
+};
+
+resource("BEOS:default_shortcut") "S";
diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt
index e1766f5..7ecb4e8 100644
--- a/Telegram/CMakeLists.txt
+++ b/Telegram/CMakeLists.txt
@@ -91,6 +91,15 @@ PRIVATE
desktop-app::external_xxhash
)
+if (HAIKU)
+ target_link_libraries(Telegram
+ PRIVATE
+ be
+ jpeg
+ translation
+ )
+endif()
+
target_precompile_headers(Telegram PRIVATE $<$<COMPILE_LANGUAGE:CXX,OBJCXX>:${src_loc}/stdafx.h>)
nice_target_sources(Telegram ${src_loc}
PRIVATE
@@ -1510,6 +1519,17 @@ if (NOT build_winstore)
)
endif()
+if (HAIKU)
+ remove_target_sources(Telegram ${src_loc}
+ platform/linux/notifications_manager_linux_dummy.cpp
+ platform/linux/notifications_manager_linux.cpp
+ )
+ nice_target_sources(Telegram ${src_loc}
+ PRIVATE
+ platform/linux/notifications_manager_haiku.cpp
+ )
+endif()
+
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
remove_target_sources(Telegram ${src_loc}
platform/linux/linux_wayland_integration.cpp
@@ -1698,7 +1718,7 @@ else()
set(bundle_identifier "com.tdesktop.Telegram")
endif()
set(bundle_entitlements "Telegram.entitlements")
- if (LINUX AND DESKTOP_APP_USE_PACKAGED)
+ if (LINUX AND NOT HAIKU AND DESKTOP_APP_USE_PACKAGED)
set(output_name "telegram-desktop")
else()
set(output_name "Telegram")
diff --git a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp
index 51a9068..b5296bc 100644
--- a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp
+++ b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp
@@ -572,6 +572,7 @@ void FillMenu(
real->recordStartDateValue(),
handler));
}
+#ifndef Q_OS_HAIKU
if (addScreenCast) {
const auto sharing = call->isSharingScreen();
const auto toggle = [=] {
@@ -589,6 +590,7 @@ void FillMenu(
: tr::lng_group_call_screen_share_start(tr::now)),
toggle);
}
+#endif
menu->addAction(tr::lng_group_call_settings(tr::now), [=] {
if (const auto strong = weak.get()) {
showBox(Box(SettingsBox, strong));
diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h
index 82aa7c4..b566a45 100644
--- a/Telegram/SourceFiles/core/core_settings.h
+++ b/Telegram/SourceFiles/core/core_settings.h
@@ -957,7 +957,7 @@ private:
rpl::variable<float64> _dialogsWidthRatio; // per-window
rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
bool _notifyFromAll = true;
- rpl::variable<bool> _nativeWindowFrame = false;
+ rpl::variable<bool> _nativeWindowFrame = true;
rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
rpl::variable<bool> _systemDarkModeEnabled = false;
rpl::variable<WindowTitleContent> _windowTitleContent;
diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp
index fb145f7..819b335 100644
--- a/Telegram/SourceFiles/core/sandbox.cpp
+++ b/Telegram/SourceFiles/core/sandbox.cpp
@@ -235,7 +235,7 @@ void Sandbox::setupScreenScale() {
const auto screen = Sandbox::primaryScreen();
const auto dpi = screen->logicalDotsPerInch();
- const auto basePair = screen->handle()->logicalBaseDpi();
+ const auto basePair = screen->handle()->logicalDpi(); // TODO: requires a fix at the QPA level
const auto base = (basePair.first + basePair.second) * 0.5;
const auto screenScaleExact = dpi / base;
const auto screenScale = int(base::SafeRound(screenScaleExact * 20)) * 5;
@@ -258,9 +258,12 @@ Sandbox::~Sandbox() = default;
bool Sandbox::event(QEvent *e) {
if (e->type() == QEvent::Quit && !Quitting()) {
- Quit(QuitReason::QtQuitEvent);
- e->ignore();
- return false;
+ if (IsAppLaunched() && App().preventsQuit(QuitReason::QtQuitEvent)) {
+ e->ignore();
+ return false;
+ } else {
+ Quit(QuitReason::QtQuitEvent);
+ }
} else if (e->type() == QEvent::Close) {
Quit();
} else if (e->type() == DeadlockDetector::PingPongEvent::Type()) {
@@ -274,7 +277,7 @@ bool Sandbox::event(QEvent *e) {
void Sandbox::socketConnected() {
LOG(("Socket connected, this is not the first application instance, sending show command..."));
_secondInstance = true;
-
+
QString commands;
const QStringList &lst(cSendPaths());
for (QStringList::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
diff --git a/Telegram/SourceFiles/platform/linux/integration_linux.cpp b/Telegram/SourceFiles/platform/linux/integration_linux.cpp
index 1087e09..42d1427 100644
--- a/Telegram/SourceFiles/platform/linux/integration_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/integration_linux.cpp
@@ -19,13 +19,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QAbstractEventDispatcher>
#include <qpa/qwindowsysteminterface.h>
+#ifndef Q_OS_HAIKU
#include <glibmm.h>
#include <gio/gio.hpp>
#include <xdpinhibit/xdpinhibit.hpp>
+#endif
namespace Platform {
namespace {
-
+#ifdef Q_OS_HAIKU
+class LinuxIntegration final : public Integration {
+};
+#else
using namespace gi::repository;
class Application : public Gio::impl::ApplicationImpl {
@@ -286,7 +291,7 @@ void LinuxIntegration::initInhibit() {
}),
nullptr);
}
-
+#endif
} // namespace
std::unique_ptr<Integration> CreateIntegration() {
diff --git a/Telegram/SourceFiles/platform/linux/linux_xdp_open_with_dialog.cpp b/Telegram/SourceFiles/platform/linux/linux_xdp_open_with_dialog.cpp
index e75bcb4..1a78dc6 100644
--- a/Telegram/SourceFiles/platform/linux/linux_xdp_open_with_dialog.cpp
+++ b/Telegram/SourceFiles/platform/linux/linux_xdp_open_with_dialog.cpp
@@ -16,6 +16,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <glibmm.h>
#include <giomm.h>
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#include <InterfaceKit.h>
+#include <StorageKit.h>
+#include <SupportKit.h>
+#include <MimeType.h>
+#include <Roster.h>
+#endif
+
namespace Platform {
namespace File {
namespace internal {
@@ -28,6 +37,22 @@ using base::Platform::XdgActivationToken;
} // namespace
bool ShowXDPOpenWithDialog(const QString &filepath) {
+#ifdef Q_OS_HAIKU
+ BMessenger trackerMessenger("application/x-vnd.Be-TRAK");
+ if (trackerMessenger.IsValid()) {
+ update_mime_info(filepath.toUtf8().data(), false, true, false);
+
+ BEntry fileEntry(filepath.toUtf8().data());
+ entry_ref fileRef;
+ if (fileEntry.GetRef(&fileRef) == B_OK) {
+ BMessage openCommand(B_REFS_RECEIVED);
+ openCommand.AddRef("refs", &fileRef);
+ openCommand.AddInt32("launchUsingSelector", 0);
+ if (trackerMessenger.SendMessage(&openCommand) == B_OK)
+ return true;
+ }
+ }
+#else
try {
const auto connection = Gio::DBus::Connection::get_sync(
Gio::DBus::BusType::SESSION);
@@ -135,7 +160,7 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
return true;
} catch (...) {
}
-
+#endif
return false;
}
diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
index f4c400f..cad2787 100644
--- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
@@ -36,6 +36,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/linux/base_linux_xcb_utilities.h"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtCore/QSize>
#include <QtCore/QMimeData>
#include <QtGui/QWindow>
@@ -221,6 +225,12 @@ void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
SkipTaskbar(windowHandle(), mode == WorkMode::TrayOnly);
}
+#ifdef Q_OS_HAIKU
+bool MainWindow::isActiveForTrayMenu() {
+ return isVisible();
+}
+#endif
+
void MainWindow::unreadCounterChangedHook() {
updateUnityCounter();
}
diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h
index 311ed3a..21c1ad3 100644
--- a/Telegram/SourceFiles/platform/linux/main_window_linux.h
+++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h
@@ -21,6 +21,9 @@ namespace Platform {
class MainWindow : public Window::MainWindow {
public:
explicit MainWindow(not_null<Window::Controller*> controller);
+#ifdef Q_OS_HAIKU
+ bool isActiveForTrayMenu() override;
+#endif
~MainWindow();
void updateWindowIcon() override;
diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp
new file mode 100644
index 0000000..21935f0
--- /dev/null
+++ b/Telegram/SourceFiles/platform/linux/notifications_manager_haiku.cpp
@@ -0,0 +1,294 @@
+/*
+This file is part of Telegram Desktop for Haiku,
+
+For license and copyright information please follow this link:
+https://github.com/desktop-app/legal/blob/master/LEGAL
+
+Copyright (c) 2018-2021 Gerasim Troeglazov, 3dEyes@gmail.com
+*/
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "platform/linux/notifications_manager_linux.h"
+
+#include "base/options.h"
+#include "base/platform/base_platform_info.h"
+#include "core/application.h"
+#include "core/sandbox.h"
+#include "core/core_settings.h"
+#include "data/data_forum_topic.h"
+#include "history/history.h"
+#include "history/history_item.h"
+#include "ui/empty_userpic.h"
+#include "main/main_session.h"
+#include "lang/lang_keys.h"
+#include "base/weak_ptr.h"
+#include "window/notifications_utilities.h"
+#include "styles/style_window.h"
+
+#define USE_HAIKU_UINT64
+#include "base/haiku_types.h"
+
+#include <AppKit.h>
+#include <SupportKit.h>
+#include <Notification.h>
+#include <InterfaceKit.h>
+#include <TranslationUtils.h>
+#include <OS.h>
+
+#define NOTIFY_MESSAGE_DEEP 16
+#define NOTIFY_PORT_NAME "tg_notify"
+#define NOTIFY_GATE_NAME "/bin/qnotify"
+#define NOTIFY_MESSAGE 'QNTF'
+
+#include <QObject>
+#include <QString>
+#include <QStringList>
+#include <QTimer>
+
+namespace Platform {
+namespace Notifications {
+
+bool Supported() {
+ return true;
+}
+
+void Finish() {
+}
+
+bool SkipAudio() {
+ return false;
+}
+
+bool SkipToast() {
+ return false;
+}
+
+bool SkipFlashBounce() {
+ return false;
+}
+
+bool SkipAudioForCustom() {
+ return false;
+}
+
+bool SkipToastForCustom() {
+ return false;
+}
+
+bool SkipFlashBounceForCustom() {
+ return false;
+}
+
+bool Enforced() {
+ return false;
+}
+
+bool ByDefault() {
+ return true;
+}
+
+bool WaitForInputForCustom() {
+ return false;
+}
+
+void MaybePlaySoundForCustom(Fn<void()> playSound) {
+ playSound();
+}
+
+void MaybeFlashBounceForCustom(Fn<void()> flashBounce) {
+ flashBounce();
+}
+
+void Create(Window::Notifications::System *system) {
+ if (Core::App().settings().nativeNotifications() && Supported()) {
+ auto result = std::make_unique<Manager>(system);
+ system->setManager(std::move(result));
+ return;
+ }
+ system->setManager(nullptr);
+}
+
+class Manager::Private : public QObject {
+
+public:
+ explicit Private(not_null<Manager*> manager);
+
+ void showNotification(
+ not_null<PeerData*> peer,
+ MsgId topicRootId,
+ Ui::PeerUserpicView &userpicView,
+ MsgId msgId,
+ const QString &title,
+ const QString &subtitle,
+ const QString &msg,
+ DisplayOptions options);
+
+ ~Private();
+
+private:
+ void CheckNotificationAction();
+
+ QTimer *_checkNotificationTimer;
+ const not_null<Manager*> _manager;
+ int32 _portId;
+};
+
+Manager::Private::Private(not_null<Manager*> manager)
+: _manager(manager) {
+ _portId = create_port(NOTIFY_MESSAGE_DEEP, NOTIFY_PORT_NAME);
+ _checkNotificationTimer = new QTimer(this);
+ connect(_checkNotificationTimer, &QTimer::timeout, this, &Manager::Private::CheckNotificationAction);
+ _checkNotificationTimer->start(250);
+}
+
+Manager::Private::~Private() {
+ delete _checkNotificationTimer;
+ if (_portId > 0)
+ delete_port(_portId);
+}
+
+void Manager::Private::CheckNotificationAction()
+{
+ ssize_t msgSize;
+
+ do {
+ msgSize = port_buffer_size_etc(_portId, B_RELATIVE_TIMEOUT, 0);
+ } while (msgSize == B_INTERRUPTED);
+
+ if (msgSize < 0)
+ return;
+
+ char* buffer = new(std::nothrow) char[msgSize];
+ if (!buffer)
+ return;
+
+ int32 code;
+ status_t result;
+ do {
+ result = read_port(_portId, &code, buffer, msgSize);
+ } while (result == B_INTERRUPTED);
+
+ BMessage message;
+
+ if (result < 0 || code != NOTIFY_MESSAGE) {
+ delete[] buffer;
+ return;
+ }
+
+ if (message.Unflatten(buffer) == B_OK) {
+ uint64 sessionId = message.GetUInt64("session", 0);
+ uint64 peerId = message.GetUInt64("peer", 0);
+ int64 messageId = message.GetInt64("message", 0);
+
+ const auto key = ContextId{
+ .sessionId = sessionId,
+ .peerId = PeerId(peerId),
+ .topicRootId = 0,
+ };
+ const auto notificationId = NotificationId{ .contextId = key, .msgId = messageId };
+
+ crl::on_main(this, [=] {
+ _manager->notificationActivated(notificationId);
+ });
+ }
+ delete[] buffer;
+}
+
+void Manager::Private::showNotification(
+ not_null<PeerData*> peer,
+ MsgId topicRootId,
+ Ui::PeerUserpicView &userpicView,
+ MsgId msgId,
+ const QString &title,
+ const QString &subtitle,
+ const QString &msg,
+ DisplayOptions options) {
+ auto titleText = title;
+ auto subtitleText = subtitle;
+ auto msgText = msg;
+
+ QString args = QString(
+ "mode:port "
+ "target:tg_notify "
+ "session:uint64:%1 "
+ "peer:uint64:%2 "
+ "message:int64:%3")
+ .arg(peer->session().uniqueId()).arg(peer->id.value).arg(msgId.bare);
+
+ BNotification notify(B_INFORMATION_NOTIFICATION);
+ notify.SetGroup("Telegram");
+ notify.SetTitle(titleText.toUtf8().data());
+ notify.SetContent(msgText.toUtf8().data());
+ entry_ref ref;
+ BEntry entry(NOTIFY_GATE_NAME);
+ entry.GetRef(&ref);
+ notify.SetOnClickFile(&ref);
+ notify.AddOnClickArg(BString(args.toUtf8().data()));
+
+ if (!options.hideNameAndPhoto) {
+ QImage userpic = Window::Notifications::GenerateUserpic(peer, userpicView);
+ BBitmap *icon = new BBitmap(BRect(0, 0, userpic.width() - 1, userpic.height() - 1), B_RGBA32);
+ icon->SetBits((void*)userpic.bits(), userpic.sizeInBytes(), 0, B_RGBA32);
+ notify.SetIcon(icon);
+ delete icon;
+ }
+
+ notify.Send();
+}
+
+Manager::Manager(not_null<Window::Notifications::System*> system)
+: NativeManager(system)
+, _private(std::make_unique<Private>(this)) {
+}
+
+Manager::~Manager() = default;
+
+void Manager::doShowNativeNotification(
+ not_null<PeerData*> peer,
+ MsgId topicRootId,
+ Ui::PeerUserpicView &userpicView,
+ MsgId msgId,
+ const QString &title,
+ const QString &subtitle,
+ const QString &msg,
+ DisplayOptions options) {
+ _private->showNotification(
+ peer,
+ topicRootId,
+ userpicView,
+ msgId,
+ title,
+ subtitle,
+ msg,
+ options);
+}
+
+void Manager::doClearAllFast() { }
+
+void Manager::doClearFromItem(not_null<HistoryItem*> item) { }
+
+void Manager::doClearFromHistory(not_null<History*> history) { }
+
+void Manager::doClearFromSession(not_null<Main::Session*> session) { }
+
+void Manager::doClearFromTopic(not_null<Data::ForumTopic*> topic) { }
+
+bool Manager::doSkipToast() const {
+ return false;
+}
+
+void Manager::doMaybePlaySound(Fn<void()> playSound) {
+ playSound();
+}
+
+void Manager::doMaybeFlashBounce(Fn<void()> flashBounce) {
+ flashBounce();
+}
+
+} // namespace Notifications
+} // namespace Platform
diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
index a63c54b..cb5aa32 100644
--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
@@ -27,6 +27,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/linux/base_linux_xcb_utilities.h"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtWidgets/QApplication>
#include <QtWidgets/QSystemTrayIcon>
#include <QtCore/QStandardPaths>
@@ -53,6 +57,33 @@ using Platform::internal::WaylandIntegration;
namespace Platform {
namespace {
+
+#ifdef Q_OS_HAIKU
+void HaikuAutostart(bool start) {
+ const auto home = QDir::homePath();
+ if (home.isEmpty()) {
+ return;
+ }
+
+ QFile file(home + "/config/settings/boot/launch/telegram-desktop");
+ if (start) {
+ if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&file);
+ out
+ << "#!/bin/bash" << Qt::endl
+ << "cd /system/apps" << Qt::endl
+ << "./Telegram -autostart" << " &" << Qt::endl;
+ file.close();
+ file.setPermissions(file.permissions()
+ | QFileDevice::ExeOwner
+ | QFileDevice::ExeGroup
+ | QFileDevice::ExeOther);
+ }
+ } else {
+ file.remove();
+ }
+}
+#endif // Q_OS_HAIKU
void PortalAutostart(bool enabled, Fn<void(bool)> done) {
if (cExeName().isEmpty()) {
@@ -486,6 +517,10 @@ bool AutostartSupported() {
}
void AutostartToggle(bool enabled, Fn<void(bool)> done) {
+#ifdef Q_OS_HAIKU
+ HaikuAutostart(enabled);
+ return;
+#else
if (KSandbox::isFlatpak()) {
PortalAutostart(enabled, done);
return;
@@ -513,6 +548,7 @@ void AutostartToggle(bool enabled, Fn<void(bool)> done) {
if (done) {
done(enabled && success);
}
+#endif
}
bool AutostartSkip() {
@@ -578,7 +614,11 @@ QString psAppDataPath() {
}
}
+#ifdef Q_OS_HAIKU
+ return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + '/';
+#else
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/';
+#endif
}
void psDoCleanup() {
@@ -706,6 +746,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
add("mate-volume-control");
}
}
+ add("Media");
add("pavucontrol-qt");
add("pavucontrol");
add("alsamixergui");
diff --git a/Telegram/SourceFiles/platform/linux/tray_linux.cpp b/Telegram/SourceFiles/platform/linux/tray_linux.cpp
index a9e1de3..291eaa7 100644
--- a/Telegram/SourceFiles/platform/linux/tray_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/tray_linux.cpp
@@ -285,7 +285,7 @@ void Tray::createIcon() {
const auto showXEmbed = [=] {
_aboutToShowRequests.fire({});
InvokeQueued(_menuXEmbed.get(), [=] {
- _menuXEmbed->popup(QCursor::pos());
+// _menuXEmbed->popup(QCursor::pos());
});
};
diff --git a/Telegram/ThirdParty/tgcalls/tgcalls/MediaManager.cpp b/Telegram/ThirdParty/tgcalls/tgcalls/MediaManager.cpp
index 88bdd22..6431130 100644
--- a/Telegram/ThirdParty/tgcalls/tgcalls/MediaManager.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/MediaManager.cpp
@@ -1038,7 +1038,7 @@ void MediaManager::fillCallStats(CallStats &callStats) {
}
void MediaManager::setAudioInputDevice(std::string id) {
-#if defined(WEBRTC_IOS)
+#if defined(WEBRTC_IOS) || defined(__HAIKU__)
#else
SetAudioInputDeviceById(_audioDeviceModule.get(), id);
#endif
diff --git a/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp b/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp
index eaf2172..2e982f8 100644
--- a/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp
@@ -2846,7 +2846,7 @@ public:
}
void setAudioOutputDevice(const std::string &id) {
-#ifndef WEBRTC_IOS
+#if !defined(WEBRTC_IOS) && !defined(__HAIKU__)
_threads->getWorkerThread()->BlockingCall([&] {
SetAudioOutputDeviceById(_audioDeviceModule.get(), id);
});
@@ -2854,7 +2854,7 @@ public:
}
void setAudioInputDevice(const std::string &id) {
-#ifndef WEBRTC_IOS
+#if !defined(WEBRTC_IOS) && !defined(__HAIKU__)
_threads->getWorkerThread()->BlockingCall([&] {
SetAudioInputDeviceById(_audioDeviceModule.get(), id);
});
diff --git a/Telegram/lib_base/base/haiku_types.h b/Telegram/lib_base/base/haiku_types.h
new file mode 100644
index 0000000..3a57ce2
--- /dev/null
+++ b/Telegram/lib_base/base/haiku_types.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#ifdef Q_OS_HAIKU
+
+#define _SUPPORT_DEFS_H
+
+#ifdef __x86_64__
+#define int64 __haiku_int64
+#ifdef USE_HAIKU_UINT64
+#define uint64 __haiku_uint64
+#endif
+#else
+#define int32 __haiku_int32
+#define uint32 __haiku_uint32
+#endif
+
+typedef int32 status_t;
+typedef uint32 type_code;
+typedef uint32 perform_code;
+
+typedef int64 bigtime_t;
+typedef int64 nanotime_t;
+
+#endif
diff --git a/Telegram/lib_base/base/platform/linux/base_file_utilities_linux.cpp b/Telegram/lib_base/base/platform/linux/base_file_utilities_linux.cpp
index 00cae96..8fc5f52 100644
--- a/Telegram/lib_base/base/platform/linux/base_file_utilities_linux.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_file_utilities_linux.cpp
@@ -25,8 +25,58 @@
#include <stdio.h>
#include <fcntl.h>
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#include <AppKit.h>
+#include <StorageKit.h>
+#endif
+
namespace base::Platform {
namespace {
+
+#ifdef Q_OS_HAIKU
+bool HaikuShowInFolder(const QString &filepath) {
+ try {
+ BMessenger trackerMessenger("application/x-vnd.Be-TRAK");
+ if (!trackerMessenger.IsValid())
+ return false;
+
+ BEntry fileEntry(filepath.toUtf8().data());
+ entry_ref fileRef;
+ if (fileEntry.GetRef(&fileRef) != B_OK)
+ return false;
+
+ if (!fileEntry.Exists())
+ return false;
+
+ BEntry folderEntry;
+ if (fileEntry.GetParent(&folderEntry) != B_OK)
+ return false;
+
+ entry_ref folderRef;
+ if (folderEntry.GetRef(&folderRef) != B_OK)
+ return false;
+
+ BMessage openCommand(B_REFS_RECEIVED);
+ openCommand.AddRef("refs", &folderRef);
+ node_ref fileNodeRef;
+ if (fileEntry.GetNodeRef(&fileNodeRef) == B_OK) {
+ openCommand.AddData("nodeRefToSelect", B_RAW_TYPE,
+ static_cast<void*>(&fileNodeRef), sizeof(node_ref));
+ }
+ if (trackerMessenger.SendMessage(&openCommand) == B_OK) {
+ snooze(300000);
+ BMessage selectCommand('Tsel');
+ selectCommand.AddRef("refs", &fileRef);
+ trackerMessenger.SendMessage(&selectCommand);
+ return true;
+ }
+ } catch (...) {
+ }
+
+ return false;
+}
+#endif
void PortalShowInFolder(const QString &filepath, Fn<void()> fail) {
const auto connection = [] {
@@ -121,12 +171,19 @@ void DBusShowInFolder(const QString &filepath, Fn<void()> fail) {
} // namespace
void ShowInFolder(const QString &filepath) {
+#ifdef Q_OS_HAIKU
+ if (!HaikuShowInFolder(filepath)) {
+ QDesktopServices::openUrl(
+ QUrl::fromLocalFile(QFileInfo(filepath).absolutePath()));
+ }
+#else
DBusShowInFolder(filepath, [=] {
PortalShowInFolder(filepath, [=] {
QDesktopServices::openUrl(
QUrl::fromLocalFile(QFileInfo(filepath).absolutePath()));
});
});
+#endif
}
QString CurrentExecutablePath(int argc, char *argv[]) {
diff --git a/Telegram/lib_base/base/platform/linux/base_info_linux.cpp b/Telegram/lib_base/base/platform/linux/base_info_linux.cpp
index a40477a..8079f1d 100644
--- a/Telegram/lib_base/base/platform/linux/base_info_linux.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_info_linux.cpp
@@ -307,6 +307,7 @@ bool IsX11() {
}
bool IsWayland() {
+#ifndef Q_OS_HAIKU
if (!QGuiApplication::instance()) {
static const auto result = []() -> bool {
struct wl_display *(*wl_display_connect)(const char *name);
@@ -324,6 +325,7 @@ bool IsWayland() {
}();
return result;
}
+#endif
static const auto result
= QGuiApplication::platformName().startsWith("wayland");
return result;
diff --git a/Telegram/lib_base/base/platform/linux/base_last_input_linux.cpp b/Telegram/lib_base/base/platform/linux/base_last_input_linux.cpp
index b7f1225..7fc8df3 100644
--- a/Telegram/lib_base/base/platform/linux/base_last_input_linux.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_last_input_linux.cpp
@@ -18,6 +18,11 @@
#include <glibmm.h>
#include <giomm.h>
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#include <InterfaceDefs.h>
+#endif
+
namespace base::Platform {
namespace {
@@ -180,9 +185,23 @@ std::optional<crl::time> MutterDBusLastUserInputTime() {
return std::nullopt;
}
+#ifdef Q_OS_HAIKU
+std::optional<crl::time> HaikuLastUserInputTime() {
+ const auto idle = idle_time() / 1000;
+ return (crl::now() - static_cast<crl::time>(idle));
+}
+#endif
+
} // namespace
std::optional<crl::time> LastUserInputTime() {
+#ifdef Q_OS_HAIKU
+ const auto haikuResult = HaikuLastUserInputTime();
+ if (haikuResult.has_value()) {
+ return haikuResult;
+ }
+#endif
+
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (::Platform::IsX11()) {
const auto xcbResult = XCBLastUserInputTime();
diff --git a/Telegram/lib_base/base/platform/linux/base_linux_xdp_utilities.cpp b/Telegram/lib_base/base/platform/linux/base_linux_xdp_utilities.cpp
index fcf1179..37c857e 100644
--- a/Telegram/lib_base/base/platform/linux/base_linux_xdp_utilities.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_linux_xdp_utilities.cpp
@@ -10,6 +10,10 @@
#include <giomm.h>
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
diff --git a/Telegram/lib_base/base/platform/linux/base_power_save_blocker_linux.cpp b/Telegram/lib_base/base/platform/linux/base_power_save_blocker_linux.cpp
index 8026c64..0fdec60 100644
--- a/Telegram/lib_base/base/platform/linux/base_power_save_blocker_linux.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_power_save_blocker_linux.cpp
@@ -17,6 +17,10 @@
#include "base/platform/linux/base_linux_xcb_utilities.h"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtGui/QWindow>
#include <giomm.h>
diff --git a/Telegram/lib_base/base/platform/linux/base_url_scheme_linux.cpp b/Telegram/lib_base/base/platform/linux/base_url_scheme_linux.cpp
index 19da0e8..0873fcb 100644
--- a/Telegram/lib_base/base/platform/linux/base_url_scheme_linux.cpp
+++ b/Telegram/lib_base/base/platform/linux/base_url_scheme_linux.cpp
@@ -9,6 +9,10 @@
#include "base/integration.h"
#include "base/debug_log.h"
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtGui/QGuiApplication>
#include <QtWidgets/QWidget>
diff --git a/Telegram/lib_spellcheck/spellcheck/third_party/language_cld3.cpp b/Telegram/lib_spellcheck/spellcheck/third_party/language_cld3.cpp
index efbfb72..9c82321 100644
--- a/Telegram/lib_spellcheck/spellcheck/third_party/language_cld3.cpp
+++ b/Telegram/lib_spellcheck/spellcheck/third_party/language_cld3.cpp
@@ -4,6 +4,10 @@
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include "spellcheck/third_party/language_cld3.h"
#include "nnet_language_identifier.h"
diff --git a/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp b/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp
index eda2916..24ec6ea 100644
--- a/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp
+++ b/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp
@@ -413,7 +413,7 @@ void ShowXCBWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
-#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) && !defined(Q_OS_HAIKU)
void ShowWaylandWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
static const auto wl_proxy_marshal_array = [] {
void (*result)(
@@ -600,7 +600,7 @@ void UnsetWindowMargins(not_null<QWidget*> widget) {
}
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
-#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) && !defined(Q_OS_HAIKU)
if (::Platform::IsWayland()) {
ShowWaylandWindowMenu(widget, point);
return;
diff --git a/Telegram/lib_ui/ui/ui_utility.cpp b/Telegram/lib_ui/ui/ui_utility.cpp
index 26b284f..5aa150c 100644
--- a/Telegram/lib_ui/ui/ui_utility.cpp
+++ b/Telegram/lib_ui/ui/ui_utility.cpp
@@ -9,6 +9,10 @@
#include "ui/platform/ui_platform_utility.h"
#include "ui/style/style_core.h"
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtWidgets/QApplication>
#include <QtGui/QWindow>
#include <QtGui/QtEvents>
diff --git a/Telegram/lib_ui/ui/widgets/popup_menu.cpp b/Telegram/lib_ui/ui/widgets/popup_menu.cpp
index 3a79351..3c58540 100644
--- a/Telegram/lib_ui/ui/widgets/popup_menu.cpp
+++ b/Telegram/lib_ui/ui/widgets/popup_menu.cpp
@@ -18,6 +18,10 @@
#include "base/invoke_queued.h"
#include "base/platform/base_platform_info.h"
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include <QtGui/QtEvents>
#include <QtGui/QPainter>
#include <QtGui/QScreen>
diff --git a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp
index e51bffa..733f6b5 100644
--- a/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp
+++ b/Telegram/lib_webrtc/webrtc/details/webrtc_openal_adm.cpp
@@ -4,6 +4,11 @@
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
+
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include "webrtc/details/webrtc_openal_adm.h"
#include "base/timer.h"
diff --git a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp
index 6e19fcf..e7a6990 100644
--- a/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp
+++ b/Telegram/lib_webrtc/webrtc/webrtc_audio_input_tester.cpp
@@ -4,6 +4,11 @@
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
+
+#ifdef Q_OS_HAIKU
+#include <base/haiku_types.h>
+#endif
+
#include "webrtc/webrtc_audio_input_tester.h"
#include "webrtc/webrtc_device_common.h"
diff --git a/cmake/external/CMakeLists.txt b/cmake/external/CMakeLists.txt
index 34181cc..85ee489 100644
--- a/cmake/external/CMakeLists.txt
+++ b/cmake/external/CMakeLists.txt
@@ -18,7 +18,7 @@ if (add_cld3_library)
add_checked_subdirectory(cld3)
endif()
add_checked_subdirectory(crash_reports)
-if (LINUX)
+if (LINUX AND NOT HAIKU)
add_checked_subdirectory(dispatch)
endif()
add_checked_subdirectory(expected)
--
2.42.1