Changed: Copy installer

This commit is contained in:
kervala 2016-05-26 19:30:18 +02:00
parent d468ad26f5
commit 1d64e5970f
6 changed files with 82 additions and 4 deletions

View file

@ -696,6 +696,12 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
} }
} }
// if installer not found in installation directory, extract it from BNP
if (!QFile::exists(getInstallationDirectory() + "/" + server.installerFilename))
{
return CopyInstaller;
}
// no default profile // no default profile
if (profile.id.isEmpty()) if (profile.id.isEmpty())
{ {

View file

@ -92,6 +92,7 @@ public:
CopyProfileFiles, CopyProfileFiles,
CleanFiles, CleanFiles,
ExtractBnpClient, ExtractBnpClient,
CopyInstaller,
CreateProfile, CreateProfile,
CreateShortcuts, CreateShortcuts,
Done Done

View file

@ -48,9 +48,9 @@ void CFilesCopier::setIncludeFilter(const QStringList &filter)
m_includeFilter = filter; m_includeFilter = filter;
} }
void CFilesCopier::setExcludeFilter(const QStringList &filter) void CFilesCopier::addFile(const QString &filename)
{ {
m_excludeFilter = filter; m_files << filename;
} }
bool CFilesCopier::exec() bool CFilesCopier::exec()
@ -127,6 +127,24 @@ void CFilesCopier::getFilesList(FilesToCopy &files)
files << file; files << file;
} }
} }
// copy additional files
foreach(const QString &fullpath, m_files)
{
QFileInfo fileInfo(fullpath);
if (fileInfo.isFile())
{
FileToCopy file;
file.filename = fileInfo.fileName();
file.src = fileInfo.filePath();
file.dst = m_destinationDirectory + "/" + fileInfo.fileName();
file.size = fileInfo.size();
file.date = fileInfo.lastModified().toTime_t();
files << file;
}
}
} }
bool CFilesCopier::copyFiles(const FilesToCopy &files) bool CFilesCopier::copyFiles(const FilesToCopy &files)

View file

@ -35,7 +35,8 @@ public:
void setDesinationDirectory(const QString &src); void setDesinationDirectory(const QString &src);
void setIncludeFilter(const QStringList &filter); void setIncludeFilter(const QStringList &filter);
void setExcludeFilter(const QStringList &filter);
void addFile(const QString &file);
bool exec(); bool exec();
@ -61,7 +62,7 @@ protected:
QString m_destinationDirectory; QString m_destinationDirectory;
QStringList m_includeFilter; QStringList m_includeFilter;
QStringList m_excludeFilter; QStringList m_files;
}; };
#endif #endif

View file

@ -136,6 +136,10 @@ void COperationDialog::processNextStep()
QtConcurrent::run(this, &COperationDialog::extractBnpClient); QtConcurrent::run(this, &COperationDialog::extractBnpClient);
break; break;
case CConfigFile::CopyInstaller:
QtConcurrent::run(this, &COperationDialog::copyIntaller);
break;
case CConfigFile::CleanFiles: case CConfigFile::CleanFiles:
QtConcurrent::run(this, &COperationDialog::cleanFiles); QtConcurrent::run(this, &COperationDialog::cleanFiles);
break; break;
@ -407,6 +411,53 @@ void COperationDialog::extractBnpClient()
emit done(); emit done();
} }
void COperationDialog::copyIntaller()
{
CConfigFile *config = CConfigFile::getInstance();
// default server
const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Copy installer to new location");
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
QString destinationDirectory = config->getInstallationDirectory();
// rename old client to installer
QString newInstallerFilename = server.installerFilename;
if (!newInstallerFilename.isEmpty())
{
QString oldInstallerFullPath = QApplication::applicationFilePath();
QString newInstallerFullPath = config->getInstallationDirectory() + "/" + newInstallerFilename;
if (!QFile::exists(newInstallerFullPath))
{
QStringList filter;
filter << "msvcp100.dll";
filter << "msvcr100.dll";
CFilesCopier copier(this);
copier.setIncludeFilter(filter);
copier.addFile(oldInstallerFullPath);
copier.setSourceDirectory(config->getSrcServerDirectory());
copier.setDestinationDirectory(config->getInstallationDirectory());
copier.exec();
// copied file
oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName();
// rename old filename if different
if (oldInstallerFullPath != newInstallerFullPath)
{
QFile::rename(oldInstallerFullPath, newInstallerFullPath);
}
}
}
emit done();
}
void COperationDialog::cleanFiles() void COperationDialog::cleanFiles()
{ {
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();

View file

@ -87,6 +87,7 @@ protected:
void copyServerFiles(); void copyServerFiles();
void copyProfileFiles(); void copyProfileFiles();
void extractBnpClient(); void extractBnpClient();
void copyIntaller();
void cleanFiles(); void cleanFiles();
bool createDefaultProfile(); bool createDefaultProfile();
bool createDefaultShortcuts(); bool createDefaultShortcuts();