Update for the latest event content changes to libquotient
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <QMimeDatabase>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include <Quotient/events/eventcontent.h>
|
||||
#include <Quotient/jobs/basejob.h>
|
||||
#include <Quotient/quotient_common.h>
|
||||
#include <qcoro/qcorosignal.h>
|
||||
@@ -74,10 +75,14 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
QString mxcUrl;
|
||||
if (auto event = eventCast<const Quotient::RoomMessageEvent>(m_event)) {
|
||||
if (event->hasFileContent()) {
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
mxcUrl = event->fileContent()->url().toString();
|
||||
#else
|
||||
mxcUrl = event->content()->fileInfo()->url().toString();
|
||||
#endif
|
||||
}
|
||||
} else if (auto event = eventCast<const Quotient::StickerEvent>(m_event)) {
|
||||
mxcUrl = event->image().fileInfo()->url().toString();
|
||||
mxcUrl = event->image().url().toString();
|
||||
}
|
||||
if (mxcUrl.isEmpty()) {
|
||||
return;
|
||||
@@ -215,7 +220,11 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
||||
auto mime = QMimeDatabase().mimeTypeForUrl(url);
|
||||
url.setScheme("file"_ls);
|
||||
QFileInfo fileInfo(url.isLocalFile() ? url.toLocalFile() : url.toString());
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
EventContent::Base *content;
|
||||
#else
|
||||
EventContent::TypedBase *content;
|
||||
#endif
|
||||
if (mime.name().startsWith("image/"_ls)) {
|
||||
QImage image(url.toLocalFile());
|
||||
content = new EventContent::ImageContent(url, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||
@@ -230,7 +239,12 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
||||
} else {
|
||||
content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
||||
}
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
QString txnId =
|
||||
postFile(body.isEmpty() ? url.fileName() : body, std::unique_ptr<EventContent::FileContent>(static_cast<EventContent::FileContent *>(content)));
|
||||
#else
|
||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content);
|
||||
#endif
|
||||
setHasFileUploading(true);
|
||||
connect(this, &Room::fileTransferCompleted, [this, txnId](const QString &id, FileSourceInfo) {
|
||||
if (id == txnId) {
|
||||
@@ -1498,12 +1512,18 @@ FileTransferInfo NeoChatRoom::cachedFileTransferInfo(const Quotient::RoomEvent *
|
||||
int total = 0;
|
||||
if (auto evt = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||
if (evt->hasFileContent()) {
|
||||
mxcUrl = evt->content()->fileInfo()->url().toString();
|
||||
total = evt->content()->fileInfo()->payloadSize;
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
const auto fileContent = evt->fileContent();
|
||||
#else
|
||||
const auto fileContent = evt->content()->fileInfo();
|
||||
#endif
|
||||
|
||||
mxcUrl = fileContent->url().toString();
|
||||
total = fileContent->payloadSize;
|
||||
}
|
||||
} else if (auto evt = eventCast<const Quotient::StickerEvent>(event)) {
|
||||
mxcUrl = evt->image().fileInfo()->url().toString();
|
||||
total = evt->image().fileInfo()->payloadSize;
|
||||
mxcUrl = evt->image().url().toString();
|
||||
total = evt->image().payloadSize;
|
||||
}
|
||||
|
||||
FileTransferInfo transferInfo = fileTransferInfo(event->id());
|
||||
|
||||
Reference in New Issue
Block a user