From b8a1365dacd7ffa8705bbb3dcaf2e2dc6613e6fb Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 2 Jun 2020 12:40:46 +0200 Subject: Update after change to CreateArchive. Remove unused archive handler from self-updater. --- src/selfupdater.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'src/selfupdater.cpp') diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 501c7ed1..dfe11880 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -71,45 +71,18 @@ along with Mod Organizer. If not, see . using namespace MOBase; using namespace MOShared; - -typedef Archive* (*CreateArchiveType)(); - - -template static T resolveFunction(QLibrary &lib, const char *name) -{ - T temp = reinterpret_cast(lib.resolve(name)); - if (temp == nullptr) { - throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1").arg(lib.errorString()).toLatin1().constData()); - } - return temp; -} - - SelfUpdater::SelfUpdater(NexusInterface *nexusInterface) : m_Parent(nullptr) , m_Interface(nexusInterface) , m_Reply(nullptr) , m_Attempts(3) { - QLibrary archiveLib(QCoreApplication::applicationDirPath() + "\\dlls\\archive.dll"); - if (!archiveLib.load()) { - throw MyException(tr("archive.dll not loaded: \"%1\"").arg(archiveLib.errorString())); - } - - CreateArchiveType CreateArchiveFunc = resolveFunction(archiveLib, "CreateArchive"); - - m_ArchiveHandler = CreateArchiveFunc(); - if (!m_ArchiveHandler->isValid()) { - throw MyException(InstallationManager::getErrorString(m_ArchiveHandler->getLastError())); - } - m_MOVersion = createVersionInfo(); } SelfUpdater::~SelfUpdater() { - delete m_ArchiveHandler; } void SelfUpdater::setUserInterface(QWidget *widget) -- cgit v1.3.1 From b7a559c75c2f00616690714b5b55c4a9edac7d58 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 2 Jun 2020 23:30:03 +0200 Subject: Update following archive callback changes. --- src/installationmanager.cpp | 16 +++++++++++----- src/selfupdater.cpp | 3 --- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/selfupdater.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index dad5b436..f4b19c71 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -86,7 +86,7 @@ InstallationManager::InstallationManager() throw MyException(getErrorString(m_ArchiveHandler->getLastError())); } m_ArchiveHandler->setLogCallback([](auto level, auto const& message) { - using LogLevel = ArchiveCallbacks::LogLevel; + using LogLevel = Archive::LogLevel; switch (level) { case LogLevel::Debug: log::debug("{}", message); @@ -165,11 +165,17 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool QString errorMessage; // The callbacks: - ArchiveCallbacks::ProgressCallback progressCallback = [&progress](float p) { progress = static_cast(p * 100.0); }; - ArchiveCallbacks::FileChangeCallback fileChangeCallback = [&progressFile](std::wstring const& file) { - progressFile = QString::fromStdWString(file); + auto progressCallback = [&progress](auto progressType, uint64_t current, uint64_t total) { + if (progressType == Archive::ProgressType::EXTRACTION) { + progress = static_cast(100 * current / total); + } + }; + Archive::FileChangeCallback fileChangeCallback = [&progressFile](auto changeType, std::wstring const& file) { + if (changeType == Archive::FileChangeType::EXTRACTION_START) { + progressFile = QString::fromStdWString(file); + } }; - ArchiveCallbacks::ErrorCallback errorCallback = [&errorMessage, this](std::wstring const& message) { + auto errorCallback = [&errorMessage, this](std::wstring const& message) { m_ArchiveHandler->cancel(); errorMessage = QString::fromStdWString(message); }; diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index dfe11880..1f56fd62 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -19,10 +19,7 @@ along with Mod Organizer. If not, see . #include "selfupdater.h" -#include "archive.h" -#include "callback.h" #include "utility.h" -#include "installationmanager.h" #include "iplugingame.h" #include "messagedialog.h" #include "downloadmanager.h" -- cgit v1.3.1