/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* 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 DEVICEHANDLER_H
#define DEVICEHANDLER_H
#include "jsonhandler.h"
#include "devicemanager.h"
class DeviceHandler : public JsonHandler
{
Q_OBJECT
public:
explicit DeviceHandler(QObject *parent = 0);
QString name() const override;
Q_INVOKABLE JsonReply* GetSupportedVendors(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetSupportedDevices(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetDiscoveredDevices(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetPlugins(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetPluginConfiguration(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* SetPluginConfiguration(const QVariantMap ¶ms);
Q_INVOKABLE JsonReply* AddConfiguredDevice(const QVariantMap ¶ms);
Q_INVOKABLE JsonReply* PairDevice(const QVariantMap ¶ms);
Q_INVOKABLE JsonReply* ConfirmPairing(const QVariantMap ¶ms);
Q_INVOKABLE JsonReply* GetConfiguredDevices(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* RemoveConfiguredDevice(const QVariantMap ¶ms);
Q_INVOKABLE JsonReply* GetEventTypes(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetActionTypes(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetStateTypes(const QVariantMap ¶ms) const;
Q_INVOKABLE JsonReply* GetStateValue(const QVariantMap ¶ms) const;
signals:
void StateChanged(const QVariantMap ¶ms);
private slots:
void deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value);
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:
// A cache for async replies
mutable QHash m_discoverRequests;
mutable QHash m_asynDeviceAdditions;
mutable QHash m_asyncPairingRequests;
};
#endif // DEVICEHANDLER_H