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.
Michael Zanetti 22dd3fe27d intermediate commit.
Working pretty well now. No cleanup done. some broken menu entries related to
connect.

TBC
2019-02-06 03:00:43 +01:00

70 lines
2.4 KiB
C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stuerz <stuerz.simon@gmail.com> *
* *
* 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 <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef UPNPDISCOVERY_H
#define UPNPDISCOVERY_H
#include <QUdpSocket>
#include <QHostAddress>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QTimer>
#include "../nymeahost.h"
#include "../nymeahosts.h"
class UpnpDiscovery : public QObject
{
Q_OBJECT
public:
explicit UpnpDiscovery(NymeaHosts *nymeaHosts, QObject *parent = nullptr);
bool discovering() const;
bool available() const;
Q_INVOKABLE void discover();
Q_INVOKABLE void stopDiscovery();
private:
QList<QUdpSocket*> m_sockets;
QNetworkAccessManager *m_networkAccessManager;
QTimer m_repeatTimer;
NymeaHosts *m_nymeaHosts;
QHash<QNetworkReply *, QHostAddress> m_runningReplies;
QList<QUrl> m_foundDevices;
signals:
void discoveringChanged();
void availableChanged();
void nymeaHostsChanged();
private slots:
void writeDiscoveryPacket();
void error(QAbstractSocket::SocketError error);
void readData();
void networkReplyFinished(QNetworkReply *reply);
};
#endif // UPNPDISCOVERY_H