2025-02-22 21:03:21 +02:00
|
|
|
// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-03-03 21:36:02 +02:00
|
|
|
#include <string>
|
2025-02-22 21:03:21 +02:00
|
|
|
#include <memory>
|
2025-03-03 21:36:02 +02:00
|
|
|
#include <functional>
|
2025-02-22 21:03:21 +02:00
|
|
|
|
|
|
|
#include <gloox/client.h>
|
|
|
|
#include <gloox/messagehandler.h>
|
|
|
|
#include <gloox/message.h>
|
|
|
|
|
2025-03-02 21:33:22 +02:00
|
|
|
#include "component/config.h"
|
2025-02-22 21:03:21 +02:00
|
|
|
|
|
|
|
class Message : public gloox::MessageHandler {
|
2025-03-03 21:36:02 +02:00
|
|
|
private:
|
|
|
|
typedef std::function<void (const std::string&, const std::string&)> Callback;
|
|
|
|
|
2025-02-22 21:03:21 +02:00
|
|
|
public:
|
2025-03-03 21:36:02 +02:00
|
|
|
Message(const std::shared_ptr<Config>& config, const std::shared_ptr<gloox::Client>& client, const Callback& callback);
|
2025-02-22 21:03:21 +02:00
|
|
|
~Message();
|
|
|
|
|
|
|
|
void handleMessage(const gloox::Message& message, gloox::MessageSession* session = 0) override;
|
|
|
|
|
|
|
|
private:
|
2025-03-03 21:36:02 +02:00
|
|
|
Callback callback;
|
2025-02-22 21:03:21 +02:00
|
|
|
std::weak_ptr<Config> config;
|
|
|
|
std::weak_ptr<gloox::Client> client;
|
|
|
|
};
|