Changed: Moved Operation steps enum

This commit is contained in:
kervala 2016-06-14 19:39:39 +02:00
parent d8984f14d4
commit e00b0447a2
7 changed files with 74 additions and 73 deletions

View file

@ -620,7 +620,7 @@ QString CConfigFile::getSrcServerClientBNPFullPath() const
return QString("%1/unpack/exedll_%2.bnp").arg(getSrcServerDirectory()).arg(getClientArch());
}
CConfigFile::InstallationStep CConfigFile::getNextStep() const
OperationStep CConfigFile::getInstallNextStep() const
{
// get last used profile
const CProfile &profile = getProfile();
@ -712,7 +712,7 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
// selected directory contains Ryzom files (shouldn't fail)
if (areRyzomDataInstalledIn(getSrcServerDirectory()))
{
return CopyServerFiles;
return CopyDataFiles;
}
else
{

View file

@ -17,8 +17,11 @@
#ifndef CONFIGFILE_H
#define CONFIGFILE_H
struct CServer
#include "operation.h"
class CServer
{
public:
CServer()
{
dataCompressedSize = 0;
@ -45,8 +48,9 @@ extern const CServer NoServer;
typedef QVector<CServer> CServers;
struct CProfile
class CProfile
{
public:
CProfile()
{
desktopShortcut = false;
@ -78,27 +82,6 @@ class CConfigFile : public QObject
Q_OBJECT
public:
enum InstallationStep
{
DisplayNoServerError,
ShowInstallWizard,
ShowMigrateWizard,
DownloadData,
ExtractDownloadedData,
DownloadClient,
ExtractDownloadedClient,
CopyServerFiles,
CopyProfileFiles,
CleanFiles,
ExtractBnpClient,
CopyInstaller,
UninstallOldClient,
CreateProfile,
CreateShortcuts,
CreateAddRemoveEntry,
Done
};
CConfigFile(QObject *parent = NULL);
virtual ~CConfigFile();
@ -180,7 +163,7 @@ public:
QString getSrcServerClientBNPFullPath() const;
InstallationStep getNextStep() const;
OperationStep getInstallNextStep() const;
// product details
QString getProductName() const;

View file

@ -80,9 +80,9 @@ int main(int argc, char *argv[])
// instanciate ConfigFile
CConfigFile config;
CConfigFile::InstallationStep step = config.load() ? config.getNextStep():CConfigFile::DisplayNoServerError;
OperationStep step = config.load() ? config.getInstallNextStep():DisplayNoServerError;
if (step == CConfigFile::DisplayNoServerError)
if (step == DisplayNoServerError)
{
QMessageBox::critical(NULL, QApplication::tr("Error"), QApplication::tr("Unable to find installer.ini"));
return 1;
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
COperationDialog dialog;
dialog.setOperation(COperationDialog::OperationUninstall);
dialog.setOperation(OperationUninstall);
dialog.setUninstallComponents(components);
// TODO: set all components to uninstall
@ -140,7 +140,7 @@ int main(int argc, char *argv[])
return dialog.exec() ? 0 : 1;
}
if (step == CConfigFile::ShowMigrateWizard)
if (step == ShowMigrateWizard)
{
CMigrateDialog dialog;
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
step = config.getNextStep();
}
else if (step == CConfigFile::ShowInstallWizard)
else if (step == ShowInstallWizard)
{
CInstallDialog dialog;
@ -157,10 +157,10 @@ int main(int argc, char *argv[])
step = config.getNextStep();
}
if (step != CConfigFile::Done)
if (step != Done)
{
COperationDialog dialog;
dialog.setOperation(config.getSrcServerDirectory().isEmpty() ? COperationDialog::OperationInstall: COperationDialog::OperationMigrate);
dialog.setOperation(config.getSrcServerDirectory().isEmpty() ? OperationInstall:OperationMigrate);
if (!dialog.exec()) return 1;

View file

@ -153,7 +153,7 @@ void CMainWindow::onProfiles()
{
COperationDialog dialog(this);
dialog.setOperation(COperationDialog::OperationUpdateProfiles);
dialog.setOperation(OperationUpdateProfiles);
if (!dialog.exec())
{
@ -212,7 +212,7 @@ void CMainWindow::onUninstall()
COperationDialog dialog;
dialog.setOperation(COperationDialog::OperationUninstall);
dialog.setOperation(OperationUninstall);
dialog.setUninstallComponents(components);
if (dialog.exec())

View file

@ -46,4 +46,34 @@ struct SUninstallComponents
bool installer;
};
enum OperationStep
{
DisplayNoServerError,
ShowInstallWizard,
ShowMigrateWizard,
DownloadData,
ExtractDownloadedData,
DownloadClient,
ExtractDownloadedClient,
CopyDataFiles,
CopyProfileFiles,
CleanFiles,
ExtractBnpClient,
CopyInstaller,
UninstallOldClient,
CreateProfile,
CreateShortcuts,
CreateAddRemoveEntry,
Done
};
enum OperationType
{
OperationNone,
OperationMigrate,
OperationUpdateProfiles,
OperationInstall,
OperationUninstall
};
#endif

View file

@ -76,7 +76,7 @@ COperationDialog::~COperationDialog()
{
}
void COperationDialog::setOperation(Operation operation)
void COperationDialog::setOperation(OperationType operation)
{
m_operation = operation;
}
@ -126,73 +126,65 @@ void COperationDialog::processMigrateNextStep()
switch(step)
{
case CConfigFile::DisplayNoServerError:
break;
case CConfigFile::ShowMigrateWizard:
break;
case CConfigFile::ShowInstallWizard:
break;
case CConfigFile::DownloadData:
case DownloadData:
downloadData();
break;
case CConfigFile::ExtractDownloadedData:
// TODO
case ExtractDownloadedData:
QtConcurrent::run(this, &COperationDialog::extractDownloadedData);
break;
case CConfigFile::DownloadClient:
case DownloadClient:
downloadClient();
break;
case CConfigFile::ExtractDownloadedClient:
// TODO
case ExtractDownloadedClient:
QtConcurrent::run(this, &COperationDialog::extractDownloadedClient);
break;
case CConfigFile::CopyServerFiles:
QtConcurrent::run(this, &COperationDialog::copyServerFiles);
case CopyDataFiles:
QtConcurrent::run(this, &COperationDialog::copyDataFiles);
break;
case CConfigFile::CopyProfileFiles:
case CopyProfileFiles:
QtConcurrent::run(this, &COperationDialog::copyProfileFiles);
break;
case CConfigFile::CleanFiles:
case CleanFiles:
QtConcurrent::run(this, &COperationDialog::cleanFiles);
break;
case CConfigFile::ExtractBnpClient:
case ExtractBnpClient:
QtConcurrent::run(this, &COperationDialog::extractBnpClient);
break;
case CConfigFile::CopyInstaller:
case CopyInstaller:
QtConcurrent::run(this, &COperationDialog::copyInstaller);
break;
case CConfigFile::UninstallOldClient:
case UninstallOldClient:
uninstallOldClient();
break;
case CConfigFile::CreateProfile:
case CreateProfile:
createDefaultProfile();
break;
case CConfigFile::CreateShortcuts:
case CreateShortcuts:
createDefaultShortcuts();
break;
case CConfigFile::CreateAddRemoveEntry:
case CreateAddRemoveEntry:
createAddRemoveEntry();
break;
case CConfigFile::Done:
case Done:
accept();
break;
default:
// cases already managed in main.cpp
qDebug() << "Shouldn't happen, step" << step;
break;
}
}
@ -352,6 +344,11 @@ void COperationDialog::downloadData()
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
}
void COperationDialog::extractDownloadedData()
{
// TODO: implement
}
void COperationDialog::downloadClient()
{
CConfigFile *config = CConfigFile::getInstance();

View file

@ -38,16 +38,7 @@ public:
COperationDialog(QWidget *parent = NULL);
virtual ~COperationDialog();
enum Operation
{
OperationNone,
OperationMigrate,
OperationUpdateProfiles,
OperationInstall,
OperationUninstall
};
void setOperation(Operation operation);
void setOperation(OperationType operation);
void setUninstallComponents(const SUninstallComponents &components);
public slots:
@ -134,7 +125,7 @@ protected:
QMutex m_abortingMutex;
bool m_aborting;
Operation m_operation;
OperationType m_operation;
SUninstallComponents m_components;
};