This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-app/libnymea-app-core/nymeaconnection.h
Michael Zanetti 113963a77b add support for tagging
rework the main page completely by using the new features available for tagging
2018-07-02 01:10:31 +02:00

56 lines
1.5 KiB
C++

#ifndef NYMEACONNECTION_H
#define NYMEACONNECTION_H
#include <QObject>
#include <QHash>
#include <QSslError>
#include <QAbstractSocket>
#include <QUrl>
class NymeaInterface;
class NymeaConnection : public QObject
{
Q_OBJECT
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
Q_PROPERTY(QString url READ url NOTIFY connectedChanged)
Q_PROPERTY(QString hostAddress READ hostAddress NOTIFY connectedChanged)
public:
explicit NymeaConnection(QObject *parent = nullptr);
Q_INVOKABLE void connect(const QString &url);
Q_INVOKABLE void disconnect();
Q_INVOKABLE void acceptCertificate(const QString &url, const QByteArray &fingerprint);
Q_INVOKABLE bool isTrusted(const QString &url);
bool connected();
QString url() const;
QString hostAddress() const;
void sendData(const QByteArray &data);
signals:
void verifyConnectionCertificate(const QString &url, const QStringList &issuerInfo, const QByteArray &fingerprint);
void connectedChanged(bool connected);
void connectionError(const QString &error);
void dataAvailable(const QByteArray &data);
private slots:
void onSslErrors(const QList<QSslError> &errors);
void onError(QAbstractSocket::SocketError error);
void onConnected();
void onDisconnected();
private:
void registerInterface(NymeaInterface *iface);
private:
QHash<QString, NymeaInterface*> m_interfaces;
NymeaInterface *m_currentInterface = nullptr;
QUrl m_currentUrl;
};
#endif // NYMEACONNECTION_H