From 5f61ae03a7c5d06ffcbc720d63acd1058309c8ab Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 22 Jun 2014 04:16:15 +0200 Subject: [PATCH] make DeviceManager and RuleEngine in GuhCore private This helps to have a cleaner separation between modules and have a place to do inter-module checks before modifying data (e.g. cascade deleting rules when a device is deleted etc) --- server/guhcore.cpp | 102 +++++++++++++++++++++++++++++++ server/guhcore.h | 42 +++++++++++-- server/jsonrpc/actionhandler.cpp | 6 +- server/jsonrpc/devicehandler.cpp | 46 +++++++------- server/jsonrpc/ruleshandler.cpp | 6 +- server/ruleengine.cpp | 10 +-- server/stateevaluator.cpp | 2 +- tests/auto/events/testevents.cpp | 8 +-- tests/auto/states/teststates.cpp | 2 +- 9 files changed, 180 insertions(+), 44 deletions(-) diff --git a/server/guhcore.cpp b/server/guhcore.cpp index 32271071..ab7cc163 100644 --- a/server/guhcore.cpp +++ b/server/guhcore.cpp @@ -58,6 +58,102 @@ void GuhCore::destroy() s_instance = 0; } +QList GuhCore::plugins() const +{ + return m_deviceManager->plugins(); +} + +QPair GuhCore::setPluginConfig(const PluginId &pluginId, const QList params) +{ + return m_deviceManager->setPluginConfig(pluginId, params); +} + +QList GuhCore::supportedVendors() const +{ + return m_deviceManager->supportedVendors(); +} + +QList GuhCore::supportedDevices(const VendorId &vendorId) const +{ + return m_deviceManager->supportedDevices(vendorId); +} + +QPair GuhCore::removeConfiguredDevice(const DeviceId &deviceId) +{ + // TODO: make sure we don't remove a device and keep stale rules around... + return m_deviceManager->removeConfiguredDevice(deviceId); +} + +QPair GuhCore::pairDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId) +{ + return m_deviceManager->pairDevice(deviceClassId, deviceDescriptorId); +} + +QPair GuhCore::pairDevice(const DeviceClassId &deviceClassId, const QList ¶ms) +{ + return m_deviceManager->pairDevice(deviceClassId, params); +} + +QPair GuhCore::confirmPairing(const QUuid &pairingTransactionId, const QString &secret) +{ + return m_deviceManager->confirmPairing(pairingTransactionId, secret); +} + +QPair GuhCore::executeAction(const Action &action) +{ + return m_deviceManager->executeAction(action); +} + +DeviceClass GuhCore::findDeviceClass(const DeviceClassId &deviceClassId) const +{ + return m_deviceManager->findDeviceClass(deviceClassId); +} + +DeviceManager::DeviceError GuhCore::discoverDevices(const DeviceClassId &deviceClassId, const QList ¶ms) +{ + return m_deviceManager->discoverDevices(deviceClassId, params); +} + +QPair GuhCore::addConfiguredDevice(const DeviceClassId &deviceClassId, const QList ¶ms, const DeviceId &newId) +{ + return m_deviceManager->addConfiguredDevice(deviceClassId, params, newId); +} + +QPair GuhCore::addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &newId) +{ + return m_deviceManager->addConfiguredDevice(deviceClassId, deviceDescriptorId, newId); +} + +QList GuhCore::configuredDevices() const +{ + return m_deviceManager->configuredDevices(); +} + +Device *GuhCore::findConfiguredDevice(const DeviceId &deviceId) const +{ + return m_deviceManager->findConfiguredDevice(deviceId); +} + +QList GuhCore::findConfiguredDevices(const DeviceClassId &deviceClassId) const +{ + return m_deviceManager->findConfiguredDevices(deviceClassId); +} + +QList GuhCore::rules() const +{ + return m_ruleEngine->rules(); +} + +RuleEngine::RuleError GuhCore::addRule(const RuleId &id, const QList &eventDescriptorList, const QList &actionList) +{ + return m_ruleEngine->addRule(id, eventDescriptorList, actionList); +} + +RuleEngine::RuleError GuhCore::removeRule(const RuleId &id) +{ + return m_ruleEngine->removeRule(id); +} + /*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/ DeviceManager *GuhCore::deviceManager() const { @@ -95,6 +191,12 @@ GuhCore::GuhCore(QObject *parent) : m_jsonServer = new JsonRPCServer(this); connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent); + connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged); + connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &GuhCore::actionExecuted); + + connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &GuhCore::devicesDiscovered); + connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &GuhCore::deviceSetupFinished); + connect(m_deviceManager, &DeviceManager::pairingFinished, this, &GuhCore::pairingFinished); } /*! Connected to the DeviceManager's emitEvent signal. Events received in diff --git a/server/guhcore.h b/server/guhcore.h index 56d67aff..53358a92 100644 --- a/server/guhcore.h +++ b/server/guhcore.h @@ -21,12 +21,15 @@ #include "rule.h" #include "types/event.h" +#include "plugin/deviceclass.h" +#include "plugin/devicedescriptor.h" + +#include "devicemanager.h" +#include "ruleengine.h" #include class JsonRPCServer; -class DeviceManager; -class RuleEngine; class Device; class GuhCore : public QObject @@ -39,13 +42,43 @@ public: // Used for testing void destroy(); - DeviceManager* deviceManager() const; - RuleEngine *ruleEngine() const; + QList plugins() const; + QPair setPluginConfig(const PluginId &pluginId, const QList params); + + // Device handling + QList supportedVendors() const; + QList supportedDevices(const VendorId &vendorId = VendorId()) const; + DeviceClass findDeviceClass(const DeviceClassId &deviceClassId) const; + DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList ¶ms); + QPair addConfiguredDevice(const DeviceClassId &deviceClassId, const QList ¶ms, const DeviceId &newId); + QPair addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &newId); + QList configuredDevices() const; + Device *findConfiguredDevice(const DeviceId &deviceId) const; + QList findConfiguredDevices(const DeviceClassId &deviceClassId) const; + QPair removeConfiguredDevice(const DeviceId &deviceId); + + QPair pairDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId); + QPair pairDevice(const DeviceClassId &deviceClassId, const QList ¶ms); + QPair confirmPairing(const QUuid &pairingTransactionId, const QString &secret = QString()); + + QPair executeAction(const Action &action); + + QList rules() const; + RuleEngine::RuleError addRule(const RuleId &id, const QList &eventDescriptorList, const QList &actionList); + RuleEngine::RuleError removeRule(const RuleId &id); signals: void eventTriggered(const Event &event); + void deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value); + void actionExecuted(const ActionId &id, DeviceManager::DeviceError status, const QString &errorMessage); + + void devicesDiscovered(const DeviceClassId &deviceClassId, const QList deviceDescriptors); + void deviceSetupFinished(Device *device, DeviceManager::DeviceError status); + void pairingFinished(const QUuid &pairingTransactionId, DeviceManager::DeviceError status, const QString &errorMessage, const DeviceId &deviceId); private: + RuleEngine *ruleEngine() const; + DeviceManager* deviceManager() const; explicit GuhCore(QObject *parent = 0); static GuhCore *s_instance; @@ -56,6 +89,7 @@ private: private slots: void gotEvent(const Event &event); + friend class GuhTestBase; }; #endif // GUHCORE_H diff --git a/server/jsonrpc/actionhandler.cpp b/server/jsonrpc/actionhandler.cpp index 8a145fb1..7d448240 100644 --- a/server/jsonrpc/actionhandler.cpp +++ b/server/jsonrpc/actionhandler.cpp @@ -46,7 +46,7 @@ ActionHandler::ActionHandler(QObject *parent) : returns.insert("o:actionType", JsonTypes::actionTypeDescription()); setReturns("GetActionType", returns); - connect(GuhCore::instance()->deviceManager(), &DeviceManager::actionExecutionFinished, this, &ActionHandler::actionExecuted); + connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &ActionHandler::actionExecuted); } QString ActionHandler::name() const @@ -67,7 +67,7 @@ JsonReply* ActionHandler::ExecuteAction(const QVariantMap ¶ms) qDebug() << "actions params in json" << action.params() << params; - QPair status = GuhCore::instance()->deviceManager()->executeAction(action); + QPair status = GuhCore::instance()->executeAction(action); if (status.first == DeviceManager::DeviceErrorAsync) { JsonReply *reply = createAsyncReply("ExecuteAction"); m_asyncActionExecutions.insert(action.id(), reply); @@ -81,7 +81,7 @@ JsonReply* ActionHandler::ExecuteAction(const QVariantMap ¶ms) JsonReply *ActionHandler::GetActionType(const QVariantMap ¶ms) const { ActionTypeId actionTypeId(params.value("actionTypeId").toString()); - foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { + foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) { if (actionType.id() == actionTypeId) { QVariantMap data; diff --git a/server/jsonrpc/devicehandler.cpp b/server/jsonrpc/devicehandler.cpp index 7f5cf901..14428c48 100644 --- a/server/jsonrpc/devicehandler.cpp +++ b/server/jsonrpc/devicehandler.cpp @@ -197,10 +197,10 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.insert("variant", "value"); setParams("StateChanged", params); - connect(GuhCore::instance()->deviceManager(), &DeviceManager::deviceStateChanged, this, &DeviceHandler::deviceStateChanged); - connect(GuhCore::instance()->deviceManager(), &DeviceManager::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection); - connect(GuhCore::instance()->deviceManager(), &DeviceManager::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished); - connect(GuhCore::instance()->deviceManager(), &DeviceManager::pairingFinished, this, &DeviceHandler::pairingFinished); + connect(GuhCore::instance(), &GuhCore::deviceStateChanged, this, &DeviceHandler::deviceStateChanged); + connect(GuhCore::instance(), &GuhCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection); + connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished); + connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished); } QString DeviceHandler::name() const @@ -213,7 +213,7 @@ JsonReply* DeviceHandler::GetSupportedVendors(const QVariantMap ¶ms) const Q_UNUSED(params) QVariantMap returns; QVariantList supportedVendors; - foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) { + foreach (const Vendor &vendor, GuhCore::instance()->supportedVendors()) { supportedVendors.append(JsonTypes::packVendor(vendor)); } returns.insert("vendors", supportedVendors); @@ -226,9 +226,9 @@ JsonReply* DeviceHandler::GetSupportedDevices(const QVariantMap ¶ms) const QVariantList supportedDeviceList; QList supportedDevices; if (params.contains("vendorId")) { - supportedDevices = GuhCore::instance()->deviceManager()->supportedDevices(VendorId(params.value("vendorId").toString())); + supportedDevices = GuhCore::instance()->supportedDevices(VendorId(params.value("vendorId").toString())); } else { - supportedDevices = GuhCore::instance()->deviceManager()->supportedDevices(); + supportedDevices = GuhCore::instance()->supportedDevices(); } foreach (const DeviceClass &deviceClass, supportedDevices) { supportedDeviceList.append(JsonTypes::packDeviceClass(deviceClass)); @@ -249,7 +249,7 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap ¶ms) const discoveryParams.append(dp); } - DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams); + DeviceManager::DeviceError status = GuhCore::instance()->discoverDevices(deviceClassId, discoveryParams); switch (status) { case DeviceManager::DeviceErrorAsync: case DeviceManager::DeviceErrorNoError: { @@ -279,7 +279,7 @@ JsonReply* DeviceHandler::GetPlugins(const QVariantMap ¶ms) const Q_UNUSED(params) QVariantMap returns; QVariantList plugins; - foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) { + foreach (DevicePlugin *plugin, GuhCore::instance()->plugins()) { QVariantMap pluginMap; pluginMap.insert("id", plugin->pluginId()); pluginMap.insert("name", plugin->pluginName()); @@ -297,7 +297,7 @@ JsonReply* DeviceHandler::GetPlugins(const QVariantMap ¶ms) const JsonReply *DeviceHandler::GetPluginConfiguration(const QVariantMap ¶ms) const { DevicePlugin *plugin = 0; - foreach (DevicePlugin *p, GuhCore::instance()->deviceManager()->plugins()) { + foreach (DevicePlugin *p, GuhCore::instance()->plugins()) { if (p->pluginId() == PluginId(params.value("pluginId").toString())) { plugin = p; } @@ -329,7 +329,7 @@ JsonReply* DeviceHandler::SetPluginConfiguration(const QVariantMap ¶ms) qDebug() << "got param" << param; pluginParams.append(JsonTypes::unpackParam(param.toMap())); } - QPair result = GuhCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams); + QPair result = GuhCore::instance()->setPluginConfig(pluginId, pluginParams); returns.insert("success", result.first == DeviceManager::DeviceErrorNoError); returns.insert("errorMessage", result.second); return createReply(returns); @@ -349,10 +349,10 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms) QPair status; if (deviceDescriptorId.isNull()) { qDebug() << "adding a manual device."; - status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceParams, newDeviceId); + status = GuhCore::instance()->addConfiguredDevice(deviceClass, deviceParams, newDeviceId); } else { qDebug() << "adding a discovered device."; - status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceDescriptorId, newDeviceId); + status = GuhCore::instance()->addConfiguredDevice(deviceClass, deviceDescriptorId, newDeviceId); } QVariantMap returns; switch(status.first) { @@ -396,12 +396,12 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms) JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms) { DeviceClassId deviceClassId(params.value("deviceClassId").toString()); - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(deviceClassId); QPair status; if (params.contains("deviceDescriptorId")) { DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString()); - status = GuhCore::instance()->deviceManager()->pairDevice(deviceClassId, deviceDescriptorId); + status = GuhCore::instance()->pairDevice(deviceClassId, deviceDescriptorId); } else { QList deviceParams; foreach (const QString ¶mName, params.value("deviceParams").toMap().keys()) { @@ -409,7 +409,7 @@ JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms) param.setValue(params.value("deviceParams").toMap().value(paramName)); deviceParams.append(param); } - status = GuhCore::instance()->deviceManager()->pairDevice(deviceClassId, deviceParams); + status = GuhCore::instance()->pairDevice(deviceClassId, deviceParams); } QVariantMap returns; @@ -445,7 +445,7 @@ JsonReply *DeviceHandler::ConfirmPairing(const QVariantMap ¶ms) { QUuid pairingTransactionId = params.value("pairingTransactionId").toUuid(); QString secret = params.value("secret").toString(); - QPair status = GuhCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret); + QPair status = GuhCore::instance()->confirmPairing(pairingTransactionId, secret); JsonReply *reply = 0; QVariantMap returns; @@ -471,7 +471,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const Q_UNUSED(params) QVariantMap returns; QVariantList configuredDeviceList; - foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) { + foreach (Device *device, GuhCore::instance()->configuredDevices()) { configuredDeviceList.append(JsonTypes::packDevice(device)); } returns.insert("devices", configuredDeviceList); @@ -481,7 +481,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const JsonReply* DeviceHandler::RemoveConfiguredDevice(const QVariantMap ¶ms) { QVariantMap returns; - QPair status = GuhCore::instance()->deviceManager()->removeConfiguredDevice(DeviceId(params.value("deviceId").toString())); + QPair status = GuhCore::instance()->removeConfiguredDevice(DeviceId(params.value("deviceId").toString())); switch(status.first) { case DeviceManager::DeviceErrorNoError: returns.insert("success", true); @@ -504,7 +504,7 @@ JsonReply* DeviceHandler::GetEventTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList eventList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const EventType &eventType, deviceClass.eventTypes()) { eventList.append(JsonTypes::packEventType(eventType)); } @@ -517,7 +517,7 @@ JsonReply* DeviceHandler::GetActionTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList actionList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const ActionType &actionType, deviceClass.actionTypes()) { actionList.append(JsonTypes::packActionType(actionType)); } @@ -530,7 +530,7 @@ JsonReply* DeviceHandler::GetStateTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList stateList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const StateType &stateType, deviceClass.stateTypes()) { stateList.append(JsonTypes::packStateType(stateType)); } @@ -542,7 +542,7 @@ JsonReply* DeviceHandler::GetStateValue(const QVariantMap ¶ms) const { QVariantMap returns; - Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString())); + Device *device = GuhCore::instance()->findConfiguredDevice(DeviceId(params.value("deviceId").toString())); if (!device) { returns.insert("success", false); returns.insert("errorMessage", "No such device"); diff --git a/server/jsonrpc/ruleshandler.cpp b/server/jsonrpc/ruleshandler.cpp index 880a7992..38bf25ec 100644 --- a/server/jsonrpc/ruleshandler.cpp +++ b/server/jsonrpc/ruleshandler.cpp @@ -70,7 +70,7 @@ JsonReply* RulesHandler::GetRules(const QVariantMap ¶ms) Q_UNUSED(params) QVariantList rulesList; - foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules()) { + foreach (const Rule &rule, GuhCore::instance()->rules()) { QVariantMap ruleMap = JsonTypes::packRule(rule); rulesList.append(ruleMap); } @@ -117,7 +117,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms) } RuleId newRuleId = RuleId::createRuleId(); - switch(GuhCore::instance()->ruleEngine()->addRule(newRuleId, eventDescriptorList, actions)) { + switch(GuhCore::instance()->addRule(newRuleId, eventDescriptorList, actions)) { case RuleEngine::RuleErrorNoError: returns.insert("success", true); returns.insert("errorMessage", ""); @@ -142,7 +142,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap ¶ms) { QVariantMap returns; RuleId ruleId(params.value("ruleId").toString()); - switch (GuhCore::instance()->ruleEngine()->removeRule(ruleId)) { + switch (GuhCore::instance()->removeRule(ruleId)) { case RuleEngine::RuleErrorNoError: returns.insert("success", true); returns.insert("errorMessage", ""); diff --git a/server/ruleengine.cpp b/server/ruleengine.cpp index 72acf67d..f643d102 100644 --- a/server/ruleengine.cpp +++ b/server/ruleengine.cpp @@ -144,7 +144,7 @@ RuleEngine::RuleEngine(QObject *parent) : list of all \l{Action}{Actions} that should be executed. */ QList RuleEngine::evaluateEvent(const Event &event) { - Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId()); + Device *device = GuhCore::instance()->findConfiguredDevice(event.deviceId()); qDebug() << "got event:" << event << device->name(); @@ -180,12 +180,12 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QListdeviceManager()->findConfiguredDevice(eventDescriptor.deviceId()); + Device *device = GuhCore::instance()->findConfiguredDevice(eventDescriptor.deviceId()); if (!device) { qWarning() << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId(); return RuleErrorDeviceNotFound; } - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId()); bool eventTypeFound = false; foreach (const EventType &eventType, deviceClass.eventTypes()) { @@ -200,12 +200,12 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QListdeviceManager()->findConfiguredDevice(action.deviceId()); + Device *device = GuhCore::instance()->findConfiguredDevice(action.deviceId()); if (!device) { qWarning() << "Cannot create rule. No configured device for actionTypeId" << action.actionTypeId(); return RuleErrorDeviceNotFound; } - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); + DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId()); bool actionTypeFound = false; foreach (const ActionType &actionType, deviceClass.actionTypes()) { diff --git a/server/stateevaluator.cpp b/server/stateevaluator.cpp index 6d4a882b..44a93793 100644 --- a/server/stateevaluator.cpp +++ b/server/stateevaluator.cpp @@ -67,7 +67,7 @@ void StateEvaluator::setOperatorType(StateOperator operatorType) bool StateEvaluator::evaluate() const { if (!m_stateDescriptor.stateTypeId().isNull() && !m_stateDescriptor.deviceId().isNull()) { - Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId()); + Device *device = GuhCore::instance()->findConfiguredDevice(m_stateDescriptor.deviceId()); if (!device) { qWarning() << "Device not existing!"; return false; diff --git a/tests/auto/events/testevents.cpp b/tests/auto/events/testevents.cpp index 55685fa5..01237bde 100644 --- a/tests/auto/events/testevents.cpp +++ b/tests/auto/events/testevents.cpp @@ -42,11 +42,11 @@ private slots: void TestEvents::triggerEvent() { - QList devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); + QList devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); Device *device = devices.first(); - QSignalSpy spy(GuhCore::instance()->deviceManager(), SIGNAL(eventTriggered(const Event&))); + QSignalSpy spy(GuhCore::instance(), SIGNAL(eventTriggered(const Event&))); // Setup connection to mock client QNetworkAccessManager nam; @@ -69,11 +69,11 @@ void TestEvents::triggerEvent() void TestEvents::triggerStateChangeEvent() { - QList devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); + QList devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); Device *device = devices.first(); - QSignalSpy spy(GuhCore::instance()->deviceManager(), SIGNAL(eventTriggered(const Event&))); + QSignalSpy spy(GuhCore::instance(), SIGNAL(eventTriggered(const Event&))); // Setup connection to mock client QNetworkAccessManager nam; diff --git a/tests/auto/states/teststates.cpp b/tests/auto/states/teststates.cpp index c1a36442..1de97b91 100644 --- a/tests/auto/states/teststates.cpp +++ b/tests/auto/states/teststates.cpp @@ -40,7 +40,7 @@ private slots: void TestStates::getStateValue_data() { - QList devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); + QList devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); Device *device = devices.first();