diff --git a/lib/mxcreply.cpp b/lib/mxcreply.cpp index b77e81ef3..08a946842 100644 --- a/lib/mxcreply.cpp +++ b/lib/mxcreply.cpp @@ -28,15 +28,15 @@ class MxcReply::Private } }; -MxcReply::MxcReply(QNetworkReply* reply) : d(makeImpl()) +MxcReply::MxcReply(DeferredFlag) : d(makeImpl()) {} + +MxcReply::MxcReply(QNetworkReply* reply) : MxcReply(Deferred) { setNetworkReply(reply); } -MxcReply::MxcReply(DeferredFlag) : d(makeImpl()) {} - -MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId) - : MxcReply(reply) +MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString& eventId) + : MxcReply(Deferred) { #ifdef Quotient_E2EE_ENABLED if (auto eventIt = room->findInTimeline(eventId); @@ -48,6 +48,7 @@ MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId) } } #endif + setNetworkReply(reply); } void MxcReply::setNetworkReply(QNetworkReply* newReply) @@ -77,7 +78,7 @@ void MxcReply::setNetworkReply(QNetworkReply* newReply) }); } -MxcReply::MxcReply() +MxcReply::MxcReply(FailedFlag) : d(ZeroImpl()) { static const auto BadRequestPhrase = tr("Bad Request"); diff --git a/lib/mxcreply.h b/lib/mxcreply.h index 3be426fdc..119d77613 100644 --- a/lib/mxcreply.h +++ b/lib/mxcreply.h @@ -15,10 +15,11 @@ class QUOTIENT_API MxcReply : public QNetworkReply Q_OBJECT public: enum DeferredFlag { Deferred }; + enum FailedFlag { Failed }; - explicit MxcReply(); - explicit MxcReply(QNetworkReply *reply); explicit MxcReply(DeferredFlag); + explicit MxcReply(FailedFlag); + explicit MxcReply(QNetworkReply *reply); MxcReply(QNetworkReply* reply, Room* room, const QString& eventId); void setNetworkReply(QNetworkReply* newReply); diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp index 9d269028e..54d5487b3 100644 --- a/lib/networkaccessmanager.cpp +++ b/lib/networkaccessmanager.cpp @@ -96,7 +96,7 @@ QNetworkReply* NetworkAccessManager::createRequest( if (accountId.isEmpty()) { if (!directMediaRequestsAllowed()) { qCWarning(NETWORK) << "No connection specified"; - return new MxcReply(); + return new MxcReply(MxcReply::Failed); } // Best effort with an unauthenticated request directly to the media // homeserver (rather than via own homeserver) @@ -115,7 +115,7 @@ QNetworkReply* NetworkAccessManager::createRequest( const auto* const connection = Accounts.get(accountId); if (!connection) { qCWarning(NETWORK) << "Connection" << accountId << "not found"; - return new MxcReply(); + return new MxcReply(MxcReply::Failed); } if (const auto roomId = query.queryItemValue(QStringLiteral("room_id")); @@ -126,7 +126,7 @@ QNetworkReply* NetworkAccessManager::createRequest( query.queryItemValue(QStringLiteral("event_id"))); qCWarning(NETWORK) << "Room" << roomId << "not found"; - return new MxcReply(); + return new MxcReply(MxcReply::Failed); } return new MxcReply( d->createImplRequest(op, request, connection));