complete source code documentation
This commit is contained in:
parent
c95e6ebeb0
commit
92a5060de6
@ -34,31 +34,20 @@
|
|||||||
Represents the known CoAP options according to \l{https://tools.ietf.org/html/rfc7252#section-3.1}{RFC7252}.
|
Represents the known CoAP options according to \l{https://tools.ietf.org/html/rfc7252#section-3.1}{RFC7252}.
|
||||||
|
|
||||||
\value IfMatch
|
\value IfMatch
|
||||||
|
|
||||||
\value UriHost
|
\value UriHost
|
||||||
|
|
||||||
\value ETag
|
\value ETag
|
||||||
|
|
||||||
\value IfNoneMatch
|
\value IfNoneMatch
|
||||||
|
|
||||||
\value Observe
|
\value Observe
|
||||||
\l{https://tools.ietf.org/html/rfc7641}
|
\l{https://tools.ietf.org/html/rfc7641}
|
||||||
|
|
||||||
\value UriPort
|
\value UriPort
|
||||||
|
|
||||||
\value LocationPath
|
\value LocationPath
|
||||||
|
|
||||||
\value UriPath
|
\value UriPath
|
||||||
|
|
||||||
\value ContentFormat
|
\value ContentFormat
|
||||||
|
|
||||||
\value MaxAge
|
\value MaxAge
|
||||||
|
|
||||||
\value UriQuery
|
\value UriQuery
|
||||||
|
|
||||||
\value Accept
|
\value Accept
|
||||||
|
|
||||||
\value LocationQuery
|
\value LocationQuery
|
||||||
|
|
||||||
\value Block2
|
\value Block2
|
||||||
\l{https://tools.ietf.org/html/draft-ietf-core-block-18}
|
\l{https://tools.ietf.org/html/draft-ietf-core-block-18}
|
||||||
|
|
||||||
@ -66,24 +55,33 @@
|
|||||||
\l{https://tools.ietf.org/html/draft-ietf-core-block-18}
|
\l{https://tools.ietf.org/html/draft-ietf-core-block-18}
|
||||||
|
|
||||||
\value ProxyUri
|
\value ProxyUri
|
||||||
|
|
||||||
\value ProxyScheme
|
\value ProxyScheme
|
||||||
|
|
||||||
\value Size1
|
\value Size1
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn CoapOption::CoapOption();
|
||||||
|
Constructs a \l{CoapOption}.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn CoapOption::CoapOption(const Option &option, const QByteArray &data);
|
||||||
|
Constructs a \l{CoapOption} with the given \a option and option \a data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void CoapOption::setOption(const Option &option);
|
||||||
|
Sets the \l{CoapOption::Option} of this CoapOption to the given \a option.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "coapoption.h"
|
#include "coapoption.h"
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
/*! Constructs a CoapOption. */
|
|
||||||
CoapOption::CoapOption()
|
CoapOption::CoapOption()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Constructs a CoapOption with the given \a option and option \a data. */
|
|
||||||
CoapOption::CoapOption(const CoapOption::Option &option, const QByteArray &data) :
|
CoapOption::CoapOption(const CoapOption::Option &option, const QByteArray &data) :
|
||||||
m_option(option),
|
m_option(option),
|
||||||
m_data(data)
|
m_data(data)
|
||||||
@ -91,7 +89,6 @@ CoapOption::CoapOption(const CoapOption::Option &option, const QByteArray &data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Sets the \l{CoapOption::Option} of this CoapOption to the given \a option. */
|
|
||||||
void CoapOption::setOption(const CoapOption::Option &option)
|
void CoapOption::setOption(const CoapOption::Option &option)
|
||||||
{
|
{
|
||||||
m_option = option;
|
m_option = option;
|
||||||
|
|||||||
@ -123,9 +123,31 @@
|
|||||||
\value InvalidOptionDeltaError
|
\value InvalidOptionDeltaError
|
||||||
\value InvalidOptionLengthError
|
\value InvalidOptionLengthError
|
||||||
\value UnknownOptionError
|
\value UnknownOptionError
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! \fn void CoapPdu::getStatusCodeString(const StatusCode &statusCode);
|
||||||
|
Returns the human readable status code for the given \a statusCode.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void CoapPdu::setContentType(const ContentType &contentType);
|
||||||
|
Sets the content type of this \l{CoapPdu} to the given \a contentType.
|
||||||
|
|
||||||
|
\sa CoapPdu::ContentType
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void CoapPdu::setMessageType(const MessageType &messageType);
|
||||||
|
Sets the message type of this \l{CoapPdu} to the given \a messageType.
|
||||||
|
|
||||||
|
\sa CoapPdu::MessageType
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void CoapPdu::setStatusCode(const StatusCode &statusCode);
|
||||||
|
Sets the message type of this \l{CoapPdu} to the given \a statusCode.
|
||||||
|
|
||||||
|
\sa CoapPdu::StatusCode
|
||||||
|
*/
|
||||||
|
|
||||||
#include "coappdu.h"
|
#include "coappdu.h"
|
||||||
#include "coapoption.h"
|
#include "coapoption.h"
|
||||||
|
|
||||||
|
|||||||
@ -99,6 +99,10 @@
|
|||||||
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 DeviceErrorDeviceIsChild
|
||||||
|
The device is a child device and can not be deleted directly.
|
||||||
|
\value DeviceErrorDeviceInRule
|
||||||
|
The device is in a rule and can not be deleted withou \l{guhserver::RuleEngine::RemovePolicy}.
|
||||||
\value DeviceErrorParameterNotWritable
|
\value DeviceErrorParameterNotWritable
|
||||||
One of the given device params is not writable.
|
One of the given device params is not writable.
|
||||||
*/
|
*/
|
||||||
@ -368,7 +372,7 @@ DeviceManager::DeviceError DeviceManager::discoverDevices(const DeviceClassId &d
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Add a new configured device for the given \l{DeviceClass}, the given parameters and \a id.
|
/*! Add a new configured device for the given \l{DeviceClass}, the given parameters, \a name and \a id.
|
||||||
* \a deviceClassId must refer to an existing \{DeviceClass} and \a params must match the parameter description in the \l{DeviceClass}.
|
* \a deviceClassId must refer to an existing \{DeviceClass} and \a params must match the parameter description in the \l{DeviceClass}.
|
||||||
* 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.
|
||||||
@ -387,7 +391,7 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
|
|||||||
|
|
||||||
/*! Add a new configured device for the given \l{DeviceClass} the given DeviceDescriptorId and \a deviceId. Only devices with \l{DeviceClass}{CreateMethodDiscovery}
|
/*! Add a new configured device for the given \l{DeviceClass} the given DeviceDescriptorId and \a deviceId. Only devices with \l{DeviceClass}{CreateMethodDiscovery}
|
||||||
* 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. The \a name parameter should contain the device name.
|
||||||
* Returns \l{DeviceError} to inform about the result. */
|
* Returns \l{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &deviceId)
|
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &deviceId)
|
||||||
{
|
{
|
||||||
@ -512,6 +516,9 @@ DeviceManager::DeviceError DeviceManager::reconfigureDevice(const DeviceId &devi
|
|||||||
return reconfigureDevice(deviceId, descriptor.params(), true);
|
return reconfigureDevice(deviceId, descriptor.params(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Edit the \a name of the \l{Device} with the given \a deviceId.
|
||||||
|
Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result.
|
||||||
|
*/
|
||||||
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const QString &name)
|
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const QString &name)
|
||||||
{
|
{
|
||||||
Device *device = findConfiguredDevice(deviceId);
|
Device *device = findConfiguredDevice(deviceId);
|
||||||
@ -525,7 +532,7 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
|||||||
return DeviceErrorNoError;
|
return DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId and \a params.
|
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId, \a name and \a params.
|
||||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms)
|
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms)
|
||||||
{
|
{
|
||||||
@ -556,7 +563,7 @@ DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId
|
|||||||
return DeviceErrorNoError;
|
return DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId and \a deviceDescriptorId.
|
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId, \a name and \a deviceDescriptorId.
|
||||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
||||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId)
|
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId)
|
||||||
{
|
{
|
||||||
@ -787,6 +794,8 @@ DeviceClass DeviceManager::findDeviceClass(const DeviceClassId &deviceClassId) c
|
|||||||
return DeviceClass();
|
return DeviceClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verify if the given \a params matche the given \a paramTypes. Ith \a requireAll
|
||||||
|
* is true, all \l{ParamList}{Params} has to be valid. Returns \l{DeviceError} to inform about the result.*/
|
||||||
DeviceManager::DeviceError DeviceManager::verifyParams(const QList<ParamType> paramTypes, ParamList ¶ms, bool requireAll)
|
DeviceManager::DeviceError DeviceManager::verifyParams(const QList<ParamType> paramTypes, ParamList ¶ms, bool requireAll)
|
||||||
{
|
{
|
||||||
foreach (const Param ¶m, params) {
|
foreach (const Param ¶m, params) {
|
||||||
@ -820,6 +829,7 @@ DeviceManager::DeviceError DeviceManager::verifyParams(const QList<ParamType> pa
|
|||||||
return DeviceErrorNoError;
|
return DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verify if the given \a param matches one of the given \a paramTypes. Returns \l{DeviceError} to inform about the result.*/
|
||||||
DeviceManager::DeviceError DeviceManager::verifyParam(const QList<ParamType> paramTypes, const Param ¶m)
|
DeviceManager::DeviceError DeviceManager::verifyParam(const QList<ParamType> paramTypes, const Param ¶m)
|
||||||
{
|
{
|
||||||
foreach (const ParamType ¶mType, paramTypes) {
|
foreach (const ParamType ¶mType, paramTypes) {
|
||||||
@ -831,6 +841,7 @@ DeviceManager::DeviceError DeviceManager::verifyParam(const QList<ParamType> par
|
|||||||
return DeviceErrorInvalidParameter;
|
return DeviceErrorInvalidParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verify if the given \a param matches the given \a paramType. Returns \l{DeviceError} to inform about the result.*/
|
||||||
DeviceManager::DeviceError DeviceManager::verifyParam(const ParamType ¶mType, const Param ¶m)
|
DeviceManager::DeviceError DeviceManager::verifyParam(const ParamType ¶mType, const Param ¶m)
|
||||||
{
|
{
|
||||||
if (paramType.name() == param.name()) {
|
if (paramType.name() == param.name()) {
|
||||||
|
|||||||
@ -169,6 +169,7 @@ QString GuhSettings::logPath()
|
|||||||
return logPath;
|
return logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the path to the folder where the GuhSettings will be saved. */
|
||||||
QString GuhSettings::settingsPath()
|
QString GuhSettings::settingsPath()
|
||||||
{
|
{
|
||||||
QString path;
|
QString path;
|
||||||
|
|||||||
@ -95,6 +95,7 @@ UpnpDiscovery::UpnpDiscovery(QObject *parent) :
|
|||||||
sendAliveMessage();
|
sendAliveMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Destruct this \l{UpnpDiscovery} object. */
|
||||||
UpnpDiscovery::~UpnpDiscovery()
|
UpnpDiscovery::~UpnpDiscovery()
|
||||||
{
|
{
|
||||||
qCDebug(dcApplication) << "Shutting down \"UPnP Server\"";
|
qCDebug(dcApplication) << "Shutting down \"UPnP Server\"";
|
||||||
|
|||||||
@ -153,7 +153,7 @@ bool Device::hasParam(const QString ¶mName) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceId m_id;
|
/*! Set the \l{State}{States} of this \l{Device} to the given \a states.*/
|
||||||
void Device::setStates(const QList<State> &states)
|
void Device::setStates(const QList<State> &states)
|
||||||
{
|
{
|
||||||
m_states = states;
|
m_states = states;
|
||||||
|
|||||||
@ -112,6 +112,7 @@
|
|||||||
he can bring it's own icon for a special DeviceClassId. If there is no special icon
|
he can bring it's own icon for a special DeviceClassId. If there is no special icon
|
||||||
defined, he can fallback to the default icon.
|
defined, he can fallback to the default icon.
|
||||||
|
|
||||||
|
\value DeviceIconNone
|
||||||
\value DeviceIconBed
|
\value DeviceIconBed
|
||||||
\value DeviceIconBlinds
|
\value DeviceIconBlinds
|
||||||
\value DeviceIconCeilingLamp
|
\value DeviceIconCeilingLamp
|
||||||
@ -147,6 +148,13 @@
|
|||||||
\value DeviceIconCloud
|
\value DeviceIconCloud
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void DeviceClass::setBasicTags(const QList<BasicTag> &basicTags);
|
||||||
|
Set the list of \a basicTags of this DeviceClass.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void DeviceClass::setDeviceIcon(const DeviceIcon &deviceIcon);
|
||||||
|
Set the \a deviceIcon of this DeviceClass.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "deviceclass.h"
|
#include "deviceclass.h"
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,21 @@
|
|||||||
* *
|
* *
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class guhserver::GuhApplication
|
||||||
|
\brief Application class of the guh server.
|
||||||
|
|
||||||
|
\ingroup core
|
||||||
|
\inmodule server
|
||||||
|
|
||||||
|
The \l{GuhApplication} is a subclass of the \{http://doc.qt.io/qt-5/qcoreapplication.html}{QCoreApplication}
|
||||||
|
and is responsable to catch system signals like SIGQUIT, SIGINT, SIGTERM, SIGHUP, SIGSEGV. This class
|
||||||
|
will provide a backtrace on a segmentation fault (SIGSEGV).
|
||||||
|
|
||||||
|
|
||||||
|
\sa GuhService
|
||||||
|
*/
|
||||||
|
|
||||||
#include "guhapplication.h"
|
#include "guhapplication.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
@ -150,6 +165,7 @@ static void catchUnixSignals(const std::vector<int>& quitSignals, const std::vec
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructs a GuhApplication with the given argument count \a argc and argument vector \a argv. */
|
||||||
GuhApplication::GuhApplication(int &argc, char **argv) :
|
GuhApplication::GuhApplication(int &argc, char **argv) :
|
||||||
QCoreApplication(argc, argv)
|
QCoreApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
/*! \fn void guhserver::GuhCore::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors);
|
/*! \fn void guhserver::GuhCore::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors);
|
||||||
This signal is emitted when the discovery of a \a deviceClassId is finished. The \a deviceDescriptors parameter describes the
|
This signal is emitted when the discovery of a \a deviceClassId is finished. The \a deviceDescriptors parameter describes the
|
||||||
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
|
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
|
||||||
\sa discoverDevices()
|
\sa DeviceManager::discoverDevices()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \fn void guhserver::GuhCore::deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
/*! \fn void guhserver::GuhCore::deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
||||||
@ -222,6 +222,8 @@ QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevic
|
|||||||
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorNoError, QList<RuleId>());
|
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorNoError, QList<RuleId>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicy. */
|
||||||
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
|
||||||
@ -303,6 +305,7 @@ DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Execute the given \a ruleActions. */
|
||||||
void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
||||||
{
|
{
|
||||||
foreach (const RuleAction &ruleAction, ruleActions) {
|
foreach (const RuleAction &ruleAction, ruleActions) {
|
||||||
|
|||||||
@ -111,10 +111,24 @@
|
|||||||
This signal is emitted when this async \l{HttpReply} is finished.
|
This signal is emitted when this async \l{HttpReply} is finished.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn guhserver::HttpReply::HttpReply(QObject *parent);
|
||||||
|
Construct an empty \l{HttpReply} with the given \a parent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn guhserver::HttpReply::HttpReply(const HttpStatusCode &statusCode, const Type &type, QObject *parent);
|
||||||
|
Construct a \l{HttpReply} with the given \a statusCode, \a type and \a parent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::HttpReply::setHttpStatusCode(const HttpStatusCode &statusCode);
|
||||||
|
Set the \l{HttpStatusCode} of this \l{HttpReply} to the given \a statusCode.
|
||||||
|
*/
|
||||||
|
|
||||||
/*! \fn QDebug guhserver::operator<< (QDebug debug, const HttpReply &httpReply);
|
/*! \fn QDebug guhserver::operator<< (QDebug debug, const HttpReply &httpReply);
|
||||||
Writes the given \l{HttpReply} \a httpReply to the given \a debug. This method gets used just for debugging.
|
Writes the given \l{HttpReply} \a httpReply to the given \a debug. This method gets used just for debugging.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "httpreply.h"
|
#include "httpreply.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -123,7 +137,6 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
/*! Construct an empty \l{HttpReply} with the given \a parent. */
|
|
||||||
HttpReply::HttpReply(QObject *parent) :
|
HttpReply::HttpReply(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_statusCode(HttpReply::Ok),
|
m_statusCode(HttpReply::Ok),
|
||||||
@ -148,7 +161,6 @@ HttpReply::HttpReply(QObject *parent) :
|
|||||||
packReply();
|
packReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Construct a \l{HttpReply} with the given \a statusCode, \a type and \a parent. */
|
|
||||||
HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpReply::Type &type, QObject *parent):
|
HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpReply::Type &type, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_statusCode(statusCode),
|
m_statusCode(statusCode),
|
||||||
@ -172,9 +184,6 @@ HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpRepl
|
|||||||
packReply();
|
packReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set the \l{HttpStatusCode} of this \l{HttpReply} to the given \a statusCode.
|
|
||||||
\sa httpStatusCode()
|
|
||||||
*/
|
|
||||||
void HttpReply::setHttpStatusCode(const HttpReply::HttpStatusCode &statusCode)
|
void HttpReply::setHttpStatusCode(const HttpReply::HttpStatusCode &statusCode)
|
||||||
{
|
{
|
||||||
m_statusCode = statusCode;
|
m_statusCode = statusCode;
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l ActionHandler with the given \a parent. */
|
||||||
ActionHandler::ActionHandler(QObject *parent) :
|
ActionHandler::ActionHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -66,6 +67,7 @@ ActionHandler::ActionHandler(QObject *parent) :
|
|||||||
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &ActionHandler::actionExecuted);
|
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &ActionHandler::actionExecuted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{ActionHandler}. In this case \b Actions.*/
|
||||||
QString ActionHandler::name() const
|
QString ActionHandler::name() const
|
||||||
{
|
{
|
||||||
return "Actions";
|
return "Actions";
|
||||||
|
|||||||
@ -33,6 +33,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! \fn void guhserver::DeviceHandler::StateChanged(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{State} has changed.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::DeviceHandler::DeviceRemoved(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Device} has been removed.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::DeviceHandler::DeviceAdded(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Device} has been added.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::DeviceHandler::DeviceChanged(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Device} has been changed or reconfigured.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "devicehandler.h"
|
#include "devicehandler.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
@ -45,6 +65,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l DeviceHandler with the given \a parent. */
|
||||||
DeviceHandler::DeviceHandler(QObject *parent) :
|
DeviceHandler::DeviceHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -280,6 +301,7 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
|||||||
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished);
|
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{DeviceHandler}. In this case \b Devices.*/
|
||||||
QString DeviceHandler::name() const
|
QString DeviceHandler::name() const
|
||||||
{
|
{
|
||||||
return "Devices";
|
return "Devices";
|
||||||
|
|||||||
@ -32,12 +32,18 @@
|
|||||||
\sa Event, JsonHandler, JsonRPCServer
|
\sa Event, JsonHandler, JsonRPCServer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::EventHandler::EventTriggered(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when an \l{Event} triggered.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "eventhandler.h"
|
#include "eventhandler.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l EventHandler with the given \a parent. */
|
||||||
EventHandler::EventHandler(QObject *parent) :
|
EventHandler::EventHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -61,6 +67,7 @@ EventHandler::EventHandler(QObject *parent) :
|
|||||||
connect(GuhCore::instance(), &GuhCore::eventTriggered, this, &EventHandler::eventTriggered);
|
connect(GuhCore::instance(), &GuhCore::eventTriggered, this, &EventHandler::eventTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{EventHandler}. In this case \b Events.*/
|
||||||
QString EventHandler::name() const
|
QString EventHandler::name() const
|
||||||
{
|
{
|
||||||
return "Events";
|
return "Events";
|
||||||
|
|||||||
@ -29,6 +29,15 @@
|
|||||||
\sa JsonRPCServer, JsonReply
|
\sa JsonRPCServer, JsonReply
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn QString guhserver::JsonHandler::name() const;
|
||||||
|
Pure virtual method for a JSON RPC handler. Returns the namespace of the handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::JsonHandler::asyncReply(int id, const QVariantMap ¶ms);
|
||||||
|
This signal will be emitted when a reply with the given \a id and \a params is finished.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
@ -94,18 +103,24 @@ bool JsonHandler::hasMethod(const QString &methodName)
|
|||||||
return m_descriptions.contains(methodName) && m_params.contains(methodName) && m_returns.contains(methodName);
|
return m_descriptions.contains(methodName) && m_params.contains(methodName) && m_returns.contains(methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Validates the given \a params for the given \a methodName. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonHandler::validateParams(const QString &methodName, const QVariantMap ¶ms)
|
QPair<bool, QString> JsonHandler::validateParams(const QString &methodName, const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
QVariantMap paramTemplate = m_params.value(methodName);
|
QVariantMap paramTemplate = m_params.value(methodName);
|
||||||
return JsonTypes::validateMap(paramTemplate, params);
|
return JsonTypes::validateMap(paramTemplate, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Validates the given \a returns for the given \a methodName. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonHandler::validateReturns(const QString &methodName, const QVariantMap &returns)
|
QPair<bool, QString> JsonHandler::validateReturns(const QString &methodName, const QVariantMap &returns)
|
||||||
{
|
{
|
||||||
QVariantMap returnsTemplate = m_returns.value(methodName);
|
QVariantMap returnsTemplate = m_returns.value(methodName);
|
||||||
return JsonTypes::validateMap(returnsTemplate, returns);
|
return JsonTypes::validateMap(returnsTemplate, returns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Sets the \a description of the method with the given \a methodName. */
|
||||||
void JsonHandler::setDescription(const QString &methodName, const QString &description)
|
void JsonHandler::setDescription(const QString &methodName, const QString &description)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
||||||
@ -118,6 +133,7 @@ void JsonHandler::setDescription(const QString &methodName, const QString &descr
|
|||||||
qCWarning(dcJsonRpc) << "Cannot set description. No such method:" << methodName;
|
qCWarning(dcJsonRpc) << "Cannot set description. No such method:" << methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a params of the method with the given \a methodName. */
|
||||||
void JsonHandler::setParams(const QString &methodName, const QVariantMap ¶ms)
|
void JsonHandler::setParams(const QString &methodName, const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
||||||
@ -130,6 +146,7 @@ void JsonHandler::setParams(const QString &methodName, const QVariantMap ¶ms
|
|||||||
qCWarning(dcJsonRpc) << "Cannot set params. No such method:" << methodName;
|
qCWarning(dcJsonRpc) << "Cannot set params. No such method:" << methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a returns of the method with the given \a methodName. */
|
||||||
void JsonHandler::setReturns(const QString &methodName, const QVariantMap &returns)
|
void JsonHandler::setReturns(const QString &methodName, const QVariantMap &returns)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
for(int i = 0; i < metaObject()->methodCount(); ++i) {
|
||||||
@ -142,16 +159,22 @@ void JsonHandler::setReturns(const QString &methodName, const QVariantMap &retur
|
|||||||
qCWarning(dcJsonRpc) << "Cannot set returns. No such method:" << methodName;
|
qCWarning(dcJsonRpc) << "Cannot set returns. No such method:" << methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the pointer to a new \l{JsonReply} with the given \a data. */
|
||||||
JsonReply *JsonHandler::createReply(const QVariantMap &data) const
|
JsonReply *JsonHandler::createReply(const QVariantMap &data) const
|
||||||
{
|
{
|
||||||
return JsonReply::createReply(const_cast<JsonHandler*>(this), data);
|
return JsonReply::createReply(const_cast<JsonHandler*>(this), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the pointer to an asynchronous new \l{JsonReply} with the given \a method. */
|
||||||
JsonReply* JsonHandler::createAsyncReply(const QString &method) const
|
JsonReply* JsonHandler::createAsyncReply(const QString &method) const
|
||||||
{
|
{
|
||||||
return JsonReply::createAsyncReply(const_cast<JsonHandler*>(this), method);
|
return JsonReply::createAsyncReply(const_cast<JsonHandler*>(this), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the formated error map for the given \a status.
|
||||||
|
*
|
||||||
|
* \sa DeviceManager::DeviceError
|
||||||
|
*/
|
||||||
QVariantMap JsonHandler::statusToReply(DeviceManager::DeviceError status) const
|
QVariantMap JsonHandler::statusToReply(DeviceManager::DeviceError status) const
|
||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
@ -159,6 +182,10 @@ QVariantMap JsonHandler::statusToReply(DeviceManager::DeviceError status) const
|
|||||||
return returns;
|
return returns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the formated error map for the given \a status.
|
||||||
|
*
|
||||||
|
* \sa RuleEngine::RuleError
|
||||||
|
*/
|
||||||
QVariantMap JsonHandler::statusToReply(RuleEngine::RuleError status) const
|
QVariantMap JsonHandler::statusToReply(RuleEngine::RuleError status) const
|
||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
@ -166,6 +193,10 @@ QVariantMap JsonHandler::statusToReply(RuleEngine::RuleError status) const
|
|||||||
return returns;
|
return returns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the formated error map for the given \a status.
|
||||||
|
*
|
||||||
|
* \sa Logging::LoggingError
|
||||||
|
*/
|
||||||
QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const
|
QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const
|
||||||
{
|
{
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
@ -184,8 +215,24 @@ QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const
|
|||||||
\sa JsonHandler, JsonRPCServer
|
\sa JsonHandler, JsonRPCServer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \enum guhserver::JsonReply::Type
|
||||||
|
|
||||||
|
This enum type specifies the type of a JsonReply.
|
||||||
|
|
||||||
|
\value TypeSync
|
||||||
|
The response is synchronous.
|
||||||
|
\value TypeAsync
|
||||||
|
The response is asynchronous.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::JsonReply::finished();
|
||||||
|
This signal will be emitted when a JsonReply is finished. A JsonReply is finished when
|
||||||
|
the response is ready or then the reply timed out.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructs a new \l JsonReply with the given \a type, \a handler, \a method and \a data. */
|
||||||
JsonReply::JsonReply(Type type, JsonHandler *handler, const QString &method, const QVariantMap &data):
|
JsonReply::JsonReply(Type type, JsonHandler *handler, const QString &method, const QVariantMap &data):
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_data(data),
|
m_data(data),
|
||||||
@ -196,61 +243,73 @@ JsonReply::JsonReply(Type type, JsonHandler *handler, const QString &method, con
|
|||||||
connect(&m_timeout, &QTimer::timeout, this, &JsonReply::timeout);
|
connect(&m_timeout, &QTimer::timeout, this, &JsonReply::timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the pointer to a new \l{JsonReply} for the given \a handler and \a data. */
|
||||||
JsonReply *JsonReply::createReply(JsonHandler *handler, const QVariantMap &data)
|
JsonReply *JsonReply::createReply(JsonHandler *handler, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
return new JsonReply(TypeSync, handler, QString(), data);
|
return new JsonReply(TypeSync, handler, QString(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the pointer to a new asynchronous \l{JsonReply} for the given \a handler and \a method. */
|
||||||
JsonReply *JsonReply::createAsyncReply(JsonHandler *handler, const QString &method)
|
JsonReply *JsonReply::createAsyncReply(JsonHandler *handler, const QString &method)
|
||||||
{
|
{
|
||||||
return new JsonReply(TypeAsync, handler, method);
|
return new JsonReply(TypeAsync, handler, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the type of this \l{JsonReply}.*/
|
||||||
JsonReply::Type JsonReply::type() const
|
JsonReply::Type JsonReply::type() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the data of this \l{JsonReply}.*/
|
||||||
QVariantMap JsonReply::data() const
|
QVariantMap JsonReply::data() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a data of this \l{JsonReply}.*/
|
||||||
void JsonReply::setData(const QVariantMap &data)
|
void JsonReply::setData(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the handler of this \l{JsonReply}.*/
|
||||||
JsonHandler *JsonReply::handler() const
|
JsonHandler *JsonReply::handler() const
|
||||||
{
|
{
|
||||||
return m_handler;
|
return m_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the method of this \l{JsonReply}.*/
|
||||||
QString JsonReply::method() const
|
QString JsonReply::method() const
|
||||||
{
|
{
|
||||||
return m_method;
|
return m_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the client ID of this \l{JsonReply}.*/
|
||||||
QUuid JsonReply::clientId() const
|
QUuid JsonReply::clientId() const
|
||||||
{
|
{
|
||||||
return m_clientId;
|
return m_clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a clientId of this \l{JsonReply}.*/
|
||||||
void JsonReply::setClientId(const QUuid &clientId)
|
void JsonReply::setClientId(const QUuid &clientId)
|
||||||
{
|
{
|
||||||
m_clientId = clientId;
|
m_clientId = clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the command ID of this \l{JsonReply}.*/
|
||||||
int JsonReply::commandId() const
|
int JsonReply::commandId() const
|
||||||
{
|
{
|
||||||
return m_commandId;
|
return m_commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the \a commandId of this \l{JsonReply}.*/
|
||||||
void JsonReply::setCommandId(int commandId)
|
void JsonReply::setCommandId(int commandId)
|
||||||
{
|
{
|
||||||
m_commandId = commandId;
|
m_commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Start the timeout timer for this \l{JsonReply}. The default timeout is 10 seconds. */
|
||||||
void JsonReply::startWait()
|
void JsonReply::startWait()
|
||||||
{
|
{
|
||||||
m_timeout.start(10000);
|
m_timeout.start(10000);
|
||||||
@ -262,6 +321,7 @@ void JsonReply::timeout()
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns true if this \l{JsonReply} timed out.*/
|
||||||
bool JsonReply::timedOut() const
|
bool JsonReply::timedOut() const
|
||||||
{
|
{
|
||||||
return m_timedOut;
|
return m_timedOut;
|
||||||
|
|||||||
@ -19,6 +19,33 @@
|
|||||||
* *
|
* *
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class guhserver::JsonTypes
|
||||||
|
\brief This class represents the types for the JSON-RPC API.
|
||||||
|
|
||||||
|
\ingroup json
|
||||||
|
\inmodule core
|
||||||
|
|
||||||
|
This class represents all JSON-RPC API types and allowes to transform Json
|
||||||
|
objects into c++ objects and vers visa.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \enum guhserver::JsonTypes::BasicType
|
||||||
|
|
||||||
|
This enum type specifies the basic types of a JSON RPC API.
|
||||||
|
|
||||||
|
\value Uuid
|
||||||
|
\value String
|
||||||
|
\value Int
|
||||||
|
\value Uint
|
||||||
|
\value Double
|
||||||
|
\value Bool
|
||||||
|
\value Variant
|
||||||
|
\value Color
|
||||||
|
\value Object
|
||||||
|
*/
|
||||||
|
|
||||||
#include "jsontypes.h"
|
#include "jsontypes.h"
|
||||||
|
|
||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
@ -270,6 +297,7 @@ QVariantList JsonTypes::enumToStrings(const QMetaObject &metaObject, const QStri
|
|||||||
return enumStrings;
|
return enumStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a map containing all API types. */
|
||||||
QVariantMap JsonTypes::allTypes()
|
QVariantMap JsonTypes::allTypes()
|
||||||
{
|
{
|
||||||
QVariantMap allTypes;
|
QVariantMap allTypes;
|
||||||
@ -315,6 +343,7 @@ QVariantMap JsonTypes::allTypes()
|
|||||||
return allTypes;
|
return allTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a eventType. */
|
||||||
QVariantMap JsonTypes::packEventType(const EventType &eventType)
|
QVariantMap JsonTypes::packEventType(const EventType &eventType)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -328,6 +357,7 @@ QVariantMap JsonTypes::packEventType(const EventType &eventType)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a event. */
|
||||||
QVariantMap JsonTypes::packEvent(const Event &event)
|
QVariantMap JsonTypes::packEvent(const Event &event)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -341,6 +371,7 @@ QVariantMap JsonTypes::packEvent(const Event &event)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a eventDescriptor. */
|
||||||
QVariantMap JsonTypes::packEventDescriptor(const EventDescriptor &eventDescriptor)
|
QVariantMap JsonTypes::packEventDescriptor(const EventDescriptor &eventDescriptor)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -354,6 +385,7 @@ QVariantMap JsonTypes::packEventDescriptor(const EventDescriptor &eventDescripto
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a actionType. */
|
||||||
QVariantMap JsonTypes::packActionType(const ActionType &actionType)
|
QVariantMap JsonTypes::packActionType(const ActionType &actionType)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -367,6 +399,7 @@ QVariantMap JsonTypes::packActionType(const ActionType &actionType)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a action. */
|
||||||
QVariantMap JsonTypes::packAction(const Action &action)
|
QVariantMap JsonTypes::packAction(const Action &action)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -380,6 +413,7 @@ QVariantMap JsonTypes::packAction(const Action &action)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a ruleAction. */
|
||||||
QVariantMap JsonTypes::packRuleAction(const RuleAction &ruleAction)
|
QVariantMap JsonTypes::packRuleAction(const RuleAction &ruleAction)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -393,6 +427,7 @@ QVariantMap JsonTypes::packRuleAction(const RuleAction &ruleAction)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a ruleActionParam. */
|
||||||
QVariantMap JsonTypes::packRuleActionParam(const RuleActionParam &ruleActionParam)
|
QVariantMap JsonTypes::packRuleActionParam(const RuleActionParam &ruleActionParam)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -407,6 +442,7 @@ QVariantMap JsonTypes::packRuleActionParam(const RuleActionParam &ruleActionPara
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a state. */
|
||||||
QVariantMap JsonTypes::packState(const State &state)
|
QVariantMap JsonTypes::packState(const State &state)
|
||||||
{
|
{
|
||||||
QVariantMap stateMap;
|
QVariantMap stateMap;
|
||||||
@ -415,6 +451,7 @@ QVariantMap JsonTypes::packState(const State &state)
|
|||||||
return stateMap;
|
return stateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a stateType. */
|
||||||
QVariantMap JsonTypes::packStateType(const StateType &stateType)
|
QVariantMap JsonTypes::packStateType(const StateType &stateType)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -438,6 +475,7 @@ QVariantMap JsonTypes::packStateType(const StateType &stateType)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a stateDescriptor. */
|
||||||
QVariantMap JsonTypes::packStateDescriptor(const StateDescriptor &stateDescriptor)
|
QVariantMap JsonTypes::packStateDescriptor(const StateDescriptor &stateDescriptor)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -448,6 +486,7 @@ QVariantMap JsonTypes::packStateDescriptor(const StateDescriptor &stateDescripto
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a stateEvaluator. */
|
||||||
QVariantMap JsonTypes::packStateEvaluator(const StateEvaluator &stateEvaluator)
|
QVariantMap JsonTypes::packStateEvaluator(const StateEvaluator &stateEvaluator)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -467,6 +506,7 @@ QVariantMap JsonTypes::packStateEvaluator(const StateEvaluator &stateEvaluator)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a param. */
|
||||||
QVariantMap JsonTypes::packParam(const Param ¶m)
|
QVariantMap JsonTypes::packParam(const Param ¶m)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -475,6 +515,7 @@ QVariantMap JsonTypes::packParam(const Param ¶m)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a paramDescriptor. */
|
||||||
QVariantMap JsonTypes::packParamDescriptor(const ParamDescriptor ¶mDescriptor)
|
QVariantMap JsonTypes::packParamDescriptor(const ParamDescriptor ¶mDescriptor)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -484,6 +525,7 @@ QVariantMap JsonTypes::packParamDescriptor(const ParamDescriptor ¶mDescripto
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a paramType. */
|
||||||
QVariantMap JsonTypes::packParamType(const ParamType ¶mType)
|
QVariantMap JsonTypes::packParamType(const ParamType ¶mType)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -515,6 +557,7 @@ QVariantMap JsonTypes::packParamType(const ParamType ¶mType)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a vendor. */
|
||||||
QVariantMap JsonTypes::packVendor(const Vendor &vendor)
|
QVariantMap JsonTypes::packVendor(const Vendor &vendor)
|
||||||
{
|
{
|
||||||
QVariantMap variantMap;
|
QVariantMap variantMap;
|
||||||
@ -523,6 +566,7 @@ QVariantMap JsonTypes::packVendor(const Vendor &vendor)
|
|||||||
return variantMap;
|
return variantMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a deviceClass. */
|
||||||
QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
|
QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -568,6 +612,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a plugin. */
|
||||||
QVariantMap JsonTypes::packPlugin(DevicePlugin *plugin)
|
QVariantMap JsonTypes::packPlugin(DevicePlugin *plugin)
|
||||||
{
|
{
|
||||||
QVariantMap pluginMap;
|
QVariantMap pluginMap;
|
||||||
@ -583,6 +628,7 @@ QVariantMap JsonTypes::packPlugin(DevicePlugin *plugin)
|
|||||||
return pluginMap;
|
return pluginMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a device. */
|
||||||
QVariantMap JsonTypes::packDevice(Device *device)
|
QVariantMap JsonTypes::packDevice(Device *device)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -603,6 +649,7 @@ QVariantMap JsonTypes::packDevice(Device *device)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a descriptor. */
|
||||||
QVariantMap JsonTypes::packDeviceDescriptor(const DeviceDescriptor &descriptor)
|
QVariantMap JsonTypes::packDeviceDescriptor(const DeviceDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
@ -612,6 +659,7 @@ QVariantMap JsonTypes::packDeviceDescriptor(const DeviceDescriptor &descriptor)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a rule. */
|
||||||
QVariantMap JsonTypes::packRule(const Rule &rule)
|
QVariantMap JsonTypes::packRule(const Rule &rule)
|
||||||
{
|
{
|
||||||
QVariantMap ruleMap;
|
QVariantMap ruleMap;
|
||||||
@ -642,6 +690,7 @@ QVariantMap JsonTypes::packRule(const Rule &rule)
|
|||||||
return ruleMap;
|
return ruleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a rules. */
|
||||||
QVariantList JsonTypes::packRules(const QList<Rule> rules)
|
QVariantList JsonTypes::packRules(const QList<Rule> rules)
|
||||||
{
|
{
|
||||||
QVariantList rulesList;
|
QVariantList rulesList;
|
||||||
@ -651,6 +700,7 @@ QVariantList JsonTypes::packRules(const QList<Rule> rules)
|
|||||||
return rulesList;
|
return rulesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a rule. */
|
||||||
QVariantMap JsonTypes::packRuleDescription(const Rule &rule)
|
QVariantMap JsonTypes::packRuleDescription(const Rule &rule)
|
||||||
{
|
{
|
||||||
QVariantMap ruleDescriptionMap;
|
QVariantMap ruleDescriptionMap;
|
||||||
@ -662,6 +712,7 @@ QVariantMap JsonTypes::packRuleDescription(const Rule &rule)
|
|||||||
return ruleDescriptionMap;
|
return ruleDescriptionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant map of the given \a logEntry. */
|
||||||
QVariantMap JsonTypes::packLogEntry(const LogEntry &logEntry)
|
QVariantMap JsonTypes::packLogEntry(const LogEntry &logEntry)
|
||||||
{
|
{
|
||||||
QVariantMap logEntryMap;
|
QVariantMap logEntryMap;
|
||||||
@ -710,6 +761,7 @@ QVariantMap JsonTypes::packLogEntry(const LogEntry &logEntry)
|
|||||||
return logEntryMap;
|
return logEntryMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of the given \a createMethods. */
|
||||||
QVariantList JsonTypes::packCreateMethods(DeviceClass::CreateMethods createMethods)
|
QVariantList JsonTypes::packCreateMethods(DeviceClass::CreateMethods createMethods)
|
||||||
{
|
{
|
||||||
QVariantList ret;
|
QVariantList ret;
|
||||||
@ -725,6 +777,7 @@ QVariantList JsonTypes::packCreateMethods(DeviceClass::CreateMethods createMetho
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of the supported vendors. */
|
||||||
QVariantList JsonTypes::packSupportedVendors()
|
QVariantList JsonTypes::packSupportedVendors()
|
||||||
{
|
{
|
||||||
QVariantList supportedVendors;
|
QVariantList supportedVendors;
|
||||||
@ -734,6 +787,7 @@ QVariantList JsonTypes::packSupportedVendors()
|
|||||||
return supportedVendors;
|
return supportedVendors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of the supported devices with the given \a vendorId. */
|
||||||
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
||||||
{
|
{
|
||||||
QVariantList supportedDeviceList;
|
QVariantList supportedDeviceList;
|
||||||
@ -743,6 +797,7 @@ QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
|||||||
return supportedDeviceList;
|
return supportedDeviceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of configured devices. */
|
||||||
QVariantList JsonTypes::packConfiguredDevices()
|
QVariantList JsonTypes::packConfiguredDevices()
|
||||||
{
|
{
|
||||||
QVariantList configuredDeviceList;
|
QVariantList configuredDeviceList;
|
||||||
@ -752,6 +807,7 @@ QVariantList JsonTypes::packConfiguredDevices()
|
|||||||
return configuredDeviceList;
|
return configuredDeviceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of States from the given \a device. */
|
||||||
QVariantList JsonTypes::packDeviceStates(Device *device)
|
QVariantList JsonTypes::packDeviceStates(Device *device)
|
||||||
{
|
{
|
||||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||||
@ -765,6 +821,7 @@ QVariantList JsonTypes::packDeviceStates(Device *device)
|
|||||||
return stateValues;
|
return stateValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of the given \a deviceDescriptors. */
|
||||||
QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> deviceDescriptors)
|
QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> deviceDescriptors)
|
||||||
{
|
{
|
||||||
QVariantList deviceDescriptorList;
|
QVariantList deviceDescriptorList;
|
||||||
@ -774,6 +831,7 @@ QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> devi
|
|||||||
return deviceDescriptorList;
|
return deviceDescriptorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list containing all rule descriptions. */
|
||||||
QVariantList JsonTypes::packRuleDescriptions()
|
QVariantList JsonTypes::packRuleDescriptions()
|
||||||
{
|
{
|
||||||
QVariantList rulesList;
|
QVariantList rulesList;
|
||||||
@ -783,6 +841,7 @@ QVariantList JsonTypes::packRuleDescriptions()
|
|||||||
return rulesList;
|
return rulesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of the given \a rules. */
|
||||||
QVariantList JsonTypes::packRuleDescriptions(const QList<Rule> &rules)
|
QVariantList JsonTypes::packRuleDescriptions(const QList<Rule> &rules)
|
||||||
{
|
{
|
||||||
QVariantList rulesList;
|
QVariantList rulesList;
|
||||||
@ -792,6 +851,7 @@ QVariantList JsonTypes::packRuleDescriptions(const QList<Rule> &rules)
|
|||||||
return rulesList;
|
return rulesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of action types for the given \a deviceClass. */
|
||||||
QVariantList JsonTypes::packActionTypes(const DeviceClass &deviceClass)
|
QVariantList JsonTypes::packActionTypes(const DeviceClass &deviceClass)
|
||||||
{
|
{
|
||||||
QVariantList actionTypes;
|
QVariantList actionTypes;
|
||||||
@ -801,6 +861,7 @@ QVariantList JsonTypes::packActionTypes(const DeviceClass &deviceClass)
|
|||||||
return actionTypes;
|
return actionTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of state types for the given \a deviceClass. */
|
||||||
QVariantList JsonTypes::packStateTypes(const DeviceClass &deviceClass)
|
QVariantList JsonTypes::packStateTypes(const DeviceClass &deviceClass)
|
||||||
{
|
{
|
||||||
QVariantList stateTypes;
|
QVariantList stateTypes;
|
||||||
@ -810,6 +871,7 @@ QVariantList JsonTypes::packStateTypes(const DeviceClass &deviceClass)
|
|||||||
return stateTypes;
|
return stateTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list of event types for the given \a deviceClass. */
|
||||||
QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
|
QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
|
||||||
{
|
{
|
||||||
QVariantList eventTypes;
|
QVariantList eventTypes;
|
||||||
@ -819,6 +881,7 @@ QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
|
|||||||
return eventTypes;
|
return eventTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a variant list containing all plugins. */
|
||||||
QVariantList JsonTypes::packPlugins()
|
QVariantList JsonTypes::packPlugins()
|
||||||
{
|
{
|
||||||
QVariantList pluginsList;
|
QVariantList pluginsList;
|
||||||
@ -829,6 +892,7 @@ QVariantList JsonTypes::packPlugins()
|
|||||||
return pluginsList;
|
return pluginsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the type string for the given \a type. */
|
||||||
QString JsonTypes::basicTypeToString(const QVariant::Type &type)
|
QString JsonTypes::basicTypeToString(const QVariant::Type &type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -859,6 +923,7 @@ QString JsonTypes::basicTypeToString(const QVariant::Type &type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{Param} created from the given \a paramMap. */
|
||||||
Param JsonTypes::unpackParam(const QVariantMap ¶mMap)
|
Param JsonTypes::unpackParam(const QVariantMap ¶mMap)
|
||||||
{
|
{
|
||||||
if (paramMap.keys().count() == 0) {
|
if (paramMap.keys().count() == 0) {
|
||||||
@ -869,6 +934,7 @@ Param JsonTypes::unpackParam(const QVariantMap ¶mMap)
|
|||||||
return Param(name, value);
|
return Param(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{ParamList} created from the given \a paramList. */
|
||||||
ParamList JsonTypes::unpackParams(const QVariantList ¶mList)
|
ParamList JsonTypes::unpackParams(const QVariantList ¶mList)
|
||||||
{
|
{
|
||||||
ParamList params;
|
ParamList params;
|
||||||
@ -878,6 +944,7 @@ ParamList JsonTypes::unpackParams(const QVariantList ¶mList)
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{RuleActionParam} created from the given \a ruleActionParamMap. */
|
||||||
RuleActionParam JsonTypes::unpackRuleActionParam(const QVariantMap &ruleActionParamMap)
|
RuleActionParam JsonTypes::unpackRuleActionParam(const QVariantMap &ruleActionParamMap)
|
||||||
{
|
{
|
||||||
if (ruleActionParamMap.keys().count() == 0)
|
if (ruleActionParamMap.keys().count() == 0)
|
||||||
@ -890,6 +957,7 @@ RuleActionParam JsonTypes::unpackRuleActionParam(const QVariantMap &ruleActionPa
|
|||||||
return RuleActionParam(name, value, eventTypeId, eventParamName);
|
return RuleActionParam(name, value, eventTypeId, eventParamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{RuleActionParamList} created from the given \a ruleActionParamList. */
|
||||||
RuleActionParamList JsonTypes::unpackRuleActionParams(const QVariantList &ruleActionParamList)
|
RuleActionParamList JsonTypes::unpackRuleActionParams(const QVariantList &ruleActionParamList)
|
||||||
{
|
{
|
||||||
RuleActionParamList ruleActionParams;
|
RuleActionParamList ruleActionParams;
|
||||||
@ -899,6 +967,7 @@ RuleActionParamList JsonTypes::unpackRuleActionParams(const QVariantList &ruleAc
|
|||||||
return ruleActionParams;
|
return ruleActionParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{ParamDescriptor} created from the given \a paramMap. */
|
||||||
ParamDescriptor JsonTypes::unpackParamDescriptor(const QVariantMap ¶mMap)
|
ParamDescriptor JsonTypes::unpackParamDescriptor(const QVariantMap ¶mMap)
|
||||||
{
|
{
|
||||||
ParamDescriptor param(paramMap.value("name").toString(), paramMap.value("value"));
|
ParamDescriptor param(paramMap.value("name").toString(), paramMap.value("value"));
|
||||||
@ -911,6 +980,7 @@ ParamDescriptor JsonTypes::unpackParamDescriptor(const QVariantMap ¶mMap)
|
|||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a list of \l{ParamDescriptor} created from the given \a paramList. */
|
||||||
QList<ParamDescriptor> JsonTypes::unpackParamDescriptors(const QVariantList ¶mList)
|
QList<ParamDescriptor> JsonTypes::unpackParamDescriptors(const QVariantList ¶mList)
|
||||||
{
|
{
|
||||||
QList<ParamDescriptor> params;
|
QList<ParamDescriptor> params;
|
||||||
@ -920,6 +990,7 @@ QList<ParamDescriptor> JsonTypes::unpackParamDescriptors(const QVariantList &par
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{EventDescriptor} created from the given \a eventDescriptorMap. */
|
||||||
EventDescriptor JsonTypes::unpackEventDescriptor(const QVariantMap &eventDescriptorMap)
|
EventDescriptor JsonTypes::unpackEventDescriptor(const QVariantMap &eventDescriptorMap)
|
||||||
{
|
{
|
||||||
EventTypeId eventTypeId(eventDescriptorMap.value("eventTypeId").toString());
|
EventTypeId eventTypeId(eventDescriptorMap.value("eventTypeId").toString());
|
||||||
@ -929,6 +1000,7 @@ EventDescriptor JsonTypes::unpackEventDescriptor(const QVariantMap &eventDescrip
|
|||||||
return eventDescriptor;
|
return eventDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{StateEvaluator} created from the given \a stateEvaluatorMap. */
|
||||||
StateEvaluator JsonTypes::unpackStateEvaluator(const QVariantMap &stateEvaluatorMap)
|
StateEvaluator JsonTypes::unpackStateEvaluator(const QVariantMap &stateEvaluatorMap)
|
||||||
{
|
{
|
||||||
StateEvaluator ret(unpackStateDescriptor(stateEvaluatorMap.value("stateDescriptor").toMap()));
|
StateEvaluator ret(unpackStateDescriptor(stateEvaluatorMap.value("stateDescriptor").toMap()));
|
||||||
@ -943,6 +1015,7 @@ StateEvaluator JsonTypes::unpackStateEvaluator(const QVariantMap &stateEvaluator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{StateDescriptor} created from the given \a stateDescriptorMap. */
|
||||||
StateDescriptor JsonTypes::unpackStateDescriptor(const QVariantMap &stateDescriptorMap)
|
StateDescriptor JsonTypes::unpackStateDescriptor(const QVariantMap &stateDescriptorMap)
|
||||||
{
|
{
|
||||||
StateTypeId stateTypeId(stateDescriptorMap.value("stateTypeId").toString());
|
StateTypeId stateTypeId(stateDescriptorMap.value("stateTypeId").toString());
|
||||||
@ -953,6 +1026,7 @@ StateDescriptor JsonTypes::unpackStateDescriptor(const QVariantMap &stateDescrip
|
|||||||
return stateDescriptor;
|
return stateDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a \l{LogFilter} created from the given \a logFilterMap. */
|
||||||
LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
|
LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
|
||||||
{
|
{
|
||||||
LogFilter filter;
|
LogFilter filter;
|
||||||
@ -1011,6 +1085,8 @@ LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Compairs the given \a map with the given \a templateMap. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonTypes::validateMap(const QVariantMap &templateMap, const QVariantMap &map)
|
QPair<bool, QString> JsonTypes::validateMap(const QVariantMap &templateMap, const QVariantMap &map)
|
||||||
{
|
{
|
||||||
s_lastError.clear();
|
s_lastError.clear();
|
||||||
@ -1049,6 +1125,8 @@ QPair<bool, QString> JsonTypes::validateMap(const QVariantMap &templateMap, cons
|
|||||||
return report(true, "");
|
return report(true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Compairs the given \a value with the given \a templateValue. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonTypes::validateProperty(const QVariant &templateValue, const QVariant &value)
|
QPair<bool, QString> JsonTypes::validateProperty(const QVariant &templateValue, const QVariant &value)
|
||||||
{
|
{
|
||||||
QString strippedTemplateValue = templateValue.toString();
|
QString strippedTemplateValue = templateValue.toString();
|
||||||
@ -1077,6 +1155,8 @@ QPair<bool, QString> JsonTypes::validateProperty(const QVariant &templateValue,
|
|||||||
return report(false, errorString);
|
return report(false, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Compairs the given \a list with the given \a templateList. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonTypes::validateList(const QVariantList &templateList, const QVariantList &list)
|
QPair<bool, QString> JsonTypes::validateList(const QVariantList &templateList, const QVariantList &list)
|
||||||
{
|
{
|
||||||
Q_ASSERT(templateList.count() == 1);
|
Q_ASSERT(templateList.count() == 1);
|
||||||
@ -1093,6 +1173,8 @@ QPair<bool, QString> JsonTypes::validateList(const QVariantList &templateList, c
|
|||||||
return report(true, "");
|
return report(true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Compairs the given \a variant with the given \a templateVariant. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonTypes::validateVariant(const QVariant &templateVariant, const QVariant &variant)
|
QPair<bool, QString> JsonTypes::validateVariant(const QVariant &templateVariant, const QVariant &variant)
|
||||||
{
|
{
|
||||||
switch(templateVariant.type()) {
|
switch(templateVariant.type()) {
|
||||||
@ -1352,6 +1434,8 @@ QPair<bool, QString> JsonTypes::validateVariant(const QVariant &templateVariant,
|
|||||||
return report(true, "");
|
return report(true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verify the given \a variant with the possible \l{BasicType}. Returns the error string and false if
|
||||||
|
the params are not valid. */
|
||||||
QPair<bool, QString> JsonTypes::validateBasicType(const QVariant &variant)
|
QPair<bool, QString> JsonTypes::validateBasicType(const QVariant &variant)
|
||||||
{
|
{
|
||||||
if (variant.canConvert(QVariant::Uuid) && QVariant(variant).convert(QVariant::Uuid)) {
|
if (variant.canConvert(QVariant::Uuid) && QVariant(variant).convert(QVariant::Uuid)) {
|
||||||
@ -1378,6 +1462,7 @@ QPair<bool, QString> JsonTypes::validateBasicType(const QVariant &variant)
|
|||||||
return report(false, QString("Error validating basic type %1.").arg(variant.toString()));
|
return report(false, QString("Error validating basic type %1.").arg(variant.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the type of the \l{Param} with the given \a paramName of the \l{ActionType} with the given \a actionTypeId. */
|
||||||
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()->deviceManager()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
@ -1394,6 +1479,7 @@ QVariant::Type JsonTypes::getActionParamType(const ActionTypeId &actionTypeId, c
|
|||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the type of the \l{Param} with the given \a paramName of the \l{EventType} with the given \a eventTypeId. */
|
||||||
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()->deviceManager()->supportedDevices()) {
|
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||||
@ -1411,6 +1497,7 @@ QVariant::Type JsonTypes::getEventParamType(const EventTypeId &eventTypeId, cons
|
|||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns true if the given \a eventTypeId is in the given \a eventDescriptors.*/
|
||||||
bool JsonTypes::checkEventDescriptors(const QList<EventDescriptor> eventDescriptors, const EventTypeId &eventTypeId)
|
bool JsonTypes::checkEventDescriptors(const QList<EventDescriptor> eventDescriptors, const EventTypeId &eventTypeId)
|
||||||
{
|
{
|
||||||
foreach (const EventDescriptor eventDescriptor, eventDescriptors) {
|
foreach (const EventDescriptor eventDescriptor, eventDescriptors) {
|
||||||
@ -1421,6 +1508,7 @@ bool JsonTypes::checkEventDescriptors(const QList<EventDescriptor> eventDescript
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verifies if the given \a params contain a valid rule. Returns \l{RuleEngine::RuleError} to inform about the result.*/
|
||||||
RuleEngine::RuleError JsonTypes::verifyRuleConsistency(const QVariantMap ¶ms)
|
RuleEngine::RuleError JsonTypes::verifyRuleConsistency(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
// check if there are an eventDescriptor and an eventDescriptorList
|
// check if there are an eventDescriptor and an eventDescriptorList
|
||||||
@ -1448,6 +1536,7 @@ RuleEngine::RuleError JsonTypes::verifyRuleConsistency(const QVariantMap ¶ms
|
|||||||
return RuleEngine::RuleErrorNoError;
|
return RuleEngine::RuleErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verifies if the given \a params contain a valid rule. Returns \l{RuleEngine::RuleError} to inform about the result.*/
|
||||||
QPair<QList<EventDescriptor>, RuleEngine::RuleError> JsonTypes::verifyEventDescriptors(const QVariantMap ¶ms)
|
QPair<QList<EventDescriptor>, RuleEngine::RuleError> JsonTypes::verifyEventDescriptors(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
// Check and unpack eventDescriptors
|
// Check and unpack eventDescriptors
|
||||||
@ -1467,6 +1556,7 @@ QPair<QList<EventDescriptor>, RuleEngine::RuleError> JsonTypes::verifyEventDescr
|
|||||||
return QPair<QList<EventDescriptor>, RuleEngine::RuleError>(eventDescriptorList, RuleEngine::RuleErrorNoError);
|
return QPair<QList<EventDescriptor>, RuleEngine::RuleError>(eventDescriptorList, RuleEngine::RuleErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verifies if the given \a eventDescriptorList corresponds to an action in the given \a params. Returns \l{RuleEngine::RuleError} and \l{RuleAction} list to inform about the result.*/
|
||||||
QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyActions(const QVariantMap ¶ms, const QList<EventDescriptor> &eventDescriptorList)
|
QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyActions(const QVariantMap ¶ms, const QList<EventDescriptor> &eventDescriptorList)
|
||||||
{
|
{
|
||||||
QList<RuleAction> actions;
|
QList<RuleAction> actions;
|
||||||
@ -1524,6 +1614,7 @@ QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyActions(const Q
|
|||||||
return QPair<QList<RuleAction>, RuleEngine::RuleError>(actions, RuleEngine::RuleErrorNoError);
|
return QPair<QList<RuleAction>, RuleEngine::RuleError>(actions, RuleEngine::RuleErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Verifies if exit actions of the rule in the given \a params. Returns \l{RuleEngine::RuleError} and \l{RuleAction} list to inform about the result. */
|
||||||
QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyExitActions(const QVariantMap ¶ms)
|
QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyExitActions(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
QList<RuleAction> exitActions;
|
QList<RuleAction> exitActions;
|
||||||
@ -1545,6 +1636,8 @@ QPair<QList<RuleAction>, RuleEngine::RuleError> JsonTypes::verifyExitActions(con
|
|||||||
return QPair<QList<RuleAction>, RuleEngine::RuleError>(exitActions, RuleEngine::RuleErrorNoError);
|
return QPair<QList<RuleAction>, RuleEngine::RuleError>(exitActions, RuleEngine::RuleErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Compairs the given \a value with the given \a enumDescription. Returns the error string and false if
|
||||||
|
the enum does not contain the given \a value. */
|
||||||
QPair<bool, QString> JsonTypes::validateEnum(const QVariantList &enumDescription, const QVariant &value)
|
QPair<bool, QString> JsonTypes::validateEnum(const QVariantList &enumDescription, const QVariant &value)
|
||||||
{
|
{
|
||||||
QStringList enumStrings;
|
QStringList enumStrings;
|
||||||
|
|||||||
@ -32,6 +32,16 @@
|
|||||||
\sa LogEngine, JsonHandler, JsonRPCServer
|
\sa LogEngine, JsonHandler, JsonRPCServer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::LoggingHandler::LogEntryAdded(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{LogEntry} was added to the database.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::LoggingHandler::LogDatabaseUpdated(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when the logging aatabase has been updated (i.e. \l{Device} or \l{Rule} removed).
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "logginghandler.h"
|
#include "logginghandler.h"
|
||||||
#include "logging/logengine.h"
|
#include "logging/logengine.h"
|
||||||
#include "logging/logfilter.h"
|
#include "logging/logfilter.h"
|
||||||
@ -40,6 +50,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l LoggingHandler with the given \a parent. */
|
||||||
LoggingHandler::LoggingHandler(QObject *parent) :
|
LoggingHandler::LoggingHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -84,6 +95,7 @@ LoggingHandler::LoggingHandler(QObject *parent) :
|
|||||||
connect(GuhCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
|
connect(GuhCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{LoggingHandler}. In this case \b Logging.*/
|
||||||
QString LoggingHandler::name() const
|
QString LoggingHandler::name() const
|
||||||
{
|
{
|
||||||
return "Logging";
|
return "Logging";
|
||||||
|
|||||||
@ -32,6 +32,26 @@
|
|||||||
\sa RuleEngine, JsonHandler, JsonRPCServer
|
\sa RuleEngine, JsonHandler, JsonRPCServer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::RulesHandler::RuleRemoved(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Rule} was removed.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::RulesHandler::RuleAdded(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Rule} was added.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::RulesHandler::RuleActiveChanged(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Rule} has changed the active status.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void guhserver::RulesHandler::RuleConfigurationChanged(const QVariantMap ¶ms);
|
||||||
|
This signal is emitted to the API notifications when a \l{Rule} has changed the configuration.
|
||||||
|
The \a params contain the map for the notification.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "ruleshandler.h"
|
#include "ruleshandler.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
@ -41,6 +61,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l{RulesHandler} with the given \a parent. */
|
||||||
RulesHandler::RulesHandler(QObject *parent) :
|
RulesHandler::RulesHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -173,6 +194,7 @@ RulesHandler::RulesHandler(QObject *parent) :
|
|||||||
connect(GuhCore::instance(), &GuhCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification);
|
connect(GuhCore::instance(), &GuhCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{RulesHandler}. In this case \b Rules.*/
|
||||||
QString RulesHandler::name() const
|
QString RulesHandler::name() const
|
||||||
{
|
{
|
||||||
return "Rules";
|
return "Rules";
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l{StateHandler} with the given \a parent. */
|
||||||
StateHandler::StateHandler(QObject *parent) :
|
StateHandler::StateHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -53,6 +54,7 @@ StateHandler::StateHandler(QObject *parent) :
|
|||||||
setReturns("GetStateType", returns);
|
setReturns("GetStateType", returns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the name of the \l{StateHandler}. In this case \b States.*/
|
||||||
QString StateHandler::name() const
|
QString StateHandler::name() const
|
||||||
{
|
{
|
||||||
return "States";
|
return "States";
|
||||||
|
|||||||
@ -56,6 +56,10 @@
|
|||||||
\sa LogEngine, LogEntry, LogFilter
|
\sa LogEngine, LogEntry, LogFilter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn guhserver::Logging::Logging(QObject *parent)
|
||||||
|
Constructs the \l{Logging} object with the given \a parent.
|
||||||
|
*/
|
||||||
|
|
||||||
/*! \enum guhserver::Logging::LoggingError
|
/*! \enum guhserver::Logging::LoggingError
|
||||||
Represents the possible errors from the \l{LogEngine}.
|
Represents the possible errors from the \l{LogEngine}.
|
||||||
|
|
||||||
@ -73,7 +77,12 @@
|
|||||||
\value LoggingEventTypeTrigger
|
\value LoggingEventTypeTrigger
|
||||||
This event type describes an \l{Event} which has triggered.
|
This event type describes an \l{Event} which has triggered.
|
||||||
\value LoggingEventTypeActiveChange
|
\value LoggingEventTypeActiveChange
|
||||||
This event type describes an \l{Rule} which has changed its active status.
|
This event type describes a \l{Rule} which has changed its active status.
|
||||||
|
\value LoggingEventTypeActionsExecuted
|
||||||
|
This event type describes the actions execution of a \l{Rule}.
|
||||||
|
\value LoggingEventTypeExitActionsExecuted
|
||||||
|
This event type describes the exit actions execution of a \l{Rule}.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \enum guhserver::Logging::LoggingLevel
|
/*! \enum guhserver::Logging::LoggingLevel
|
||||||
@ -145,6 +154,7 @@ LogEngine::LogEngine(QObject *parent):
|
|||||||
initDB();
|
initDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Destructs the \l{LogEngine}. */
|
||||||
LogEngine::~LogEngine()
|
LogEngine::~LogEngine()
|
||||||
{
|
{
|
||||||
qCDebug(dcApplication) << "Shutting down \"Log Engine\"";
|
qCDebug(dcApplication) << "Shutting down \"Log Engine\"";
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a \l{LogEntry} with the given \a timestamp, \a level, \a source and \a errorCode.*/
|
||||||
LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
||||||
m_timestamp(timestamp),
|
m_timestamp(timestamp),
|
||||||
m_level(level),
|
m_level(level),
|
||||||
@ -54,83 +55,99 @@ LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::Lo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Constructs a \l{LogEntry} with the given \a level, \a source and \a errorCode.*/
|
||||||
LogEntry::LogEntry(Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
LogEntry::LogEntry(Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
||||||
LogEntry(QDateTime::currentDateTime(), level, source, errorCode)
|
LogEntry(QDateTime::currentDateTime(), level, source, errorCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Constructs a \l{LogEntry} with the given \a source.*/
|
||||||
LogEntry::LogEntry(Logging::LoggingSource source):
|
LogEntry::LogEntry(Logging::LoggingSource source):
|
||||||
LogEntry(Logging::LoggingLevelInfo, source)
|
LogEntry(Logging::LoggingLevelInfo, source)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the timestamp of this \l{LogEntry}. */
|
||||||
QDateTime LogEntry::timestamp() const
|
QDateTime LogEntry::timestamp() const
|
||||||
{
|
{
|
||||||
return m_timestamp;
|
return m_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the level of this \l{LogEntry}. */
|
||||||
Logging::LoggingLevel LogEntry::level() const
|
Logging::LoggingLevel LogEntry::level() const
|
||||||
{
|
{
|
||||||
return m_level;
|
return m_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the source of this \l{LogEntry}. */
|
||||||
Logging::LoggingSource LogEntry::source() const
|
Logging::LoggingSource LogEntry::source() const
|
||||||
{
|
{
|
||||||
return m_source;
|
return m_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the type ID of this \l{LogEntry}. */
|
||||||
QUuid LogEntry::typeId() const
|
QUuid LogEntry::typeId() const
|
||||||
{
|
{
|
||||||
return m_typeId;
|
return m_typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a typeId of this \l{LogEntry}. */
|
||||||
void LogEntry::setTypeId(const QUuid &typeId) {
|
void LogEntry::setTypeId(const QUuid &typeId) {
|
||||||
m_typeId = typeId;
|
m_typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the deviceId of this \l{LogEntry}. */
|
||||||
DeviceId LogEntry::deviceId() const
|
DeviceId LogEntry::deviceId() const
|
||||||
{
|
{
|
||||||
return m_deviceId;
|
return m_deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a deviceId of this \l{LogEntry}. */
|
||||||
void LogEntry::setDeviceId(const DeviceId &deviceId)
|
void LogEntry::setDeviceId(const DeviceId &deviceId)
|
||||||
{
|
{
|
||||||
m_deviceId = deviceId;
|
m_deviceId = deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the value of this \l{LogEntry}. */
|
||||||
QString LogEntry::value() const
|
QString LogEntry::value() const
|
||||||
{
|
{
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets the \a value of this \l{LogEntry}. */
|
||||||
void LogEntry::setValue(const QString &value)
|
void LogEntry::setValue(const QString &value)
|
||||||
{
|
{
|
||||||
m_value = value;
|
m_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the event type of this \l{LogEntry}. */
|
||||||
Logging::LoggingEventType LogEntry::eventType() const
|
Logging::LoggingEventType LogEntry::eventType() const
|
||||||
{
|
{
|
||||||
return m_eventType;
|
return m_eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns true if this \l{LogEntry} is a system active type. */
|
||||||
bool LogEntry::active() const
|
bool LogEntry::active() const
|
||||||
{
|
{
|
||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Sets this \l{LogEntry} to \a active. */
|
||||||
void LogEntry::setActive(bool active)
|
void LogEntry::setActive(bool active)
|
||||||
{
|
{
|
||||||
m_eventType = Logging::LoggingEventTypeActiveChange;
|
m_eventType = Logging::LoggingEventTypeActiveChange;
|
||||||
m_active = active;
|
m_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the error code of this \l{LogEntry}. */
|
||||||
int LogEntry::errorCode() const
|
int LogEntry::errorCode() const
|
||||||
{
|
{
|
||||||
return m_errorCode;
|
return m_errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const LogEntry &entry)
|
QDebug operator<<(QDebug dbg, const LogEntry &entry)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "LogEntry (count:" << entry.timestamp().toString() << endl;
|
dbg.nospace() << "LogEntry (count:" << entry.timestamp().toString() << endl;
|
||||||
|
|||||||
@ -36,11 +36,13 @@
|
|||||||
|
|
||||||
namespace guhserver {
|
namespace guhserver {
|
||||||
|
|
||||||
|
/*! Constructs a new \l{LogFilter}.*/
|
||||||
LogFilter::LogFilter()
|
LogFilter::LogFilter()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the database query string for this \l{LogFilter}.*/
|
||||||
QString LogFilter::queryString() const
|
QString LogFilter::queryString() const
|
||||||
{
|
{
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
@ -83,6 +85,7 @@ QString LogFilter::queryString() const
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new time filter with the given \a startDate and \a endDate. */
|
||||||
void LogFilter::addTimeFilter(const QDateTime &startDate, const QDateTime &endDate)
|
void LogFilter::addTimeFilter(const QDateTime &startDate, const QDateTime &endDate)
|
||||||
{
|
{
|
||||||
QPair<QDateTime, QDateTime> timeFilter(startDate, endDate);
|
QPair<QDateTime, QDateTime> timeFilter(startDate, endDate);
|
||||||
@ -90,77 +93,91 @@ void LogFilter::addTimeFilter(const QDateTime &startDate, const QDateTime &endDa
|
|||||||
m_timeFilters.append(timeFilter);
|
m_timeFilters.append(timeFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of time filters from this \l{LogFilter}. */
|
||||||
QList<QPair<QDateTime, QDateTime> > LogFilter::timeFilters() const
|
QList<QPair<QDateTime, QDateTime> > LogFilter::timeFilters() const
|
||||||
{
|
{
|
||||||
return m_timeFilters;
|
return m_timeFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a source to this \l{LogFilter}. */
|
||||||
void LogFilter::addLoggingSource(const Logging::LoggingSource &source)
|
void LogFilter::addLoggingSource(const Logging::LoggingSource &source)
|
||||||
{
|
{
|
||||||
if (!m_sources.contains(source))
|
if (!m_sources.contains(source))
|
||||||
m_sources.append(source);
|
m_sources.append(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of logging sources from this \l{LogFilter}. */
|
||||||
QList<Logging::LoggingSource> LogFilter::loggingSources() const
|
QList<Logging::LoggingSource> LogFilter::loggingSources() const
|
||||||
{
|
{
|
||||||
return m_sources;
|
return m_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a level to this \l{LogFilter}. */
|
||||||
void LogFilter::addLoggingLevel(const Logging::LoggingLevel &level)
|
void LogFilter::addLoggingLevel(const Logging::LoggingLevel &level)
|
||||||
{
|
{
|
||||||
if (!m_levels.contains(level))
|
if (!m_levels.contains(level))
|
||||||
m_levels.append(level);
|
m_levels.append(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of logging levels from this \l{LogFilter}. */
|
||||||
QList<Logging::LoggingLevel> LogFilter::loggingLevels() const
|
QList<Logging::LoggingLevel> LogFilter::loggingLevels() const
|
||||||
{
|
{
|
||||||
return m_levels;
|
return m_levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a eventType to this \l{LogFilter}. */
|
||||||
void LogFilter::addLoggingEventType(const Logging::LoggingEventType &eventType)
|
void LogFilter::addLoggingEventType(const Logging::LoggingEventType &eventType)
|
||||||
{
|
{
|
||||||
if (!m_eventTypes.contains(eventType))
|
if (!m_eventTypes.contains(eventType))
|
||||||
m_eventTypes.append(eventType);
|
m_eventTypes.append(eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of event types from this \l{LogFilter}. */
|
||||||
QList<Logging::LoggingEventType> LogFilter::loggingEventTypes() const
|
QList<Logging::LoggingEventType> LogFilter::loggingEventTypes() const
|
||||||
{
|
{
|
||||||
return m_eventTypes;
|
return m_eventTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a typeId to this \l{LogFilter}. */
|
||||||
void LogFilter::addTypeId(const QUuid &typeId)
|
void LogFilter::addTypeId(const QUuid &typeId)
|
||||||
{
|
{
|
||||||
if (!m_typeIds.contains(typeId))
|
if (!m_typeIds.contains(typeId))
|
||||||
m_typeIds.append(typeId);
|
m_typeIds.append(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of type id's from this \l{LogFilter}. */
|
||||||
QList<QUuid> LogFilter::typeIds() const
|
QList<QUuid> LogFilter::typeIds() const
|
||||||
{
|
{
|
||||||
return m_typeIds;
|
return m_typeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a deviceId to this \l{LogFilter}. */
|
||||||
void LogFilter::addDeviceId(const DeviceId &deviceId)
|
void LogFilter::addDeviceId(const DeviceId &deviceId)
|
||||||
{
|
{
|
||||||
if (!m_deviceIds.contains(deviceId))
|
if (!m_deviceIds.contains(deviceId))
|
||||||
m_deviceIds.append(deviceId);
|
m_deviceIds.append(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of device id's from this \l{LogFilter}. */
|
||||||
QList<DeviceId> LogFilter::deviceIds() const
|
QList<DeviceId> LogFilter::deviceIds() const
|
||||||
{
|
{
|
||||||
return m_deviceIds;
|
return m_deviceIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add a new \a value to this \l{LogFilter}. */
|
||||||
void LogFilter::addValue(const QString &value)
|
void LogFilter::addValue(const QString &value)
|
||||||
{
|
{
|
||||||
if (!m_values.contains(value))
|
if (!m_values.contains(value))
|
||||||
m_values.append(value);
|
m_values.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the list of values from this \l{LogFilter}. */
|
||||||
QList<QString> LogFilter::values() const
|
QList<QString> LogFilter::values() const
|
||||||
{
|
{
|
||||||
return m_values;
|
return m_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns true if this \l{LogFilter} is empty. */
|
||||||
bool LogFilter::isEmpty() const
|
bool LogFilter::isEmpty() const
|
||||||
{
|
{
|
||||||
return m_timeFilters.isEmpty() &&
|
return m_timeFilters.isEmpty() &&
|
||||||
|
|||||||
@ -213,6 +213,7 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Destructor of the \l{RuleEngine}. */
|
||||||
RuleEngine::~RuleEngine()
|
RuleEngine::~RuleEngine()
|
||||||
{
|
{
|
||||||
qCDebug(dcApplication) << "Shutting down \"Rule Engine\"";
|
qCDebug(dcApplication) << "Shutting down \"Rule Engine\"";
|
||||||
|
|||||||
Reference in New Issue
Block a user