mirror-chatterino2/src/providers/twitch/twitchchannel.hpp
Rasmus Karlsson 6ea3a1df08 Switch some c-style includes to c++-style includes (i.e. stdint.h to
cstdint)

Make MessageElement to a class to fit better with the derived classes.
Make MessageLayoutElement to a class to fit better with the derived
classes.

Remove virtual from override functions

Replace all instances of boost::signals2 with pajlada::Signals. This
lets us properly use clang code model to check for issues.

Add missing virtual destructor to AbstractIrcServer
Add missing virtual destructor to MessageLayoutElement

Remove unused "connectedConnection" connection in TwitchChannel

Fix typo in TrimChannelName function
Fix typo in MessageParseArgs

Replace some raw pointers with unique pointers where it made more sense.
This allowed us to remove some manually written destructors whose only
purpose was to delete that raw pointer.

Reformat: Add namespace comments
Reformat: Add empty empty lines between main namespace beginning and end
Reformat: Re-order includes
Reformat: Fix some includes that used quotes where they should use angle
brackets
Reformat: Replace some typedef's with using's

Filter out more useless warnings
2018-04-11 22:54:34 +02:00

108 lines
2.5 KiB
C++

#pragma once
#include <IrcConnection>
#include "channel.hpp"
#include "common.hpp"
#include "singletons/emotemanager.hpp"
#include "singletons/ircmanager.hpp"
#include "util/concurrentmap.hpp"
#include <mutex>
namespace chatterino {
namespace providers {
namespace twitch {
class TwitchServer;
class TwitchChannel final : public Channel
{
QTimer *liveStatusTimer;
QTimer *chattersListTimer;
public:
struct StreamStatus {
bool live = false;
unsigned viewerCount = 0;
QString title;
QString game;
QString uptime;
};
~TwitchChannel() final;
void reloadChannelEmotes();
bool isEmpty() const override;
bool canSendMessage() const override;
void sendMessage(const QString &message) override;
bool isMod() const override;
void setMod(bool value);
bool isBroadcaster();
bool hasModRights();
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
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);
pajlada::Signals::NoArgSignal roomIDchanged;
pajlada::Signals::NoArgSignal onlineStatusChanged;
pajlada::Signals::NoArgBoltSignal fetchMessages;
pajlada::Signals::NoArgSignal 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:
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
void setLive(bool newLiveStatus);
void refreshLiveStatus();
mutable std::mutex streamStatusMutex;
StreamStatus streamStatus;
void fetchRecentMessages();
bool mod;
QByteArray messageSuffix;
QString lastSentMessage;
Communi::IrcConnection *readConnection;
friend class TwitchServer;
// Key = login name
std::map<QString, NameOptions> recentChatters;
std::mutex recentChattersMutex;
};
} // namespace twitch
} // namespace providers
} // namespace chatterino