// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include #include #include #include #include "component/core.h" class Connection: public gloox::ConnectionListener, public gloox::MessageHandler { public: enum State { initial, disconnected, connected }; public: Connection(const std::shared_ptr& core); ~Connection() noexcept; void initialize(); void deinitialize(); void connect(); void send(const std::string& jid, const std::string& body); public: void onConnect() override; void onDisconnect(gloox::ConnectionError e) override; bool onTLSConnect(const gloox::CertInfo&) override; void handleMessage(const gloox::Message& message, gloox::MessageSession* session = 0) override; private: State state; std::shared_ptr core; std::unique_ptr gloox; };