DiscordHandler.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2018 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <list>
  5. #include <mutex>
  6. #include <thread>
  7. #include <QObject>
  8. #include "Common/Event.h"
  9. #include "Common/Flag.h"
  10. #include "UICommon/DiscordPresence.h"
  11. class DiscordJoinRequestDialog;
  12. class DiscordHandler : public QObject, public Discord::Handler
  13. {
  14. Q_OBJECT
  15. #ifdef USE_DISCORD_PRESENCE
  16. public:
  17. explicit DiscordHandler(QWidget* parent);
  18. ~DiscordHandler();
  19. void Start();
  20. void Stop();
  21. void DiscordJoin() override;
  22. void DiscordJoinRequest(const char* id, const std::string& discord_tag,
  23. const char* avatar) override;
  24. void ShowNewJoinRequest(const std::string& id, const std::string& discord_tag,
  25. const std::string& avatar);
  26. #endif
  27. signals:
  28. void Join();
  29. void JoinRequest(const std::string id, const std::string discord_tag, const std::string avatar);
  30. #ifdef USE_DISCORD_PRESENCE
  31. private:
  32. void Run();
  33. QWidget* m_parent;
  34. Common::Flag m_stop_requested;
  35. Common::Event m_wakeup_event;
  36. std::thread m_thread;
  37. std::list<DiscordJoinRequestDialog> m_request_dialogs;
  38. std::mutex m_request_dialogs_mutex;
  39. #endif
  40. };