Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2016-05-16 16:31:30 +02:00
commit 57268e0f43
12 changed files with 179 additions and 85 deletions

View file

@ -105,7 +105,7 @@ bool CConfigFile::load(const QString &filename)
settings.beginGroup(QString("profile_%1").arg(i)); settings.beginGroup(QString("profile_%1").arg(i));
profile.id = settings.value("id").toInt(); profile.id = settings.value("id").toString();
profile.name = settings.value("name").toString(); profile.name = settings.value("name").toString();
profile.account = settings.value("account").toString(); profile.account = settings.value("account").toString();
profile.server = settings.value("server").toString(); profile.server = settings.value("server").toString();
@ -410,11 +410,20 @@ bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
// directory doesn't exist // directory doesn't exist
if (!dir.exists()) return false; if (!dir.exists()) return false;
if (!dir.cd("data") && dir.exists()) return false; if (!dir.cd("data") || !dir.exists()) return false;
// at least 200 BNP in data directory // at least 200 BNP in data directory
if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false; if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false;
// fonts.bnp is required
if (!dir.exists("fonts.bnp")) return false;
// gamedev.bnp is required
if (!dir.exists("gamedev.bnp")) return false;
// interfaces.bnp is required
if (!dir.exists("interfaces.bnp")) return false;
// TODO: more checks // TODO: more checks
return true; return true;
@ -550,16 +559,18 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
{ {
// user decided to copy files // user decided to copy files
// selected directory contains Ryzom files (shouldn't fail)
if (!areRyzomDataInstalledIn(getSrcServerDirectory()))
{
return ShowWizard;
}
// data are not copied // data are not copied
if (!areRyzomDataInstalledIn(serverDirectory)) if (!areRyzomDataInstalledIn(serverDirectory))
{ {
return CopyServerFiles; // selected directory contains Ryzom files (shouldn't fail)
if (areRyzomDataInstalledIn(getSrcServerDirectory()))
{
return CopyServerFiles;
}
else
{
return ShowWizard;
}
} }
// client is not extracted from BNP // client is not extracted from BNP
@ -590,7 +601,7 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
} }
// no default profile // no default profile
if (profile.id < 0) if (profile.id.isEmpty())
{ {
return CreateProfile; return CreateProfile;
} }

View file

@ -46,12 +46,11 @@ struct CProfile
{ {
CProfile() CProfile()
{ {
id = -1;
desktopShortcut = false; desktopShortcut = false;
menuShortcut = false; menuShortcut = false;
} }
int id; QString id;
QString account; QString account;
QString name; QString name;
QString server; QString server;

View file

@ -52,6 +52,8 @@ void CFilesCleaner::setDirectory(const QString &src)
bool CFilesCleaner::exec() bool CFilesCleaner::exec()
{ {
if (m_listener) m_listener->operationPrepare();
QDir dir(m_directory); QDir dir(m_directory);
// directory doesn't exist // directory doesn't exist
@ -62,9 +64,21 @@ bool CFilesCleaner::exec()
// temporary files // temporary files
QStringList files = dir.entryList(QStringList() << "*.string_cache" << "*.packed_sheets" << "*.packed" << "*.pem", QDir::Files); QStringList files = dir.entryList(QStringList() << "*.string_cache" << "*.packed_sheets" << "*.packed" << "*.pem", QDir::Files);
if (m_listener)
{
m_listener->operationInit(0, files.size());
m_listener->operationStart();
}
int filesCount = 0;
foreach(const QString &file, files) foreach(const QString &file, files)
{ {
dir.remove(file); dir.remove(file);
if (m_listener) m_listener->operationProgress(filesCount, file);
++filesCount;
} }
// fonts directory is not needed anymore // fonts directory is not needed anymore
@ -73,7 +87,7 @@ bool CFilesCleaner::exec()
dir.removeRecursively(); dir.removeRecursively();
} }
if (m_listener) m_listener->operationFinish(); if (m_listener) m_listener->operationSuccess(files.size());
return true; return true;
} }

View file

@ -181,7 +181,6 @@ bool CFilesCopier::copyFiles(const FilesToCopy &files)
if (m_listener) if (m_listener)
{ {
m_listener->operationSuccess(totalSize); m_listener->operationSuccess(totalSize);
m_listener->operationFinish();
} }
return true; return true;

View file

@ -457,7 +457,6 @@ bool CFilesExtractor::extract7z()
if (m_listener) if (m_listener)
{ {
m_listener->operationSuccess(totalUncompressed); m_listener->operationSuccess(totalUncompressed);
m_listener->operationFinish();
} }
return true; return true;
@ -563,7 +562,6 @@ bool CFilesExtractor::extractZip()
if (m_listener) if (m_listener)
{ {
m_listener->operationSuccess(totalSize); m_listener->operationSuccess(totalSize);
m_listener->operationFinish();
} }
return true; return true;
@ -594,7 +592,6 @@ bool CFilesExtractor::progress(const std::string &filename, uint32 currentSize,
if (m_listener) if (m_listener)
{ {
m_listener->operationSuccess((qint64)totalSize); m_listener->operationSuccess((qint64)totalSize);
m_listener->operationFinish();
} }
} }
@ -617,6 +614,7 @@ bool CFilesExtractor::extractBnp()
if (m_listener && m_listener->operationShouldStop()) if (m_listener && m_listener->operationShouldStop())
{ {
// stopped // stopped
m_listener->operationStop();
return true; return true;
} }

View file

@ -29,7 +29,6 @@ public:
virtual void operationProgress(qint64 current, const QString &filename) =0; virtual void operationProgress(qint64 current, const QString &filename) =0;
virtual void operationSuccess(qint64 total) =0; virtual void operationSuccess(qint64 total) =0;
virtual void operationFail(const QString &error) =0; virtual void operationFail(const QString &error) =0;
virtual void operationFinish() =0;
virtual bool operationShouldStop() =0; virtual bool operationShouldStop() =0;
}; };

View file

@ -42,6 +42,8 @@ COperationDialog::COperationDialog():QDialog(), m_aborting(false)
{ {
setupUi(this); setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
#if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB) #if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button = new QWinTaskbarButton(this); m_button = new QWinTaskbarButton(this);
#endif #endif
@ -70,6 +72,7 @@ COperationDialog::COperationDialog():QDialog(), m_aborting(false)
connect(this, SIGNAL(progress(qint64, QString)), SLOT(onProgressProgress(qint64, QString))); connect(this, SIGNAL(progress(qint64, QString)), SLOT(onProgressProgress(qint64, QString)));
connect(this, SIGNAL(success(qint64)), SLOT(onProgressSuccess(qint64))); connect(this, SIGNAL(success(qint64)), SLOT(onProgressSuccess(qint64)));
connect(this, SIGNAL(fail(QString)), SLOT(onProgressFail(QString))); connect(this, SIGNAL(fail(QString)), SLOT(onProgressFail(QString)));
connect(this, SIGNAL(done()), SLOT(onDone()));
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
} }
@ -88,7 +91,10 @@ void COperationDialog::processNextStep()
// default profile // default profile
const CProfile &configuration = config->getProfile(); const CProfile &configuration = config->getProfile();
switch(config->getNextStep()) // long operations are done in a thread
CConfigFile::InstallationStep step = config->getNextStep();
switch(step)
{ {
case CConfigFile::DisplayNoServerError: case CConfigFile::DisplayNoServerError:
break; break;
@ -97,7 +103,7 @@ void COperationDialog::processNextStep()
break; break;
case CConfigFile::DownloadData: case CConfigFile::DownloadData:
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part"); downloadData();
break; break;
case CConfigFile::ExtractDownloadedData: case CConfigFile::ExtractDownloadedData:
@ -105,7 +111,7 @@ void COperationDialog::processNextStep()
break; break;
case CConfigFile::DownloadClient: case CConfigFile::DownloadClient:
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part"); downloadClient();
break; break;
case CConfigFile::ExtractDownloadedClient: case CConfigFile::ExtractDownloadedClient:
@ -136,12 +142,14 @@ void COperationDialog::processNextStep()
createDefaultShortcuts(); createDefaultShortcuts();
break; break;
case CConfigFile::Done:
accept();
break;
default: default:
// cases already managed in main.cpp // cases already managed in main.cpp
break; break;
} }
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
} }
void COperationDialog::showEvent(QShowEvent *e) void COperationDialog::showEvent(QShowEvent *e)
@ -218,7 +226,7 @@ void COperationDialog::onProgressStop()
m_button->progress()->hide(); m_button->progress()->hide();
#endif #endif
close(); reject();
} }
void COperationDialog::onProgressProgress(qint64 current, const QString &filename) void COperationDialog::onProgressProgress(qint64 current, const QString &filename)
@ -248,7 +256,33 @@ void COperationDialog::onProgressFail(const QString &error)
void COperationDialog::onDone() void COperationDialog::onDone()
{ {
processNextStep(); if (!operationShouldStop()) processNextStep();
}
void COperationDialog::downloadData()
{
CConfigFile *config = CConfigFile::getInstance();
// default server
const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Download data required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
}
void COperationDialog::downloadClient()
{
CConfigFile *config = CConfigFile::getInstance();
// default server
const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Download client required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part");
} }
void COperationDialog::copyServerFiles() void COperationDialog::copyServerFiles()
@ -258,8 +292,8 @@ void COperationDialog::copyServerFiles()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
// default profile m_currentOperation = QApplication::tr("Copy client files required by server %1").arg(server.name);
const CProfile &configuration = config->getProfile(); m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
QStringList serverFiles; QStringList serverFiles;
serverFiles << "cfg"; serverFiles << "cfg";
@ -269,9 +303,6 @@ void COperationDialog::copyServerFiles()
serverFiles << "unpack"; serverFiles << "unpack";
serverFiles << "client_default.cfg"; serverFiles << "client_default.cfg";
m_currentOperation = QApplication::tr("Copying client files needed for server %1...").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setSourceDirectory(config->getSrcServerDirectory()); copier.setSourceDirectory(config->getSrcServerDirectory());
copier.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id); copier.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id);
@ -283,6 +314,8 @@ void COperationDialog::copyServerFiles()
else else
{ {
} }
emit done();
} }
void COperationDialog::copyProfileFiles() void COperationDialog::copyProfileFiles()
@ -295,6 +328,9 @@ void COperationDialog::copyProfileFiles()
// default profile // default profile
const CProfile &profile = config->getProfile(); const CProfile &profile = config->getProfile();
m_currentOperation = QApplication::tr("Copy old profile to new location");
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
QStringList profileFiles; QStringList profileFiles;
profileFiles << "cache"; profileFiles << "cache";
profileFiles << "save"; profileFiles << "save";
@ -314,6 +350,8 @@ void COperationDialog::copyProfileFiles()
else else
{ {
} }
emit done();
} }
void COperationDialog::extractBnpClient() void COperationDialog::extractBnpClient()
@ -323,13 +361,44 @@ void COperationDialog::extractBnpClient()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
// default profile m_currentOperation = QApplication::tr("Extract client to new location");
const CProfile &profile = config->getProfile(); m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
QString destinationDirectory = config->getInstallationDirectory() + "/" + server.id;
CFilesExtractor extractor(this); CFilesExtractor extractor(this);
extractor.setSourceFile(config->getSrcServerClientBNPFullPath()); extractor.setSourceFile(config->getSrcServerClientBNPFullPath());
extractor.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id); extractor.setDesinationDirectory(destinationDirectory);
extractor.exec(); extractor.exec();
QString upgradeScript = destinationDirectory + "/upgd_nl.";
#ifdef Q_OS_WIN
upgradeScript += "bat";
#else
upgradeScript += "sh";
#endif
if (QFile::exists(upgradeScript))
{
QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("RYZOM_CLIENT", QDir::toNativeSeparators(destinationDirectory + "/ryzom_client_r.exe"));
env.insert("UNPACKPATH", QDir::toNativeSeparators(destinationDirectory + "/unpack"));
env.insert("ROOTPATH", QDir::toNativeSeparators(destinationDirectory));
env.insert("STARTUPPATH", "");
process.setProcessEnvironment(env);
process.start(upgradeScript);
while (process.waitForFinished())
{
qDebug() << "waiting";
}
}
emit done();
} }
void COperationDialog::cleanFiles() void COperationDialog::cleanFiles()
@ -339,12 +408,54 @@ void COperationDialog::cleanFiles()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
// default profile m_currentOperation = QApplication::tr("Clean obsolete files");
const CProfile &profile = config->getProfile(); m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
CFilesCleaner cleaner(this); CFilesCleaner cleaner(this);
cleaner.setDirectory(config->getInstallationDirectory() + "/" + server.id); cleaner.setDirectory(config->getInstallationDirectory() + "/" + server.id);
cleaner.exec(); cleaner.exec();
emit done();
}
bool COperationDialog::createDefaultProfile()
{
CConfigFile *config = CConfigFile::getInstance();
CServer server = config->getServer(config->getDefaultServerIndex());
m_currentOperation = QApplication::tr("Create default profile");
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
CProfile profile;
profile.id = "0";
profile.executable = config->getClientFullPath();
profile.name = QString("Ryzom (%1)").arg(server.name);
profile.server = server.id;
profile.comments = "Default profile created by Ryzom Installer";
#ifdef Q_OS_WIN32
// C:\Users\Public\Desktop
profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
#endif
// TODO
// profile.menuShortcut
config->addProfile(profile);
config->save();
emit done();
return true;
}
bool COperationDialog::createDefaultShortcuts()
{
emit done();
return true;
} }
void COperationDialog::operationPrepare() void COperationDialog::operationPrepare()
@ -382,50 +493,9 @@ void COperationDialog::operationFail(const QString &error)
emit fail(error); emit fail(error);
} }
void COperationDialog::operationFinish()
{
emit done();
}
bool COperationDialog::operationShouldStop() bool COperationDialog::operationShouldStop()
{ {
QMutexLocker locker(&m_abortingMutex); QMutexLocker locker(&m_abortingMutex);
return m_aborting; return m_aborting;
} }
bool COperationDialog::createDefaultProfile()
{
CConfigFile *config = CConfigFile::getInstance();
CServer server = config->getServer(config->getDefaultServerIndex());
CProfile profile;
profile.id = 0;
profile.executable = config->getClientFullPath();
profile.name = QString("Ryzom (%1)").arg(server.name);
profile.server = server.id;
profile.comments = "Default profile created by Ryzom Installer";
#ifdef Q_OS_WIN32
profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
#endif
// TODO
// profile.menuShortcut
config->addProfile(profile);
config->save();
onDone();
return true;
}
bool COperationDialog::createDefaultShortcuts()
{
onDone();
return true;
}

View file

@ -82,6 +82,8 @@ protected:
void processNextStep(); void processNextStep();
// operations // operations
void downloadData();
void downloadClient();
void copyServerFiles(); void copyServerFiles();
void copyProfileFiles(); void copyProfileFiles();
void extractBnpClient(); void extractBnpClient();
@ -97,7 +99,6 @@ protected:
virtual void operationProgress(qint64 current, const QString &filename); virtual void operationProgress(qint64 current, const QString &filename);
virtual void operationSuccess(qint64 total); virtual void operationSuccess(qint64 total);
virtual void operationFail(const QString &error); virtual void operationFail(const QString &error);
virtual void operationFinish();
virtual bool operationShouldStop(); virtual bool operationShouldStop();

View file

@ -38,7 +38,7 @@ CProfilesDialog::CProfilesDialog():QDialog(), m_currentProfileIndex(-1)
profilesListView->setModel(m_model); profilesListView->setModel(m_model);
serverComboBox->setModel(m_serversModel); serverComboBox->setModel(m_serversModel);
int index = m_model->getIndexFromProfileID(CConfigFile::getInstance()->getDefaultProfileIndex()); int index = CConfigFile::getInstance()->getDefaultProfileIndex();
profilesListView->setCurrentIndex(m_model->index(index, 0)); profilesListView->setCurrentIndex(m_model->index(index, 0));
displayProfile(index); displayProfile(index);
@ -97,7 +97,7 @@ void CProfilesDialog::displayProfile(int index)
const CProfile &profile = m_model->getProfiles()[index]; const CProfile &profile = m_model->getProfiles()[index];
// update all widgets with content of profile // update all widgets with content of profile
profileIdLabel->setText(QString::number(profile.id)); profileIdLabel->setText(profile.id);
accountEdit->setText(profile.account); accountEdit->setText(profile.account);
nameEdit->setText(profile.name); nameEdit->setText(profile.name);
serverComboBox->setCurrentIndex(m_serversModel->getIndexFromServerID(profile.server)); serverComboBox->setCurrentIndex(m_serversModel->getIndexFromServerID(profile.server));

View file

@ -24,7 +24,7 @@ QVariant CProfilesModel::data(const QModelIndex &index, int role) const
const CProfile &profile = m_profiles.at(index.row()); const CProfile &profile = m_profiles.at(index.row());
return QString("%1 (#%2)").arg(profile.name).arg(profile.id); return tr("#%1: %2").arg(profile.id).arg(profile.name);
} }
bool CProfilesModel::removeRows(int row, int count, const QModelIndex &parent) bool CProfilesModel::removeRows(int row, int count, const QModelIndex &parent)
@ -48,7 +48,7 @@ bool CProfilesModel::save() const
return true; return true;
} }
int CProfilesModel::getIndexFromProfileID(int profileId) const int CProfilesModel::getIndexFromProfileID(const QString &profileId) const
{ {
for(int i = 0; i < m_profiles.size(); ++i) for(int i = 0; i < m_profiles.size(); ++i)
{ {
@ -58,7 +58,7 @@ int CProfilesModel::getIndexFromProfileID(int profileId) const
return -1; return -1;
} }
int CProfilesModel::getProfileIDFromIndex(int index) const QString CProfilesModel::getProfileIDFromIndex(int index) const
{ {
if (index < 0 || index >= m_profiles.size()) return -1; if (index < 0 || index >= m_profiles.size()) return -1;

View file

@ -25,8 +25,8 @@ public:
bool save() const; bool save() const;
int getIndexFromProfileID(int profileId) const; int getIndexFromProfileID(const QString &profileId) const;
int getProfileIDFromIndex(int index) const; QString getProfileIDFromIndex(int index) const;
private: private:
CProfiles m_profiles; CProfiles m_profiles;

View file

@ -2,6 +2,9 @@
<ui version="4.0"> <ui version="4.0">
<class>OperationDialog</class> <class>OperationDialog</class>
<widget class="QDialog" name="OperationDialog"> <widget class="QDialog" name="OperationDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -11,7 +14,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Ryzom Installer</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>