mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Get XDG activation token from native notification on Linux
This commit is contained in:
@@ -435,11 +435,13 @@ private:
|
|||||||
|
|
||||||
uint _notificationId = 0;
|
uint _notificationId = 0;
|
||||||
uint _actionInvokedSignalId = 0;
|
uint _actionInvokedSignalId = 0;
|
||||||
|
uint _activationTokenSignalId = 0;
|
||||||
uint _notificationRepliedSignalId = 0;
|
uint _notificationRepliedSignalId = 0;
|
||||||
uint _notificationClosedSignalId = 0;
|
uint _notificationClosedSignalId = 0;
|
||||||
|
|
||||||
void notificationClosed(uint id, uint reason);
|
void notificationClosed(uint id, uint reason);
|
||||||
void actionInvoked(uint id, const Glib::ustring &actionName);
|
void actionInvoked(uint id, const Glib::ustring &actionName);
|
||||||
|
void activationToken(uint id, const Glib::ustring &token);
|
||||||
void notificationReplied(uint id, const Glib::ustring &text);
|
void notificationReplied(uint id, const Glib::ustring &text);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -486,6 +488,14 @@ bool NotificationData::init(
|
|||||||
parameters.get_child(1));
|
parameters.get_child(1));
|
||||||
|
|
||||||
crl::on_main(weak, [=] { actionInvoked(id, actionName); });
|
crl::on_main(weak, [=] { actionInvoked(id, actionName); });
|
||||||
|
} else if (signal_name == "ActivationToken") {
|
||||||
|
const auto id = GlibVariantCast<uint>(
|
||||||
|
parameters.get_child(0));
|
||||||
|
|
||||||
|
const auto token = GlibVariantCast<Glib::ustring>(
|
||||||
|
parameters.get_child(1));
|
||||||
|
|
||||||
|
crl::on_main(weak, [=] { activationToken(id, token); });
|
||||||
} else if (signal_name == "NotificationReplied") {
|
} else if (signal_name == "NotificationReplied") {
|
||||||
const auto id = GlibVariantCast<uint>(
|
const auto id = GlibVariantCast<uint>(
|
||||||
parameters.get_child(0));
|
parameters.get_child(0));
|
||||||
@@ -558,6 +568,13 @@ bool NotificationData::init(
|
|||||||
std::string(kInterface),
|
std::string(kInterface),
|
||||||
"ActionInvoked",
|
"ActionInvoked",
|
||||||
std::string(kObjectPath));
|
std::string(kObjectPath));
|
||||||
|
|
||||||
|
_activationTokenSignalId = _dbusConnection->signal_subscribe(
|
||||||
|
signalEmitted,
|
||||||
|
std::string(kService),
|
||||||
|
std::string(kInterface),
|
||||||
|
"ActivationToken",
|
||||||
|
std::string(kObjectPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capabilities.contains("action-icons")) {
|
if (capabilities.contains("action-icons")) {
|
||||||
@@ -601,6 +618,10 @@ NotificationData::~NotificationData() {
|
|||||||
_dbusConnection->signal_unsubscribe(_actionInvokedSignalId);
|
_dbusConnection->signal_unsubscribe(_actionInvokedSignalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_activationTokenSignalId != 0) {
|
||||||
|
_dbusConnection->signal_unsubscribe(_activationTokenSignalId);
|
||||||
|
}
|
||||||
|
|
||||||
if (_notificationRepliedSignalId != 0) {
|
if (_notificationRepliedSignalId != 0) {
|
||||||
_dbusConnection->signal_unsubscribe(_notificationRepliedSignalId);
|
_dbusConnection->signal_unsubscribe(_notificationRepliedSignalId);
|
||||||
}
|
}
|
||||||
@@ -738,6 +759,12 @@ void NotificationData::actionInvoked(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationData::activationToken(uint id, const Glib::ustring &token) {
|
||||||
|
if (id == _notificationId) {
|
||||||
|
qputenv("XDG_ACTIVATION_TOKEN", QByteArray::fromStdString(token));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotificationData::notificationReplied(
|
void NotificationData::notificationReplied(
|
||||||
uint id,
|
uint id,
|
||||||
const Glib::ustring &text) {
|
const Glib::ustring &text) {
|
||||||
|
Submodule Telegram/lib_waylandshells updated: 866d3618cf...50d5fefb8a
Reference in New Issue
Block a user