diff --git a/debian/guh-plugins.install b/debian/guh-plugins.install index 0d74a8da..61e3e285 100644 --- a/debian/guh-plugins.install +++ b/debian/guh-plugins.install @@ -10,3 +10,4 @@ usr/lib/guh/plugins/libguh_devicepluginphilipshue.so usr/lib/guh/plugins/libguh_devicepluginwakeonlan.so usr/lib/guh/plugins/libguh_devicepluginwemo.so usr/lib/guh/plugins/libguh_devicepluginwifidetector.so +usr/lib/guh/plugins/libguh_deviceplugingenericelements.so diff --git a/plugins/deviceplugins/deviceplugins.pro b/plugins/deviceplugins/deviceplugins.pro index 2cc5fe9d..752cd4d0 100644 --- a/plugins/deviceplugins/deviceplugins.pro +++ b/plugins/deviceplugins/deviceplugins.pro @@ -11,6 +11,7 @@ SUBDIRS += elro \ mailnotification \ philipshue \ lgsmarttv \ + genericelements \ diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.cpp b/plugins/deviceplugins/genericelements/deviceplugingenericelements.cpp new file mode 100644 index 00000000..d145149d --- /dev/null +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.cpp @@ -0,0 +1,55 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "deviceplugingenericelements.h" +#include "devicemanager.h" + +#include + +DeviceClassId toggleButtonDeviceClassId = DeviceClassId("c0f511f9-70f5-499b-bd70-2c0e9ddd68c4"); +ActionTypeId toggleButtonToggleActionTypeId = ActionTypeId("47bdc15a-b393-4dc2-801b-845420cdfda3"); +StateTypeId toggleButtonStatusStateTypeId = StateTypeId("b5e90567-54aa-49bd-a78a-3c19fb38aaf5"); + +DevicePluginGenericElements::DevicePluginGenericElements() +{ +} + +DeviceManager::HardwareResources DevicePluginGenericElements::requiredHardware() const +{ + return DeviceManager::HardwareResourceNone; +} + +DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device) +{ + if (device->deviceClassId() == toggleButtonDeviceClassId) { + device->setName(device->paramValue("name").toString() +" (Toggle Button)"); + return DeviceManager::DeviceSetupStatusSuccess; + } + return DeviceManager::DeviceSetupStatusFailure; +} + +DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action) +{ + if (device->deviceClassId() == toggleButtonDeviceClassId + && action.actionTypeId() == toggleButtonToggleActionTypeId) { + bool currentStatus = device->stateValue(toggleButtonStatusStateTypeId).toBool(); + device->setStateValue(toggleButtonStatusStateTypeId, !currentStatus); + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorDeviceClassNotFound; +} diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.h b/plugins/deviceplugins/genericelements/deviceplugingenericelements.h new file mode 100644 index 00000000..e5da1c73 --- /dev/null +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.h @@ -0,0 +1,43 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef DEVICEPLUGINGENERICELEMENTS_H +#define DEVICEPLUGINGENERICELEMENTS_H + +#include "plugin/deviceplugin.h" + +class DevicePluginGenericElements : public DevicePlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "deviceplugingenericelements.json") + Q_INTERFACES(DevicePlugin) + +public: + explicit DevicePluginGenericElements(); + + DeviceManager::HardwareResources requiredHardware() const override; + DeviceManager::DeviceSetupStatus setupDevice(Device *device) override; + + +public slots: + DeviceManager::DeviceError executeAction(Device *device, const Action &action) override; + +}; + +#endif // DEVICEPLUGINGENERICELEMENTS_H diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json new file mode 100644 index 00000000..63f8d0ef --- /dev/null +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json @@ -0,0 +1,36 @@ +{ + "name": "Generic Elements", + "id": "6e22161e-39b7-4416-8623-39e730721efb", + "vendors": [ + { + "name": "guh", + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "deviceClassId": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4", + "name": "Toggle Button", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "name", + "type": "QString" + } + ], + "stateTypes": [ + { + "id": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5", + "name": "status", + "type": "bool", + } + ], + "actionTypes": [ + { + "id": "47bdc15a-b393-4dc2-801b-845420cdfda3", + "name": "toggle" + } + ] + } + ] + } + ] +} diff --git a/plugins/deviceplugins/genericelements/genericelements.pro b/plugins/deviceplugins/genericelements/genericelements.pro new file mode 100644 index 00000000..f0742bba --- /dev/null +++ b/plugins/deviceplugins/genericelements/genericelements.pro @@ -0,0 +1,11 @@ +include(../../plugins.pri) + +TARGET = $$qtLibraryTarget(guh_deviceplugingenericelements) + +SOURCES += \ + deviceplugingenericelements.cpp + +HEADERS += \ + deviceplugingenericelements.h + + diff --git a/tests/scripts/cmdmgr.py b/tests/scripts/cmdmgr.py index 1ed70aa8..14d9cf6f 100755 --- a/tests/scripts/cmdmgr.py +++ b/tests/scripts/cmdmgr.py @@ -169,7 +169,6 @@ def select_stateOperator(): def read_paramDescriptors(paramTypes): params = [] for paramType in paramTypes: - print paramType['allowedValues'] paramValue = raw_input("Please enter value for parameter <%s> (type: %s): " % (paramType['name'], paramType['type'])) operator = select_valueOperator() param = {}