#pragma once #include #include #include #include #include #include #include #include #include // tmp class IRCClientContactModel : public IRCClientEventI, public ContactModel4I { ContactStore4I& _cs; ConfigModelI& _conf; IRCClient1& _ircc; IRCClient1::SubscriptionReference _ircc_sr; // cm needs the connect event to happen bool _connected {false}; std::vector _server_hash; // cached for id gen Contact4 _server {entt::null}; Contact4 _self {entt::null}; // used if not connected std::queue _join_queue; public: IRCClientContactModel( ContactStore4I& cs, ConfigModelI& conf, IRCClient1& ircc ); virtual ~IRCClientContactModel(void); void join(const std::string& channel); protected: // interface bool addContact(Contact4 c) override; bool acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) override; bool leave(Contact4 c, std::string_view reason) override; private: // just the hash algo std::vector getHash(std::string_view value); std::vector getHash(const std::vector& value); public: // the actually ID is a chain containing the server+channel or server+name // eg: hash(hash(ServerName)+ChannelName) std::vector getIDHash(std::string_view name); ContactHandle4 getC(std::string_view channel); ContactHandle4 getU(std::string_view nick); // user or channel using channel prefix ContactHandle4 getCU(std::string_view name); private: // ircclient bool onEvent(const IRCClient::Events::Connect& e) override; bool onEvent(const IRCClient::Events::Numeric& e) override; bool onEvent(const IRCClient::Events::Join& e) override; bool onEvent(const IRCClient::Events::Part& e) override; bool onEvent(const IRCClient::Events::Topic& e) override; bool onEvent(const IRCClient::Events::Quit& e) override; bool onEvent(const IRCClient::Events::CTCP_Req&) override; bool onEvent(const IRCClient::Events::Disconnect&) override; };