added postSetupDevice

pull/135/head
Simon Stürz 2015-03-09 15:52:22 +01:00 committed by Michael Zanetti
parent e555754706
commit b88994e3f4
4 changed files with 19 additions and 1 deletions

View File

@ -473,7 +473,7 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDeviceInternal(const Devi
m_configuredDevices.append(device);
storeConfiguredDevices();
postSetupDevice(device);
return DeviceErrorNoError;
}
@ -864,6 +864,7 @@ void DeviceManager::slotPairingFinished(const PairingTransactionId &pairingTrans
storeConfiguredDevices();
emit deviceSetupFinished(device, DeviceError::DeviceErrorNoError);
postSetupDevice(device);
}
void DeviceManager::autoDevicesAppeared(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &deviceDescriptors)
@ -894,6 +895,7 @@ void DeviceManager::autoDevicesAppeared(const DeviceClassId &deviceClassId, cons
case DeviceSetupStatusSuccess:
qDebug() << "Device setup complete.";
emit deviceSetupFinished(device, DeviceError::DeviceErrorNoError);
postSetupDevice(device);
m_configuredDevices.append(device);
storeConfiguredDevices();
break;
@ -1025,6 +1027,14 @@ DeviceManager::DeviceSetupStatus DeviceManager::setupDevice(Device *device)
return status;
}
void DeviceManager::postSetupDevice(Device *device)
{
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
plugin->postSetupDevice(device);
}
DeviceManager::DeviceError DeviceManager::verifyParams(const QList<ParamType> paramTypes, ParamList &params, bool requireAll)
{
foreach (const Param &param, params) {

View File

@ -137,6 +137,7 @@ private:
bool verifyPluginMetadata(const QJsonObject &data);
DeviceError addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList &params, const DeviceId id = DeviceId::createDeviceId());
DeviceSetupStatus setupDevice(Device *device);
void postSetupDevice(Device *device);
DeviceError verifyParams(const QList<ParamType> paramTypes, ParamList &params, bool requireAll = true);
DeviceError verifyParam(const QList<ParamType> paramTypes, const Param &param);
DeviceError verifyParam(const ParamType &paramType, const Param &param);

View File

@ -317,6 +317,12 @@ DeviceManager::DeviceSetupStatus DevicePlugin::setupDevice(Device *device)
return DeviceManager::DeviceSetupStatusSuccess;
}
/*! This will be called when a new \a device was added successfully and the device setup is finished.*/
void DevicePlugin::postSetupDevice(Device *device)
{
Q_UNUSED(device)
}
/*! This will be called when a \a device removed. The plugin has the chance to do some teardown.
* The device is still valid during this call, but already removed from the system.
* The device will be deleted as soon as this method returns.*/

View File

@ -54,6 +54,7 @@ public:
virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList &params);
virtual DeviceManager::DeviceSetupStatus setupDevice(Device *device);
virtual void postSetupDevice(Device *device);
virtual void deviceRemoved(Device *device);
virtual DeviceManager::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList &params);