Remoto - VFS: VFS_httpd_browser.h Source File
Remoto - VFS
VFS_httpd_browser.h
Go to the documentation of this file.
1 
2 #ifndef VFS_HTTPD_BROWSER_H
3 #define VFS_HTTPD_BROWSER_H
4 
5 #include <QHash>
6 #include <QUrl>
7 #include <QThread>
8 
9 #include <QJsonDocument>
10 
12 
14 {
15  Q_OBJECT
16 
17  public:
18  Q_INVOKABLE VFS_httpd_browser(QString dataRootPath, quint16 port, QHostAddress addr=QHostAddress::Any, bool ssl=false, QString sslCertPath="", QString sslKeyPath="");
19  virtual ~VFS_httpd_browser();
20 
21  protected:
22  QString _dataRootPath;
24  VFS_node *dataRoot();
25 
26  private:
27 
28  protected slots:
29  virtual void handle(QHttpRequest *req, QHttpResponse *resp);
30 
31 };
32 
34 {
35  Q_OBJECT
36 
37  public:
38  VFS_httpd_browser_responder(QHttpRequest *req, QHttpResponse *resp, VFS_node *node, quint16 port);
40 
41  virtual void respond();
42 
44  QString _mode;
45  QJsonDocument _data;
46 
47  bool _done;
48 
49  protected:
50  bool _process;
51 
53  quint16 _port;
54 
55  virtual void validatePath(QUrl url);
56 
57  QByteArray fetchResponse();
58  QByteArray lsDir();
59 
60  QByteArray processRHTML(QByteArray page);
61 
62  private:
63  QJsonValue getSystemValue(QString which);
64 
65  protected slots:
66  void done();
67 };
68 
70 {
71  public:
74 
75  virtual void execute();
76 
77  protected:
79 };
80 
81 #endif //VFS_HTTPD_BROWSER_H
82 
A subclass of VFS_request.
virtual void execute()
Execute the request now that it has been satisfied.
VFS_httpd_browser_responder * _m_responder
The responder object used during execute()
VFS_httpd_browser_request(VFS_request::requestType type, VFS_node *t, VFS_httpd_browser_responder *r)
A subclass of VFS_httpd_responder.
QJsonValue getSystemValue(QString which)
Return information about the system running VFS.
VFS_node * _node
The VFS_node that is _dataRoot. This is unused.
virtual void respond()
based on http status, write page contents or an error to the responder
QByteArray fetchResponse()
Actually fetch and/or prep the response data.
QByteArray lsDir()
Convert an incoming json object to an html <ul> for display.
virtual void validatePath(QUrl url)
Based on the incoming url, decide what work needs to be done.
QJsonDocument _data
The response data, populated after a VFS_request is complete, or immediately if not asynchronous.
void done()
Mark the responder as _done, and schedule a deletion with deleteLater().
QByteArray processRHTML(QByteArray page)
Detokenize an .rhtml file.
QString _mode
either browse, report, command, or file. Used in fetchFile()
bool _process
A flag meaning that the response data must be detokenized. This is used for .rhtml files.
quint16 _port
The port that VFS_httpd_browser is listening on. Only used as a print value when processing ....
VFS_httpd_browser_responder(QHttpRequest *req, QHttpResponse *resp, VFS_node *node, quint16 port)
bool _needsToIssueRequest
A flag that means the request is asynchronous and will be satisfied after a VFS_request completes.
bool _done
If the _m_resp has finished, or was aborted or deleted, mark this as true.
A subclass of VFS_httpd which will display a summary of the current state of the VFS.
Q_INVOKABLE VFS_httpd_browser(QString dataRootPath, quint16 port, QHostAddress addr=QHostAddress::Any, bool ssl=false, QString sslCertPath="", QString sslKeyPath="")
virtual void handle(QHttpRequest *req, QHttpResponse *resp)
Handle an incoming request.
VFS_node * dataRoot()
Resolve the _dataRootPath into a VFS_node.
VFS_node * _dataRoot
The node found by resolving _dataRootPath.
QString _dataRootPath
The VFS root path to serve from.
Holds the request and response objects for future use.
Definition: VFS_httpd.h:45
Creates httpd server node for VFS.
Definition: VFS_httpd.h:15
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
The base class for all requests between nodes.
Definition: VFS_node.h:54
requestType
Requests perform one of these actions.
Definition: VFS_node.h:63