From b88994e3f47716064cdc7f13903dabce2d3ac560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 9 Mar 2015 15:52:22 +0100 Subject: [PATCH] added postSetupDevice --- libguh/devicemanager.cpp | 12 +++++++++++- libguh/devicemanager.h | 1 + libguh/plugin/deviceplugin.cpp | 6 ++++++ libguh/plugin/deviceplugin.h | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libguh/devicemanager.cpp b/libguh/devicemanager.cpp index 70872ce9..07dbd605 100644 --- a/libguh/devicemanager.cpp +++ b/libguh/devicemanager.cpp @@ -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 &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 paramTypes, ParamList ¶ms, bool requireAll) { foreach (const Param ¶m, params) { diff --git a/libguh/devicemanager.h b/libguh/devicemanager.h index 8642cac6..298721a5 100644 --- a/libguh/devicemanager.h +++ b/libguh/devicemanager.h @@ -137,6 +137,7 @@ private: bool verifyPluginMetadata(const QJsonObject &data); DeviceError addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId()); DeviceSetupStatus setupDevice(Device *device); + void postSetupDevice(Device *device); DeviceError verifyParams(const QList paramTypes, ParamList ¶ms, bool requireAll = true); DeviceError verifyParam(const QList paramTypes, const Param ¶m); DeviceError verifyParam(const ParamType ¶mType, const Param ¶m); diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 7ec80ebb..5f93a94c 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -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.*/ diff --git a/libguh/plugin/deviceplugin.h b/libguh/plugin/deviceplugin.h index cdf29263..7608b25a 100644 --- a/libguh/plugin/deviceplugin.h +++ b/libguh/plugin/deviceplugin.h @@ -54,6 +54,7 @@ public: virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms); 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 ¶ms);