- Take account of aborted call in logs

- Test if a file is an image before showing it
This commit is contained in:
Julien Wadel 2020-06-14 20:12:19 +02:00
parent 9075a02367
commit ef28ab0156
7 changed files with 29 additions and 16 deletions

View file

@ -36,14 +36,7 @@ ExternalImageProvider::ExternalImageProvider () : QQuickImageProvider(
}
QImage ExternalImageProvider::requestImage (const QString &id, QSize *size, const QSize &) {
QImage image(id);
if(image.isNull()){// Try to determine format from headers instead of using suffix
QImageReader reader(id);
reader.setDecideFormatFromContent(true);
QByteArray format = reader.format();
if(!format.isEmpty())
image = QImage(id, format);
}
QImage image(Utils::getImage(id));
*size = image.size();
return image;
}

View file

@ -278,6 +278,10 @@ void Notifier::notifyReceivedMessage (const shared_ptr<linphone::ChatMessage> &m
void Notifier::notifyReceivedFileMessage (const shared_ptr<linphone::ChatMessage> &message) {
QVariantMap map;
map["fileUri"] = Utils::coreStringToAppString(message->getFileTransferInformation()->getFilePath());
if( Utils::getImage(map["fileUri"].toString()).isNull())
map["imageUri"] = "";
else
map["imageUri"] = map["fileUri"];
map["fileSize"] = quint64(message->getFileTransferInformation()->getSize() +message->getFileTransferInformation()->getFileSize());
CREATE_NOTIFICATION(Notifier::ReceivedFileMessage, map)
}

View file

@ -69,7 +69,12 @@ shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () c
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
return proxyConfig ? proxyConfig->getIdentityAddress() : core->createPrimaryContactParsed();
if( !proxyConfig){
shared_ptr<linphone::Address> addr = core->createPrimaryContactParsed();
addr->setPort(0);
return std::move(addr);
}else
return proxyConfig->getIdentityAddress();
}
void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {

View file

@ -304,10 +304,6 @@ void SipAddressesModel::handleCallStateChanged (
const shared_ptr<linphone::Call> &call,
linphone::Call::State state
) {
// Ignore aborted calls.
if (call->getCallLog()->getStatus() == linphone::Call::Status::Aborted)
return;
if (state == linphone::Call::State::End || state == linphone::Call::State::Error)
addOrUpdateSipAddress(
Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly()), call

View file

@ -22,6 +22,7 @@
#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QImageReader>
#include "Utils.hpp"
@ -47,7 +48,17 @@ char *Utils::rstrstr (const char *a, const char *b) {
}
// -----------------------------------------------------------------------------
QImage Utils::getImage(const QString &pUri) {
QImage image(pUri);
if(image.isNull()){// Try to determine format from headers instead of using suffix
QImageReader reader(pUri);
reader.setDecideFormatFromContent(true);
QByteArray format = reader.format();
if(!format.isEmpty())
image = QImage(pUri, format);
}
return image;
}
QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) {
if (soFarSoGood)
*soFarSoGood = true;

View file

@ -24,6 +24,8 @@
#include <QObject>
#include <QString>
#include <QLocale>
#include <QImage>
// =============================================================================
@ -50,7 +52,8 @@ namespace Utils {
// Reverse function of strstr.
char *rstrstr (const char *a, const char *b);
// Return the path if it is an image else an empty path.
QImage getImage(const QString &pUri);
// Returns the same path given in parameter if `filePath` exists.
// Otherwise returns a safe path with a unique number before the extension.
QString getSafeFilePath (const QString &filePath, bool *soFarSoGood = nullptr);

View file

@ -16,6 +16,7 @@ Notification {
// ---------------------------------------------------------------------------
readonly property string fileUri: notificationData && notificationData.fileUri || ''
readonly property string imageUri: notificationData && notificationData.imageUri || ''
// ---------------------------------------------------------------------------
@ -46,7 +47,7 @@ Notification {
Layout.fillHeight: true
Layout.fillWidth: true
fillMode: Image.PreserveAspectFit
source: "image://external/"+notification.fileUri
source: (imageUri ?"image://external/"+notification.imageUri : '')
visible: image.status == Image.Ready
}