Notification.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <LibGUI/Notification.h>
  2. #include <LibIPC/ServerConnection.h>
  3. #include <NotificationServer/NotificationClientEndpoint.h>
  4. #include <NotificationServer/NotificationServerEndpoint.h>
  5. namespace GUI {
  6. class NotificationServerConnection : public IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint>
  7. , public NotificationClientEndpoint {
  8. C_OBJECT(NotificationServerConnection)
  9. public:
  10. virtual void handshake() override
  11. {
  12. auto response = send_sync<Messages::NotificationServer::Greet>();
  13. set_my_client_id(response->client_id());
  14. }
  15. private:
  16. NotificationServerConnection()
  17. : IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint>(*this, "/tmp/portal/notify")
  18. {
  19. }
  20. virtual void handle(const Messages::NotificationClient::Dummy&) override {}
  21. };
  22. Notification::Notification()
  23. {
  24. }
  25. Notification::~Notification()
  26. {
  27. }
  28. void Notification::show()
  29. {
  30. auto connection = NotificationServerConnection::construct();
  31. connection->post_message(Messages::NotificationServer::ShowNotification(m_text, m_title));
  32. }
  33. }