diff --git a/libguh/devicemanager.cpp b/libguh/devicemanager.cpp index 6e23a918..dfe24574 100644 --- a/libguh/devicemanager.cpp +++ b/libguh/devicemanager.cpp @@ -311,7 +311,7 @@ QList DeviceManager::findConfiguredDevices(const DeviceClassId &device /*! For conveninece, this returns the \{DeviceClass} with the id given by \a deviceClassId. Note: The returned DeviceClass may be invalid.*/ -DeviceClass DeviceManager::findDeviceClass(const QUuid &deviceClassId) const +DeviceClass DeviceManager::findDeviceClass(const DeviceClassId &deviceClassId) const { foreach (const DeviceClass &deviceClass, m_supportedDevices) { if (deviceClass.id() == deviceClassId) { diff --git a/libguh/devicemanager.h b/libguh/devicemanager.h index 4fecc3d5..f0aea7f4 100644 --- a/libguh/devicemanager.h +++ b/libguh/devicemanager.h @@ -78,7 +78,7 @@ public: Device* findConfiguredDevice(const DeviceId &id) const; QList findConfiguredDevices(const DeviceClassId &deviceClassId) const; - DeviceClass findDeviceClass(const QUuid &deviceClassId) const; + DeviceClass findDeviceClass(const DeviceClassId &deviceClassId) const; signals: void loaded(); diff --git a/libguh/plugin/device.cpp b/libguh/plugin/device.cpp index 1f925668..03695ce2 100644 --- a/libguh/plugin/device.cpp +++ b/libguh/plugin/device.cpp @@ -105,7 +105,7 @@ void Device::setStates(const QList &states) m_states = states; } -bool Device::hasState(const QUuid &stateTypeId) const +bool Device::hasState(const StateTypeId &stateTypeId) const { foreach (const State &state, m_states) { if (state.stateTypeId() == stateTypeId) { @@ -116,7 +116,7 @@ bool Device::hasState(const QUuid &stateTypeId) const } /*! For convenience, this finds the \l{State} matching the given \a stateTypeId and returns the current valie in this Device. */ -QVariant Device::stateValue(const QUuid &stateTypeId) const +QVariant Device::stateValue(const StateTypeId &stateTypeId) const { qDebug() << "device has states:" << m_states.count(); foreach (const State &state, m_states) { diff --git a/libguh/plugin/device.h b/libguh/plugin/device.h index 1b2eac6f..68779fa6 100644 --- a/libguh/plugin/device.h +++ b/libguh/plugin/device.h @@ -49,8 +49,8 @@ public: QList states() const; void setStates(const QList &states); - bool hasState(const QUuid &stateTypeId) const; - QVariant stateValue(const QUuid &stateTypeId) const; + bool hasState(const StateTypeId &stateTypeId) const; + QVariant stateValue(const StateTypeId &stateTypeId) const; void setStateValue(const StateTypeId &stateTypeId, const QVariant &value); signals: diff --git a/libguh/types/event.cpp b/libguh/types/event.cpp index 6a80a4a2..76a68914 100644 --- a/libguh/types/event.cpp +++ b/libguh/types/event.cpp @@ -71,6 +71,13 @@ void Event::setParams(const QVariantMap ¶ms) Events are equal (returns true) if eventTypeId, deviceId and params match. */ bool Event::operator ==(const Event &other) const { + + bool result =m_eventTypeId == other.eventTypeId() + && m_deviceId == other.deviceId() + && m_params == other.params(); + + qDebug() << "comparing event" << *this << "with" << other << "result is" << result << "params" << m_params << "other" << other.params(); + return m_eventTypeId == other.eventTypeId() && m_deviceId == other.deviceId() && m_params == other.params(); diff --git a/libguh/typeutils.h b/libguh/typeutils.h index 4b5c6a31..fd24dace 100644 --- a/libguh/typeutils.h +++ b/libguh/typeutils.h @@ -11,6 +11,9 @@ public: \ type##Id(): QUuid() {} \ static type##Id create##type##Id() { return type##Id(QUuid::createUuid().toString()); } \ static type##Id fromUuid(const QUuid &uuid) { return type##Id(uuid.toString()); } \ + bool operator==(const type##Id &other) const { \ + return toString() == other.toString(); \ + } \ }; \ Q_DECLARE_METATYPE(type##Id); @@ -25,4 +28,14 @@ DECLARE_TYPE_ID(StateType) DECLARE_TYPE_ID(ActionType) DECLARE_TYPE_ID(Plugin) + +enum ParamOperand { + ParamOperandEquals, + ParamOperandNotEquals, + ParamOperandLess, + ParamOperandGreater, + ParamOperandLessThan, + ParamOperandGreaterThan +}; + #endif // TYPEUTILS_H diff --git a/plugins/deviceplugins/lircd/devicepluginlircd.cpp b/plugins/deviceplugins/lircd/devicepluginlircd.cpp index bd9aed6b..20cf462c 100644 --- a/plugins/deviceplugins/lircd/devicepluginlircd.cpp +++ b/plugins/deviceplugins/lircd/devicepluginlircd.cpp @@ -114,12 +114,10 @@ void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString & qDebug() << "found remote" << remoteName << supportedDevices().first().events().count(); foreach (const EventType &eventType, supportedDevices().first().events()) { - qDebug() << "checking eventType" << eventType.name() << "with" << buttonName; if (eventType.name() == buttonName) { QVariantMap param; param.insert("repeat", repeat); Event event(eventType.id(), remote->id(), param); - qDebug() << "emitting event"; emitEvent(event); } } diff --git a/plugins/deviceplugins/mock/httpdaemon.cpp b/plugins/deviceplugins/mock/httpdaemon.cpp index d31ef444..eef0c26d 100644 --- a/plugins/deviceplugins/mock/httpdaemon.cpp +++ b/plugins/deviceplugins/mock/httpdaemon.cpp @@ -35,9 +35,9 @@ void HttpDaemon::incomingConnection(qintptr socket) } -void HttpDaemon::actionExecuted(const QUuid &actionTypeId) +void HttpDaemon::actionExecuted(const ActionTypeId &actionTypeId) { - m_actionList.append(qMakePair(actionTypeId, QDateTime::currentDateTime())); + m_actionList.append(qMakePair(actionTypeId, QDateTime::currentDateTime())); } void HttpDaemon::readClient() @@ -160,7 +160,7 @@ QString HttpDaemon::generateWebPage() body.append(""); body.append(""); for (int i = 0; i < m_actionList.count(); ++i) { - QUuid actionTypeId = m_actionList.at(i).first; + ActionTypeId actionTypeId = ActionTypeId(m_actionList.at(i).first); QDateTime timestamp = m_actionList.at(i).second; QString actionName; foreach (const ActionType &at, deviceClass.actions()) { diff --git a/plugins/deviceplugins/mock/httpdaemon.h b/plugins/deviceplugins/mock/httpdaemon.h index 3a7dc3f1..a82e8bee 100644 --- a/plugins/deviceplugins/mock/httpdaemon.h +++ b/plugins/deviceplugins/mock/httpdaemon.h @@ -18,7 +18,7 @@ public: void incomingConnection(qintptr socket) override; - void actionExecuted(const QUuid&actionTypeId); + void actionExecuted(const ActionTypeId &actionTypeId); signals: void setState(const StateTypeId &stateTypeId, const QVariant &value); @@ -38,7 +38,7 @@ private: DevicePlugin *m_plugin; Device *m_device; - QList > m_actionList; + QList > m_actionList; }; #endif // HTTPDAEMON_H diff --git a/server/jsonrpc/devicehandler.cpp b/server/jsonrpc/devicehandler.cpp index 55b5285b..3fbcaf10 100644 --- a/server/jsonrpc/devicehandler.cpp +++ b/server/jsonrpc/devicehandler.cpp @@ -332,7 +332,7 @@ JsonReply* DeviceHandler::GetEventTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList eventList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid()); + DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const EventType &eventType, deviceClass.events()) { eventList.append(JsonTypes::packEventType(eventType)); } @@ -345,7 +345,7 @@ JsonReply* DeviceHandler::GetActionTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList actionList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid()); + DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const ActionType &actionType, deviceClass.actions()) { actionList.append(JsonTypes::packActionType(actionType)); } @@ -358,7 +358,7 @@ JsonReply* DeviceHandler::GetStateTypes(const QVariantMap ¶ms) const QVariantMap returns; QVariantList stateList; - DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid()); + DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); foreach (const StateType &stateType, deviceClass.states()) { stateList.append(JsonTypes::packStateType(stateType)); } @@ -376,12 +376,12 @@ JsonReply* DeviceHandler::GetStateValue(const QVariantMap ¶ms) const returns.insert("errorMessage", "No such device"); return createReply(returns); } - if (!device->hasState(params.value("stateTypeId").toUuid())) { + if (!device->hasState(StateTypeId(params.value("stateTypeId").toString()))) { returns.insert("success", false); returns.insert("errorMessage", QString("Device %1 %2 doesn't have such a state.").arg(device->name()).arg(device->id().toString())); return createReply(returns); } - QVariant stateValue = device->stateValue(params.value("stateTypeId").toUuid()); + QVariant stateValue = device->stateValue(StateTypeId(params.value("stateTypeId").toString())); returns.insert("success", true); returns.insert("errorMessage", ""); diff --git a/server/server.pro b/server/server.pro index 21d14f20..56e03be3 100644 --- a/server/server.pro +++ b/server/server.pro @@ -26,6 +26,10 @@ LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweatherm LIBS += -L../plugins/deviceplugins/lircd -lguh_devicepluginlircd boblight { - LIBS += -L../plugins/deviceplugins/boblight -lguh_devicepluginboblight -L/usr/local/lib/ -lboblight + xcompile { + LIBS += -L../plugins/deviceplugins/boblight -lguh_devicepluginboblight -lboblight + } else { + LIBS += -L../plugins/deviceplugins/boblight -lguh_devicepluginboblight -L/usr/local/lib/ -lboblight + } DEFINES += USE_BOBLIGHT }
NameType IDTimestamp