| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef GEMINISCHEMEHANDLER_H |
| 4 | #define GEMINISCHEMEHANDLER_H |
| 5 | |
| 6 | #include "network-web/gemini/geminiclient.h" |
| 7 | #include "network-web/gemini/geminiparser.h" |
| 8 | |
| 9 | #include <QWebEngineUrlRequestJob> |
| 10 | #include <QWebEngineUrlSchemeHandler> |
| 11 | |
| 12 | class GeminiSchemeHandler : public QWebEngineUrlSchemeHandler { |
| 13 | public: |
| 14 | explicit GeminiSchemeHandler(QObject* parent = nullptr); |
| 15 | |
| 16 | virtual void requestStarted(QWebEngineUrlRequestJob* request); |
| 17 | |
| 18 | private slots: |
| 19 | void onRedirect(const QUrl& uri, bool is_permanent); |
| 20 | void onCompleted(const QByteArray& data, const QString& mime); |
| 21 | void onNetworkError(GeminiClient::NetworkError error, const QString& reason); |
| 22 | |
| 23 | void onJobDeleted(QObject* job); |
| 24 | |
| 25 | private: |
| 26 | QHash<QWebEngineUrlRequestJob*, GeminiClient*> m_jobs; |
| 27 | GeminiParser m_geminiParser; |
| 28 | }; |
| 29 | |
| 30 | #endif // GEMINISCHEMEHANDLER_H |