changed editable property to readOnly
added guhcore documentation bump JSONRPC api version
This commit is contained in:
parent
4c022b6a7e
commit
745107c469
4
guh.pri
4
guh.pri
@ -2,9 +2,9 @@
|
|||||||
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 JSON protocol version
|
# define JSON protocol version
|
||||||
JSON_PROTOCOL_VERSION=21
|
JSON_PROTOCOL_VERSION=22
|
||||||
|
|
||||||
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" JSON_PROTOCOL_VERSION=21
|
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION}\\\"
|
||||||
|
|
||||||
QT+= network
|
QT+= network
|
||||||
|
|
||||||
|
|||||||
@ -95,8 +95,8 @@
|
|||||||
Couldn't find the PairingTransactionId for the given id.
|
Couldn't find the PairingTransactionId for the given id.
|
||||||
\value DeviceErrorAuthentificationFailure
|
\value DeviceErrorAuthentificationFailure
|
||||||
The device could not authentificate with something.
|
The device could not authentificate with something.
|
||||||
\value DeviceErrorParameterNotEditable
|
\value DeviceErrorParameterNotWritable
|
||||||
One of the given device params is not editable.
|
One of the given device params is not writable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \enum DeviceManager::DeviceSetupStatus
|
/*! \enum DeviceManager::DeviceSetupStatus
|
||||||
@ -352,10 +352,10 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
|
|||||||
|
|
||||||
/*! Edit the \l{ParamList}{Params} of a configured device with the given \a deviceId to the new given \a params.
|
/*! Edit the \l{ParamList}{Params} of a configured device with the given \a deviceId to the new given \a params.
|
||||||
* The given parameter \a fromDiscovery specifies if the new \a params came
|
* The given parameter \a fromDiscovery specifies if the new \a params came
|
||||||
* from a discovery or if the user set them. If it came from discovery not editable will be changed too.
|
* from a discovery or if the user set them. If it came from discovery not writable parameters (readOnly) will be changed too.
|
||||||
*
|
*
|
||||||
* Returns \l{DeviceError} to inform about the result. */
|
* Returns \l{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const ParamList ¶ms, const bool &fromDiscovery)
|
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery)
|
||||||
{
|
{
|
||||||
Device *device = findConfiguredDevice(deviceId);
|
Device *device = findConfiguredDevice(deviceId);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@ -379,8 +379,8 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
|||||||
foreach (const ParamType ¶mType, deviceClass.paramTypes()) {
|
foreach (const ParamType ¶mType, deviceClass.paramTypes()) {
|
||||||
foreach (const Param ¶m, params) {
|
foreach (const Param ¶m, params) {
|
||||||
if (paramType.name() == param.name()) {
|
if (paramType.name() == param.name()) {
|
||||||
if (!paramType.editable())
|
if (paramType.readOnly())
|
||||||
return DeviceErrorParameterNotEditable;
|
return DeviceErrorParameterNotWritable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,6 +391,10 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// first remove the device in the plugin
|
||||||
|
plugin->deviceRemoved(device);
|
||||||
|
|
||||||
|
// mark setup as incomplete
|
||||||
device->setSetupComplete(false);
|
device->setSetupComplete(false);
|
||||||
|
|
||||||
// set new params
|
// set new params
|
||||||
@ -398,10 +402,11 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
|||||||
device->setParamValue(param.name(), param.value());
|
device->setParamValue(param.name(), param.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceSetupStatus status = plugin->editDevice(device);
|
// try to setup the device with the new params
|
||||||
|
DeviceSetupStatus status = plugin->setupDevice(device);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case DeviceSetupStatusFailure:
|
case DeviceSetupStatusFailure:
|
||||||
qWarning() << "Device edit failed. Not saving changes of device paramters.";
|
qWarning() << "Device edit failed. Not saving changes of device paramters. Device setup incomplete.";
|
||||||
return DeviceErrorSetupFailed;
|
return DeviceErrorSetupFailed;
|
||||||
case DeviceSetupStatusAsync:
|
case DeviceSetupStatusAsync:
|
||||||
m_asyncDeviceEdit.append(device);
|
m_asyncDeviceEdit.append(device);
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public:
|
|||||||
DeviceErrorAsync,
|
DeviceErrorAsync,
|
||||||
DeviceErrorDeviceInUse,
|
DeviceErrorDeviceInUse,
|
||||||
DeviceErrorPairingTransactionIdNotFound,
|
DeviceErrorPairingTransactionIdNotFound,
|
||||||
DeviceErrorParameterNotEditable
|
DeviceErrorParameterNotWritable
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DeviceSetupStatus {
|
enum DeviceSetupStatus {
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, 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 DeviceDescriptorId &deviceDescriptorId, const DeviceId &id = DeviceId::createDeviceId());
|
||||||
|
|
||||||
DeviceError editDevice(const DeviceId &deviceId, const ParamList ¶ms, const 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);
|
||||||
|
|
||||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
||||||
|
|||||||
@ -333,21 +333,6 @@ DeviceManager::DeviceSetupStatus DevicePlugin::setupDevice(Device *device)
|
|||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! This will be called when the \l{ParamList}{Params} of the given \a device was changed.
|
|
||||||
* Here you have the chance to set up the device with the new \l{ParamList}{Params} without creating a new one.
|
|
||||||
*
|
|
||||||
* Return \l{DeviceManager}{DeviceSetupStatusFailure} if something bad happened during the setup in which case the \a device
|
|
||||||
* will be disabled. Return \l{DeviceManager}{DeviceSetupStatusSuccess} if everything went well. If you can't tell yet and
|
|
||||||
* need more time to set up the \a device (note: you should never block in this method) you can
|
|
||||||
* return \l{DeviceManager}{DeviceSetupStatusAsync}. In that case the \l{DeviceManager} will wait for you to emit
|
|
||||||
* \l{DevicePlugin}{deviceSetupFinished} to report the status.
|
|
||||||
*/
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePlugin::editDevice(Device *device)
|
|
||||||
{
|
|
||||||
Q_UNUSED(device)
|
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! This will be called when a new \a device was added successfully and the device setup is finished.*/
|
/*! This will be called when a new \a device was added successfully and the device setup is finished.*/
|
||||||
void DevicePlugin::postSetupDevice(Device *device)
|
void DevicePlugin::postSetupDevice(Device *device)
|
||||||
{
|
{
|
||||||
@ -429,9 +414,9 @@ QList<ParamType> DevicePlugin::parseParamTypes(const QJsonArray &array) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set editable if given (default true)
|
// set readOnly if given (default false)
|
||||||
if (pt.contains("editable")) {
|
if (pt.contains("readOnly")) {
|
||||||
paramType.setEditable(pt.value("editable").toBool());
|
paramType.setReadOnly(pt.value("readOnly").toBool());
|
||||||
}
|
}
|
||||||
paramType.setAllowedValues(allowedValues);
|
paramType.setAllowedValues(allowedValues);
|
||||||
paramType.setLimits(pt.value("minValue").toVariant(), pt.value("maxValue").toVariant());
|
paramType.setLimits(pt.value("minValue").toVariant(), pt.value("maxValue").toVariant());
|
||||||
|
|||||||
@ -57,7 +57,6 @@ public:
|
|||||||
virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
||||||
|
|
||||||
virtual DeviceManager::DeviceSetupStatus setupDevice(Device *device);
|
virtual DeviceManager::DeviceSetupStatus setupDevice(Device *device);
|
||||||
virtual DeviceManager::DeviceSetupStatus editDevice(Device *device);
|
|
||||||
virtual void postSetupDevice(Device *device);
|
virtual void postSetupDevice(Device *device);
|
||||||
virtual void deviceRemoved(Device *device);
|
virtual void deviceRemoved(Device *device);
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ ParamType::ParamType(const QString &name, const QVariant::Type type, const QVari
|
|||||||
m_type(type),
|
m_type(type),
|
||||||
m_defaultValue(defaultValue),
|
m_defaultValue(defaultValue),
|
||||||
m_inputType(Types::InputTypeNone),
|
m_inputType(Types::InputTypeNone),
|
||||||
m_editable(true)
|
m_readOnly(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,19 +139,19 @@ void ParamType::setAllowedValues(const QList<QVariant> allowedValues)
|
|||||||
m_allowedValues = allowedValues;
|
m_allowedValues = allowedValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns true if this ParamType is editable by the user. By default a ParamType is always editable. */
|
/*! Returns false if this ParamType is writable by the user. By default a ParamType is always writable. */
|
||||||
bool ParamType::editable() const
|
bool ParamType::readOnly() const
|
||||||
{
|
{
|
||||||
return m_editable;
|
return m_readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Sets this ParamType \a editable. By default a ParamType is always editable. */
|
/*! Sets this ParamType \a readOnly. By default a ParamType is always writable. */
|
||||||
void ParamType::setEditable(const bool &editable)
|
void ParamType::setReadOnly(const bool &readOnly)
|
||||||
{
|
{
|
||||||
m_editable = editable;
|
m_readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Writes the name, type defaultValue, min value, max value and editable of the given \a paramType to \a dbg. */
|
/*! Writes the name, type defaultValue, min value, max value and readOnly of the given \a paramType to \a dbg. */
|
||||||
QDebug operator<<(QDebug dbg, const ParamType ¶mType)
|
QDebug operator<<(QDebug dbg, const ParamType ¶mType)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "ParamType(Name: " << paramType.name()
|
dbg.nospace() << "ParamType(Name: " << paramType.name()
|
||||||
@ -160,7 +160,7 @@ QDebug operator<<(QDebug dbg, const ParamType ¶mType)
|
|||||||
<< ", Min:" << paramType.minValue()
|
<< ", Min:" << paramType.minValue()
|
||||||
<< ", Max:" << paramType.maxValue()
|
<< ", Max:" << paramType.maxValue()
|
||||||
<< ", Allowed values:" << paramType.allowedValues()
|
<< ", Allowed values:" << paramType.allowedValues()
|
||||||
<< ", Editable:" << paramType.editable()
|
<< ", ReadOnly:" << paramType.readOnly()
|
||||||
<< ")";
|
<< ")";
|
||||||
|
|
||||||
return dbg.space();
|
return dbg.space();
|
||||||
|
|||||||
@ -55,8 +55,8 @@ public:
|
|||||||
QList<QVariant> allowedValues() const;
|
QList<QVariant> allowedValues() const;
|
||||||
void setAllowedValues(const QList<QVariant> allowedValues);
|
void setAllowedValues(const QList<QVariant> allowedValues);
|
||||||
|
|
||||||
bool editable() const;
|
bool readOnly() const;
|
||||||
void setEditable(const bool &editable);
|
void setReadOnly(const bool &readOnly);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
@ -66,7 +66,7 @@ private:
|
|||||||
QVariant m_maxValue;
|
QVariant m_maxValue;
|
||||||
Types::InputType m_inputType;
|
Types::InputType m_inputType;
|
||||||
QVariantList m_allowedValues;
|
QVariantList m_allowedValues;
|
||||||
bool m_editable;
|
bool m_readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const ParamType ¶mType);
|
QDebug operator<<(QDebug dbg, const ParamType ¶mType);
|
||||||
|
|||||||
@ -84,43 +84,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
|
|||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePluginMock::editDevice(Device *device)
|
|
||||||
{
|
|
||||||
qDebug() << "Mockdevice edit params to"
|
|
||||||
<< device->paramValue("name").toString()
|
|
||||||
<< device->paramValue("httpport").toInt()
|
|
||||||
<< device->paramValue("async").toBool()
|
|
||||||
<< device->paramValue("broken").toBool();
|
|
||||||
|
|
||||||
if (device->paramValue("broken").toBool()) {
|
|
||||||
qWarning() << "This device is intentionally broken.";
|
|
||||||
return DeviceManager::DeviceSetupStatusFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the old daemon...
|
|
||||||
foreach (Device *d, m_daemons.keys()) {
|
|
||||||
if (d->id() == device->id()) {
|
|
||||||
delete m_daemons.take(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...and create/start a new one
|
|
||||||
HttpDaemon *daemon = new HttpDaemon(device, this);
|
|
||||||
m_daemons.insert(device, daemon);
|
|
||||||
|
|
||||||
if (!daemon->isListening()) {
|
|
||||||
qWarning() << "HTTP port opening failed.";
|
|
||||||
return DeviceManager::DeviceSetupStatusFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device->paramValue("async").toBool()) {
|
|
||||||
m_asyncSetupDevices.append(device);
|
|
||||||
QTimer::singleShot(1000, this, SLOT(emitDeviceSetupFinished()));
|
|
||||||
return DeviceManager::DeviceSetupStatusAsync;
|
|
||||||
}
|
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginMock::deviceRemoved(Device *device)
|
void DevicePluginMock::deviceRemoved(Device *device)
|
||||||
{
|
{
|
||||||
delete m_daemons.take(device);
|
delete m_daemons.take(device);
|
||||||
|
|||||||
@ -43,7 +43,6 @@ public:
|
|||||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||||
DeviceManager::DeviceSetupStatus editDevice(Device *device) override;
|
|
||||||
void deviceRemoved(Device *device) override;
|
void deviceRemoved(Device *device) override;
|
||||||
|
|
||||||
void startMonitoringAutoDevices() override;
|
void startMonitoringAutoDevices() override;
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
"type": "QString",
|
"type": "QString",
|
||||||
"inputType": "TextLine",
|
"inputType": "TextLine",
|
||||||
"defaultValue": "Mock device",
|
"defaultValue": "Mock device",
|
||||||
"editable": false
|
"readOnly": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "httpport",
|
"name": "httpport",
|
||||||
@ -120,7 +120,7 @@
|
|||||||
"type": "QString",
|
"type": "QString",
|
||||||
"inputType": "TextLine",
|
"inputType": "TextLine",
|
||||||
"defaultValue": "Mock device",
|
"defaultValue": "Mock device",
|
||||||
"editable": false
|
"readOnly": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "httpport",
|
"name": "httpport",
|
||||||
|
|||||||
@ -46,6 +46,18 @@
|
|||||||
\l{StateType} and the \a value parameter holds the new value.
|
\l{StateType} and the \a value parameter holds the new value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::deviceRemoved(const DeviceId &deviceId);
|
||||||
|
This signal is emitted when a \l{Device} with the given \a deviceId was removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::deviceAdded(Device *device);
|
||||||
|
This signal is emitted when a \a device was added to the system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::deviceParamsChanged(Device *device);
|
||||||
|
This signal is emitted when the \l{ParamList}{Params} of a \a device have been changed.
|
||||||
|
*/
|
||||||
|
|
||||||
/*! \fn void GuhCore::actionExecuted(const ActionId &id, DeviceManager::DeviceError status);
|
/*! \fn void GuhCore::actionExecuted(const ActionId &id, DeviceManager::DeviceError status);
|
||||||
This signal is emitted when the \l{Action} with the given \a id is finished.
|
This signal is emitted when the \l{Action} with the given \a id is finished.
|
||||||
The \a status of the \l{Action} execution will be described as \l{DeviceManager::DeviceError}{DeviceError}.
|
The \a status of the \l{Action} execution will be described as \l{DeviceManager::DeviceError}{DeviceError}.
|
||||||
@ -62,11 +74,25 @@
|
|||||||
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
|
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::deviceEditFinished(Device *device, DeviceManager::DeviceError status);
|
||||||
|
This signal is emitted when the edit request of a \a device is finished. The \a status of the edit request will be
|
||||||
|
described as \l{DeviceManager::DeviceError}{DeviceError}.
|
||||||
|
*/
|
||||||
|
|
||||||
/*! \fn void GuhCore::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
/*! \fn void GuhCore::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
||||||
The DeviceManager will emit a this Signal when the pairing of a \l{Device} with the \a deviceId and \a pairingTransactionId is finished.
|
The DeviceManager will emit a this Signal when the pairing of a \l{Device} with the \a deviceId and \a pairingTransactionId is finished.
|
||||||
The \a status of the pairing will be described as \l{DeviceManager::DeviceError}{DeviceError}.
|
The \a status of the pairing will be described as \l{DeviceManager::DeviceError}{DeviceError}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::ruleRemoved(const RuleId &ruleId);
|
||||||
|
This signal is emitted when a \l{Rule} with the given \a ruleId was removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void GuhCore::ruleAdded(const Rule &rule);
|
||||||
|
This signal is emitted when a \a rule was added to the system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "jsonrpcserver.h"
|
#include "jsonrpcserver.h"
|
||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
@ -266,11 +292,15 @@ QList<Device *> GuhCore::findConfiguredDevices(const DeviceClassId &deviceClassI
|
|||||||
return m_deviceManager->findConfiguredDevices(deviceClassId);
|
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)
|
DeviceManager::DeviceError GuhCore::editDevice(const DeviceId &deviceId, const ParamList ¶ms)
|
||||||
{
|
{
|
||||||
return m_deviceManager->editDevice(deviceId, params);
|
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)
|
DeviceManager::DeviceError GuhCore::editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId)
|
||||||
{
|
{
|
||||||
return m_deviceManager->editDevice(deviceId, deviceDescriptorId);
|
return m_deviceManager->editDevice(deviceId, deviceDescriptorId);
|
||||||
|
|||||||
@ -145,8 +145,8 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
|||||||
setDescription("EditDevice", "Edit the parameters of a device. The device params will be set to the "
|
setDescription("EditDevice", "Edit the parameters of a device. The device params will be set to the "
|
||||||
"passed parameters and the setup device will be called. If the device is discoverable, "
|
"passed parameters and the setup device will be called. If the device is discoverable, "
|
||||||
"you can perform a GetDiscoveredDevices before calling this method and pass "
|
"you can perform a GetDiscoveredDevices before calling this method and pass "
|
||||||
"the new DeviceDescriptor (rediscover). If a parameter is not editable, you will find a "
|
"the new DeviceDescriptor (rediscover). If a parameter is not writable, you will find a "
|
||||||
"'editable': false in the ParamType. By default, every Param is editable.");
|
"'readOnly': true in the ParamType. By default, every Param is writable.");
|
||||||
params.insert("deviceId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
params.insert("deviceId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
params.insert("o:deviceDescriptorId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
params.insert("o:deviceDescriptorId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
QVariantList newDeviceParams;
|
QVariantList newDeviceParams;
|
||||||
|
|||||||
@ -94,7 +94,7 @@ void JsonTypes::init()
|
|||||||
s_paramType.insert("o:maxValue", basicTypeToString(Variant));
|
s_paramType.insert("o:maxValue", basicTypeToString(Variant));
|
||||||
s_paramType.insert("o:allowedValues", QVariantList() << basicTypeToString(Variant));
|
s_paramType.insert("o:allowedValues", QVariantList() << basicTypeToString(Variant));
|
||||||
s_paramType.insert("o:inputType", inputTypeRef());
|
s_paramType.insert("o:inputType", inputTypeRef());
|
||||||
s_paramType.insert("o:editable", basicTypeToString(Bool));
|
s_paramType.insert("o:readOnly", basicTypeToString(Bool));
|
||||||
|
|
||||||
// Param
|
// Param
|
||||||
s_param.insert("name", basicTypeToString(String));
|
s_param.insert("name", basicTypeToString(String));
|
||||||
@ -448,8 +448,8 @@ QVariantMap JsonTypes::packParamType(const ParamType ¶mType)
|
|||||||
variantMap.insert("inputType", s_inputType.at(paramType.inputType()));
|
variantMap.insert("inputType", s_inputType.at(paramType.inputType()));
|
||||||
}
|
}
|
||||||
// only add if this param is NOT ediable
|
// only add if this param is NOT ediable
|
||||||
if (!paramType.editable()) {
|
if (!paramType.readOnly()) {
|
||||||
variantMap.insert("editable", paramType.editable());
|
variantMap.insert("readOnly", paramType.readOnly());
|
||||||
}
|
}
|
||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Devices.EditDevice": {
|
"Devices.EditDevice": {
|
||||||
"description": "Edit the parameters of a device. The device params will be set to the passed parameters and the setup device will be called. If the device is discoverable, you can perform a GetDiscoveredDevices before calling this method and pass the new DeviceDescriptor (rediscover). If a parameter is not editable, you will find a 'editable': false in the ParamType. By default, every Param is editable.",
|
"description": "Edit the parameters of a device. The device params will be set to the passed parameters and the setup device will be called. If the device is discoverable, you can perform a GetDiscoveredDevices before calling this method and pass the new DeviceDescriptor (rediscover). If a parameter is not writable, you will find a 'readOnly': true in the ParamType. By default, every Param is writable.",
|
||||||
"params": {
|
"params": {
|
||||||
"deviceId": "Uuid",
|
"deviceId": "Uuid",
|
||||||
"o:deviceDescriptorId": "Uuid",
|
"o:deviceDescriptorId": "Uuid",
|
||||||
@ -519,7 +519,7 @@
|
|||||||
"DeviceErrorAsync",
|
"DeviceErrorAsync",
|
||||||
"DeviceErrorDeviceInUse",
|
"DeviceErrorDeviceInUse",
|
||||||
"DeviceErrorPairingTransactionIdNotFound",
|
"DeviceErrorPairingTransactionIdNotFound",
|
||||||
"DeviceErrorParameterNotEditable"
|
"DeviceErrorParameterNotWritable"
|
||||||
],
|
],
|
||||||
"Event": {
|
"Event": {
|
||||||
"deviceId": "Uuid",
|
"deviceId": "Uuid",
|
||||||
@ -599,10 +599,10 @@
|
|||||||
"Variant"
|
"Variant"
|
||||||
],
|
],
|
||||||
"o:defaultValue": "Variant",
|
"o:defaultValue": "Variant",
|
||||||
"o:editable": "Bool",
|
|
||||||
"o:inputType": "$ref:InputType",
|
"o:inputType": "$ref:InputType",
|
||||||
"o:maxValue": "Variant",
|
"o:maxValue": "Variant",
|
||||||
"o:minValue": "Variant",
|
"o:minValue": "Variant",
|
||||||
|
"o:readOnly": "Bool",
|
||||||
"type": "$ref:BasicType"
|
"type": "$ref:BasicType"
|
||||||
},
|
},
|
||||||
"Plugin": {
|
"Plugin": {
|
||||||
|
|||||||
@ -556,10 +556,10 @@ void TestDevices::editDevices_data()
|
|||||||
asyncAndPortChangeDeviceParams.append(httpportParamDifferent);
|
asyncAndPortChangeDeviceParams.append(httpportParamDifferent);
|
||||||
|
|
||||||
|
|
||||||
QVariantList changeAllEditableDeviceParams;
|
QVariantList changeAllWritableDeviceParams;
|
||||||
changeAllEditableDeviceParams.append(nameParam);
|
changeAllWritableDeviceParams.append(nameParam);
|
||||||
changeAllEditableDeviceParams.append(asyncParamDifferent);
|
changeAllWritableDeviceParams.append(asyncParamDifferent);
|
||||||
changeAllEditableDeviceParams.append(httpportParamDifferent);
|
changeAllWritableDeviceParams.append(httpportParamDifferent);
|
||||||
|
|
||||||
|
|
||||||
QTest::addColumn<bool>("broken");
|
QTest::addColumn<bool>("broken");
|
||||||
@ -569,8 +569,8 @@ void TestDevices::editDevices_data()
|
|||||||
QTest::newRow("valid - change async param") << false << asyncChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
QTest::newRow("valid - change async param") << false << asyncChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||||
QTest::newRow("valid - change httpport param") << false << httpportChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
QTest::newRow("valid - change httpport param") << false << httpportChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||||
QTest::newRow("valid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
QTest::newRow("valid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||||
QTest::newRow("invalid - change name param (not editable)") << false << nameChangedDeviceParams << DeviceManager::DeviceErrorParameterNotEditable;
|
QTest::newRow("invalid - change name param (not writable)") << false << nameChangedDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||||
QTest::newRow("invalid - change all params (except broken)") << false << changeAllEditableDeviceParams << DeviceManager::DeviceErrorParameterNotEditable;
|
QTest::newRow("invalid - change all params (except broken)") << false << changeAllWritableDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDevices::editDevices()
|
void TestDevices::editDevices()
|
||||||
|
|||||||
Reference in New Issue
Block a user