Changed: Copy installer

This commit is contained in:
kervala 2016-05-26 19:30:18 +02:00
parent 4c7b823e02
commit 10754a5adb
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
if (profile.id.isEmpty())
{

View file

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

View file

@ -48,9 +48,9 @@ void CFilesCopier::setIncludeFilter(const QStringList &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()
@ -127,6 +127,24 @@ void CFilesCopier::getFilesList(FilesToCopy &files)
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)

View file

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

View file

@ -136,6 +136,10 @@ void COperationDialog::processNextStep()
QtConcurrent::run(this, &COperationDialog::extractBnpClient);
break;
case CConfigFile::CopyInstaller:
QtConcurrent::run(this, &COperationDialog::copyIntaller);
break;
case CConfigFile::CleanFiles:
QtConcurrent::run(this, &COperationDialog::cleanFiles);
break;
@ -407,6 +411,53 @@ void COperationDialog::extractBnpClient()
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()
{
CConfigFile *config = CConfigFile::getInstance();

View file

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