diff --git a/debian/changelog b/debian/changelog index 48728e51..396b37a6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +nymea (0.15.0) UNRELEASED; urgency=medium + + + -- Michael Zanetti Tue, 09 Jul 2019 02:08:05 +0200 + nymea (0.14.0) xenial; urgency=medium [ Michael Zanetti ] * Bump minimum required TLS version to 1.2 diff --git a/libnymea/types/ruleaction.cpp b/libnymea/types/ruleaction.cpp index 08882ccd..556ba2c1 100644 --- a/libnymea/types/ruleaction.cpp +++ b/libnymea/types/ruleaction.cpp @@ -46,17 +46,21 @@ #include "ruleaction.h" -/*! Constructs a RuleAction with the given by \a actionTypeId, \a deviceId and \a params. */ +/*! Constructs a RuleAction with the given by \a actionTypeId, \a deviceId and \a params. + * Use this to create a RuleAction for regular actions, that is, identifying the Action by deviceId and actionTypeId. + */ RuleAction::RuleAction(const ActionTypeId &actionTypeId, const DeviceId &deviceId, const RuleActionParamList ¶ms): m_id(ActionId::createActionId()), - m_actionTypeId(actionTypeId), m_deviceId(deviceId), + m_actionTypeId(actionTypeId), m_ruleActionParams(params) { } -/*! Constructs a RuleAction with the given by \a interface and \a interfaceAction. */ +/*! Constructs a RuleAction with the given by \a interface and \a interfaceAction. + * This will create an interface based RuleAction. Meaning, the Action is idenfified by an interface and and interfaceAction. + */ RuleAction::RuleAction(const QString &interface, const QString &interfaceAction, const RuleActionParamList ¶ms) : m_interface(interface), m_interfaceAction(interfaceAction), @@ -65,11 +69,22 @@ RuleAction::RuleAction(const QString &interface, const QString &interfaceAction, } +/*! Constructs a RuleAction with the given by \a interface and \a interfaceAction. + * Use this to create a RuleAction for executing browser items. + */ +RuleAction::RuleAction(const DeviceId &deviceId, const QString &browserItemId): + m_deviceId(deviceId), + m_browserItemId(browserItemId) +{ + +} + /*! Constructs a copy of the given \a other RuleAction. */ RuleAction::RuleAction(const RuleAction &other) : m_id(other.id()), - m_actionTypeId(other.actionTypeId()), m_deviceId(other.deviceId()), + m_actionTypeId(other.actionTypeId()), + m_browserItemId(other.browserItemId()), m_interface(other.interface()), m_interfaceAction(other.interfaceAction()), m_ruleActionParams(other.ruleActionParams()) @@ -86,13 +101,25 @@ ActionId RuleAction::id() const /*! Return true, if the actionTypeId and the deviceId of this RuleAction are valid (set).*/ bool RuleAction::isValid() const { - return (!m_actionTypeId.isNull() && !m_deviceId.isNull()) || (!m_interface.isEmpty() && !m_interfaceAction.isEmpty()); + return (!m_actionTypeId.isNull() && !m_deviceId.isNull()) + || (!m_interface.isEmpty() && !m_interfaceAction.isEmpty()) + || (!m_deviceId.isNull() && !m_browserItemId.isEmpty()); } /*! Returns whether this RuleAction is targetting a specific device or rather an interface. */ RuleAction::Type RuleAction::type() const { - return (!m_actionTypeId.isNull() && !m_deviceId.isNull()) ? TypeDevice : TypeInterface; + if (!m_deviceId.isNull() && !m_actionTypeId.isNull()) { + return TypeDevice; + } + if (!m_deviceId.isNull() && m_browserItemId.isEmpty()) { + return TypeBrowser; + } + if (!m_interface.isEmpty() && !m_interfaceAction.isEmpty()) { + return TypeInterface; + } + // uhmm... invalid... + return TypeDevice; } /*! Return true, if this RuleAction contains a \l{RuleActionParam} which is based on an EventTypeId.*/ @@ -129,6 +156,13 @@ Action RuleAction::toAction() const return action; } +/*! Converts this \l{RuleAction} to a \l{BrowserItemAction}. + * \sa BrowserItemAction, */ +BrowserItemAction RuleAction::toBrowserItemAction() const +{ + return BrowserItemAction(m_deviceId, m_browserItemId); +} + /*! Returns the actionTypeId of this RuleAction. */ ActionTypeId RuleAction::actionTypeId() const { @@ -204,7 +238,7 @@ void RuleAction::operator=(const RuleAction &other) /*! Print a RuleAction including RuleActionParams to QDebug. */ QDebug operator<<(QDebug dbg, const RuleAction &ruleAction) { - dbg.nospace() << "RuleAction(ActionTypeId:" << ruleAction.actionTypeId().toString() << ", DeviceId:" << ruleAction.deviceId().toString() << ", Interface:" << ruleAction.interface() << ", InterfaceAction:" << ruleAction.interfaceAction() << ")" << endl; + dbg.nospace() << "RuleAction(ActionTypeId:" << ruleAction.actionTypeId().toString() << ", DeviceId:" << ruleAction.deviceId().toString() << ", Interface:" << ruleAction.interface() << ", InterfaceAction:" << ruleAction.interfaceAction() << ", BrowserItemId:" << ruleAction.browserItemId() << ")" << endl; for (int i = 0; i < ruleAction.ruleActionParams().count(); i++) { dbg.nospace() << " " << i << ": " << ruleAction.ruleActionParams().at(i) << endl; } diff --git a/libnymea/types/ruleaction.h b/libnymea/types/ruleaction.h index 98dee3b9..3dc50ab3 100644 --- a/libnymea/types/ruleaction.h +++ b/libnymea/types/ruleaction.h @@ -27,16 +27,19 @@ #include "libnymea.h" #include "action.h" #include "ruleactionparam.h" +#include "browseritemaction.h" class LIBNYMEA_EXPORT RuleAction { public: enum Type { TypeDevice, - TypeInterface + TypeInterface, + TypeBrowser }; explicit RuleAction(const ActionTypeId &actionTypeId = ActionTypeId(), const DeviceId &deviceId = DeviceId(), const RuleActionParamList ¶ms = RuleActionParamList()); explicit RuleAction(const QString &interface, const QString &interfaceAction, const RuleActionParamList ¶ms = RuleActionParamList()); + explicit RuleAction(const DeviceId &deviceId, const QString &browserItemId); RuleAction(const RuleAction &other); ActionId id() const; @@ -48,9 +51,11 @@ public: bool isStateBased() const; Action toAction() const; + BrowserItemAction toBrowserItemAction() const; - ActionTypeId actionTypeId() const; DeviceId deviceId() const; + ActionTypeId actionTypeId() const; + QString browserItemId() const; QString interface() const; QString interfaceAction() const; @@ -64,8 +69,9 @@ public: private: ActionId m_id; - ActionTypeId m_actionTypeId; DeviceId m_deviceId; + ActionTypeId m_actionTypeId; + QString m_browserItemId; QString m_interface; QString m_interfaceAction; RuleActionParamList m_ruleActionParams;