Merge with develop

This commit is contained in:
kervala 2016-10-17 11:35:24 +02:00
parent 2379918a3e
commit 364efba09d
8 changed files with 104 additions and 102 deletions

View file

@ -1,9 +1,9 @@
version=3 version=4
[common] [common]
installation_directory= installation_directory=
installer_filename_windows=ryzom_installer_qt_r.exe installer_filename_windows=ryzom_installer_qt_r.exe
installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller installer_filename_osx="Ryzom Installer.app/Contents/MacOS/Ryzom Installer"
installer_filename_linux=ryzom_installer_qt installer_filename_linux=ryzom_installer_qt
[product] [product]

View file

@ -106,15 +106,19 @@ bool CConfigFile::load(const QString &filename)
m_productHelpUrl = settings.value("url_help").toString(); m_productHelpUrl = settings.value("url_help").toString();
m_productComments = settings.value("comments").toString(); m_productComments = settings.value("comments").toString();
settings.endGroup(); settings.endGroup();
}
settings.beginGroup("servers"); settings.beginGroup("servers");
int serversCount = settings.value("size").toInt(); int serversCount = settings.value("size").toInt();
m_defaultServerIndex = settings.value("default").toInt(); m_defaultServerIndex = settings.value("default").toInt();
settings.endGroup(); settings.endGroup();
m_servers.resize(serversCount); // only resize if added servers in local ryzom_installer.ini
int oldServersCount = m_servers.size();
for (int i = 0; i < serversCount; ++i) if (serversCount > oldServersCount) m_servers.resize(serversCount);
for (int i = oldServersCount; i < serversCount; ++i)
{ {
CServer &server = m_servers[i]; CServer &server = m_servers[i];
@ -122,7 +126,6 @@ bool CConfigFile::load(const QString &filename)
server.loadFromSettings(settings); server.loadFromSettings(settings);
settings.endGroup(); settings.endGroup();
} }
}
// custom choices, always keep them // custom choices, always keep them
settings.beginGroup("profiles"); settings.beginGroup("profiles");
@ -492,11 +495,6 @@ QString CConfigFile::getParentDirectory()
return current.absolutePath(); return current.absolutePath();
} }
QString CConfigFile::getApplicationDirectory()
{
return QApplication::applicationDirPath();
}
QString CConfigFile::getOldInstallationDirectory() QString CConfigFile::getOldInstallationDirectory()
{ {
// HKEY_CURRENT_USER/SOFTWARE/Nevrax/RyzomInstall/InstallId=1917716796 (string) // HKEY_CURRENT_USER/SOFTWARE/Nevrax/RyzomInstall/InstallId=1917716796 (string)
@ -757,7 +755,19 @@ QString CConfigFile::getInstallerCurrentFilePath() const
QString CConfigFile::getInstallerCurrentDirPath() const QString CConfigFile::getInstallerCurrentDirPath() const
{ {
// installer is always run from TEMP under Windows // installer is always run from TEMP under Windows
return QApplication::applicationDirPath(); QString appDir = QApplication::applicationDirPath();
#ifdef Q_OS_MAC
QDir dir(appDir);
dir.cdUp(); // .. = Contents
dir.cdUp(); // .. = .app
dir.cdUp(); // .. = <parent>
// return absolute path
appDir = dir.absolutePath();
#endif
return appDir;
} }
QString CConfigFile::getInstallerInstalledFilePath() const QString CConfigFile::getInstallerInstalledFilePath() const
@ -818,7 +828,7 @@ QStringList CConfigFile::getInstallerRequiredFiles() const
#endif #endif
// include current executable // include current executable
files << QFileInfo(QApplication::applicationFilePath()).fileName(); files << QFileInfo(getInstallerCurrentFilePath()).fileName();
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
// everything is in a directory // everything is in a directory
files << "Ryzom Installer.app"; files << "Ryzom Installer.app";
@ -827,7 +837,7 @@ QStringList CConfigFile::getInstallerRequiredFiles() const
files << "ryzom_installer.png"; files << "ryzom_installer.png";
// include current executable // include current executable
files << QFileInfo(QApplication::applicationFilePath()).fileName(); files << QFileInfo(getInstallerCurrentFilePath()).fileName();
#endif #endif
return files; return files;
@ -875,7 +885,7 @@ OperationStep CConfigFile::getInstallNextStep() const
if (!isRyzomInstalledIn(currentDirectory)) if (!isRyzomInstalledIn(currentDirectory))
{ {
// Ryzom is in the same directory as Ryzom Installer // Ryzom is in the same directory as Ryzom Installer
currentDirectory = getApplicationDirectory(); currentDirectory = getInstallerCurrentDirPath();
if (!isRyzomInstalledIn(currentDirectory)) if (!isRyzomInstalledIn(currentDirectory))
{ {
@ -972,8 +982,8 @@ OperationStep CConfigFile::getInstallNextStep() const
// current installer older, launch the more recent installer // current installer older, launch the more recent installer
case -1: return LaunchInstalledInstaller; case -1: return LaunchInstalledInstaller;
// continue only if 0 // continue only if 0 and launched Installer is the installed one
default: break; default: if (getInstallerCurrentDirPath() != getInstallerInstalledFilePath() && QFile::exists(getInstallerInstalledFilePath())) return LaunchInstalledInstaller;
} }
// no default profile // no default profile

View file

@ -90,7 +90,6 @@ public:
// default directories // default directories
static QString getCurrentDirectory(); static QString getCurrentDirectory();
static QString getParentDirectory(); static QString getParentDirectory();
static QString getApplicationDirectory();
static QString getOldInstallationDirectory(); static QString getOldInstallationDirectory();
static QString getNewInstallationDirectory(); static QString getNewInstallationDirectory();
static QString getOldInstallationLanguage(); static QString getOldInstallationLanguage();

View file

@ -63,71 +63,62 @@ bool CFilesCopier::exec()
FilesToCopy files; FilesToCopy files;
// create the list of files to copy
CFilesCopier::getFilesList(files); CFilesCopier::getFilesList(files);
// copy them
return copyFiles(files); return copyFiles(files);
} }
void CFilesCopier::getFilesList(FilesToCopy &files) void CFilesCopier::getFile(const QFileInfo &fileInfo, const QDir &srcDir, FilesToCopy &files) const
{ {
QDir dir(m_sourceDirectory); // full path to file
QString fullPath = fileInfo.absoluteFilePath();
QFileInfoList entries = dir.entryInfoList(m_includeFilter); // full path where to copy file
QString dstPath = m_destinationDirectory + "/" + srcDir.relativeFilePath(fullPath);
foreach(const QFileInfo &entry, entries) if (fileInfo.isDir())
{
QString fullPath = entry.absoluteFilePath();
QString dstPath = m_destinationDirectory + "/" + dir.relativeFilePath(fullPath);
if (entry.isDir())
{ {
// create directory
QDir().mkpath(dstPath); QDir().mkpath(dstPath);
QDir subDir(fullPath); QDir subDir(fullPath);
QDirIterator it(subDir, QDirIterator::Subdirectories); // get list of all files in directory
QFileInfoList entries = subDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
while (it.hasNext()) // proces seach file recursively
foreach(const QFileInfo &entry, entries)
{ {
fullPath = it.next(); getFile(entry, srcDir, files);
if (it.fileName().startsWith('.')) continue;
QFileInfo fileInfo = it.fileInfo();
dstPath = m_destinationDirectory + "/" + dir.relativeFilePath(fullPath);
if (fileInfo.isDir())
{
QDir().mkpath(dstPath);
}
else
{
FileToCopy file;
file.filename = it.fileName();
file.src = it.filePath();
file.dst = dstPath;
file.size = it.fileInfo().size();
file.date = it.fileInfo().lastModified().toTime_t();
file.permissions = it.fileInfo().permissions();
files << file;
}
} }
} }
else else
{ {
// add the file to list with all useful information
FileToCopy file; FileToCopy file;
file.filename = entry.fileName(); file.filename = fileInfo.fileName();
file.src = entry.filePath(); file.src = fileInfo.filePath();
file.dst = dstPath; file.dst = dstPath;
file.size = entry.size(); file.size = fileInfo.size();
file.date = entry.lastModified().toTime_t(); file.date = fileInfo.lastModified().toTime_t();
file.permissions = entry.permissions(); file.permissions = fileInfo.permissions();
files << file; files << file;
} }
}
void CFilesCopier::getFilesList(FilesToCopy &files) const
{
QDir srcDir(m_sourceDirectory);
// only copy all files from filter
QFileInfoList entries = srcDir.entryInfoList(m_includeFilter);
foreach(const QFileInfo &entry, entries)
{
getFile(entry, srcDir, files);
} }
// copy additional files // copy additional files
@ -135,18 +126,7 @@ void CFilesCopier::getFilesList(FilesToCopy &files)
{ {
QFileInfo fileInfo(fullpath); QFileInfo fileInfo(fullpath);
if (fileInfo.isFile()) getFile(fileInfo, srcDir, files);
{
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();
file.permissions = fileInfo.permissions();
files << file;
}
} }
} }
@ -186,7 +166,7 @@ bool CFilesCopier::copyFiles(const FilesToCopy &files)
if (!QFile::copy(file.src, file.dst)) if (!QFile::copy(file.src, file.dst))
{ {
if (m_listener) m_listener->operationFail(QApplication::tr("Unable to copy file %1").arg(file.src)); if (m_listener) m_listener->operationFail(QApplication::tr("Unable to copy file %1 to %2").arg(file.src).arg(file.dst));
return false; return false;
} }

View file

@ -54,7 +54,9 @@ protected:
typedef QList<FileToCopy> FilesToCopy; typedef QList<FileToCopy> FilesToCopy;
void getFilesList(FilesToCopy &files); void getFile(const QFileInfo &info, const QDir &srcDir, FilesToCopy &files) const;
void getFilesList(FilesToCopy &files) const;
bool copyFiles(const FilesToCopy &files); bool copyFiles(const FilesToCopy &files);
IOperationProgressListener *m_listener; IOperationProgressListener *m_listener;

View file

@ -180,7 +180,7 @@ int main(int argc, char *argv[])
// copy installer and required files to TEMP directory // copy installer and required files to TEMP directory
if (QDir().mkdir(tempPath) && copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) if (QDir().mkdir(tempPath) && copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath))
{ {
QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); QString tempFile = tempPath + "/" + QFileInfo(getInstallerCurrentFilePath()).fileName();
// launch copy in TEMP directory with same arguments // launch copy in TEMP directory with same arguments
if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0;

View file

@ -38,7 +38,7 @@ CMigrateDialog::CMigrateDialog():QDialog()
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{ {
// Ryzom is in the same directory as Ryzom Installer // Ryzom is in the same directory as Ryzom Installer
m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory(); m_currentDirectory = CConfigFile::getInstance()->getInstallerCurrentDirPath();
if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory))
{ {

View file

@ -729,18 +729,28 @@ void COperationDialog::copyInstaller()
// rename old client to installer // rename old client to installer
QString oldInstallerFullPath = QApplication::applicationFilePath(); QString oldInstallerFullPath = config->getInstallerCurrentFilePath();
QString newInstallerFullPath = config->getInstallerInstalledFilePath(); QString newInstallerFullPath = config->getInstallerInstalledFilePath();
if (!newInstallerFullPath.isEmpty()) if (!newInstallerFullPath.isEmpty())
{ {
QString srcDir = config->getSrcServerDirectory();
if (srcDir.isEmpty()) srcDir = config->getInstallerCurrentDirPath();
// always copy new installers // always copy new installers
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setIncludeFilter(config->getInstallerRequiredFiles()); copier.setIncludeFilter(config->getInstallerRequiredFiles());
#ifdef Q_OS_WIN32
copier.addFile(oldInstallerFullPath); copier.addFile(oldInstallerFullPath);
copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); #endif
copier.setSourceDirectory(srcDir);
copier.setDestinationDirectory(config->getInstallationDirectory()); copier.setDestinationDirectory(config->getInstallationDirectory());
copier.exec();
if (!copier.exec()) return;
#ifdef Q_OS_WIN32
// only happens under Windows in Debug or when migrating
// copied file // copied file
oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName(); oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName();
@ -754,6 +764,7 @@ void COperationDialog::copyInstaller()
// rename new installer with final name // rename new installer with final name
QFile::rename(oldInstallerFullPath, newInstallerFullPath); QFile::rename(oldInstallerFullPath, newInstallerFullPath);
} }
#endif
// create menu directory if defined // create menu directory if defined
QString path = config->getMenuDirectory(); QString path = config->getMenuDirectory();