diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:14:21 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:14:21 +0200 |
| commit | 3aed883402dc8da829fc304434c5efd0570cbb97 (patch) | |
| tree | 48c46ab087a950d80f78819ceb609e93d246b040 /src/geminiclient.hpp | |
| parent | 44e85dce678e7e36f436a6d0a25c212c9a2d3657 (diff) | |
| download | kristall-3aed883402dc8da829fc304434c5efd0570cbb97.tar.gz | |
Moves source code into subdirectory.
Diffstat (limited to 'src/geminiclient.hpp')
| -rw-r--r-- | src/geminiclient.hpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/geminiclient.hpp b/src/geminiclient.hpp new file mode 100644 index 0000000..590eb5b --- /dev/null +++ b/src/geminiclient.hpp @@ -0,0 +1,89 @@ +#ifndef GEMINICLIENT_HPP +#define GEMINICLIENT_HPP + +#include <QObject> +#include <QMimeType> +#include <QSslSocket> +#include <QUrl> + +enum class TemporaryFailure { + unspecified, + server_unavailable, + cgi_error, + proxy_error, + slow_down, +}; + +enum class PermanentFailure { + unspecified, + not_found, + gone, + proxy_request_required, + bad_request, +}; + +enum class CertificateRejection { + unspecified, + not_accepted, + future_certificate_rejected, + expired_certificate_rejected, +}; + +class GeminiClient : public QObject +{ +private: + Q_OBJECT +public: + explicit GeminiClient(QObject *parent = nullptr); + + ~GeminiClient() override; + + bool startRequest(QUrl const & url); + + bool isInProgress() const; + + bool cancelRequest(); + +signals: + void requestComplete(QByteArray const & data, QString const & mime); + + void protocolViolation(QString const & reason); + + void inputRequired(QString const & query); + + void redirected(QUrl const & uri, bool is_permanent); + + void temporaryFailure(TemporaryFailure reason, QString const & info); + + void permanentFailure(PermanentFailure reason, QString const & info); + + void transientCertificateRequested(QString const & reason); + + void authorisedCertificateRequested(QString const & reason); + + void certificateRejected(CertificateRejection reason, QString const & info); + +private slots: + + void socketEncrypted(); + + void socketReadyRead(); + + void socketDisconnected(); + + void sslErrors(const QList<QSslError> &errors); + + void socketError(QAbstractSocket::SocketError socketError); + + +private: + bool is_receiving_body; + + QUrl target_url; + QSslSocket socket; + QByteArray buffer; + QByteArray body; + QString mime_type; +}; + +#endif // GEMINICLIENT_HPP |
