SVN commit 766446 by chehrlic: move uninstall to an extra thread. Displaying the progress bar in the uninstall menu doesn't work atm . I know why so don't care :) M +3 -2 CMakeLists.txt M +12 -15 gui/installwizard.cpp M +5 -4 gui/installwizard.h M +2 -2 shared/database.cpp M +20 -5 shared/installer.cpp M +4 -1 shared/installer.h M +3 -4 shared/package.cpp D shared/uninstall.cpp D shared/uninstall.h A shared/uninstaller.cpp shared/uninstall.cpp#765868 [License: LGPL (v2)] A shared/uninstaller.h shared/uninstall.h#765868 [License: LGPL (v2)] --- trunk/kdesupport/kdewin-installer/CMakeLists.txt #766445:766446 @@ -116,9 +116,9 @@ ${CMAKE_CURRENT_SOURCE_DIR}/shared/installerengine.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared/misc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared/database.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/shared/uninstall.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared/packagecategorycache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared/hintfile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/shared/uninstaller.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared/unpacker.cpp # ${CMAKE_CURRENT_SOURCE_DIR}/shared/installerbase.cpp ) @@ -138,9 +138,10 @@ ${CMAKE_CURRENT_SOURCE_DIR}/shared/misc.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/globalconfig.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/database.h - ${CMAKE_CURRENT_SOURCE_DIR}/shared/uninstall.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/packagecategorycache.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/hintfile.h + ${CMAKE_CURRENT_SOURCE_DIR}/shared/uninstaller.h + ${CMAKE_CURRENT_SOURCE_DIR}/shared/uninstaller_p.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/unpacker.h ${CMAKE_CURRENT_SOURCE_DIR}/shared/unpacker_p.h # ${CMAKE_CURRENT_SOURCE_DIR}/shared/installerbase.h --- trunk/kdesupport/kdewin-installer/gui/installwizard.cpp #766445:766446 @@ -79,14 +79,11 @@ } */ -InstallerProgress *installProgressBar; -DownloaderProgress *progressBar; - InstallWizard::InstallWizard(QWidget *parent) : QWizard(parent), m_lastId(0){ - progressBar = new DownloaderProgress(this); - installProgressBar = new InstallerProgress(this); + DownloaderProgress *downloadProgressBar = new DownloaderProgress(this); + InstallerProgress *installProgressBar = new InstallerProgress(this); - engine = new InstallerEngineGui(this,progressBar,installProgressBar); + engine = new InstallerEngineGui(this,downloadProgressBar,installProgressBar); connect(engine, SIGNAL(error(const QString &)), this, SLOT(slotEngineError(const QString &)) ); // must be first @@ -129,9 +126,9 @@ setPage(mirrorSettingsPage, new MirrorSettingsPage(_settingsPage->mirrorPage())); setPage(packageSelectorPage, new PackageSelectorPage()); setPage(dependenciesPage, new DependenciesPage()); - setPage(downloadPage, new DownloadPage()); - setPage(uninstallPage, new UninstallPage()); - setPage(installPage, new InstallPage()); + setPage(downloadPage, new DownloadPage(downloadProgressBar)); + setPage(uninstallPage, new UninstallPage(installProgressBar)); + setPage(installPage, new InstallPage(installProgressBar)); setPage(finishPage, new FinishPage()); QString windowTitle = tr("KDE Installer - Version " VERSION); @@ -706,13 +703,13 @@ return true; } -DownloadPage::DownloadPage() : InstallWizardPage(0) +DownloadPage::DownloadPage(DownloaderProgress *progress) : InstallWizardPage(0) { setTitle(tr("Downloading packages")); setSubTitle(tr(" ")); QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(progressBar); + layout->addWidget(progress); layout->addStretch(1); setLayout(layout); } @@ -743,13 +740,13 @@ return true; } -UninstallPage::UninstallPage() : InstallWizardPage(0) +UninstallPage::UninstallPage(InstallerProgress *progress) : InstallWizardPage(0) { setTitle(tr("Uninstalling packages")); setSubTitle(tr(" ")); QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(installProgressBar); + layout->addWidget(progress); layout->addStretch(1); setLayout(layout); } @@ -778,13 +775,13 @@ return true; } -InstallPage::InstallPage() : InstallWizardPage(0) +InstallPage::InstallPage(InstallerProgress *progress) : InstallWizardPage(0) { setTitle(tr("Installing packages")); setSubTitle(tr(" ")); QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(installProgressBar); + layout->addWidget(progress); layout->addStretch(1); setLayout(layout); } --- trunk/kdesupport/kdewin-installer/gui/installwizard.h #766445:766446 @@ -31,7 +31,6 @@ #include #include "settingspage.h" -#include "installerprogress.h" class QCheckBox; class QLabel; @@ -52,6 +51,8 @@ class UninstallPage; class DownloadPage; class FinishPage; +class InstallerProgress; +class DownloaderProgress; extern QListWidget *g_dependenciesList; @@ -216,7 +217,7 @@ Q_OBJECT public: - DownloadPage(); + DownloadPage(DownloaderProgress *progress); void cancel(); void initializePage(); @@ -230,7 +231,7 @@ Q_OBJECT public: - UninstallPage(); + UninstallPage(InstallerProgress *progress); void cancel(); void initializePage(); @@ -244,7 +245,7 @@ Q_OBJECT public: - InstallPage(); + InstallPage(InstallerProgress *progress); void cancel(); void initializePage(); --- trunk/kdesupport/kdewin-installer/shared/database.cpp #766445:766446 @@ -110,7 +110,7 @@ qDebug() << files; } -extern bool isHash(const QString &str); +extern bool isHash(const QByteArray &str); QStringList Database::getPackageFiles(const QString &pkgName, Package::Type pkgType) { QStringList files; @@ -133,7 +133,7 @@ continue; } for(int i = 0; i < parts.count(); i++) { - if(!isHash(parts[i])) { + if(!isHash(parts[i].toUtf8())) { iPosFilename = i; files << parts[iPosFilename]; break; --- trunk/kdesupport/kdewin-installer/shared/installer.cpp #766445:766446 @@ -36,6 +36,7 @@ #include "installerprogress.h" #include "packagelist.h" #include "unpacker.h" +#include "uninstaller.h" //#define DEBUG #ifdef Q_CC_MSVC @@ -43,7 +44,8 @@ #endif Installer::Installer(InstallerProgress *_progress) - : QObject(), m_progress(_progress), m_type(Installer::Standard) + : m_progress(_progress), m_type(Installer::Standard), + m_unpacker(0), m_uninstaller(0) { m_root = "."; } @@ -170,15 +172,16 @@ return true; } -bool Installer::install(Package *pkg, const Package::Type type, const QString &fileName, const StringHash &pathRelocations) +bool Installer::install(Package *pkg, const Package::Type type, const QString &fileName) { m_packageToInstall = pkg; m_installType = type; m_unpacker = new Unpacker(m_progress, this); - if(!m_unpacker->unpackFile(fileName, m_root, pathRelocations)) { - delete m_unpacker; + if(!m_unpacker->unpackFile(fileName, m_root, pkg->pathRelocations())) { + m_unpacker->deleteLater(); + m_unpacker = 0; return false; } @@ -189,14 +192,26 @@ if(fi.fileName().startsWith("qt")) createQtConfigFile(); - delete m_unpacker; + m_unpacker->deleteLater(); + m_unpacker = 0; return true; } +bool Installer::uninstall(const QString &pathToManifest) +{ + m_uninstaller = new Uninstaller(m_progress, this); + bool bRet = m_uninstaller->uninstallPackage(pathToManifest, m_root); + m_uninstaller->deleteLater(); + m_uninstaller = 0; + return bRet; +} + void Installer::cancel() { if (m_unpacker) m_unpacker->cancel(); + if (m_uninstaller) + m_uninstaller->cancel(); } #include "installer.moc" --- trunk/kdesupport/kdewin-installer/shared/installer.h #766445:766446 @@ -29,6 +29,7 @@ class Database; class InstallerProgress; class PackageList; +class Uninstaller; class Unpacker; class Installer : public QObject @@ -51,7 +52,8 @@ Database *database() { return m_database; } void setDatabase(Database *database) { m_database = database; } /// @TODO pathRelocations are obsolated, they can be retrieved from the pkg parameter - QT_DEPRECATED bool install(Package *pkg, const Package::Type type, const QString &fileName, const StringHash &pathRelocations=StringHash()); + bool install(Package *pkg, const Package::Type type, const QString &fileName); + bool uninstall(const QString &pathToManifest); // installPackage(Package *pkg) // bool readFromFile(QString const &fileName); // bool writeToFile(QString const &fileName); @@ -77,6 +79,7 @@ QStringList m_files; Database *m_database; Unpacker *m_unpacker; + Uninstaller *m_uninstaller; Package* m_packageToInstall; Package::Type m_installType; --- trunk/kdesupport/kdewin-installer/shared/package.cpp #766445:766446 @@ -31,7 +31,7 @@ #include "downloader.h" #include "installer.h" #include "database.h" -#include "uninstall.h" +#include "uninstaller.h" #ifndef PACKAGE_SMALL_VERSION /** @@ -431,7 +431,7 @@ return false; } fileName = makeFileName(type); - if (!installer->install(this, type, fileName, pathRelocations())) + if (!installer->install(this, type, fileName)) { qDebug() << __FUNCTION__ << " install failure for file " << fileName << " type " << type; return false; @@ -445,8 +445,7 @@ bool Package::removeItem(Installer *installer, Package::Type type) { QString manifestFile = installer->root()+"/manifest/"+Package::manifestFileName(name(),installedVersion(),type); - Uninstall ui(installer->root(),manifestFile); - ui.uninstallPackage(false); + installer->uninstall(manifestFile); return true; }