From f04257ab33591f94e3ed4c55c3f837a0af5c1b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Sun, 21 Feb 2016 11:26:23 +0100 Subject: [PATCH] remove boblight from project tree (is now a separat repository) --- plugins/deviceplugins/boblight/bobclient.cpp | 132 ---------------- plugins/deviceplugins/boblight/bobclient.h | 61 -------- plugins/deviceplugins/boblight/boblight.pro | 17 --- .../boblight/devicepluginboblight.cpp | 142 ------------------ .../boblight/devicepluginboblight.h | 61 -------- .../boblight/devicepluginboblight.json | 29 ---- plugins/deviceplugins/deviceplugins.pro | 10 -- plugins/deviceplugins/lircd/lircd.pro | 3 - server/server.pro | 9 -- 9 files changed, 464 deletions(-) delete mode 100644 plugins/deviceplugins/boblight/bobclient.cpp delete mode 100644 plugins/deviceplugins/boblight/bobclient.h delete mode 100644 plugins/deviceplugins/boblight/boblight.pro delete mode 100644 plugins/deviceplugins/boblight/devicepluginboblight.cpp delete mode 100644 plugins/deviceplugins/boblight/devicepluginboblight.h delete mode 100644 plugins/deviceplugins/boblight/devicepluginboblight.json diff --git a/plugins/deviceplugins/boblight/bobclient.cpp b/plugins/deviceplugins/boblight/bobclient.cpp deleted file mode 100644 index 8d41fa10..00000000 --- a/plugins/deviceplugins/boblight/bobclient.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * - * Copyright (C) 2015 Simon Stuerz * - * Copyright (C) 2014 Michael Zanetti * - * * - * 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 "bobclient.h" -#include "extern-plugininfo.h" - -#include "libboblight/boblight.h" - -#include - -BobClient::BobClient(QObject *parent) : - QObject(parent), - m_connected(false), - m_port(-1) -{ - - m_lastSyncTime = QTime::currentTime(); - - m_resyncTimer.setInterval(200); - m_resyncTimer.setSingleShot(true); - QObject::connect(&m_resyncTimer, SIGNAL(timeout()), SLOT(sync())); -} - -bool BobClient::connect(const QString &hostname, int port) -{ - qCDebug(dcBoblight) << "Connecting to boblightd\n"; - m_boblight = boblight_init(); - - //try to connect, if we can't then bitch to stderr and destroy boblight - if (!boblight_connect(m_boblight, hostname.toLatin1().data(), port, 5000000) || - !boblight_setpriority(m_boblight, 1)) - { - qCWarning(dcBoblight) << "Failed to connect:" << boblight_geterror(m_boblight); - boblight_destroy(m_boblight); - m_connected = false; - return false; - } - qCDebug(dcBoblight) << "Connection to boblightd opened\n"; - m_hostname = hostname; - m_port = port; - m_connected = true; - return true; -} - -bool BobClient::connected() const -{ - return m_connected; -} - -void BobClient::setPriority(int priority) -{ - qCDebug(dcBoblight) << "setting new priority:" << priority; - qCDebug(dcBoblight) << "setting priority to" << priority << boblight_setpriority(m_boblight, priority); -} - -void BobClient::setColor(int channel, QColor color) -{ - if(channel == -1) { - for(int i = 0; i < lightsCount(); ++i) { - setColor(i, color); - } - } else { - m_colors[channel] = color; - qCDebug(dcBoblight) << "set channel" << channel << "to color" << color; - } -} - -void BobClient::sync() -{ - if(!m_connected) { - qCWarning(dcBoblight) << "Not connected to boblight. Cannot sync"; - return; - } - if(m_lastSyncTime.addMSecs(50) > QTime::currentTime()) { - if(!m_resyncTimer.isActive()) { - m_resyncTimer.start(); - } - return; - } - qCDebug(dcBoblight) << "syncing"; - m_lastSyncTime = QTime::currentTime(); - - for(int i = 0; i < lightsCount(); ++i) { - //load the color into int array - int rgb[3]; - rgb[0] = m_colors[i].red() * m_colors[i].alphaF(); - rgb[1] = m_colors[i].green() * m_colors[i].alphaF(); - rgb[2] = m_colors[i].blue() * m_colors[i].alphaF(); - qCDebug(dcBoblight) << "set color" << rgb[0] << rgb[1] << rgb[2]; - - //set all lights to the color we want and send it - boblight_addpixel(m_boblight, i, rgb); - - } - - if (!boblight_sendrgb(m_boblight, 1, NULL)) //some error happened, probably connection broken, so bitch and try again - { - qCWarning(dcBoblight) << "Boblight connection error:" << boblight_geterror(m_boblight); - boblight_destroy(m_boblight); - m_connected = false; - connect(m_hostname, m_port); - } -} - -int BobClient::lightsCount() -{ - return boblight_getnrlights(m_boblight); -} - -QColor BobClient::currentColor(int channel) -{ - return m_colors[channel]; -} diff --git a/plugins/deviceplugins/boblight/bobclient.h b/plugins/deviceplugins/boblight/bobclient.h deleted file mode 100644 index be375dff..00000000 --- a/plugins/deviceplugins/boblight/bobclient.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * - * Copyright (C) 2015 Simon Stuerz * - * Copyright (C) 2014 Michael Zanetti * - * * - * 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 BOBCLIENT_H -#define BOBCLIENT_H - -#include -#include -#include -#include -#include - -class BobClient : public QObject -{ - Q_OBJECT -public: - explicit BobClient(QObject *parent = 0); - bool connect(const QString &hostname, int port); - bool connected() const; - - int lightsCount(); - QColor currentColor(int channel); - - void setPriority(int priority); - -signals: - -public slots: - void setColor(int channel, QColor color); - void sync(); - -private: - QMap m_colors; //channel, color - void *m_boblight; - bool m_connected; - QString m_hostname; - int m_port; - - QTime m_lastSyncTime; - QTimer m_resyncTimer; -}; - -#endif // BOBCLIENT_H diff --git a/plugins/deviceplugins/boblight/boblight.pro b/plugins/deviceplugins/boblight/boblight.pro deleted file mode 100644 index bc4ea13f..00000000 --- a/plugins/deviceplugins/boblight/boblight.pro +++ /dev/null @@ -1,17 +0,0 @@ -include(../../plugins.pri) - -TARGET = $$qtLibraryTarget(guh_devicepluginboblight) - -INCLUDEPATH += /usr/local/include/ -LIBS += -L/usr/local/lib/libboblight.a - -SOURCES += \ - devicepluginboblight.cpp \ - bobclient.cpp \ - -HEADERS += \ - devicepluginboblight.h \ - bobclient.h \ - - - diff --git a/plugins/deviceplugins/boblight/devicepluginboblight.cpp b/plugins/deviceplugins/boblight/devicepluginboblight.cpp deleted file mode 100644 index 47e98326..00000000 --- a/plugins/deviceplugins/boblight/devicepluginboblight.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * - * Copyright (C) 2015 Simon Stuerz * - * Copyright (C) 2014 Michael Zanetti * - * * - * 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 . * - * * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*! - \page boblight.html - \title Boblight - - \ingroup plugins - \ingroup network - - This plugin allows to communicate with a \l{https://code.google.com/p/boblight/}{boblight} server - running on localhost:19333. If a boblight server is running ,the configured light devices from the server will - appear automatically in guh. - - \chapter Plugin properties - Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses} - and \l{Vendor}{Vendors} of this \l{DevicePlugin}. - - Each \l{DeviceClass} has a list of \l{ParamType}{paramTypes}, \l{ActionType}{actionTypes}, \l{StateType}{stateTypes} - and \l{EventType}{eventTypes}. The \l{DeviceClass::CreateMethod}{createMethods} parameter describes how the \l{Device} - will be created in the system. A device can have more than one \l{DeviceClass::CreateMethod}{CreateMethod}. - The \l{DeviceClass::SetupMethod}{setupMethod} describes the setup method of the \l{Device}. - The detailed implementation of each \l{DeviceClass} can be found in the source code. - - \note If a \l{StateType} has the parameter \tt{"writable": {...}}, an \l{ActionType} with the same uuid and \l{ParamType}{ParamTypes} - will be created automatically. - - \quotefile plugins/deviceplugins/boblight/devicepluginboblight.json -*/ - -#include "devicepluginboblight.h" - -#include "plugin/device.h" -#include "devicemanager.h" - -#include "bobclient.h" -#include "plugininfo.h" - -#include -#include - -DevicePluginBoblight::DevicePluginBoblight() -{ - m_bobClient = new BobClient(this); - connect(this, &DevicePlugin::configValueChanged, this, &DevicePluginBoblight::connectToBoblight); -} - -DeviceManager::HardwareResources DevicePluginBoblight::requiredHardware() const -{ - return DeviceManager::HardwareResourceNone; -} - -void DevicePluginBoblight::startMonitoringAutoDevices() -{ - if (!m_bobClient->connected()) { - return; - } - - QList loadedDevices = deviceManager()->findConfiguredDevices(boblightDeviceClassId); - - QList deviceDescriptorList; - for (int i = loadedDevices.count(); i < m_bobClient->lightsCount(); i++) { - DeviceDescriptor deviceDescriptor(boblightDeviceClassId, "Boblight Channel " + QString::number(i)); - ParamList params; - Param param("channel"); - param.setValue(i); - params.append(param); - deviceDescriptor.setParams(params); - deviceDescriptorList.append(deviceDescriptor); - } - emit autoDevicesAppeared(boblightDeviceClassId, deviceDescriptorList); -} - -QPair DevicePluginBoblight::setupDevice(Device *device) -{ - if (!m_bobClient->connected()) { - return reportDeviceSetup(DeviceManager::DeviceSetupStatusFailure, "Cannot connect to Boblight"); - } - - m_bobClient->currentColor(device->paramValue("channel").toInt()); - return reportDeviceSetup(); -} - -QString DevicePluginBoblight::pluginName() const -{ - return "Boblight client"; -} - -PluginId DevicePluginBoblight::pluginId() const -{ - return boblightPluginUuid; -} - -QList DevicePluginBoblight::configurationDescription() const -{ - QList params; - params.append(ParamType("boblighthost", QVariant::String, "localhost")); - params.append(ParamType("boblightport", QVariant::String, "19333")); - return params; -} - -QPair DevicePluginBoblight::executeAction(Device *device, const Action &action) -{ - if (!m_bobClient->connected()) { - return report(DeviceManager::DeviceErrorSetupFailed, device->id().toString()); - } - QColor newColor = action.param("color").value().value(); - if (!newColor.isValid()) { - return report(DeviceManager::DeviceErrorActionParameterError, "color"); - } - qCDebug(dcBoblight) << "executing boblight action" << newColor; - m_bobClient->setColor(device->paramValue("channel").toInt(), newColor); - m_bobClient->sync(); - - device->setStateValue(colorStateTypeId, newColor); - return report(); -} - -void DevicePluginBoblight::connectToBoblight() -{ - if (configValue("boblighthost").isValid() && configValue("boblightport").isValid()) { - m_bobClient->connect(configValue("boblighthost").toString(), configValue("boblightport").toInt()); - } -} diff --git a/plugins/deviceplugins/boblight/devicepluginboblight.h b/plugins/deviceplugins/boblight/devicepluginboblight.h deleted file mode 100644 index 38af0bb1..00000000 --- a/plugins/deviceplugins/boblight/devicepluginboblight.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * - * Copyright (C) 2015 Simon Stuerz * - * Copyright (C) 2014 Michael Zanetti * - * * - * 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 DEVICEPLUGINBOBLIGHT_H -#define DEVICEPLUGINBOBLIGHT_H - -#include "plugin/deviceplugin.h" - -#include - -class BobClient; - -class DevicePluginBoblight : public DevicePlugin -{ - Q_OBJECT - - Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginboblight.json") - Q_INTERFACES(DevicePlugin) - -public: - explicit DevicePluginBoblight(); - - DeviceManager::HardwareResources requiredHardware() const override; - - void startMonitoringAutoDevices() override; - QPair setupDevice(Device *device) override; - - QString pluginName() const override; - PluginId pluginId() const override; - - QList configurationDescription() const override; - -public slots: - QPair executeAction(Device *device, const Action &action); - -private slots: - void connectToBoblight(); - -private: - BobClient *m_bobClient; -}; - -#endif // DEVICEPLUGINBOBLIGHT_H diff --git a/plugins/deviceplugins/boblight/devicepluginboblight.json b/plugins/deviceplugins/boblight/devicepluginboblight.json deleted file mode 100644 index d3331f5e..00000000 --- a/plugins/deviceplugins/boblight/devicepluginboblight.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "id": "8c5e8d4c-b5ed-4bfe-b30d-35c2790ec100", - "name": "Boblight", - "idName": "Boblight", - "vendors": [ - { - "name": "Boblight", - "id": "e1647872-c0f5-4680-b49b-3924e5b54dcd", - "deviceClasses": [ - { - "deviceClassId": "1647c61c-db14-461e-8060-8a3533d5d92f", - "idName": "boblight", - "name": "Boblight", - "createMethods": ["auto"], - "stateTypes": [ - { - "id": "97ec80cd-43a9-40fa-93b7-d1580043d981", - "idName": "color", - "name": "color", - "type": "QColor", - "defaultValue": "#000000", - "writable": {} - } - ] - } - ] - } - ] -} diff --git a/plugins/deviceplugins/deviceplugins.pro b/plugins/deviceplugins/deviceplugins.pro index 3ee36757..0e43389b 100644 --- a/plugins/deviceplugins/deviceplugins.pro +++ b/plugins/deviceplugins/deviceplugins.pro @@ -22,13 +22,3 @@ SUBDIRS += elro \ awattar \ netatmo \ #osdomotics \ - - - -boblight { - SUBDIRS += boblight -} - -contains(DEFINES, BLUETOOTH_LE) { - SUBDIRS += elgato -} diff --git a/plugins/deviceplugins/lircd/lircd.pro b/plugins/deviceplugins/lircd/lircd.pro index 293c24a6..f25a505f 100644 --- a/plugins/deviceplugins/lircd/lircd.pro +++ b/plugins/deviceplugins/lircd/lircd.pro @@ -4,9 +4,6 @@ TARGET = $$qtLibraryTarget(guh_devicepluginlircd) QT += network -#INCLUDEPATH += /usr/local/include/ -#LIBS += -L/usr/local/lib/libboblight.a - SOURCES += \ devicepluginlircd.cpp \ lircdclient.cpp \ diff --git a/server/server.pro b/server/server.pro index c8144221..39ae6c04 100644 --- a/server/server.pro +++ b/server/server.pro @@ -19,15 +19,6 @@ SOURCES += main.cpp \ guhservice.cpp \ guhapplication.cpp -boblight { - 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 -} - HEADERS += \ guhservice.h \ guhapplication.h