18
18
#include < stdint.h>
19
19
#include < queue>
20
20
#include < memory>
21
- #if QT_VERSION < 0x050000
22
- #include < QHttpRequestHeader>
23
- #endif
24
21
#include < sqlite3.h>
25
22
#include < deconz.h>
26
23
#include " device.h"
31
28
#include " event_emitter.h"
32
29
#include " green_power.h"
33
30
#include " resource.h"
31
+ #include " rest_api.h"
34
32
#include " rest_node_base.h"
35
33
#include " light_node.h"
36
34
#include " group.h"
37
35
#include " group_info.h"
38
- #include " ias_zone.h"
39
36
#include " scene.h"
40
37
#include " sensor.h"
41
38
#include " resourcelinks.h"
42
39
#include " rule.h"
43
40
#include " bindings.h"
44
- #include < math.h>
45
41
#include " websocket_server.h"
46
- #include " tuya.h"
47
42
48
43
// enable domain specific string literals
49
44
using namespace deCONZ ::literals;
@@ -53,35 +48,6 @@ using namespace deCONZ::literals;
53
48
#define ARCH_ARM
54
49
#endif
55
50
56
- /* ! JSON generic error message codes */
57
- #define ERR_UNAUTHORIZED_USER 1
58
- #define ERR_INVALID_JSON 2
59
- #define ERR_RESOURCE_NOT_AVAILABLE 3
60
- #define ERR_METHOD_NOT_AVAILABLE 4
61
- #define ERR_MISSING_PARAMETER 5
62
- #define ERR_PARAMETER_NOT_AVAILABLE 6
63
- #define ERR_INVALID_VALUE 7
64
- #define ERR_PARAMETER_NOT_MODIFIABLE 8
65
- #define ERR_TOO_MANY_ITEMS 11
66
- #define ERR_DUPLICATE_EXIST 100 // de extension
67
- #define ERR_NOT_ALLOWED_SENSOR_TYPE 501
68
- #define ERR_SENSOR_LIST_FULL 502
69
- #define ERR_RULE_ENGINE_FULL 601
70
- #define ERR_CONDITION_ERROR 607
71
- #define ERR_ACTION_ERROR 608
72
- #define ERR_INTERNAL_ERROR 901
73
-
74
- #define ERR_NOT_CONNECTED 950 // de extension
75
- #define ERR_BRIDGE_BUSY 951 // de extension
76
-
77
- #define ERR_LINK_BUTTON_NOT_PRESSED 101
78
- #define ERR_DEVICE_OFF 201
79
- #define ERR_DEVICE_NOT_REACHABLE 202
80
- #define ERR_BRIDGE_GROUP_TABLE_FULL 301
81
- #define ERR_DEVICE_GROUP_TABLE_FULL 302
82
-
83
- #define ERR_DEVICE_SCENES_TABLE_FULL 402 // de extension
84
-
85
51
#define IDLE_TIMER_INTERVAL 1000
86
52
#define IDLE_LIMIT 30
87
53
#define IDLE_READ_LIMIT 120
@@ -428,10 +394,6 @@ using namespace deCONZ::literals;
428
394
#define MAX_RULE_NAME_LENGTH 64
429
395
#define MAX_SENSOR_NAME_LENGTH 32
430
396
431
- // REST API return codes
432
- #define REQ_READY_SEND 0
433
- #define REQ_NOT_HANDLED -1
434
-
435
397
// Special application return codes
436
398
#define APP_RET_UPDATE 40
437
399
#define APP_RET_RESTART_APP 41
@@ -489,9 +451,6 @@ void getTime(quint32 *time, qint32 *tz, quint32 *dstStart, quint32 *dstEnd, qint
489
451
int getFreeSensorId (); // TODO needs to be part of a Database class
490
452
int getFreeLightId (); // TODO needs to be part of a Database class
491
453
492
- // REST API common
493
- QVariantMap errorToMap (int id, const QString &ressource, const QString &description);
494
-
495
454
extern const quint64 macPrefixMask;
496
455
497
456
extern const quint64 celMacPrefix;
@@ -704,24 +663,6 @@ inline bool checkMacAndVendor(const deCONZ::Node *node, quint16 vendor)
704
663
quint8 zclNextSequenceNumber ();
705
664
const deCONZ::Node *getCoreNode (uint64_t extAddress);
706
665
707
- // HTTP status codes
708
- extern const char *HttpStatusOk;
709
- extern const char *HttpStatusAccepted;
710
- extern const char *HttpStatusNotModified;
711
- extern const char *HttpStatusUnauthorized;
712
- extern const char *HttpStatusBadRequest;
713
- extern const char *HttpStatusForbidden;
714
- extern const char *HttpStatusNotFound;
715
- extern const char *HttpStatusNotImplemented;
716
- extern const char *HttpStatusServiceUnavailable;
717
- extern const char *HttpContentHtml;
718
- extern const char *HttpContentCss;
719
- extern const char *HttpContentJson;
720
- extern const char *HttpContentJS;
721
- extern const char *HttpContentPNG;
722
- extern const char *HttpContentJPG;
723
- extern const char *HttpContentSVG;
724
-
725
666
// Forward declarations
726
667
class DeviceDescriptions ;
727
668
class DeviceWidget ;
@@ -981,67 +922,6 @@ class ApiAuth
981
922
QString useragent;
982
923
};
983
924
984
- enum ApiVersion
985
- {
986
- ApiVersion_1, // !< common version 1.0
987
- ApiVersion_1_DDEL, // !< version 1.0, "Accept: application/vnd.ddel.v1"
988
- ApiVersion_1_1_DDEL, // !< version 1.1, "Accept: application/vnd.ddel.v1.1"
989
- ApiVersion_2_DDEL, // !< version 2.0, "Accept: application/vnd.ddel.v2"
990
- ApiVersion_3_DDEL // !< version 3.0, "Accept: application/vnd.ddel.v3"
991
- };
992
-
993
- enum ApiAuthorisation
994
- {
995
- ApiAuthNone,
996
- ApiAuthLocal,
997
- ApiAuthInternal,
998
- ApiAuthFull
999
- };
1000
-
1001
- enum ApiMode
1002
- {
1003
- ApiModeNormal,
1004
- ApiModeStrict,
1005
- ApiModeEcho,
1006
- ApiModeHue
1007
- };
1008
-
1009
- /* ! \class ApiRequest
1010
-
1011
- Helper to simplify HTTP REST request handling.
1012
- */
1013
- class ApiRequest
1014
- {
1015
- public:
1016
- ApiRequest (const QHttpRequestHeader &h, const QStringList &p, QTcpSocket *s, const QString &c);
1017
- QString apikey () const ;
1018
- ApiVersion apiVersion () const { return version; }
1019
-
1020
- const QHttpRequestHeader &hdr;
1021
- const QStringList &path;
1022
- QTcpSocket *sock;
1023
- QString content;
1024
- ApiVersion version;
1025
- ApiAuthorisation auth;
1026
- ApiMode mode;
1027
- };
1028
-
1029
- /* ! \class ApiResponse
1030
-
1031
- Helper to simplify HTTP REST request handling.
1032
- */
1033
- class ApiResponse
1034
- {
1035
- public:
1036
- QString etag;
1037
- const char *httpStatus;
1038
- const char *contentType;
1039
- QList<QPair<QString, QString> > hdrFields; // extra header fields
1040
- QVariantMap map; // json content
1041
- QVariantList list; // json content
1042
- QString str; // json string
1043
- };
1044
-
1045
925
/* ! \class ApiConfig
1046
926
1047
927
Provide config to the resource system.
0 commit comments