aboutsummaryrefslogtreecommitdiff
path: root/lib/mxcreply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mxcreply.cpp')
-rw-r--r--lib/mxcreply.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/mxcreply.cpp b/lib/mxcreply.cpp
index b757bb93..c7547be8 100644
--- a/lib/mxcreply.cpp
+++ b/lib/mxcreply.cpp
@@ -5,11 +5,10 @@
#include <QtCore/QBuffer>
#include "accountregistry.h"
-#include "connection.h"
#include "room.h"
#ifdef Quotient_E2EE_ENABLED
-#include "events/encryptedfile.h"
+#include "events/filesourceinfo.h"
#endif
using namespace Quotient;
@@ -21,7 +20,7 @@ public:
: m_reply(r)
{}
QNetworkReply* m_reply;
- Omittable<EncryptedFile> m_encryptedFile;
+ Omittable<EncryptedFileMetadata> m_encryptedFile;
QIODevice* m_device = nullptr;
};
@@ -48,9 +47,9 @@ MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId)
if(!d->m_encryptedFile.has_value()) {
d->m_device = d->m_reply;
} else {
- EncryptedFile file = *d->m_encryptedFile;
auto buffer = new QBuffer(this);
- buffer->setData(file.decryptFile(d->m_reply->readAll()));
+ buffer->setData(
+ decryptFile(d->m_reply->readAll(), *d->m_encryptedFile));
buffer->open(ReadOnly);
d->m_device = buffer;
}
@@ -65,17 +64,13 @@ MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId)
auto eventIt = room->findInTimeline(eventId);
if(eventIt != room->historyEdge()) {
auto event = eventIt->viewAs<RoomMessageEvent>();
- d->m_encryptedFile = event->content()->fileInfo()->file;
+ if (auto* efm = std::get_if<EncryptedFileMetadata>(
+ &event->content()->fileInfo()->source))
+ d->m_encryptedFile = *efm;
}
#endif
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
-#define ERROR_SIGNAL errorOccurred
-#else
-#define ERROR_SIGNAL error
-#endif
-
MxcReply::MxcReply()
: d(ZeroImpl<Private>())
{
@@ -87,7 +82,7 @@ MxcReply::MxcReply()
setError(QNetworkReply::ProtocolInvalidOperationError,
BadRequestPhrase);
setFinished(true);
- emit ERROR_SIGNAL(QNetworkReply::ProtocolInvalidOperationError);
+ emit errorOccurred(QNetworkReply::ProtocolInvalidOperationError);
emit finished();
}, Qt::QueuedConnection);
}