Skip to content
Snippets Groups Projects
Commit 5d205e49 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

vCard: send compressed avatar

- load only files in PNG or JPEG format
- if image loading failed skip sending image

Change-Id: I61fe83b8f16bb942a76cd14eb55e1ad1cb10ac17
parent 63c2ee4b
No related branches found
No related tags found
No related merge requests found
...@@ -143,18 +143,14 @@ QString ...@@ -143,18 +143,14 @@ QString
compressedAvatar(const QString& image) compressedAvatar(const QString& image)
{ {
QImage qimage; QImage qimage;
#ifdef ENABLE_LIBWRAP
auto ret = qimage.loadFromData(QByteArray::fromBase64(image.toUtf8()), 0);
#else
// Avoid to use all formats. Some seems bugguy, like libpbf, asking // Avoid to use all formats. Some seems bugguy, like libpbf, asking
// for a QGuiApplication for QFontDatabase // for a QGuiApplication for QFontDatabase
auto ret = qimage.loadFromData(QByteArray::fromBase64(image.toUtf8()), "JPEG"); auto ret = qimage.loadFromData(QByteArray::fromBase64(image.toUtf8()), "JPEG");
if (!ret) if (!ret)
ret = qimage.loadFromData(QByteArray::fromBase64(image.toUtf8()), "PNG"); ret = qimage.loadFromData(QByteArray::fromBase64(image.toUtf8()), "PNG");
#endif
if (!ret) { if (!ret) {
qDebug() << "vCard image loading failed"; qDebug() << "vCard image loading failed";
return image; return "";
} }
QByteArray bArray; QByteArray bArray;
QBuffer buffer(&bArray); QBuffer buffer(&bArray);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment