2019-03-15 12:14:23 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/AKString.h>
|
|
|
|
#include <AK/CircularQueue.h>
|
2019-06-21 18:45:35 +02:00
|
|
|
#include <AK/RefPtr.h>
|
2019-06-21 18:58:45 +02:00
|
|
|
#include <AK/RefCounted.h>
|
2019-07-18 10:15:00 +02:00
|
|
|
#include <LibDraw/Color.h>
|
2019-03-15 12:14:23 +01:00
|
|
|
|
2019-03-15 13:07:04 +01:00
|
|
|
class IRCLogBufferModel;
|
|
|
|
|
2019-06-21 15:29:31 +02:00
|
|
|
class IRCLogBuffer : public RefCounted<IRCLogBuffer> {
|
2019-03-15 12:14:23 +01:00
|
|
|
public:
|
2019-06-21 18:37:47 +02:00
|
|
|
static NonnullRefPtr<IRCLogBuffer> create();
|
2019-03-15 12:14:23 +01:00
|
|
|
~IRCLogBuffer();
|
|
|
|
|
|
|
|
struct Message {
|
|
|
|
time_t timestamp { 0 };
|
|
|
|
char prefix { 0 };
|
|
|
|
String sender;
|
|
|
|
String text;
|
2019-03-18 20:56:45 +01:00
|
|
|
Color color { Color::Black };
|
2019-03-15 12:14:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int count() const { return m_messages.size(); }
|
|
|
|
const Message& at(int index) const { return m_messages.at(index); }
|
2019-03-18 20:56:45 +01:00
|
|
|
void add_message(char prefix, const String& name, const String& text, Color = Color::Black);
|
|
|
|
void add_message(const String& text, Color = Color::Black);
|
2019-03-15 12:14:23 +01:00
|
|
|
void dump() const;
|
|
|
|
|
2019-03-20 03:27:07 +01:00
|
|
|
const IRCLogBufferModel* model() const { return m_model.ptr(); }
|
|
|
|
IRCLogBufferModel* model() { return m_model.ptr(); }
|
2019-03-15 13:07:04 +01:00
|
|
|
|
2019-03-15 12:14:23 +01:00
|
|
|
private:
|
|
|
|
IRCLogBuffer();
|
2019-06-21 18:37:47 +02:00
|
|
|
NonnullRefPtr<IRCLogBufferModel> m_model;
|
2019-03-15 12:14:23 +01:00
|
|
|
CircularQueue<Message, 1000> m_messages;
|
|
|
|
};
|