#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 : uint32_t; using MessageFlags = FlagsEnum; enum class TimeoutStackStyle : int { StackHard = 0, DontStackBeyondUserMessage = 1, DontStack = 2, Default = DontStackBeyondUserMessage, }; class Channel : public std::enable_shared_from_this { public: enum class Type { None, Direct, Twitch, TwitchWhispers, TwitchWatching, TwitchMentions, TwitchEnd, Irc, Misc }; explicit Channel(const QString &name, Type type); virtual ~Channel(); // SIGNALS 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; virtual const QString &getDisplayName() const; bool isTwitchChannel() const; virtual bool isEmpty() const; LimitedQueueSnapshot getMessageSnapshot(); // MESSAGES // 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); void deleteMessage(QString messageID); void clearMessages(); bool hasMessages() const; QStringList modList; // CHANNEL INFO virtual bool canSendMessage() const; virtual void sendMessage(const QString &message); virtual bool isMod() const; virtual bool isBroadcaster() const; virtual bool hasModRights() const; virtual bool hasHighRateLimit() const; virtual bool isLive() const; virtual bool shouldIgnoreHighlights() const; virtual bool canReconnect() const; virtual void reconnect(); static std::shared_ptr getEmpty(); CompletionModel completionModel; protected: virtual void onConnected(); 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