Another api change
This commit is contained in:
parent
40c0de8863
commit
0820dad5ef
@ -44,6 +44,7 @@
|
|||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
#include "platform/platformzeroconfcontroller.h"
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -56,12 +57,6 @@ DevicePluginAvahiMonitor::DevicePluginAvahiMonitor()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginAvahiMonitor::init()
|
|
||||||
{
|
|
||||||
connect(hardwareManager()->zeroConfServiceBrowser(), &ZeroConfServiceBrowser::serviceEntryAdded, this, &DevicePluginAvahiMonitor::onServiceEntryAdded);
|
|
||||||
connect(hardwareManager()->zeroConfServiceBrowser(), &ZeroConfServiceBrowser::serviceEntryRemoved, this, &DevicePluginAvahiMonitor::onServiceEntryRemoved);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePluginAvahiMonitor::setupDevice(Device *device)
|
DeviceManager::DeviceSetupStatus DevicePluginAvahiMonitor::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
qCDebug(dcAvahiMonitor()) << "Setup" << device->name() << device->params();
|
qCDebug(dcAvahiMonitor()) << "Setup" << device->name() << device->params();
|
||||||
@ -76,8 +71,14 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic
|
|||||||
if (deviceClassId != avahiDeviceClassId)
|
if (deviceClassId != avahiDeviceClassId)
|
||||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||||
|
|
||||||
|
if (!m_serviceBrowser) {
|
||||||
|
m_serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser();
|
||||||
|
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryAdded, this, &DevicePluginAvahiMonitor::onServiceEntryAdded);
|
||||||
|
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryRemoved, this, &DevicePluginAvahiMonitor::onServiceEntryRemoved);
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceDescriptor> deviceDescriptors;
|
QList<DeviceDescriptor> deviceDescriptors;
|
||||||
foreach (const ZeroConfServiceEntry &service, hardwareManager()->zeroConfServiceBrowser()->serviceEntries()) {
|
foreach (const ZeroConfServiceEntry &service, m_serviceBrowser->serviceEntries()) {
|
||||||
DeviceDescriptor deviceDescriptor(avahiDeviceClassId, service.name(), service.hostAddress().toString());
|
DeviceDescriptor deviceDescriptor(avahiDeviceClassId, service.name(), service.hostAddress().toString());
|
||||||
ParamList params;
|
ParamList params;
|
||||||
params.append(Param(avahiDeviceServiceParamTypeId, service.name()));
|
params.append(Param(avahiDeviceServiceParamTypeId, service.name()));
|
||||||
@ -99,6 +100,7 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic
|
|||||||
|
|
||||||
void DevicePluginAvahiMonitor::onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry)
|
void DevicePluginAvahiMonitor::onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry)
|
||||||
{
|
{
|
||||||
|
qCDebug(dcAvahiMonitor()) << "Service entry added:" << serviceEntry;
|
||||||
foreach (Device *device, myDevices()) {
|
foreach (Device *device, myDevices()) {
|
||||||
if (device->paramValue(avahiDeviceServiceParamTypeId).toString() == serviceEntry.name()) {
|
if (device->paramValue(avahiDeviceServiceParamTypeId).toString() == serviceEntry.name()) {
|
||||||
device->setStateValue(avahiIsPresentStateTypeId, true);
|
device->setStateValue(avahiIsPresentStateTypeId, true);
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#define DEVICEPLUGINAVAHIMONITOR_H
|
#define DEVICEPLUGINAVAHIMONITOR_H
|
||||||
|
|
||||||
#include "plugin/deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
#include "network/zeroconf/zeroconfserviceentry.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@ -39,14 +40,15 @@ class DevicePluginAvahiMonitor : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginAvahiMonitor();
|
explicit DevicePluginAvahiMonitor();
|
||||||
|
|
||||||
void init() override;
|
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
|
void onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
|
||||||
void onServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry);
|
void onServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZeroConfServiceBrowser *m_serviceBrowser = nullptr;;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEPLUGINAVAHIMONITOR_H
|
#endif // DEVICEPLUGINAVAHIMONITOR_H
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "network/upnp/upnpdiscovery.h"
|
#include "network/upnp/upnpdiscovery.h"
|
||||||
|
#include "platform/platformzeroconfcontroller.h"
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
#include "network/zeroconf/zeroconfserviceentry.h"
|
||||||
#include "network/networkaccessmanager.h"
|
#include "network/networkaccessmanager.h"
|
||||||
@ -183,9 +184,10 @@ DeviceManager::DeviceError DevicePluginKodi::discoverDevices(const DeviceClassId
|
|||||||
Q_UNUSED(params)
|
Q_UNUSED(params)
|
||||||
Q_UNUSED(deviceClassId)
|
Q_UNUSED(deviceClassId)
|
||||||
|
|
||||||
QList<DeviceDescriptor> descriptors;
|
ZeroConfServiceBrowser *serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser("_xbmc-jsonrpc._tcp");
|
||||||
foreach (const ZeroConfServiceEntry &avahiEntry, hardwareManager()->zeroConfServiceBrowser()->serviceEntries()) {
|
QTimer::singleShot(5000, this, [this, serviceBrowser](){
|
||||||
if (avahiEntry.serviceType() == "_xbmc-jsonrpc._tcp") {
|
QList<DeviceDescriptor> descriptors;
|
||||||
|
foreach (const ZeroConfServiceEntry avahiEntry, serviceBrowser->serviceEntries()) {
|
||||||
qCDebug(dcKodi) << "Zeroconf entry:" << avahiEntry;
|
qCDebug(dcKodi) << "Zeroconf entry:" << avahiEntry;
|
||||||
DeviceDescriptor descriptor(kodiDeviceClassId, avahiEntry.name(), avahiEntry.hostName() + " (" + avahiEntry.hostAddress().toString() + ")");
|
DeviceDescriptor descriptor(kodiDeviceClassId, avahiEntry.name(), avahiEntry.hostName() + " (" + avahiEntry.hostAddress().toString() + ")");
|
||||||
ParamList params;
|
ParamList params;
|
||||||
@ -194,10 +196,9 @@ DeviceManager::DeviceError DevicePluginKodi::discoverDevices(const DeviceClassId
|
|||||||
descriptor.setParams(params);
|
descriptor.setParams(params);
|
||||||
descriptors << descriptor;
|
descriptors << descriptor;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!descriptors.isEmpty()) {
|
|
||||||
emit devicesDiscovered(kodiDeviceClassId, descriptors);
|
emit devicesDiscovered(kodiDeviceClassId, descriptors);
|
||||||
}
|
serviceBrowser->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
return DeviceManager::DeviceErrorAsync;
|
return DeviceManager::DeviceErrorAsync;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user