2016-05-16 09:11:40 +00:00
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "stdpch.h"
# include "operationdialog.h"
# include "downloader.h"
# include "profilesdialog.h"
# include "configfile.h"
# include "config.h"
# include "profilesmodel.h"
# include "filescopier.h"
# include "filesextractor.h"
# include "filescleaner.h"
# include "seven_zip.h"
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
# include <QtWinExtras/QWinTaskbarProgress>
# include <QtWinExtras/QWinTaskbarButton>
# endif
2016-05-25 21:26:40 +00:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
2016-05-16 09:11:40 +00:00
# ifdef DEBUG_NEW
# define new DEBUG_NEW
# endif
2016-05-29 18:30:53 +00:00
COperationDialog : : COperationDialog ( QWidget * parent ) : QDialog ( parent ) , m_aborting ( false ) , m_operation ( OperationNone )
2016-05-16 09:11:40 +00:00
{
setupUi ( this ) ;
2016-05-16 12:50:15 +00:00
setWindowFlags ( windowFlags ( ) & ~ Qt : : WindowContextHelpButtonHint ) ;
2016-05-16 09:11:40 +00:00
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button = new QWinTaskbarButton ( this ) ;
# endif
// connect(resumeButton, SIGNAL(clicked()), SLOT(onResumeClicked()));
// connect(stopButton, SIGNAL(clicked()), SLOT(onStopClicked()));
// downloader
m_downloader = new CDownloader ( this ) ;
connect ( m_downloader , SIGNAL ( downloadPrepare ( ) ) , SLOT ( onProgressPrepare ( ) ) ) ;
connect ( m_downloader , SIGNAL ( downloadInit ( qint64 , qint64 ) ) , SLOT ( onProgressInit ( qint64 , qint64 ) ) ) ;
connect ( m_downloader , SIGNAL ( downloadStart ( ) ) , SLOT ( onProgressStart ( ) ) ) ;
connect ( m_downloader , SIGNAL ( downloadStop ( ) ) , SLOT ( onProgressStop ( ) ) ) ;
2016-05-26 17:35:13 +00:00
connect ( m_downloader , SIGNAL ( downloadProgress ( qint64 , QString ) ) , SLOT ( onProgressProgress ( qint64 , QString ) ) ) ;
2016-05-16 09:11:40 +00:00
connect ( m_downloader , SIGNAL ( downloadSuccess ( qint64 ) ) , SLOT ( onProgressSuccess ( qint64 ) ) ) ;
connect ( m_downloader , SIGNAL ( downloadFail ( QString ) ) , SLOT ( onProgressFail ( QString ) ) ) ;
connect ( operationButtonBox , SIGNAL ( clicked ( QAbstractButton * ) ) , SLOT ( onAbortClicked ( ) ) ) ;
// operations
connect ( this , SIGNAL ( prepare ( ) ) , SLOT ( onProgressPrepare ( ) ) ) ;
connect ( this , SIGNAL ( init ( qint64 , qint64 ) ) , SLOT ( onProgressInit ( qint64 , qint64 ) ) ) ;
connect ( this , SIGNAL ( start ( ) ) , SLOT ( onProgressStart ( ) ) ) ;
connect ( this , SIGNAL ( stop ( ) ) , SLOT ( onProgressStop ( ) ) ) ;
connect ( this , SIGNAL ( progress ( qint64 , QString ) ) , SLOT ( onProgressProgress ( qint64 , QString ) ) ) ;
connect ( this , SIGNAL ( success ( qint64 ) ) , SLOT ( onProgressSuccess ( qint64 ) ) ) ;
connect ( this , SIGNAL ( fail ( QString ) ) , SLOT ( onProgressFail ( QString ) ) ) ;
2016-05-16 12:52:47 +00:00
connect ( this , SIGNAL ( done ( ) ) , SLOT ( onDone ( ) ) ) ;
2016-05-16 09:11:40 +00:00
setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Fixed ) ;
}
COperationDialog : : ~ COperationDialog ( )
{
}
2016-05-29 18:34:43 +00:00
void COperationDialog : : setOperation ( Operation operation )
{
m_operation = operation ;
}
2016-06-04 17:57:50 +00:00
void COperationDialog : : setUninstallComponents ( const SUninstallComponents & components )
{
m_components = components ;
}
2016-05-16 09:11:40 +00:00
void COperationDialog : : processNextStep ( )
2016-05-29 18:34:43 +00:00
{
switch ( m_operation )
{
case OperationMigrate :
processMigrateNextStep ( ) ;
break ;
case OperationInstall :
processInstallNextStep ( ) ;
break ;
case OperationUninstall :
processUninstallNextStep ( ) ;
break ;
default :
break ;
}
}
void COperationDialog : : processMigrateNextStep ( )
2016-05-16 09:11:40 +00:00
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
// default profile
const CProfile & configuration = config - > getProfile ( ) ;
2016-05-16 12:54:24 +00:00
// long operations are done in a thread
CConfigFile : : InstallationStep step = config - > getNextStep ( ) ;
switch ( step )
2016-05-16 09:11:40 +00:00
{
case CConfigFile : : DisplayNoServerError :
break ;
2016-05-25 21:23:48 +00:00
case CConfigFile : : ShowMigrateWizard :
break ;
case CConfigFile : : ShowInstallWizard :
2016-05-16 09:11:40 +00:00
break ;
case CConfigFile : : DownloadData :
2016-05-16 12:49:18 +00:00
downloadData ( ) ;
2016-05-16 09:11:40 +00:00
break ;
case CConfigFile : : ExtractDownloadedData :
// TODO
break ;
case CConfigFile : : DownloadClient :
2016-05-16 12:49:18 +00:00
downloadClient ( ) ;
2016-05-16 09:11:40 +00:00
break ;
case CConfigFile : : ExtractDownloadedClient :
// TODO
break ;
case CConfigFile : : CopyServerFiles :
QtConcurrent : : run ( this , & COperationDialog : : copyServerFiles ) ;
break ;
case CConfigFile : : CopyProfileFiles :
QtConcurrent : : run ( this , & COperationDialog : : copyProfileFiles ) ;
break ;
2016-05-29 18:34:43 +00:00
case CConfigFile : : CleanFiles :
QtConcurrent : : run ( this , & COperationDialog : : cleanFiles ) ;
break ;
2016-05-16 09:11:40 +00:00
case CConfigFile : : ExtractBnpClient :
QtConcurrent : : run ( this , & COperationDialog : : extractBnpClient ) ;
break ;
2016-05-26 17:30:18 +00:00
case CConfigFile : : CopyInstaller :
2016-05-29 18:34:43 +00:00
QtConcurrent : : run ( this , & COperationDialog : : copyInstaller ) ;
2016-05-26 17:30:18 +00:00
break ;
2016-05-29 18:34:43 +00:00
case CConfigFile : : UninstallOldClient :
uninstallOldClient ( ) ;
2016-05-16 09:11:40 +00:00
break ;
case CConfigFile : : CreateProfile :
createDefaultProfile ( ) ;
break ;
case CConfigFile : : CreateShortcuts :
createDefaultShortcuts ( ) ;
break ;
2016-05-26 17:34:15 +00:00
case CConfigFile : : CreateAddRemoveEntry :
createAddRemoveEntry ( ) ;
break ;
2016-05-16 12:53:19 +00:00
case CConfigFile : : Done :
accept ( ) ;
break ;
2016-05-16 09:11:40 +00:00
default :
// cases already managed in main.cpp
break ;
}
}
2016-05-29 18:34:43 +00:00
void COperationDialog : : processInstallNextStep ( )
{
}
void COperationDialog : : processUninstallNextStep ( )
{
2016-06-04 17:57:50 +00:00
CConfigFile * config = CConfigFile : : getInstance ( ) ;
if ( ! m_components . servers . isEmpty ( ) )
{
QtConcurrent : : run ( this , & COperationDialog : : deleteComponentsServers ) ;
}
else if ( ! m_components . profiles . isEmpty ( ) )
{
QtConcurrent : : run ( this , & COperationDialog : : deleteComponentsProfiles ) ;
}
else if ( m_components . installer )
{
QtConcurrent : : run ( this , & COperationDialog : : deleteComponentsInstaller ) ;
}
else
{
// done
accept ( ) ;
}
2016-05-29 18:34:43 +00:00
}
2016-05-16 09:11:40 +00:00
void COperationDialog : : showEvent ( QShowEvent * e )
{
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > setWindow ( windowHandle ( ) ) ;
# endif
e - > accept ( ) ;
processNextStep ( ) ;
}
void COperationDialog : : closeEvent ( QCloseEvent * e )
{
if ( e - > spontaneous ( ) )
{
e - > ignore ( ) ;
onAbortClicked ( ) ;
}
}
void COperationDialog : : onAbortClicked ( )
{
if ( m_downloader - > isDownloading ( ) )
{
if ( ! m_downloader - > supportsResume ( ) )
{
QMessageBox : : StandardButton res = QMessageBox : : question ( this , tr ( " Confirmation " ) , tr ( " Warning, this server doesn't support resume! If you stop download now, you won't be able to resume it later. \n Are you sure to abort download? " ) ) ;
if ( res ! = QMessageBox : : Yes ) return ;
}
}
QMutexLocker locker ( & m_abortingMutex ) ;
m_aborting = true ;
}
void COperationDialog : : onProgressPrepare ( )
{
operationProgressBar - > setFormat ( tr ( " %p% (%v/%m KiB) " ) ) ;
operationProgressBar - > setMinimum ( 0 ) ;
operationProgressBar - > setMaximum ( 0 ) ;
operationProgressBar - > setValue ( 0 ) ;
operationLabel - > setText ( m_currentOperation ) ;
}
void COperationDialog : : onProgressInit ( qint64 current , qint64 total )
{
operationProgressBar - > setMinimum ( 0 ) ;
operationProgressBar - > setMaximum ( total / 1024 ) ;
operationProgressBar - > setValue ( current / 1024 ) ;
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > progress ( ) - > setMinimum ( 0 ) ;
m_button - > progress ( ) - > setMaximum ( total / 1024 ) ;
m_button - > progress ( ) - > setValue ( current / 1024 ) ;
# endif
}
void COperationDialog : : onProgressStart ( )
{
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > progress ( ) - > show ( ) ;
# endif
}
void COperationDialog : : onProgressStop ( )
{
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > progress ( ) - > hide ( ) ;
# endif
2016-05-16 12:53:19 +00:00
reject ( ) ;
2016-05-16 09:11:40 +00:00
}
void COperationDialog : : onProgressProgress ( qint64 current , const QString & filename )
{
operationProgressLabel - > setText ( m_currentOperationProgressFormat . arg ( filename ) ) ;
operationProgressBar - > setValue ( current / 1024 ) ;
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > progress ( ) - > setValue ( current / 1024 ) ;
# endif
}
void COperationDialog : : onProgressSuccess ( qint64 total )
{
operationProgressBar - > setValue ( total / 1024 ) ;
# if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
m_button - > progress ( ) - > hide ( ) ;
# endif
}
void COperationDialog : : onProgressFail ( const QString & error )
{
QMessageBox : : critical ( this , tr ( " Error " ) , error ) ;
}
void COperationDialog : : onDone ( )
{
2016-05-16 12:49:18 +00:00
if ( ! operationShouldStop ( ) ) processNextStep ( ) ;
}
void COperationDialog : : downloadData ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
2016-05-16 14:21:47 +00:00
m_currentOperation = QApplication : : tr ( " Download data required by server %1 " ) . arg ( server . name ) ;
2016-05-16 12:49:18 +00:00
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 ( ) ;
2016-05-16 14:21:47 +00:00
m_currentOperation = QApplication : : tr ( " Download client required by server %1 " ) . arg ( server . name ) ;
2016-05-16 12:49:18 +00:00
m_currentOperationProgressFormat = QApplication : : tr ( " Downloading %1... " ) ;
m_downloader - > prepareFile ( config - > expandVariables ( server . clientDownloadUrl ) , config - > getInstallationDirectory ( ) + " / " + config - > expandVariables ( server . clientDownloadFilename ) + " .part " ) ;
2016-05-16 09:11:40 +00:00
}
void COperationDialog : : copyServerFiles ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
2016-05-16 14:21:47 +00:00
m_currentOperation = QApplication : : tr ( " Copy client files required by server %1 " ) . arg ( server . name ) ;
2016-05-16 12:50:53 +00:00
m_currentOperationProgressFormat = QApplication : : tr ( " Copying %1... " ) ;
2016-05-16 09:11:40 +00:00
QStringList serverFiles ;
serverFiles < < " cfg " ;
serverFiles < < " data " ;
serverFiles < < " examples " ;
serverFiles < < " patch " ;
serverFiles < < " unpack " ;
serverFiles < < " client_default.cfg " ;
CFilesCopier copier ( this ) ;
copier . setSourceDirectory ( config - > getSrcServerDirectory ( ) ) ;
2016-05-26 17:34:48 +00:00
copier . setDestinationDirectory ( config - > getInstallationDirectory ( ) + " / " + server . id ) ;
2016-05-16 09:11:40 +00:00
copier . setIncludeFilter ( serverFiles ) ;
if ( copier . exec ( ) )
{
}
else
{
}
2016-05-16 12:52:47 +00:00
emit done ( ) ;
2016-05-16 09:11:40 +00:00
}
void COperationDialog : : copyProfileFiles ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
// default profile
const CProfile & profile = config - > getProfile ( ) ;
2016-05-16 12:50:53 +00:00
m_currentOperation = QApplication : : tr ( " Copy old profile to new location " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Copying %1... " ) ;
2016-05-16 09:11:40 +00:00
QStringList profileFiles ;
profileFiles < < " cache " ;
profileFiles < < " save " ;
profileFiles < < " user " ;
profileFiles < < " screenshots " ;
profileFiles < < " client.cfg " ;
profileFiles < < " *.log " ;
CFilesCopier copier ( this ) ;
copier . setSourceDirectory ( config - > getSrcProfileDirectory ( ) ) ;
2016-05-26 17:34:48 +00:00
copier . setDestinationDirectory ( config - > getProfileDirectory ( ) + " / " + profile . id ) ;
2016-05-16 09:11:40 +00:00
copier . setIncludeFilter ( profileFiles ) ;
if ( copier . exec ( ) )
{
}
else
{
}
2016-05-16 12:52:47 +00:00
emit done ( ) ;
2016-05-16 09:11:40 +00:00
}
void COperationDialog : : extractBnpClient ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
2016-05-16 12:50:53 +00:00
m_currentOperation = QApplication : : tr ( " Extract client to new location " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Extracting %1... " ) ;
QString destinationDirectory = config - > getInstallationDirectory ( ) + " / " + server . id ;
2016-05-16 09:11:40 +00:00
CFilesExtractor extractor ( this ) ;
extractor . setSourceFile ( config - > getSrcServerClientBNPFullPath ( ) ) ;
2016-05-16 12:52:16 +00:00
extractor . setDesinationDirectory ( destinationDirectory ) ;
2016-05-16 09:11:40 +00:00
extractor . exec ( ) ;
2016-05-16 12:52:16 +00:00
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 ( ) ;
2016-05-17 18:47:38 +00:00
env . insert ( " RYZOM_CLIENT " , QDir : : toNativeSeparators ( destinationDirectory + " / " + server . clientFilename ) ) ;
2016-05-16 12:52:16 +00:00
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 ( ) ;
2016-05-16 09:11:40 +00:00
}
2016-05-29 18:34:43 +00:00
void COperationDialog : : copyInstaller ( )
2016-05-26 17:30:18 +00:00
{
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 ( ) ;
}
2016-05-29 18:32:33 +00:00
void COperationDialog : : uninstallOldClient ( )
{
# ifdef Q_OS_WIN
# ifdef Q_OS_WIN64
// use WOW6432Node in 64 bits (64 bits OS and 64 bits Installer) because Ryzom old installer was in 32 bits
QSettings settings ( " HKEY_LOCAL_MACHINE \\ SOFTWARE \\ WOW6432Node \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\ Ryzom " , QSettings : : NativeFormat ) ;
# else
QSettings settings ( " HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\ Ryzom " , QSettings : : NativeFormat ) ;
# endif
// check if Ryzom 2.1.0 is installed
if ( settings . contains ( " UninstallString " ) )
{
QString uninstaller = settings . value ( " UninstallString " ) . toString ( ) ;
if ( ! uninstaller . isEmpty ( ) & & QFile : : exists ( uninstaller ) )
{
QMessageBox : : StandardButtons button = QMessageBox : : question ( this , tr ( " Uninstall old client " ) , tr ( " An old version of Ryzom has been detected on this system, would you like to uninstall it to save space disk? " ) ) ;
if ( button = = QMessageBox : : Yes )
{
CConfigFile : : getInstance ( ) - > setShouldUninstallOldClient ( true ) ;
QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( uninstaller ) ) ;
}
else
{
// don't ask this question anymore
CConfigFile : : getInstance ( ) - > setShouldUninstallOldClient ( false ) ;
}
}
}
# endif
emit done ( ) ;
}
2016-05-16 09:11:40 +00:00
void COperationDialog : : cleanFiles ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// default server
const CServer & server = config - > getServer ( ) ;
2016-05-16 12:50:53 +00:00
m_currentOperation = QApplication : : tr ( " Clean obsolete files " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Deleting %1... " ) ;
2016-05-16 09:11:40 +00:00
CFilesCleaner cleaner ( this ) ;
cleaner . setDirectory ( config - > getInstallationDirectory ( ) + " / " + server . id ) ;
cleaner . exec ( ) ;
2016-05-16 12:49:50 +00:00
emit done ( ) ;
}
bool COperationDialog : : createDefaultProfile ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
CServer server = config - > getServer ( config - > getDefaultServerIndex ( ) ) ;
m_currentOperation = QApplication : : tr ( " Create default profile " ) ;
CProfile profile ;
profile . id = " 0 " ;
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 ;
2016-05-16 09:11:40 +00:00
}
2016-05-25 21:26:40 +00:00
bool COperationDialog : : createAddRemoveEntry ( )
{
CConfigFile * config = CConfigFile : : getInstance ( ) ;
const CServer & server = config - > getServer ( ) ;
QString oldInstallerFilename = server . clientFilenameOld ;
QString newInstallerFilename = server . installerFilename ;
if ( ! oldInstallerFilename . isEmpty ( ) & & ! newInstallerFilename . isEmpty ( ) )
{
QString oldInstallerFullPath = config - > getSrcServerDirectory ( ) + " / " + oldInstallerFilename ;
QString newInstallerFullPath = config - > getInstallationDirectory ( ) + " / " + newInstallerFilename ;
if ( QFile : : exists ( newInstallerFullPath ) )
{
2016-05-26 17:34:15 +00:00
# ifdef Q_OS_WIN
2016-05-25 21:26:40 +00:00
QSettings settings ( " HKEY_CURRENT_USER \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\ Ryzom " , QSettings : : NativeFormat ) ;
QStringList versionTokens = QString ( RYZOM_VERSION ) . split ( ' . ' ) ;
2016-05-27 20:20:41 +00:00
QString nativeFullPath = QDir : : toNativeSeparators ( newInstallerFullPath ) ;
2016-05-25 21:26:40 +00:00
settings . setValue ( " Comments " , " " ) ;
2016-05-27 20:20:41 +00:00
settings . setValue ( " DisplayIcon " , nativeFullPath + " ,0 " ) ;
2016-05-25 21:26:40 +00:00
settings . setValue ( " DisplayName " , " Ryzom " ) ;
settings . setValue ( " DisplayVersion " , RYZOM_VERSION ) ;
settings . setValue ( " EstimatedSize " , 1500000 ) ; // TODO: compute real size
settings . setValue ( " InstallDate " , QDateTime : : currentDateTime ( ) . toString ( " Ymd " ) ) ;
settings . setValue ( " InstallLocation " , config - > getInstallationDirectory ( ) ) ;
settings . setValue ( " MajorVersion " , versionTokens [ 0 ] . toInt ( ) ) ;
settings . setValue ( " MinorVersion " , versionTokens [ 1 ] . toInt ( ) ) ;
settings . setValue ( " NoModify " , 0 ) ;
settings . setValue ( " NoRemove " , 0 ) ;
settings . setValue ( " NoRepair " , 0 ) ;
2016-05-27 20:20:41 +00:00
if ( ! config - > getProductPublisher ( ) . isEmpty ( ) ) settings . setValue ( " Publisher " , config - > getProductPublisher ( ) ) ;
settings . setValue ( " QuietUninstallString " , nativeFullPath + " -u -s " ) ;
settings . setValue ( " UninstallString " , nativeFullPath + " -u " ) ;
if ( ! config - > getProductUpdateUrl ( ) . isEmpty ( ) ) settings . setValue ( " URLUpdateInfo " , config - > getProductUpdateUrl ( ) ) ;
if ( ! config - > getProductAboutUrl ( ) . isEmpty ( ) ) settings . setValue ( " URLInfoAbout " , config - > getProductAboutUrl ( ) ) ;
if ( ! config - > getProductHelpUrl ( ) . isEmpty ( ) ) settings . setValue ( " HelpLink " , config - > getProductHelpUrl ( ) ) ;
2016-05-25 21:26:40 +00:00
// ModifyPath
2016-05-26 17:34:15 +00:00
# endif
2016-05-25 21:26:40 +00:00
}
}
2016-05-26 17:34:15 +00:00
emit done ( ) ;
2016-05-25 21:26:40 +00:00
return true ;
}
2016-06-07 11:24:26 +00:00
bool COperationDialog : : deleteAddRemoveEntry ( )
{
# ifdef Q_OS_WIN
QSettings settings ( " HKEY_CURRENT_USER \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\ Ryzom " , QSettings : : NativeFormat ) ;
settings . remove ( " " ) ;
# endif
emit done ( ) ;
return true ;
}
2016-06-04 17:57:50 +00:00
void COperationDialog : : deleteComponentsServers ( )
{
m_currentOperation = QApplication : : tr ( " Delete client files " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Deleting %1... " ) ;
2016-06-07 11:24:26 +00:00
emit prepare ( ) ;
emit init ( 0 , m_components . servers . size ( ) ) ;
emit start ( ) ;
2016-06-04 17:57:50 +00:00
CConfigFile * config = CConfigFile : : getInstance ( ) ;
2016-06-07 11:24:26 +00:00
int i = 0 ;
2016-06-04 17:57:50 +00:00
foreach ( int serverIndex , m_components . servers )
{
2016-06-07 11:24:26 +00:00
if ( operationShouldStop ( ) )
{
emit stop ( ) ;
return ;
}
2016-06-04 17:57:50 +00:00
const CServer & server = config - > getServer ( serverIndex ) ;
2016-06-07 11:24:26 +00:00
emit progress ( i + + , server . name ) ;
2016-06-04 17:57:50 +00:00
QString path = config - > getInstallationDirectory ( ) + " / " + server . id ;
QDir dir ( path ) ;
2016-06-07 11:24:26 +00:00
if ( dir . exists ( ) & & ! dir . removeRecursively ( ) )
2016-06-04 17:57:50 +00:00
{
2016-06-07 11:24:26 +00:00
emit fail ( tr ( " Unable to delete files for client %1 " ) . arg ( server . name ) ) ;
return ;
2016-06-04 17:57:50 +00:00
}
}
2016-06-07 11:24:26 +00:00
emit success ( m_components . servers . size ( ) ) ;
2016-06-04 17:57:50 +00:00
emit done ( ) ;
}
void COperationDialog : : deleteComponentsProfiles ( )
{
2016-06-07 11:24:26 +00:00
m_currentOperation = QApplication : : tr ( " Delete profiles " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Deleting profile %1... " ) ;
emit prepare ( ) ;
emit init ( 0 , m_components . servers . size ( ) ) ;
CConfigFile * config = CConfigFile : : getInstance ( ) ;
int i = 0 ;
foreach ( int profileIndex , m_components . profiles )
{
if ( operationShouldStop ( ) )
{
emit stop ( ) ;
return ;
}
const CProfile & profile = config - > getProfile ( profileIndex ) ;
emit progress ( i + + , profile . name ) ;
QString path = config - > getProfileDirectory ( ) + " / " + profile . id ;
QDir dir ( path ) ;
if ( dir . exists ( ) & & ! dir . removeRecursively ( ) )
{
emit fail ( tr ( " Unable to delete files for profile %1 " ) . arg ( profile . name ) ) ;
return ;
}
}
emit success ( m_components . servers . size ( ) ) ;
2016-06-04 17:57:50 +00:00
emit done ( ) ;
}
void COperationDialog : : deleteComponentsInstaller ( )
{
2016-06-07 11:24:26 +00:00
m_currentOperation = QApplication : : tr ( " Delete installer " ) ;
m_currentOperationProgressFormat = QApplication : : tr ( " Deleting %1... " ) ;
CConfigFile * config = CConfigFile : : getInstance ( ) ;
// TODO: delete installer
deleteAddRemoveEntry ( ) ;
emit onProgressSuccess ( m_components . servers . size ( ) ) ;
2016-06-04 17:57:50 +00:00
emit done ( ) ;
}
2016-05-16 09:11:40 +00:00
void COperationDialog : : operationPrepare ( )
{
emit prepare ( ) ;
}
void COperationDialog : : operationInit ( qint64 current , qint64 total )
{
emit init ( current , total ) ;
}
void COperationDialog : : operationStart ( )
{
emit start ( ) ;
}
void COperationDialog : : operationStop ( )
{
emit stop ( ) ;
}
void COperationDialog : : operationProgress ( qint64 current , const QString & filename )
{
emit progress ( current , filename ) ;
}
void COperationDialog : : operationSuccess ( qint64 total )
{
emit success ( total ) ;
}
void COperationDialog : : operationFail ( const QString & error )
{
emit fail ( error ) ;
}
bool COperationDialog : : operationShouldStop ( )
{
QMutexLocker locker ( & m_abortingMutex ) ;
return m_aborting ;
}