forked from dresden-elektronik/deconz-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
de_web_plugin.h
77 lines (65 loc) · 1.87 KB
/
de_web_plugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (c) 2017 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*
*/
#ifndef REST_PLUGIN_H
#define REST_PLUGIN_H
#include <list>
#include <QObject>
#include <deconz.h>
class DeRestWidget;
class DeRestPluginPrivate;
#if DECONZ_LIB_VERSION < 0x010500
#error "The REST plugin requires at least deCONZ library version 1.5.0."
#endif
class DeRestPlugin : public QObject,
public deCONZ::NodeInterface,
public deCONZ::HttpClientHandler
{
Q_OBJECT
Q_INTERFACES(deCONZ::NodeInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.dresden-elektronik.DeRestPlugin")
#endif
public:
enum State
{
StateOff,
StateIdle
};
explicit DeRestPlugin(QObject *parent = 0);
~DeRestPlugin();
// node interface
const char *name();
bool hasFeature(Features feature);
QWidget *createWidget();
QDialog *createDialog();
// http client handler interface
bool isHttpTarget(const QHttpRequestHeader &hdr);
int handleHttpRequest(const QHttpRequestHeader &hdr, QTcpSocket *sock);
void clientGone(QTcpSocket *sock);
bool pluginActive() const;
public Q_SLOTS:
void idleTimerFired();
void refreshAll();
void startZclAttributeTimer(int delay);
void stopZclAttributeTimer();
void checkZclAttributeTimerFired();
void appAboutToQuit();
bool startUpdateFirmware();
const QString &getNodeName(quint64 extAddress) const;
Q_SIGNALS:
void nodeUpdated(quint64 extAddress, QString key, QString value);
private:
QTimer *m_idleTimer;
QTimer *m_readAttributesTimer;
State m_state;
DeRestWidget *m_w;
DeRestPluginPrivate *d;
};
#endif // REST_PLUGIN_H