mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Attempt to fix build with Clang on Linux.
This commit is contained in:
parent
a757e07c3a
commit
99f4b93745
1 changed files with 14 additions and 12 deletions
|
@ -55,6 +55,10 @@ bool ServiceRegistered = false;
|
||||||
ServerInformation CurrentServerInformation;
|
ServerInformation CurrentServerInformation;
|
||||||
std::vector<Glib::ustring> CurrentCapabilities;
|
std::vector<Glib::ustring> CurrentCapabilities;
|
||||||
|
|
||||||
|
[[nodiscard]] bool HasCapability(const char *value) {
|
||||||
|
return ranges::contains(CurrentCapabilities, value, &Glib::ustring::raw);
|
||||||
|
}
|
||||||
|
|
||||||
void Noexcept(Fn<void()> callback, Fn<void()> failed = nullptr) noexcept {
|
void Noexcept(Fn<void()> callback, Fn<void()> failed = nullptr) noexcept {
|
||||||
try {
|
try {
|
||||||
callback();
|
callback();
|
||||||
|
@ -445,7 +449,6 @@ bool NotificationData::init(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
const auto &capabilities = CurrentCapabilities;
|
|
||||||
|
|
||||||
const auto signalEmitted = crl::guard(weak, [=](
|
const auto signalEmitted = crl::guard(weak, [=](
|
||||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||||
|
@ -503,7 +506,7 @@ bool NotificationData::init(
|
||||||
|
|
||||||
_imageKey = GetImageKey(CurrentServerInformation.specVersion);
|
_imageKey = GetImageKey(CurrentServerInformation.specVersion);
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "body-markup")) {
|
if (HasCapability("body-markup")) {
|
||||||
_title = title.toStdString();
|
_title = title.toStdString();
|
||||||
|
|
||||||
_body = subtitle.isEmpty()
|
_body = subtitle.isEmpty()
|
||||||
|
@ -519,7 +522,7 @@ bool NotificationData::init(
|
||||||
_body = msg.toStdString();
|
_body = msg.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "actions")) {
|
if (HasCapability("actions")) {
|
||||||
_actions.push_back("default");
|
_actions.push_back("default");
|
||||||
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
|
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
|
||||||
|
|
||||||
|
@ -530,7 +533,7 @@ bool NotificationData::init(
|
||||||
tr::lng_context_mark_read(tr::now).toStdString());
|
tr::lng_context_mark_read(tr::now).toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "inline-reply")
|
if (HasCapability("inline-reply")
|
||||||
&& !options.hideReplyButton) {
|
&& !options.hideReplyButton) {
|
||||||
_actions.push_back("inline-reply");
|
_actions.push_back("inline-reply");
|
||||||
_actions.push_back(
|
_actions.push_back(
|
||||||
|
@ -560,13 +563,13 @@ bool NotificationData::init(
|
||||||
kObjectPath);
|
kObjectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "action-icons")) {
|
if (HasCapability("action-icons")) {
|
||||||
_hints["action-icons"] = Glib::create_variant(true);
|
_hints["action-icons"] = Glib::create_variant(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// suppress system sound if telegram sound activated,
|
// suppress system sound if telegram sound activated,
|
||||||
// otherwise use system sound
|
// otherwise use system sound
|
||||||
if (ranges::contains(capabilities, "sound")) {
|
if (HasCapability("sound")) {
|
||||||
if (Core::App().settings().soundNotify()) {
|
if (Core::App().settings().soundNotify()) {
|
||||||
_hints["suppress-sound"] = Glib::create_variant(true);
|
_hints["suppress-sound"] = Glib::create_variant(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -576,7 +579,7 @@ bool NotificationData::init(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "x-canonical-append")) {
|
if (HasCapability("x-canonical-append")) {
|
||||||
_hints["x-canonical-append"] = Glib::create_variant(
|
_hints["x-canonical-append"] = Glib::create_variant(
|
||||||
Glib::ustring("true"));
|
Glib::ustring("true"));
|
||||||
}
|
}
|
||||||
|
@ -822,7 +825,7 @@ bool ByDefault() {
|
||||||
// (no, using sound capability is not a way)
|
// (no, using sound capability is not a way)
|
||||||
"inhibitions",
|
"inhibitions",
|
||||||
}, [](const auto *capability) {
|
}, [](const auto *capability) {
|
||||||
return ranges::contains(CurrentCapabilities, capability);
|
return HasCapability(capability);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,7 +918,6 @@ private:
|
||||||
Manager::Private::Private(not_null<Manager*> manager)
|
Manager::Private::Private(not_null<Manager*> manager)
|
||||||
: _manager(manager) {
|
: _manager(manager) {
|
||||||
const auto &serverInformation = CurrentServerInformation;
|
const auto &serverInformation = CurrentServerInformation;
|
||||||
const auto &capabilities = CurrentCapabilities;
|
|
||||||
|
|
||||||
if (!serverInformation.name.empty()) {
|
if (!serverInformation.name.empty()) {
|
||||||
LOG(("Notification daemon product name: %1")
|
LOG(("Notification daemon product name: %1")
|
||||||
|
@ -937,17 +939,17 @@ Manager::Private::Private(not_null<Manager*> manager)
|
||||||
.arg(serverInformation.specVersion.toString()));
|
.arg(serverInformation.specVersion.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!capabilities.empty()) {
|
if (!CurrentCapabilities.empty()) {
|
||||||
LOG(("Notification daemon capabilities: %1").arg(
|
LOG(("Notification daemon capabilities: %1").arg(
|
||||||
ranges::fold_left(
|
ranges::fold_left(
|
||||||
capabilities,
|
CurrentCapabilities,
|
||||||
"",
|
"",
|
||||||
[](const Glib::ustring &a, const Glib::ustring &b) {
|
[](const Glib::ustring &a, const Glib::ustring &b) {
|
||||||
return a + (a.empty() ? "" : ", ") + b;
|
return a + (a.empty() ? "" : ", ") + b;
|
||||||
}).c_str()));
|
}).c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ranges::contains(capabilities, "inhibitions")) {
|
if (HasCapability("inhibitions")) {
|
||||||
Noexcept([&] {
|
Noexcept([&] {
|
||||||
_dbusConnection = Gio::DBus::Connection::get_sync(
|
_dbusConnection = Gio::DBus::Connection::get_sync(
|
||||||
Gio::DBus::BusType::SESSION);
|
Gio::DBus::BusType::SESSION);
|
||||||
|
|
Loading…
Add table
Reference in a new issue