2018-07-20 22:27:43 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-20 22:27:43 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <list>
|
2018-08-06 21:56:40 +00:00
|
|
|
#include <mutex>
|
2018-07-20 22:27:43 +00:00
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2019-06-13 21:34:25 +00:00
|
|
|
#include "Common/Event.h"
|
2018-07-20 22:27:43 +00:00
|
|
|
#include "Common/Flag.h"
|
|
|
|
|
|
|
|
#include "UICommon/DiscordPresence.h"
|
|
|
|
|
2018-08-06 21:56:40 +00:00
|
|
|
class DiscordJoinRequestDialog;
|
|
|
|
|
2018-07-20 22:27:43 +00:00
|
|
|
class DiscordHandler : public QObject, public Discord::Handler
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-08-06 21:56:40 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-07-20 22:27:43 +00:00
|
|
|
public:
|
|
|
|
explicit DiscordHandler(QWidget* parent);
|
|
|
|
~DiscordHandler();
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
void Stop();
|
|
|
|
void DiscordJoin() override;
|
|
|
|
void DiscordJoinRequest(const char* id, const std::string& discord_tag,
|
|
|
|
const char* avatar) override;
|
2018-08-06 21:56:40 +00:00
|
|
|
void ShowNewJoinRequest(const std::string& id, const std::string& discord_tag,
|
|
|
|
const std::string& avatar);
|
|
|
|
#endif
|
|
|
|
|
2018-07-20 22:27:43 +00:00
|
|
|
signals:
|
|
|
|
void Join();
|
2018-08-06 21:56:40 +00:00
|
|
|
void JoinRequest(const std::string id, const std::string discord_tag, const std::string avatar);
|
2018-07-20 22:27:43 +00:00
|
|
|
|
2018-08-06 21:56:40 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-07-20 22:27:43 +00:00
|
|
|
private:
|
|
|
|
void Run();
|
|
|
|
QWidget* m_parent;
|
|
|
|
Common::Flag m_stop_requested;
|
2019-06-13 21:34:25 +00:00
|
|
|
Common::Event m_wakeup_event;
|
2018-07-20 22:27:43 +00:00
|
|
|
std::thread m_thread;
|
|
|
|
std::list<DiscordJoinRequestDialog> m_request_dialogs;
|
2018-08-06 21:56:40 +00:00
|
|
|
std::mutex m_request_dialogs_mutex;
|
|
|
|
#endif
|
2018-07-20 22:27:43 +00:00
|
|
|
};
|