mirror of https://github.com/nymea/nymea.git
Restructure a bit
parent
6af2639183
commit
5a03cb840b
|
|
@ -25,7 +25,6 @@
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
|
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
#include "platform/platformzeroconfcontroller.h"
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
|
||||||
|
|
||||||
#include "hardwaremanagerimplementation.h"
|
#include "hardwaremanagerimplementation.h"
|
||||||
#include "hardware/plugintimermanagerimplementation.h"
|
#include "hardware/plugintimermanagerimplementation.h"
|
||||||
|
|
@ -72,8 +71,8 @@ HardwareManagerImplementation::HardwareManagerImplementation(Platform *platform,
|
||||||
if (m_upnpDiscovery->available())
|
if (m_upnpDiscovery->available())
|
||||||
setResourceEnabled(m_upnpDiscovery, true);
|
setResourceEnabled(m_upnpDiscovery, true);
|
||||||
|
|
||||||
if (m_platform->zeroConfController()->zeroConfServiceBrowser()->available())
|
if (m_platform->zeroConfController()->available())
|
||||||
setResourceEnabled(m_platform->zeroConfController()->zeroConfServiceBrowser(), true);
|
setResourceEnabled(m_platform->zeroConfController(), true);
|
||||||
|
|
||||||
if (m_bluetoothLowEnergyManager->available())
|
if (m_bluetoothLowEnergyManager->available())
|
||||||
setResourceEnabled(m_bluetoothLowEnergyManager, true);
|
setResourceEnabled(m_bluetoothLowEnergyManager, true);
|
||||||
|
|
@ -105,9 +104,9 @@ UpnpDiscovery *HardwareManagerImplementation::upnpDiscovery()
|
||||||
return m_upnpDiscovery;
|
return m_upnpDiscovery;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroConfServiceBrowser *HardwareManagerImplementation::zeroConfServiceBrowser()
|
PlatformZeroConfController *HardwareManagerImplementation::zeroConfController()
|
||||||
{
|
{
|
||||||
return m_platform->zeroConfController()->zeroConfServiceBrowser();
|
return m_platform->zeroConfController();
|
||||||
}
|
}
|
||||||
|
|
||||||
BluetoothLowEnergyManager *HardwareManagerImplementation::bluetoothLowEnergyManager()
|
BluetoothLowEnergyManager *HardwareManagerImplementation::bluetoothLowEnergyManager()
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class UpnpDiscovery;
|
||||||
class PluginTimerManager;
|
class PluginTimerManager;
|
||||||
class NetworkAccessManager;
|
class NetworkAccessManager;
|
||||||
class UpnpDeviceDescriptor;
|
class UpnpDeviceDescriptor;
|
||||||
class ZeroConfServiceBrowser;
|
class PlatformZeroConfController;
|
||||||
class BluetoothLowEnergyManager;
|
class BluetoothLowEnergyManager;
|
||||||
|
|
||||||
namespace nymeaserver {
|
namespace nymeaserver {
|
||||||
|
|
@ -54,7 +54,7 @@ public:
|
||||||
PluginTimerManager *pluginTimerManager() override;
|
PluginTimerManager *pluginTimerManager() override;
|
||||||
NetworkAccessManager *networkManager() override;
|
NetworkAccessManager *networkManager() override;
|
||||||
UpnpDiscovery *upnpDiscovery() override;
|
UpnpDiscovery *upnpDiscovery() override;
|
||||||
ZeroConfServiceBrowser *zeroConfServiceBrowser() override;
|
PlatformZeroConfController *zeroConfController() override;
|
||||||
BluetoothLowEnergyManager *bluetoothLowEnergyManager() override;
|
BluetoothLowEnergyManager *bluetoothLowEnergyManager() override;
|
||||||
MqttProvider *mqttProvider() override;
|
MqttProvider *mqttProvider() override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ bool ServerManager::registerZeroConfService(const ServerConfiguration &configura
|
||||||
txt.insert("name", NymeaCore::instance()->configuration()->serverName());
|
txt.insert("name", NymeaCore::instance()->configuration()->serverName());
|
||||||
txt.insert("sslEnabled", configuration.sslEnabled ? "true" : "false");
|
txt.insert("sslEnabled", configuration.sslEnabled ? "true" : "false");
|
||||||
QString name = "nymea-" + serverType + "-" + configuration.id;
|
QString name = "nymea-" + serverType + "-" + configuration.id;
|
||||||
if (!m_platform->zeroConfController()->zeroConfServicePublisher()->registerService(name, configuration.address, static_cast<quint16>(configuration.port), serviceType, txt)) {
|
if (!m_platform->zeroConfController()->servicePublisher()->registerService(name, configuration.address, static_cast<quint16>(configuration.port), serviceType, txt)) {
|
||||||
qCWarning(dcServerManager()) << "Could not register ZeroConf service for" << configuration;
|
qCWarning(dcServerManager()) << "Could not register ZeroConf service for" << configuration;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -338,7 +338,7 @@ bool ServerManager::registerZeroConfService(const ServerConfiguration &configura
|
||||||
|
|
||||||
void ServerManager::unregisterZeroConfService(const QString &configId, const QString &serverType)
|
void ServerManager::unregisterZeroConfService(const QString &configId, const QString &serverType)
|
||||||
{
|
{
|
||||||
m_platform->zeroConfController()->zeroConfServicePublisher()->unregisterService("nymea-" + serverType + "-" + configId);
|
m_platform->zeroConfController()->servicePublisher()->unregisterService("nymea-" + serverType + "-" + configId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerManager::loadCertificate(const QString &certificateKeyFileName, const QString &certificateFileName)
|
bool ServerManager::loadCertificate(const QString &certificateKeyFileName, const QString &certificateFileName)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class UpnpDiscovery;
|
||||||
class PluginTimerManager;
|
class PluginTimerManager;
|
||||||
class NetworkAccessManager;
|
class NetworkAccessManager;
|
||||||
class UpnpDeviceDescriptor;
|
class UpnpDeviceDescriptor;
|
||||||
class ZeroConfServiceBrowser;
|
class PlatformZeroConfController;
|
||||||
class BluetoothLowEnergyManager;
|
class BluetoothLowEnergyManager;
|
||||||
class MqttProvider;
|
class MqttProvider;
|
||||||
class HardwareResource;
|
class HardwareResource;
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
virtual PluginTimerManager *pluginTimerManager() = 0;
|
virtual PluginTimerManager *pluginTimerManager() = 0;
|
||||||
virtual NetworkAccessManager *networkManager() = 0;
|
virtual NetworkAccessManager *networkManager() = 0;
|
||||||
virtual UpnpDiscovery *upnpDiscovery() = 0;
|
virtual UpnpDiscovery *upnpDiscovery() = 0;
|
||||||
virtual ZeroConfServiceBrowser *zeroConfServiceBrowser() = 0;
|
virtual PlatformZeroConfController *zeroConfController() = 0;
|
||||||
virtual BluetoothLowEnergyManager *bluetoothLowEnergyManager() = 0;
|
virtual BluetoothLowEnergyManager *bluetoothLowEnergyManager() = 0;
|
||||||
virtual MqttProvider *mqttProvider() = 0;
|
virtual MqttProvider *mqttProvider() = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,25 +102,10 @@
|
||||||
#include "zeroconfservicebrowser.h"
|
#include "zeroconfservicebrowser.h"
|
||||||
|
|
||||||
/*! Constructs a new \l{ZeroConfServiceBrowser} with the given \a parent. */
|
/*! Constructs a new \l{ZeroConfServiceBrowser} with the given \a parent. */
|
||||||
ZeroConfServiceBrowser::ZeroConfServiceBrowser(QObject *parent) :
|
ZeroConfServiceBrowser::ZeroConfServiceBrowser(const QString &serviceType, QObject *parent):
|
||||||
HardwareResource("ZeroConf service browser", parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(serviceType)
|
||||||
}
|
|
||||||
|
|
||||||
bool ZeroConfServiceBrowser::available() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZeroConfServiceBrowser::enabled() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZeroConfServiceBrowser::setEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
Q_UNUSED(enabled)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ZeroConfServiceEntry> ZeroConfServiceBrowser::serviceEntries() const
|
QList<ZeroConfServiceEntry> ZeroConfServiceBrowser::serviceEntries() const
|
||||||
|
|
|
||||||
|
|
@ -26,22 +26,16 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "libnymea.h"
|
#include "libnymea.h"
|
||||||
#include "hardwareresource.h"
|
|
||||||
#include "zeroconfserviceentry.h"
|
#include "zeroconfserviceentry.h"
|
||||||
|
|
||||||
class LIBNYMEA_EXPORT ZeroConfServiceBrowser : public HardwareResource
|
class LIBNYMEA_EXPORT ZeroConfServiceBrowser : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ZeroConfServiceBrowser(QObject *parent = nullptr);
|
explicit ZeroConfServiceBrowser(const QString &serviceType = QString(), QObject *parent = nullptr);
|
||||||
virtual ~ZeroConfServiceBrowser() = default;
|
virtual ~ZeroConfServiceBrowser() = default;
|
||||||
|
|
||||||
virtual bool available() const override;
|
|
||||||
virtual bool enabled() const override;
|
|
||||||
virtual void setEnabled(bool enabled) override;
|
|
||||||
|
|
||||||
|
|
||||||
virtual QList<ZeroConfServiceEntry> serviceEntries() const;
|
virtual QList<ZeroConfServiceEntry> serviceEntries() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,32 @@
|
||||||
#include "network/zeroconf/zeroconfservicepublisher.h"
|
#include "network/zeroconf/zeroconfservicepublisher.h"
|
||||||
|
|
||||||
PlatformZeroConfController::PlatformZeroConfController(QObject *parent):
|
PlatformZeroConfController::PlatformZeroConfController(QObject *parent):
|
||||||
QObject(parent)
|
HardwareResource("ZeroConf", parent)
|
||||||
{
|
{
|
||||||
m_zeroConfBrowserStub = new ZeroConfServiceBrowser(this);
|
m_zeroConfPublisherDummy = new ZeroConfServicePublisher(this);
|
||||||
m_zeroConfPublisherStub = new ZeroConfServicePublisher(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroConfServiceBrowser *PlatformZeroConfController::zeroConfServiceBrowser() const
|
ZeroConfServiceBrowser *PlatformZeroConfController::createServiceBrowser(const QString &serviceType)
|
||||||
{
|
{
|
||||||
return m_zeroConfBrowserStub;
|
return new ZeroConfServiceBrowser(serviceType, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroConfServicePublisher *PlatformZeroConfController::zeroConfServicePublisher() const
|
ZeroConfServicePublisher *PlatformZeroConfController::servicePublisher() const
|
||||||
{
|
{
|
||||||
return m_zeroConfPublisherStub;
|
return m_zeroConfPublisherDummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlatformZeroConfController::available() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlatformZeroConfController::enabled() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlatformZeroConfController::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
Q_UNUSED(enabled)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,23 +24,28 @@
|
||||||
#define PLATFORMZEROCONFCONTROLLER_H
|
#define PLATFORMZEROCONFCONTROLLER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "hardwareresource.h"
|
||||||
|
|
||||||
class ZeroConfServiceBrowser;
|
class ZeroConfServiceBrowser;
|
||||||
class ZeroConfServicePublisher;
|
class ZeroConfServicePublisher;
|
||||||
|
|
||||||
class PlatformZeroConfController: public QObject
|
class PlatformZeroConfController: public HardwareResource
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PlatformZeroConfController(QObject *parent = nullptr);
|
explicit PlatformZeroConfController(QObject *parent = nullptr);
|
||||||
virtual ~PlatformZeroConfController() = default;
|
virtual ~PlatformZeroConfController() = default;
|
||||||
|
|
||||||
virtual ZeroConfServiceBrowser *zeroConfServiceBrowser() const;
|
virtual ZeroConfServiceBrowser *createServiceBrowser(const QString &serviceType = QString());
|
||||||
virtual ZeroConfServicePublisher *zeroConfServicePublisher() const;
|
virtual ZeroConfServicePublisher *servicePublisher() const;
|
||||||
|
|
||||||
|
// HardwareResource
|
||||||
|
virtual bool available() const override;
|
||||||
|
virtual bool enabled() const override;
|
||||||
|
virtual void setEnabled(bool enabled) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ZeroConfServiceBrowser *m_zeroConfBrowserStub = nullptr;
|
ZeroConfServicePublisher *m_zeroConfPublisherDummy = nullptr;
|
||||||
ZeroConfServicePublisher *m_zeroConfPublisherStub = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(PlatformZeroConfController, "io.nymea.PlatformZeroConfController")
|
Q_DECLARE_INTERFACE(PlatformZeroConfController, "io.nymea.PlatformZeroConfController")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue