#pragma once #include #include #include #include #include #include "connection/dbus/dbus.hpp" #include "giomm/dbusconnection.h" #include "giomm/dbusownname.h" #include "glib.h" const Glib::ustring introspection_xml = R"( )"; class NotificationService : public DbusConnection { public: static std::shared_ptr getInstance() { if (NotificationService::instance == nullptr) { NotificationService::instance = std::shared_ptr(new NotificationService()); } return NotificationService::instance; } void onBusAcquired(const Glib::RefPtr &connection, const Glib::ustring &name); private: NotificationService() { Gio::DBus::own_name( Gio::DBus::BusType::SESSION, "org.freedesktop.Notifications", sigc::mem_fun(*this, &NotificationService::onBusAcquired), {}, // Name acquired slot (optional) {}, // Name lost slot (optional) Gio::DBus::BusNameOwnerFlags::REPLACE); } static inline std::shared_ptr instance = nullptr; guint notificationIdCounter = 0; const Gio::DBus::InterfaceVTable &getMessageInterfaceVTable(); void on_method_call(const Glib::RefPtr &connection, const Glib::ustring &sender, const Glib::ustring &object_path, const Glib::ustring &interface_name, const Glib::ustring &method_name, const Glib::VariantContainerBase ¶meters, const Glib::RefPtr &invocation); void handle_notify(const Glib::VariantContainerBase ¶meters, const Glib::RefPtr &invocation); void createNotificationPopup(const Glib::ustring &title, const Glib::ustring &message); };