/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2015 Simon Stuerz * * * * This file is part of nymea:app. * * * * nymea:app is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, version 3 of the License. * * * * nymea:app 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with nymea:app. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef UPNPDISCOVERY_H #define UPNPDISCOVERY_H #include #include #include #include #include #include "discoverydevice.h" #include "discoverymodel.h" class UpnpDiscovery : public QObject { Q_OBJECT public: explicit UpnpDiscovery(DiscoveryModel *discoveryModel, QObject *parent = 0); bool discovering() const; bool available() const; Q_INVOKABLE void discover(); Q_INVOKABLE void stopDiscovery(); private: QList m_sockets; QNetworkAccessManager *m_networkAccessManager; QTimer m_repeatTimer; DiscoveryModel *m_discoveryModel; QHash m_runningReplies; QList m_foundDevices; signals: void discoveringChanged(); void availableChanged(); void discoveryModelChanged(); private slots: void writeDiscoveryPacket(); void error(QAbstractSocket::SocketError error); void readData(); void networkReplyFinished(QNetworkReply *reply); }; #endif // UPNPDISCOVERY_H