aboutsummaryrefslogtreecommitdiff
path: root/src/geminiclient.hpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-16 22:01:59 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-16 22:01:59 +0200
commita3f3e3933c4a2522e233917a6795c6e9d677e65c (patch)
tree6e1bd483bbd5e8ca6fee4566e544de48bfa754a6 /src/geminiclient.hpp
parentbc18d9356828f1ae40d3b4ce5432b30ca13cfc15 (diff)
downloadkristall-a3f3e3933c4a2522e233917a6795c6e9d677e65c.tar.gz
Refactoring: Changes internal structure of requests and unifies a lot of code. Now all errors are handled the same.
Diffstat (limited to 'src/geminiclient.hpp')
-rw-r--r--src/geminiclient.hpp64
1 files changed, 9 insertions, 55 deletions
diff --git a/src/geminiclient.hpp b/src/geminiclient.hpp
index deac50b..5558200 100644
--- a/src/geminiclient.hpp
+++ b/src/geminiclient.hpp
@@ -6,74 +6,29 @@
#include <QSslSocket>
#include <QUrl>
-#include "cryptoidentity.hpp"
-
-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,
-};
+#include "protocolhandler.hpp"
-class GeminiClient : public QObject
+class GeminiClient : public ProtocolHandler
{
private:
Q_OBJECT
public:
- explicit GeminiClient(QObject *parent = nullptr);
+ explicit GeminiClient();
~GeminiClient() override;
- bool startRequest(QUrl const & url);
-
- bool isInProgress() const;
-
- bool cancelRequest();
-
- void enableClientCertificate(CryptoIdentity const & ident);
- void disableClientCertificate();
-
-signals:
- void requestProgress(qint64 transferred);
+ bool supportsScheme(QString const & scheme) const override;
- void requestComplete(QByteArray const & data, QString const & mime);
+ bool startRequest(QUrl const & url) override;
- void protocolViolation(QString const & reason);
+ bool isInProgress() const override;
- void inputRequired(QString const & query);
+ bool cancelRequest() override;
- 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);
-
- void networkError(QString const & reason);
+ bool enableClientCertificate(CryptoIdentity const & ident) override;
+ void disableClientCertificate() override;
private slots:
-
void socketEncrypted();
void socketReadyRead();
@@ -84,7 +39,6 @@ private slots:
void socketError(QAbstractSocket::SocketError socketError);
-
private:
bool is_receiving_body;