46 lines
948 B
C++
46 lines
948 B
C++
#ifndef MQTTCONTROLLER_H
|
|
#define MQTTCONTROLLER_H
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include "appconfig.h"
|
|
|
|
struct mosquitto;
|
|
struct mosquitto_message;
|
|
|
|
class MqttController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MqttController(const MqttConfig &config, QObject *parent = nullptr);
|
|
~MqttController();
|
|
|
|
void start();
|
|
|
|
signals:
|
|
void play();
|
|
void pause();
|
|
void nextImage();
|
|
void nextFolder();
|
|
void restart();
|
|
void immichControl(const QString &payload);
|
|
|
|
private slots:
|
|
void handleMessage(const QString &topic, const QString &payload);
|
|
|
|
private:
|
|
static void HandleConnect(struct mosquitto *mosq, void *userdata, int rc);
|
|
static void HandleMessage(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *message);
|
|
|
|
void subscribe();
|
|
|
|
MqttConfig config;
|
|
QString controlTopic;
|
|
QString immichTopic;
|
|
struct mosquitto *client = nullptr;
|
|
bool connected = false;
|
|
};
|
|
|
|
#endif // MQTTCONTROLLER_H
|