/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2014 Michael Zanetti * * Copyright (C) 2015 Simon Stuerz * * * * 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 DEVICEPLUGINPHILIPSHUE_H #define DEVICEPLUGINPHILIPSHUE_H #include "plugin/deviceplugin.h" #include "huebridge.h" #include "huelight.h" #include "hueremote.h" #include "pairinginfo.h" class QNetworkReply; class DevicePluginPhilipsHue: public DevicePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginphilipshue.json") Q_INTERFACES(DevicePlugin) public: explicit DevicePluginPhilipsHue(); DeviceManager::HardwareResources requiredHardware() const override; DeviceManager::DeviceSetupStatus setupDevice(Device *device) override; DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override; void deviceRemoved(Device *device) override; void upnpDiscoveryFinished(const QList &upnpDeviceDescriptorList) override; DeviceManager::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret) override; void networkManagerReplyReady(QNetworkReply *reply) override; public slots: DeviceManager::DeviceError executeAction(Device *device, const Action &action); private slots: void lightStateChanged(); void remoteStateChanged(); void onRemoteButtonEvent(const int &buttonCode); void onTimeout(); private: QTimer *m_timer; QHash m_pairingRequests; QHash m_informationRequests; QList m_unconfiguredBridges; QList m_unconfiguredLights; QList m_discoveryRequests; QHash m_lightRefreshRequests; QHash m_lightSetNameRequests; QHash m_bridgeRefreshRequests; QHash m_lightsRefreshRequests; QHash m_sensorsRefreshRequests; QHash m_bridgeLightsDiscoveryRequests; QHash m_bridgeSensorsDiscoveryRequests; QHash m_bridgeSearchDevicesRequests; QHash > m_asyncActions; QHash m_bridges; QHash m_lights; QHash m_remotes; void refreshLight(Device *device); void refreshBridge(Device *device); void refreshLights(HueBridge *bridge); void refreshSensors(HueBridge *bridge); void discoverBridgeDevices(HueBridge *bridge); void searchNewDevices(HueBridge *bridge); void setLightName(Device *device, const QString &name); void processNUpnpResponse(const QByteArray &data); void processBridgeLightDiscoveryResponse(Device *device, const QByteArray &data); void processBridgeSensorDiscoveryResponse(Device *device, const QByteArray &data); void processLightRefreshResponse(Device *device, const QByteArray &data); void processBridgeRefreshResponse(Device *device, const QByteArray &data); void processLightsRefreshResponse(Device *device, const QByteArray &data); void processSensorsRefreshResponse(Device *device, const QByteArray &data); void processSetNameResponse(Device *device, const QByteArray &data); void processPairingResponse(PairingInfo *pairingInfo, const QByteArray &data); void processInformationResponse(PairingInfo *pairingInfo, const QByteArray &data); void processActionResponse(Device *device, const ActionId actionId, const QByteArray &data); void bridgeReachableChanged(Device *device, const bool &reachable); bool bridgeAlreadyAdded(const QString &id); bool lightAlreadyAdded(const QString &uuid); bool sensorAlreadyAdded(const QString &uuid); int brightnessToPercentage(int brightness); int percentageToBrightness(int percentage); }; #endif // DEVICEPLUGINBOBLIGHT_H