mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-07 15:08:24 +00:00
Use a cryptographic checksum when downloading openH264 from CISCO and update them to 2.2.0
This commit is contained in:
parent
f2bab2f1d1
commit
a2c5a9e571
11 changed files with 72 additions and 13 deletions
|
|
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Mark as Read synchronized between devices.
|
||||
- Merge messages into one notification to avoid spam.
|
||||
- Design overhaul on calls.
|
||||
- Use a cryptographic checksum when downloading openH264 from CISCO (Update to 2.2.0)
|
||||
|
||||
### Fixed
|
||||
- Crash on exit.
|
||||
|
|
|
|||
|
|
@ -157,7 +157,8 @@ void AbstractCodecsModel::addDownloadableCodec (
|
|||
const QString &mime,
|
||||
const QString &encoderDescription,
|
||||
const QString &downloadUrl,
|
||||
const QString &installName
|
||||
const QString &installName,
|
||||
const QString &chekcksum
|
||||
) {
|
||||
QVariantMap map;
|
||||
|
||||
|
|
@ -165,6 +166,7 @@ void AbstractCodecsModel::addDownloadableCodec (
|
|||
map["encoderDescription"] = encoderDescription;
|
||||
map["installName"] = installName;
|
||||
map["mime"] = mime;
|
||||
map["checksum"] = chekcksum;
|
||||
|
||||
mList << map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ protected:
|
|||
const QString &mime,
|
||||
const QString &encoderDescription,
|
||||
const QString &downloadUrl,
|
||||
const QString &installName
|
||||
const QString &installName,
|
||||
const QString &chekcksum
|
||||
);
|
||||
|
||||
virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType>> &codecs) = 0;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ static bool downloadUpdatableCodec (
|
|||
const QString &codecsFolder,
|
||||
const QString &mime,
|
||||
const QString &downloadUrl,
|
||||
const QString &installName
|
||||
const QString &installName,
|
||||
const QString &checksum
|
||||
) {
|
||||
QString versionFilePath = codecsFolder + mime + ".txt";
|
||||
QFile versionFile(versionFilePath);
|
||||
|
|
@ -70,9 +71,16 @@ static bool downloadUpdatableCodec (
|
|||
fileExtractor->setExtractFolder(codecsFolder);
|
||||
fileExtractor->setExtractName(installName + ".in");
|
||||
|
||||
QObject::connect(fileDownloader, &FileDownloader::downloadFinished, [fileExtractor](const QString &filePath) {
|
||||
QObject::connect(fileDownloader, &FileDownloader::downloadFinished, [fileDownloader, fileExtractor, checksum](const QString &filePath) {
|
||||
fileExtractor->setFile(filePath);
|
||||
fileExtractor->extract();
|
||||
QString fileChecksum = Utils::getFileChecksum(filePath);
|
||||
if(fileChecksum == checksum)
|
||||
fileExtractor->extract();
|
||||
else{
|
||||
qWarning() << "File cannot be downloaded : Bad checksum.";
|
||||
fileDownloader->remove();
|
||||
fileDownloader->deleteLater();
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(fileDownloader, &FileDownloader::downloadFailed, [fileDownloader]() {
|
||||
|
|
@ -128,7 +136,7 @@ void VideoCodecsModel::updateCodecs () {
|
|||
|
||||
void VideoCodecsModel::downloadUpdatableCodecs (QObject *parent) {
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
downloadUpdatableCodec(parent, getCodecsFolder(), "H264", Constants::PluginUrlH264, Constants::H264InstallName);
|
||||
downloadUpdatableCodec(parent, getCodecsFolder(), "H264", Constants::PluginUrlH264, Constants::H264InstallName, Constants::PluginH264Check);
|
||||
#else
|
||||
Q_UNUSED(parent);
|
||||
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
|
|
@ -169,7 +177,7 @@ void VideoCodecsModel::load () {
|
|||
if (find_if(codecs.begin(), codecs.end(), [](const shared_ptr<linphone::PayloadType> &codec) {
|
||||
return codec->getMimeType() == "H264";
|
||||
}) == codecs.end())
|
||||
addDownloadableCodec("H264", Constants::H264Description, Constants::PluginUrlH264, Constants::H264InstallName);
|
||||
addDownloadableCodec("H264", Constants::H264Description, Constants::PluginUrlH264, Constants::H264InstallName, Constants::PluginH264Check);
|
||||
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
|
|
@ -149,7 +150,14 @@ void FileDownloader::handleDownloadFinished() {
|
|||
qInfo() << QStringLiteral("Download of %1 finished to %2").arg(mUrl.toString(), mDestinationFile.fileName());
|
||||
mDestinationFile.close();
|
||||
cleanDownloadEnd();
|
||||
emit downloadFinished(mDestinationFile.fileName());
|
||||
QString fileChecksum = Utils::getFileChecksum(mDestinationFile.fileName());
|
||||
if( fileChecksum == mChecksum)
|
||||
emit downloadFinished(mDestinationFile.fileName());
|
||||
else{
|
||||
qCritical() << "File cannot be downloaded : Bad checksum " << fileChecksum;
|
||||
mDestinationFile.remove();
|
||||
emit downloadFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,6 +269,17 @@ QString FileDownloader::synchronousDownload(const QUrl &url, const QString &dest
|
|||
return filePath;
|
||||
}
|
||||
|
||||
QString FileDownloader::getChecksum() const{
|
||||
return mChecksum;
|
||||
}
|
||||
|
||||
void FileDownloader::setChecksum(const QString& code){
|
||||
if(mChecksum != code) {
|
||||
mChecksum = code;
|
||||
emit checksumChanged();
|
||||
}
|
||||
}
|
||||
|
||||
qint64 FileDownloader::getReadBytes () const {
|
||||
return mReadBytes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class FileDownloader : public QObject{
|
|||
Q_PROPERTY(qint64 readBytes READ getReadBytes NOTIFY readBytesChanged);
|
||||
Q_PROPERTY(qint64 totalBytes READ getTotalBytes NOTIFY totalBytesChanged);
|
||||
Q_PROPERTY(bool downloading READ getDownloading NOTIFY downloadingChanged);
|
||||
Q_PROPERTY(QString checksum READ getChecksum WRITE setChecksum NOTIFY checksumChanged);
|
||||
|
||||
public:
|
||||
FileDownloader (QObject *parent = Q_NULLPTR) : QObject(parent) {
|
||||
|
|
@ -63,6 +64,9 @@ public:
|
|||
void setOverwriteFile(const bool &overwrite);
|
||||
static QString synchronousDownload(const QUrl &url, const QString &destinationFolder, const bool &overwriteFile);// Return the filpath. Empty if nof file could be downloaded
|
||||
|
||||
QString getChecksum() const;
|
||||
void setChecksum(const QString& code);
|
||||
|
||||
signals:
|
||||
void urlChanged (const QUrl &url);
|
||||
void downloadFolderChanged (const QString &downloadFolder);
|
||||
|
|
@ -71,6 +75,7 @@ signals:
|
|||
void downloadingChanged (bool downloading);
|
||||
void downloadFinished (const QString &filePath);
|
||||
void downloadFailed();
|
||||
void checksumChanged();
|
||||
|
||||
private:
|
||||
qint64 getReadBytes () const;
|
||||
|
|
@ -97,6 +102,7 @@ private:
|
|||
QUrl mUrl;
|
||||
QString mDownloadFolder;
|
||||
QFile mDestinationFile;
|
||||
QString mChecksum;
|
||||
|
||||
qint64 mReadBytes = 0;
|
||||
qint64 mTotalBytes = 0;
|
||||
|
|
|
|||
|
|
@ -82,16 +82,20 @@ constexpr char Constants::LibraryExtension[];
|
|||
constexpr char Constants::H264InstallName[];
|
||||
#ifdef Q_PROCESSOR_X86_64
|
||||
constexpr char Constants::PluginUrlH264[];
|
||||
constexpr char Constants::PluginH264Check[];
|
||||
#else
|
||||
constexpr char Constants::PluginUrlH264[];
|
||||
constexpr char Constants::PluginH264Check[];
|
||||
#endif // ifdef Q_PROCESSOR_X86_64
|
||||
#elif defined(Q_OS_WIN)
|
||||
constexpr char Constants::LibraryExtension[];
|
||||
constexpr char Constants::H264InstallName[];
|
||||
#ifdef Q_OS_WIN64
|
||||
constexpr char Constants::PluginUrlH264[];
|
||||
constexpr char Constants::PluginH264Check[];
|
||||
#else
|
||||
constexpr char Constants::PluginUrlH264[];
|
||||
constexpr char Constants::PluginH264Check[];
|
||||
#endif // ifdef Q_OS_WIN64
|
||||
#endif // ifdef Q_OS_LINUX
|
||||
constexpr char Constants::VcardScheme[];
|
||||
|
|
|
|||
|
|
@ -156,17 +156,21 @@ public:
|
|||
static constexpr char LibraryExtension[] = "so";
|
||||
static constexpr char H264InstallName[] = "libopenh264.so";
|
||||
#ifdef Q_PROCESSOR_X86_64
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux64.5.so.bz2";
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.2.0-linux64.6.so.bz2";
|
||||
static constexpr char PluginH264Check[] = "45ba1aaeb6213c19cd9622b79788e16b05beabc4d16a3a74e57f046a0826fd77";
|
||||
#else
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux32.5.so.bz2";
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.2.0-linux32.6.so.bz2";
|
||||
static constexpr char PluginH264Check[] = "bf18e0e79c4a23018b0ea5ad6d7dd14fd1b6a6189d2f88fd56dece019fc415c8";
|
||||
#endif // ifdef Q_PROCESSOR_X86_64
|
||||
#elif defined(Q_OS_WIN)
|
||||
static constexpr char LibraryExtension[] = "dll";
|
||||
static constexpr char H264InstallName[] = "openh264.dll";
|
||||
#ifdef Q_OS_WIN64
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win64.dll.bz2";
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.2.0-win64.dll.bz2";
|
||||
static constexpr char PluginH264Check[] = "799e08c418b6cdeadfbe18d027392158face4a5c901d41f83712a20f0d41ad7d";
|
||||
#else
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win32.dll.bz2";
|
||||
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.2.0-win32.dll.bz2";
|
||||
static constexpr char PluginH264Check[] = "2205097a3a309271e15879b25a905eb290cfdd7fd7a8a0c1037e0458e5dc1f21";
|
||||
#endif // ifdef Q_OS_WIN64
|
||||
#endif // ifdef Q_OS_LINUX
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <QFileInfo>
|
||||
#include <QCoreApplication>
|
||||
#include <QCryptographicHash>
|
||||
#include <QCursor>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
|
@ -569,4 +570,15 @@ QSize Utils::getImageSize(const QString& url){
|
|||
|
||||
QPoint Utils::getCursorPosition(){
|
||||
return QCursor::pos();
|
||||
}
|
||||
|
||||
QString Utils::getFileChecksum(const QString& filePath){
|
||||
QFile file(filePath);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
||||
if (hash.addData(&file)) {
|
||||
return hash.result().toHex();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -64,6 +64,7 @@ public:
|
|||
Q_INVOKABLE static bool isPhoneNumber(const QString& txt);
|
||||
Q_INVOKABLE QSize getImageSize(const QString& url);
|
||||
Q_INVOKABLE static QPoint getCursorPosition();
|
||||
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
static inline QString coreStringToAppString (const std::string &str) {
|
||||
|
|
|
|||
|
|
@ -765,7 +765,8 @@ function openCodecOnlineInstallerDialog (window, codecInfo, cb) {
|
|||
extract: true,
|
||||
installFolder: VideoCodecsModel.codecsFolder,
|
||||
installName: codecInfo.installName,
|
||||
mime: codecInfo.mime
|
||||
mime: codecInfo.mime,
|
||||
checksum: codecInfo.checksum
|
||||
}, function (status) {
|
||||
if (status) {
|
||||
VideoCodecsModel.reload()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue