From c635094a6bdfcf2f081eb3c0ed9a1454ae2933fb Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Sat, 9 Jan 2021 15:55:52 +1100 Subject: status bar: show request status when loading pages status text for loading HTTP/S is only a simple 'loading webpage'. The other protocols display more information --- src/protocols/gopherclient.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/protocols/gopherclient.cpp') diff --git a/src/protocols/gopherclient.cpp b/src/protocols/gopherclient.cpp index ec0fa70..af2b141 100644 --- a/src/protocols/gopherclient.cpp +++ b/src/protocols/gopherclient.cpp @@ -1,5 +1,6 @@ #include "gopherclient.hpp" #include "ioutil.hpp" +#include "kristall.hpp" GopherClient::GopherClient(QObject *parent) : ProtocolHandler(parent) { @@ -12,6 +13,11 @@ GopherClient::GopherClient(QObject *parent) : ProtocolHandler(parent) #else connect(&socket, QOverload::of(&QTcpSocket::error), this, &GopherClient::on_socketError); #endif + + connect(&socket, &QAbstractSocket::hostFound, this, [this]() { + emit this->requestStateChange(RequestState::HostFound); + }); + emit this->requestStateChange(RequestState::None); } GopherClient::~GopherClient() @@ -34,6 +40,8 @@ bool GopherClient::startRequest(const QUrl &url, RequestOptions options) if(url.scheme() != "gopher") return false; + emit this->requestStateChange(RequestState::Started); + // Second char on the URL path denotes the Gopher type // See https://tools.ietf.org/html/rfc4266 QString type = url.path().mid(1, 1); @@ -79,6 +87,8 @@ void GopherClient::on_connected() auto blob = (requested_url.path().mid(2) + "\r\n").toUtf8(); IoUtil::writeAll(socket, blob); + + emit this->requestStateChange(RequestState::Connected); } void GopherClient::on_readRead() @@ -107,6 +117,8 @@ void GopherClient::on_finished() was_cancelled = true; } body.clear(); + + emit this->requestStateChange(RequestState::None); } void GopherClient::on_socketError(QAbstractSocket::SocketError error_code) -- cgit v1.2.3