Chatterino
Message.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "common/FlagsEnum.hpp"
5 #include "util/QStringHash.hpp"
7 
8 #include <QTime>
9 #include <boost/noncopyable.hpp>
10 #include <cinttypes>
11 #include <memory>
12 #include <vector>
13 
14 namespace chatterino {
15 class MessageElement;
16 class MessageThread;
17 
18 enum class MessageFlag : int64_t {
19  None = 0LL,
20  System = (1LL << 0),
21  Timeout = (1LL << 1),
22  Highlighted = (1LL << 2),
23  DoNotTriggerNotification = (1LL << 3), // disable notification sound
24  Centered = (1LL << 4),
25  Disabled = (1LL << 5),
26  DisableCompactEmotes = (1LL << 6),
27  Collapsed = (1LL << 7),
28  ConnectedMessage = (1LL << 8),
29  DisconnectedMessage = (1LL << 9),
30  Untimeout = (1LL << 10),
31  PubSub = (1LL << 11),
32  Subscription = (1LL << 12),
33  DoNotLog = (1LL << 13),
34  AutoMod = (1LL << 14),
35  RecentMessage = (1LL << 15),
36  Whisper = (1LL << 16),
37  HighlightedWhisper = (1LL << 17),
38  Debug = (1LL << 18),
39  Similar = (1LL << 19),
40  RedeemedHighlight = (1LL << 20),
41  RedeemedChannelPointReward = (1LL << 21),
42  ShowInMentions = (1LL << 22),
43  FirstMessage = (1LL << 23),
44  ReplyMessage = (1LL << 24),
45  ElevatedMessage = (1LL << 25),
46  ParticipatedThread = (1LL << 26),
47  CheerMessage = (1LL << 27),
48  LiveUpdatesAdd = (1LL << 28),
49  LiveUpdatesRemove = (1LL << 29),
50  LiveUpdatesUpdate = (1LL << 30),
51 };
53 
54 struct Message : boost::noncopyable {
55  Message();
56  ~Message();
57 
58  // Making this a mutable means that we can update a messages flags,
59  // while still keeping Message constant. This means that a message's flag
60  // can be updated without the renderer being made aware, which might be bad.
61  // This is a temporary effort until we can figure out what the right
62  // const-correct way to deal with this is.
63  // This might bring race conditions with it
65  QTime parseTime;
66  QString id;
67  QString searchText;
68  QString messageText;
69  QString loginName;
70  QString displayName;
71  QString localizedName;
72  QString timeoutUser;
73  QString channelName;
74  QColor usernameColor;
75  QDateTime serverReceivedTime;
76  std::vector<Badge> badges;
77  std::unordered_map<QString, QString> badgeInfos;
78  std::shared_ptr<QColor> highlightColor;
79  // Each reply holds a reference to the thread. When every reply is dropped,
80  // the reply thread will be cleaned up by the TwitchChannel.
81  // The root of the thread does not have replyThread set.
82  std::shared_ptr<MessageThread> replyThread;
83  uint32_t count = 1;
84  std::vector<std::unique_ptr<MessageElement>> elements;
85 
86  ScrollbarHighlight getScrollBarHighlight() const;
87 };
88 
89 using MessagePtr = std::shared_ptr<const Message>;
90 
91 } // namespace chatterino
Definition: ScrollbarHighlight.hpp:9
QString id
Definition: Message.hpp:66
QString timeoutUser
Definition: Message.hpp:72
QColor usernameColor
Definition: Message.hpp:74
std::vector< std::unique_ptr< MessageElement > > elements
Definition: Message.hpp:84
std::shared_ptr< MessageThread > replyThread
Definition: Message.hpp:82
Definition: Application.cpp:48
std::vector< Badge > badges
Definition: Message.hpp:76
Definition: StreamerMode.hpp:8
QString searchText
Definition: Message.hpp:67
Definition: PubSubManager.hpp:27
MessageFlag
Definition: Message.hpp:18
int64_t FlagsEnum< MessageFlag > MessageFlags
Definition: Channel.hpp:20
QString localizedName
Definition: Message.hpp:71
std::unordered_map< QString, QString > badgeInfos
Definition: Message.hpp:77
MessageFlags flags
Definition: Message.hpp:64
std::shared_ptr< QColor > highlightColor
Definition: Message.hpp:78
std::shared_ptr< const Message > MessagePtr
Definition: Channel.hpp:18
Definition: Message.hpp:54
QTime parseTime
Definition: Message.hpp:65
QString channelName
Definition: Message.hpp:73
QString loginName
Definition: Message.hpp:69
QDateTime serverReceivedTime
Definition: Message.hpp:75
QString displayName
Definition: Message.hpp:70
QString messageText
Definition: Message.hpp:68