/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2017 - 2018 Simon Stuerz * * * * This file is part of nymea:app. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; If not, see * * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef NYMEATRANSPORTINTERFACE_H #define NYMEATRANSPORTINTERFACE_H #include #include #include class NymeaTransportInterface; class NymeaTransportInterfaceFactory { public: virtual ~NymeaTransportInterfaceFactory() = default; virtual NymeaTransportInterface* createTransport(QObject* parent = nullptr) const = 0; virtual QStringList supportedSchemes() const = 0; }; class NymeaTransportInterface : public QObject { Q_OBJECT public: enum ConnectionState { ConnectionStateDisconnected, ConnectionStateConnecting, ConnectionStateConnected }; Q_ENUM(ConnectionState) explicit NymeaTransportInterface(QObject *parent = nullptr); virtual ~NymeaTransportInterface() = default; virtual bool connect(const QUrl &url) = 0; virtual void disconnect() = 0; virtual ConnectionState connectionState() const = 0; virtual void sendData(const QByteArray &data) = 0; virtual void ignoreSslErrors(const QList &errors) { Q_UNUSED(errors) } signals: void connected(); void disconnected(); void error(QAbstractSocket::SocketError error); void sslErrors(const QList &errors); void dataReady(const QByteArray &data); }; #endif // NYMEATRANSPORTINTERFACE_H