#pragma once #include #include #include "key_value_store.h" namespace roro { // The one IRC server the IRC Service connects to, persisted in internal flash. class IrcConfig { public: explicit IrcConfig(KeyValueStore& store) : store_(store) {} std::string host = "irc.libera.chat"; int port = 6697; bool tls = true; bool allowSelfSigned = false; // pin the certificate on first use instead of checking a CA std::string pinnedSha256; // hex fingerprint once pinned std::string nick; std::string saslUser, saslPassword; // SASL PLAIN when both are set std::string nickservPassword; // otherwise IDENTIFY with NickServ, if set std::vector autojoin; // A copy is a draft the UI can edit freely; copySettingsFrom() applies one. IrcConfig(const IrcConfig&) = default; void copySettingsFrom(const IrcConfig& other) { host = other.host; port = other.port; tls = other.tls; allowSelfSigned = other.allowSelfSigned; pinnedSha256 = other.pinnedSha256; nick = other.nick; saslUser = other.saslUser; saslPassword = other.saslPassword; nickservPassword = other.nickservPassword; autojoin = other.autojoin; } void load(const std::string& defaultNick); std::string save(); // empty on success, otherwise why it was refused std::string validate() const; static std::vector parseChannels(const std::string& text); static std::string formatChannels(const std::vector& channels); private: KeyValueStore& store_; }; } // namespace roro