2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-01 13:07:36 +01:00
|
|
|
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "common/CompletionModel.hpp"
|
2018-10-05 23:33:01 +02:00
|
|
|
#include "common/FlagsEnum.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "messages/LimitedQueue.hpp"
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#include <QString>
|
2018-03-30 13:50:43 +02:00
|
|
|
#include <QTimer>
|
2018-10-05 23:33:01 +02:00
|
|
|
#include <boost/optional.hpp>
|
2018-04-03 02:55:32 +02:00
|
|
|
#include <pajlada/signals/signal.hpp>
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2017-01-11 01:08:20 +01:00
|
|
|
#include <memory>
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2018-08-11 22:23:06 +02:00
|
|
|
|
2018-01-28 03:29:42 +01:00
|
|
|
struct Message;
|
2018-08-11 22:23:06 +02:00
|
|
|
using MessagePtr = std::shared_ptr<const Message>;
|
2019-03-20 20:46:20 +01:00
|
|
|
enum class MessageFlag : uint32_t;
|
2018-10-05 23:33:01 +02:00
|
|
|
using MessageFlags = FlagsEnum<MessageFlag>;
|
2017-01-01 13:07:36 +01:00
|
|
|
|
2019-07-28 13:19:17 +02:00
|
|
|
enum class TimeoutStackStyle : int {
|
|
|
|
StackHard = 0,
|
|
|
|
DontStackBeyondUserMessage = 1,
|
2019-08-21 00:41:48 +02:00
|
|
|
DontStack = 2,
|
2019-07-28 13:19:17 +02:00
|
|
|
|
2019-08-21 00:41:48 +02:00
|
|
|
Default = DontStackBeyondUserMessage,
|
2019-07-28 13:19:17 +02:00
|
|
|
};
|
|
|
|
|
2018-01-05 00:58:25 +01:00
|
|
|
class Channel : public std::enable_shared_from_this<Channel>
|
2017-01-01 13:07:36 +01:00
|
|
|
{
|
|
|
|
public:
|
2018-07-06 17:30:12 +02:00
|
|
|
enum class Type {
|
2018-04-18 09:12:29 +02:00
|
|
|
None,
|
2018-04-20 19:54:45 +02:00
|
|
|
Direct,
|
2018-04-18 09:12:29 +02:00
|
|
|
Twitch,
|
|
|
|
TwitchWhispers,
|
|
|
|
TwitchWatching,
|
|
|
|
TwitchMentions,
|
2018-05-25 13:53:55 +02:00
|
|
|
TwitchEnd,
|
2019-09-09 22:22:47 +02:00
|
|
|
Irc,
|
2018-07-03 16:55:02 +02:00
|
|
|
Misc
|
2018-04-18 09:12:29 +02:00
|
|
|
};
|
|
|
|
|
2018-07-06 18:10:21 +02:00
|
|
|
explicit Channel(const QString &name, Type type);
|
2018-02-05 15:11:50 +01:00
|
|
|
virtual ~Channel();
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
pajlada::Signals::Signal<const QString &, const QString &, bool &>
|
|
|
|
sendMessageSignal;
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
pajlada::Signals::Signal<MessagePtr &> messageRemovedFromStart;
|
2018-10-05 23:33:01 +02:00
|
|
|
pajlada::Signals::Signal<MessagePtr &, boost::optional<MessageFlags>>
|
|
|
|
messageAppended;
|
2018-06-28 19:38:57 +02:00
|
|
|
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
|
|
|
|
pajlada::Signals::Signal<size_t, MessagePtr &> messageReplaced;
|
2018-02-05 15:11:50 +01:00
|
|
|
pajlada::Signals::NoArgSignal destroyed;
|
2017-02-02 20:35:12 +01:00
|
|
|
|
2018-04-18 09:12:29 +02:00
|
|
|
Type getType() const;
|
2018-08-02 14:23:27 +02:00
|
|
|
const QString &getName() const;
|
2019-03-01 21:18:32 +01:00
|
|
|
virtual const QString &getDisplayName() const;
|
2018-05-25 13:53:55 +02:00
|
|
|
bool isTwitchChannel() const;
|
2017-09-16 00:05:06 +02:00
|
|
|
virtual bool isEmpty() const;
|
2018-06-28 19:38:57 +02:00
|
|
|
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
|
2017-01-05 20:49:33 +01:00
|
|
|
|
2018-10-05 23:33:01 +02:00
|
|
|
// 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<MessageFlags> overridingFlags = boost::none);
|
2018-07-06 17:30:12 +02:00
|
|
|
void addMessagesAtStart(std::vector<MessagePtr> &messages_);
|
2018-06-28 19:38:57 +02:00
|
|
|
void addOrReplaceTimeout(MessagePtr message);
|
2018-06-22 23:44:02 +02:00
|
|
|
void disableAllMessages();
|
2018-06-28 19:38:57 +02:00
|
|
|
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
2019-04-19 22:44:02 +02:00
|
|
|
void deleteMessage(QString messageID);
|
2017-12-17 17:49:32 +01:00
|
|
|
|
2017-09-23 19:23:10 +02:00
|
|
|
QStringList modList;
|
2017-05-27 17:45:40 +02:00
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
virtual bool canSendMessage() const;
|
|
|
|
virtual void sendMessage(const QString &message);
|
2018-04-18 09:12:29 +02:00
|
|
|
virtual bool isMod() const;
|
2018-06-22 23:19:52 +02:00
|
|
|
virtual bool isBroadcaster() const;
|
2018-07-04 19:43:41 +02:00
|
|
|
virtual bool hasModRights() const;
|
2019-04-13 15:26:47 +02:00
|
|
|
virtual bool hasHighRateLimit() const;
|
2018-10-13 14:20:06 +02:00
|
|
|
virtual bool isLive() const;
|
2018-10-21 13:29:52 +02:00
|
|
|
virtual bool shouldIgnoreHighlights() const;
|
2017-07-02 15:12:00 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
static std::shared_ptr<Channel> getEmpty();
|
|
|
|
|
2018-03-24 12:13:09 +01:00
|
|
|
CompletionModel completionModel;
|
2018-03-24 12:02:07 +01:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
protected:
|
|
|
|
virtual void onConnected();
|
2018-08-13 13:54:39 +02:00
|
|
|
virtual void addRecentChatter(const MessagePtr &message);
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2017-01-01 13:07:36 +01:00
|
|
|
private:
|
2018-08-02 14:23:27 +02:00
|
|
|
const QString name_;
|
2018-07-06 17:30:12 +02:00
|
|
|
LimitedQueue<MessagePtr> messages_;
|
|
|
|
Type type_;
|
|
|
|
QTimer clearCompletionModelTimer_;
|
2017-01-01 13:07:36 +01:00
|
|
|
};
|
2017-03-11 11:32:19 +01:00
|
|
|
|
2018-03-30 12:37:00 +02:00
|
|
|
using ChannelPtr = std::shared_ptr<Channel>;
|
2018-01-11 20:16:25 +01:00
|
|
|
|
2018-04-20 19:54:45 +02:00
|
|
|
class IndirectChannel
|
|
|
|
{
|
|
|
|
struct Data {
|
|
|
|
ChannelPtr channel;
|
|
|
|
Channel::Type type;
|
|
|
|
pajlada::Signals::NoArgSignal changed;
|
|
|
|
|
2018-08-10 19:00:14 +02:00
|
|
|
Data(ChannelPtr channel, Channel::Type type);
|
2018-04-20 19:54:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2018-08-06 21:17:03 +02:00
|
|
|
IndirectChannel(ChannelPtr channel,
|
2018-08-10 19:00:14 +02:00
|
|
|
Channel::Type type = Channel::Type::Direct);
|
|
|
|
|
|
|
|
ChannelPtr get();
|
|
|
|
void reset(ChannelPtr channel);
|
|
|
|
pajlada::Signals::NoArgSignal &getChannelChanged();
|
|
|
|
Channel::Type getType();
|
2018-07-06 17:30:12 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::shared_ptr<Data> data_;
|
2018-04-20 19:54:45 +02:00
|
|
|
};
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|