fixed edit device (rediscovery)

pull/135/head
Simon Stürz 2015-05-26 18:49:48 +02:00 committed by Michael Zanetti
parent ea03497b15
commit cb8ff00702
3 changed files with 10 additions and 20 deletions

View File

@ -103,13 +103,6 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::discoverDevices(const DeviceCl
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() + ")");
UpnpDeviceDescriptor upnpDeviceDescriptor;
@ -125,7 +118,6 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *devi
// TODO: make dynamic...displayPin setup!!!
tvDevice->setKey("539887");
tvDevice->setupEventHandler();
connect(tvDevice, &TvDevice::pairingFinished, this, &DevicePluginLgSmartTv::pairingFinished);
connect(tvDevice, &TvDevice::sendCommandFinished, this, &DevicePluginLgSmartTv::sendingCommandFinished);
@ -211,8 +203,12 @@ void DevicePluginLgSmartTv::upnpDiscoveryFinished(const QList<UpnpDeviceDescript
void DevicePluginLgSmartTv::upnpNotifyReceived(const QByteArray &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)
@ -223,8 +219,9 @@ void DevicePluginLgSmartTv::deviceRemoved(Device *device)
TvDevice *tvDevice= m_tvList.key(device);
qDebug() << "remove LG SmartTv " << tvDevice->modelName();
tvDevice->endPairing();
m_tvList.remove(tvDevice);
tvDevice->deleteLater();
delete tvDevice;
}
void DevicePluginLgSmartTv::guhTimer()
@ -240,14 +237,6 @@ void DevicePluginLgSmartTv::pairingFinished(const bool &success)
TvDevice *tvDevice = static_cast<TvDevice*>(sender());
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
if (success) {
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);

View File

@ -42,6 +42,7 @@ public:
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
void upnpDiscoveryFinished(const QList<UpnpDeviceDescriptor> &upnpDeviceDescriptorList) override;
void upnpNotifyReceived(const QByteArray &notifyData);
void postSetupDevice(Device *device) override;
void deviceRemoved(Device *device) override;

View File

@ -172,7 +172,7 @@ void TvDevice::sendCommand(TvDevice::RemoteKey key, ActionId actionId)
void TvDevice::setupEventHandler()
{
//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);
}