Implement decryption of images

It is a bit of a hack, but it works...
This commit is contained in:
Nicolas Werner 2019-12-03 23:34:16 +01:00
parent a689118d71
commit 5bfdaff778
6 changed files with 57 additions and 9 deletions

View file

@ -5,7 +5,7 @@
void
MxcImageResponse::run()
{
if (m_requestedSize.isValid()) {
if (m_requestedSize.isValid() && !m_encryptionInfo) {
QString fileName = QString("%1_%2x%3_crop")
.arg(m_id)
.arg(m_requestedSize.width())
@ -65,7 +65,12 @@ MxcImageResponse::run()
return;
}
auto data = QByteArray(res.data(), res.size());
auto temp = res;
if (m_encryptionInfo)
temp = mtx::crypto::to_string(
mtx::crypto::decrypt_file(temp, m_encryptionInfo.value()));
auto data = QByteArray(temp.data(), temp.size());
m_image.loadFromData(data);
m_image.setText("original filename",
QString::fromStdString(originalFilename));