add device name
clean up guhCore
This commit is contained in:
parent
6aa4af88e0
commit
b2763cafd0
2
guh.pri
2
guh.pri
@ -2,7 +2,7 @@
|
|||||||
GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
|
GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
|
||||||
|
|
||||||
# define protocol versions
|
# define protocol versions
|
||||||
JSON_PROTOCOL_VERSION=37
|
JSON_PROTOCOL_VERSION=38
|
||||||
REST_API_VERSION=1
|
REST_API_VERSION=1
|
||||||
|
|
||||||
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \
|
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \
|
||||||
|
|||||||
@ -374,14 +374,14 @@ DeviceManager::DeviceError DeviceManager::discoverDevices(const DeviceClassId &d
|
|||||||
* Optionally you can supply an id yourself if you must keep track of the added device. If you don't supply it, a new one will
|
* Optionally you can supply an id yourself if you must keep track of the added device. If you don't supply it, a new one will
|
||||||
* be generated. Only devices with \l{DeviceClass}{CreateMethodUser} can be created using this method.
|
* be generated. Only devices with \l{DeviceClass}{CreateMethodUser} can be created using this method.
|
||||||
* Returns \l{DeviceError} to inform about the result. */
|
* Returns \l{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id)
|
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms, const DeviceId id)
|
||||||
{
|
{
|
||||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||||
if (!deviceClass.isValid()) {
|
if (!deviceClass.isValid()) {
|
||||||
return DeviceErrorDeviceClassNotFound;
|
return DeviceErrorDeviceClassNotFound;
|
||||||
}
|
}
|
||||||
if (deviceClass.createMethods().testFlag(DeviceClass::CreateMethodUser)) {
|
if (deviceClass.createMethods().testFlag(DeviceClass::CreateMethodUser)) {
|
||||||
return addConfiguredDeviceInternal(deviceClassId, params, id);
|
return addConfiguredDeviceInternal(deviceClassId, name, params, id);
|
||||||
}
|
}
|
||||||
return DeviceErrorCreationMethodNotSupported;
|
return DeviceErrorCreationMethodNotSupported;
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
|
|||||||
* can be created using this method. The \a deviceClassId must refer to an existing \l{DeviceClass} and the \a deviceDescriptorId must refer to an existing DeviceDescriptorId
|
* can be created using this method. The \a deviceClassId must refer to an existing \l{DeviceClass} and the \a deviceDescriptorId must refer to an existing DeviceDescriptorId
|
||||||
* from the discovery.
|
* from the discovery.
|
||||||
* Returns \l{DeviceError} to inform about the result. */
|
* Returns \l{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &deviceId)
|
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &deviceId)
|
||||||
{
|
{
|
||||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||||
if (!deviceClass.isValid()) {
|
if (!deviceClass.isValid()) {
|
||||||
@ -405,7 +405,7 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
|
|||||||
return DeviceErrorDeviceDescriptorNotFound;
|
return DeviceErrorDeviceDescriptorNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return addConfiguredDeviceInternal(deviceClassId, descriptor.params(), deviceId);
|
return addConfiguredDeviceInternal(deviceClassId, name, descriptor.params(), deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -620,9 +620,9 @@ DeviceManager::DeviceError DeviceManager::confirmPairing(const PairingTransactio
|
|||||||
return DeviceErrorPairingTransactionIdNotFound;
|
return DeviceErrorPairingTransactionIdNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! This method will only be used from the DeviceManager in order to add a \l{Device} with the given \a deviceClassId, \a params and \ id.
|
/*! This method will only be used from the DeviceManager in order to add a \l{Device} with the given \a deviceClassId, \a name, \a params and \ id.
|
||||||
* Returns \l{DeviceError} to inform about the result. */
|
* Returns \l{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id)
|
DeviceManager::DeviceError DeviceManager::addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms, const DeviceId id)
|
||||||
{
|
{
|
||||||
ParamList effectiveParams = params;
|
ParamList effectiveParams = params;
|
||||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||||
@ -651,7 +651,11 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDeviceInternal(const Devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
Device *device = new Device(plugin->pluginId(), id, deviceClassId, this);
|
Device *device = new Device(plugin->pluginId(), id, deviceClassId, this);
|
||||||
device->setName(deviceClass.name());
|
if (name.isEmpty()) {
|
||||||
|
device->setName(deviceClass.name());
|
||||||
|
} else {
|
||||||
|
device->setName(name);
|
||||||
|
}
|
||||||
device->setParams(effectiveParams);
|
device->setParams(effectiveParams);
|
||||||
|
|
||||||
DeviceSetupStatus status = setupDevice(device);
|
DeviceSetupStatus status = setupDevice(device);
|
||||||
|
|||||||
@ -112,8 +112,8 @@ public:
|
|||||||
DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
||||||
|
|
||||||
QList<Device*> configuredDevices() const;
|
QList<Device*> configuredDevices() const;
|
||||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &id = DeviceId::createDeviceId());
|
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &id = DeviceId::createDeviceId());
|
||||||
|
|
||||||
DeviceError editDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery = false);
|
DeviceError editDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery = false);
|
||||||
DeviceError editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId);
|
DeviceError editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId);
|
||||||
@ -175,7 +175,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool verifyPluginMetadata(const QJsonObject &data);
|
bool verifyPluginMetadata(const QJsonObject &data);
|
||||||
DeviceError addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
DeviceError addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||||
DeviceSetupStatus setupDevice(Device *device);
|
DeviceSetupStatus setupDevice(Device *device);
|
||||||
void postSetupDevice(Device *device);
|
void postSetupDevice(Device *device);
|
||||||
|
|
||||||
|
|||||||
@ -133,39 +133,11 @@ void GuhCore::destroy()
|
|||||||
s_instance = 0;
|
s_instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::plugins().
|
|
||||||
* \sa DeviceManager::plugins(), */
|
|
||||||
QList<DevicePlugin *> GuhCore::plugins() const
|
|
||||||
{
|
|
||||||
return m_deviceManager->plugins();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::setPluginConfig(\a pluginId, \a params).
|
|
||||||
* \sa DeviceManager::setPluginConfig(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::setPluginConfig(const PluginId &pluginId, const ParamList ¶ms)
|
|
||||||
{
|
|
||||||
return m_deviceManager->setPluginConfig(pluginId, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::supportedVendors().
|
|
||||||
* \sa DeviceManager::supportedVendors(), */
|
|
||||||
QList<Vendor> GuhCore::supportedVendors() const
|
|
||||||
{
|
|
||||||
return m_deviceManager->supportedVendors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::supportedDevices(\a vendorId).
|
|
||||||
* \sa DeviceManager::supportedDevices(), */
|
|
||||||
QList<DeviceClass> GuhCore::supportedDevices(const VendorId &vendorId) const
|
|
||||||
{
|
|
||||||
return m_deviceManager->supportedDevices(vendorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */
|
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */
|
||||||
QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList)
|
QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList)
|
||||||
{
|
{
|
||||||
// Check if this is a child device
|
// Check if this is a child device
|
||||||
Device *device = findConfiguredDevice(deviceId);
|
Device *device = m_deviceManager->findConfiguredDevice(deviceId);
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceNotFound, QList<RuleId>());
|
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceNotFound, QList<RuleId>());
|
||||||
@ -253,7 +225,7 @@ QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevic
|
|||||||
DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy)
|
DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy)
|
||||||
{
|
{
|
||||||
// Check if this is a child device
|
// Check if this is a child device
|
||||||
Device *device = findConfiguredDevice(deviceId);
|
Device *device = m_deviceManager->findConfiguredDevice(deviceId);
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
return DeviceManager::DeviceErrorDeviceNotFound;
|
return DeviceManager::DeviceErrorDeviceNotFound;
|
||||||
@ -316,30 +288,6 @@ DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &devic
|
|||||||
return removeError;
|
return removeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::pairDevice(\a pairingTransactionId, \a deviceClassId, \a deviceDescriptorId).
|
|
||||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result.
|
|
||||||
* \sa DeviceManager::pairDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId)
|
|
||||||
{
|
|
||||||
return m_deviceManager->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::pairDevice(\a pairingTransactionId, \a deviceClassId, \a params).
|
|
||||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result.
|
|
||||||
* \sa DeviceManager::pairDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
|
||||||
{
|
|
||||||
return m_deviceManager->pairDevice(pairingTransactionId, deviceClassId, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::confirmPairing(\a pairingTransactionId, \a secret).
|
|
||||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result.
|
|
||||||
* \sa DeviceManager::confirmPairing(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::confirmPairing(const PairingTransactionId &pairingTransactionId, const QString &secret)
|
|
||||||
{
|
|
||||||
return m_deviceManager->confirmPairing(pairingTransactionId, secret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::executeAction(\a action).
|
/*! Calls the metheod DeviceManager::executeAction(\a action).
|
||||||
* \sa DeviceManager::executeAction(), */
|
* \sa DeviceManager::executeAction(), */
|
||||||
DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
||||||
@ -382,104 +330,6 @@ void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::findDeviceClass(\a deviceClassId).
|
|
||||||
* \sa DeviceManager::findDeviceClass(), */
|
|
||||||
DeviceClass GuhCore::findDeviceClass(const DeviceClassId &deviceClassId) const
|
|
||||||
{
|
|
||||||
return m_deviceManager->findDeviceClass(deviceClassId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::discoverDevices(\a deviceClassId, \a params).
|
|
||||||
* \sa DeviceManager::discoverDevices(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
|
||||||
{
|
|
||||||
return m_deviceManager->discoverDevices(deviceClassId, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::addConfiguredDevice(\a deviceClassId, \a params, \a newId).
|
|
||||||
* \sa DeviceManager::addConfiguredDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::addConfiguredDevice(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId &newId)
|
|
||||||
{
|
|
||||||
return m_deviceManager->addConfiguredDevice(deviceClassId, params, newId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::addConfiguredDevice(\a deviceClassId, \a deviceDescriptorId, \a newId).
|
|
||||||
* \sa DeviceManager::addConfiguredDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &newId)
|
|
||||||
{
|
|
||||||
return m_deviceManager->addConfiguredDevice(deviceClassId, deviceDescriptorId, newId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::configuredDevices().
|
|
||||||
* \sa DeviceManager::configuredDevices(), */
|
|
||||||
QList<Device *> GuhCore::configuredDevices() const
|
|
||||||
{
|
|
||||||
return m_deviceManager->configuredDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::findConfiguredDevice(\a deviceId).
|
|
||||||
* \sa DeviceManager::findConfiguredDevice(), */
|
|
||||||
Device *GuhCore::findConfiguredDevice(const DeviceId &deviceId) const
|
|
||||||
{
|
|
||||||
return m_deviceManager->findConfiguredDevice(deviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::findConfiguredDevice(\a deviceClassId).
|
|
||||||
* \sa DeviceManager::findConfiguredDevice(), */
|
|
||||||
QList<Device *> GuhCore::findConfiguredDevices(const DeviceClassId &deviceClassId) const
|
|
||||||
{
|
|
||||||
return m_deviceManager->findConfiguredDevices(deviceClassId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::editDevice(\a deviceId, \a params).
|
|
||||||
* \sa DeviceManager::editDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::editDevice(const DeviceId &deviceId, const ParamList ¶ms)
|
|
||||||
{
|
|
||||||
return m_deviceManager->editDevice(deviceId, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::editDevice(\a deviceId, \a deviceDescriptorId).
|
|
||||||
* \sa DeviceManager::editDevice(), */
|
|
||||||
DeviceManager::DeviceError GuhCore::editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId)
|
|
||||||
{
|
|
||||||
return m_deviceManager->editDevice(deviceId, deviceDescriptorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::rules().
|
|
||||||
* \sa RuleEngine::rules(), */
|
|
||||||
QList<Rule> GuhCore::rules() const
|
|
||||||
{
|
|
||||||
return m_ruleEngine->rules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::ruleIds().
|
|
||||||
* \sa RuleEngine::ruleIds(), */
|
|
||||||
QList<RuleId> GuhCore::ruleIds() const
|
|
||||||
{
|
|
||||||
return m_ruleEngine->ruleIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::findRule(\a ruleId).
|
|
||||||
* \sa RuleEngine::findRule(), */
|
|
||||||
Rule GuhCore::findRule(const RuleId &ruleId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->findRule(ruleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::addRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
|
||||||
* \sa RuleEngine::addRule(), */
|
|
||||||
RuleEngine::RuleError GuhCore::addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled, bool executable)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->addRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled, executable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::editRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
|
||||||
* \sa RuleEngine::editRule(), */
|
|
||||||
RuleEngine::RuleError GuhCore::editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled, bool executable)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->editRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled, executable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::removeRule(\a id).
|
/*! Calls the metheod RuleEngine::removeRule(\a id).
|
||||||
* \sa RuleEngine, */
|
* \sa RuleEngine, */
|
||||||
RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
|
RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
|
||||||
@ -491,37 +341,6 @@ RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
|
|||||||
return removeError;
|
return removeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::findRules(\a deviceId).
|
|
||||||
* \sa RuleEngine, */
|
|
||||||
QList<RuleId> GuhCore::findRules(const DeviceId &deviceId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->findRules(deviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::enableRule(\a ruleId).
|
|
||||||
* \sa RuleEngine::enableRule(), */
|
|
||||||
RuleEngine::RuleError GuhCore::enableRule(const RuleId &ruleId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->enableRule(ruleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::disableRule(\a ruleId).
|
|
||||||
* \sa RuleEngine::disableRule(), */
|
|
||||||
RuleEngine::RuleError GuhCore::disableRule(const RuleId &ruleId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->disableRule(ruleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
RuleEngine::RuleError GuhCore::executeRuleActions(const RuleId &ruleId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->executeActions(ruleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
RuleEngine::RuleError GuhCore::executeRuleExitActions(const RuleId &ruleId)
|
|
||||||
{
|
|
||||||
return m_ruleEngine->executeExitActions(ruleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
||||||
DeviceManager *GuhCore::deviceManager() const
|
DeviceManager *GuhCore::deviceManager() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -45,54 +45,29 @@ class LogEngine;
|
|||||||
class GuhCore : public QObject
|
class GuhCore : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
friend class GuhTestBase;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static GuhCore* instance();
|
static GuhCore* instance();
|
||||||
~GuhCore();
|
~GuhCore();
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
QList<DevicePlugin *> plugins() const;
|
|
||||||
DeviceManager::DeviceError setPluginConfig(const PluginId &pluginId, const ParamList ¶ms);
|
|
||||||
|
|
||||||
// Device handling
|
// Device handling
|
||||||
QList<Vendor> supportedVendors() const;
|
|
||||||
QList<DeviceClass> supportedDevices(const VendorId &vendorId = VendorId()) const;
|
|
||||||
DeviceClass findDeviceClass(const DeviceClassId &deviceClassId) const;
|
|
||||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
|
||||||
DeviceManager::DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId &newId);
|
|
||||||
DeviceManager::DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &newId);
|
|
||||||
QList<Device *> configuredDevices() const;
|
|
||||||
Device *findConfiguredDevice(const DeviceId &deviceId) const;
|
|
||||||
QList<Device *> findConfiguredDevices(const DeviceClassId &deviceClassId) const;
|
|
||||||
DeviceManager::DeviceError editDevice(const DeviceId &deviceId, const ParamList ¶ms);
|
|
||||||
DeviceManager::DeviceError editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId);
|
|
||||||
QPair<DeviceManager::DeviceError, QList<RuleId> >removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList);
|
QPair<DeviceManager::DeviceError, QList<RuleId> >removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList);
|
||||||
DeviceManager::DeviceError removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy);
|
DeviceManager::DeviceError removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy);
|
||||||
|
|
||||||
DeviceManager::DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId);
|
|
||||||
DeviceManager::DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
|
||||||
DeviceManager::DeviceError confirmPairing(const PairingTransactionId &pairingTransactionId, const QString &secret = QString());
|
|
||||||
|
|
||||||
DeviceManager::DeviceError executeAction(const Action &action);
|
DeviceManager::DeviceError executeAction(const Action &action);
|
||||||
|
|
||||||
void executeRuleActions(const QList<RuleAction> ruleActions);
|
void executeRuleActions(const QList<RuleAction> ruleActions);
|
||||||
|
|
||||||
QList<Rule> rules() const;
|
|
||||||
QList<RuleId> ruleIds() const;
|
|
||||||
Rule findRule(const RuleId &ruleId);
|
|
||||||
RuleEngine::RuleError addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true, bool executable = true);
|
|
||||||
RuleEngine::RuleError editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true, bool executable = true);
|
|
||||||
RuleEngine::RuleError removeRule(const RuleId &id);
|
RuleEngine::RuleError removeRule(const RuleId &id);
|
||||||
QList<RuleId> findRules(const DeviceId &deviceId);
|
|
||||||
RuleEngine::RuleError enableRule(const RuleId &ruleId);
|
|
||||||
RuleEngine::RuleError disableRule(const RuleId &ruleId);
|
|
||||||
RuleEngine::RuleError executeRuleActions(const RuleId &ruleId);
|
|
||||||
RuleEngine::RuleError executeRuleExitActions(const RuleId &ruleId);
|
|
||||||
|
|
||||||
LogEngine* logEngine() const;
|
LogEngine* logEngine() const;
|
||||||
JsonRPCServer *jsonRPCServer() const;
|
JsonRPCServer *jsonRPCServer() const;
|
||||||
RestServer *restServer() const;
|
RestServer *restServer() const;
|
||||||
DeviceManager *deviceManager() const;
|
DeviceManager *deviceManager() const;
|
||||||
|
RuleEngine *ruleEngine() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void eventTriggered(const Event &event);
|
void eventTriggered(const Event &event);
|
||||||
@ -113,8 +88,6 @@ signals:
|
|||||||
void ruleConfigurationChanged(const Rule &rule);
|
void ruleConfigurationChanged(const Rule &rule);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RuleEngine *ruleEngine() const;
|
|
||||||
|
|
||||||
explicit GuhCore(QObject *parent = 0);
|
explicit GuhCore(QObject *parent = 0);
|
||||||
static GuhCore *s_instance;
|
static GuhCore *s_instance;
|
||||||
|
|
||||||
@ -130,7 +103,6 @@ private slots:
|
|||||||
void gotEvent(const Event &event);
|
void gotEvent(const Event &event);
|
||||||
void actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status);
|
void actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status);
|
||||||
|
|
||||||
friend class GuhTestBase;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ JsonReply *ActionHandler::GetActionType(const QVariantMap ¶ms) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcJsonRpc) << "asked for action type" << params;
|
qCDebug(dcJsonRpc) << "asked for action type" << params;
|
||||||
ActionTypeId actionTypeId(params.value("actionTypeId").toString());
|
ActionTypeId actionTypeId(params.value("actionTypeId").toString());
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||||
if (actionType.id() == actionTypeId) {
|
if (actionType.id() == actionTypeId) {
|
||||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||||
|
|||||||
@ -102,6 +102,7 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
|||||||
"CreateMethodDiscovery requires the use of a deviceDescriptorId."
|
"CreateMethodDiscovery requires the use of a deviceDescriptorId."
|
||||||
);
|
);
|
||||||
params.insert("deviceClassId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
params.insert("deviceClassId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
|
params.insert("name", JsonTypes::basicTypeToString(JsonTypes::String));
|
||||||
params.insert("o:deviceDescriptorId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
params.insert("o:deviceDescriptorId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
QVariantList deviceParams;
|
QVariantList deviceParams;
|
||||||
deviceParams.append(JsonTypes::paramRef());
|
deviceParams.append(JsonTypes::paramRef());
|
||||||
@ -299,7 +300,7 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap ¶ms) const
|
|||||||
|
|
||||||
ParamList discoveryParams = JsonTypes::unpackParams(params.value("discoveryParams").toList());
|
ParamList discoveryParams = JsonTypes::unpackParams(params.value("discoveryParams").toList());
|
||||||
|
|
||||||
DeviceManager::DeviceError status = GuhCore::instance()->discoverDevices(deviceClassId, discoveryParams);
|
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams);
|
||||||
if (status == DeviceManager::DeviceErrorAsync ) {
|
if (status == DeviceManager::DeviceErrorAsync ) {
|
||||||
JsonReply *reply = createAsyncReply("GetDiscoveredDevices");
|
JsonReply *reply = createAsyncReply("GetDiscoveredDevices");
|
||||||
m_discoverRequests.insert(deviceClassId, reply);
|
m_discoverRequests.insert(deviceClassId, reply);
|
||||||
@ -321,7 +322,7 @@ JsonReply* DeviceHandler::GetPlugins(const QVariantMap ¶ms) const
|
|||||||
JsonReply *DeviceHandler::GetPluginConfiguration(const QVariantMap ¶ms) const
|
JsonReply *DeviceHandler::GetPluginConfiguration(const QVariantMap ¶ms) const
|
||||||
{
|
{
|
||||||
DevicePlugin *plugin = 0;
|
DevicePlugin *plugin = 0;
|
||||||
foreach (DevicePlugin *p, GuhCore::instance()->plugins()) {
|
foreach (DevicePlugin *p, GuhCore::instance()->deviceManager()->plugins()) {
|
||||||
if (p->pluginId() == PluginId(params.value("pluginId").toString())) {
|
if (p->pluginId() == PluginId(params.value("pluginId").toString())) {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
}
|
}
|
||||||
@ -347,7 +348,7 @@ JsonReply* DeviceHandler::SetPluginConfiguration(const QVariantMap ¶ms)
|
|||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
PluginId pluginId = PluginId(params.value("pluginId").toString());
|
PluginId pluginId = PluginId(params.value("pluginId").toString());
|
||||||
ParamList pluginParams = JsonTypes::unpackParams(params.value("configuration").toList());
|
ParamList pluginParams = JsonTypes::unpackParams(params.value("configuration").toList());
|
||||||
DeviceManager::DeviceError result = GuhCore::instance()->setPluginConfig(pluginId, pluginParams);
|
DeviceManager::DeviceError result = GuhCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams);
|
||||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(result));
|
returns.insert("deviceError", JsonTypes::deviceErrorToString(result));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
}
|
}
|
||||||
@ -355,14 +356,15 @@ JsonReply* DeviceHandler::SetPluginConfiguration(const QVariantMap ¶ms)
|
|||||||
JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
DeviceClassId deviceClass(params.value("deviceClassId").toString());
|
DeviceClassId deviceClass(params.value("deviceClassId").toString());
|
||||||
|
QString deviceName = params.value("name").toString();
|
||||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
DeviceId newDeviceId = DeviceId::createDeviceId();
|
DeviceId newDeviceId = DeviceId::createDeviceId();
|
||||||
DeviceManager::DeviceError status;
|
DeviceManager::DeviceError status;
|
||||||
if (deviceDescriptorId.isNull()) {
|
if (deviceDescriptorId.isNull()) {
|
||||||
status = GuhCore::instance()->addConfiguredDevice(deviceClass, deviceParams, newDeviceId);
|
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceParams, newDeviceId);
|
||||||
} else {
|
} else {
|
||||||
status = GuhCore::instance()->addConfiguredDevice(deviceClass, deviceDescriptorId, newDeviceId);
|
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceDescriptorId, newDeviceId);
|
||||||
}
|
}
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@ -382,16 +384,16 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
|||||||
JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms)
|
JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||||
|
|
||||||
DeviceManager::DeviceError status;
|
DeviceManager::DeviceError status;
|
||||||
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
||||||
if (params.contains("deviceDescriptorId")) {
|
if (params.contains("deviceDescriptorId")) {
|
||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
status = GuhCore::instance()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
||||||
} else {
|
} else {
|
||||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||||
status = GuhCore::instance()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
@ -408,7 +410,7 @@ JsonReply *DeviceHandler::ConfirmPairing(const QVariantMap ¶ms)
|
|||||||
{
|
{
|
||||||
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
|
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
|
||||||
QString secret = params.value("secret").toString();
|
QString secret = params.value("secret").toString();
|
||||||
DeviceManager::DeviceError status = GuhCore::instance()->confirmPairing(pairingTransactionId, secret);
|
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret);
|
||||||
|
|
||||||
JsonReply *reply = 0;
|
JsonReply *reply = 0;
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
@ -427,7 +429,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const
|
|||||||
Q_UNUSED(params)
|
Q_UNUSED(params)
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
QVariantList configuredDeviceList;
|
QVariantList configuredDeviceList;
|
||||||
foreach (Device *device, GuhCore::instance()->configuredDevices()) {
|
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) {
|
||||||
configuredDeviceList.append(JsonTypes::packDevice(device));
|
configuredDeviceList.append(JsonTypes::packDevice(device));
|
||||||
}
|
}
|
||||||
returns.insert("devices", configuredDeviceList);
|
returns.insert("devices", configuredDeviceList);
|
||||||
@ -443,9 +445,9 @@ JsonReply *DeviceHandler::EditDevice(const QVariantMap ¶ms)
|
|||||||
DeviceManager::DeviceError status;
|
DeviceManager::DeviceError status;
|
||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
if (deviceDescriptorId.isNull()) {
|
if (deviceDescriptorId.isNull()) {
|
||||||
status = GuhCore::instance()->editDevice(deviceId, deviceParams);
|
status = GuhCore::instance()->deviceManager()->editDevice(deviceId, deviceParams);
|
||||||
} else {
|
} else {
|
||||||
status = GuhCore::instance()->editDevice(deviceId, deviceDescriptorId);
|
status = GuhCore::instance()->deviceManager()->editDevice(deviceId, deviceDescriptorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
@ -498,7 +500,7 @@ JsonReply* DeviceHandler::GetEventTypes(const QVariantMap ¶ms) const
|
|||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
|
|
||||||
QVariantList eventList;
|
QVariantList eventList;
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
||||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||||
eventList.append(JsonTypes::packEventType(eventType));
|
eventList.append(JsonTypes::packEventType(eventType));
|
||||||
}
|
}
|
||||||
@ -511,7 +513,7 @@ JsonReply* DeviceHandler::GetActionTypes(const QVariantMap ¶ms) const
|
|||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
|
|
||||||
QVariantList actionList;
|
QVariantList actionList;
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
||||||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||||
actionList.append(JsonTypes::packActionType(actionType));
|
actionList.append(JsonTypes::packActionType(actionType));
|
||||||
}
|
}
|
||||||
@ -524,7 +526,7 @@ JsonReply* DeviceHandler::GetStateTypes(const QVariantMap ¶ms) const
|
|||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
|
|
||||||
QVariantList stateList;
|
QVariantList stateList;
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
|
||||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||||
stateList.append(JsonTypes::packStateType(stateType));
|
stateList.append(JsonTypes::packStateType(stateType));
|
||||||
}
|
}
|
||||||
@ -536,7 +538,7 @@ JsonReply* DeviceHandler::GetStateValue(const QVariantMap ¶ms) const
|
|||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
|
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
|
||||||
if (!device) {
|
if (!device) {
|
||||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
@ -556,7 +558,7 @@ JsonReply *DeviceHandler::GetStateValues(const QVariantMap ¶ms) const
|
|||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
|
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
|
||||||
if (!device) {
|
if (!device) {
|
||||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ JsonReply* EventHandler::GetEventType(const QVariantMap ¶ms) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcJsonRpc) << "asked for event type" << params;
|
qCDebug(dcJsonRpc) << "asked for event type" << params;
|
||||||
EventTypeId eventTypeId(params.value("eventTypeId").toString());
|
EventTypeId eventTypeId(params.value("eventTypeId").toString());
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||||
if (eventType.id() == eventTypeId) {
|
if (eventType.id() == eventTypeId) {
|
||||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||||
|
|||||||
@ -728,7 +728,7 @@ QVariantList JsonTypes::packCreateMethods(DeviceClass::CreateMethods createMetho
|
|||||||
QVariantList JsonTypes::packSupportedVendors()
|
QVariantList JsonTypes::packSupportedVendors()
|
||||||
{
|
{
|
||||||
QVariantList supportedVendors;
|
QVariantList supportedVendors;
|
||||||
foreach (const Vendor &vendor, GuhCore::instance()->supportedVendors()) {
|
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) {
|
||||||
supportedVendors.append(packVendor(vendor));
|
supportedVendors.append(packVendor(vendor));
|
||||||
}
|
}
|
||||||
return supportedVendors;
|
return supportedVendors;
|
||||||
@ -737,7 +737,7 @@ QVariantList JsonTypes::packSupportedVendors()
|
|||||||
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
||||||
{
|
{
|
||||||
QVariantList supportedDeviceList;
|
QVariantList supportedDeviceList;
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices(vendorId)) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices(vendorId)) {
|
||||||
supportedDeviceList.append(packDeviceClass(deviceClass));
|
supportedDeviceList.append(packDeviceClass(deviceClass));
|
||||||
}
|
}
|
||||||
return supportedDeviceList;
|
return supportedDeviceList;
|
||||||
@ -746,7 +746,7 @@ QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
|||||||
QVariantList JsonTypes::packConfiguredDevices()
|
QVariantList JsonTypes::packConfiguredDevices()
|
||||||
{
|
{
|
||||||
QVariantList configuredDeviceList;
|
QVariantList configuredDeviceList;
|
||||||
foreach (Device *device, GuhCore::instance()->configuredDevices()) {
|
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) {
|
||||||
configuredDeviceList.append(packDevice(device));
|
configuredDeviceList.append(packDevice(device));
|
||||||
}
|
}
|
||||||
return configuredDeviceList;
|
return configuredDeviceList;
|
||||||
@ -754,7 +754,7 @@ QVariantList JsonTypes::packConfiguredDevices()
|
|||||||
|
|
||||||
QVariantList JsonTypes::packDeviceStates(Device *device)
|
QVariantList JsonTypes::packDeviceStates(Device *device)
|
||||||
{
|
{
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
QVariantList stateValues;
|
QVariantList stateValues;
|
||||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||||
QVariantMap stateValue;
|
QVariantMap stateValue;
|
||||||
@ -777,7 +777,7 @@ QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> devi
|
|||||||
QVariantList JsonTypes::packRuleDescriptions()
|
QVariantList JsonTypes::packRuleDescriptions()
|
||||||
{
|
{
|
||||||
QVariantList rulesList;
|
QVariantList rulesList;
|
||||||
foreach (const Rule &rule, GuhCore::instance()->rules()) {
|
foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules()) {
|
||||||
rulesList.append(JsonTypes::packRuleDescription(rule));
|
rulesList.append(JsonTypes::packRuleDescription(rule));
|
||||||
}
|
}
|
||||||
return rulesList;
|
return rulesList;
|
||||||
@ -822,7 +822,7 @@ QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
|
|||||||
QVariantList JsonTypes::packPlugins()
|
QVariantList JsonTypes::packPlugins()
|
||||||
{
|
{
|
||||||
QVariantList pluginsList;
|
QVariantList pluginsList;
|
||||||
foreach (DevicePlugin *plugin, GuhCore::instance()->plugins()) {
|
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||||
QVariantMap pluginMap = packPlugin(plugin);
|
QVariantMap pluginMap = packPlugin(plugin);
|
||||||
pluginsList.append(pluginMap);
|
pluginsList.append(pluginMap);
|
||||||
}
|
}
|
||||||
@ -1380,7 +1380,7 @@ QPair<bool, QString> JsonTypes::validateBasicType(const QVariant &variant)
|
|||||||
|
|
||||||
QVariant::Type JsonTypes::getActionParamType(const ActionTypeId &actionTypeId, const QString ¶mName)
|
QVariant::Type JsonTypes::getActionParamType(const ActionTypeId &actionTypeId, const QString ¶mName)
|
||||||
{
|
{
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||||
if (actionType.id() == actionTypeId) {
|
if (actionType.id() == actionTypeId) {
|
||||||
foreach (const ParamType ¶mType, actionType.paramTypes()) {
|
foreach (const ParamType ¶mType, actionType.paramTypes()) {
|
||||||
@ -1396,7 +1396,7 @@ QVariant::Type JsonTypes::getActionParamType(const ActionTypeId &actionTypeId, c
|
|||||||
|
|
||||||
QVariant::Type JsonTypes::getEventParamType(const EventTypeId &eventTypeId, const QString ¶mName)
|
QVariant::Type JsonTypes::getEventParamType(const EventTypeId &eventTypeId, const QString ¶mName)
|
||||||
{
|
{
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||||
if (eventType.id() == eventTypeId) {
|
if (eventType.id() == eventTypeId) {
|
||||||
foreach (const ParamType ¶mType, eventType.paramTypes()) {
|
foreach (const ParamType ¶mType, eventType.paramTypes()) {
|
||||||
|
|||||||
@ -191,7 +191,7 @@ JsonReply* RulesHandler::GetRules(const QVariantMap ¶ms)
|
|||||||
JsonReply *RulesHandler::GetRuleDetails(const QVariantMap ¶ms)
|
JsonReply *RulesHandler::GetRuleDetails(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
||||||
Rule rule = GuhCore::instance()->findRule(ruleId);
|
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId);
|
||||||
if (rule.id().isNull()) {
|
if (rule.id().isNull()) {
|
||||||
return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound));
|
return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound));
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||||||
bool executable = params.value("executable", true).toBool();
|
bool executable = params.value("executable", true).toBool();
|
||||||
|
|
||||||
RuleId newRuleId = RuleId::createRuleId();
|
RuleId newRuleId = RuleId::createRuleId();
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
returns.insert("ruleId", newRuleId.toString());
|
returns.insert("ruleId", newRuleId.toString());
|
||||||
@ -311,10 +311,10 @@ JsonReply *RulesHandler::EditRule(const QVariantMap ¶ms)
|
|||||||
bool executable = params.value("executable", true).toBool();
|
bool executable = params.value("executable", true).toBool();
|
||||||
|
|
||||||
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
returns.insert("rule", JsonTypes::packRule(GuhCore::instance()->findRule(ruleId)));
|
returns.insert("rule", JsonTypes::packRule(GuhCore::instance()->ruleEngine()->findRule(ruleId)));
|
||||||
}
|
}
|
||||||
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
@ -332,7 +332,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap ¶ms)
|
|||||||
JsonReply *RulesHandler::FindRules(const QVariantMap ¶ms)
|
JsonReply *RulesHandler::FindRules(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
DeviceId deviceId = DeviceId(params.value("deviceId").toString());
|
DeviceId deviceId = DeviceId(params.value("deviceId").toString());
|
||||||
QList<RuleId> rules = GuhCore::instance()->findRules(deviceId);
|
QList<RuleId> rules = GuhCore::instance()->ruleEngine()->findRules(deviceId);
|
||||||
|
|
||||||
QVariantList rulesList;
|
QVariantList rulesList;
|
||||||
foreach (const RuleId &ruleId, rules) {
|
foreach (const RuleId &ruleId, rules) {
|
||||||
@ -346,19 +346,19 @@ JsonReply *RulesHandler::FindRules(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
JsonReply *RulesHandler::EnableRule(const QVariantMap ¶ms)
|
JsonReply *RulesHandler::EnableRule(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
return createReply(statusToReply(GuhCore::instance()->enableRule(RuleId(params.value("ruleId").toString()))));
|
return createReply(statusToReply(GuhCore::instance()->ruleEngine()->enableRule(RuleId(params.value("ruleId").toString()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonReply *RulesHandler::DisableRule(const QVariantMap ¶ms)
|
JsonReply *RulesHandler::DisableRule(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
return createReply(statusToReply(GuhCore::instance()->disableRule(RuleId(params.value("ruleId").toString()))));
|
return createReply(statusToReply(GuhCore::instance()->ruleEngine()->disableRule(RuleId(params.value("ruleId").toString()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonReply *RulesHandler::ExecuteActions(const QVariantMap ¶ms)
|
JsonReply *RulesHandler::ExecuteActions(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
RuleId ruleId(params.value("ruleId").toString());
|
RuleId ruleId(params.value("ruleId").toString());
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->executeRuleActions(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeActions(ruleId);
|
||||||
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ JsonReply *RulesHandler::ExecuteExitActions(const QVariantMap ¶ms)
|
|||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
RuleId ruleId(params.value("ruleId").toString());
|
RuleId ruleId(params.value("ruleId").toString());
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->executeRuleExitActions(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeExitActions(ruleId);
|
||||||
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ JsonReply* StateHandler::GetStateType(const QVariantMap ¶ms) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcJsonRpc) << "asked for state type" << params;
|
qCDebug(dcJsonRpc) << "asked for state type" << params;
|
||||||
StateTypeId stateTypeId(params.value("stateTypeId").toString());
|
StateTypeId stateTypeId(params.value("stateTypeId").toString());
|
||||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||||
if (stateType.id() == stateTypeId) {
|
if (stateType.id() == stateTypeId) {
|
||||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||||
|
|||||||
@ -76,7 +76,7 @@ HttpReply *DeviceClassesResource::proccessRequest(const HttpRequest &request, co
|
|||||||
qCWarning(dcRest) << "Could not parse DeviceClassId:" << urlTokens.at(3);
|
qCWarning(dcRest) << "Could not parse DeviceClassId:" << urlTokens.at(3);
|
||||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||||
}
|
}
|
||||||
m_deviceClass = GuhCore::instance()->findDeviceClass(deviceClassId);
|
m_deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||||
if (!m_deviceClass.isValid()) {
|
if (!m_deviceClass.isValid()) {
|
||||||
qCWarning(dcRest) << "DeviceClassId" << deviceClassId.toString() << "not found";
|
qCWarning(dcRest) << "DeviceClassId" << deviceClassId.toString() << "not found";
|
||||||
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceClassNotFound);
|
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||||
@ -265,7 +265,7 @@ HttpReply *DeviceClassesResource::getDiscoverdDevices(const ParamList &discovery
|
|||||||
qCDebug(dcRest) << "Discover devices for DeviceClass" << m_deviceClass.id();
|
qCDebug(dcRest) << "Discover devices for DeviceClass" << m_deviceClass.id();
|
||||||
qCDebug(dcRest) << discoveryParams;
|
qCDebug(dcRest) << discoveryParams;
|
||||||
|
|
||||||
DeviceManager::DeviceError status = GuhCore::instance()->discoverDevices(m_deviceClass.id(), discoveryParams);
|
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(m_deviceClass.id(), discoveryParams);
|
||||||
|
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
HttpReply *reply = createAsyncReply();
|
HttpReply *reply = createAsyncReply();
|
||||||
|
|||||||
@ -81,7 +81,7 @@ HttpReply *DevicesResource::proccessRequest(const HttpRequest &request, const QS
|
|||||||
qCWarning(dcRest) << "Could not parse DeviceId:" << urlTokens.at(3);
|
qCWarning(dcRest) << "Could not parse DeviceId:" << urlTokens.at(3);
|
||||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceNotFound);
|
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceNotFound);
|
||||||
}
|
}
|
||||||
m_device = GuhCore::instance()->findConfiguredDevice(deviceId);
|
m_device = GuhCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
|
||||||
if (!m_device) {
|
if (!m_device) {
|
||||||
qCWarning(dcRest) << "Could find any device with DeviceId:" << urlTokens.at(3);
|
qCWarning(dcRest) << "Could find any device with DeviceId:" << urlTokens.at(3);
|
||||||
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceNotFound);
|
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceNotFound);
|
||||||
@ -212,7 +212,7 @@ HttpReply *DevicesResource::proccessPostRequest(const HttpRequest &request, cons
|
|||||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorActionTypeNotFound);
|
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorActionTypeNotFound);
|
||||||
}
|
}
|
||||||
bool found = false;
|
bool found = false;
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(m_device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(m_device->deviceClassId());
|
||||||
foreach (const ActionType actionType, deviceClass.actionTypes()) {
|
foreach (const ActionType actionType, deviceClass.actionTypes()) {
|
||||||
if (actionType.id() == actionTypeId) {
|
if (actionType.id() == actionTypeId) {
|
||||||
found = true;
|
found = true;
|
||||||
@ -363,6 +363,7 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
|||||||
if (deviceClassId.isNull())
|
if (deviceClassId.isNull())
|
||||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||||
|
|
||||||
|
QString deviceName = params.value("name").toString();
|
||||||
DeviceId newDeviceId = DeviceId::createDeviceId();
|
DeviceId newDeviceId = DeviceId::createDeviceId();
|
||||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
@ -370,10 +371,10 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
|||||||
DeviceManager::DeviceError status;
|
DeviceManager::DeviceError status;
|
||||||
if (deviceDescriptorId.isNull()) {
|
if (deviceDescriptorId.isNull()) {
|
||||||
qCDebug(dcRest) << "Adding device with " << deviceParams;
|
qCDebug(dcRest) << "Adding device with " << deviceParams;
|
||||||
status = GuhCore::instance()->addConfiguredDevice(deviceClassId, deviceParams, newDeviceId);
|
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceParams, newDeviceId);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcRest) << "Adding discovered device with DeviceDescriptorId" << deviceDescriptorId.toString();
|
qCDebug(dcRest) << "Adding discovered device with DeviceDescriptorId" << deviceDescriptorId.toString();
|
||||||
status = GuhCore::instance()->addConfiguredDevice(deviceClassId, deviceDescriptorId, newDeviceId);
|
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceDescriptorId, newDeviceId);
|
||||||
}
|
}
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
HttpReply *reply = createAsyncReply();
|
HttpReply *reply = createAsyncReply();
|
||||||
@ -385,7 +386,7 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
|||||||
if (status != DeviceManager::DeviceErrorNoError)
|
if (status != DeviceManager::DeviceErrorNoError)
|
||||||
return createDeviceErrorReply(HttpReply::InternalServerError, status);
|
return createDeviceErrorReply(HttpReply::InternalServerError, status);
|
||||||
|
|
||||||
QVariant result = JsonTypes::packDevice(GuhCore::instance()->findConfiguredDevice(newDeviceId));
|
QVariant result = JsonTypes::packDevice(GuhCore::instance()->deviceManager()->findConfiguredDevice(newDeviceId));
|
||||||
HttpReply *reply = createSuccessReply();
|
HttpReply *reply = createSuccessReply();
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||||
reply->setPayload(QJsonDocument::fromVariant(result).toJson());
|
reply->setPayload(QJsonDocument::fromVariant(result).toJson());
|
||||||
@ -401,7 +402,7 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
|
|||||||
QVariantMap params = verification.second.toMap();
|
QVariantMap params = verification.second.toMap();
|
||||||
|
|
||||||
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||||
|
|
||||||
if (deviceClassId.isNull()) {
|
if (deviceClassId.isNull()) {
|
||||||
qCWarning(dcRest) << "Could not find deviceClassId" << params.value("deviceClassId").toString();
|
qCWarning(dcRest) << "Could not find deviceClassId" << params.value("deviceClassId").toString();
|
||||||
@ -414,10 +415,10 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
|
|||||||
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
||||||
if (params.contains("deviceDescriptorId")) {
|
if (params.contains("deviceDescriptorId")) {
|
||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
status = GuhCore::instance()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
||||||
} else {
|
} else {
|
||||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||||
status = GuhCore::instance()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != DeviceManager::DeviceErrorNoError)
|
if (status != DeviceManager::DeviceErrorNoError)
|
||||||
@ -443,7 +444,7 @@ HttpReply *DevicesResource::confirmPairDevice(const QByteArray &payload) const
|
|||||||
|
|
||||||
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
|
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
|
||||||
QString secret = params.value("secret").toString();
|
QString secret = params.value("secret").toString();
|
||||||
DeviceManager::DeviceError status = GuhCore::instance()->confirmPairing(pairingTransactionId, secret);
|
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret);
|
||||||
|
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
HttpReply *reply = createAsyncReply();
|
HttpReply *reply = createAsyncReply();
|
||||||
@ -472,10 +473,10 @@ HttpReply *DevicesResource::editDevice(Device *device, const QByteArray &payload
|
|||||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||||
if (deviceDescriptorId.isNull()) {
|
if (deviceDescriptorId.isNull()) {
|
||||||
qCDebug(dcRest) << "Edit device with params:" << deviceParams;
|
qCDebug(dcRest) << "Edit device with params:" << deviceParams;
|
||||||
status = GuhCore::instance()->editDevice(device->id(), deviceParams);
|
status = GuhCore::instance()->deviceManager()->editDevice(device->id(), deviceParams);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcRest) << "Edit device using the discovered device with descriptorId:" << deviceDescriptorId.toString();
|
qCDebug(dcRest) << "Edit device using the discovered device with descriptorId:" << deviceDescriptorId.toString();
|
||||||
status = GuhCore::instance()->editDevice(device->id(), deviceDescriptorId);
|
status = GuhCore::instance()->deviceManager()->editDevice(device->id(), deviceDescriptorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == DeviceManager::DeviceErrorAsync) {
|
if (status == DeviceManager::DeviceErrorAsync) {
|
||||||
|
|||||||
@ -147,7 +147,7 @@ HttpReply *PluginsResource::getPlugin(const PluginId &pluginId) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Get plugin with id" << pluginId;
|
qCDebug(dcRest) << "Get plugin with id" << pluginId;
|
||||||
HttpReply *reply = createSuccessReply();
|
HttpReply *reply = createSuccessReply();
|
||||||
foreach (DevicePlugin *plugin, GuhCore::instance()->plugins()) {
|
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||||
if (plugin->pluginId() == pluginId) {
|
if (plugin->pluginId() == pluginId) {
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||||
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packPlugin(plugin)).toJson());
|
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packPlugin(plugin)).toJson());
|
||||||
@ -193,7 +193,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
|
|||||||
QVariantList configuration = verification.second.toList();
|
QVariantList configuration = verification.second.toList();
|
||||||
ParamList pluginParams = JsonTypes::unpackParams(configuration);
|
ParamList pluginParams = JsonTypes::unpackParams(configuration);
|
||||||
qCDebug(dcRest) << pluginParams;
|
qCDebug(dcRest) << pluginParams;
|
||||||
DeviceManager::DeviceError result = GuhCore::instance()->setPluginConfig(pluginId, pluginParams);
|
DeviceManager::DeviceError result = GuhCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams);
|
||||||
|
|
||||||
if (result != DeviceManager::DeviceErrorNoError)
|
if (result != DeviceManager::DeviceErrorNoError)
|
||||||
return createDeviceErrorReply(HttpReply::BadRequest, result);
|
return createDeviceErrorReply(HttpReply::BadRequest, result);
|
||||||
@ -203,7 +203,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
|
|||||||
|
|
||||||
DevicePlugin *PluginsResource::findPlugin(const PluginId &pluginId) const
|
DevicePlugin *PluginsResource::findPlugin(const PluginId &pluginId) const
|
||||||
{
|
{
|
||||||
foreach (DevicePlugin *plugin, GuhCore::instance()->plugins()) {
|
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||||
if (plugin->pluginId() == pluginId) {
|
if (plugin->pluginId() == pluginId) {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ HttpReply *RulesResource::proccessRequest(const HttpRequest &request, const QStr
|
|||||||
return createRuleErrorReply(HttpReply::BadRequest, RuleEngine::RuleErrorRuleNotFound);
|
return createRuleErrorReply(HttpReply::BadRequest, RuleEngine::RuleErrorRuleNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GuhCore::instance()->findRule(m_ruleId).id().isNull())
|
if (GuhCore::instance()->ruleEngine()->findRule(m_ruleId).id().isNull())
|
||||||
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
|
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -197,10 +197,10 @@ HttpReply *RulesResource::getRules(const DeviceId &deviceId) const
|
|||||||
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packRuleDescriptions()).toJson());
|
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packRuleDescriptions()).toJson());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcRest) << "Get rule descriptions which contain the device with id" << deviceId.toString();
|
qCDebug(dcRest) << "Get rule descriptions which contain the device with id" << deviceId.toString();
|
||||||
QList<RuleId> ruleIdsList = GuhCore::instance()->findRules(deviceId);
|
QList<RuleId> ruleIdsList = GuhCore::instance()->ruleEngine()->findRules(deviceId);
|
||||||
QList<Rule> ruleList;
|
QList<Rule> ruleList;
|
||||||
foreach (const RuleId &ruleId, ruleIdsList) {
|
foreach (const RuleId &ruleId, ruleIdsList) {
|
||||||
Rule rule = GuhCore::instance()->findRule(ruleId);
|
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId);
|
||||||
if (!rule.id().isNull())
|
if (!rule.id().isNull())
|
||||||
ruleList.append(rule);
|
ruleList.append(rule);
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ HttpReply *RulesResource::getRules(const DeviceId &deviceId) const
|
|||||||
|
|
||||||
HttpReply *RulesResource::getRuleDetails(const RuleId &ruleId) const
|
HttpReply *RulesResource::getRuleDetails(const RuleId &ruleId) const
|
||||||
{
|
{
|
||||||
Rule rule = GuhCore::instance()->findRule(ruleId);
|
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId);
|
||||||
if (rule.id().isNull())
|
if (rule.id().isNull())
|
||||||
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
|
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
|
||||||
|
|
||||||
@ -279,10 +279,10 @@ HttpReply *RulesResource::addRule(const QByteArray &payload) const
|
|||||||
bool executable = params.value("executable", true).toBool();
|
bool executable = params.value("executable", true).toBool();
|
||||||
|
|
||||||
RuleId newRuleId = RuleId::createRuleId();
|
RuleId newRuleId = RuleId::createRuleId();
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
||||||
|
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
QVariant returns = JsonTypes::packRule(GuhCore::instance()->findRule(newRuleId));
|
QVariant returns = JsonTypes::packRule(GuhCore::instance()->ruleEngine()->findRule(newRuleId));
|
||||||
HttpReply *reply = createSuccessReply();
|
HttpReply *reply = createSuccessReply();
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||||
reply->setPayload(QJsonDocument::fromVariant(returns).toJson());
|
reply->setPayload(QJsonDocument::fromVariant(returns).toJson());
|
||||||
@ -296,7 +296,7 @@ HttpReply *RulesResource::enableRule(const RuleId &ruleId) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Enable rule with id" << ruleId.toString();
|
qCDebug(dcRest) << "Enable rule with id" << ruleId.toString();
|
||||||
|
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->enableRule(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->enableRule(ruleId);
|
||||||
|
|
||||||
if (status != RuleEngine::RuleErrorNoError)
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
@ -308,7 +308,7 @@ HttpReply *RulesResource::disableRule(const RuleId &ruleId) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Disable rule with id" << ruleId.toString();
|
qCDebug(dcRest) << "Disable rule with id" << ruleId.toString();
|
||||||
|
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->disableRule(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->disableRule(ruleId);
|
||||||
|
|
||||||
if (status != RuleEngine::RuleErrorNoError)
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
@ -320,7 +320,7 @@ HttpReply *RulesResource::executeActions(const RuleId &ruleId) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Execute actions of rule with id" << ruleId.toString();
|
qCDebug(dcRest) << "Execute actions of rule with id" << ruleId.toString();
|
||||||
|
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->executeRuleActions(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeActions(ruleId);
|
||||||
|
|
||||||
if (status != RuleEngine::RuleErrorNoError)
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
@ -332,7 +332,7 @@ HttpReply *RulesResource::executeExitActions(const RuleId &ruleId) const
|
|||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Execute exit actions of rule with id" << ruleId.toString();
|
qCDebug(dcRest) << "Execute exit actions of rule with id" << ruleId.toString();
|
||||||
|
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->executeRuleExitActions(ruleId);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeExitActions(ruleId);
|
||||||
|
|
||||||
if (status != RuleEngine::RuleErrorNoError)
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
@ -382,7 +382,7 @@ HttpReply *RulesResource::editRule(const RuleId &ruleId, const QByteArray &paylo
|
|||||||
QString name = params.value("name", QString()).toString();
|
QString name = params.value("name", QString()).toString();
|
||||||
bool enabled = params.value("enabled", true).toBool();
|
bool enabled = params.value("enabled", true).toBool();
|
||||||
|
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled);
|
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled);
|
||||||
|
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
qCDebug(dcRest) << "Edit rule successfully finished";
|
qCDebug(dcRest) << "Edit rule successfully finished";
|
||||||
|
|||||||
@ -110,7 +110,7 @@ HttpReply *VendorsResource::getVendors() const
|
|||||||
HttpReply *reply = createSuccessReply();
|
HttpReply *reply = createSuccessReply();
|
||||||
|
|
||||||
QVariantList vendorsList;
|
QVariantList vendorsList;
|
||||||
foreach (const Vendor &vendor, GuhCore::instance()->supportedVendors()) {
|
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) {
|
||||||
vendorsList.append(JsonTypes::packVendor(vendor));
|
vendorsList.append(JsonTypes::packVendor(vendor));
|
||||||
}
|
}
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||||
@ -121,7 +121,7 @@ HttpReply *VendorsResource::getVendors() const
|
|||||||
HttpReply *VendorsResource::getVendor(const VendorId &vendorId) const
|
HttpReply *VendorsResource::getVendor(const VendorId &vendorId) const
|
||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Get vendor with id" << vendorId;
|
qCDebug(dcRest) << "Get vendor with id" << vendorId;
|
||||||
foreach (const Vendor &vendor, GuhCore::instance()->supportedVendors()) {
|
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) {
|
||||||
if (vendor.id() == vendorId) {
|
if (vendor.id() == vendorId) {
|
||||||
HttpReply *reply = createSuccessReply();
|
HttpReply *reply = createSuccessReply();
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||||
|
|||||||
@ -226,7 +226,7 @@ RuleEngine::~RuleEngine()
|
|||||||
*/
|
*/
|
||||||
QList<Rule> RuleEngine::evaluateEvent(const Event &event)
|
QList<Rule> RuleEngine::evaluateEvent(const Event &event)
|
||||||
{
|
{
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(event.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId());
|
||||||
|
|
||||||
qCDebug(dcRuleEngine) << "got event:" << event << device->name() << event.eventTypeId();
|
qCDebug(dcRuleEngine) << "got event:" << event << device->name() << event.eventTypeId();
|
||||||
|
|
||||||
@ -293,12 +293,12 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (const EventDescriptor &eventDescriptor, eventDescriptorList) {
|
foreach (const EventDescriptor &eventDescriptor, eventDescriptorList) {
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(eventDescriptor.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(eventDescriptor.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId();
|
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId();
|
||||||
return RuleErrorDeviceNotFound;
|
return RuleErrorDeviceNotFound;
|
||||||
}
|
}
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
|
|
||||||
bool eventTypeFound = false;
|
bool eventTypeFound = false;
|
||||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||||
@ -315,12 +315,12 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
|
|
||||||
|
|
||||||
foreach (const RuleAction &action, actions) {
|
foreach (const RuleAction &action, actions) {
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(action.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for actionTypeId" << action.actionTypeId();
|
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for actionTypeId" << action.actionTypeId();
|
||||||
return RuleErrorDeviceNotFound;
|
return RuleErrorDeviceNotFound;
|
||||||
}
|
}
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
if (!deviceClass.hasActionType(action.actionTypeId())) {
|
if (!deviceClass.hasActionType(action.actionTypeId())) {
|
||||||
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
|
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
|
||||||
return RuleErrorActionTypeNotFound;
|
return RuleErrorActionTypeNotFound;
|
||||||
@ -344,12 +344,12 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
qCDebug(dcRuleEngine) << "actions" << actions.last().actionTypeId() << actions.last().ruleActionParams();
|
qCDebug(dcRuleEngine) << "actions" << actions.last().actionTypeId() << actions.last().ruleActionParams();
|
||||||
|
|
||||||
foreach (const RuleAction &action, exitActions) {
|
foreach (const RuleAction &action, exitActions) {
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(action.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for actionTypeId" << action.actionTypeId();
|
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for actionTypeId" << action.actionTypeId();
|
||||||
return RuleErrorDeviceNotFound;
|
return RuleErrorDeviceNotFound;
|
||||||
}
|
}
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
|
|
||||||
if (!deviceClass.hasActionType(action.actionTypeId())) {
|
if (!deviceClass.hasActionType(action.actionTypeId())) {
|
||||||
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
|
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
|
||||||
|
|||||||
@ -100,7 +100,7 @@ void StateEvaluator::setOperatorType(Types::StateOperator operatorType)
|
|||||||
bool StateEvaluator::evaluate() const
|
bool StateEvaluator::evaluate() const
|
||||||
{
|
{
|
||||||
if (m_stateDescriptor.isValid()) {
|
if (m_stateDescriptor.isValid()) {
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCWarning(dcRuleEngine) << "Device not existing!";
|
qCWarning(dcRuleEngine) << "Device not existing!";
|
||||||
return false;
|
return false;
|
||||||
@ -210,7 +210,7 @@ StateEvaluator StateEvaluator::loadFromSettings(GuhSettings &settings, const QSt
|
|||||||
bool StateEvaluator::isValid() const
|
bool StateEvaluator::isValid() const
|
||||||
{
|
{
|
||||||
if (m_stateDescriptor.isValid()) {
|
if (m_stateDescriptor.isValid()) {
|
||||||
Device *device = GuhCore::instance()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCWarning(dcRuleEngine) << "State evaluator device does not exist!";
|
qCWarning(dcRuleEngine) << "State evaluator device does not exist!";
|
||||||
return false;
|
return false;
|
||||||
@ -221,7 +221,7 @@ bool StateEvaluator::isValid() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceClass deviceClass = GuhCore::instance()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||||
if (stateType.id() == m_stateDescriptor.stateTypeId()) {
|
if (stateType.id() == m_stateDescriptor.stateTypeId()) {
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ private slots:
|
|||||||
|
|
||||||
void TestEvents::triggerEvent()
|
void TestEvents::triggerEvent()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void TestEvents::triggerEvent()
|
|||||||
|
|
||||||
void TestEvents::triggerStateChangeEvent()
|
void TestEvents::triggerStateChangeEvent()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
|||||||
@ -136,7 +136,7 @@ void TestLogging::invalidFilter()
|
|||||||
|
|
||||||
void TestLogging::eventLogs()
|
void TestLogging::eventLogs()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
|||||||
@ -483,7 +483,7 @@ void TestRestDevices::executeAction()
|
|||||||
|
|
||||||
void TestRestDevices::getStateValue_data()
|
void TestRestDevices::getStateValue_data()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ void TestRestLogging::invalidFilter()
|
|||||||
|
|
||||||
void TestRestLogging::eventLogs()
|
void TestRestLogging::eventLogs()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ void TestStates::getStateTypes()
|
|||||||
|
|
||||||
void TestStates::getStateValue_data()
|
void TestStates::getStateValue_data()
|
||||||
{
|
{
|
||||||
QList<Device*> devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId);
|
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
|
||||||
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
|
||||||
Device *device = devices.first();
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user