diff --git a/denon/deviceplugindenon.cpp b/denon/deviceplugindenon.cpp index 27cf0fa5..5a54ae3c 100644 --- a/denon/deviceplugindenon.cpp +++ b/denon/deviceplugindenon.cpp @@ -43,13 +43,17 @@ #include "deviceplugindenon.h" #include "plugininfo.h" +#include "plugin/device.h" +#include "network/networkaccessmanager.h" #include "network/upnp/upnpdiscovery.h" #include "network/upnp/upnpdiscoveryreply.h" -#include "network/avahi/qtavahiservicebrowser.h" +#include "platform/platformzeroconfcontroller.h" +#include "network/zeroconf/zeroconfservicebrowser.h" #include #include #include +#include DevicePluginDenon::DevicePluginDenon() { @@ -61,24 +65,8 @@ DeviceManager::DeviceError DevicePluginDenon::discoverDevices(const DeviceClassI if (deviceClassId == AVRX1000DeviceClassId) { - QList deviceDescriptors; - foreach (const AvahiServiceEntry &service, hardwareManager()->avahiBrowser()->serviceEntries()) { - if (service.name().contains("AVR-X1000")) { - DeviceDescriptor deviceDescriptor(AVRX1000DeviceClassId, service.hostName().remove(".local"), service.hostAddress().toString()); - ParamList params; - qCDebug(dcDenon) << "Avahi discovered device: " << service.name() << service.hostName() << service.serviceType(); - params.append(Param(AVRX1000DeviceIpParamTypeId, service.hostAddress().toString())); - deviceDescriptor.setParams(params); - foreach (Device *existingDevice, myDevices()) { - if (existingDevice->paramValue(AVRX1000DeviceIpParamTypeId).toString() == service.hostAddress().toString()) { - deviceDescriptor.setDeviceId(existingDevice->id()); - break; - } - } - deviceDescriptors.append(deviceDescriptor); - } - } - emit devicesDiscovered(AVRX1000DeviceClassId, deviceDescriptors); + UpnpDiscoveryReply *reply = hardwareManager()->upnpDiscovery()->discoverDevices("urn:schemas-upnp-org:device:MediaRenderer:1", "nymea", 7000); + connect(reply, &UpnpDiscoveryReply::finished, this, &DevicePluginDenon::onUpnpDiscoveryFinished); return DeviceManager::DeviceErrorAsync; } @@ -497,7 +485,8 @@ void DevicePluginDenon::onUpnpDiscoveryFinished() return; } - QList deviceDescriptors; + QList heosDescriptors; + QList avrDescriptors; foreach (const UpnpDeviceDescriptor &upnpDevice, reply->deviceDescriptors()) { if (upnpDevice.modelName().contains("HEOS")) { @@ -517,11 +506,19 @@ void DevicePluginDenon::onUpnpDiscoveryFinished() params.append(Param(heosDeviceIpParamTypeId, upnpDevice.hostAddress().toString())); params.append(Param(heosDeviceSerialNumberParamTypeId, serialNumber)); descriptor.setParams(params); - deviceDescriptors.append(descriptor); + heosDescriptors.append(descriptor); } } + //if (upnpDevice.modelName().contains("")) { + qCDebug(dcDenon) << "UPnP device found:" << upnpDevice.modelDescription() << upnpDevice.friendlyName() << upnpDevice.hostAddress().toString() << upnpDevice.modelName() << upnpDevice.manufacturer() << upnpDevice.serialNumber(); + //} + } + if (!heosDescriptors.isEmpty()) { + emit devicesDiscovered(heosDeviceClassId, heosDescriptors); + } + if (!avrDescriptors.isEmpty()) { + emit devicesDiscovered(AVRX1000DeviceClassId, avrDescriptors); } - emit devicesDiscovered(heosDeviceClassId, deviceDescriptors); } void DevicePluginDenon::onHeosConnectionChanged() diff --git a/denon/deviceplugindenon.h b/denon/deviceplugindenon.h index a71cad8e..7da3f97a 100644 --- a/denon/deviceplugindenon.h +++ b/denon/deviceplugindenon.h @@ -67,6 +67,7 @@ private: private slots: void onPluginTimer(); + void onAVRConnectionChanged(); void onAVRDataReceived(const QByteArray &data); void onAVRSocketError();