Changeset View
Changeset View
Standalone View
Standalone View
plugins/htmlinterface/webserver.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 by Emmanuel Eytan * | ||||
3 | * eje211@gmail.com * | ||||
4 | * * | ||||
5 | * This program is free software; you can redistribute it and/or modify * | ||||
6 | * it under the terms of the GNU General Public License as published by * | ||||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||||
8 | * (at your option) any later version. * | ||||
9 | * * | ||||
10 | * This program is distributed in the hope that it will be useful, * | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
13 | * GNU General Public License for more details. * | ||||
14 | * * | ||||
15 | * You should have received a copy of the GNU General Public License * | ||||
16 | * along with this program; if not, write to the * | ||||
17 | * Free Software Foundation, Inc., * | ||||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||||
19 | ***************************************************************************/ | ||||
20 | | ||||
21 | #ifndef KHTMLINTERFACEWEBSERVER_H | ||||
22 | #define KHTMLINTERFACEWEBSERVER_H | ||||
23 | | ||||
24 | #include <QtGlobal> | ||||
25 | #include <QObject> | ||||
26 | | ||||
27 | #include <interfaces/coreinterface.h> | ||||
28 | #include <microhttpd.h> | ||||
29 | #include "torrentlistgenerator.h" | ||||
30 | | ||||
31 | namespace kt | ||||
32 | { | ||||
33 | class WebServer : public QObject | ||||
34 | { | ||||
35 | Q_OBJECT | ||||
36 | public: | ||||
37 | WebServer(CoreInterface * core); | ||||
38 | ~WebServer(); | ||||
39 | public slots: | ||||
40 | void process(); | ||||
41 | signals: | ||||
42 | void finished(); | ||||
43 | void error(QString err); | ||||
44 | private: | ||||
45 | static int answer_to_connection(void *cls, struct MHD_Connection *connection, | ||||
46 | const char *url, const char *method, | ||||
47 | const char *version, const char *upload_data, | ||||
48 | size_t *upload_data_size, void **con_cls); | ||||
49 | struct MHD_Daemon *daemon; | ||||
50 | CoreInterface * core; | ||||
51 | static TorrentListGenerator * listGenerator; | ||||
52 | static QString sessionToken; | ||||
53 | static const char * makeCookie(); | ||||
54 | static const char * cookie; | ||||
55 | static bool checkForToken(MHD_Connection * connection); | ||||
56 | }; | ||||
57 | } | ||||
58 | | ||||
59 | #endif |