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