Notifier.h 788 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Function.h>
  8. #include <LibCore/Event.h>
  9. #include <LibCore/EventReceiver.h>
  10. namespace Core {
  11. class Notifier final : public EventReceiver {
  12. C_OBJECT(Notifier);
  13. public:
  14. using Type = NotificationType;
  15. virtual ~Notifier() override;
  16. void set_enabled(bool);
  17. Function<void()> on_activation;
  18. void close();
  19. int fd() const { return m_fd; }
  20. Type type() const { return m_type; }
  21. void set_type(Type type);
  22. void event(Core::Event&) override;
  23. private:
  24. Notifier(int fd, Type type, EventReceiver* parent = nullptr);
  25. int m_fd { -1 };
  26. bool m_is_enabled { false };
  27. Type m_type { Type::None };
  28. };
  29. }