mirror of https://github.com/nymea/nymea.git
96 lines
4.5 KiB
C++
96 lines
4.5 KiB
C++
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* *
|
|
* Copyright (C) 2015 Simon Stürz <simon.stuerz@guh.io> *
|
|
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
|
|
* *
|
|
* 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 <http://www.gnu.org/licenses/>. *
|
|
* *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#ifndef DEVICEHANDLER_H
|
|
#define DEVICEHANDLER_H
|
|
|
|
#include "jsonhandler.h"
|
|
#include "devicemanager.h"
|
|
|
|
namespace nymeaserver {
|
|
|
|
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 *ReconfigureDevice(const QVariantMap ¶ms);
|
|
Q_INVOKABLE JsonReply *EditDevice(const QVariantMap ¶ms);
|
|
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;
|
|
Q_INVOKABLE JsonReply *GetStateValues(const QVariantMap ¶ms) const;
|
|
|
|
signals:
|
|
void PluginConfigurationChanged(const QVariantMap ¶ms);
|
|
void StateChanged(const QVariantMap ¶ms);
|
|
void DeviceRemoved(const QVariantMap ¶ms);
|
|
void DeviceAdded(const QVariantMap ¶ms);
|
|
void DeviceChanged(const QVariantMap ¶ms);
|
|
|
|
private slots:
|
|
void pluginConfigChanged(const PluginId &id, const ParamList &config);
|
|
|
|
void deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value);
|
|
|
|
void deviceRemovedNotification(const QUuid &deviceId);
|
|
|
|
void deviceAddedNotification(Device *device);
|
|
|
|
void deviceChangedNotification(Device *device);
|
|
|
|
void devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors);
|
|
|
|
void deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
|
|
|
void deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
|
|
|
|
void pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
|
|
|
private:
|
|
// A cache for async replies
|
|
mutable QHash<DeviceClassId, JsonReply*> m_discoverRequests;
|
|
mutable QHash<DeviceId, JsonReply*> m_asynDeviceAdditions;
|
|
mutable QHash<DeviceId, JsonReply*> m_asynDeviceEditAdditions;
|
|
mutable QHash<QUuid, JsonReply*> m_asyncPairingRequests;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // DEVICEHANDLER_H
|