/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 GUHCORE_H #define GUHCORE_H #include "rule.h" #include "types/event.h" #include "plugin/deviceclass.h" #include "plugin/devicedescriptor.h" #include "devicemanager.h" #include "ruleengine.h" #include class JsonRPCServer; class Device; class GuhCore : public QObject { Q_OBJECT public: static GuhCore* instance(); ~GuhCore(); // Used for testing void destroy(); QList plugins() const; QPair setPluginConfig(const PluginId &pluginId, const QList params); // Device handling QList supportedVendors() const; QList supportedDevices(const VendorId &vendorId = VendorId()) const; DeviceClass findDeviceClass(const DeviceClassId &deviceClassId) const; DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList ¶ms); QPair addConfiguredDevice(const DeviceClassId &deviceClassId, const QList ¶ms, const DeviceId &newId); QPair addConfiguredDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &newId); QList configuredDevices() const; Device *findConfiguredDevice(const DeviceId &deviceId) const; QList findConfiguredDevices(const DeviceClassId &deviceClassId) const; QPair removeConfiguredDevice(const DeviceId &deviceId, const QHash &removePolicyList); QPair pairDevice(const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId); QPair pairDevice(const DeviceClassId &deviceClassId, const QList ¶ms); QPair confirmPairing(const QUuid &pairingTransactionId, const QString &secret = QString()); QPair executeAction(const Action &action); QList rules() const; QList ruleIds() const; Rule findRule(const RuleId &ruleId); RuleEngine::RuleError addRule(const RuleId &id, const QList &eventDescriptorList, const QList &actionList); RuleEngine::RuleError removeRule(const RuleId &id); QList findRules(const DeviceId &deviceId); signals: void eventTriggered(const Event &event); void deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value); void actionExecuted(const ActionId &id, DeviceManager::DeviceError status, const QString &errorMessage); void devicesDiscovered(const DeviceClassId &deviceClassId, const QList deviceDescriptors); void deviceSetupFinished(Device *device, DeviceManager::DeviceError status); void pairingFinished(const QUuid &pairingTransactionId, DeviceManager::DeviceError status, const QString &errorMessage, const DeviceId &deviceId); private: RuleEngine *ruleEngine() const; DeviceManager* deviceManager() const; explicit GuhCore(QObject *parent = 0); static GuhCore *s_instance; JsonRPCServer *m_jsonServer; DeviceManager *m_deviceManager; RuleEngine *m_ruleEngine; private slots: void gotEvent(const Event &event); friend class GuhTestBase; }; #endif // GUHCORE_H