Cache device classes and keep devices with missing plugins in the system
This commit is contained in:
parent
6e4a0bc84b
commit
68e9fe1ba1
52
libnymea-core/devices/deviceclasscache.cpp
Normal file
52
libnymea-core/devices/deviceclasscache.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "deviceclasscache.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
PluginInfoCache::PluginInfoCache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginInfoCache::cachePluginInfo(const QJsonObject &metaData)
|
||||||
|
{
|
||||||
|
QString fileName = metaData.value("id").toString().remove(QRegExp("[{}]")) + ".cache";
|
||||||
|
QDir path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/plugininfo/";
|
||||||
|
if (!path.exists()) {
|
||||||
|
if (!path.mkpath(path.absolutePath())) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Error creating device class cache dir at" << path.absolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QFile file(path.absoluteFilePath(fileName));
|
||||||
|
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Error opening device class cache for writing at" << path.absoluteFilePath(fileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.write(QJsonDocument::fromVariant(metaData.toVariantMap()).toJson(QJsonDocument::Compact));
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject PluginInfoCache::loadPluginInfo(const PluginId &pluginId)
|
||||||
|
{
|
||||||
|
QString fileName = pluginId.toString().remove(QRegExp("[{}]")) + ".cache";
|
||||||
|
QDir path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/plugininfo/";
|
||||||
|
QFile file(path.absoluteFilePath(fileName));
|
||||||
|
if (!file.open(QFile::ReadOnly)) {
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray data = file.readAll();
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
|
if (error.error != QJsonParseError::NoError) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Error parsing plugin info cache entry:" << path.absoluteFilePath(fileName);
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
return QJsonObject::fromVariantMap(jsonDoc.toVariant().toMap());
|
||||||
|
}
|
||||||
16
libnymea-core/devices/deviceclasscache.h
Normal file
16
libnymea-core/devices/deviceclasscache.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef PLUGININFOCACHE_H
|
||||||
|
#define PLUGININFOCACHE_H
|
||||||
|
|
||||||
|
#include "types/deviceclass.h"
|
||||||
|
#include "devices/deviceplugin.h"
|
||||||
|
|
||||||
|
class PluginInfoCache
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PluginInfoCache();
|
||||||
|
|
||||||
|
static void cachePluginInfo(const QJsonObject &metaData);
|
||||||
|
static QJsonObject loadPluginInfo(const PluginId &pluginId);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLUGININFOCACHE_H
|
||||||
@ -38,6 +38,7 @@
|
|||||||
#include "typeutils.h"
|
#include "typeutils.h"
|
||||||
#include "nymeasettings.h"
|
#include "nymeasettings.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "deviceclasscache.h"
|
||||||
|
|
||||||
#include "devices/devicediscoveryinfo.h"
|
#include "devices/devicediscoveryinfo.h"
|
||||||
#include "devices/devicepairinginfo.h"
|
#include "devices/devicepairinginfo.h"
|
||||||
@ -258,7 +259,7 @@ DeviceDiscoveryInfo* DeviceManagerImplementation::discoverDevices(const DeviceCl
|
|||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCWarning(dcDeviceManager) << "Device discovery failed. Plugin not found for device class" << deviceClass.name();
|
qCWarning(dcDeviceManager) << "Device discovery failed. Plugin not found for device class" << deviceClass.name();
|
||||||
DeviceDiscoveryInfo *discoveryInfo = new DeviceDiscoveryInfo(deviceClassId, params, this);
|
DeviceDiscoveryInfo *discoveryInfo = new DeviceDiscoveryInfo(deviceClassId, params, this);
|
||||||
discoveryInfo->finish(Device::DeviceErrorPluginNotFound);
|
discoveryInfo->finish(Device::DeviceErrorPluginNotFound, tr("The plugin for this device or service is not loaded."));
|
||||||
return discoveryInfo;
|
return discoveryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,9 +595,10 @@ DevicePairingInfo *DeviceManagerImplementation::confirmPairing(const PairingTran
|
|||||||
PairingContext context = m_pendingPairings.take(pairingTransactionId);
|
PairingContext context = m_pendingPairings.take(pairingTransactionId);
|
||||||
DeviceClassId deviceClassId = context.deviceClassId;
|
DeviceClassId deviceClassId = context.deviceClassId;
|
||||||
|
|
||||||
DevicePlugin *plugin = m_devicePlugins.value(m_supportedDevices.value(deviceClassId).pluginId());
|
DeviceClass deviceClass = m_supportedDevices.value(deviceClassId);
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCWarning(dcDeviceManager) << "Can't find a plugin for this device class";
|
qCWarning(dcDeviceManager) << "Can't find a plugin for this device class:" << deviceClass;
|
||||||
DevicePairingInfo *info = new DevicePairingInfo(pairingTransactionId, deviceClassId, context.deviceId, context.deviceName, context.params, context.parentDeviceId, this);
|
DevicePairingInfo *info = new DevicePairingInfo(pairingTransactionId, deviceClassId, context.deviceId, context.deviceName, context.params, context.parentDeviceId, this);
|
||||||
info->finish(Device::DeviceErrorPluginNotFound);
|
info->finish(Device::DeviceErrorPluginNotFound);
|
||||||
return info;
|
return info;
|
||||||
@ -633,7 +635,7 @@ DevicePairingInfo *DeviceManagerImplementation::confirmPairing(const PairingTran
|
|||||||
Device *device = nullptr;
|
Device *device = nullptr;
|
||||||
|
|
||||||
if (addNewDevice) {
|
if (addNewDevice) {
|
||||||
device = new Device(plugin, deviceClass, internalInfo->deviceId(), this);
|
device = new Device(plugin->pluginId(), deviceClass, internalInfo->deviceId(), this);
|
||||||
if (internalInfo->deviceName().isEmpty()) {
|
if (internalInfo->deviceName().isEmpty()) {
|
||||||
device->setName(deviceClass.displayName());
|
device->setName(deviceClass.displayName());
|
||||||
} else {
|
} else {
|
||||||
@ -735,7 +737,7 @@ DeviceSetupInfo* DeviceManagerImplementation::addConfiguredDeviceInternal(const
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
Device *device = new Device(plugin, deviceClass, deviceId, this);
|
Device *device = new Device(plugin->pluginId(), deviceClass, deviceId, this);
|
||||||
device->setParentId(parentDeviceId);
|
device->setParentId(parentDeviceId);
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
device->setName(deviceClass.name());
|
device->setName(deviceClass.name());
|
||||||
@ -809,13 +811,24 @@ BrowseResult *DeviceManagerImplementation::browseDevice(const DeviceId &deviceId
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||||
|
if (!plugin) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Plugin not found for device" << device;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device->setupComplete()) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Device did not finish setup" << device;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!device->deviceClass().browsable()) {
|
if (!device->deviceClass().browsable()) {
|
||||||
qCWarning(dcDeviceManager()) << "Cannot browse device. DeviceClass" << device->deviceClass().name() << "is not browsable.";
|
qCWarning(dcDeviceManager()) << "Cannot browse device. DeviceClass" << device->deviceClass().name() << "is not browsable.";
|
||||||
result->finish(Device::DeviceErrorUnsupportedFeature);
|
result->finish(Device::DeviceErrorUnsupportedFeature);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->plugin()->browseDevice(result);
|
plugin->browseDevice(result);
|
||||||
connect(result, &BrowseResult::finished, this, [result](){
|
connect(result, &BrowseResult::finished, this, [result](){
|
||||||
if (result->status() != Device::DeviceErrorNoError) {
|
if (result->status() != Device::DeviceErrorNoError) {
|
||||||
qCWarning(dcDeviceManager()) << "Browse device failed:" << result->status();
|
qCWarning(dcDeviceManager()) << "Browse device failed:" << result->status();
|
||||||
@ -836,13 +849,24 @@ BrowserItemResult *DeviceManagerImplementation::browserItemDetails(const DeviceI
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||||
|
if (!plugin) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Plugin not found for device" << device;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->setupStatus() != Device::DeviceSetupStatusComplete) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Device did not finish setup" << device;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!device->deviceClass().browsable()) {
|
if (!device->deviceClass().browsable()) {
|
||||||
qCWarning(dcDeviceManager()) << "Cannot browse device. DeviceClass" << device->deviceClass().name() << "is not browsable.";
|
qCWarning(dcDeviceManager()) << "Cannot browse device. DeviceClass" << device->deviceClass().name() << "is not browsable.";
|
||||||
result->finish(Device::DeviceErrorUnsupportedFeature);
|
result->finish(Device::DeviceErrorUnsupportedFeature);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->plugin()->browserItem(result);
|
plugin->browserItem(result);
|
||||||
connect(result, &BrowserItemResult::finished, this, [result](){
|
connect(result, &BrowserItemResult::finished, this, [result](){
|
||||||
if (result->status() != Device::DeviceErrorNoError) {
|
if (result->status() != Device::DeviceErrorNoError) {
|
||||||
qCWarning(dcDeviceManager()) << "Browse device failed:" << result->status();
|
qCWarning(dcDeviceManager()) << "Browse device failed:" << result->status();
|
||||||
@ -862,11 +886,24 @@ BrowserActionInfo* DeviceManagerImplementation::executeBrowserItem(const Browser
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||||
|
if (!plugin) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Plugin not found for device" << device;
|
||||||
|
info->finish(Device::DeviceErrorPluginNotFound);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->setupStatus() != Device::DeviceSetupStatusComplete) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot browse device. Device did not finish setup" << device;
|
||||||
|
info->finish(Device::DeviceErrorSetupFailed);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
if (!device->deviceClass().browsable()) {
|
if (!device->deviceClass().browsable()) {
|
||||||
info->finish(Device::DeviceErrorUnsupportedFeature);
|
info->finish(Device::DeviceErrorUnsupportedFeature);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
device->plugin()->executeBrowserItem(info);
|
plugin->executeBrowserItem(info);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,13 +918,26 @@ BrowserItemActionInfo* DeviceManagerImplementation::executeBrowserItemAction(con
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||||
|
if (!plugin) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute browser item action. Plugin not found for device" << device;
|
||||||
|
info->finish(Device::DeviceErrorPluginNotFound);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->setupStatus() != Device::DeviceSetupStatusComplete) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute browser item action. Device did not finish setup" << device;
|
||||||
|
info->finish(Device::DeviceErrorSetupFailed);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
if (!device->deviceClass().browsable()) {
|
if (!device->deviceClass().browsable()) {
|
||||||
info->finish(Device::DeviceErrorUnsupportedFeature);
|
info->finish(Device::DeviceErrorUnsupportedFeature);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
// TODO: check browserItemAction.params with deviceClass
|
// TODO: check browserItemAction.params with deviceClass
|
||||||
|
|
||||||
device->plugin()->executeBrowserItemAction(info);
|
plugin->executeBrowserItemAction(info);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1099,7 +1149,8 @@ void DeviceManagerImplementation::loadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMetadata metaData(loader.metaData().value("MetaData").toObject());
|
QJsonObject pluginInfo = loader.metaData().value("MetaData").toObject();
|
||||||
|
PluginMetadata metaData(pluginInfo);
|
||||||
if (!metaData.isValid()) {
|
if (!metaData.isValid()) {
|
||||||
foreach (const QString &error, metaData.validationErrors()) {
|
foreach (const QString &error, metaData.validationErrors()) {
|
||||||
qCWarning(dcDeviceManager()) << error;
|
qCWarning(dcDeviceManager()) << error;
|
||||||
@ -1119,6 +1170,7 @@ void DeviceManagerImplementation::loadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
loadPlugin(pluginIface, metaData);
|
loadPlugin(pluginIface, metaData);
|
||||||
|
PluginInfoCache::cachePluginInfo(pluginInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,13 +1301,28 @@ void DeviceManagerImplementation::loadConfiguredDevices()
|
|||||||
foreach (const QString &idString, settings.childGroups()) {
|
foreach (const QString &idString, settings.childGroups()) {
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
QString deviceName = settings.value("devicename").toString();
|
QString deviceName = settings.value("devicename").toString();
|
||||||
DevicePlugin *plugin = m_devicePlugins.value(PluginId(settings.value("pluginid").toString()));
|
PluginId pluginId = PluginId(settings.value("pluginid").toString());
|
||||||
|
DevicePlugin *plugin = m_devicePlugins.value(pluginId);
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCWarning(dcDeviceManager()) << "Not loading device" << deviceName << idString << "because the plugin for this device could not be found.";
|
qCWarning(dcDeviceManager()) << "Plugin for device" << deviceName << idString << "not found. This device will not be functional until the plugin can be loaded.";
|
||||||
settings.endGroup(); // DeviceId
|
}
|
||||||
continue;
|
DeviceClassId deviceClassId = DeviceClassId(settings.value("deviceClassId").toString());
|
||||||
|
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||||
|
if (!deviceClass.isValid()) {
|
||||||
|
// Try to load the device class from the cache
|
||||||
|
QJsonObject pluginInfo = PluginInfoCache::loadPluginInfo(pluginId);
|
||||||
|
if (!pluginInfo.empty()) {
|
||||||
|
PluginMetadata pluginMetadata(pluginInfo);
|
||||||
|
deviceClass = pluginMetadata.deviceClasses().findById(deviceClassId);
|
||||||
|
if (deviceClass.isValid()) {
|
||||||
|
m_supportedDevices.insert(deviceClassId, deviceClass);
|
||||||
|
if (!m_supportedVendors.contains(deviceClass.vendorId())) {
|
||||||
|
Vendor vendor = pluginMetadata.vendors().findById(deviceClass.vendorId());
|
||||||
|
m_supportedVendors.insert(vendor.id(), vendor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DeviceClass deviceClass = findDeviceClass(DeviceClassId(settings.value("deviceClassId").toString()));
|
|
||||||
if (!deviceClass.isValid()) {
|
if (!deviceClass.isValid()) {
|
||||||
qCWarning(dcDeviceManager()) << "Not loading device" << deviceName << idString << "because the device class for this device could not be found.";
|
qCWarning(dcDeviceManager()) << "Not loading device" << deviceName << idString << "because the device class for this device could not be found.";
|
||||||
settings.endGroup(); // DeviceId
|
settings.endGroup(); // DeviceId
|
||||||
@ -1263,12 +1330,12 @@ void DeviceManagerImplementation::loadConfiguredDevices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cross-check if this plugin still implements this device class
|
// Cross-check if this plugin still implements this device class
|
||||||
if (!plugin->supportedDevices().contains(deviceClass)) {
|
if (plugin && !plugin->supportedDevices().contains(deviceClass)) {
|
||||||
qCWarning(dcDeviceManager()) << "Not loading device" << deviceName << idString << "because plugin" << plugin->pluginName() << "has removed support for it.";
|
qCWarning(dcDeviceManager()) << "Not loading device" << deviceName << idString << "because plugin" << plugin->pluginName() << "has removed support for it.";
|
||||||
settings.endGroup(); // DeviceId
|
settings.endGroup(); // DeviceId
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Device *device = new Device(plugin, deviceClass, DeviceId(idString), this);
|
Device *device = new Device(pluginId, deviceClass, DeviceId(idString), this);
|
||||||
device->m_autoCreated = settings.value("autoCreated").toBool();
|
device->m_autoCreated = settings.value("autoCreated").toBool();
|
||||||
device->setName(deviceName);
|
device->setName(deviceName);
|
||||||
device->setParentId(DeviceId(settings.value("parentid", QUuid()).toString()));
|
device->setParentId(DeviceId(settings.value("parentid", QUuid()).toString()));
|
||||||
@ -1463,7 +1530,7 @@ void DeviceManagerImplementation::onAutoDevicesAppeared(const DeviceDescriptors
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
device = new Device(plugin, deviceClass, this);
|
device = new Device(plugin->pluginId(), deviceClass, this);
|
||||||
device->m_autoCreated = true;
|
device->m_autoCreated = true;
|
||||||
device->setName(deviceDescriptor.title());
|
device->setName(deviceDescriptor.title());
|
||||||
device->setParams(deviceDescriptor.params());
|
device->setParams(deviceDescriptor.params());
|
||||||
@ -1655,9 +1722,9 @@ DeviceSetupInfo* DeviceManagerImplementation::setupDevice(Device *device)
|
|||||||
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
|
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
|
||||||
|
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCWarning(dcDeviceManager) << "Can't find a plugin for this device" << device->id();
|
qCWarning(dcDeviceManager) << "Can't find a plugin for this device" << device;
|
||||||
DeviceSetupInfo *info = new DeviceSetupInfo(nullptr, this);
|
DeviceSetupInfo *info = new DeviceSetupInfo(device, this);
|
||||||
info->finish(Device::DeviceErrorPluginNotFound);
|
info->finish(Device::DeviceErrorPluginNotFound, tr("The plugin for this device or service is not loaded."));
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ RESOURCES += $$top_srcdir/icons.qrc \
|
|||||||
|
|
||||||
|
|
||||||
HEADERS += nymeacore.h \
|
HEADERS += nymeacore.h \
|
||||||
|
devices/deviceclasscache.h \
|
||||||
devices/devicemanagerimplementation.h \
|
devices/devicemanagerimplementation.h \
|
||||||
devices/translator.h \
|
devices/translator.h \
|
||||||
experiences/experiencemanager.h \
|
experiences/experiencemanager.h \
|
||||||
@ -100,6 +101,7 @@ HEADERS += nymeacore.h \
|
|||||||
|
|
||||||
|
|
||||||
SOURCES += nymeacore.cpp \
|
SOURCES += nymeacore.cpp \
|
||||||
|
devices/deviceclasscache.cpp \
|
||||||
devices/devicemanagerimplementation.cpp \
|
devices/devicemanagerimplementation.cpp \
|
||||||
devices/translator.cpp \
|
devices/translator.cpp \
|
||||||
experiences/experiencemanager.cpp \
|
experiences/experiencemanager.cpp \
|
||||||
|
|||||||
@ -119,20 +119,20 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
/*! Construct an Device with the given \a pluginId, \a id, \a deviceClassId and \a parent. */
|
/*! Construct an Device with the given \a pluginId, \a id, \a deviceClassId and \a parent. */
|
||||||
Device::Device(DevicePlugin *plugin, const DeviceClass &deviceClass, const DeviceId &id, QObject *parent):
|
Device::Device(const PluginId &pluginId, const DeviceClass &deviceClass, const DeviceId &id, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_deviceClass(deviceClass),
|
m_deviceClass(deviceClass),
|
||||||
m_plugin(plugin),
|
m_pluginId(pluginId),
|
||||||
m_id(id)
|
m_id(id)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Construct an Device with the given \a pluginId, \a deviceClassId and \a parent. A new DeviceId will be created for this Device. */
|
/*! Construct an Device with the given \a pluginId, \a deviceClassId and \a parent. A new DeviceId will be created for this Device. */
|
||||||
Device::Device(DevicePlugin *plugin, const DeviceClass &deviceClass, QObject *parent):
|
Device::Device(const PluginId &pluginId, const DeviceClass &deviceClass, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_deviceClass(deviceClass),
|
m_deviceClass(deviceClass),
|
||||||
m_plugin(plugin),
|
m_pluginId(pluginId),
|
||||||
m_id(DeviceId::createDeviceId())
|
m_id(DeviceId::createDeviceId())
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ DeviceClassId Device::deviceClassId() const
|
|||||||
/*! Returns the id of the \l{DevicePlugin} this Device is managed by. */
|
/*! Returns the id of the \l{DevicePlugin} this Device is managed by. */
|
||||||
PluginId Device::pluginId() const
|
PluginId Device::pluginId() const
|
||||||
{
|
{
|
||||||
return m_plugin->pluginId();
|
return m_pluginId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns the \l{DeviceClass} of this device. */
|
/*! Returns the \l{DeviceClass} of this device. */
|
||||||
@ -162,12 +162,6 @@ DeviceClass Device::deviceClass() const
|
|||||||
return m_deviceClass;
|
return m_deviceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns the the \l{DevicePlugin} this Device is managed by. */
|
|
||||||
DevicePlugin *Device::plugin() const
|
|
||||||
{
|
|
||||||
return m_plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Returns the name of this Device. This is visible to the user. */
|
/*! Returns the name of this Device. This is visible to the user. */
|
||||||
QString Device::name() const
|
QString Device::name() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -105,7 +105,6 @@ public:
|
|||||||
PluginId pluginId() const;
|
PluginId pluginId() const;
|
||||||
|
|
||||||
DeviceClass deviceClass() const;
|
DeviceClass deviceClass() const;
|
||||||
DevicePlugin* plugin() const;
|
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@ -153,14 +152,14 @@ signals:
|
|||||||
private:
|
private:
|
||||||
friend class DeviceManager;
|
friend class DeviceManager;
|
||||||
friend class DeviceManagerImplementation;
|
friend class DeviceManagerImplementation;
|
||||||
Device(DevicePlugin *plugin, const DeviceClass &deviceClass, const DeviceId &id, QObject *parent = nullptr);
|
Device(const PluginId &pluginId, const DeviceClass &deviceClass, const DeviceId &id, QObject *parent = nullptr);
|
||||||
Device(DevicePlugin *plugin, const DeviceClass &deviceClass, QObject *parent = nullptr);
|
Device(const PluginId &pluginId, const DeviceClass &deviceClass, QObject *parent = nullptr);
|
||||||
|
|
||||||
void setSetupStatus(Device::DeviceSetupStatus status, Device::DeviceError setupError, const QString &displayMessage = QString());
|
void setSetupStatus(Device::DeviceSetupStatus status, Device::DeviceError setupError, const QString &displayMessage = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceClass m_deviceClass;
|
DeviceClass m_deviceClass;
|
||||||
DevicePlugin* m_plugin = nullptr;
|
PluginId m_pluginId;
|
||||||
|
|
||||||
DeviceId m_id;
|
DeviceId m_id;
|
||||||
DeviceId m_parentId;
|
DeviceId m_parentId;
|
||||||
|
|||||||
Reference in New Issue
Block a user