#pragma once #include #include #include #include #include #include "IRCLogBuffer.h" class IRCClient; class IRCChannelMemberListModel; class IRCWindow; class IRCChannel : public Retainable { public: static Retained create(IRCClient&, const String&); ~IRCChannel(); bool is_open() const { return m_open; } void set_open(bool b) { m_open = b; } String name() const { return m_name; } void add_member(const String& name, char prefix); void remove_member(const String& name); void add_message(char prefix, const String& name, const String& text, Color = Color::Black); void add_message(const String& text, Color = Color::Black); void dump() const; void say(const String&); const IRCLogBuffer& log() const { return *m_log; } IRCLogBuffer& log() { return *m_log; } IRCChannelMemberListModel* member_model() { return m_member_model.ptr(); } const IRCChannelMemberListModel* member_model() const { return m_member_model.ptr(); } int member_count() const { return m_members.size(); } String member_at(int i) { return m_members[i].name; } void handle_join(const String& nick, const String& hostmask); void handle_part(const String& nick, const String& hostmask); void handle_topic(const String& nick, const String& topic); IRCWindow& window() { return *m_window; } const IRCWindow& window() const { return *m_window; } String topic() const { return m_topic; } void notify_nick_changed(const String& old_nick, const String& new_nick); private: IRCChannel(IRCClient&, const String&); IRCClient& m_client; String m_name; String m_topic; struct Member { String name; char prefix { 0 }; }; Vector m_members; bool m_open { false }; Retained m_log; Retained m_member_model; IRCWindow* m_window { nullptr }; };