fixed edit device (rediscovery)
This commit is contained in:
parent
ea03497b15
commit
cb8ff00702
@ -103,13 +103,6 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::discoverDevices(const DeviceCl
|
|||||||
DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *device)
|
DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (Device* d, myDevices()) {
|
|
||||||
if (d->paramValue("uuid").toString() == device->paramValue("uuid").toString()) {
|
|
||||||
qWarning() << "LG Smart Tv (" << device->paramValue("model").toString() << ")" << "allready added....";
|
|
||||||
return DeviceManager::DeviceSetupStatusFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
device->setName("LG Smart Tv (" + device->paramValue("model").toString() + ")");
|
device->setName("LG Smart Tv (" + device->paramValue("model").toString() + ")");
|
||||||
|
|
||||||
UpnpDeviceDescriptor upnpDeviceDescriptor;
|
UpnpDeviceDescriptor upnpDeviceDescriptor;
|
||||||
@ -125,7 +118,6 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *devi
|
|||||||
|
|
||||||
// TODO: make dynamic...displayPin setup!!!
|
// TODO: make dynamic...displayPin setup!!!
|
||||||
tvDevice->setKey("539887");
|
tvDevice->setKey("539887");
|
||||||
tvDevice->setupEventHandler();
|
|
||||||
|
|
||||||
connect(tvDevice, &TvDevice::pairingFinished, this, &DevicePluginLgSmartTv::pairingFinished);
|
connect(tvDevice, &TvDevice::pairingFinished, this, &DevicePluginLgSmartTv::pairingFinished);
|
||||||
connect(tvDevice, &TvDevice::sendCommandFinished, this, &DevicePluginLgSmartTv::sendingCommandFinished);
|
connect(tvDevice, &TvDevice::sendCommandFinished, this, &DevicePluginLgSmartTv::sendingCommandFinished);
|
||||||
@ -211,8 +203,12 @@ void DevicePluginLgSmartTv::upnpDiscoveryFinished(const QList<UpnpDeviceDescript
|
|||||||
void DevicePluginLgSmartTv::upnpNotifyReceived(const QByteArray ¬ifyData)
|
void DevicePluginLgSmartTv::upnpNotifyReceived(const QByteArray ¬ifyData)
|
||||||
{
|
{
|
||||||
Q_UNUSED(notifyData);
|
Q_UNUSED(notifyData);
|
||||||
// qDebug() << "######################################";
|
}
|
||||||
// qDebug() << notifyData;
|
|
||||||
|
void DevicePluginLgSmartTv::postSetupDevice(Device *device)
|
||||||
|
{
|
||||||
|
TvDevice *tvDevice= m_tvList.key(device);
|
||||||
|
tvDevice->setupEventHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginLgSmartTv::deviceRemoved(Device *device)
|
void DevicePluginLgSmartTv::deviceRemoved(Device *device)
|
||||||
@ -223,8 +219,9 @@ void DevicePluginLgSmartTv::deviceRemoved(Device *device)
|
|||||||
|
|
||||||
TvDevice *tvDevice= m_tvList.key(device);
|
TvDevice *tvDevice= m_tvList.key(device);
|
||||||
qDebug() << "remove LG SmartTv " << tvDevice->modelName();
|
qDebug() << "remove LG SmartTv " << tvDevice->modelName();
|
||||||
|
tvDevice->endPairing();
|
||||||
m_tvList.remove(tvDevice);
|
m_tvList.remove(tvDevice);
|
||||||
tvDevice->deleteLater();
|
delete tvDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginLgSmartTv::guhTimer()
|
void DevicePluginLgSmartTv::guhTimer()
|
||||||
@ -240,14 +237,6 @@ void DevicePluginLgSmartTv::pairingFinished(const bool &success)
|
|||||||
TvDevice *tvDevice = static_cast<TvDevice*>(sender());
|
TvDevice *tvDevice = static_cast<TvDevice*>(sender());
|
||||||
Device *device = m_tvList.value(tvDevice);
|
Device *device = m_tvList.value(tvDevice);
|
||||||
|
|
||||||
// check if we allready set up this device...
|
|
||||||
foreach (Device *configuredDevice, deviceManager()->findConfiguredDevices(lgSmartTvDeviceClassId)) {
|
|
||||||
if (configuredDevice->paramValue("uuid").toString() == device->paramValue("uuid").toString()) {
|
|
||||||
tvDevice->refresh();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...otherwise emit deviceSetupFinished with appropriate DeviceError
|
// ...otherwise emit deviceSetupFinished with appropriate DeviceError
|
||||||
if (success) {
|
if (success) {
|
||||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public:
|
|||||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||||
void upnpDiscoveryFinished(const QList<UpnpDeviceDescriptor> &upnpDeviceDescriptorList) override;
|
void upnpDiscoveryFinished(const QList<UpnpDeviceDescriptor> &upnpDeviceDescriptorList) override;
|
||||||
void upnpNotifyReceived(const QByteArray ¬ifyData);
|
void upnpNotifyReceived(const QByteArray ¬ifyData);
|
||||||
|
void postSetupDevice(Device *device) override;
|
||||||
|
|
||||||
void deviceRemoved(Device *device) override;
|
void deviceRemoved(Device *device) override;
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ void TvDevice::sendCommand(TvDevice::RemoteKey key, ActionId actionId)
|
|||||||
void TvDevice::setupEventHandler()
|
void TvDevice::setupEventHandler()
|
||||||
{
|
{
|
||||||
//qDebug() << "set up event handler " << m_hostAddress.toString() << m_port;
|
//qDebug() << "set up event handler " << m_hostAddress.toString() << m_port;
|
||||||
m_eventHandler = new TvEventHandler(this,hostAddress(),port());
|
m_eventHandler = new TvEventHandler(this, hostAddress(), port());
|
||||||
connect(m_eventHandler, &TvEventHandler::eventOccured, this, &TvDevice::eventOccured);
|
connect(m_eventHandler, &TvEventHandler::eventOccured, this, &TvDevice::eventOccured);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user