summaryrefslogtreecommitdiff
path: root/src/installationmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/installationmanager.cpp')
-rw-r--r--src/installationmanager.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index 801b2a67..a755b0cb 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -369,7 +369,7 @@ QString InstallationManager::generateBackupName(const QString &directoryName) co
}
-bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *merge)
+IPluginInstaller::EInstallResult InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *merge)
{
QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName);
@@ -388,7 +388,7 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *me
QString backupDirectory = generateBackupName(targetDirectory);
if (!copyDir(targetDirectory, backupDirectory, false)) {
reportError(tr("Failed to create backup"));
- return false;
+ return IPluginInstaller::RESULT_FAILED;
}
}
if (merge != nullptr) {
@@ -401,7 +401,7 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *me
if (ok && !name.isEmpty()) {
modName.update(name, GUESS_USER);
if (!ensureValidModName(modName)) {
- return false;
+ return IPluginInstaller::RESULT_FAILED;
}
targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory) + "/" + modName;
}
@@ -410,7 +410,7 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *me
if (idx != UINT_MAX) {
auto modInfo = ModInfo::getByIndex(idx);
// mark the old install file as uninstalled
- emit modReplaced(modInfo->getInstallationFile());
+ emit modReplaced(modInfo->installationFile());
}
// save original settings like categories. Because it makes sense
QString metaFilename = targetDirectory + "/meta.ini";
@@ -436,18 +436,20 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *me
} else {
log::error("failed to restore original settings: {}", metaFilename);
}
- return true;
+ return IPluginInstaller::RESULT_SUCCESS;
} else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_MERGE) {
- return true;
+ return IPluginInstaller::RESULT_SUCCESS;
+ } else /* if (overwriteDialog.action() == QueryOverwriteDialog::ACT_NONE) */ {
+ return IPluginInstaller::RESULT_CANCELED;
}
} else {
- return false;
+ return IPluginInstaller::RESULT_CANCELED;
}
}
QDir().mkdir(targetDirectory);
- return true;
+ return IPluginInstaller::RESULT_SUCCESS;;
}
@@ -476,8 +478,9 @@ IPluginInstaller::EInstallResult InstallationManager::doInstall(GuessedValue<QSt
bool merge = false;
// determine target directory
- if (!testOverwrite(modName, &merge)) {
- return IPluginInstaller::RESULT_FAILED;
+ IPluginInstaller::EInstallResult result = testOverwrite(modName, &merge);
+ if (result != IPluginInstaller::RESULT_SUCCESS) {
+ return result;
}
QString targetDirectory = QDir(m_ModsDirectory + "/" + modName).canonicalPath();
@@ -865,3 +868,19 @@ QStringList InstallationManager::getSupportedExtensions() const
{
return QStringList(std::begin(m_SupportedExtensions), std::end(m_SupportedExtensions));
}
+
+void InstallationManager::notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod)
+{
+ for (auto* installer : m_Installers) {
+ installer->onInstallationStart(archive, reinstallation, currentMod.get());
+ }
+}
+
+void InstallationManager::notifyInstallationEnd(
+ MOBase::IPluginInstaller::EInstallResult result,
+ ModInfo::Ptr newMod)
+{
+ for (auto* installer : m_Installers) {
+ installer->onInstallationEnd(result, newMod.get());
+ }
+}