-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfacehttp.h
96 lines (75 loc) · 2.56 KB
/
interfacehttp.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
This file is part of HTTP2OSC
Copyright (C) 2014-2015 — Buzzing Light
Development: Guillaume Jacquemin (http://www.buzzinglight.com)
This file was written by Guillaume Jacquemin.
HTTP2OSC is a 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, either version 3 of the License, or
any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INTERFACEHTTP_H
#define INTERFACEHTTP_H
#include <QWidget>
#include <QtGlobal>
#include <QDesktopServices>
#include <QDir>
#include <QBuffer>
#include <QDateTime>
#include <QApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QTcpServer>
#include <QTcpSocket>
#include "global.h"
#ifndef QT4
#include <QUrlQuery>
#endif
class InterfaceHttpServer : public QTcpServer, public SenderInterface {
Q_OBJECT
public:
InterfaceHttpServer(QObject *parent, quint16 port);
private:
QNetworkAccessManager *http;
public:
void setPort(quint16 port);
QString send(const QString &ip, quint16 port, const QString &destination, const QList<QVariant> &valeurs);
protected:
void incomingConnection(qintptr socketDescriptor);
private slots:
void readClient();
void discardClient();
void parse(QNetworkReply*);
signals:
void parseRequest(QNetworkReply*);
void parseSocket(QTcpSocket*);
};
class InterfaceHttp : public QObject, public SenderInterface {
Q_OBJECT
public:
explicit InterfaceHttp(QObject *parent = 0, quint16 port = 15556);
~InterfaceHttp();
private:
InterfaceHttpServer *httpServer;
public:
void setPort(quint16 port) {
httpServer->setPort(port);
}
QString send(const QString &ip, quint16 port, const QString &destination, const QList<QVariant> &valeurs) {
return httpServer->send(ip, port, destination, valeurs);
}
private slots:
void parseRequest(QNetworkReply*);
void parseSocket(QTcpSocket*);
signals:
void outgoingMessage(const QString &log);
void outgoingData(const QString &ip, quint16 port, const QString &destination, const QList<QVariant> &valeurs);
};
#endif // INTERFACEHTTP_H