#pragma once #include "common/CompletionModel.hpp" #include "common/FlagsEnum.hpp" #include "messages/LimitedQueue.hpp" #include #include #include #include #include namespace chatterino { struct Message; using MessagePtr = std::shared_ptr; enum class MessageFlag : uint16_t; using MessageFlags = FlagsEnum; class Channel : public std::enable_shared_from_this { public: enum class Type { None, Direct, Twitch, TwitchWhispers, TwitchWatching, TwitchMentions, TwitchEnd, Misc }; explicit Channel(const QString &name, Type type); virtual ~Channel(); pajlada::Signals::Signal sendMessageSignal; pajlada::Signals::Signal messageRemovedFromStart; pajlada::Signals::Signal> messageAppended; pajlada::Signals::Signal &> messagesAddedAtStart; pajlada::Signals::Signal messageReplaced; pajlada::Signals::NoArgSignal destroyed; Type getType() const; const QString &getName() const; bool isTwitchChannel() const; virtual bool isEmpty() const; LimitedQueueSnapshot getMessageSnapshot(); // overridingFlags can be filled in with flags that should be used instead // of the message's flags. This is useful in case a flag is specific to a // type of split void addMessage( MessagePtr message, boost::optional overridingFlags = boost::none); void addMessagesAtStart(std::vector &messages_); void addOrReplaceTimeout(MessagePtr message); void disableAllMessages(); void replaceMessage(MessagePtr message, MessagePtr replacement); QStringList modList; virtual bool canSendMessage() const; virtual void sendMessage(const QString &message); virtual bool isMod() const; virtual bool isBroadcaster() const; virtual bool hasModRights() const; virtual bool isLive() const; static std::shared_ptr getEmpty(); CompletionModel completionModel; protected: virtual void onConnected(); virtual void addRecentChatter(const MessagePtr &message); private: const QString name_; LimitedQueue messages_; Type type_; QTimer clearCompletionModelTimer_; }; using ChannelPtr = std::shared_ptr; class IndirectChannel { struct Data { ChannelPtr channel; Channel::Type type; pajlada::Signals::NoArgSignal changed; Data(ChannelPtr channel, Channel::Type type); }; public: IndirectChannel(ChannelPtr channel, Channel::Type type = Channel::Type::Direct); ChannelPtr get(); void reset(ChannelPtr channel); pajlada::Signals::NoArgSignal &getChannelChanged(); Channel::Type getType(); private: std::shared_ptr data_; }; } // namespace chatterino