Changeset View
Changeset View
Standalone View
Standalone View
plugins/htmlinterface/webserver.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef KHTMLINTERFACEWEBSERVER_H | 21 | #ifndef KHTMLINTERFACEWEBSERVER_H | ||
22 | #define KHTMLINTERFACEWEBSERVER_H | 22 | #define KHTMLINTERFACEWEBSERVER_H | ||
23 | 23 | | |||
24 | #include <QtGlobal> | 24 | #include <QtGlobal> | ||
25 | #include <QObject> | 25 | #include <QObject> | ||
26 | 26 | | |||
27 | #include <interfaces/coreinterface.h> | 27 | #include <interfaces/coreinterface.h> | ||
28 | #include <microhttpd.h> | ||||
28 | #include "torrentlistgenerator.h" | 29 | #include "torrentlistgenerator.h" | ||
29 | 30 | | |||
30 | #include "mongoose.h" | | |||
31 | | ||||
32 | namespace kt | 31 | namespace kt | ||
33 | { | 32 | { | ||
34 | class WebServer : public QObject | 33 | class WebServer : public QObject | ||
35 | { | 34 | { | ||
36 | Q_OBJECT | 35 | Q_OBJECT | ||
37 | public: | 36 | public: | ||
38 | WebServer(CoreInterface * core); | 37 | WebServer(CoreInterface * core); | ||
39 | ~WebServer(); | 38 | ~WebServer(); | ||
40 | public slots: | 39 | public slots: | ||
41 | void process(); | 40 | void process(); | ||
42 | static void httpeventhandler(struct mg_connection * c, int ev, void * ev_data); | | |||
43 | signals: | 41 | signals: | ||
44 | void finished(); | 42 | void finished(); | ||
45 | void error(QString err); | 43 | void error(QString err); | ||
46 | private: | 44 | private: | ||
47 | struct mg_mgr mgr; | 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; | ||||
48 | CoreInterface * core; | 50 | CoreInterface * core; | ||
49 | static TorrentListGenerator * listGenerator; | 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); | ||||
50 | }; | 56 | }; | ||
51 | } | 57 | } | ||
52 | 58 | | |||
53 | #endif | 59 | #endif |