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