jay/jay.h

43 lines
892 B
C
Raw Normal View History

2024-03-30 22:44:52 -03:00
// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <memory>
2025-02-22 21:03:21 +02:00
#include <mutex>
2024-03-30 22:44:52 -03:00
#include <gloox/client.h>
2025-02-22 21:03:21 +02:00
#include <gloox/disco.h>
2025-02-21 23:01:11 +02:00
#include <gloox/connectionlistener.h>
2024-03-30 22:44:52 -03:00
#include "logger.h"
2025-02-22 21:03:21 +02:00
#include "config.h"
#include "handlers/message.h"
#include "handlers/connection.h"
2024-03-30 22:44:52 -03:00
2025-02-22 21:03:21 +02:00
class Jay {
2024-03-30 22:44:52 -03:00
public:
2025-02-22 21:03:21 +02:00
Jay(const std::string& configPath);
2024-03-30 22:44:52 -03:00
~Jay();
2025-02-22 21:03:21 +02:00
bool isConfigValid() const;
2024-03-30 22:44:52 -03:00
void run();
2025-02-22 21:03:21 +02:00
private:
void addLogger(gloox::LogLevel level);
void initialize();
void createClient();
2024-03-30 22:44:52 -03:00
private:
2025-02-22 21:03:21 +02:00
std::mutex runMutex;
std::shared_ptr<Config> config;
std::shared_ptr<gloox::Client> client;
std::unique_ptr<Message> messageHandler;
std::unique_ptr<Connection> connectionHandler;
2024-03-30 22:44:52 -03:00
std::vector<std::unique_ptr<Logger>> loggers;
};