mirror-chatterino2/src/providers/twitch/twitchchannel.hpp

110 lines
2.5 KiB
C++
Raw Normal View History

#pragma once
2018-02-05 15:11:50 +01:00
#include <IrcConnection>
#include "channel.hpp"
2018-02-05 15:11:50 +01:00
#include "common.hpp"
2017-12-31 00:50:07 +01:00
#include "singletons/emotemanager.hpp"
#include "singletons/ircmanager.hpp"
2017-12-31 22:58:35 +01:00
#include "util/concurrentmap.hpp"
#include <mutex>
namespace chatterino {
2018-02-05 15:11:50 +01:00
namespace providers {
namespace twitch {
2018-02-05 15:11:50 +01:00
class TwitchServer;
2018-02-05 15:11:50 +01:00
class TwitchChannel final : public Channel
{
QTimer *liveStatusTimer;
QTimer *chattersListTimer;
public:
struct StreamStatus {
bool live = false;
unsigned viewerCount = 0;
QString title;
QString game;
QString uptime;
};
2018-03-30 12:37:00 +02:00
~TwitchChannel() final;
void reloadChannelEmotes();
bool isEmpty() const override;
bool canSendMessage() const override;
void sendMessage(const QString &message) override;
bool isMod() const override;
2018-01-17 18:36:12 +01:00
void setMod(bool value);
2018-01-17 17:17:26 +01:00
bool isBroadcaster();
bool hasModRights();
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
2017-12-31 22:58:35 +01:00
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
const QString subscriptionURL;
const QString channelURL;
const QString popoutPlayerURL;
void setRoomID(const QString &_roomID);
boost::signals2::signal<void()> roomIDchanged;
boost::signals2::signal<void()> onlineStatusChanged;
pajlada::Signals::NoArgBoltSignal fetchMessages;
2018-01-17 18:36:12 +01:00
boost::signals2::signal<void()> userStateChanged;
QString roomID;
StreamStatus GetStreamStatus() const
{
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
return this->streamStatus;
}
struct NameOptions {
QString displayName;
QString localizedName;
};
bool IsLive() const
{
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
return this->streamStatus.live;
}
private:
2018-02-05 15:11:50 +01:00
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
void setLive(bool newLiveStatus);
void refreshLiveStatus();
mutable std::mutex streamStatusMutex;
StreamStatus streamStatus;
void fetchRecentMessages();
2018-01-17 17:17:26 +01:00
2018-01-17 18:36:12 +01:00
boost::signals2::connection connectedConnection;
2018-01-17 17:17:26 +01:00
bool mod;
QByteArray messageSuffix;
QString lastSentMessage;
Communi::IrcConnection *readConnection;
2018-02-05 15:11:50 +01:00
friend class TwitchServer;
// Key = login name
std::map<QString, NameOptions> recentChatters;
std::mutex recentChattersMutex;
2018-02-05 15:11:50 +01:00
};
} // namespace twitch
2018-02-05 15:11:50 +01:00
} // namespace providers
} // namespace chatterino