mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +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;
|
||||
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 {
|
||||
try {
|
||||
callback();
|
||||
|
@ -445,7 +449,6 @@ bool NotificationData::init(
|
|||
}
|
||||
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto &capabilities = CurrentCapabilities;
|
||||
|
||||
const auto signalEmitted = crl::guard(weak, [=](
|
||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
|
@ -503,7 +506,7 @@ bool NotificationData::init(
|
|||
|
||||
_imageKey = GetImageKey(CurrentServerInformation.specVersion);
|
||||
|
||||
if (ranges::contains(capabilities, "body-markup")) {
|
||||
if (HasCapability("body-markup")) {
|
||||
_title = title.toStdString();
|
||||
|
||||
_body = subtitle.isEmpty()
|
||||
|
@ -519,7 +522,7 @@ bool NotificationData::init(
|
|||
_body = msg.toStdString();
|
||||
}
|
||||
|
||||
if (ranges::contains(capabilities, "actions")) {
|
||||
if (HasCapability("actions")) {
|
||||
_actions.push_back("default");
|
||||
_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());
|
||||
}
|
||||
|
||||
if (ranges::contains(capabilities, "inline-reply")
|
||||
if (HasCapability("inline-reply")
|
||||
&& !options.hideReplyButton) {
|
||||
_actions.push_back("inline-reply");
|
||||
_actions.push_back(
|
||||
|
@ -560,13 +563,13 @@ bool NotificationData::init(
|
|||
kObjectPath);
|
||||
}
|
||||
|
||||
if (ranges::contains(capabilities, "action-icons")) {
|
||||
if (HasCapability("action-icons")) {
|
||||
_hints["action-icons"] = Glib::create_variant(true);
|
||||
}
|
||||
|
||||
// suppress system sound if telegram sound activated,
|
||||
// otherwise use system sound
|
||||
if (ranges::contains(capabilities, "sound")) {
|
||||
if (HasCapability("sound")) {
|
||||
if (Core::App().settings().soundNotify()) {
|
||||
_hints["suppress-sound"] = Glib::create_variant(true);
|
||||
} 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(
|
||||
Glib::ustring("true"));
|
||||
}
|
||||
|
@ -822,7 +825,7 @@ bool ByDefault() {
|
|||
// (no, using sound capability is not a way)
|
||||
"inhibitions",
|
||||
}, [](const auto *capability) {
|
||||
return ranges::contains(CurrentCapabilities, capability);
|
||||
return HasCapability(capability);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -915,7 +918,6 @@ private:
|
|||
Manager::Private::Private(not_null<Manager*> manager)
|
||||
: _manager(manager) {
|
||||
const auto &serverInformation = CurrentServerInformation;
|
||||
const auto &capabilities = CurrentCapabilities;
|
||||
|
||||
if (!serverInformation.name.empty()) {
|
||||
LOG(("Notification daemon product name: %1")
|
||||
|
@ -937,17 +939,17 @@ Manager::Private::Private(not_null<Manager*> manager)
|
|||
.arg(serverInformation.specVersion.toString()));
|
||||
}
|
||||
|
||||
if (!capabilities.empty()) {
|
||||
if (!CurrentCapabilities.empty()) {
|
||||
LOG(("Notification daemon capabilities: %1").arg(
|
||||
ranges::fold_left(
|
||||
capabilities,
|
||||
CurrentCapabilities,
|
||||
"",
|
||||
[](const Glib::ustring &a, const Glib::ustring &b) {
|
||||
return a + (a.empty() ? "" : ", ") + b;
|
||||
}).c_str()));
|
||||
}
|
||||
|
||||
if (ranges::contains(capabilities, "inhibitions")) {
|
||||
if (HasCapability("inhibitions")) {
|
||||
Noexcept([&] {
|
||||
_dbusConnection = Gio::DBus::Connection::get_sync(
|
||||
Gio::DBus::BusType::SESSION);
|
||||
|
|
Loading…
Add table
Reference in a new issue