summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-07-01 12:09:32 +0200
committerkh1 <qt-info@nokia.com>2011-07-01 12:09:32 +0200
commit7f75020e00a2e3189020e9efd2e1279263792107 (patch)
tree5b1b595f31c3c905385683dd294f4febfdf34f9d
parentfd128c68c28657492a2b0f92d9da3f30e4d72a65 (diff)
Keep the updater application as class member.
I can't see any reason to be able to set it from the outside, thus it makes no sense to have that functionality at all. To be able to work properly the app had to be set, but could be easily forgotten, leading to a crash later on. Re-parsing should be removed as well, will do it next.
-rw-r--r--examples/testapp/mainwindow.cpp8
-rw-r--r--examples/testapp/mainwindow.h3
-rw-r--r--examples/testapp/updateagent.cpp4
-rw-r--r--installerbuilder/installerbase/installerbase.cpp14
-rw-r--r--installerbuilder/libinstaller/packagemanagercore.cpp36
-rw-r--r--installerbuilder/libinstaller/packagemanagercore.h4
-rw-r--r--installerbuilder/libinstaller/packagemanagercore_p.cpp22
-rw-r--r--installerbuilder/libinstaller/packagemanagercore_p.h2
-rw-r--r--installerbuilder/libinstaller/updater.cpp3
9 files changed, 30 insertions, 66 deletions
diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp
index 0bb387edb..579d7dec5 100644
--- a/examples/testapp/mainwindow.cpp
+++ b/examples/testapp/mainwindow.cpp
@@ -56,7 +56,6 @@ MainWindow::MainWindow(const QStringList &args, QWidget *parent)
, m_dialog(new UpdateSettingsDialog(this))
{
m_core.setUpdater();
- m_core.setUpdaterApplication(&updaterapp);
QMenu *fm = menuBar()->addMenu(QObject::tr("File"));
fm->addAction(QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()),
@@ -72,9 +71,6 @@ MainWindow::MainWindow(const QStringList &args, QWidget *parent)
label->setText(QString::fromLatin1("Version: %1\n").arg(m_core.settings().applicationVersion())
+ args.join(QLatin1String(" ")));
- updaterapp.packagesInfo()->setApplicationName(m_settings.applicationName());
- updaterapp.packagesInfo()->setApplicationVersion(m_settings.applicationVersion());
-
UpdateAgent *const agent = new UpdateAgent(this);
connect(agent, SIGNAL(updatesAvailable()), this, SLOT(updatesAvailable()));
}
@@ -108,8 +104,8 @@ void MainWindow::checkForUpdates()
return;
}
- // set the target directory to the actual one
- m_core.setValue(scTargetDir, QFileInfo(updaterapp.packagesInfo()->fileName()).absolutePath());
+ // TODO: fix this, set the target directory to the actual one
+ // m_core.setValue(scTargetDir, QFileInfo(updaterapp.packagesInfo()->fileName()).absolutePath());
// this will automatically mark components as to get installed
ComponentSelectionDialog componentSelection(&m_core, this);
diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h
index 862b5bf0d..301954d5a 100644
--- a/examples/testapp/mainwindow.h
+++ b/examples/testapp/mainwindow.h
@@ -27,8 +27,6 @@
#include <packagemanagercore.h>
#include <settings.h>
-#include <KDUpdater/Application>
-
#include <QtGui/QMainWindow>
class UpdateSettingsDialog;
@@ -50,6 +48,5 @@ private:
UpdateSettingsDialog *m_dialog;
QInstaller::Settings m_settings;
- KDUpdater::Application updaterapp;
QInstaller::PackageManagerCore m_core;
};
diff --git a/examples/testapp/updateagent.cpp b/examples/testapp/updateagent.cpp
index 8b35aa1af..73db16e98 100644
--- a/examples/testapp/updateagent.cpp
+++ b/examples/testapp/updateagent.cpp
@@ -42,8 +42,6 @@
#include <QtCore/QDateTime>
#include <QtCore/QTimer>
-#include <KDUpdater/Application>
-
using namespace QInstaller;
using QInstallerCreator::ComponentIndex;
using QInstallerCreator::BinaryFormatEngineHandler;
@@ -78,9 +76,7 @@ public:
handler.reset(new BinaryFormatEngineHandler(ComponentIndex()));
handler->setComponentIndex(QInstallerCreator::ComponentIndex());
- KDUpdater::Application app;
PackageManagerCore core(QInstaller::MagicUpdaterMarker);
- core.setUpdaterApplication(&app);
core.setTemporaryRepositories(settings.repositories());
if (!core.fetchUpdaterPackages())
throw Error(tr("Software Update failed."));
diff --git a/installerbuilder/installerbase/installerbase.cpp b/installerbuilder/installerbase/installerbase.cpp
index 7e885d79e..666b1e9fe 100644
--- a/installerbuilder/installerbase/installerbase.cpp
+++ b/installerbuilder/installerbase/installerbase.cpp
@@ -53,9 +53,6 @@
#include <QtNetwork/QNetworkProxyFactory>
-#include <KDUpdater/Application>
-#include <KDUpdater/PackagesInfo>
-
#include <KDToolsCore/KDSelfRestarter>
#include <KDToolsCore/KDRunOnceChecker>
@@ -264,17 +261,6 @@ int main(int argc, char *argv[])
}
}
-
- KDUpdater::Application updaterapp;
- const QString &productName = core.value(QLatin1String("ProductName"));
- updaterapp.packagesInfo()->setApplicationName(productName);
- updaterapp.packagesInfo()->setApplicationVersion(core.value(QLatin1String("ProductVersion")));
- if (content.magicmaker() == MagicInstallerMarker) {
- updaterapp.addUpdateSource(productName, productName, QString(),
- QUrl(QLatin1String("resource://metadata/")), 0);
- }
- core.setUpdaterApplication(&updaterapp);
-
// Create the wizard gui
TabController controller(0);
controller.setManager(&core);
diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp
index 12463f2e0..f775e3aad 100644
--- a/installerbuilder/libinstaller/packagemanagercore.cpp
+++ b/installerbuilder/libinstaller/packagemanagercore.cpp
@@ -255,16 +255,6 @@ QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine/*, const
Non-existing page - this value has to be used if you want to insert a page after \a InstallationFinished
*/
-KDUpdater::Application& PackageManagerCore::updaterApplication() const
-{
- return *d->m_app;
-}
-
-void PackageManagerCore::setUpdaterApplication(KDUpdater::Application *app)
-{
- d->m_app = app;
-}
-
void PackageManagerCore::writeUninstaller()
{
if (d->m_needToWriteUninstaller) {
@@ -278,7 +268,7 @@ void PackageManagerCore::writeUninstaller()
gainAdminRights();
gainedAdminRights = true;
}
- d->m_app->packagesInfo()->writeToDisk();
+ d->m_updaterApplication.packagesInfo()->writeToDisk();
if (gainedAdminRights)
dropAdminRights();
d->m_needToWriteUninstaller = false;
@@ -379,8 +369,8 @@ void PackageManagerCore::installSelectedComponents()
delete d->m_performedOperationsOld.takeAt(i);
}
foreach(const QString possilbeName, possibleNames)
- d->m_app->packagesInfo()->removePackage(possilbeName);
- d->m_app->packagesInfo()->writeToDisk();
+ d->m_updaterApplication.packagesInfo()->removePackage(possilbeName);
+ d->m_updaterApplication.packagesInfo()->writeToDisk();
}
ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(
tr("\nInstalling the new version of: %1").arg(currentComponent->name()));
@@ -506,7 +496,7 @@ void PackageManagerCore::rollBackInstallation()
{
emit titleMessageChanged(tr("Cancelling the Installer"));
- KDUpdater::PackagesInfo *const packages = d->m_app->packagesInfo();
+ KDUpdater::PackagesInfo *const packages = d->m_updaterApplication.packagesInfo();
packages->setFileName(d->componentsXmlPath()); // forces a refresh of installed packages
packages->setApplicationName(d->m_settings.applicationName());
packages->setApplicationVersion(d->m_settings.applicationVersion());
@@ -653,17 +643,17 @@ QHash<QString, KDUpdater::PackageInfo> PackageManagerCore::localInstalledPackage
QHash<QString, KDUpdater::PackageInfo> installedPackages;
if (!isInstaller()) {
- KDUpdater::PackagesInfo &packagesInfo = *d->m_app->packagesInfo();
+ KDUpdater::PackagesInfo &packagesInfo = *d->m_updaterApplication.packagesInfo();
if (!setAndParseLocalComponentsFile(packagesInfo)) {
verbose() << tr("Could not parse local components xml file: %1")
.arg(d->localComponentsXmlPath());
return installedPackages;
}
+ foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos())
+ installedPackages.insert(info.name, info);
packagesInfo.setApplicationName(d->m_settings.applicationName());
packagesInfo.setApplicationVersion(d->m_settings.applicationVersion());
- foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos())
- installedPackages.insert(info.name, info);
}
return installedPackages;
@@ -723,9 +713,9 @@ bool PackageManagerCore::addUpdateResourcesFrom(GetRepositoriesMetaInfoJob *meta
if (!checksum.isNull())
setTestChecksum(checksum.toElement().text().toLower() == scTrue);
}
- d->m_app->addUpdateSource(appName, appName, QString(), QUrl::fromLocalFile(tmpDir), 1);
+ d->m_updaterApplication.addUpdateSource(appName, appName, QString(), QUrl::fromLocalFile(tmpDir), 1);
}
- d->m_app->updateSourcesInfo()->setModified(false);
+ d->m_updaterApplication.updateSourcesInfo()->setModified(false);
return true;
}
@@ -758,13 +748,13 @@ bool PackageManagerCore::fetchAllPackages()
}
}
- if (d->m_app->updateSourcesInfo()->updateSourceInfoCount() == 0) {
+ if (d->m_updaterApplication.updateSourcesInfo()->updateSourceInfoCount() == 0) {
d->setStatus(Failure, tr("Could not find any update source information."));
verbose() << tr("Could not find any update source information.") << std::endl;
return false;
}
- KDUpdater::UpdateFinder updateFinder(d->m_app);
+ KDUpdater::UpdateFinder updateFinder(&d->m_updaterApplication);
updateFinder.setAutoDelete(false);
updateFinder.setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
updateFinder.run();
@@ -873,13 +863,13 @@ bool PackageManagerCore::fetchUpdaterPackages()
}
}
- if (d->m_app->updateSourcesInfo()->updateSourceInfoCount() == 0) {
+ if (d->m_updaterApplication.updateSourcesInfo()->updateSourceInfoCount() == 0) {
d->setStatus(Failure, tr("Could not find any update source information."));
verbose() << tr("Could not find any update source information.") << std::endl;
return false;
}
- KDUpdater::UpdateFinder updateFinder(d->m_app);
+ KDUpdater::UpdateFinder updateFinder(&d->m_updaterApplication);
updateFinder.setAutoDelete(false);
updateFinder.setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
updateFinder.run();
diff --git a/installerbuilder/libinstaller/packagemanagercore.h b/installerbuilder/libinstaller/packagemanagercore.h
index bdddcd0e8..36610d062 100644
--- a/installerbuilder/libinstaller/packagemanagercore.h
+++ b/installerbuilder/libinstaller/packagemanagercore.h
@@ -43,7 +43,6 @@
#include <QtScript/QScriptValue>
namespace KDUpdater {
- class Application;
class PackagesInfo;
class Update;
class UpdateOperation;
@@ -161,9 +160,6 @@ public:
bool testChecksum() const;
void setTestChecksum(bool test);
- KDUpdater::Application &updaterApplication() const;
- void setUpdaterApplication(KDUpdater::Application *app);
-
void addRepositories(const QList<Repository> &repositories);
void setTemporaryRepositories(const QList<Repository> &repositories, bool replace = false);
diff --git a/installerbuilder/libinstaller/packagemanagercore_p.cpp b/installerbuilder/libinstaller/packagemanagercore_p.cpp
index 989c891be..9f481b27b 100644
--- a/installerbuilder/libinstaller/packagemanagercore_p.cpp
+++ b/installerbuilder/libinstaller/packagemanagercore_p.cpp
@@ -151,16 +151,14 @@ static void deferredRename(const QString &oldName, const QString &newName, bool
// -- PackageManagerCorePrivate
PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core)
- : m_app(0)
- , m_FSEngineClientHandler(0)
+ : m_FSEngineClientHandler(0)
, m_core(core)
{
}
PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, qint64 magicInstallerMaker,
const QList<KDUpdater::UpdateOperation*> &performedOperations)
- : m_app(0)
- , m_FSEngineClientHandler(initFSEngineClientHandler())
+ : m_FSEngineClientHandler(initFSEngineClientHandler())
, m_status(PackageManagerCore::Unfinished)
, m_forceRestart(false)
, m_silentRetries(3)
@@ -369,6 +367,14 @@ void PackageManagerCorePrivate::initialize()
connect(this, SIGNAL(installationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
disconnect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
connect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+
+ m_updaterApplication.packagesInfo()->setFileName(componentsXmlPath());
+ m_updaterApplication.packagesInfo()->setApplicationName(m_settings.applicationName());
+ m_updaterApplication.packagesInfo()->setApplicationVersion(m_settings.applicationVersion());
+ if (isInstaller()) {
+ m_updaterApplication.addUpdateSource(m_settings.applicationName(), m_settings.applicationName(),
+ QString(), QUrl(QLatin1String("resource://metadata/")), 0);
+ }
}
QString PackageManagerCorePrivate::installerBinaryPath() const
@@ -1045,7 +1051,7 @@ void PackageManagerCorePrivate::runInstaller()
componentsInstallPartProgressSize = double(1);
// put the installed packages info into the target dir
- KDUpdater::PackagesInfo *const packages = m_app->packagesInfo();
+ KDUpdater::PackagesInfo *const packages = m_updaterApplication.packagesInfo();
packages->setFileName(componentsXmlPath()); // forces a refresh of installed packages
// Clear these packages as we might install into an already existing installation folder.
packages->clearPackageInfoList();
@@ -1198,7 +1204,7 @@ void PackageManagerCorePrivate::runPackageUpdater()
const double progressOperationCount = countProgressOperations(componentsToInstall);
const double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
- KDUpdater::PackagesInfo *packages = m_app->packagesInfo();
+ KDUpdater::PackagesInfo *packages = m_updaterApplication.packagesInfo();
packages->setFileName(packagesXml);
packages->setApplicationName(m_settings.applicationName());
packages->setApplicationVersion(m_settings.applicationVersion());
@@ -1406,7 +1412,7 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr
}
// now mark the component as installed
- KDUpdater::PackagesInfo *const packages = m_app->packagesInfo();
+ KDUpdater::PackagesInfo *const packages = m_updaterApplication.packagesInfo();
packages->installPackage(component->name(), component->value(scVersion), component->value(scDisplayName),
component->value(scDescription), component->dependencies(), component->forcedInstallation(),
component->isVirtual(), component->value(scUncompressedSize).toULongLong());
@@ -1514,7 +1520,7 @@ void PackageManagerCorePrivate::unregisterUninstaller()
void PackageManagerCorePrivate::runUndoOperations(const QList<KDUpdater::UpdateOperation*> &undoOperations,
double undoOperationProgressSize, bool adminRightsGained, bool deleteOperation)
{
- KDUpdater::PackagesInfo *const packages = m_app->packagesInfo();
+ KDUpdater::PackagesInfo *const packages = m_updaterApplication.packagesInfo();
packages->setFileName(componentsXmlPath());
packages->setApplicationName(m_settings.applicationName());
packages->setApplicationVersion(m_settings.applicationVersion());
diff --git a/installerbuilder/libinstaller/packagemanagercore_p.h b/installerbuilder/libinstaller/packagemanagercore_p.h
index 1992d07f0..159e52043 100644
--- a/installerbuilder/libinstaller/packagemanagercore_p.h
+++ b/installerbuilder/libinstaller/packagemanagercore_p.h
@@ -150,7 +150,7 @@ signals:
void uninstallationFinished();
public:
- KDUpdater::Application *m_app;
+ KDUpdater::Application m_updaterApplication;
FSEngineClientHandler *m_FSEngineClientHandler;
int m_status;
diff --git a/installerbuilder/libinstaller/updater.cpp b/installerbuilder/libinstaller/updater.cpp
index 9adba482c..e4962bede 100644
--- a/installerbuilder/libinstaller/updater.cpp
+++ b/installerbuilder/libinstaller/updater.cpp
@@ -72,9 +72,6 @@ bool Updater::checkForUpdates()
core.setUpdater();
PackageManagerCore::setVirtualComponentsVisible(true);
- KDUpdater::Application updaterapp;
- core.setUpdaterApplication(&updaterapp);
-
if (core.fetchUpdaterPackages()) {
const QList<QInstaller::Component*> components = core.components(true, UpdaterMode);