mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-27 00:48:08 +00:00
feat(Chat): detect correctly mime types for file messages
This commit is contained in:
parent
aa5eea13a5
commit
1d2dbfb774
1 changed files with 10 additions and 2 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
#include <QUuid>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
|
|
@ -392,8 +393,15 @@ void ChatModel::sendFileMessage (const QString &path) {
|
|||
}
|
||||
|
||||
shared_ptr<linphone::Content> content = CoreManager::getInstance()->getCore()->createContent();
|
||||
content->setType("application");
|
||||
content->setSubtype("octet-stream");
|
||||
{
|
||||
QStringList mimeType = QMimeDatabase().mimeTypeForFile(path).name().split('/');
|
||||
if (mimeType.length() != 2) {
|
||||
qWarning() << QStringLiteral("Unable to get supported mime type for: `%1`.").arg(path);
|
||||
return;
|
||||
}
|
||||
content->setType(::Utils::appStringToCoreString(mimeType[0]));
|
||||
content->setSubtype(::Utils::appStringToCoreString(mimeType[1]));
|
||||
}
|
||||
|
||||
content->setSize(static_cast<size_t>(fileSize));
|
||||
content->setName(::Utils::appStringToCoreString(QFileInfo(file).fileName()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue