mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Eliminate ifndefs in notifications_manager_linux
This commit is contained in:
parent
0c37990ccd
commit
3b7d5d3c80
4 changed files with 70 additions and 35 deletions
|
@ -1114,6 +1114,12 @@ if (LINUX AND DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
||||||
remove_target_sources(Telegram ${src_loc}
|
remove_target_sources(Telegram ${src_loc}
|
||||||
platform/linux/linux_gsd_media_keys.cpp
|
platform/linux/linux_gsd_media_keys.cpp
|
||||||
platform/linux/linux_gsd_media_keys.h
|
platform/linux/linux_gsd_media_keys.h
|
||||||
|
platform/linux/notifications_manager_linux.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
nice_target_sources(Telegram ${src_loc}
|
||||||
|
PRIVATE
|
||||||
|
platform/linux/notifications_manager_linux_dummy.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
#include <QtCore/QVersionNumber>
|
#include <QtCore/QVersionNumber>
|
||||||
#include <QtDBus/QDBusConnection>
|
#include <QtDBus/QDBusConnection>
|
||||||
#include <QtDBus/QDBusMessage>
|
#include <QtDBus/QDBusMessage>
|
||||||
|
@ -29,12 +28,9 @@ extern "C" {
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#define signals public
|
#define signals public
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace Notifications {
|
namespace Notifications {
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDBusTimeout = 30000;
|
constexpr auto kDBusTimeout = 30000;
|
||||||
|
@ -615,16 +611,13 @@ void NotificationData::notificationReplied(uint id, const QString &text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
bool SkipAudio() {
|
bool SkipAudio() {
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
if (Supported()
|
if (Supported()
|
||||||
&& GetCapabilities().contains(qsl("inhibitions"))
|
&& GetCapabilities().contains(qsl("inhibitions"))
|
||||||
&& !InhibitedNotSupported) {
|
&& !InhibitedNotSupported) {
|
||||||
return Inhibited();
|
return Inhibited();
|
||||||
}
|
}
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -638,18 +631,12 @@ bool SkipFlashBounce() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Supported() {
|
bool Supported() {
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
return NotificationsSupported;
|
return NotificationsSupported;
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Window::Notifications::Manager> Create(
|
std::unique_ptr<Window::Notifications::Manager> Create(
|
||||||
Window::Notifications::System *system) {
|
Window::Notifications::System *system) {
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
GetSupported();
|
GetSupported();
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
if ((Core::App().settings().nativeNotifications() && Supported())
|
if ((Core::App().settings().nativeNotifications() && Supported())
|
||||||
|| IsWayland()) {
|
|| IsWayland()) {
|
||||||
|
@ -659,27 +646,6 @@ std::unique_ptr<Window::Notifications::Manager> Create(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
class Manager::Private {
|
|
||||||
public:
|
|
||||||
using Type = Window::Notifications::CachedUserpics::Type;
|
|
||||||
explicit Private(not_null<Manager*> manager, Type type) {}
|
|
||||||
|
|
||||||
void showNotification(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
std::shared_ptr<Data::CloudImageView> &userpicView,
|
|
||||||
MsgId msgId,
|
|
||||||
const QString &title,
|
|
||||||
const QString &subtitle,
|
|
||||||
const QString &msg,
|
|
||||||
bool hideNameAndPhoto,
|
|
||||||
bool hideReplyButton) {}
|
|
||||||
void clearAll() {}
|
|
||||||
void clearFromHistory(not_null<History*> history) {}
|
|
||||||
void clearFromSession(not_null<Main::Session*> session) {}
|
|
||||||
void clearNotification(NotificationId id) {}
|
|
||||||
};
|
|
||||||
#else // DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
class Manager::Private {
|
class Manager::Private {
|
||||||
public:
|
public:
|
||||||
using Type = Window::Notifications::CachedUserpics::Type;
|
using Type = Window::Notifications::CachedUserpics::Type;
|
||||||
|
@ -866,7 +832,6 @@ void Manager::Private::clearNotification(NotificationId id) {
|
||||||
Manager::Private::~Private() {
|
Manager::Private::~Private() {
|
||||||
clearAll();
|
clearAll();
|
||||||
}
|
}
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
Manager::Manager(not_null<Window::Notifications::System*> system)
|
Manager::Manager(not_null<Window::Notifications::System*> system)
|
||||||
: NativeManager(system)
|
: NativeManager(system)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#include "platform/linux/notifications_manager_linux.h"
|
||||||
|
|
||||||
|
namespace Platform {
|
||||||
|
namespace Notifications {
|
||||||
|
|
||||||
|
bool SkipAudio() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SkipToast() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SkipFlashBounce() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Supported() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Window::Notifications::Manager> Create(
|
||||||
|
Window::Notifications::System *system) {
|
||||||
|
if (IsWayland()) {
|
||||||
|
return std::make_unique<Window::Notifications::DummyManager>(system);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Notifications
|
||||||
|
} // namespace Platform
|
|
@ -248,6 +248,30 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DummyManager : public NativeManager {
|
||||||
|
public:
|
||||||
|
using NativeManager::NativeManager;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void doShowNativeNotification(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
std::shared_ptr<Data::CloudImageView> &userpicView,
|
||||||
|
MsgId msgId,
|
||||||
|
const QString &title,
|
||||||
|
const QString &subtitle,
|
||||||
|
const QString &msg,
|
||||||
|
bool hideNameAndPhoto,
|
||||||
|
bool hideReplyButton) override {
|
||||||
|
}
|
||||||
|
void doClearAllFast() override {
|
||||||
|
}
|
||||||
|
void doClearFromHistory(not_null<History*> history) override {
|
||||||
|
}
|
||||||
|
void doClearFromSession(not_null<Main::Session*> session) override {
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
QString WrapFromScheduled(const QString &text);
|
QString WrapFromScheduled(const QString &text);
|
||||||
|
|
||||||
} // namespace Notifications
|
} // namespace Notifications
|
||||||
|
|
Loading…
Add table
Reference in a new issue