summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/testapp/componentselectiondialog.cpp194
-rw-r--r--examples/testapp/componentselectiondialog.h (renamed from installerbuilder/libinstaller/componentselectiondialog.h)34
-rw-r--r--examples/testapp/componentselectiondialog.ui (renamed from installerbuilder/libinstaller/componentselectiondialog.ui)6
-rw-r--r--examples/testapp/main.cpp22
-rw-r--r--examples/testapp/mainwindow.cpp193
-rw-r--r--examples/testapp/mainwindow.h19
-rw-r--r--examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml1
-rw-r--r--examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs9
-rw-r--r--examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml2
-rw-r--r--examples/testapp/testapp.pro17
-rw-r--r--examples/testapp/updateagent.cpp114
-rw-r--r--examples/testapp/updateagent.h (renamed from installerbuilder/libinstaller/updateagent.h)17
-rw-r--r--examples/testapp/updatesettingsdialog.cpp (renamed from installerbuilder/libinstaller/updatesettingsdialog.cpp)35
-rw-r--r--examples/testapp/updatesettingsdialog.h (renamed from installerbuilder/libinstaller/updatesettingsdialog.h)22
-rw-r--r--examples/testapp/updatesettingsdialog.ui (renamed from installerbuilder/libinstaller/updatesettingsdialog.ui)4
-rw-r--r--examples/testapp/updatesettingswidget.cpp155
-rw-r--r--examples/testapp/updatesettingswidget.h (renamed from installerbuilder/libinstaller/updatesettingswidget.h)29
-rw-r--r--examples/testapp/updatesettingswidget.ui (renamed from installerbuilder/libinstaller/updatesettingswidget.ui)0
-rw-r--r--installerbuilder/binarycreator/binarycreator.cpp10
-rw-r--r--installerbuilder/common/binaryformat.cpp1028
-rw-r--r--installerbuilder/common/binaryformat.h313
-rw-r--r--installerbuilder/common/blockingbuffer.cpp126
-rw-r--r--installerbuilder/common/fileutils.cpp509
-rw-r--r--installerbuilder/common/fileutils.h129
-rw-r--r--installerbuilder/common/installersettings.cpp307
-rw-r--r--installerbuilder/common/installersettings.h116
-rw-r--r--installerbuilder/common/kd7zengine.cpp679
-rw-r--r--installerbuilder/common/kd7zengine.h73
-rw-r--r--installerbuilder/common/kd7zenginehandler.h39
-rw-r--r--installerbuilder/common/repository.cpp46
-rw-r--r--installerbuilder/common/repository.h42
-rw-r--r--installerbuilder/common/repositorygen.cpp3
-rw-r--r--installerbuilder/common/repositorygen.h3
-rw-r--r--installerbuilder/common/utils.cpp56
-rw-r--r--installerbuilder/common/utils.h26
-rw-r--r--installerbuilder/common/zipjob.h6
-rw-r--r--installerbuilder/installerbase/installerbase.cpp235
-rw-r--r--installerbuilder/installerbase/installerbase.pro6
-rw-r--r--installerbuilder/installerbase/installerbasecommons.cpp389
-rw-r--r--installerbuilder/installerbase/installerbasecommons.h100
-rw-r--r--installerbuilder/installerbase/maintabwidget.h49
-rw-r--r--installerbuilder/installerbase/tabcontroller.cpp525
-rw-r--r--installerbuilder/installerbase/tabcontroller.h47
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDAutoPointer (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDByteSize (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDGenericFactory (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDJob (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDLockfile (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDMetaMethodIterator (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDRunOnceChecker (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSaveFile (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSelfRestarter (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSysInfo (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDToolsCore.pri (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDWatchdog (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h)3
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_p.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_unix.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_win.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_mac.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_win.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_x11.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.cpp (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.h (renamed from installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Application (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/Application)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloader (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloaderFactory (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater.pri (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/PackagesInfo (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerificationResult (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerifier (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Update (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/Update)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateFinder (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperation (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperationFactory (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateSourcesInfo (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdatesDialog (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/addupdatesourcedialog.ui (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp)8
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/environment.h)4
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdater.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h)5
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp)16
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h)6
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader_p.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp)10
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h)3
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp)21
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h)3
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor_p.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp)2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.h (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/updatesdialog.ui (renamed from installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/LICENSE.LGPL (renamed from installerbuilder/libinstaller/kdtools/LICENSE.LGPL)0
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp5
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h2
-rw-r--r--installerbuilder/libinstaller/NQSDevAgreement.txt204
-rw-r--r--installerbuilder/libinstaller/NQSThirdPartyAgreement.txt1019
-rw-r--r--installerbuilder/libinstaller/adminauthorization.cpp8
-rw-r--r--installerbuilder/libinstaller/adminauthorization_mac.cpp79
-rw-r--r--installerbuilder/libinstaller/adminauthorization_win.cpp52
-rw-r--r--installerbuilder/libinstaller/adminauthorization_x11.cpp1
-rw-r--r--installerbuilder/libinstaller/componentmodel.cpp408
-rw-r--r--installerbuilder/libinstaller/componentmodel.h107
-rw-r--r--installerbuilder/libinstaller/componentselectiondialog.cpp210
-rw-r--r--installerbuilder/libinstaller/copydirectoryoperation.cpp68
-rw-r--r--installerbuilder/libinstaller/copydirectoryoperation.h12
-rw-r--r--installerbuilder/libinstaller/createdesktopentryoperation.cpp5
-rw-r--r--installerbuilder/libinstaller/cryptosignatureverifier.h26
-rw-r--r--installerbuilder/libinstaller/downloadarchivesjob.cpp374
-rw-r--r--installerbuilder/libinstaller/downloadarchivesjob.h68
-rw-r--r--installerbuilder/libinstaller/elevatedexecuteoperation.cpp19
-rw-r--r--installerbuilder/libinstaller/environmentvariablesoperation.cpp24
-rw-r--r--installerbuilder/libinstaller/extractarchiveoperation_p.h10
-rw-r--r--installerbuilder/libinstaller/fsengineclient.cpp1555
-rw-r--r--installerbuilder/libinstaller/fsengineclient.h195
-rw-r--r--installerbuilder/libinstaller/fsengineserver.cpp776
-rw-r--r--installerbuilder/libinstaller/fsengineserver.h36
-rw-r--r--installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp47
-rw-r--r--installerbuilder/libinstaller/getrepositoriesmetainfojob.h14
-rw-r--r--installerbuilder/libinstaller/getrepositorymetainfojob.cpp141
-rw-r--r--installerbuilder/libinstaller/getrepositorymetainfojob.h13
-rw-r--r--installerbuilder/libinstaller/globalsettingsoperation.cpp6
-rw-r--r--installerbuilder/libinstaller/globalsettingsoperation.h1
-rw-r--r--installerbuilder/libinstaller/installationprogressdialog.h12
-rw-r--r--installerbuilder/libinstaller/installer_global.h10
-rw-r--r--installerbuilder/libinstaller/installerbase.qrc8
-rw-r--r--installerbuilder/libinstaller/installiconsoperation.cpp2
-rw-r--r--installerbuilder/libinstaller/kdmmappedfileiodevice.h6
-rw-r--r--installerbuilder/libinstaller/libinstaller.pri17
-rw-r--r--installerbuilder/libinstaller/libinstaller.pro53
-rw-r--r--installerbuilder/libinstaller/macrelocateqt.cpp4
-rw-r--r--installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp4
-rw-r--r--installerbuilder/libinstaller/messageboxhandler.cpp300
-rw-r--r--installerbuilder/libinstaller/messageboxhandler.h97
-rw-r--r--installerbuilder/libinstaller/performinstallationform.h2
-rw-r--r--installerbuilder/libinstaller/progresscoordinator.cpp65
-rw-r--r--installerbuilder/libinstaller/progresscoordinator.h27
-rw-r--r--installerbuilder/libinstaller/qinstaller.cpp3139
-rw-r--r--installerbuilder/libinstaller/qinstaller.h160
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.cpp1583
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.h205
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent.cpp1443
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent.h269
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent_p.cpp333
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent_p.h155
-rw-r--r--installerbuilder/libinstaller/qinstallercomponentmodel.cpp522
-rw-r--r--installerbuilder/libinstaller/qinstallercomponentmodel.h95
-rw-r--r--installerbuilder/libinstaller/qinstallerglobal.h55
-rw-r--r--installerbuilder/libinstaller/qinstallergui.cpp1584
-rw-r--r--installerbuilder/libinstaller/qinstallergui.h186
-rw-r--r--installerbuilder/libinstaller/qprocesswrapper.cpp424
-rw-r--r--installerbuilder/libinstaller/qprocesswrapper.h120
-rw-r--r--installerbuilder/libinstaller/qsettingswrapper.cpp398
-rw-r--r--installerbuilder/libinstaller/qsettingswrapper.h100
-rw-r--r--installerbuilder/libinstaller/registerdocumentationoperation.cpp20
-rw-r--r--installerbuilder/libinstaller/registerfiletypeoperation.cpp11
-rw-r--r--installerbuilder/libinstaller/registertoolchainoperation.cpp11
-rw-r--r--installerbuilder/libinstaller/resources/files-to-patch-linux (renamed from installerbuilder/libinstaller/files-to-patch-linux)0
-rw-r--r--installerbuilder/libinstaller/resources/files-to-patch-macx (renamed from installerbuilder/libinstaller/files-to-patch-macx)0
-rw-r--r--installerbuilder/libinstaller/resources/files-to-patch-windows (renamed from installerbuilder/libinstaller/files-to-patch-windows)0
-rw-r--r--installerbuilder/libinstaller/resources/patch_file_lists.qrc (renamed from installerbuilder/libinstaller/patch_file_lists.qrc)0
-rw-r--r--installerbuilder/libinstaller/selfrestartoperation.cpp5
-rw-r--r--installerbuilder/libinstaller/templates.cpp169
-rw-r--r--installerbuilder/libinstaller/translations/de_de.ts (renamed from installerbuilder/libinstaller/de_de.ts)0
-rw-r--r--installerbuilder/libinstaller/translations/sv_se.ts (renamed from installerbuilder/libinstaller/sv_se.ts)0
-rw-r--r--installerbuilder/libinstaller/updateagent.cpp126
-rw-r--r--installerbuilder/libinstaller/updater.cpp285
-rw-r--r--installerbuilder/libinstaller/updater.h32
-rw-r--r--installerbuilder/libinstaller/updatesettings.cpp103
-rw-r--r--installerbuilder/libinstaller/updatesettings.h2
-rw-r--r--installerbuilder/libinstaller/updatesettingswidget.cpp161
-rw-r--r--installerbuilder/tests/tests.pro6
-rw-r--r--installerfw.pro2
-rw-r--r--tools/fileengineclient/fileengineclient.cpp183
-rw-r--r--tools/fileengineclient/fileengineclient.pro15
-rw-r--r--tools/fileengineserver/fileengineserver.cpp (renamed from installerbuilder/common/kd7zenginehandler.cpp)12
-rw-r--r--tools/fileengineserver/fileengineserver.pro15
-rw-r--r--tools/operationrunner/operationrunner.pro3
-rw-r--r--tools/repocompare/main.cpp (renamed from installerbuilder/common/blockingbuffer.h)36
-rw-r--r--tools/repocompare/mainwindow.cpp235
-rw-r--r--tools/repocompare/mainwindow.h (renamed from installerbuilder/installerbase/maintabwidget.cpp)75
-rw-r--r--tools/repocompare/mainwindow.ui206
-rw-r--r--tools/repocompare/repocompare.pro18
245 files changed, 11481 insertions, 12951 deletions
diff --git a/examples/testapp/componentselectiondialog.cpp b/examples/testapp/componentselectiondialog.cpp
new file mode 100644
index 000000000..b7f620d39
--- /dev/null
+++ b/examples/testapp/componentselectiondialog.cpp
@@ -0,0 +1,194 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "componentselectiondialog.h"
+#include "ui_componentselectiondialog.h"
+
+#include <componentmodel.h>
+#include <qinstaller.h>
+#include <qinstallercomponent.h>
+
+#include <QtGui/QHeaderView>
+#include <QtGui/QPushButton>
+
+using namespace QInstaller;
+
+class ComponentSelectionDialog::Private : public QObject
+{
+ Q_OBJECT
+
+public:
+ Private(ComponentSelectionDialog *qq, Installer *inst)
+ : q(qq),
+ installer(inst)
+ {
+ }
+
+ void currentChanged(const QModelIndex &index)
+ {
+ installBtn->setEnabled(componentModel->hasCheckedComponents());
+ const int selectionCount = componentModel->checkedComponents().count();
+ installBtn->setText(selectionCount > 1 ? tr("Install %1 Items").arg(selectionCount) :
+ selectionCount == 1 ? tr("Install 1 Item") : tr("Install"));
+ ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(selectionCount > 0 ? tr("Cancel")
+ : tr("Close"));
+
+ if (index.isValid()) {
+ ui.textBrowser->setHtml(componentModel->data(componentModel->index(index.row(), 0,
+ index.parent()), Qt::ToolTipRole).toString());
+ } else {
+ ui.textBrowser->clear();
+ }
+ }
+
+ void modelReset()
+ {
+ ui.treeView->header()->resizeSection(0, ui.labelTitle->sizeHint().width() / 1.5);
+ ui.treeView->header()->setStretchLastSection(true);
+ for (int i = 0; i < ui.treeView->model()->columnCount(); ++i)
+ ui.treeView->resizeColumnToContents(i);
+
+ bool hasChildren = false;
+ const int rowCount = ui.treeView->model()->rowCount();
+ for (int row = 0; row < rowCount && !hasChildren; ++row)
+ hasChildren = ui.treeView->model()->hasChildren(ui.treeView->model()->index(row, 0));
+ ui.treeView->setRootIsDecorated(hasChildren);
+ ui.treeView->expandToDepth(0);
+ }
+
+private:
+ ComponentSelectionDialog *const q;
+
+public:
+ Ui::ComponentSelectionDialog ui;
+ Installer *const installer;
+ ComponentModel *componentModel;
+ QPushButton *installBtn;
+
+public Q_SLOTS:
+ void selectAll();
+ void deselectAll();
+};
+
+void ComponentSelectionDialog::Private::selectAll()
+{
+ componentModel->selectAll();
+}
+
+void ComponentSelectionDialog::Private::deselectAll()
+{
+ componentModel->deselectAll();
+}
+
+
+// -- ComponentSelectionDialog
+
+ComponentSelectionDialog::ComponentSelectionDialog(Installer *installer, QWidget *parent)
+ : QDialog(parent),
+ d(new Private(this, installer))
+{
+ d->ui.setupUi(this);
+ d->ui.icon->setPixmap(windowIcon().pixmap(48, 48));
+
+ d->ui.splitter->setStretchFactor(0, 2);
+ d->ui.splitter->setStretchFactor(1, 1);
+ d->ui.splitter->setCollapsible(0, false);
+
+ d->componentModel = new ComponentModel(5, installer);
+ d->componentModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
+ d->componentModel->setHeaderData(1, Qt::Horizontal, tr("Installed Version"));
+ d->componentModel->setHeaderData(2, Qt::Horizontal, tr("New Version"));
+ d->componentModel->setHeaderData(3, Qt::Horizontal, tr("Size"));
+
+ d->ui.treeView->setModel(d->componentModel);
+ d->ui.treeView->setAttribute(Qt::WA_MacShowFocusRect, false);
+ connect(d->ui.treeView->model(), SIGNAL(modelReset()), this, SLOT(modelReset()));
+ connect(d->ui.treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentChanged(QModelIndex)));
+
+ d->ui.labelSubTitle->setAttribute(Qt::WA_MacSmallSize);
+ d->ui.labelLicenseBlurb->setAttribute(Qt::WA_MacSmallSize);
+ d->ui.textBrowser->setAttribute(Qt::WA_MacShowFocusRect, false);
+
+ d->installBtn = d->ui.buttonBox->addButton(tr("Install"), QDialogButtonBox::AcceptRole) ;
+ if (!d->ui.buttonBox->button(QDialogButtonBox::Cancel)->icon().isNull())
+ d->installBtn->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
+
+ connect(d->installBtn, SIGNAL(clicked()), this, SIGNAL(requestUpdate()));
+ connect(d->ui.selectAll, SIGNAL(clicked()), d, SLOT(selectAll()), Qt::QueuedConnection);
+ connect(d->ui.deselectAll, SIGNAL(clicked()), d, SLOT(deselectAll()), Qt::QueuedConnection);
+
+ d->ui.treeView->header()->setStretchLastSection(true);
+ d->ui.treeView->setCurrentIndex(d->ui.treeView->model()->index(0, 0));
+ for (int i = 0; i < d->ui.treeView->model()->columnCount(); ++i)
+ d->ui.treeView->resizeColumnToContents(i);
+ d->modelReset();
+}
+
+ComponentSelectionDialog::~ComponentSelectionDialog()
+{
+ delete d;
+}
+
+void ComponentSelectionDialog::selectAll()
+{
+ d->selectAll();
+}
+
+void ComponentSelectionDialog::deselectAll()
+{
+ d->deselectAll();
+}
+
+void ComponentSelectionDialog::install()
+{
+ emit requestUpdate();
+}
+
+void ComponentSelectionDialog::selectComponent(const QString &id)
+{
+ const QModelIndex &idx = d->componentModel->indexFromComponentName(id);
+ if (!idx.isValid())
+ return;
+ d->componentModel->setData(idx, Qt::Checked, Qt::CheckStateRole);
+}
+
+void ComponentSelectionDialog::deselectComponent(const QString &id)
+{
+ const QModelIndex &idx = d->componentModel->indexFromComponentName(id);
+ if (!idx.isValid())
+ return;
+ d->componentModel->setData(idx, Qt::Unchecked, Qt::CheckStateRole);
+}
+
+#include "moc_componentselectiondialog.cpp"
+#include "componentselectiondialog.moc"
diff --git a/installerbuilder/libinstaller/componentselectiondialog.h b/examples/testapp/componentselectiondialog.h
index 0b67084c6..609d08eb4 100644
--- a/installerbuilder/libinstaller/componentselectiondialog.h
+++ b/examples/testapp/componentselectiondialog.h
@@ -28,40 +28,34 @@
#include <QtGui/QDialog>
-#include <KDToolsCore/pimpl_ptr>
-
-#include "installer_global.h"
-
-namespace QInstaller
-{
-class Installer;
+namespace QInstaller {
+ class Installer;
+}
-class INSTALLER_EXPORT ComponentSelectionDialog : public QDialog
+class ComponentSelectionDialog : public QDialog
{
Q_OBJECT
+
public:
- explicit ComponentSelectionDialog( QInstaller::Installer* installer, QWidget* parent = 0 );
- ~ComponentSelectionDialog();
- Q_INVOKABLE void selectComponent( const QString& compoenent );
- Q_INVOKABLE void deselectComponent( const QString& component );
+ explicit ComponentSelectionDialog(QInstaller::Installer *installer, QWidget *parent = 0);
+ virtual ~ComponentSelectionDialog();
+
+ Q_INVOKABLE void selectComponent(const QString &compoenent);
+ Q_INVOKABLE void deselectComponent(const QString &component);
Q_INVOKABLE void selectAll();
Q_INVOKABLE void deselectAll();
Q_INVOKABLE void install();
-public Q_SLOTS:
- void refreshDialog();
-
Q_SIGNALS:
void requestUpdate();
private:
- Q_PRIVATE_SLOT( d, void selectionChanged() );
- Q_PRIVATE_SLOT( d, void modelReset() );
+ Q_PRIVATE_SLOT(d, void modelReset())
+ Q_PRIVATE_SLOT(d, void currentChanged(const QModelIndex &index))
+private:
class Private;
- kdtools::pimpl_ptr< Private > d;
+ Private *d;
};
-}
-
#endif
diff --git a/installerbuilder/libinstaller/componentselectiondialog.ui b/examples/testapp/componentselectiondialog.ui
index 6ed730f99..74f3b3fe4 100644
--- a/installerbuilder/libinstaller/componentselectiondialog.ui
+++ b/examples/testapp/componentselectiondialog.ui
@@ -25,7 +25,7 @@
</sizepolicy>
</property>
<property name="pixmap">
- <pixmap>:/logo.png</pixmap>
+ <pixmap resource="testapp.qrc">:/logo.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
@@ -160,7 +160,9 @@
</item>
</layout>
</widget>
- <resources/>
+ <resources>
+ <include location="testapp.qrc"/>
+ </resources>
<connections>
<connection>
<sender>buttonBox</sender>
diff --git a/examples/testapp/main.cpp b/examples/testapp/main.cpp
index 3012c333f..edd7cdaa6 100644
--- a/examples/testapp/main.cpp
+++ b/examples/testapp/main.cpp
@@ -30,17 +30,23 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-#include <QApplication>
#include "mainwindow.h"
+
+#include <init.h>
+
#include <KDToolsCore/KDSelfRestarter>
-int main( int argc, char** argv ) {
- const KDSelfRestarter restarter( argc, argv );
- QStringList args;
- for ( int i = 0; i < argc; ++i )
- args << QString::fromLocal8Bit( argv[i] );
- QApplication app( argc, argv );
- MainWindow mw( args );
+#include <QtGui/QApplication>
+
+
+int main(int argc, char *argv[])
+{
+ QInstaller::init();
+ const KDSelfRestarter restarter(argc, argv);
+
+ QApplication app(argc, argv);
+ MainWindow mw(app.arguments());
mw.show();
+
return app.exec();
}
diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp
index 4a6fd1618..9c7364de5 100644
--- a/examples/testapp/mainwindow.cpp
+++ b/examples/testapp/mainwindow.cpp
@@ -32,151 +32,146 @@
**************************************************************************/
#include "mainwindow.h"
-#include <memory>
-
-#include <QAbstractButton>
-#include <QApplication>
-#include <QLabel>
-#include <QMenu>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QProgressDialog>
-#include <QStringList>
-
-#include <KDToolsCore/KDAutoPointer>
-#include <KDToolsCore/KDSelfRestarter>
-
-#include <KDUpdater/Application>
-#include <KDUpdater/PackagesInfo>
-#include <KDUpdater/UpdateFinder>
-#include <KDUpdater/UpdateSourcesInfo>
-
-#include "common/binaryformatenginehandler.h"
-#include "common/binaryformat.h"
#include "componentselectiondialog.h"
-#include "getrepositorymetainfojob.h"
-#include "common/errors.h"
-#include "common/fileutils.h"
-#include "init.h"
#include "updateagent.h"
-
-#include "updatesettings.h"
#include "updatesettingsdialog.h"
-using namespace QInstaller;
+#include <common/binaryformat.h>
+#include <common/errors.h>
+#include <updatesettings.h>
-MainWindow::MainWindow( const QStringList& args, QWidget* parent ) : QMainWindow( parent ) {
+#include <KDToolsCore/KDSelfRestarter>
- QInstaller::init();
+#include <QtGui/QAbstractButton>
+#include <QtGui/QApplication>
+#include <QtGui/QLabel>
+#include <QtGui/QMenuBar>
+#include <QtGui/QProgressDialog>
- QMenuBar* mbar = menuBar();
- QMenu* fm = mbar->addMenu( QObject::tr("File") );
- fm->addAction( QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()), QKeySequence( QLatin1String("Ctrl+U") ) );
- fm->addAction( QObject::tr("Update Settings"), this, SLOT(editUpdateSettings()) );
- fm->addAction( QObject::tr("Quit"), QApplication::instance(), SLOT(quit()), QKeySequence( QLatin1String("Ctrl+Q") ) );
- QLabel* label = new QLabel( this );
- label->setAlignment( Qt::AlignCenter );
- setCentralWidget( label );
- label->setText( QString::fromLatin1("Version: %1\n").arg( m_installer.settings().applicationVersion() ) + args.join( QLatin1String(" ") ) );
- updaterapp.packagesInfo()->setApplicationName( m_settings.applicationName() );
- updaterapp.packagesInfo()->setApplicationVersion( m_settings.applicationVersion() );
+using namespace QInstaller;
+using namespace QInstallerCreator;
- UpdateAgent* const agent = new UpdateAgent( this );
- connect( agent, SIGNAL( updatesAvailable() ), this, SLOT( updatesAvailable() ) );
+MainWindow::MainWindow(const QStringList &args, QWidget *parent)
+ : QMainWindow(parent)
+ , m_dialog(new UpdateSettingsDialog(this))
+{
+ m_installer.setUpdater();
+ m_installer.setUpdaterApplication(&updaterapp);
+
+ QMenu *fm = menuBar()->addMenu(QObject::tr("File"));
+ fm->addAction(QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()),
+ QKeySequence(QLatin1String("Ctrl+U")));
+ fm->addAction(QObject::tr("Update Settings"), this, SLOT(editUpdateSettings()));
+ fm->addAction(QObject::tr("Quit"), QApplication::instance(), SLOT(quit()),
+ QKeySequence(QLatin1String("Ctrl+Q")));
+
+ QLabel *label = new QLabel(this);
+ label->setWordWrap(true);
+ label->setAlignment(Qt::AlignCenter);
+ setCentralWidget(label);
+ label->setText(QString::fromLatin1("Version: %1\n").arg(m_installer.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()));
}
void MainWindow::editUpdateSettings()
{
- UpdateSettingsDialog dialog( this );
- connect( &dialog, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) );
- dialog.exec();
+ connect(m_dialog, SIGNAL(checkForUpdates()), this, SLOT(checkForUpdates()));
+ m_dialog->show();
}
-void MainWindow::checkForUpdates() {
- std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
- handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
-
+void MainWindow::checkForUpdates()
+{
+ QScopedPointer<BinaryFormatEngineHandler> handler(new BinaryFormatEngineHandler(ComponentIndex()));
+ handler->setComponentIndex(QInstallerCreator::ComponentIndex());
+
UpdateSettings settings;
-
- try
- {
- m_installer.setRemoteRepositories( settings.repositories() );
- settings.setLastCheck( QDateTime::currentDateTime() );
-
+ try {
+ m_installer.setTemporaryRepositories(settings.repositories());
+ settings.setLastCheck(QDateTime::currentDateTime());
+
+ if (!m_installer.fetchUpdaterPackages()) {
+ settings.setLastResult(tr("Software Update failed."));
+ QMessageBox::information(this, tr("Check for Updates"), tr("Failed to retrieve updates!"));
+ return;
+ }
+
// no updates for us
- if( m_installer.components().isEmpty() )
- {
- QMessageBox::information( this, tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) );
+ if (m_installer.components(false, UpdaterMode).isEmpty()) {
+ QMessageBox::information(this, tr("Check for Updates"), tr("There are currently no updates "
+ "available for you."));
return;
}
// set the target directory to the actual one
- m_installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
+ m_installer.setValue(QLatin1String("TargetDir"), QFileInfo(updaterapp.packagesInfo()->fileName())
+ .absolutePath());
- // this will automatically mork components as to get installed
- ComponentSelectionDialog componentSelection( &m_installer, this );
- if( componentSelection.exec() == QDialog::Rejected )
+ // this will automatically mark components as to get installed
+ ComponentSelectionDialog componentSelection(&m_installer, this);
+ if (componentSelection.exec() == QDialog::Rejected)
return;
- QProgressDialog dialog( this );
- dialog.setRange( 0, 100 );
+ QProgressDialog dialog(this);
+ dialog.setRange(0, 100);
dialog.show();
- connect( &dialog, SIGNAL( canceled() ), &m_installer, SLOT( interrupt() ) );
- connect( &m_installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) );
- connect( &m_installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) );
+ connect(&dialog, SIGNAL(canceled()), &m_installer, SLOT(interrupt()));
+ connect(&m_installer, SIGNAL(installationProgressTextChanged(QString)), &dialog,
+ SLOT(setLabelText(QString)));
+ connect(&m_installer, SIGNAL(installationProgressChanged(int)), &dialog, SLOT(setValue(int)));
m_installer.installSelectedComponents();
updatesInstalled();
- }
- catch( const QInstaller::Error& error )
- {
- QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) );
+ } catch (const QInstaller::Error &error) {
+ QMessageBox::critical(this, tr("Check for Updates"), tr("Error while installing updates:\n%1")
+ .arg(error.what()));
m_installer.rollBackInstallation();
- settings.setLastResult( tr( "Software Update failed." ) );
- }
- catch( ... )
- {
- QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ settings.setLastResult(tr("Software Update failed."));
+ } catch (...) {
+ QMessageBox::critical(this, tr("Check for Updates"), tr("Unknown error while installing updates."));
m_installer.rollBackInstallation();
- settings.setLastResult( tr( "Software Update failed." ) );
+ settings.setLastResult(tr("Software Update failed."));
}
}
void MainWindow::updatesAvailable()
{
- KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
- box->setWindowTitle( tr("Updates Available") );
- box->setText( tr("Software updates are available for your computer. Do you want to install them?") );
- box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
- box->button( QMessageBox::Yes )->setText( tr( "Continue" ) );
- box->button( QMessageBox::No )->setText( tr( "Not Now" ) );
+ QScopedPointer<QMessageBox> box(new QMessageBox(this));
+ box->setWindowTitle(tr("Updates Available"));
+ box->setText(tr("Software updates are available for your computer. Do you want to install them?"));
+ box->setStandardButtons(QMessageBox::Yes|QMessageBox::No);
+ box->button(QMessageBox::Yes)->setText(tr("Continue"));
+ box->button(QMessageBox::No)->setText(tr("Not Now"));
box->exec();
- if ( !box )
- return;
- if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+
+ if (box && box->clickedButton() == box->button(QMessageBox::Yes))
checkForUpdates();
}
void MainWindow::updatesInstalled()
{
// only ask that dumb question if a SelfUpdateOperation was executed
- if( !KDSelfRestarter::restartOnQuit() )
- {
- QMessageBox::information( this, tr( "Updates Installed" ), tr( "Installation complete." ) );
+ if (!KDSelfRestarter::restartOnQuit()) {
+ QMessageBox::information(this, tr("Updates Installed"), tr("Installation complete."));
return;
}
- KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
- box->setWindowTitle( tr("Updates Installed" ) );
- box->setText( tr("Installation complete, you need to restart the application for the changes to take effect.") );
- box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
- box->button( QMessageBox::Yes )->setText( tr("Restart Now") );
- box->button( QMessageBox::No )->setText( tr("Restart Later") );
+ QScopedPointer<QMessageBox> box(new QMessageBox(this));
+ box->setWindowTitle(tr("Updates Installed"));
+ box->setText(tr("Installation complete, you need to restart the application for the changes to take effect."));
+ box->setStandardButtons(QMessageBox::Yes|QMessageBox::No);
+ box->button(QMessageBox::Yes)->setText(tr("Restart Now"));
+ box->button(QMessageBox::No)->setText(tr("Restart Later"));
box->exec();
- if ( !box )
+ if (!box)
return;
- if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ if (box->clickedButton() == box->button(QMessageBox::Yes))
QCoreApplication::quit();
else
- KDSelfRestarter::setRestartOnQuit( false );
+ KDSelfRestarter::setRestartOnQuit(false);
}
diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h
index c0611eaab..e2ae37a8c 100644
--- a/examples/testapp/mainwindow.h
+++ b/examples/testapp/mainwindow.h
@@ -23,17 +23,22 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-#include <QMainWindow>
+
+#include <qinstaller.h>
+#include <common/installersettings.h>
#include <KDUpdater/Application>
-#include "qinstaller.h"
-#include "common/installersettings.h"
+#include <QtGui/QMainWindow>
+
+class UpdateSettingsDialog;
-class MainWindow : public QMainWindow {
+class MainWindow : public QMainWindow
+{
Q_OBJECT
+
public:
- explicit MainWindow( const QStringList& args, QWidget* parent=0 );
+ explicit MainWindow(const QStringList &args, QWidget *parent = 0);
private Q_SLOTS:
void editUpdateSettings();
@@ -42,7 +47,9 @@ private Q_SLOTS:
void updatesAvailable();
private:
- KDUpdater::Application updaterapp;
+ UpdateSettingsDialog *m_dialog;
+
QInstaller::Installer m_installer;
+ KDUpdater::Application updaterapp;
QInstaller::InstallerSettings m_settings;
};
diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml b/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml
index f46f5dd69..8e0fac180 100644
--- a/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml
+++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml
@@ -4,4 +4,5 @@
<Version>1</Version>
<ReleaseDate>2009-12-03</ReleaseDate>
<Name>com.nokia.testapp.subcomponent.alwaysvisible</Name>
+ <Default>true</Default>
</Package>
diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs
new file mode 100644
index 000000000..4ccf7a047
--- /dev/null
+++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs
@@ -0,0 +1,9 @@
+// constructor
+function Component()
+{
+}
+
+Component.prototype.isDefault = function()
+{
+ return true;
+}
diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml
index eae13a429..3da78f49d 100644
--- a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml
+++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml
@@ -5,4 +5,6 @@
<ReleaseDate>2009-12-03</ReleaseDate>
<Name>com.nokia.testapp.subcomponent.virtual</Name>
<Virtual>true</Virtual>
+ <Script>installscript.qs</Script>
+ <Default>script</Default>
</Package>
diff --git a/examples/testapp/testapp.pro b/examples/testapp/testapp.pro
index 372d85908..9ae4edc70 100644
--- a/examples/testapp/testapp.pro
+++ b/examples/testapp/testapp.pro
@@ -11,9 +11,20 @@ CONFIG += uitools help
QTPLUGIN += qsqlite
# Input
-HEADERS += mainwindow.h
-SOURCES += main.cpp mainwindow.cpp
+FORMS += componentselectiondialog.ui updatesettingsdialog.ui updatesettingswidget.ui
+HEADERS += mainwindow.h \
+ componentselectiondialog.h \
+ updatesettingsdialog.h \
+ updateagent.h \
+ updatesettingswidget.h
+
+SOURCES += main.cpp mainwindow.cpp \
+ componentselectiondialog.cpp \
+ updatesettingsdialog.cpp \
+ updateagent.cpp \
+ updatesettingswidget.cpp
+
RESOURCES += testapp.qrc
macx:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase TestAppInstaller.app com.nokia.testapp)
-win32:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator.exe -p $$PWD/packages -c $$PWD/config -t $$OUT_PWD/../../installerbuilder/bin/installerbase.exe TestAppInstaller.exe com.nokia.testapp)
+win32:QMAKE_POST_LINK = ($$OUT_PWD\\..\\..\\installerbuilder\\bin\\binarycreator.exe -p $$PWD\\packages -c $$PWD\\config -t $$OUT_PWD\\..\\..\\installerbuilder\\bin\\installerbase.exe TestAppInstaller.exe com.nokia.testapp)
diff --git a/examples/testapp/updateagent.cpp b/examples/testapp/updateagent.cpp
new file mode 100644
index 000000000..7f7722c08
--- /dev/null
+++ b/examples/testapp/updateagent.cpp
@@ -0,0 +1,114 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updateagent.h"
+
+#include <common/binaryformatenginehandler.h>
+#include <common/binaryformat.h>
+#include <common/errors.h>
+#include <qinstaller.h>
+#include <qinstallercomponent.h>
+#include <updatesettings.h>
+
+#include <QtCore/QDateTime>
+#include <QtCore/QTimer>
+
+#include <KDUpdater/Application>
+
+using namespace QInstaller;
+using QInstallerCreator::ComponentIndex;
+using QInstallerCreator::BinaryFormatEngineHandler;
+
+class UpdateAgent::Private
+{
+public:
+ Private(UpdateAgent *qq)
+ : q(qq)
+ {
+ connect(&checkTimer, SIGNAL(timeout()), q, SLOT(maybeCheck()));
+ checkTimer.start(1000);
+ }
+
+private:
+ QTimer checkTimer;
+ UpdateAgent *const q;
+
+public:
+ void maybeCheck()
+ {
+ checkTimer.stop();
+
+ UpdateSettings settings;
+ try {
+ if (settings.updateInterval() > 0
+ && settings.lastCheck().secsTo(QDateTime::currentDateTime()) >= settings.updateInterval()) {
+ // update the time we last checked for updates
+ settings.setLastCheck(QDateTime::currentDateTime());
+
+ QScopedPointer<BinaryFormatEngineHandler> handler;
+ handler.reset(new BinaryFormatEngineHandler(ComponentIndex()));
+ handler->setComponentIndex(QInstallerCreator::ComponentIndex());
+
+ KDUpdater::Application app;
+ Installer installer(QInstaller::MagicUpdaterMarker);
+ installer.setUpdaterApplication(&app);
+ installer.setTemporaryRepositories(settings.repositories());
+ if (!installer.fetchUpdaterPackages())
+ throw Error(tr("Software Update failed."));
+ settings.setLastResult(tr("Software Update run successfully."));
+
+ QList<Component*> components = installer.components(false, UpdaterMode);
+ // no updates available
+ if (components.isEmpty())
+ return;
+ emit q->updatesAvailable();
+ }
+ } catch (...) {
+ settings.setLastResult(tr("Software Update failed."));
+ return;
+ }
+ checkTimer.start();
+ }
+};
+
+UpdateAgent::UpdateAgent(QObject *parent)
+ : QObject(parent),
+ d(new Private(this))
+{
+}
+
+UpdateAgent::~UpdateAgent()
+{
+ delete d;
+}
+
+#include "moc_updateagent.cpp"
diff --git a/installerbuilder/libinstaller/updateagent.h b/examples/testapp/updateagent.h
index 34310b75d..b4b245586 100644
--- a/installerbuilder/libinstaller/updateagent.h
+++ b/examples/testapp/updateagent.h
@@ -27,30 +27,23 @@
#define UPDATEAGENT_H
#include <QtCore/QObject>
-#include <KDToolsCore/pimpl_ptr.h>
-#include "installer_global.h"
-
-namespace QInstaller
-{
-
-class INSTALLER_EXPORT UpdateAgent : public QObject
+class UpdateAgent : public QObject
{
Q_OBJECT
public:
- explicit UpdateAgent( QObject* parent = 0 );
+ explicit UpdateAgent(QObject *parent = 0);
~UpdateAgent();
Q_SIGNALS:
void updatesAvailable();
private:
- Q_PRIVATE_SLOT( d, void maybeCheck() );
+ Q_PRIVATE_SLOT(d, void maybeCheck());
+private:
class Private;
- kdtools::pimpl_ptr< Private > d;
+ Private *const d;
};
-}
-
#endif
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.cpp b/examples/testapp/updatesettingsdialog.cpp
index 0c3c676cb..f65a391b6 100644
--- a/installerbuilder/libinstaller/updatesettingsdialog.cpp
+++ b/examples/testapp/updatesettingsdialog.cpp
@@ -33,45 +33,46 @@
#include "updatesettingsdialog.h"
#include "ui_updatesettingsdialog.h"
-#include "common/repository.h"
+#include <common/repository.h>
+#include <updatesettings.h>
-#include "updatesettings.h"
+#include <QtCore/QDateTime>
-#include <QDateTime>
-#include <QStringListModel>
+#include <QtGui/QStringListModel>
using namespace QInstaller;
class UpdateSettingsDialog::Private
{
public:
- Private( UpdateSettingsDialog* qq )
- : q( qq )
+ Private(UpdateSettingsDialog *qq)
+ : q(qq)
{
- ui.setupUi( q );
+ ui.setupUi(q);
}
private:
- UpdateSettingsDialog* const q;
+ UpdateSettingsDialog *const q;
public:
Ui::UpdateSettingsDialog ui;
};
-UpdateSettingsDialog::UpdateSettingsDialog( QWidget* parent )
- : QDialog( parent ),
- d( new Private( this ) )
+UpdateSettingsDialog::UpdateSettingsDialog(QWidget *parent)
+ : QDialog(parent),
+ d(new Private(this))
{
- connect( d->ui.buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
- connect( d->ui.buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
-
- connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SLOT( accept() ) );
- connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SIGNAL( checkForUpdates() ) );
- setFixedSize( size() );
+ connect(d->ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(d->ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+ connect(d->ui.widget, SIGNAL(checkForUpdates()), this, SLOT(accept()));
+ connect(d->ui.widget, SIGNAL(checkForUpdates()), this, SIGNAL(checkForUpdates()));
+ setFixedSize(size());
}
UpdateSettingsDialog::~UpdateSettingsDialog()
{
+ delete d;
}
void UpdateSettingsDialog::accept()
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.h b/examples/testapp/updatesettingsdialog.h
index 35fe599e5..78daad7fb 100644
--- a/installerbuilder/libinstaller/updatesettingsdialog.h
+++ b/examples/testapp/updatesettingsdialog.h
@@ -28,31 +28,23 @@
#include <QtGui/QDialog>
-#include <KDToolsCore/pimpl_ptr.h>
-
-#include "installer_global.h"
-
-namespace QInstaller
-{
-
-class INSTALLER_EXPORT UpdateSettingsDialog : public QDialog
+class UpdateSettingsDialog : public QDialog
{
Q_OBJECT
+
public:
- explicit UpdateSettingsDialog( QWidget* parent = 0 );
+ explicit UpdateSettingsDialog(QWidget *parent = 0);
~UpdateSettingsDialog();
-Q_SIGNALS:
- void checkForUpdates();
-
public Q_SLOTS:
void accept();
+Q_SIGNALS:
+ void checkForUpdates();
+
private:
class Private;
- kdtools::pimpl_ptr< Private > d;
+ Private *const d;
};
-}
-
#endif
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.ui b/examples/testapp/updatesettingsdialog.ui
index 430f6c590..0a879257b 100644
--- a/installerbuilder/libinstaller/updatesettingsdialog.ui
+++ b/examples/testapp/updatesettingsdialog.ui
@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QInstaller::UpdateSettingsWidget" name="widget" native="true"/>
+ <widget class="UpdateSettingsWidget" name="widget" native="true"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
@@ -28,7 +28,7 @@
</widget>
<customwidgets>
<customwidget>
- <class>QInstaller::UpdateSettingsWidget</class>
+ <class>UpdateSettingsWidget</class>
<extends>QWidget</extends>
<header>updatesettingswidget.h</header>
<container>1</container>
diff --git a/examples/testapp/updatesettingswidget.cpp b/examples/testapp/updatesettingswidget.cpp
new file mode 100644
index 000000000..6455760fe
--- /dev/null
+++ b/examples/testapp/updatesettingswidget.cpp
@@ -0,0 +1,155 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updatesettingswidget.h"
+#include "ui_updatesettingswidget.h"
+
+#include <common/repository.h>
+#include "updatesettings.h"
+
+#include <QtCore/QDateTime>
+
+#include <QtGui/QStringListModel>
+
+using namespace QInstaller;
+
+class UpdateSettingsWidget::Private
+{
+public:
+ Private(UpdateSettingsWidget *qq)
+ : q(qq),
+ initialized(false)
+ {
+ ui.setupUi(q);
+ }
+
+ void addUpdateSource()
+ {
+ const int newRow = model.rowCount();
+ if (model.insertRow(newRow))
+ ui.treeViewUpdateSources->edit(model.index(newRow, 0));
+ }
+
+ void removeUpdateSource()
+ {
+ model.removeRow(ui.treeViewUpdateSources->currentIndex().row());
+ }
+
+private:
+ UpdateSettingsWidget *const q;
+
+public:
+ bool initialized;
+ QStringListModel model;
+ UpdateSettings settings;
+
+ Ui::UpdateSettingsWidget ui;
+};
+
+
+// -- UpdateSettingsWidget
+
+UpdateSettingsWidget::UpdateSettingsWidget(QWidget *parent)
+ : QWidget(parent),
+ d(new Private(this))
+{
+}
+
+UpdateSettingsWidget::~UpdateSettingsWidget()
+{
+ delete d;
+}
+
+void UpdateSettingsWidget::showEvent(QShowEvent *event)
+{
+ Q_UNUSED(event)
+ if (d->initialized)
+ return;
+
+ d->ui.checkBoxCheckForUpdates->setChecked(d->settings.updateInterval() > 0);
+ d->ui.checkBoxCheckOnlyImportant->setChecked(d->settings.checkOnlyImportantUpdates());
+ switch (qAbs(d->settings.updateInterval())) {
+ case UpdateSettings::Daily:
+ d->ui.comboBoxFrequency->setCurrentIndex(0);
+ break;
+ case UpdateSettings::Weekly:
+ d->ui.comboBoxFrequency->setCurrentIndex(1);
+ break;
+ case UpdateSettings::Monthly:
+ d->ui.comboBoxFrequency->setCurrentIndex(2);
+ break;
+ }
+
+ connect(d->ui.buttonCheckNow, SIGNAL(clicked()), this, SIGNAL(checkForUpdates()));
+ connect(d->ui.buttonAddUpdateSource, SIGNAL(clicked()), this, SLOT(addUpdateSource()));
+ connect(d->ui.buttonRemoveUpdateSource, SIGNAL(clicked()), this, SLOT(removeUpdateSource()));
+
+ QStringList reps;
+ foreach (const Repository &repository, d->settings.repositories())
+ reps.append(repository.url().toString());
+
+ d->model.setStringList(reps);
+ d->ui.treeViewUpdateSources->setModel(&d->model);
+
+ d->ui.labelLastUpdateResult->clear();
+ if (!d->settings.lastResult().isEmpty()) {
+ d->ui.labelLastUpdateResult->setText(d->settings.lastResult() + QLatin1Char('\n')
+ + d->settings.lastCheck().toString());
+ }
+ d->initialized = true;
+}
+
+void UpdateSettingsWidget::accept()
+{
+ switch(d->ui.comboBoxFrequency->currentIndex()) {
+ case 0:
+ d->settings.setUpdateInterval(UpdateSettings::Daily);
+ break;
+ case 1:
+ d->settings.setUpdateInterval(UpdateSettings::Weekly);
+ break;
+ case 2:
+ d->settings.setUpdateInterval(UpdateSettings::Monthly);
+ break;
+ }
+
+ if (!d->ui.checkBoxCheckForUpdates->isChecked())
+ d->settings.setUpdateInterval(-d->settings.updateInterval());
+ d->settings.setCheckOnlyImportantUpdates(d->ui.checkBoxCheckOnlyImportant->isChecked());
+
+ QList<Repository> repositories;
+ foreach (const QString &url, d->model.stringList())
+ repositories.append(Repository(QUrl(url)));
+ d->settings.setRepositories(repositories);
+}
+
+#include "moc_updatesettingswidget.cpp"
diff --git a/installerbuilder/libinstaller/updatesettingswidget.h b/examples/testapp/updatesettingswidget.h
index 7c7c125eb..25f75daae 100644
--- a/installerbuilder/libinstaller/updatesettingswidget.h
+++ b/examples/testapp/updatesettingswidget.h
@@ -28,37 +28,30 @@
#include <QtGui/QWidget>
-#include <KDToolsCore/pimpl_ptr.h>
-
-#include "installer_global.h"
-
-namespace QInstaller
-{
-
-class INSTALLER_EXPORT UpdateSettingsWidget : public QWidget
+class UpdateSettingsWidget : public QWidget
{
Q_OBJECT
+
public:
- explicit UpdateSettingsWidget( QWidget* parent = 0 );
+ explicit UpdateSettingsWidget(QWidget *parent = 0);
~UpdateSettingsWidget();
-Q_SIGNALS:
- void checkForUpdates();
-
public Q_SLOTS:
void accept();
+Q_SIGNALS:
+ void checkForUpdates();
+
protected:
- void showEvent( QShowEvent* event );
+ void showEvent(QShowEvent *event);
private:
- Q_PRIVATE_SLOT( d, void addUpdateSource() );
- Q_PRIVATE_SLOT( d, void removeUpdateSource() );
+ Q_PRIVATE_SLOT(d, void addUpdateSource());
+ Q_PRIVATE_SLOT(d, void removeUpdateSource());
+private:
class Private;
- kdtools::pimpl_ptr< Private > d;
+ Private *const d;
};
-}
-
#endif
diff --git a/installerbuilder/libinstaller/updatesettingswidget.ui b/examples/testapp/updatesettingswidget.ui
index 49525e1b9..49525e1b9 100644
--- a/installerbuilder/libinstaller/updatesettingswidget.ui
+++ b/examples/testapp/updatesettingswidget.ui
diff --git a/installerbuilder/binarycreator/binarycreator.cpp b/installerbuilder/binarycreator/binarycreator.cpp
index c5f9236da..3f262bdfe 100644
--- a/installerbuilder/binarycreator/binarycreator.cpp
+++ b/installerbuilder/binarycreator/binarycreator.cpp
@@ -139,10 +139,12 @@ static int assemble(Input input, const QString &configdir)
QInstaller::mkpath(fi.filePath() + QLatin1String("/Contents/MacOS"));
QInstaller::mkpath(fi.filePath() + QLatin1String("/Contents/Resources"));
- QFile pkgInfo(fi.filePath() + QLatin1String("/Contents/PkgInfo"));
- pkgInfo.open(QIODevice::WriteOnly);
- QTextStream pkgInfoStream(&pkgInfo);
- pkgInfoStream << QLatin1String("APPL????") << endl;
+ {
+ QFile pkgInfo(fi.filePath() + QLatin1String("/Contents/PkgInfo"));
+ pkgInfo.open(QIODevice::WriteOnly);
+ QTextStream pkgInfoStream(&pkgInfo);
+ pkgInfoStream << QLatin1String("APPL????") << endl;
+ }
const QString iconFile = QFile::exists(settings.icon()) ? settings.icon()
: QString::fromLatin1(":/resources/default_icon_mac.icns");
diff --git a/installerbuilder/common/binaryformat.cpp b/installerbuilder/common/binaryformat.cpp
index d418d0f98..72ab9db48 100644
--- a/installerbuilder/common/binaryformat.cpp
+++ b/installerbuilder/common/binaryformat.cpp
@@ -31,29 +31,20 @@
**
**************************************************************************/
#include "binaryformat.h"
+
#include "errors.h"
#include "fileutils.h"
+#include "lib7z_facade.h"
#include "utils.h"
#include "zipjob.h"
-#include "lib7z_facade.h"
-
-#include <QDir>
-#include <QDirIterator>
-#include <QFileInfo>
-#include <QDebug>
-#include <QResource>
-#include <QTemporaryFile>
-#include <QThreadPool>
-#include <QVector>
-
-#include "common/kd7zenginehandler.h"
-
#include <KDUpdater/UpdateOperation>
#include <KDUpdater/UpdateOperationFactory>
-#include <cassert>
-#include <cerrno>
+#include <QtCore/QResource>
+#include <QtCore/QTemporaryFile>
+
+#include <errno.h>
using namespace QInstaller;
using namespace QInstallerCreator;
@@ -70,22 +61,22 @@ static inline QByteArray &theBuffer(int size)
{
static QByteArray b;
if (size > b.size())
- b.resize( size );
+ b.resize(size);
return b;
}
void QInstaller::appendFileData(QIODevice *out, QIODevice *in)
{
- assert( !in->isSequential() );
+ Q_ASSERT(!in->isSequential());
const qint64 size = in->size();
- blockingCopy( in, out, size );
+ blockingCopy(in, out, size);
}
void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in)
{
qint64 size = QInstaller::retrieveInt64(in);
- appendData( in, out, size );
+ appendData(in, out, size);
/* QByteArray &b = theBuffer(size);
blockingRead(in, b.data(), size);
blockingWrite(out, b.constData(), size);*/
@@ -93,26 +84,27 @@ void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in)
void QInstaller::appendInt64(QIODevice *out, qint64 n)
{
- blockingWrite(out, reinterpret_cast<const char*>( &n ), sizeof(n));
+ blockingWrite(out, reinterpret_cast<const char*>(&n), sizeof(n));
}
-void QInstaller::appendInt64Range( QIODevice* out, const Range<qint64>& r ) {
- appendInt64( out, r.start() );
- appendInt64( out, r.length() );
+void QInstaller::appendInt64Range(QIODevice *out, const Range<qint64> &r)
+{
+ appendInt64(out, r.start());
+ appendInt64(out, r.length());
}
qint64 QInstaller::retrieveInt64(QIODevice *in)
{
qint64 n = 0;
- blockingRead( in, reinterpret_cast<char*>( &n ), sizeof(n) );
+ blockingRead(in, reinterpret_cast<char*>(&n), sizeof(n));
return n;
}
-Range< qint64 > QInstaller::retrieveInt64Range( QIODevice* in )
+Range<qint64> QInstaller::retrieveInt64Range(QIODevice *in)
{
- const quint64 start = retrieveInt64( in );
- const quint64 length = retrieveInt64( in );
- return Range< qint64 >::fromStartAndLength( start, length );
+ const quint64 start = retrieveInt64(in);
+ const quint64 length = retrieveInt64(in);
+ return Range<qint64>::fromStartAndLength(start, length);
}
@@ -138,19 +130,18 @@ static void appendFileData(QIODevice *out, const QString &fileName)
void QInstaller::appendData(QIODevice *out, QIODevice *in, qint64 size)
{
- while( size > 0 )
- {
- const qint64 nextSize = qMin( size, 16384LL );
- QByteArray &b = theBuffer( nextSize );
- blockingRead( in, b.data(), nextSize );
- blockingWrite( out, b.constData(), nextSize );
+ while (size > 0) {
+ const qint64 nextSize = qMin(size, 16384LL);
+ QByteArray &b = theBuffer(nextSize);
+ blockingRead(in, b.data(), nextSize);
+ blockingWrite(out, b.constData(), nextSize);
size -= nextSize;
}
}
void QInstaller::appendString(QIODevice *out, const QString &str)
{
- appendByteArray( out, str.toUtf8() );
+ appendByteArray(out, str.toUtf8());
}
void QInstaller::appendByteArray(QIODevice *out, const QByteArray &ba)
@@ -161,39 +152,50 @@ void QInstaller::appendByteArray(QIODevice *out, const QByteArray &ba)
void QInstaller::appendStringList(QIODevice *out, const QStringList &list)
{
- appendInt64( out, list.size() );
- Q_FOREACH ( const QString &s, list )
+ appendInt64(out, list.size());
+ foreach (const QString &s, list)
appendString(out, s);
}
-void QInstaller::appendDictionary(QIODevice *out, const QHash<QString,QString>& dict)
+void QInstaller::appendDictionary(QIODevice *out, const QHash<QString,QString> &dict)
{
appendInt64(out, dict.size());
- Q_FOREACH (const QString &key, dict.keys()) {
+ foreach (const QString &key, dict.keys()) {
appendString(out, key);
appendString(out, dict.value(key));
}
}
+qint64 QInstaller::appendCompressedData(QIODevice *out, QIODevice *in, qint64 size)
+{
+ QByteArray ba;
+ ba.resize(size);
+ blockingRead(in, ba.data(), size);
+
+ QByteArray cba = qCompress(ba);
+ blockingWrite(out, cba, cba.size());
+ return cba.size();
+}
+
QString QInstaller::retrieveString(QIODevice *in)
{
- const QByteArray b = retrieveByteArray( in );
- return QString::fromUtf8( b );
+ const QByteArray b = retrieveByteArray(in);
+ return QString::fromUtf8(b);
}
QByteArray QInstaller::retrieveByteArray(QIODevice *in)
{
QByteArray ba;
- const qint64 n = retrieveInt64( in );
- ba.resize( n );
- blockingRead( in, ba.data(), n );
+ const qint64 n = retrieveInt64(in);
+ ba.resize(n);
+ blockingRead(in, ba.data(), n);
return ba;
}
QStringList QInstaller::retrieveStringList(QIODevice *in)
{
QStringList list;
- for(qint64 i = retrieveInt64(in); --i >= 0; )
+ for (qint64 i = retrieveInt64(in); --i >= 0;)
list << retrieveString(in);
return list;
}
@@ -201,608 +203,606 @@ QStringList QInstaller::retrieveStringList(QIODevice *in)
QHash<QString,QString> QInstaller::retrieveDictionary(QIODevice *in)
{
QHash<QString,QString> dict;
- for (qint64 i = retrieveInt64(in); --i >= 0; ) {
+ for (qint64 i = retrieveInt64(in); --i >= 0;) {
QString key = retrieveString(in);
dict.insert(key, retrieveString(in));
}
return dict;
}
-qint64 QInstaller::findMagicCookie( QFile* in ) {
- assert( in );
- assert( in->isOpen() );
- assert( in->isReadable() );
+QByteArray QInstaller::retrieveData(QIODevice *in, qint64 size)
+{
+ QByteArray ba;
+ ba.resize(size);
+ blockingRead(in, ba.data(), size);
+ return ba;
+}
+
+QByteArray QInstaller::retrieveCompressedData(QIODevice *in, qint64 size)
+{
+ QByteArray ba;
+ ba.resize(size);
+ blockingRead(in, ba.data(), size);
+ return qUncompress(ba);
+}
+
+qint64 QInstaller::findMagicCookie(QFile *in, quint64 magicCookie)
+{
+ Q_ASSERT(in);
+ Q_ASSERT(in->isOpen());
+ Q_ASSERT(in->isReadable());
const qint64 oldPos = in->pos();
const qint64 MAX_SEARCH = 1024 * 1024; // stop searching after one MB
qint64 searched = 0;
try {
- while ( searched < MAX_SEARCH ) {
- const qint64 pos = in->size() - searched - sizeof( qint64 );
- if ( pos < 0 )
- throw Error( QObject::tr("Searched whole file, no marker found") );
- if ( !in->seek( pos ) )
- throw Error( QObject::tr("Could not seek to %1 in file %2: %3.").arg( QString::number(pos), in->fileName(), in->errorString() ) );
- const quint64 num = static_cast<quint64>( retrieveInt64( in ) );
- if ( num == MagicCookie ) {
- in->seek( oldPos );
+ while (searched < MAX_SEARCH) {
+ const qint64 pos = in->size() - searched - sizeof(qint64);
+ if (pos < 0)
+ throw Error(QObject::tr("Searched whole file, no marker found"));
+ if (!in->seek(pos)) {
+ throw Error(QObject::tr("Could not seek to %1 in file %2: %3.").arg(QString::number(pos),
+ in->fileName(), in->errorString()));
+ }
+ const quint64 num = static_cast<quint64>(retrieveInt64(in));
+ if (num == magicCookie) {
+ in->seek(oldPos);
return pos;
}
searched += 1;
}
- throw Error( QObject::tr("No marker found, stopped after %1 bytes").arg( QString::number( MAX_SEARCH ) ) );
- } catch ( const Error& err ) {
- in->seek( oldPos );
+ throw Error(QObject::tr("No marker found, stopped after %1 bytes").arg(QString::number(MAX_SEARCH)));
+ } catch (const Error& err) {
+ in->seek(oldPos);
throw err;
- } catch ( ... ) {
- in->seek( oldPos );
- throw Error( QObject::tr("No marker found, unknown exception caught.") );
+ } catch (...) {
+ in->seek(oldPos);
+ throw Error(QObject::tr("No marker found, unknown exception caught."));
}
return -1; // never reached
}
-/**
- * Creates an archive providing the data in \a path.
- * \a path can be a path to a file or to a directory. If it's a file, it's considered to be
- * pre-zipped and gets delivered as it is. If it's a directory, it gets zipped by Archive.
+/*!
+ Creates an archive providing the data in \a path.
+ \a path can be a path to a file or to a directory. If it's a file, it's considered to be
+ pre-zipped and gets delivered as it is. If it's a directory, it gets zipped by Archive.
*/
-Archive::Archive( const QString& path )
- : m_device( 0 ),
- m_isTempFile( false ),
- m_path( path ),
- m_name( QFileInfo( path ).fileName().toUtf8() )
+Archive::Archive(const QString &path)
+ : m_device(0),
+ m_isTempFile(false),
+ m_path(path),
+ m_name(QFileInfo(path).fileName().toUtf8())
{
}
-Archive::Archive( const QByteArray& identifier, const QByteArray& data )
- : m_device( 0 ),
- m_isTempFile( true ),
- m_path( generateTemporaryFileName() ),
- m_name( identifier )
+Archive::Archive(const QByteArray &identifier, const QByteArray &data)
+ : m_device(0),
+ m_isTempFile(true),
+ m_path(generateTemporaryFileName()),
+ m_name(identifier)
{
- QFile file( m_path );
- file.open( QIODevice::WriteOnly );
- file.write( data );
+ QFile file(m_path);
+ file.open(QIODevice::WriteOnly);
+ file.write(data);
}
-/**
- * Creates an archive identified by \a identifier providing a data \a segment within a \a device.
+/*!
+ Creates an archive identified by \a identifier providing a data \a segment within a \a device.
*/
-Archive::Archive( const QByteArray& identifier, QIODevice* device, const Range< qint64 >& segment )
- : m_device( device ),
- m_segment( segment ),
- m_isTempFile( false ),
- m_name( identifier )
+Archive::Archive(const QByteArray &identifier, QIODevice *device, const Range<qint64> &segment)
+ : m_device(device),
+ m_segment(segment),
+ m_isTempFile(false),
+ m_name(identifier)
{
}
Archive::~Archive()
{
- if( isOpen() )
+ if (isOpen())
close();
- if( m_isTempFile )
- QFile::remove( m_path );
+ if (m_isTempFile)
+ QFile::remove(m_path);
}
-/**
- * Copies the archives contents to the path \a name.
- *
- * If the archive is a zipped directory, \a name is threated as a directory. The archive
- * gets extracted there.
- *
- * If the archive is a plain file and \a name an existing directory, it gets created
- * with it's name. Otherwise it gets saved as \a name.
- * Note that if a file with the \a name already exists, copy() return false (i.e. Archive will not overwrite it).
+/*!
+ Copies the archives contents to the path \a name.
+ If the archive is a zipped directory, \a name is threated as a directory. The archive gets extracted there.
+
+ If the archive is a plain file and \a name an existing directory, it gets created
+ with it's name. Otherwise it gets saved as \a name.
+ Note that if a file with the \a name already exists, copy() return false (i.e. Archive will not overwrite it).
*/
-bool Archive::copy( const QString& name )
+bool Archive::copy(const QString &name)
{
- if( isZippedDirectory() )
- {
- const QFileInfo fi( name );
- if( fi.exists() && !fi.isDir() )
+ const QFileInfo fileInfo(name);
+ if (isZippedDirectory()) {
+ if (fileInfo.exists() && !fileInfo.isDir())
return false;
+
errno = 0;
- if( !fi.exists() && !QDir().mkpath( fi.absoluteFilePath() ) ) {
- setErrorString( tr("Could not create %1: %2").arg( name, QString::fromLocal8Bit( strerror( errno ) ) ) );
+ const QString absoluteFilePath = fileInfo.absoluteFilePath();
+ if (!fileInfo.exists() && !QDir().mkpath(absoluteFilePath)) {
+ setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(strerror(errno))));
return false;
}
- UnzipJob job;
- if( isOpen() )
+ if (isOpen())
close();
- open( QIODevice::ReadOnly );
- job.setInputDevice( this );
- job.setOutputPath( fi.absoluteFilePath() );
+ open(QIODevice::ReadOnly);
+ UnzipJob job;
+ job.setInputDevice(this);
+ job.setOutputPath(absoluteFilePath);
job.run();
-
- close();
-
- return true;
- }
- else
- {
- if( isOpen() )
+ } else {
+ if (isOpen())
close();
+ open(QIODevice::ReadOnly);
- open( QIODevice::ReadOnly );
-
- QFile target( QFileInfo( name ).isDir() ? QString::fromLatin1( "%1/%2" ).arg( name ).arg( QString::fromUtf8( m_name.data(), m_name.count() ) ) : name );
- if( target.exists() )
+ QFile target(fileInfo.isDir() ? QString::fromLatin1("%1/%2").arg(name)
+ .arg(QString::fromUtf8(m_name.data(), m_name.count())) : name);
+ if (target.exists())
return false;
- target.open( QIODevice::WriteOnly );
- blockingCopy( this, &target, size() );
-
- close();
- return true;
+ target.open(QIODevice::WriteOnly);
+ blockingCopy(this, &target, size());
}
+ close();
+ return true;
}
-/**
- * \reimp
+/*!
+ \reimp
*/
-bool Archive::seek( qint64 pos )
+bool Archive::seek(qint64 pos)
{
- if( m_inputFile.isOpen() )
- return m_inputFile.seek( pos ) && QIODevice::seek( pos );
- return QIODevice::seek( pos );
+ if (m_inputFile.isOpen())
+ return m_inputFile.seek(pos) && QIODevice::seek(pos);
+ return QIODevice::seek(pos);
}
-/**
- * Returns true, if this archive was created by zipping a directory.
+/*!
+ Returns true, if this archive was created by zipping a directory.
*/
bool Archive::isZippedDirectory() const
{
- if( m_device == 0 )
- {
- // easy, just check wheter it's a dir
- return QFileInfo( m_path ).isDir();
- }
- else
- {
- // more complex, check the zip header magic
- Archive* const arch = const_cast< Archive* >( this );
-
- const bool opened = !isOpen();
- if( opened )
- arch->open( QIODevice::ReadOnly );
- const qint64 p = pos();
- arch->seek( 0 );
-
- const QByteArray ba = arch->read( 4 );
- const bool result = ba == QByteArray( "\x50\x4b\x03\04" );
-
- arch->seek( p );
- if( opened )
- arch->close();
- return result;
+ if (m_device == 0) {
+ // easy, just check whether it's a dir
+ return QFileInfo(m_path).isDir();
}
+
+ // more complex, check the zip header magic
+ Archive* const arch = const_cast<Archive*> (this);
+
+ const bool notOpened = !isOpen();
+ if (notOpened)
+ arch->open(QIODevice::ReadOnly);
+ const qint64 p = pos();
+ arch->seek(0);
+
+ const QByteArray ba = arch->read(4);
+ const bool result = ba == QByteArray("\x50\x4b\x03\04");
+
+ arch->seek(p);
+ if (notOpened)
+ arch->close();
+ return result;
}
QByteArray Archive::name() const
{
return m_name;
}
-
-void Archive::setName( const QByteArray& name )
+
+void Archive::setName(const QByteArray &name)
{
m_name = name;
}
-/**
- * \reimpl
+/*!
+ \reimpl
*/
void Archive::close()
{
m_inputFile.close();
- if( QFileInfo( m_path ).isDir() )
+ if (QFileInfo(m_path).isDir())
m_inputFile.remove();
QIODevice::close();
}
-/**
- * \reimp
+/*!
+ \reimp
*/
-bool Archive::open( OpenMode mode )
+bool Archive::open(OpenMode mode)
{
- if( isOpen() )
+ if (isOpen())
return false;
- const bool writeOnly = ( mode & QIODevice::WriteOnly ) != QIODevice::NotOpen;
- const bool append = ( mode & QIODevice::Append ) != QIODevice::NotOpen;
+ const bool writeOnly = (mode & QIODevice::WriteOnly) != QIODevice::NotOpen;
+ const bool append = (mode & QIODevice::Append) != QIODevice::NotOpen;
// no write support
- if( writeOnly || append )
+ if (writeOnly || append)
return false;
- if( m_device != 0 )
- return QIODevice::open( mode );
-
- // we
+ if (m_device != 0)
+ return QIODevice::open(mode);
- const QFileInfo fi( m_path );
- if( fi.isFile() )
- {
- m_inputFile.setFileName( m_path );
- if( !m_inputFile.open( mode ) ) {
- setErrorString( tr("Could not open archive file %1 for reading.").arg( m_path ) );
+ const QFileInfo fi(m_path);
+ if (fi.isFile()) {
+ m_inputFile.setFileName(m_path);
+ if (!m_inputFile.open(mode)) {
+ setErrorString(tr("Could not open archive file %1 for reading.").arg(m_path));
return false;
}
-
-/* if ( !Lib7z::isSupportedArchive( &m_inputFile ) ) {
- setErrorString( tr("Not in a supported archive format: %1").arg( m_path ) );
- m_inputFile.close();
- return false;
- }*/
-
- setOpenMode( mode );
+ setOpenMode(mode);
return true;
}
- if( fi.isDir() )
- {
- if( m_inputFile.fileName().isEmpty() || !m_inputFile.exists() )
- {
- if( !createZippedFile() )
+ if (fi.isDir()) {
+ if (m_inputFile.fileName().isEmpty() || !m_inputFile.exists()) {
+ if (!createZippedFile())
return false;
}
- Q_ASSERT( !m_inputFile.fileName().isEmpty() );
- if( !m_inputFile.open( mode ) )
+ Q_ASSERT(!m_inputFile.fileName().isEmpty());
+ if (!m_inputFile.open(mode))
return false;
- setOpenMode( mode );
+ setOpenMode(mode);
return true;
}
- setErrorString(tr("Could not create archive from %1: Not a file.").arg( m_path ) );
+ setErrorString(tr("Could not create archive from %1: Not a file.").arg(m_path));
return false;
}
bool Archive::createZippedFile()
{
QTemporaryFile file;
- file.setAutoRemove( false );
- if ( !file.open() )
+ file.setAutoRemove(false);
+ if (!file.open())
return false;
- m_inputFile.setFileName( file.fileName() );
+
+ m_inputFile.setFileName(file.fileName());
file.close();
- m_inputFile.open( QIODevice::ReadWrite );
+ m_inputFile.open(QIODevice::ReadWrite);
try {
- Lib7z::createArchive( &m_inputFile, m_path );
- } catch( Lib7z::SevenZipException &e ) {
+ Lib7z::createArchive(&m_inputFile, m_path);
+ } catch(Lib7z::SevenZipException &e) {
m_inputFile.close();
- setErrorString( e.message() );
+ setErrorString(e.message());
return false;
}
- if( !Lib7z::isSupportedArchive( &m_inputFile ) )
- {
+
+ if (!Lib7z::isSupportedArchive(&m_inputFile)) {
m_inputFile.close();
- setErrorString( tr( "Error while packing directory at %1" ).arg( m_path ) );
+ setErrorString(tr("Error while packing directory at %1").arg(m_path));
return false;
}
m_inputFile.close();
return true;
}
-/**
- * \reimp
+/*!
+ \reimp
*/
qint64 Archive::size() const
{
// if we got a device, we just pass the length of the segment
- if( m_device != 0 )
+ if (m_device != 0)
return m_segment.length();
- const QFileInfo fi( m_path );
+ const QFileInfo fi(m_path);
// if we got a regular file, we pass the size of the file
- if( fi.isFile() )
+ if (fi.isFile())
return fi.size();
- else if( fi.isDir() )
- {
- if( m_inputFile.fileName().isEmpty() || !m_inputFile.exists() )
- {
- if( !const_cast< Archive* >( this )->createZippedFile() )
- throw Error(QObject::tr("Cannot create zipped file for path %1: %2").arg( m_path, errorString() ) );
+
+ if (fi.isDir()) {
+ if (m_inputFile.fileName().isEmpty() || !m_inputFile.exists()) {
+ if (!const_cast< Archive* >(this)->createZippedFile()) {
+ throw Error(QObject::tr("Cannot create zipped file for path %1: %2").arg(m_path,
+ errorString()));
+ }
}
- Q_ASSERT( !m_inputFile.fileName().isEmpty() );
+ Q_ASSERT(!m_inputFile.fileName().isEmpty());
return m_inputFile.size();
}
return 0;
}
-/**
- * \reimp
+/*!
+ \reimp
*/
-qint64 Archive::readData( char* data, qint64 maxSize )
+qint64 Archive::readData(char* data, qint64 maxSize)
{
- if( m_device == 0 )
- return m_inputFile.read( data, maxSize );
+ if (m_device == 0)
+ return m_inputFile.read(data, maxSize);
const qint64 p = m_device->pos();
- m_device->seek( m_segment.start() + pos() );
- const qint64 amountRead = m_device->read( data, qMin< quint64 >( maxSize, m_segment.length() - pos() ) );
- m_device->seek( p );
+ m_device->seek(m_segment.start() + pos());
+ const qint64 amountRead = m_device->read(data, qMin<quint64>(maxSize, m_segment.length() - pos()));
+ m_device->seek(p);
return amountRead;
}
-/**
- * \reimp
+/*!
+ \reimp
*/
-qint64 Archive::writeData( const char* data, qint64 maxSize )
+qint64 Archive::writeData(const char* data, qint64 maxSize)
{
- Q_UNUSED( data );
- Q_UNUSED( maxSize );
+ Q_UNUSED(data);
+ Q_UNUSED(maxSize);
// should never be called, as we're read only
return -1;
}
-QByteArray Component::name() const {
+QByteArray Component::name() const
+{
return m_name;
}
-void Component::setName( const QByteArray& ba ) {
+void Component::setName(const QByteArray &ba)
+{
m_name = ba;
}
-Range<qint64> Component::binarySegment() const {
+Range<qint64> Component::binarySegment() const
+{
return m_binarySegment;
}
-void Component::setBinarySegment( const Range<qint64>& r ) {
+void Component::setBinarySegment(const Range<qint64> &r)
+{
m_binarySegment = r;
}
-Component Component::readFromIndexEntry( QIODevice* in, qint64 offset )
+Component Component::readFromIndexEntry(QIODevice *in, qint64 offset)
{
Component c;
- c.m_name = retrieveByteArray( in );
- c.m_binarySegment = retrieveInt64Range( in ).moved( offset );
+ c.m_name = retrieveByteArray(in);
+ c.m_binarySegment = retrieveInt64Range(in).moved(offset);
- c.readData( in, offset );
+ c.readData(in, offset);
return c;
}
-void Component::writeIndexEntry( QIODevice* out, qint64 positionOffset ) const
+void Component::writeIndexEntry(QIODevice *out, qint64 positionOffset) const
{
- appendByteArray( out, m_name );
- const Range<qint64> relative = m_binarySegment.moved( positionOffset );
- appendInt64( out, binarySegment().start() );
- appendInt64( out, binarySegment().length() );
+ appendByteArray(out, m_name);
+ const Range<qint64> relative = m_binarySegment.moved(positionOffset);
+ appendInt64(out, binarySegment().start());
+ appendInt64(out, binarySegment().length());
}
-void Component::writeData( QIODevice* out, qint64 offset ) const {
+void Component::writeData(QIODevice *out, qint64 offset) const
+{
const qint64 dataBegin = out->pos() + offset;
- appendInt64( out, m_archives.count() );
+ appendInt64(out, m_archives.count());
qint64 start = out->pos() + offset;
+ // Why 16 + 16? This is 24, not 32???
+ const int foo = 3 * sizeof(qint64);
// add 16 + 16 + number of name characters for each archive (the size of the table)
- for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
- start += 3 * sizeof( qint64 ) + (*it)->name().count();
-
- QList< qint64 > starts;
-
- for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
- {
- const Archive* const arch = (*it).data();
- appendByteArray( out, arch->name() );
- starts.push_back( start );
- appendInt64Range( out, Range< qint64 >::fromStartAndLength( start, arch->size() ) );
- start += arch->size();
+ foreach (const QSharedPointer<Archive> &archive, m_archives)
+ start += foo + archive->name().count();
+
+ QList<qint64> starts;
+ foreach (const QSharedPointer<Archive> &archive, m_archives) {
+ appendByteArray(out, archive->name());
+ starts.push_back(start);
+ appendInt64Range(out, Range<qint64>::fromStartAndLength(start, archive->size()));
+ start += archive->size();
}
- for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
- {
- if( !(*it)->open( QIODevice::ReadOnly ) )
- throw Error( tr("Could not open archive %1: %2").arg( QLatin1String( (*it)->name() ), (*it)->errorString() ) );
+ foreach (const QSharedPointer<Archive> &archive, m_archives) {
+ if (!archive->open(QIODevice::ReadOnly)) {
+ throw Error(tr("Could not open archive %1: %2").arg(QLatin1String(archive->name()),
+ archive->errorString()));
+ }
+
const qint64 expectedStart = starts.takeFirst();
const qint64 actualStart = out->pos() + offset;
- Q_UNUSED( expectedStart );
- Q_UNUSED( actualStart );
- Q_ASSERT( expectedStart == actualStart );
- blockingCopy( it->data(), out, (*it)->size() );
+ Q_UNUSED(expectedStart);
+ Q_UNUSED(actualStart);
+ Q_ASSERT(expectedStart == actualStart);
+ blockingCopy(archive.data(), out, archive->size());
}
- m_binarySegment = Range<qint64>::fromStartAndEnd( dataBegin, out->pos() + offset );
+ m_binarySegment = Range<qint64>::fromStartAndEnd(dataBegin, out->pos() + offset);
}
-void Component::readData( QIODevice* in, qint64 offset )
+void Component::readData(QIODevice *in, qint64 offset)
{
const qint64 pos = in->pos();
- in->seek( m_binarySegment.start() );
- const qint64 count = retrieveInt64( in );
-
- QVector< QByteArray > names;
- QVector< Range< qint64 > > ranges;
- for( int i = 0; i < count; ++i )
- {
- names.push_back( retrieveByteArray( in ) );
- ranges.push_back( retrieveInt64Range( in ).moved( offset ) );
+ in->seek(m_binarySegment.start());
+ const qint64 count = retrieveInt64(in);
+
+ QVector<QByteArray> names;
+ QVector<Range<qint64> > ranges;
+ for (int i = 0; i < count; ++i) {
+ names.push_back(retrieveByteArray(in));
+ ranges.push_back(retrieveInt64Range(in).moved(offset));
}
- for( int i = 0; i < ranges.count(); ++i )
- m_archives.push_back( QSharedPointer< Archive >( new Archive( names.at( i ), in, ranges.at( i ) ) ) );
+ for (int i = 0; i < ranges.count(); ++i)
+ m_archives.push_back(QSharedPointer<Archive>(new Archive(names.at(i), in, ranges.at(i))));
- in->seek( pos );
+ in->seek(pos);
}
-QString Component::dataDirectory() const {
+QString Component::dataDirectory() const
+{
return m_dataDirectory;
}
-void Component::setDataDirectory( const QString& path ) {
+void Component::setDataDirectory(const QString &path)
+{
m_dataDirectory = path;
}
-bool Component::operator<( const Component& other ) const {
- if ( m_name != other.name() )
+bool Component::operator<(const Component& other) const
+{
+ if (m_name != other.name())
return m_name < other.m_name;
return m_binarySegment < other.m_binarySegment;
}
-bool Component::operator==( const Component& other ) const {
+bool Component::operator==(const Component& other) const
+{
return m_name == other.m_name && m_binarySegment == other.m_binarySegment;
}
-Component ComponentIndex::componentByName( const QByteArray& id ) const {
- return m_components.value( id );
-}
-
-/**
- * Destroys this component.
+/*!
+ Destroys this component.
*/
Component::~Component()
{
}
-/**
- * Appends \a archive to this component.
- * The componet takes ownership of \a archive.
+/*!
+ Appends \a archive to this component. The component takes ownership of \a archive.
*/
-void Component::appendArchive( const QSharedPointer<Archive>& archive )
+void Component::appendArchive(const QSharedPointer<Archive>& archive)
{
- assert( archive );
- archive->setParent( 0 );
- m_archives.push_back( archive );
+ Q_ASSERT(archive);
+ archive->setParent(0);
+ m_archives.push_back(archive);
}
-/**
- * Returns the archives associated with this component.
+/*!
+ Returns the archives associated with this component.
*/
-QVector< QSharedPointer<Archive> > Component::archives() const
+QVector<QSharedPointer<Archive> > Component::archives() const
{
return m_archives;
}
-QSharedPointer<Archive> Component::archiveByName( const QByteArray& name ) const
+QSharedPointer<Archive> Component::archiveByName(const QByteArray &name) const
{
- Q_FOREACH( const QSharedPointer<Archive>& i, m_archives )
- if( i->name() == name )
+ foreach (const QSharedPointer<Archive>& i, m_archives) {
+ if (i->name() == name)
return i;
+ }
return QSharedPointer<Archive>();
}
-void ComponentIndex::insertComponent( const Component& c )
+
+// -- ComponentIndex
+
+ComponentIndex::ComponentIndex()
{
- m_components.insert( c.name(), c );
}
-int ComponentIndex::componentCount() const
+ComponentIndex ComponentIndex::read(QIODevice *dev, qint64 offset)
{
- return m_components.size();
+ ComponentIndex result;
+ const qint64 size = retrieveInt64(dev);
+ for (int i = 0; i < size; ++i)
+ result.insertComponent(Component::readFromIndexEntry(dev, offset));
+ retrieveInt64(dev);
+ return result;
}
-void ComponentIndex::removeComponent( const QByteArray& name ) {
- m_components.remove( name );
+void ComponentIndex::writeIndex(QIODevice *out, qint64 offset) const
+{
+ // Q: why do we write the size twice?
+ // A: for us to be able to read it beginning from the end of the file as well
+ appendInt64(out, componentCount());
+ foreach (const Component& i, components())
+ i.writeIndexEntry(out, offset);
+ appendInt64(out, componentCount());
}
-QVector<Component> ComponentIndex::components() const {
- return m_components.values().toVector();
+void ComponentIndex::writeComponentData(QIODevice *out, qint64 offset) const
+{
+ appendInt64(out, componentCount());
+
+ foreach (const Component &component, m_components)
+ component.writeData(out, offset);
}
-void ComponentIndex::writeComponentData( QIODevice* out, qint64 offset ) const {
- appendInt64( out, componentCount() );
-
- for( QHash< QByteArray, Component >::const_iterator it = m_components.begin(); it != m_components.end(); ++it )
- it->writeData( out, offset );
+Component ComponentIndex::componentByName(const QByteArray &id) const
+{
+ return m_components.value(id);
}
-
-KD7zEngineHandler* ComponentIndex::zipHandler = 0;
-ComponentIndex::ComponentIndex()
+void ComponentIndex::insertComponent(const Component& c)
{
- if( zipHandler == 0 ) {
- // TODO: this one get leaked
- zipHandler = new KD7zEngineHandler;
- }
+ m_components.insert(c.name(), c);
}
-ComponentIndex ComponentIndex::read( QIODevice* dev, qint64 offset )
+void ComponentIndex::removeComponent(const QByteArray &name)
{
- ComponentIndex result;
- const qint64 size = retrieveInt64( dev );
- for( int i = 0; i < size; ++i )
- result.insertComponent( Component::readFromIndexEntry( dev, offset ) );
- retrieveInt64( dev );
- return result;
+ m_components.remove(name);
}
-void ComponentIndex::writeIndex( QIODevice* out, qint64 offset ) const
+QVector<Component> ComponentIndex::components() const
{
- // Q: why do we write the size twice?
- // A: for us to be able to read it beginning from the end of the file as well
- appendInt64( out, componentCount() );
- Q_FOREACH( const Component& i, components() )
- i.writeIndexEntry( out, offset );
- appendInt64( out, componentCount() );
+ return m_components.values().toVector();
+}
+
+int ComponentIndex::componentCount() const
+{
+ return m_components.size();
}
+
+static QVector<QByteArray> sResourceVec;
/*!
- \internal
- Registers the resource found at \a segment within \a file into the Qt resource system.
+ \internal
+ Registers the resource found at \a segment within \a file into the Qt resource system.
*/
-static const uchar* addResourceFromBinary( QFile* file, const Range< qint64 >& segment )
+static const uchar* addResourceFromBinary(QFile* file, const Range<qint64> &segment, bool compressed)
{
- if ( segment.length() <= 0 )
+ if (segment.length() <= 0)
return 0;
- const uchar* const mapped = file->map( segment.start(), segment.length() );
- if ( !mapped )
- throw Error( QObject::tr("Could not mmap in-binary resource. (offset=%1, length=%2").arg( QString::number( segment.start() ), QString::number( segment.length() ) ) );
-
- if ( !QResource::registerResource( mapped, QLatin1String(":/metadata") ) )
- throw Error( QObject::tr("Could not register in-binary resource.") );
+ if (!file->seek(segment.start())) {
+ throw Error(QObject::tr("Could not seek to in-binary resource. (offset: %1, length: %2")
+ .arg(QString::number(segment.start()), QString::number(segment.length())));
+ }
+ sResourceVec.append(compressed ? retrieveCompressedData(file, segment.length()) : retrieveData(file,
+ segment.length()));
- return mapped;
+ if (!QResource::registerResource((const uchar*)(sResourceVec.last().constData()),
+ QLatin1String(":/metadata"))) {
+ throw Error(QObject::tr("Could not register in-binary resource."));
+ }
+ return (const uchar*)(sResourceVec.last().constData());
}
-BinaryContent::BinaryContent( const QString& path )
- : file( new QFile( path ) ),
- handler( components ),
- magicmaker( 0 ),
- dataBlockStart( 0 )
+BinaryContent::BinaryContent(const QString &path)
+ : file(new QFile(path))
+ , m_binaryFile(0)
+ , handler(components)
+ , m_magicmarker(0)
+ , dataBlockStart(0)
{
}
BinaryContent::~BinaryContent()
{
- for( QVector< const uchar* >::const_iterator it = mappings.begin(); it != mappings.end(); ++it )
- QResource::unregisterResource( *it );
+ foreach (const uchar *rccData, mappings)
+ QResource::unregisterResource(rccData);
}
/*!
- \internal
- Registers the Qt resources embedded in this binary.
- */
-int BinaryContent::registerEmbeddedQResources()
-{
- if( !file->isOpen() )
- if( !file->open( QIODevice::ReadOnly ))
- throw Error( QObject::tr("Could not open binary %1: %2").arg( file->fileName(), file->errorString() ) );
- Q_FOREACH( const Range<qint64>& i, metadataResourceSegments )
- mappings.push_back( addResourceFromBinary( file.data(), i ) );
- //file->close();
- return mappings.count();
-}
-
-/*!
- \internal
- \fn static BinaryContent BinaryContent::readFromApplicationFile()
- Reads BinaryContent stored in the current application binary.
- */
+ Reads BinaryContent stored in the current application binary.
+*/
BinaryContent BinaryContent::readFromApplicationFile()
{
- return BinaryContent::readFromBinary( QCoreApplication::applicationFilePath() );
+ return BinaryContent::readFromBinary(QCoreApplication::applicationFilePath());
}
/*!
* \class QInstaller::BinaryContent
- *
+ *
* BinaryContent handles binary information embedded into executables.
* Qt resources as well as component information can be stored.
*
- * Explanation of the binary blob at the end of the file:
+ * Explanation of the binary blob at the end of the installer or separate data file:
*
* \verbatim
* Meta data segment 0
@@ -818,14 +818,18 @@ BinaryContent BinaryContent::readFromApplicationFile()
* quint64 offset of component index segment
* quint64 length of component index segment
* ------------------------------------------------------
- * quint64 offset of meta data segment 0
- * quint64 length of meta data segment 0
- * quint64 offset of meta data segment ..
- * quint64 length of meta data segment ..
- * quint64 offset of meta data segment n
- * quint64 length of meta data segment n
+ * qint64 offset of meta data segment 0
+ * qint64 length of meta data segment 0
+ * qint64 offset of meta data segment ..
+ * qint64 length of meta data segment ..
+ * qint64 offset of meta data segment n
+ * qint64 length of meta data segment n
* ------------------------------------------------------
- * quint64 number of meta data segments
+ * operations start offest
+ * operations end
+ * quint64 embedded resource count
+ * quint64 data block size
+ * quint64 Magic marker
* quint64 Magic cookie (0xc2 0x63 0x0a 0x1c 0x99 0xd6 0x68 0xf8)
* <eof>
*
@@ -864,89 +868,181 @@ BinaryContent BinaryContent::readFromApplicationFile()
* \endverbatim
*/
-BinaryContent BinaryContent::readFromBinary( const QString& path ) {
- BinaryContent c( path );
-
- QFile* const file = c.file.data();
-
- if ( !file->open( QIODevice::ReadOnly ) )
- throw Error( QObject::tr("Could not open binary %1: %2").arg( path, file->errorString()) );
-
- const qint64 cookiepos = findMagicCookie( file );
- Q_ASSERT( cookiepos >= 0 );
- const qint64 endOfData = cookiepos + sizeof( qint64 );
- const qint64 indexSize = 6 * sizeof( qint64 );
- if ( !file->seek( endOfData - indexSize ) )
- throw Error( QObject::tr("Could not seek to binary layout section") );
-
- qint64 operationsStart = retrieveInt64( file );
- /*qint64 operationsEnd = */ retrieveInt64( file ); // don't care
- const qint64 count = retrieveInt64( file );
- const qint64 dataBlockSize = retrieveInt64( file );
- const qint64 dataBlockStart = endOfData - dataBlockSize;
-
- operationsStart += dataBlockStart;
- //operationsEnd += dataBlockStart;
- c.magicmaker = retrieveInt64( file );
-
- const quint64 magicCookie = retrieveInt64( file );
- Q_UNUSED( magicCookie );
- Q_ASSERT( magicCookie == MagicCookie );
-
- const qint64 resourceSectionSize = 2 * sizeof( qint64 ) * count;
- for( int i = 0; i < count; ++i )
- {
- if ( !file->seek(endOfData - indexSize - 2 * sizeof( qint64 ) * ( i + 1 ) ) )
- throw Error( QObject::tr("Could not seek to metadata index") );
- const qint64 metadataResourceOffset = retrieveInt64( file ) + dataBlockStart;
- const qint64 metadataResourceLength = retrieveInt64( file );
- c.metadataResourceSegments.push_back( Range< qint64 >::fromStartAndLength( metadataResourceOffset, metadataResourceLength ) );
+BinaryContent BinaryContent::readFromBinary(const QString &path)
+{
+ BinaryContent c(path);
+
+ QFile *file = c.file.data();
+ if (!file->open(QIODevice::ReadOnly))
+ throw Error(QObject::tr("Could not open binary %1: %2").arg(path, file->errorString()));
+
+ // check for supported binary, will throw if we can't find a marker
+ const BinaryLayout layout = readBinaryLayout(file, findMagicCookie(file, QInstaller::MagicCookie));
+
+ bool retry = true;
+ if (layout.magicMarker != MagicInstallerMarker) {
+ QString binaryDataPath = path;
+ QFileInfo fi(path + QLatin1String("/../../.."));
+ if (QFileInfo(fi.absoluteFilePath()).isBundle())
+ binaryDataPath = fi.absoluteFilePath();
+ fi.setFile(binaryDataPath);
+
+ c.m_binaryFile = QSharedPointer<QFile>(new QFile(fi.absolutePath() + QLatin1Char('/') + fi.baseName()
+ + QLatin1String(".dat")));
+ if (c.m_binaryFile->exists() && c.m_binaryFile->open(QIODevice::ReadOnly)) {
+ // check for supported binary data file, will throw if we can't find a marker
+ try {
+ const qint64 cookiePos = findMagicCookie(c.m_binaryFile.data(), QInstaller::MagicCookieDat);
+ readBinaryData(c, c.m_binaryFile.data(), readBinaryLayout(c.m_binaryFile.data(), cookiePos),
+ true);
+ retry = false;
+ } catch (const Error &error) {
+ // this seems to be an unsupported dat file, try to read from original binary
+ c.m_binaryFile.clear();
+ verbose() << error.message();
+ }
+ } else {
+ c.m_binaryFile.clear();
+ }
+ }
+
+ if (retry)
+ readBinaryData(c, file, layout, false);
+
+ return c;
+}
+
+/* static */
+BinaryLayout BinaryContent::readBinaryLayout(QIODevice *file, qint64 cookiePos)
+{
+ const qint64 indexSize = 5 * sizeof(qint64);
+ if (!file->seek(cookiePos - indexSize))
+ throw Error(QObject::tr("Could not seek to binary layout section!"));
+
+ BinaryLayout layout;
+ layout.operationsStart = retrieveInt64(file);
+ layout.operationsEnd = retrieveInt64(file);
+ layout.resourceCount = retrieveInt64(file);
+ layout.dataBlockSize = retrieveInt64(file);
+ layout.magicMarker = retrieveInt64(file);
+ layout.magicCookie = retrieveInt64(file);
+ layout.indexSize = indexSize + sizeof(qint64);
+ layout.endOfData = file->pos();
+
+ verbose() << "Operations start: "<< layout.operationsStart << "; " << "Operations end: "
+ << layout.operationsEnd << "; " << "Resource count: " << layout.resourceCount << "; "
+ << "Data block size: " << layout.dataBlockSize << "; " << "Magic marker: "
+ << layout.magicMarker << "; " << "Magic cookie: " << layout.magicCookie << "; "
+ << "Index size: " << layout.indexSize << "; " << "End of data: " << layout.endOfData << std::endl;
+
+ const qint64 resourceOffsetAndLengtSize = 2 * sizeof(qint64);
+ const qint64 dataBlockStart = layout.endOfData - layout.dataBlockSize;
+ for (int i = 0; i < layout.resourceCount; ++i) {
+ if (!file->seek(layout.endOfData - layout.indexSize - resourceOffsetAndLengtSize * (i + 1)))
+ throw Error(QObject::tr("Could not seek to metadata index"));
+
+ const qint64 metadataResourceOffset = retrieveInt64(file);
+ const qint64 metadataResourceLength = retrieveInt64(file);
+ layout.metadataResourceSegments.append(Range<qint64>::fromStartAndLength(metadataResourceOffset
+ + dataBlockStart, metadataResourceLength));
}
- if ( !file->seek( operationsStart ) )
- throw Error( QObject::tr("Could not seek to operation list") );
- QStack<KDUpdater::UpdateOperation*> performedOperations;
+ return layout;
+}
+
+/* static */
+void BinaryContent::readBinaryData(BinaryContent &c, QIODevice *const file, const BinaryLayout &layout,
+ bool compressed)
+{
+ c.m_magicmarker = layout.magicMarker;
+ c.metadataResourceSegments = layout.metadataResourceSegments;
+
+ const qint64 dataBlockStart = layout.endOfData - layout.dataBlockSize;
+ const qint64 operationsStart = layout.operationsStart + dataBlockStart;
+ if (!file->seek(operationsStart))
+ throw Error(QObject::tr("Could not seek to operation list"));
+
const qint64 operationsCount = retrieveInt64(file);
- verbose() << "operationsCount=" << operationsCount << std::endl;
-
- for(int i = operationsCount; --i >= 0; )
- {
- const QString name = retrieveString( file );
- const QString xml = retrieveString( file );
- KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( name );
- QString debugXmlString(xml);
- debugXmlString.truncate(1000);
- verbose() << "Operation name=" << name << " xml=\n" << debugXmlString << std::endl;
- Q_ASSERT_X(op, "BinaryContent::readFromBinary", QString::fromLatin1("Invalid operation name='%1'").arg(name).toLatin1());
- if( ! op->fromXml( xml ))
- qWarning() << "Failed to load XML for operation=" << name;
- performedOperations.push(op);
+ verbose() << "Number of operations: " << operationsCount << std::endl;
+
+ for (int i = 0; i < operationsCount; ++i) {
+ const QString name = retrieveString(file);
+ KDUpdater::UpdateOperation *op = KDUpdater::UpdateOperationFactory::instance().create(name);
+ Q_ASSERT_X(op, __FUNCTION__, QString::fromLatin1("Invalid operation name: %1").arg(name)
+ .toLatin1());
+
+ const QString xml = (compressed ? QString::fromUtf8(qUncompress(retrieveByteArray(file)))
+ : retrieveString(file));
+ if (!op->fromXml(xml))
+ qWarning() << "Failed to load XML for operation:" << name;
+ verbose() << "Operation name: " << name << "\nOperation xml:\n" << xml.leftRef(1000) << std::endl;
+ c.m_performedOperations.push(op);
}
- c.performedOperations = performedOperations;
// seek to the position of the component index
- if ( !file->seek( endOfData - indexSize - resourceSectionSize - 2 * sizeof( qint64 ) ) )
- throw Error( QObject::tr("Could not seek to component index information") );
-
- const qint64 compIndexStart = retrieveInt64( file ) + dataBlockStart;
- if ( !file->seek( compIndexStart ) )
- throw Error( QObject::tr("Could not seek to component index") );
-
-
- c.components = QInstallerCreator::ComponentIndex::read( file, dataBlockStart );
- c.handler.setComponentIndex( c.components );
-
- const QVector< QInstallerCreator::Component > comps = c.components.components();
- verbose() << "components loaded:" << comps.count() << std::endl;
- for( QVector< QInstallerCreator::Component >::const_iterator it = comps.begin(); it != comps.end(); ++it )
- {
- verbose() << "loaded " << it->name();
- const QVector<QSharedPointer<Archive> > archives = it->archives();
- verbose() << " having " << archives.count() << " archives:" << std::endl;
- Q_FOREACH( const QSharedPointer<Archive>& arch, archives )
- {
- verbose() << " " << arch->name() << " (" << arch->size() << " bytes)" << std::endl;
+ const qint64 resourceOffsetAndLengtSize = 2 * sizeof(qint64);
+ const qint64 resourceSectionSize = resourceOffsetAndLengtSize * layout.resourceCount;
+ if (!file->seek(layout.endOfData - layout.indexSize - resourceSectionSize - resourceOffsetAndLengtSize))
+ throw Error(QObject::tr("Could not seek to component index information"));
+
+ const qint64 compIndexStart = retrieveInt64(file) + dataBlockStart;
+ if (!file->seek(compIndexStart))
+ throw Error(QObject::tr("Could not seek to component index"));
+
+ c.components = QInstallerCreator::ComponentIndex::read(file, dataBlockStart);
+ c.handler.setComponentIndex(c.components);
+
+ if (isVerbose()) {
+ const QVector<QInstallerCreator::Component> components = c.components.components();
+ verbose() << "Number of components loaded: " << components.count() << std::endl;
+ foreach (const QInstallerCreator::Component &component, components) {
+ const QVector<QSharedPointer<Archive> > archives = component.archives();
+ verbose() << "Loaded component " << component.name() << " containing " << archives.count()
+ << " archives:" << std::endl;
+ foreach (const QSharedPointer<Archive> &archive, archives) {
+ verbose() << " Archive name: " << archive->name() << ", Archive size: "
+ << archive->size() << " bytes" << std::endl;
+ }
}
}
- return c;
+}
+
+
+/*!
+ Returns the magic marker found in the binary. Returns 0 if no marker has been found.
+*/
+qint64 BinaryContent::magicmaker() const
+{
+ return m_magicmarker;
+}
+
+/*!
+ Registers the Qt resources embedded in this binary.
+ */
+int BinaryContent::registerEmbeddedQResources()
+{
+ const bool hasBinaryDataFile = !m_binaryFile.isNull();
+ QFile *const data = hasBinaryDataFile ? m_binaryFile.data() : file.data();
+ if (!data->isOpen() && !data->open(QIODevice::ReadOnly)) {
+ throw Error(QObject::tr("Could not open binary %1: %2").arg(data->fileName(),
+ data->errorString()));
+ }
+
+ foreach (const Range<qint64> &i, metadataResourceSegments)
+ mappings.append(addResourceFromBinary(data, i, hasBinaryDataFile));
+
+ file.clear();
+ if (hasBinaryDataFile)
+ m_binaryFile.clear();
+
+ return mappings.count();
+}
+
+/*!
+ Returns the operations performed during installation. Returns an empty list if no operations are
+ performed or the binary is the installer application.
+*/
+QStack<KDUpdater::UpdateOperation*> BinaryContent::performedOperations() const
+{
+ return m_performedOperations;
}
diff --git a/installerbuilder/common/binaryformat.h b/installerbuilder/common/binaryformat.h
index 493a0329d..1e9245ccf 100644
--- a/installerbuilder/common/binaryformat.h
+++ b/installerbuilder/common/binaryformat.h
@@ -26,183 +26,196 @@
#ifndef BINARYFORMAT_H
#define BINARYFORMAT_H
-#include "range.h"
-
-#include <QByteArray>
-#include <QCoreApplication>
-#include <QFile>
-#include <QHash>
-#include <QIODevice>
-#include <QStack>
-#include <QString>
-#include <QSharedPointer>
-
#include "binaryformatenginehandler.h"
#include "installer_global.h"
+#include "range.h"
-class QFile;
-class KD7zEngineHandler;
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFile>
+#include <QtCore/QHash>
+#include <QtCore/QStack>
+#include <QtCore/QVector>
+#include <QtCore/QSharedPointer>
-namespace KDUpdater
-{
+namespace KDUpdater {
class UpdateOperation;
}
-namespace QInstaller
-{
- qint64 INSTALLER_EXPORT findMagicCookie( QFile* file );
+namespace QInstaller {
+ static const qint64 MagicInstallerMarker = 0x12023233UL;
+ static const qint64 MagicUninstallerMarker = 0x12023234UL;
+
+ static const qint64 MagicUpdaterMarker = 0x12023235UL;
+ static const qint64 MagicPackageManagerMarker = 0x12023236UL;
+
+ // this cookie is put at the end of the file to determine whether we have data
+ static const quint64 MagicCookie = 0xc2630a1c99d668f8LL;
+ static const quint64 MagicCookieDat = 0xc2630a1c99d668f9LL;
+ qint64 INSTALLER_EXPORT findMagicCookie(QFile *file, quint64 magicCookie = MagicCookie);
void INSTALLER_EXPORT appendFileData(QIODevice *out, QIODevice *in);
- void INSTALLER_EXPORT appendInt64( QIODevice* out, qint64 n );
- void INSTALLER_EXPORT appendInt64Range( QIODevice* out, const Range<qint64>& r );
+ void INSTALLER_EXPORT appendInt64(QIODevice *out, qint64 n);
+ void INSTALLER_EXPORT appendInt64Range(QIODevice *out, const Range<qint64> &r);
void INSTALLER_EXPORT appendData(QIODevice *out, QIODevice *in, qint64 size);
void INSTALLER_EXPORT appendByteArray(QIODevice *out, const QByteArray &ba);
void INSTALLER_EXPORT appendString(QIODevice *out, const QString &str);
void INSTALLER_EXPORT appendStringList(QIODevice *out, const QStringList &list);
- void INSTALLER_EXPORT appendDictionary(QIODevice *out, const QHash<QString,QString>& dict);
+ void INSTALLER_EXPORT appendDictionary(QIODevice *out, const QHash<QString,QString> &dict);
+ qint64 INSTALLER_EXPORT appendCompressedData(QIODevice *out, QIODevice *in, qint64 size);
void INSTALLER_EXPORT retrieveFileData(QIODevice *out, QIODevice *in);
- qint64 INSTALLER_EXPORT retrieveInt64( QIODevice* in );
- Range<qint64> INSTALLER_EXPORT retrieveInt64Range( QIODevice* in );
+ qint64 INSTALLER_EXPORT retrieveInt64(QIODevice *in);
+ Range<qint64> INSTALLER_EXPORT retrieveInt64Range(QIODevice *in);
QByteArray INSTALLER_EXPORT retrieveByteArray(QIODevice *in);
QString INSTALLER_EXPORT retrieveString(QIODevice *in);
QStringList INSTALLER_EXPORT retrieveStringList(QIODevice *in);
QHash<QString,QString> INSTALLER_EXPORT retrieveDictionary(QIODevice *in);
+ QByteArray INSTALLER_EXPORT retrieveData(QIODevice *in, qint64 size);
+ QByteArray INSTALLER_EXPORT retrieveCompressedData(QIODevice *in, qint64 size);
+}
- //static qint64 magicInstallerMarker = (0xdea0d345UL << 32) + 0x12023233UL;
- //static qint64 magicUninstallerMarker = (0xdea0d345UL << 32) + 0x12023234UL;
- static const qint64 MagicInstallerMarker = 0x12023233UL;
- static const qint64 MagicUninstallerMarker = 0x12023234UL;
+namespace QInstallerCreator {
+class Component;
- // this cookie is put at the end of the file to determine wheter we have data
- static const quint64 MagicCookie = 0xc2630a1c99d668f8LL;
+class INSTALLER_EXPORT Archive : public QIODevice
+{
+ Q_OBJECT
+public:
+ explicit Archive(const QString &path);
+ Archive(const QByteArray &name, const QByteArray &data);
+ Archive(const QByteArray &name, QIODevice *device, const Range<qint64> &segment);
+ ~Archive();
-}
+ bool open(OpenMode mode);
+ void close();
+
+ bool seek(qint64 pos);
+ qint64 size() const;
+
+ bool createZippedFile();
+ bool isZippedDirectory() const;
+ bool copy(const QString &name);
+
+ QByteArray name() const;
+ void setName(const QByteArray &name);
-namespace QInstallerCreator
+protected:
+ qint64 readData(char *data, qint64 maxSize);
+ qint64 writeData(const char *data, qint64 maxSize);
+
+ Range< qint64 > binarySegment() const;
+
+private:
+ //used when when reading from the installer
+ QIODevice *const m_device;
+ const Range<qint64> m_segment;
+
+ //used when creating the installer, archive input file
+ QFile m_inputFile;
+ const bool m_isTempFile;
+ const QString m_path;
+ QByteArray m_name;
+};
+
+class INSTALLER_EXPORT Component
+{
+ Q_DECLARE_TR_FUNCTIONS(Component);
+public:
+ virtual ~Component();
+
+ static Component readFromIndexEntry(QIODevice *dev, qint64 offset);
+ void writeIndexEntry(QIODevice *dev, qint64 offset) const;
+
+ void writeData(QIODevice *dev, qint64 positionOffset) const;
+ void readData(QIODevice *dev, qint64 offset);
+
+ QByteArray name() const;
+ void setName(const QByteArray &ba);
+
+ QString dataDirectory() const;
+ void setDataDirectory(const QString &path);
+
+ Range<qint64> binarySegment() const;
+ void setBinarySegment(const Range<qint64> &r);
+
+ void appendArchive(const QSharedPointer<Archive> &archive);
+ QSharedPointer<Archive> archiveByName(const QByteArray &name) const;
+ QVector< QSharedPointer<Archive> > archives() const;
+
+ bool operator<(const Component &other) const;
+ bool operator==(const Component &other) const;
+
+private:
+ QByteArray m_name;
+ QVector<QSharedPointer<Archive> > m_archives;
+ mutable Range<qint64> m_binarySegment;
+ QString m_dataDirectory;
+};
+
+
+class INSTALLER_EXPORT ComponentIndex
{
- class Component;
-
- class INSTALLER_EXPORT Archive : public QIODevice
- {
- Q_OBJECT
- public:
- explicit Archive( const QString& path );
- Archive( const QByteArray& name, const QByteArray& data );
- Archive( const QByteArray& name, QIODevice* device, const Range< qint64 >& segment );
- ~Archive();
-
- bool open( OpenMode mode );
- void close();
-
- bool seek( qint64 pos );
- qint64 size() const;
-
- bool createZippedFile();
- bool isZippedDirectory() const;
- bool copy( const QString& name );
-
- QByteArray name() const;
- void setName( const QByteArray& name );
-
- protected:
- qint64 readData( char* data, qint64 maxSize );
- qint64 writeData( const char* data, qint64 maxSize );
-
- Range< qint64 > binarySegment() const;
-
- private:
- //used when when reading from the installer
- QIODevice* const m_device;
- const Range<qint64> m_segment;
-
- //used when creating the installer, archive input file
- QFile m_inputFile;
- const bool m_isTempFile;
- const QString m_path;
- QByteArray m_name;
- };
-
- class INSTALLER_EXPORT Component
- {
- Q_DECLARE_TR_FUNCTIONS(Component);
- public:
- virtual ~Component();
-
- static Component readFromIndexEntry( QIODevice* dev, qint64 offset );
- void writeIndexEntry( QIODevice* dev, qint64 offset ) const;
-
- void writeData( QIODevice* dev, qint64 positionOffset ) const;
- void readData( QIODevice* dev, qint64 offset );
-
- QByteArray name() const;
- void setName( const QByteArray& ba );
-
- QString dataDirectory() const;
- void setDataDirectory( const QString& path );
-
- Range<qint64> binarySegment() const;
- void setBinarySegment( const Range<qint64>& r );
-
- void appendArchive( const QSharedPointer<Archive>& archive );
- QSharedPointer<Archive> archiveByName( const QByteArray& name ) const;
- QVector< QSharedPointer<Archive> > archives() const;
-
- bool operator<( const Component& other ) const;
- bool operator==( const Component& other ) const;
-
- private:
- QByteArray m_name;
- QVector< QSharedPointer< Archive > > m_archives;
- mutable Range<qint64> m_binarySegment;
- QString m_dataDirectory;
- };
-
-
- class INSTALLER_EXPORT ComponentIndex
- {
- public:
- ComponentIndex();
- static ComponentIndex read( QIODevice* dev, qint64 offset );
- void writeIndex( QIODevice* dev, qint64 offset ) const;
- void writeComponentData( QIODevice* dev, qint64 offset ) const;
- Component componentByName( const QByteArray& ) const;
- void insertComponent( const Component& );
- void removeComponent( const QByteArray& name );
- QVector<Component> components() const;
- int componentCount() const;
-
- protected:
- static KD7zEngineHandler* zipHandler;
-
- private:
- QHash<QByteArray,Component> m_components;
- };
+public:
+ ComponentIndex();
+ static ComponentIndex read(QIODevice *dev, qint64 offset);
+ void writeIndex(QIODevice *dev, qint64 offset) const;
+ void writeComponentData(QIODevice *dev, qint64 offset) const;
+ Component componentByName(const QByteArray &name) const;
+ void insertComponent(const Component &name);
+ void removeComponent(const QByteArray &name);
+ QVector<Component> components() const;
+ int componentCount() const;
+
+private:
+ QHash<QByteArray, Component> m_components;
+};
}
-namespace QInstaller
+namespace QInstaller {
+
+struct BinaryLayout {
+ QVector<Range<qint64> >metadataResourceSegments;
+ qint64 operationsStart;
+ qint64 operationsEnd;
+ qint64 resourceCount;
+ qint64 dataBlockSize;
+ qint64 magicMarker;
+ quint64 magicCookie;
+ qint64 indexSize;
+ qint64 endOfData;
+};
+
+class INSTALLER_EXPORT BinaryContent
{
- class INSTALLER_EXPORT BinaryContent
- {
- explicit BinaryContent( const QString& path );
-
- public:
- virtual ~BinaryContent();
-
- static BinaryContent readFromApplicationFile();
- static BinaryContent readFromBinary( const QString& path );
-
- int registerEmbeddedQResources();
-
- QSharedPointer<QFile> file;
- QInstallerCreator::ComponentIndex components;
- QInstallerCreator::BinaryFormatEngineHandler handler;
- QVector< Range< qint64 > > metadataResourceSegments;
- QVector< const uchar* > mappings;
- qint64 magicmaker;
- qint64 dataBlockStart;
- QStack<KDUpdater::UpdateOperation*> performedOperations;
- };
+ explicit BinaryContent(const QString &path);
+
+public:
+ virtual ~BinaryContent();
+
+ static BinaryContent readFromApplicationFile();
+ static BinaryContent readFromBinary(const QString &path);
+ static BinaryLayout readBinaryLayout(QIODevice *file, qint64 cookiePos);
+
+ qint64 magicmaker() const;
+ int registerEmbeddedQResources();
+ QStack<KDUpdater::UpdateOperation*> performedOperations() const;
+
+private:
+ static void readBinaryData(BinaryContent &c, QIODevice *const file, const BinaryLayout &layout,
+ bool compressed);
+
+private:
+ QSharedPointer<QFile> file;
+ QSharedPointer<QFile> m_binaryFile;
+ QInstallerCreator::ComponentIndex components;
+ QInstallerCreator::BinaryFormatEngineHandler handler;
+ QVector<Range<qint64> > metadataResourceSegments;
+ QVector<const uchar*> mappings;
+ qint64 m_magicmarker;
+ qint64 dataBlockStart;
+ QStack<KDUpdater::UpdateOperation*> m_performedOperations;
+};
+
}
#endif // BINARYFORMAT_H
diff --git a/installerbuilder/common/blockingbuffer.cpp b/installerbuilder/common/blockingbuffer.cpp
deleted file mode 100644
index 8879c9c8c..000000000
--- a/installerbuilder/common/blockingbuffer.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "blockingbuffer.h"
-
-#include <QByteArray>
-#include <QMutex>
-#include <QMutexLocker>
-#include <QWaitCondition>
-
-#include <cassert>
-
-using namespace QInstaller;
-
-class BlockingBuffer::Private {
-public:
- explicit Private( int siz ) : size( siz ), readPos( 0 ), writePos( 0 ), closed( false ), mutex( QMutex::Recursive ) {
- data.resize( size );
- }
-
- int bytesFree() const {
- return size - bytesUsed();
- }
-
- int bytesUsed() const {
- return writePos >= readPos ? ( writePos - readPos ) : ( size - readPos + writePos );
- }
-
- const int size;
- QByteArray data;
- int readPos;
- int writePos;
- bool closed;
- QMutex mutex;
- QWaitCondition canWrite;
- QWaitCondition canRead;
-};
-
-BlockingBuffer::BlockingBuffer( int size ) : d( new Private( size ) ) {
-}
-
-BlockingBuffer::~BlockingBuffer() {
- delete d;
-}
-
-qint64 BlockingBuffer::read( char* buf, qint64 max ) {
- assert( max >= 0 );
- if ( max == 0 )
- return 0;
- const QMutexLocker lock( &d->mutex );
- while ( d->bytesUsed() == 0 && !d->closed )
- d->canRead.wait( &d->mutex );
- const int actual = qMin<int>( max, d->bytesUsed() );
- if ( actual == 0 ) // closed
- return 0;
-
- const int untilEnd = qMin( d->size - 1 - d->readPos, actual );
- memcpy( buf, d->data.constData() + d->readPos, untilEnd );
- d->readPos = ( d->readPos + untilEnd ) % d->size;
- const int left = actual - untilEnd;
- if ( left > 0 ) {
- memcpy( buf + untilEnd, d->data.constData(), left );
- d->readPos = left;
- }
-
- d->canWrite.wakeAll();
- return actual;
-}
-
-qint64 BlockingBuffer::write( const char* buf, qint64 max ) {
- assert( max >= 0 );
- if ( max == 0 )
- return 0;
- const QMutexLocker lock( &d->mutex );
- while ( d->bytesFree() == 0 && !d->closed )
- d->canWrite.wait( &d->mutex );
- if ( d->closed ) // closed, writing fails
- return -1;
- const int actual = qMin<int>( max, d->bytesFree() );
- assert( actual > 0 );
- const int untilEnd = qMin( d->size - 1 - d->readPos, actual );
- memcpy( d->data.data() + d->writePos, buf, untilEnd );
- d->writePos = ( d->writePos + untilEnd ) % d->size;
- const int left = actual - untilEnd;
- if ( left > 0 ) {
- memcpy( d->data.data(), buf + untilEnd, left );
- d->writePos = left;
- }
-
- d->canRead.wakeAll();
- return actual;
-}
-
-void BlockingBuffer::close() {
- const QMutexLocker lock( &d->mutex );
- d->closed = true;
-}
diff --git a/installerbuilder/common/fileutils.cpp b/installerbuilder/common/fileutils.cpp
index 04fa9ae94..0dd2f7772 100644
--- a/installerbuilder/common/fileutils.cpp
+++ b/installerbuilder/common/fileutils.cpp
@@ -31,111 +31,123 @@
**
**************************************************************************/
#include "fileutils.h"
+
#include <common/errors.h>
#include <common/utils.h>
-#include <QDateTime>
-#include <QDir>
-#include <QDirIterator>
-#include <QEventLoop>
-#include <QFileInfo>
-#include <QString>
-#include <QTemporaryFile>
-#include <QThread>
-#include <QUrl>
+#include <QtCore/QDateTime>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QEventLoop>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QThread>
-#include <cassert>
-#include <cerrno>
+#include <errno.h>
using namespace QInstaller;
-TempDirDeleter::TempDirDeleter( const QString& path )
- : m_paths( QStringList() << path )
+
+// -- TempDirDeleter
+
+TempDirDeleter::TempDirDeleter(const QString &path)
{
+ m_paths.insert(path);
}
-TempDirDeleter::TempDirDeleter( const QStringList& paths_ )
- : m_paths( paths_ )
+TempDirDeleter::TempDirDeleter(const QStringList &paths)
+ : m_paths(paths.toSet())
{
}
TempDirDeleter::~TempDirDeleter()
{
- for( QStringList::const_iterator it = m_paths.constBegin(); it != m_paths.constEnd(); ++it )
- {
- const QString& path = *it;
- if( !path.isEmpty() )
+ foreach (const QString &path, m_paths) {
+ if (!path.isEmpty()) {
try {
- removeDirectory( path );
- } catch ( const Error& e ) {
+ removeDirectory(path);
+ } catch (const Error &e) {
qCritical() << Q_FUNC_INFO << "Exception caught:" << e.message();
- } catch ( ... ) {
+ } catch (...) {
qCritical() << Q_FUNC_INFO << "Unknown exception caught.";
}
+ }
}
}
-void TempDirDeleter::passAndReleaseAll( TempDirDeleter& tdd ) {
- tdd.m_paths = m_paths;
- releaseAll();
+QStringList TempDirDeleter::paths() const
+{
+ return m_paths.toList();
}
-void TempDirDeleter::passAndRelease( TempDirDeleter& tdd, const QString& path ) {
- tdd.add( path );
- release( path );
+void TempDirDeleter::add(const QString &path)
+{
+ m_paths.insert(path);
}
-void TempDirDeleter::releaseAll() {
- m_paths.clear();
+void TempDirDeleter::add(const QStringList &paths)
+{
+ m_paths += paths.toSet();
}
-void TempDirDeleter::release( const QString& path ) {
- m_paths.removeAll( path );
+void TempDirDeleter::releaseAll()
+{
+ m_paths.clear();
}
-QStringList TempDirDeleter::paths() const {
- return m_paths;
+void TempDirDeleter::release(const QString &path)
+{
+ m_paths.remove(path);
}
-void TempDirDeleter::add( const QString& path )
+void TempDirDeleter::passAndReleaseAll(TempDirDeleter &tdd)
{
- if( !m_paths.contains( path ) )
- m_paths.push_back( path );
+ tdd.m_paths = m_paths;
+ releaseAll();
}
-void TempDirDeleter::add( const QStringList& paths )
+void TempDirDeleter::passAndRelease(TempDirDeleter &tdd, const QString &path)
{
- for( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it )
- add( *it );
+ tdd.add(path);
+ release(path);
}
-bool QInstaller::isLocalUrl( const QUrl& url ) {
+
+// -- read, write operations
+
+bool QInstaller::isLocalUrl(const QUrl &url)
+{
return url.scheme().isEmpty() || url.scheme().toLower() == QLatin1String("file");
}
-QString QInstaller::pathFromUrl( const QUrl& url )
+QString QInstaller::pathFromUrl(const QUrl &url)
{
- if( isLocalUrl( url ) )
+ if (isLocalUrl(url))
return url.toLocalFile();
const QString str = url.toString();
- if ( url.scheme() == QLatin1String("resource") )
- return str.mid( QString::fromLatin1("resource").length() );
+ if (url.scheme() == QLatin1String("resource"))
+ return str.mid(QString::fromLatin1("resource").length());
return str;
}
+void QInstaller::openForRead(QIODevice *dev, const QString &name)
+{
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::ReadOnly))
+ throw Error(QObject::tr("Cannot open file %1 for reading: %2").arg(name, dev->errorString()));
+}
-void QInstaller::openForWrite(QIODevice* dev, const QString& name)
+void QInstaller::openForWrite(QIODevice *dev, const QString &name)
{
- assert( dev );
+ Q_ASSERT(dev);
if (!dev->open(QIODevice::WriteOnly))
- throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg( name, dev->errorString() ) );
+ throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
}
-void QInstaller::openForRead(QIODevice* dev, const QString& name)
+void QInstaller::openForAppend(QIODevice *dev, const QString &name)
{
- assert( dev );
- if (!dev->open(QIODevice::ReadOnly))
- throw Error(QObject::tr( "Cannot open file %1 for reading: %2" ).arg( name, dev->errorString() ) );
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::ReadWrite | QIODevice::Append))
+ throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
}
qint64 QInstaller::blockingWrite(QIODevice *out, const char *buffer, qint64 size)
@@ -143,74 +155,84 @@ qint64 QInstaller::blockingWrite(QIODevice *out, const char *buffer, qint64 size
qint64 left = size;
while (left > 0) {
const qint64 n = out->write(buffer, left);
- if (n < 0)
- throw Error( QObject::tr("Write failed after %1 bytes: %2").arg( QString::number(size-left), out->errorString() ) );
+ if (n < 0) {
+ throw Error(QObject::tr("Write failed after %1 bytes: %2").arg(QString::number(size-left),
+ out->errorString()));
+ }
left -= n;
}
return size;
}
-qint64 QInstaller::blockingWrite(QIODevice *out, const QByteArray& ba)
+qint64 QInstaller::blockingWrite(QIODevice *out, const QByteArray &ba)
{
- return blockingWrite( out, ba.constData(), ba.size() );
+ return blockingWrite(out, ba.constData(), ba.size());
}
qint64 QInstaller::blockingRead(QIODevice *in, char *buffer, qint64 size)
{
- if ( in->atEnd() )
+ if (in->atEnd())
return 0;
qint64 left = size;
while (left > 0) {
const qint64 n = in->read(buffer, left);
- if ( n < 0 )
- throw Error( QObject::tr("Read failed after %1 bytes: %2").arg( QString::number(size-left), in->errorString() ) );
-
+ if (n < 0) {
+ throw Error(QObject::tr("Read failed after %1 bytes: %2").arg(QString::number(size-left),
+ in->errorString()));
+ }
left -= n;
buffer += n;
}
return size;
}
-void QInstaller::blockingCopy( QIODevice* in, QIODevice* out, qint64 size )
+void QInstaller::blockingCopy(QIODevice *in, QIODevice *out, qint64 size)
{
static const qint64 blockSize = 4096;
- QByteArray ba( blockSize, '\0' );
- qint64 actual = qMin( blockSize, size );
- while( actual > 0 )
- {
- blockingRead( in, ba.data(), actual );
- blockingWrite( out, ba.constData(), actual );
+ QByteArray ba(blockSize, '\0');
+ qint64 actual = qMin(blockSize, size);
+ while (actual > 0) {
+ blockingRead(in, ba.data(), actual);
+ blockingWrite(out, ba.constData(), actual);
size -= actual;
- actual = qMin( blockSize, size );
+ actual = qMin(blockSize, size);
+ }
+}
+
+void QInstaller::removeFiles(const QString &path, bool ignoreErrors)
+{
+ const QFileInfoList entries = QDir(path).entryInfoList(QDir::AllEntries | QDir::Hidden);
+ foreach (const QFileInfo &fi, entries) {
+ if (fi.isSymLink() || fi.isFile()) {
+ QFile f(fi.filePath());
+ if (!f.remove() && !ignoreErrors)
+ throw Error(QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString()));
+ }
}
}
-void QInstaller::removeDirectory( const QString& path, bool ignoreErrors )
+void QInstaller::removeDirectory(const QString &path, bool ignoreErrors)
{
- if ( path.isEmpty() ) // QDir( "" ) points to the working directory! We never want to remove that one.
+ if (path.isEmpty()) // QDir("") points to the working directory! We never want to remove that one.
return;
- QDirIterator it( path, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden );
- while( it.hasNext() )
- {
+ QStringList dirs;
+ QDirIterator it(path, QDir::NoDotAndDotDot | QDir::Dirs | QDir::NoSymLinks | QDir::Hidden,
+ QDirIterator::Subdirectories);
+ while (it.hasNext()) {
it.next();
- const QFileInfo fi = it.fileInfo();
-
- if( fi.isDir() && !fi.isSymLink() )
- {
- removeDirectory( fi.filePath(), ignoreErrors );
- }
- else
- {
- QFile f( fi.filePath() );
- if( !f.remove() && !ignoreErrors )
- throw Error( QObject::tr("Could not remove file %1: %2").arg( f.fileName(), f.errorString() ) );
- }
+ dirs.prepend(it.filePath());
+ removeFiles(dirs.at(0), ignoreErrors);
}
- errno = 0;
- if ( !QDir().rmdir( path ) && !ignoreErrors )
- throw Error( QObject::tr("Could not remove folder %1: %2").arg( path, QLatin1String(strerror(errno)) ) );
+ QDir d;
+ dirs.append(path);
+ removeFiles(path, ignoreErrors);
+ foreach (const QString &dir, dirs) {
+ errno = 0;
+ if (d.exists(path) && !d.rmdir(dir) && !ignoreErrors)
+ throw Error(QObject::tr("Could not remove folder %1: %2").arg(dir, QLatin1String(strerror(errno))));
+ }
}
/*!
@@ -219,14 +241,14 @@ void QInstaller::removeDirectory( const QString& path, bool ignoreErrors )
class RemoveDirectoryThread : public QThread
{
public:
- explicit RemoveDirectoryThread( const QString& path, bool ignoreErrors = false, QObject* parent = 0 )
- : QThread( parent ),
- p( path ),
- ignore( ignoreErrors )
+ explicit RemoveDirectoryThread(const QString &path, bool ignoreErrors = false, QObject *parent = 0)
+ : QThread(parent),
+ p(path),
+ ignore(ignoreErrors)
{
}
-
- const QString& error() const
+
+ const QString &error() const
{
return err;
}
@@ -237,12 +259,9 @@ protected:
*/
void run()
{
- try
- {
- removeDirectory( p, ignore );
- }
- catch( const Error& e )
- {
+ try {
+ removeDirectory(p, ignore);
+ } catch (const Error &e) {
err = e.message();
}
}
@@ -253,216 +272,216 @@ private:
const bool ignore;
};
-void QInstaller::removeDirectoryThreaded( const QString& path, bool ignoreErrors )
+void QInstaller::removeDirectoryThreaded(const QString &path, bool ignoreErrors)
{
- RemoveDirectoryThread thread( path, ignoreErrors );
+ RemoveDirectoryThread thread(path, ignoreErrors);
QEventLoop loop;
- QObject::connect( &thread, SIGNAL( finished() ), &loop, SLOT( quit() ) );
+ QObject::connect(&thread, SIGNAL(finished()), &loop, SLOT(quit()));
thread.start();
loop.exec();
- if( !thread.error().isEmpty() )
- throw Error( thread.error() );
+ if (!thread.error().isEmpty())
+ throw Error(thread.error());
}
-void QInstaller::copyDirectoryContents( const QString& sourceDir, const QString& targetDir ) {
+void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString &targetDir)
+{
verbose() << "Copying " << sourceDir << " to " << targetDir << std::endl;
- Q_ASSERT( QFileInfo( sourceDir ).isDir() );
- Q_ASSERT( !QFileInfo( targetDir ).exists() || QFileInfo( targetDir ).isDir() );
- if ( !QDir().mkpath( targetDir ) )
- throw Error( QObject::tr("Could not create folder %1").arg( targetDir ) );
-
- QDirIterator it( sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries );
- while( it.hasNext() )
- {
- const QFileInfo i( it.next() );
- if( i.isDir() )
- {
- copyDirectoryContents( QDir( sourceDir ).absoluteFilePath( i.fileName() ), QDir( targetDir ).absoluteFilePath( i.fileName() ) );
- }
- else
- {
- QFile f( i.filePath() );
- const QString target = QDir( targetDir ).absoluteFilePath( i.fileName() );
- if( !f.copy( target ) )
- throw Error( QObject::tr("Could not copy file from %1 to %2: %3").arg( f.fileName(), target, f.errorString() ) );
+ Q_ASSERT(QFileInfo(sourceDir).isDir());
+ Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir());
+ if (!QDir().mkpath(targetDir))
+ throw Error(QObject::tr("Could not create folder %1").arg(targetDir));
+
+ QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries);
+ while (it.hasNext()) {
+ const QFileInfo i(it.next());
+ if (i.isDir()) {
+ copyDirectoryContents(QDir(sourceDir).absoluteFilePath(i.fileName()),
+ QDir(targetDir).absoluteFilePath(i.fileName()));
+ } else {
+ QFile f(i.filePath());
+ const QString target = QDir(targetDir).absoluteFilePath(i.fileName());
+ if (!f.copy(target)) {
+ throw Error(QObject::tr("Could not copy file from %1 to %2: %3").arg(f.fileName(), target,
+ f.errorString()));
+ }
}
}
}
-void QInstaller::moveDirectoryContents( const QString& sourceDir, const QString& targetDir ) {
+void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &targetDir)
+{
verbose() << "Moving " << sourceDir << " to " << targetDir << std::endl;
- Q_ASSERT( QFileInfo( sourceDir ).isDir() );
- Q_ASSERT( !QFileInfo( targetDir ).exists() || QFileInfo( targetDir ).isDir() );
- if ( !QDir().mkpath( targetDir ) )
- throw Error( QObject::tr("Could not create folder %1").arg( targetDir ) );
-
- QDirIterator it( sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries );
- while( it.hasNext() )
- {
- const QFileInfo i( it.next() );
- if( i.isDir() )
- {
- moveDirectoryContents( QDir( sourceDir ).absoluteFilePath( i.fileName() ), QDir( targetDir ).absoluteFilePath( i.fileName() ) );
- }
- else
- {
- QFile f( i.filePath() );
- const QString target = QDir( targetDir ).absoluteFilePath( i.fileName() );
- if( !f.rename( target ) )
- throw Error( QObject::tr("Could not move file from %1 to %2: %3").arg( f.fileName(), target, f.errorString() ) );
+ Q_ASSERT(QFileInfo(sourceDir).isDir());
+ Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir());
+ if (!QDir().mkpath(targetDir))
+ throw Error(QObject::tr("Could not create folder %1").arg(targetDir));
+
+ QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries);
+ while (it.hasNext()) {
+ const QFileInfo i(it.next());
+ if (i.isDir()) {
+ moveDirectoryContents(QDir(sourceDir).absoluteFilePath(i.fileName()),
+ QDir(targetDir).absoluteFilePath(i.fileName()));
+ } else {
+ QFile f(i.filePath());
+ const QString target = QDir(targetDir).absoluteFilePath(i.fileName());
+ if (!f.rename(target)) {
+ throw Error(QObject::tr("Could not move file from %1 to %2: %3").arg(f.fileName(), target,
+ f.errorString()));
+ }
}
}
}
-void QInstaller::mkdir( const QString& path ) {
+void QInstaller::mkdir(const QString &path)
+{
errno = 0;
- if ( !QDir().mkdir( QFileInfo( path ).absoluteFilePath() ) )
- throw Error( QObject::tr("Could not create folder %1: %2" ).arg( path, QString::fromLocal8Bit( strerror( errno ) ) ) );
+ if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) {
+ throw Error(QObject::tr("Could not create folder %1: %2").arg(path,
+ QString::fromLocal8Bit(strerror(errno))));
+ }
}
-void QInstaller::mkpath( const QString& path ) {
+void QInstaller::mkpath(const QString &path)
+{
errno = 0;
- if ( !QDir().mkpath( QFileInfo( path ).absoluteFilePath() ) )
- throw Error( QObject::tr("Could not create folder %1: %2" ).arg( path, QString::fromLocal8Bit( strerror( errno ) ) ) );
+ if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) {
+ throw Error(QObject::tr("Could not create folder %1: %2").arg(path,
+ QString::fromLocal8Bit(strerror(errno))));
+ }
}
-QString QInstaller::generateTemporaryFileName( const QString& templ )
+QString QInstaller::generateTemporaryFileName(const QString &templ)
{
- if ( templ.isEmpty() )
- {
+ if (templ.isEmpty()) {
QTemporaryFile f;
- if ( !f.open() )
- throw Error( QObject::tr("Could not open temporary file: %1").arg( f.errorString() ) );
- return f.fileName();
- }
- else
- {
- static const QString characters = QLatin1String( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" );
-/* const QFileInfo fi( path );
- const QString dir = fi.absolutePath();
- const QString file = fi.fileName();*/
- QString suffix;
- qsrand( qrand() * QDateTime::currentDateTime().toTime_t() );
- for( int i = 0; i < 5; ++i )
- suffix += characters[ qrand() % characters.length() ];
- const QString tmp = QLatin1String( "%1.tmp.%2.%3" );
- int count = 1;
- while ( QFile::exists( tmp.arg( templ, suffix ).arg( count ) ) )
- ++count;
- QFile f( tmp.arg( templ, suffix ).arg( count ) );
- if( !f.open( QIODevice::WriteOnly ) )
- throw Error( QObject::tr("Could not open temporary file for template %1: %2").arg( templ, f.errorString() ) );
- f.remove();
+ if (!f.open())
+ throw Error(QObject::tr("Could not open temporary file: %1").arg(f.errorString()));
return f.fileName();
}
+
+ static const QString characters = QLatin1String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
+ QString suffix;
+ qsrand(qrand() * QDateTime::currentDateTime().toTime_t());
+ for (int i = 0; i < 5; ++i)
+ suffix += characters[qrand() % characters.length()];
+
+ const QString tmp = QLatin1String("%1.tmp.%2.%3");
+ int count = 1;
+ while (QFile::exists(tmp.arg(templ, suffix).arg(count)))
+ ++count;
+
+ QFile f(tmp.arg(templ, suffix).arg(count));
+ if (!f.open(QIODevice::WriteOnly))
+ throw Error(QObject::tr("Could not open temporary file for template %1: %2").arg(templ, f.errorString()));
+ f.remove();
+ return f.fileName();
}
-QString QInstaller::createTemporaryDirectory( const QString& templ ) {
+QString QInstaller::createTemporaryDirectory(const QString &templ)
+{
const QString t = QDir::tempPath() + QLatin1String("/") + templ + QLatin1String("XXXXXX");
- QTemporaryFile f( t );
- if ( !f.open() )
- throw Error( QObject::tr("Could not create temporary folder for template %1: %2").arg( t, f.errorString() ) );
- const QString path = f.fileName() + QString::fromLatin1( "meta" );
+ QTemporaryFile f(t);
+ if (!f.open())
+ throw Error(QObject::tr("Could not create temporary folder for template %1: %2").arg(t, f.errorString()));
+ const QString path = f.fileName() + QString::fromLatin1("meta");
verbose() << "Creating meta data directory at " << path << std::endl;
- QInstaller::mkpath( path );
+ QInstaller::mkpath(path);
return path;
}
#ifdef Q_WS_WIN
#include <windows.h>
-#pragma pack( push )
+#pragma pack(push)
#pragma pack(2)
-typedef struct
-{
-BYTE bWidth; // Width, in pixels, of the image
-BYTE bHeight; // Height, in pixels, of the image
-BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
-BYTE bReserved; // Reserved
-WORD wPlanes; // Color Planes
-WORD wBitCount; // Bits per pixel
-DWORD dwBytesInRes; // how many bytes in this resource?
-DWORD dwImageOffset; // the ID
+typedef struct {
+ BYTE bWidth; // Width, in pixels, of the image
+ BYTE bHeight; // Height, in pixels, of the image
+ BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
+ BYTE bReserved; // Reserved
+ WORD wPlanes; // Color Planes
+ WORD wBitCount; // Bits per pixel
+ DWORD dwBytesInRes; // how many bytes in this resource?
+ DWORD dwImageOffset; // the ID
} ICONDIRENTRY;
-typedef struct
-{
-WORD idReserved; // Reserved (must be 0)
-WORD idType; // Resource type (1 for icons)
-WORD idCount; // How many images?
-ICONDIRENTRY idEntries[1]; // The entries for each image
+typedef struct {
+ WORD idReserved; // Reserved (must be 0)
+ WORD idType; // Resource type (1 for icons)
+ WORD idCount; // How many images?
+ ICONDIRENTRY idEntries[1]; // The entries for each image
} ICONDIR;
-typedef struct
-{
-BYTE bWidth; // Width, in pixels, of the image
-BYTE bHeight; // Height, in pixels, of the image
-BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
-BYTE bReserved; // Reserved
-WORD wPlanes; // Color Planes
-WORD wBitCount; // Bits per pixel
-DWORD dwBytesInRes; // how many bytes in this resource?
-WORD nID; // the ID
+typedef struct {
+ BYTE bWidth; // Width, in pixels, of the image
+ BYTE bHeight; // Height, in pixels, of the image
+ BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
+ BYTE bReserved; // Reserved
+ WORD wPlanes; // Color Planes
+ WORD wBitCount; // Bits per pixel
+ DWORD dwBytesInRes; // how many bytes in this resource?
+ WORD nID; // the ID
} GRPICONDIRENTRY, *LPGRPICONDIRENTRY;
-typedef struct
-{
-WORD idReserved; // Reserved (must be 0)
-WORD idType; // Resource type (1 for icons)
-WORD idCount; // How many images?
-GRPICONDIRENTRY idEntries[1]; // The entries for each image
+typedef struct {
+ WORD idReserved; // Reserved (must be 0)
+ WORD idType; // Resource type (1 for icons)
+ WORD idCount; // How many images?
+ GRPICONDIRENTRY idEntries[1]; // The entries for each image
} GRPICONDIR, *LPGRPICONDIR;
-#pragma pack( pop )
+#pragma pack(pop)
-void QInstaller::setApplicationIcon( const QString& application, const QString& icon )
+void QInstaller::setApplicationIcon(const QString &application, const QString &icon)
{
- wchar_t* const path = new wchar_t[ application.length() + 1 ];
- QDir::toNativeSeparators( application ).toWCharArray( path );
- path[ application.length() ] = 0;
+ wchar_t* const path = new wchar_t[application.length() + 1];
+ QDir::toNativeSeparators(application).toWCharArray(path);
+ path[application.length()] = 0;
- HANDLE updateRes = BeginUpdateResource( path, false );
+ HANDLE updateRes = BeginUpdateResource(path, false);
delete[] path;
- QFile iconFile( icon );
- if( !iconFile.open( QIODevice::ReadOnly ) )
+ QFile iconFile(icon);
+ if (!iconFile.open(QIODevice::ReadOnly))
return;
QByteArray temp = iconFile.readAll();
- ICONDIR* ig = reinterpret_cast< ICONDIR* >( temp.data() );
+ ICONDIR* ig = reinterpret_cast< ICONDIR* >(temp.data());
- DWORD newSize = sizeof( GRPICONDIR ) + sizeof( GRPICONDIRENTRY ) * ( ig->idCount - 1 );
- GRPICONDIR* newDir = reinterpret_cast< GRPICONDIR* >( new char[ newSize ] );
+ DWORD newSize = sizeof(GRPICONDIR) + sizeof(GRPICONDIRENTRY) * (ig->idCount - 1);
+ GRPICONDIR* newDir = reinterpret_cast< GRPICONDIR* >(new char[newSize]);
newDir->idReserved = ig->idReserved;
newDir->idType = ig->idType;
newDir->idCount = ig->idCount;
- for( int i = 0; i < ig->idCount; ++i )
- {
- char* temp1 = temp.data() + ig->idEntries[ i ].dwImageOffset;
- DWORD size1 = ig->idEntries[ i ].dwBytesInRes;
-
- newDir->idEntries[ i ].bWidth = ig->idEntries[ i ].bWidth;
- newDir->idEntries[ i ].bHeight = ig->idEntries[ i ].bHeight;
- newDir->idEntries[ i ].bColorCount = ig->idEntries[ i ].bColorCount;
- newDir->idEntries[ i ].bReserved = ig->idEntries[ i ].bReserved;
- newDir->idEntries[ i ].wPlanes = ig->idEntries[ i ].wPlanes;
- newDir->idEntries[ i ].wBitCount = ig->idEntries[ i ].wBitCount;
- newDir->idEntries[ i ].dwBytesInRes = ig->idEntries[ i ].dwBytesInRes;
- newDir->idEntries[ i ].nID = i + 1;
-
- UpdateResource( updateRes, RT_ICON, MAKEINTRESOURCE( i + 1 ),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), temp1, size1 );
+ for (int i = 0; i < ig->idCount; ++i) {
+ char* temp1 = temp.data() + ig->idEntries[i].dwImageOffset;
+ DWORD size1 = ig->idEntries[i].dwBytesInRes;
+
+ newDir->idEntries[i].bWidth = ig->idEntries[i].bWidth;
+ newDir->idEntries[i].bHeight = ig->idEntries[i].bHeight;
+ newDir->idEntries[i].bColorCount = ig->idEntries[i].bColorCount;
+ newDir->idEntries[i].bReserved = ig->idEntries[i].bReserved;
+ newDir->idEntries[i].wPlanes = ig->idEntries[i].wPlanes;
+ newDir->idEntries[i].wBitCount = ig->idEntries[i].wBitCount;
+ newDir->idEntries[i].dwBytesInRes = ig->idEntries[i].dwBytesInRes;
+ newDir->idEntries[i].nID = i + 1;
+
+ UpdateResource(updateRes, RT_ICON, MAKEINTRESOURCE(i + 1),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), temp1, size1);
}
- UpdateResource( updateRes, RT_GROUP_ICON, L"IDI_ICON1", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newDir, newSize );
+ UpdateResource(updateRes, RT_GROUP_ICON, L"IDI_ICON1", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newDir
+ , newSize);
- delete[] newDir;
+ delete [] newDir;
- EndUpdateResource( updateRes, false );
+ EndUpdateResource(updateRes, false);
}
+
#endif
diff --git a/installerbuilder/common/fileutils.h b/installerbuilder/common/fileutils.h
index efed7930e..4c28d9d09 100644
--- a/installerbuilder/common/fileutils.h
+++ b/installerbuilder/common/fileutils.h
@@ -26,78 +26,85 @@
#ifndef QINSTALLER_FILEUTILS_H
#define QINSTALLER_FILEUTILS_H
+#include "installer_global.h"
+
+#include <QtCore/QSet>
#include <QtCore/QString>
#include <QtCore/QStringList>
-#include "installer_global.h"
-
+QT_BEGIN_NAMESPACE
class QByteArray;
class QIODevice;
class QUrl;
+QT_END_NAMESPACE
namespace QInstaller {
- void INSTALLER_EXPORT openForWrite(QIODevice* dev, const QString& name);
- void INSTALLER_EXPORT openForRead(QIODevice* dev, const QString& name);
-
- qint64 INSTALLER_EXPORT blockingRead( QIODevice* in, char *buffer, qint64 size );
- qint64 INSTALLER_EXPORT blockingWrite( QIODevice* out, const char* buffer, qint64 size);
- qint64 INSTALLER_EXPORT blockingWrite( QIODevice* out, const QByteArray& ba );
- void INSTALLER_EXPORT blockingCopy( QIODevice* in, QIODevice* out, qint64 size );
-
- /**
- * Removes the directory at \a path recursively.
- * @param path The directory to remove
- * @param ignoreErrors if @p true, errors will be silently ignored. Otherwise an exception will be thrown if removing fails.
- *
- * @throws QInstaller::Error if the directory cannot be removed and ignoreErrors is @p false
- */
- void INSTALLER_EXPORT removeDirectory( const QString& path, bool ignoreErrors = false );
- void INSTALLER_EXPORT removeDirectoryThreaded( const QString& path, bool ignoreErrors = false );
-
- /**
- * Creates a temporary directory
- * @throws QInstaller::Error if creating the temporary directory fails
- */
- QString INSTALLER_EXPORT createTemporaryDirectory( const QString& templ=QString() );
-
- QString INSTALLER_EXPORT generateTemporaryFileName( const QString& templ=QString() );
-
- void INSTALLER_EXPORT moveDirectoryContents( const QString& sourceDir, const QString& targetDir );
- void INSTALLER_EXPORT copyDirectoryContents( const QString& sourceDir, const QString& targetDir );
-
- bool INSTALLER_EXPORT isLocalUrl( const QUrl& url );
- QString INSTALLER_EXPORT pathFromUrl( const QUrl& url );
-
- void INSTALLER_EXPORT mkdir( const QString& path );
- void INSTALLER_EXPORT mkpath( const QString& path );
+class INSTALLER_EXPORT TempDirDeleter
+{
+public:
+ explicit TempDirDeleter(const QString &path);
+ explicit TempDirDeleter(const QStringList &paths = QStringList());
+ ~TempDirDeleter();
+
+ QStringList paths() const;
+
+ void add(const QString &path);
+ void add(const QStringList &paths);
+
+ void releaseAll();
+ void release(const QString &path);
+ void passAndReleaseAll(TempDirDeleter &tdd);
+ void passAndRelease(TempDirDeleter &tdd, const QString &path);
+
+private:
+ Q_DISABLE_COPY(TempDirDeleter)
+ QSet<QString> m_paths;
+};
+
+ void INSTALLER_EXPORT openForRead(QIODevice *dev, const QString &name);
+ void INSTALLER_EXPORT openForWrite(QIODevice *dev, const QString &name);
+ void INSTALLER_EXPORT openForAppend(QIODevice *dev, const QString &name);
+
+ qint64 INSTALLER_EXPORT blockingRead(QIODevice *in, char *buffer, qint64 size);
+ void INSTALLER_EXPORT blockingCopy(QIODevice *in, QIODevice *out, qint64 size);
+ qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const char* buffer, qint64 size);
+ qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const QByteArray& ba);
+
+ /*!
+ Removes the directory at \a path recursively.
+ @param path The directory to remove
+ @param ignoreErrors if @p true, errors will be silently ignored. Otherwise an exception will be thrown
+ if removing fails.
+
+ @throws QInstaller::Error if the directory cannot be removed and ignoreErrors is @p false
+ */
+ void INSTALLER_EXPORT removeFiles(const QString &path, bool ignoreErrors = false);
+ void INSTALLER_EXPORT removeDirectory(const QString &path, bool ignoreErrors = false);
+ void INSTALLER_EXPORT removeDirectoryThreaded(const QString &path, bool ignoreErrors = false);
+
+ /*!
+ Creates a temporary directory
+ @throws QInstaller::Error if creating the temporary directory fails
+ */
+ QString INSTALLER_EXPORT createTemporaryDirectory(const QString &templ=QString());
+
+ QString INSTALLER_EXPORT generateTemporaryFileName(const QString &templ=QString());
+
+ void INSTALLER_EXPORT moveDirectoryContents(const QString &sourceDir, const QString &targetDir);
+ void INSTALLER_EXPORT copyDirectoryContents(const QString &sourceDir, const QString &targetDir);
+
+ bool INSTALLER_EXPORT isLocalUrl(const QUrl &url);
+ QString INSTALLER_EXPORT pathFromUrl(const QUrl &url);
+
+ void INSTALLER_EXPORT mkdir(const QString &path);
+ void INSTALLER_EXPORT mkpath(const QString &path);
#ifdef Q_WS_WIN
- /**
- * Sets the .ico file at \a icon as application icon for \a application.
- */
- void INSTALLER_EXPORT setApplicationIcon( const QString& application, const QString& icon );
-
+ /*!
+ Sets the .ico file at \a icon as application icon for \a application.
+ */
+ void INSTALLER_EXPORT setApplicationIcon(const QString &application, const QString &icon);
#endif
-
- class INSTALLER_EXPORT TempDirDeleter
- {
- public:
- explicit TempDirDeleter( const QString& path );
- explicit TempDirDeleter( const QStringList& paths = QStringList() );
- ~TempDirDeleter();
- void releaseAll();
- void release( const QString& path );
- void passAndReleaseAll( TempDirDeleter& tdd );
- void passAndRelease( TempDirDeleter& tdd, const QString& path );
-
- void add( const QString& path );
- void add( const QStringList& paths );
- QStringList paths() const;
-
- private:
- Q_DISABLE_COPY(TempDirDeleter)
- QStringList m_paths;
- };
}
#endif // QINSTALLER_FILEUTILS_H
diff --git a/installerbuilder/common/installersettings.cpp b/installerbuilder/common/installersettings.cpp
index 19f3eeb25..02f49f28e 100644
--- a/installerbuilder/common/installersettings.cpp
+++ b/installerbuilder/common/installersettings.cpp
@@ -35,21 +35,18 @@
#include "common/errors.h"
#include "common/repository.h"
-#include <QDomDocument>
+#include <QtCore/QFileInfo>
+#include <QtCore/QStringList>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-#include <QSharedData>
-#include <QStringList>
+#include <QtXml/QDomDocument>
using namespace QInstaller;
-/*
-TRANSLATOR QInstaller::InstallerSettings
-*/
-class InstallerSettings::Private : public QSharedData {
+// -- InstallerSettings::Private
+
+class InstallerSettings::Private : public QSharedData
+{
public:
QString prefix;
QString logo;
@@ -72,190 +69,215 @@ public:
QString uninstallerName;
QString uninstallerIniFile;
QString configurationFileName;
- QList<Repository> repositories;
+ QSet<Repository> m_repositories;
+ QSet<Repository> m_userRepositories;
QStringList certificateFiles;
QByteArray privateKey;
QByteArray publicKey;
- QString makeAbsolutePath( const QString& p ) const {
- if ( QFileInfo( p ).isAbsolute() )
+ QString makeAbsolutePath(const QString &p) const
+ {
+ if (QFileInfo(p).isAbsolute())
return p;
- return prefix + QLatin1String("/") + p;
+ return prefix + QLatin1String("/") + p;
}
};
-static QString readChild( const QDomElement& el, const QString& child, const QString& defValue=QString() ) {
- const QDomNodeList list = el.elementsByTagName( child );
- if ( list.size() > 1 )
- throw Error( QObject::tr("Multiple %1 elements found, but only one allowed.").arg( child ) );
- return list.isEmpty() ? defValue : list.at( 0 ).toElement().text();
+static QString readChild(const QDomElement &el, const QString &child, const QString &defValue = QString())
+{
+ const QDomNodeList list = el.elementsByTagName(child);
+ if (list.size() > 1)
+ throw Error(QObject::tr("Multiple %1 elements found, but only one allowed.").arg(child));
+ return list.isEmpty() ? defValue : list.at(0).toElement().text();
}
#if 0
-static QStringList readChildList( const QDomElement& el, const QString& child ) {
- const QDomNodeList list = el.elementsByTagName( child );
+static QStringList readChildList(const QDomElement &el, const QString &child)
+{
+ const QDomNodeList list = el.elementsByTagName(child);
QStringList res;
- for ( int i = 0; i < list.size(); ++i )
- res += list.at( i ).toElement().text();
+ for (int i = 0; i < list.size(); ++i)
+ res += list.at(i).toElement().text();
return res;
}
#endif
-InstallerSettings::InstallerSettings( const InstallerSettings& other ) : d( other.d ) {}
+static QString splitTrimmed(const QString &string)
+{
+ if (string.isEmpty())
+ return QString();
+
+ const QStringList input = string.split(QRegExp(QLatin1String("\n|\r\n")));
-InstallerSettings& InstallerSettings::operator=( const InstallerSettings& other ) {
- InstallerSettings copy( other );
- std::swap( d, copy.d );
- return *this;
+ QStringList result;
+ foreach (const QString &line, input)
+ result.append(line.trimmed());
+ result.append(QString());
+
+ return result.join(QLatin1String("\n"));
}
-static QString splitTrimmed( const QString& string )
+
+// -- InstallerSettings
+
+InstallerSettings::InstallerSettings()
+ : d(new Private)
{
- if( string.isEmpty() )
- return QString();
+}
- QStringList result;
- const QStringList input = string.split( QRegExp( QLatin1String( "\n|\r\n" ) ) );
- for( QStringList::const_iterator it = input.begin(); it != input.end(); ++it )
- {
- const QString line = it->trimmed();
- result.push_back( line );
- }
- result.push_back( QString() );
- return result.join( QLatin1String( "\n" ) );
+InstallerSettings::~InstallerSettings()
+{
+}
+
+InstallerSettings::InstallerSettings(const InstallerSettings &other)
+ : d(other.d)
+{
+}
+
+InstallerSettings& InstallerSettings::operator=(const InstallerSettings &other)
+{
+ InstallerSettings copy(other);
+ std::swap(d, copy.d);
+ return *this;
}
-InstallerSettings InstallerSettings::fromFileAndPrefix( const QString& path, const QString& prefix ) {
+/*!
+ @throws QInstallerError
+*/
+InstallerSettings InstallerSettings::fromFileAndPrefix(const QString &path, const QString &prefix)
+{
QDomDocument doc;
- QFile file( path );
- QFile overrideConfig( QLatin1String( ":/overrideconfig.xml" ) );
- if ( overrideConfig.exists() )
- file.setFileName( overrideConfig.fileName() );
- if ( !file.open( QIODevice::ReadOnly ) )
- throw Error( tr("Could not open settings file %1 for reading: %2").arg( path, file.errorString() ) );
+ QFile file(path);
+ QFile overrideConfig(QLatin1String(":/overrideconfig.xml"));
+
+ if (overrideConfig.exists())
+ file.setFileName(overrideConfig.fileName());
+
+ if (!file.open(QIODevice::ReadOnly))
+ throw Error(tr("Could not open settings file %1 for reading: %2").arg(path, file.errorString()));
+
QString msg;
int line = 0;
int col = 0;
- if ( !doc.setContent( &file, &msg, &line, &col ) )
- throw Error( tr("Could not parse settings file %1: %2:%3: %4").arg( path,
- QString::number( line ),
- QString::number( col ),
- msg ) );
+ if (!doc.setContent(&file, &msg, &line, &col)) {
+ throw Error(tr("Could not parse settings file %1: %2:%3: %4").arg(path, QString::number(line),
+ QString::number(col), msg));
+ }
+
const QDomElement root = doc.documentElement();
- if ( root.tagName() != QLatin1String( "Installer" ) )
- throw Error( tr("%1 is not valid: Installer root node expected") );
+ if (root.tagName() != QLatin1String("Installer"))
+ throw Error(tr("%1 is not valid: Installer root node expected"));
InstallerSettings s;
s.d->prefix = prefix;
- s.d->logo = readChild( root, QLatin1String("Logo") );
- s.d->logoSmall = readChild( root, QLatin1String("LogoSmall") );
- s.d->title = readChild( root, QLatin1String("Title") );
- s.d->maintenanceTitle = readChild( root, QLatin1String("MaintenanceTitle") );
- s.d->name = readChild( root, QLatin1String("Name") );
- s.d->version = readChild( root, QLatin1String("Version") );
- s.d->publisher = readChild( root, QLatin1String("Publisher") );
- s.d->url = readChild( root, QLatin1String("ProductUrl") );
- s.d->watermark = readChild( root, QLatin1String("Watermark") );
- s.d->background = readChild( root, QLatin1String("Background") );
- s.d->runProgram = readChild( root, QLatin1String("RunProgram") );
- s.d->runProgramDescription = readChild( root, QLatin1String("RunProgramDescription") );
- s.d->startMenuDir = readChild( root, QLatin1String("StartMenuDir") );
- s.d->targetDir = readChild( root, QLatin1String("TargetDir") );
- s.d->adminTargetDir = readChild( root, QLatin1String("AdminTargetDir") );
- s.d->icon = readChild( root, QLatin1String( "Icon" ) );
+ s.d->logo = readChild(root, QLatin1String("Logo"));
+ s.d->logoSmall = readChild(root, QLatin1String("LogoSmall"));
+ s.d->title = readChild(root, QLatin1String("Title"));
+ s.d->maintenanceTitle = readChild(root, QLatin1String("MaintenanceTitle"));
+ s.d->name = readChild(root, QLatin1String("Name"));
+ s.d->version = readChild(root, QLatin1String("Version"));
+ s.d->publisher = readChild(root, QLatin1String("Publisher"));
+ s.d->url = readChild(root, QLatin1String("ProductUrl"));
+ s.d->watermark = readChild(root, QLatin1String("Watermark"));
+ s.d->background = readChild(root, QLatin1String("Background"));
+ s.d->runProgram = readChild(root, QLatin1String("RunProgram"));
+ s.d->runProgramDescription = readChild(root, QLatin1String("RunProgramDescription"));
+ s.d->startMenuDir = readChild(root, QLatin1String("StartMenuDir"));
+ s.d->targetDir = readChild(root, QLatin1String("TargetDir"));
+ s.d->adminTargetDir = readChild(root, QLatin1String("AdminTargetDir"));
+ s.d->icon = readChild(root, QLatin1String("Icon"));
s.d->removeTargetDir = readChild(root, QLatin1String("RemoveTargetDir"), QLatin1String("true"));
- s.d->uninstallerName = readChild( root, QLatin1String( "UninstallerName" ), QLatin1String("uninstall") );
- s.d->uninstallerIniFile = readChild( root, QLatin1String("UninstallerIniFile"), s.d->uninstallerName + QLatin1String(".ini") );
- s.d->privateKey = splitTrimmed( readChild( root, QLatin1String( "PrivateKey" ) ) ).toLatin1();
- s.d->publicKey = splitTrimmed( readChild( root, QLatin1String( "PublicKey" ) ) ).toLatin1();
- s.d->configurationFileName = readChild( root, QLatin1String( "TargetConfigurationFile"), QLatin1String("components.xml"));
-
- const QDomNodeList reposTags = root.elementsByTagName( QLatin1String("RemoteRepositories") );
- if ( reposTags.size() > 1 )
- throw Error( tr("Multiple RemoteRepositories elements found, but only one allowed.") );
- if ( !reposTags.isEmpty() ) {
- const QDomNodeList repos = reposTags.at( 0 ).toElement().elementsByTagName( QLatin1String("Repository") );
- for ( int i = 0; i < repos.size(); ++i ) {
+ s.d->uninstallerName = readChild(root, QLatin1String("UninstallerName"), QLatin1String("uninstall"));
+ s.d->uninstallerIniFile = readChild(root, QLatin1String("UninstallerIniFile"), s.d->uninstallerName
+ + QLatin1String(".ini"));
+ s.d->privateKey = splitTrimmed(readChild(root, QLatin1String("PrivateKey"))).toLatin1();
+ s.d->publicKey = splitTrimmed(readChild(root, QLatin1String("PublicKey"))).toLatin1();
+ s.d->configurationFileName = readChild(root, QLatin1String("TargetConfigurationFile"),
+ QLatin1String("components.xml"));
+
+ const QDomNodeList reposTags = root.elementsByTagName(QLatin1String("RemoteRepositories"));
+ for (int a = 0; a < reposTags.count(); ++a) {
+ const QDomNodeList repos = reposTags.at(a).toElement().elementsByTagName(QLatin1String("Repository"));
+ for (int i = 0; i < repos.size(); ++i) {
Repository r;
- const QDomNodeList children = repos.at( i ).childNodes();
- for ( int j = 0; j < children.size(); ++j ) {
- if ( children.at( j ).toElement().tagName() == QLatin1String( "Url" ) )
- r.setUrl( children.at( j ).toElement().text() );
- if ( children.at( j ).toElement().tagName() == QLatin1String( "Required" ) )
- r.setRequired( children.at( j ).toElement().text() == QLatin1String("true") );
+ const QDomNodeList children = repos.at(i).childNodes();
+ for (int j = 0; j < children.size(); ++j) {
+ if (children.at(j).toElement().tagName() == QLatin1String("Url"))
+ r.setUrl(children.at(j).toElement().text());
}
- s.d->repositories.append( r );
+ s.d->m_repositories.insert(r);
}
}
- const QDomNodeList certs = root.elementsByTagName( QLatin1String("SigningCertificate") );
- for ( int i=0; i < certs.size(); ++i ) {
- const QString str = certs.at( i ).toElement().text();
- if ( str.isEmpty() )
+ const QDomNodeList certs = root.elementsByTagName(QLatin1String("SigningCertificate"));
+ for (int i=0; i < certs.size(); ++i) {
+ const QString str = certs.at(i).toElement().text();
+ if (str.isEmpty())
continue;
- s.d->certificateFiles.push_back( s.d->makeAbsolutePath( str ) );
+ s.d->certificateFiles.push_back(s.d->makeAbsolutePath(str));
}
return s;
}
-InstallerSettings::InstallerSettings() : d( new Private ) {
-}
-
QString InstallerSettings::maintenanceTitle() const
{
return d->maintenanceTitle;
}
-InstallerSettings::~InstallerSettings() {
-}
-
-QString InstallerSettings::logo() const {
- return d->makeAbsolutePath( d->logo );
+QString InstallerSettings::logo() const
+{
+ return d->makeAbsolutePath(d->logo);
}
-QString InstallerSettings::logoSmall() const {
- return d->makeAbsolutePath( d->logoSmall );
+QString InstallerSettings::logoSmall() const
+{
+ return d->makeAbsolutePath(d->logoSmall);
}
-QString InstallerSettings::title() const {
+QString InstallerSettings::title() const
+{
return d->title;
}
-QString InstallerSettings::applicationName() const {
+QString InstallerSettings::applicationName() const
+{
return d->name;
}
-QString InstallerSettings::applicationVersion() const {
+QString InstallerSettings::applicationVersion() const
+{
return d->version;
}
-QString InstallerSettings::publisher() const {
+QString InstallerSettings::publisher() const
+{
return d->publisher;
}
-QString InstallerSettings::url() const {
+QString InstallerSettings::url() const
+{
return d->url;
}
-
-QString InstallerSettings::watermark() const {
- return d->makeAbsolutePath( d->watermark );
+
+QString InstallerSettings::watermark() const
+{
+ return d->makeAbsolutePath(d->watermark);
}
-QString InstallerSettings::background() const
+QString InstallerSettings::background() const
{
- return d->makeAbsolutePath( d->background );
+ return d->makeAbsolutePath(d->background);
}
QString InstallerSettings::icon() const
{
-#if defined( Q_WS_MAC )
- return d->makeAbsolutePath( d->icon ) + QLatin1String( ".icns" );
-#elif defined( Q_WS_WIN )
- return d->makeAbsolutePath( d->icon ) + QLatin1String( ".ico" );
-#else
- return d->makeAbsolutePath( d->icon ) + QLatin1String( ".png" );
+#if defined(Q_WS_MAC)
+ return d->makeAbsolutePath(d->icon) + QLatin1String(".icns");
+#elif defined(Q_WS_WIN)
+ return d->makeAbsolutePath(d->icon) + QLatin1String(".ico");
#endif
+ return d->makeAbsolutePath(d->icon) + QLatin1String(".png");
}
QString InstallerSettings::removeTargetDir() const
@@ -265,8 +287,8 @@ QString InstallerSettings::removeTargetDir() const
QString InstallerSettings::uninstallerName() const
{
- if( d->uninstallerName.isEmpty() )
- return QLatin1String( "uninstall" );
+ if (d->uninstallerName.isEmpty())
+ return QLatin1String("uninstall");
return d->uninstallerName;
}
@@ -275,7 +297,8 @@ QString InstallerSettings::uninstallerIniFile() const
return d->uninstallerIniFile;
}
-QString InstallerSettings::runProgram() const {
+QString InstallerSettings::runProgram() const
+{
return d->runProgram;
}
@@ -284,27 +307,28 @@ QString InstallerSettings::runProgramDescription() const
return d->runProgramDescription;
}
-QString InstallerSettings::startMenuDir() const {
+QString InstallerSettings::startMenuDir() const
+{
return d->startMenuDir;
}
-QString InstallerSettings::targetDir() const {
+QString InstallerSettings::targetDir() const
+{
return d->targetDir;
}
-QString InstallerSettings::adminTargetDir() const {
+QString InstallerSettings::adminTargetDir() const
+{
return d->adminTargetDir;
}
-QString InstallerSettings::configurationFileName() const {
+QString InstallerSettings::configurationFileName() const
+{
return d->configurationFileName;
}
-QList<Repository> InstallerSettings::repositories() const {
- return d->repositories;
-}
-
-QStringList InstallerSettings::certificateFiles() const {
+QStringList InstallerSettings::certificateFiles() const
+{
return d->certificateFiles;
}
@@ -318,10 +342,25 @@ QByteArray InstallerSettings::publicKey() const
return d->publicKey;
}
+QList<Repository> InstallerSettings::repositories() const
+{
+ return (d->m_repositories + d->m_userRepositories).toList();
+}
+
void InstallerSettings::setTemporaryRepositories(const QList<Repository> &repos, bool replace)
{
if (replace)
- d->repositories = repos;
+ d->m_repositories = repos.toSet();
else
- d->repositories.append(repos);
+ d->m_repositories.unite(repos.toSet());
+}
+
+QList<Repository> InstallerSettings::userRepositories() const
+{
+ return d->m_userRepositories.toList();
+}
+
+void InstallerSettings::addUserRepositories(const QList<Repository> &repositories)
+{
+ d->m_userRepositories.unite(repositories.toSet());
}
diff --git a/installerbuilder/common/installersettings.h b/installerbuilder/common/installersettings.h
index 939d35f00..7a1c72fdb 100644
--- a/installerbuilder/common/installersettings.h
+++ b/installerbuilder/common/installersettings.h
@@ -26,68 +26,70 @@
#ifndef INSTALLERSETTINGS_H
#define INSTALLERSETTINGS_H
+#include "installer_global.h"
+
#include <QtCore/QCoreApplication>
#include <QtCore/QSharedDataPointer>
-#include "installer_global.h"
-
namespace QInstaller {
+class Repository;
+
+class INSTALLER_EXPORT InstallerSettings
+{
+ Q_DECLARE_TR_FUNCTIONS(InstallerSettings)
+
+public:
+ explicit InstallerSettings();
+ ~InstallerSettings();
+
+ InstallerSettings(const InstallerSettings &other);
+ InstallerSettings &operator=(const InstallerSettings &other);
+
+ static InstallerSettings fromFileAndPrefix(const QString &path, const QString &prefix);
+
+ bool isValid() const;
+
+ QString logo() const;
+ QString logoSmall() const;
+ QString title() const;
+ QString maintenanceTitle() const;
+ QString publisher() const;
+ QString url() const;
+ QString watermark() const;
+ QString background() const;
+ QString icon() const;
+
+ QString applicationName() const;
+ QString applicationVersion() const;
+
+ QString runProgram() const;
+ QString runProgramDescription() const;
+ QString startMenuDir() const;
+ QString targetDir() const;
+ QString adminTargetDir() const;
+
+ QString removeTargetDir() const;
+ QString uninstallerName() const;
+ QString uninstallerIniFile() const;
+
+ QByteArray privateKey() const;
+ QByteArray publicKey() const;
+
+ QString configurationFileName() const;
+
+ QList<Repository> repositories() const;
+ void setTemporaryRepositories(const QList<Repository> &repos, bool replace);
+
+ QList<Repository> userRepositories() const;
+ void addUserRepositories(const QList<Repository> &repositories);
+
+ QStringList certificateFiles() const;
+
+private:
+ class Private;
+ QSharedDataPointer<Private> d;
+};
- class Repository;
-
- class INSTALLER_EXPORT InstallerSettings {
- Q_DECLARE_TR_FUNCTIONS(InstallerSettings)
- public:
- /**
- * @throws QInstallerError
- */
- static InstallerSettings fromFileAndPrefix( const QString& path, const QString& prefix );
-
- explicit InstallerSettings();
- InstallerSettings( const InstallerSettings& other );
- ~InstallerSettings();
-
- InstallerSettings& operator=( const InstallerSettings& other );
-
- bool isValid() const;
-
- QString logo() const;
- QString logoSmall() const;
- QString title() const;
- QString maintenanceTitle() const;
- QString publisher() const;
- QString url() const;
- QString watermark() const;
- QString background() const;
- QString icon() const;
-
- QString applicationName() const;
- QString applicationVersion() const;
-
- QString runProgram() const;
- QString runProgramDescription() const;
- QString startMenuDir() const;
- QString targetDir() const;
- QString adminTargetDir() const;
-
- QString removeTargetDir() const;
- QString uninstallerName() const;
- QString uninstallerIniFile() const;
-
- QByteArray privateKey() const;
- QByteArray publicKey() const;
-
- QString configurationFileName() const;
-
- QList<Repository> repositories() const;
- void setTemporaryRepositories(const QList<Repository> &repos, bool replace);
-
- QStringList certificateFiles() const;
-
- private:
- class Private;
- QSharedDataPointer<Private> d;
- };
}
#endif // INSTALLERSETTINGS_H
diff --git a/installerbuilder/common/kd7zengine.cpp b/installerbuilder/common/kd7zengine.cpp
deleted file mode 100644
index 71298b326..000000000
--- a/installerbuilder/common/kd7zengine.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "kd7zengine.h"
-
-#include <QBuffer>
-#include <QDateTime>
-#include <QDebug>
-#include <QDir>
-#include <QMap>
-#include <QSet>
-#include <QTextCodec>
-
-#include "lib7z_facade.h"
-
-static QMap< QString, QFile* > archives;
-static QMap< QString, QVector< Lib7z::File > > currentContents;
-static QMap< QString, QHash< QString, const Lib7z::File* > > currentFiles;
-
-namespace
-{
-
-static bool matches( const QList< QRegExp >& regexps, QDir::Filters filters, const Lib7z::File& n )
-{
- const QString fileName = n.path.section( QChar::fromLatin1( '/' ), -1, -1, QString::SectionSkipEmpty );
-
- static QLatin1Char sep( '/' );
-
- // check for directories filter
- if( ( filters & QDir::Dirs ) == 0 && n.isDirectory )
- return false;
-
- // check for files filter
- if( ( filters & QDir::Files ) == 0 && !n.isDirectory )
- return false;
-
- // check for name filter
- if( !regexps.isEmpty() )
- {
- bool matched = false;
- for( QList< QRegExp >::const_iterator it = regexps.begin(); it != regexps.end(); ++it )
- {
- matched = it->exactMatch( fileName );
- if ( matched )
- break;
- }
- return matched;
- }
- return true;
-}
-}
-
-class KD7zEngine::Private
-{
-public:
- Private( KD7zEngine* q )
- : q( q ),
- flags( 0 ),
- mode( QIODevice::NotOpen )
- {
- }
-
-private:
- KD7zEngine* const q;
-
-public:
- void setFileName( const QString& file )
- {
- const QString oldZipFileName = zipFileName;
- providedFileName = file;
-
- static const QLatin1Char sep( '/' );
-
- static const QString prefix = QString::fromLatin1( "7z://" );
- Q_ASSERT( file.toLower().startsWith( prefix ) );
- zipFileName = file.mid( prefix.length() );
- zipFileName.replace( QLatin1Char( '\\' ), sep );
-
- QDir dir( zipFileName );
- int i = -1;
- while( !dir.exists() )
- dir = QDir( zipFileName.section( sep, 0, i-- ) );
-
- zipFileName = zipFileName.section( sep, 0, i + 2 );
- fileName = file.mid( prefix.length() + zipFileName.length() );
-
- while( fileName.endsWith( sep ) )
- fileName.chop( 1 );
- while( fileName.startsWith( sep ) )
- fileName.remove( 0, 1 );
-
- flags = 0;
- q->close();
- currentFile = Lib7z::File();
- }
-
- /**
- * Taken from qfsfileengine.cpp
- */
- static QString canonicalized(const QString &path)
- {
- if (path.isEmpty())
- return path;
-
- QFileInfo fi;
- const QChar slash(QLatin1Char('/'));
- QString tmpPath = path;
- int separatorPos = 0;
- QSet<QString> nonSymlinks;
- QSet<QString> known;
-
- known.insert(path);
- do {
-#ifdef Q_OS_WIN
- // UNC, skip past the first two elements
- if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//")))
- separatorPos = tmpPath.indexOf(slash, 2);
- if (separatorPos != -1)
-#endif
- separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
- QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
- if (!nonSymlinks.contains(prefix)) {
- fi.setFile(prefix);
- if (fi.isSymLink()) {
- QString target = fi.symLinkTarget();
- if (separatorPos != -1) {
- if (fi.isDir() && !target.endsWith(slash))
- target.append(slash);
- target.append(tmpPath.mid(separatorPos));
- }
- tmpPath = QDir::cleanPath(target);
- separatorPos = 0;
-
- if (known.contains(tmpPath))
- return QString();
- known.insert(tmpPath);
- } else {
- nonSymlinks.insert(prefix);
- }
- }
- } while (separatorPos != -1);
-
- return QDir::cleanPath(tmpPath);
- }
-
- QFile* archive() const
- {
- if( archives[ zipFileName ] == 0 )
- archives[ zipFileName ] = new QFile( zipFileName );
- return archives[ zipFileName ];
- }
-
- const Lib7z::File& file() const
- {
- if( currentFile.path.isEmpty() )
- currentFile = file( fileName );
- return currentFile;
- }
-
- const QVector< Lib7z::File >& list() const
- {
- if( currentContents[ zipFileName ].isEmpty() )
- {
- QFile* const archive = this->archive();
- try {
- if( !archive->open( QIODevice::ReadOnly ) ) {
- qWarning("Could not open %s for reading", qPrintable(zipFileName) );
- return currentContents[ zipFileName ];
- }
- currentContents[ zipFileName ] = Lib7z::listArchive( archive );
- } catch ( const Lib7z::SevenZipException& e ) {
- qWarning() << e.message();
- }
- archive->close();
- }
- return currentContents[ zipFileName ];
- }
-
- Lib7z::File file( const QString& path ) const
- {
- QString p = QDir::cleanPath( path ).toLower();
- const QLatin1Char sep( '/' );
- while( p.endsWith( sep ) )
- p.chop( 1 );
- while( p.startsWith( sep ) )
- p.remove( 0, 1 );
-
- const Lib7z::File* const f = currentFiles[ zipFileName ][ p ];
- if( f != 0 )
- return *f;
-
- const QVector<Lib7z::File>& files = list();
- for( QVector< Lib7z::File >::const_iterator it = files.begin(); it != files.end(); ++it )
- {
- QString n = it->path.toLower();
- while( n.endsWith( sep ) )
- n.chop( 1 );
-
- currentFiles[ zipFileName ][ n ] = &(*it);
-
- if( p == n )
- return *it;
- }
-
- return Lib7z::File();
- }
-
- QString providedFileName;
- QString zipFileName;
- QString fileName;
-
- mutable FileFlags flags;
-
- Lib7z::File openFile;
- QIODevice::OpenMode mode;
- QBuffer buffer;
-
- mutable Lib7z::File currentFile;
-};
-
-class KD7zEngineIterator : public QAbstractFileEngineIterator
-{
-public:
- KD7zEngineIterator( const QStringList& entries, QDir::Filters filters, const QStringList& nameFilters )
- : QAbstractFileEngineIterator( filters, nameFilters ),
- list( entries ),
- index( -1 )
- {
- }
-
- ~KD7zEngineIterator()
- {
- }
-
- /**
- * \reimp
- */
- bool hasNext() const
- {
- return index < list.size() - 1;
- }
-
- /**
- * \reimp
- */
- QString next()
- {
- if( !hasNext() )
- return QString();
- ++index;
- return currentFilePath();
- }
-
- /**
- * \reimp
- */
- QString currentFileName() const
- {
- return index < 0 ? QString() : list[ index ];
- }
-
-private:
- const QStringList list;
- int index;
-};
-
-KD7zEngine::KD7zEngine( const QString& fileName )
- : d( new Private( this ) )
-{
- d->setFileName( fileName );
-}
-
-KD7zEngine::~KD7zEngine()
-{
- //delete d;
-}
-
-/**
- * \reimp
- */
-QStringList KD7zEngine::entryList( QDir::Filters filters, const QStringList& filterNames ) const
-{
- QStringList result;
-
- const QVector<Lib7z::File>& files = d->list();
-
- static QLatin1Char sep( '/' );
-
- QString p = QDir::cleanPath( d->fileName ).toLower();
- if( !p.endsWith( sep ) )
- p += sep;
- while( p.startsWith( sep ) )
- p.remove( 0, 1 );
-
- const int slashes = p.count( sep );
-
- QList< QRegExp > regexps;
- for( QStringList::const_iterator it = filterNames.begin(); it != filterNames.end(); ++it )
- regexps.push_back( QRegExp( *it, Qt::CaseInsensitive, QRegExp::Wildcard ) );
-
- for( QVector< Lib7z::File >::const_iterator it = files.begin(); it != files.end(); ++it )
- {
- const QString n = it->path;
- if( !n.toLower().startsWith( p ) || n == p || ( n.count( sep ) != slashes ) )
- continue;
-
- if( slashes != n.left( n.length() - 1 ).count( sep ) )
- continue;
-
- if( matches( regexps, filters, *it ) )
- result.push_back( n.section( sep, -1, -1, QString::SectionSkipEmpty ) );
- }
-
- return result;
-}
-
-/**
- * \reimp
- */
-QAbstractFileEngine::Iterator* KD7zEngine::beginEntryList( QDir::Filters filters, const QStringList& filterNames )
-{
- return new KD7zEngineIterator( entryList( filters, filterNames ), filters, filterNames );
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::caseSensitive() const
-{
- return false;
-}
-
-/**
- * \reimp
- */
-void KD7zEngine::setFileName( const QString& file )
-{
- d->setFileName( file );
-}
-
-/**
- * \reimp
- */
-QString KD7zEngine::fileName( FileName file ) const
-{
- static const QLatin1Char sep( '/' );
- switch( file )
- {
- case DefaultName:
- return d->providedFileName;
- case BaseName:
- return QString::fromLatin1( "7z://%1%2" ).arg( d->zipFileName ).arg( d->fileName ).section( QChar::fromLatin1( '/' ), -1 );
- case PathName:
- return QString::fromLatin1( "7z://%1%2" ).arg( d->zipFileName ).arg( d->fileName ).section( QChar::fromLatin1( '/' ), 0, -2 );
- case AbsoluteName:
- {
- if( d->zipFileName.startsWith( sep ) )
- return QDir::cleanPath( d->providedFileName );
- return QDir::cleanPath( QString::fromLatin1( "%1/%2" ).arg( QDir::currentPath(), d->providedFileName ) );
- }
- case AbsolutePathName:
- return fileName( AbsoluteName ).section( sep, 0, -2 );
- case CanonicalName:
- return Private::canonicalized( fileName( AbsoluteName ) );
- case CanonicalPathName:
- return fileName( CanonicalName ).section( sep, 0, -2 );
- case BundleName:
- case LinkName:
- default:
- return QString();
- }
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::open( QIODevice::OpenMode mode )
-{
- //FIXME: should be unused cause we are using KDUpdater operations for extracting now
-
- if( d->mode != QIODevice::NotOpen )
- return false;
-
- const Lib7z::File file = d->file();
- if( file.isDirectory )
- return false; // can't open a directory, dude...
-
- if( mode & QIODevice::WriteOnly )
- return false; // no write support yet
-
- d->openFile = file;
- d->mode = mode;
-
- d->buffer.setData( QByteArray() );
- d->buffer.open( QIODevice::WriteOnly );
-
- QFile* f = d->archive();
- if( !f->open( QIODevice::ReadOnly ) )
- return false;
-
- bool error = true;
- try {
- Lib7z::extractArchive( f, d->openFile, &d->buffer );
- error = false;
- d->buffer.close();
- d->buffer.open( mode );
- f->close();
- } catch( const Lib7z::SevenZipException& e ) {
- qWarning() << e.message();
- d->buffer.close();
- f->close();
- }
-
- return !error;
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::flush()
-{
-#ifdef SEVENZ_PORT
- return d->openFileWrite != 0;
-#else
- return false;
-#endif
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::close()
-{
- if( d->mode == QIODevice::NotOpen )
- return false;
-
- flush();
- d->mode = QIODevice::NotOpen;
- d->openFile = Lib7z::File();
- d->buffer.close();
- d->buffer.setData( QByteArray() );
- return true;
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::atEnd() const
-{
- return d->buffer.atEnd();
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::seek( qint64 offset )
-{
- return d->buffer.seek( offset );
-}
-
-/**
- * \reimp
- */
-qint64 KD7zEngine::pos() const
-{
- return d->buffer.pos();
-}
-
-/**
- * \reimp
- */
-bool KD7zEngine::copy( const QString& newName )
-{
- //FIXME: should be unused cause we are using KDUpdater operations for extracting now
-
- QFile* f = d->archive();
- if( !f->open( QIODevice::ReadOnly ) )
- return false;
-
- QFile target( newName );
- if( !target.open( QIODevice::WriteOnly ) )
- {
- f->close();
- return false;
- }
-
- try
- {
- qDebug()<<"Extract from"<<d->zipFileName<<"to"<<newName;
- Lib7z::extractArchive( f, d->file(), &target );
- f->close();
- return true;
- }
- catch( const Lib7z::SevenZipException& e )
- {
- qWarning() << e.message();
- f->close();
- return false;
- }
-}
-
-/**
- * \reimp
- */
-qint64 KD7zEngine::read( char* data, qint64 maxlen )
-{
- return d->buffer.read( data, maxlen );
-}
-
-/**
- * \reimp
- */
-qint64 KD7zEngine::write( const char* data, qint64 len )
-{
-#ifdef SEVENZ_PORT
- const unsigned int l = static_cast< unsigned int >( qMin( len, 0x7fffffffLL ) );
- return zipWriteInFileInZip( d->openFileWrite, data, l ) == 0 ? l : -1;
-#else
- Q_UNUSED(data);
- Q_UNUSED(len);
- return -1;
-#endif
-}
-
-/**
- * \reimp
- */
-qint64 KD7zEngine::size() const
-{
- const Lib7z::File file = d->file();
- return file.uncompressedSize;
-}
-
-/**
- * \reimpl
- */
-QDateTime KD7zEngine::fileTime( FileTime time ) const
-{
- const Lib7z::File file = d->file();
-
- switch( time )
- {
- case CreationTime:
- if( d->fileName.isEmpty() )
- return QFileInfo( d->zipFileName ).created();
- case ModificationTime:
- return d->fileName.isEmpty() ? QFileInfo( d->zipFileName ).lastModified() : file.mtime;
- case AccessTime:
- return QFileInfo( d->zipFileName ).lastRead();
- default:
- return QDateTime();
- }
-}
-
-/**
- * \reimpl
- */
-bool KD7zEngine::mkdir( const QString& dirName, bool createParentDirectories ) const
-{
-#ifdef SEVENZ_PORT
- Q_UNUSED( createParentDirectories );
- static const QChar sep = QChar::fromLatin1( '/' );
- QString path;
- const QString root = QString::fromLatin1( "zip://%1" ).arg( d->zipFileName );
- const QString dir = dirName.mid( root.length() );
-
- for( int i = 0; i <= dir.count( sep ); ++i )
- {
- path += sep + dir.section( sep, i, i );
-
- if( !QDir( root + path ).exists() )
- {
- QString fileName = QString::fromLatin1( "%1/" ).arg( path );
- QFile file( d->zipFileName );
-
- zipFile openFileWrite = zipOpen( QFile::encodeName( d->zipFileName ).data(), file.exists() && file.size() > 0 ? APPEND_STATUS_ADDINZIP : APPEND_STATUS_CREATE );
- zip_fileinfo zi;
- const QDateTime dt = QDateTime::currentDateTime();
- zi.tmz_date.tm_sec = dt.time().second();
- zi.tmz_date.tm_min = dt.time().minute();
- zi.tmz_date.tm_hour = dt.time().hour();
- zi.tmz_date.tm_mday = dt.date().day();
- zi.tmz_date.tm_mon = dt.date().month() - 1;
- zi.tmz_date.tm_year = dt.date().year();
- zi.dosDate = 0;
- zi.internal_fa = 0;
- zi.external_fa = 0;
- while( fileName.startsWith( sep ) )
- fileName.remove( 0, 1 );
-
- if( fileName.isEmpty() )
- continue;
-
- const bool result = zipOpenNewFileInZip( openFileWrite, QFile::encodeName( fileName ).data(),
- &zi, 0, 0, 0, 0, 0, Z_DEFLATED, Z_DEFAULT_COMPRESSION ) == ZIP_OK;
- if( result )
- zipCloseFileInZip( openFileWrite );
- zipClose( openFileWrite, 0 );
- if( !result )
- return false;
- }
- }
- return true;
-#else
- Q_UNUSED(dirName);
- Q_UNUSED(createParentDirectories);
- return false;
-#endif
-}
-
-/**
- * \reimp
- */
-QAbstractFileEngine::FileFlags KD7zEngine::fileFlags( FileFlags type ) const
-{
- FileFlags result;
-
- static const QLatin1Char sep( '/' );
- static const QString sepString( sep );
-
- if( !QFile::exists( d->zipFileName ) )
- return result;
-
- if( d->flags != 0 && ( type & Refresh ) == 0 )
- return d->flags;
-
- const Lib7z::File file = d->file();
- const QString name = file.path;
-
- if( type & ExistsFlag )
- {
- if( d->fileName.isEmpty() || d->fileName == sepString )
- result |= ExistsFlag;
- else if( !name.isEmpty() )
- result |= ExistsFlag;
- }
- if( ( type & FileType ) && !name.isEmpty() && !file.isDirectory )
- result |= FileType;
- if( ( ( type & DirectoryType ) && file.isDirectory ) || ( name.isEmpty() && ( result & ExistsFlag ) ) )
- result |= DirectoryType;
- if( ( type & DirectoryType ) && ( d->fileName.isEmpty() || d->fileName == sepString ) )
- result |= DirectoryType;
-
- if( ( type & 0x7777 ) )
- result |= ( static_cast< QAbstractFileEngine::FileFlags >( static_cast< quint32 >( file.permissions ) ) & type );
-
- d->flags = result;
-
- return result;
-}
diff --git a/installerbuilder/common/kd7zengine.h b/installerbuilder/common/kd7zengine.h
deleted file mode 100644
index 71cd7da77..000000000
--- a/installerbuilder/common/kd7zengine.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#ifndef KD7ZENGINE_H
-#define KD7ZENGINE_H
-
-#include <QtCore/QAbstractFileEngine>
-#include <KDToolsCore/pimpl_ptr.h>
-
-#include "installer_global.h"
-
-class INSTALLER_EXPORT KD7zEngine : public QAbstractFileEngine
-{
-public:
- explicit KD7zEngine( const QString& fileName );
- ~KD7zEngine();
-
- bool caseSensitive() const;
-
- FileFlags fileFlags( FileFlags type = FileInfoAll ) const;
- QString fileName( FileName file = DefaultName ) const;
- QDateTime fileTime( FileTime time ) const;
-
- bool copy( const QString& newName );
-
- bool atEnd() const;
- qint64 size() const;
-
- bool seek( qint64 offset );
- qint64 pos() const;
-
- bool open( QIODevice::OpenMode mode );
- bool close();
- bool flush();
-
- bool mkdir( const QString& dirName, bool createParentDirectories ) const;
-
- QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const;
- Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames );
-
- void setFileName( const QString& file );
-
- qint64 read( char* data, qint64 maxlen );
- qint64 write( const char* data, qint64 len );
-
-private:
- class Private;
- kdtools::pimpl_ptr<Private> d;
-};
-
-#endif // KD7ZENGINE_H
diff --git a/installerbuilder/common/kd7zenginehandler.h b/installerbuilder/common/kd7zenginehandler.h
deleted file mode 100644
index 4c06d983e..000000000
--- a/installerbuilder/common/kd7zenginehandler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#ifndef KD7ZENGINEHANDLER_H
-#define KD7ZENGINEHANDLER_H
-
-#include <QtCore/QAbstractFileEngineHandler>
-
-#include "installer_global.h"
-
-class INSTALLER_EXPORT KD7zEngineHandler : public QAbstractFileEngineHandler
-{
-public:
- QAbstractFileEngine* create( const QString& filename ) const;
-};
-
-#endif // KD7ZENGINEHANDLER_H
diff --git a/installerbuilder/common/repository.cpp b/installerbuilder/common/repository.cpp
index ecd4d8a98..c58ea5aac 100644
--- a/installerbuilder/common/repository.cpp
+++ b/installerbuilder/common/repository.cpp
@@ -32,27 +32,53 @@
**************************************************************************/
#include "repository.h"
-using namespace QInstaller;
+namespace QInstaller {
-Repository::Repository() : m_required( false ) {
+/*
+ Constructs an invalid Repository object.
+*/
+Repository::Repository()
+{
}
-void Repository::setUrl( const QUrl& url ) {
- m_url = url;
+/*!
+ Constructs a new repository by setting it's address to \a url.
+*/
+Repository::Repository(const QUrl &url)
+ : m_url(url)
+{
}
-bool Repository::isValid() const {
+/*!
+ Returns true if the repository URL is valid; otherwise returns false.
+
+ Note: The URL is simpley run through a conformance test. It is not checked that the repository
+ actually exists.
+*/
+bool Repository::isValid() const
+{
return m_url.isValid();
}
-QUrl Repository::url() const {
+/*!
+ Returns the URL of the repository. By default an invalid \sa QUrl is returned.
+*/
+QUrl Repository::url() const
+{
return m_url;
}
-void Repository::setRequired( bool r ) {
- m_required = r;
+/*!
+ Sets the repository URL to the one specified at \a url.
+*/
+void Repository::setUrl(const QUrl& url)
+{
+ m_url = url;
+}
+
+bool Repository::operator==(const Repository &repository) const
+{
+ return m_url == repository.m_url;
}
-bool Repository::required() const {
- return m_required;
}
diff --git a/installerbuilder/common/repository.h b/installerbuilder/common/repository.h
index e6680b9f0..a7389f6ff 100644
--- a/installerbuilder/common/repository.h
+++ b/installerbuilder/common/repository.h
@@ -26,34 +26,36 @@
#ifndef REPOSITORY_H
#define REPOSITORY_H
-#include <QUrl>
-
#include "installer_global.h"
+#include <QtCore/QUrl>
+
namespace QInstaller {
- class INSTALLER_EXPORT Repository
- {
- public:
- Repository();
- void setUrl( const QUrl& url );
- QUrl url() const;
+class INSTALLER_EXPORT Repository
+{
+public:
+ Repository();
+ explicit Repository(const QUrl &url);
+
+ bool isValid() const;
- bool isValid() const;
+ QUrl url() const;
+ void setUrl(const QUrl& url);
- void setRequired( bool r );
+ uint qHash(const Repository &repository);
+ bool operator==(const Repository &repository) const;
- /**
- * returns whether the repository is required for installation. If a
- * required repository cannot be reached or an error occurrs accessing
- * it, the installer will fail.
- */
- bool required() const;
+private:
+ QUrl m_url;
+};
- private:
- bool m_required;
- QUrl m_url;
- };
+inline uint qHash(const Repository &repository)
+{
+ return qHash(repository.url().toString());
}
+
+} // namespace QInstaller
+
#endif // REPOSITORY_H
diff --git a/installerbuilder/common/repositorygen.cpp b/installerbuilder/common/repositorygen.cpp
index 8e4d1d350..15db90925 100644
--- a/installerbuilder/common/repositorygen.cpp
+++ b/installerbuilder/common/repositorygen.cpp
@@ -46,6 +46,7 @@
#include <QDomAttr>
#include <QDomDocument>
#include <QTemporaryFile>
+#include <QVector>
#include "lib7z_facade.h"
@@ -53,10 +54,12 @@
using namespace QInstaller;
+QT_BEGIN_NAMESPACE
static bool operator==(const PackageInfo& lhs, const PackageInfo& rhs)
{
return lhs.name == rhs.name && lhs.version == rhs.version;
}
+QT_END_NAMESPACE
static QVector<PackageInfo> collectAvailablePackages(const QString& packagesDirectory)
{
diff --git a/installerbuilder/common/repositorygen.h b/installerbuilder/common/repositorygen.h
index 0c092ae6d..9d2d8a5f3 100644
--- a/installerbuilder/common/repositorygen.h
+++ b/installerbuilder/common/repositorygen.h
@@ -28,8 +28,7 @@
#include <QString>
#include <QStringList>
-
-template <typename T> class QVector;
+#include <QVector>
namespace QInstaller {
struct PackageInfo {
diff --git a/installerbuilder/common/utils.cpp b/installerbuilder/common/utils.cpp
index 39b53a470..887da30d7 100644
--- a/installerbuilder/common/utils.cpp
+++ b/installerbuilder/common/utils.cpp
@@ -92,15 +92,13 @@ std::ostream& QInstaller::stdverbose()
{
static std::fstream null;
#ifdef Q_WS_WIN
- // TODO: this one get leaked
- static debugstream& stream = *(new debugstream);
+ static debugstream stream;
#else
static std::ostream& stream = std::cout;
#endif
- if( verb )
+ if (verb)
return stream;
- else
- return null;
+ return null;
}
std::ostream& QInstaller::operator<<( std::ostream& os, const QUrl& url )
@@ -221,6 +219,7 @@ QInstaller::VerboseWriter& QInstaller::verbose()
}
#ifdef Q_OS_WIN
+// taken from qcoreapplication_p.h
template<typename Char>
static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
{
@@ -305,3 +304,50 @@ QStringList QInstaller::parseCommandLineArgs(int argc, char **argv)
return arguments;
}
#endif
+
+#ifdef Q_OS_WIN
+// taken from qprocess_win.cpp
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString args;
+ if (!program.isEmpty()) {
+ QString programName = program;
+ if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"'))
+ && programName.contains(QLatin1Char(' '))) {
+ programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
+ }
+ programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+
+ // add the prgram as the first arg ... it works better
+ args = programName + QLatin1Char(' ');
+ }
+
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // in the case of \" already being in the string the \ must also be escaped
+ tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
+ // escape a single " because the arguments will be parsed
+ tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ QString endQuote(QLatin1Char('\"'));
+ int i = tmp.length();
+ while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ --i;
+ endQuote += QLatin1Char('\\');
+ }
+ args += QLatin1String(" \"") + tmp.left(i) + endQuote;
+ } else {
+ args += QLatin1Char(' ') + tmp;
+ }
+ }
+ return args;
+}
+
+QString QInstaller::createCommandline(const QString &program, const QStringList &arguments)
+{
+ return qt_create_commandline(program, arguments);
+}
+#endif
diff --git a/installerbuilder/common/utils.h b/installerbuilder/common/utils.h
index e570e2bc8..a479e6f70 100644
--- a/installerbuilder/common/utils.h
+++ b/installerbuilder/common/utils.h
@@ -26,25 +26,19 @@
#ifndef QINSTALLER_UTILS_H
#define QINSTALLER_UTILS_H
-#include <QtCore/QCryptographicHash>
-#include <QtCore/QFile>
-#include <QtCore/QTextStream>
+#include "installer_global.h"
+
#include <QtCore/QBuffer>
+#include <QtCore/QCryptographicHash>
+#include <QtCore/QHash>
#include <QtCore/QUrl>
-
-#include "installer_global.h"
+#include <QtCore/QTextStream>
#include <ostream>
-class QByteArray;
+QT_BEGIN_NAMESPACE
class QIODevice;
-class QString;
-class QUrl;
-
-template< typename T >
-class QList;
-
-template<typename K, typename V> class QHash;
+QT_END_NAMESPACE
namespace QInstaller
{
@@ -53,13 +47,14 @@ namespace QInstaller
QString INSTALLER_EXPORT replaceVariables( const QHash<QString,QString>& vars, const QString &str );
QString INSTALLER_EXPORT replaceWindowsEnvironmentVariables( const QString &str );
QStringList INSTALLER_EXPORT parseCommandLineArgs(int argc, char **argv);
+#ifdef Q_OS_WIN
+ QString createCommandline(const QString &program, const QStringList &arguments);
+#endif
void INSTALLER_EXPORT setVerbose( bool v );
bool INSTALLER_EXPORT isVerbose();
INSTALLER_EXPORT std::ostream& stdverbose();
-
-
INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QUrl& url );
INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QString& string );
INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QByteArray& array );
@@ -93,6 +88,7 @@ namespace QInstaller
inline VerboseWriter &operator<<(std::string &t) { stdverbose() << t; stream << QString::fromStdString(t); return *this; }
inline VerboseWriter &operator<<(const QByteArray &t) { stdverbose() << t; stream << t; return *this; }
inline VerboseWriter &operator<<(const QString &t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(const QStringRef &t) { return verbose() << t.toString(); }
inline VerboseWriter &operator<<(const QLatin1String &t) { stdverbose() << t; stream << t; return *this; }
inline VerboseWriter &operator<<(const char *t) { stdverbose() << t; stream << t; return *this; }
inline VerboseWriter &operator<<(const QUrl &t) { return verbose() << t.toString(); }
diff --git a/installerbuilder/common/zipjob.h b/installerbuilder/common/zipjob.h
index 8107482d6..77ad833a7 100644
--- a/installerbuilder/common/zipjob.h
+++ b/installerbuilder/common/zipjob.h
@@ -29,12 +29,16 @@
#include <QProcess>
#include <QRunnable>
+QT_BEGIN_NAMESPACE
class QDir;
class QIODevice;
class QStringList;
+QT_END_NAMESPACE
-class ZipJob : public QObject, public QRunnable {
+class ZipJob : public QObject, public QRunnable
+{
Q_OBJECT
+
public:
ZipJob();
~ZipJob();
diff --git a/installerbuilder/installerbase/installerbase.cpp b/installerbuilder/installerbase/installerbase.cpp
index 1c969e9f3..1611cebe8 100644
--- a/installerbuilder/installerbase/installerbase.cpp
+++ b/installerbuilder/installerbase/installerbase.cpp
@@ -30,73 +30,36 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-
-// This file contains the base part of the installer.
-// It lists the files and features the installer should handle.
-
-#include "qinstaller.h"
-#include "qinstallercomponentmodel.h"
-#include "qinstallercomponent.h"
-#include "qinstallergui.h"
-#include "qinstallerglobal.h"
-#include "init.h"
-#include "lib7z_facade.h"
-#include "common/installersettings.h"
+#include "common/binaryformat.h"
+#include "common/errors.h"
#include "common/fileutils.h"
+#include "common/installersettings.h"
#include "common/utils.h"
#include "fsengineserver.h"
+#include "init.h"
+#include "installerbasecommons.h"
+#include "lib7z_facade.h"
+#include "qinstallerglobal.h"
+#include "qinstallergui.h"
+#include "tabcontroller.h"
#include "updater.h"
-#include <QtCore/QBuffer>
-#include <QtCore/QDir>
-#include <QtCore/QDirIterator>
-#include <QtCore/QFileInfo>
-#include <QtCore/QResource>
-#include <QtCore/QObject>
-#include <QtCore/QSharedPointer>
-#include <QtCore/QTimer>
+#include <qinstaller.h>
+
#include <QtCore/QTranslator>
-#include <QtCore/QUrl>
-#include <QtCore/QPointer>
-#include <QtCore/QSettings>
#include <QtCore/QThread>
#include <QtGui/QApplication>
-#include <QtGui/QTabWidget>
-#include <QtGui/QLabel>
-#include <QtGui/QMessageBox>
-#include <QtGui/QVBoxLayout>
#include <QtNetwork/QNetworkProxyFactory>
-#include <KDToolsCore/KDSelfRestarter>
-#include <KDToolsCore/KDRunOnceChecker>
-
#include <KDUpdater/Application>
-#include <KDUpdater/UpdateSourcesInfo>
#include <KDUpdater/PackagesInfo>
-#include <KDUpdater/Update>
-#include <KDUpdater/UpdateFinder>
-#include <KDUpdater/UpdateOperationFactory>
-
-#include <KDUpdater/UpdateOperation>
-// QInstallerGui is base of the Gui part of an installer, i.e.
-// the "main installer wizard". In the simplest case it's just
-// a sequence of "standard" wizard pages. A few commonly used
-// ones are provided already in qinstallergui.h.
-
-#include "common/binaryformat.h"
-#include "common/binaryformatenginehandler.h"
-#include "common/errors.h"
-#include "common/range.h"
+#include <KDToolsCore/KDSelfRestarter>
+#include <KDToolsCore/KDRunOnceChecker>
#include <iostream>
-#include <memory>
-
-#include "installerbasecommons.h"
-#include "maintabwidget.h"
-#include "tabcontroller.h"
using namespace QInstaller;
using namespace QInstallerCreator;
@@ -110,21 +73,20 @@ public:
}
};
-static void printUsage(bool isInstaller, const QString &productName,
- const QString &installerBinaryPath)
+static QList<Repository> repositories(const QStringList &arguments, const int index)
{
- QString str;
- if (isInstaller) {
- str = QString::fromLatin1(" [--script <scriptfile>] [<name>=<value>...]\n"
- "\n Runs the %1 installer\n"
- "\n --script runs the the installer non-interactively, without UI, using the "
- "script <scriptfile> to perform the installation.\n").arg(productName);
+ QList<Repository> repoList;
+ if (index < arguments.size()) {
+ QStringList items = arguments.at(index).split(QLatin1Char(','));
+ foreach (const QString &item, items) {
+ verbose() << "Adding custom repository:" << item << std::endl;
+ Repository rep(item);
+ repoList.append(rep);
+ }
} else {
- str = QString::fromLatin1(" [<name>=<value>...]\n\n Runs the %1 uninstaller.\n")
- .arg(productName);
+ std::cerr << "No repository specified" << std::endl;
}
- str = QLatin1String("\nUsage: ") + installerBinaryPath + str;
- std::cerr << qPrintable(str) << std::endl;
+ return repoList;
}
int main(int argc, char *argv[])
@@ -138,11 +100,7 @@ int main(int argc, char *argv[])
// this is the FSEngineServer as an admin rights process upon request:
if (args.count() >= 3 && args[1] == QLatin1String("--startserver")) {
QCoreApplication app(argc, argv);
-#ifdef FSENGINE_TCP
FSEngineServer* const server = new FSEngineServer(args[2].toInt());
-#else
- FSEngineServer* const server = new FSEngineServer(args[2]);
-#endif
if (args.count() >= 4)
server->setAuthorizationKey(args[3]);
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()));
@@ -153,8 +111,8 @@ int main(int argc, char *argv[])
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
QUrl proxyUrl(QString::fromLatin1(qgetenv("http_proxy")));
if (proxyUrl.isValid()) {
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(),
- proxyUrl.port(), proxyUrl.userName(), proxyUrl.password());
+ QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(),
+ proxyUrl.userName(), proxyUrl.password());
QNetworkProxy::setApplicationProxy(proxy);
}
#else
@@ -167,13 +125,9 @@ int main(int argc, char *argv[])
if (runCheck.isRunning(KDRunOnceChecker::ProcessList))
return 0;
- QInstaller::setVerbose(args.contains(QLatin1String("--verbose")));
- QInstaller::init();
- // load the embedded binary resource
- BinaryContent content = BinaryContent::readFromApplicationFile();
- content.registerEmbeddedQResources();
Updater u;
- return u.checkForUpdates(true) ? 0 : 1;
+ u.setVerbose(args.contains(QLatin1String("--verbose")));
+ return u.checkForUpdates() ? 0 : 1;
}
// from here, the "normal" installer binary is running
@@ -190,9 +144,6 @@ int main(int argc, char *argv[])
if (args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("Verbose")))
QInstaller::setVerbose(true);
- verbose() << "This is installerbase version " << INSTALLERBASE_VERSION << std::endl;
- verbose() << "ARGS: " << args << std::endl;
-
// install the default translator
const QString localeFile =
QString::fromLatin1(":/translations/qt_%1").arg(QLocale::system().name());
@@ -212,40 +163,43 @@ int main(int argc, char *argv[])
app.installTranslator(translator);
}
- verbose() << "resource tree before loading the in-binary resource: " << std::endl;
+ if (QInstaller::isVerbose()) {
+ verbose() << "This is installerbase version " << INSTALLERBASE_VERSION << std::endl;
+ verbose() << "ARGS: " << args << std::endl;
- QDir dir(QLatin1String(":/"));
- Q_FOREACH (const QString &i, dir.entryList()) {
- const QByteArray ba = i.toUtf8();
- verbose() << ba.constData() << std::endl;
+ verbose() << "resource tree before loading the in-binary resource: " << std::endl;
+
+ QDir dir(QLatin1String(":/"));
+ foreach (const QString &i, dir.entryList()) {
+ const QByteArray ba = i.toUtf8();
+ verbose() << ba.constData() << std::endl;
+ }
}
// register custom operations before reading the binary content cause they may used in
- // the uninstaller for the recorded list of during the installation performed operations.
+ // the uninstaller for the recorded list of during the installation performed operations
QInstaller::init();
// load the embedded binary resource
BinaryContent content = BinaryContent::readFromApplicationFile();
content.registerEmbeddedQResources();
- verbose() << "resource tree after loading the in-binary resource: " << std::endl;
+ // instantiate the installer we are actually going to use
+ QInstaller::Installer installer(content.magicmaker(), content.performedOperations());
- dir = QDir(QLatin1String(":/"));
- Q_FOREACH (const QString &i, dir.entryList())
- verbose() << QString::fromLatin1(":/%1").arg(i) << std::endl;
+ if (QInstaller::isVerbose()) {
+ verbose() << "resource tree after loading the in-binary resource: " << std::endl;
- dir = QDir(QLatin1String(":/metadata/"));
- Q_FOREACH (const QString &i, dir.entryList())
- verbose() << QString::fromLatin1(":/metadata/%1").arg(i) << std::endl;
+ QDir dir = QDir(QLatin1String(":/"));
+ foreach (const QString &i, dir.entryList())
+ verbose() << QString::fromLatin1(":/%1").arg(i) << std::endl;
- KDUpdater::Application updaterapp;
- QInstaller::Installer installer(content.magicmaker, content.performedOperations);
- installer.setUpdaterApplication(&updaterapp);
-
- const QString productName = installer.value(QLatin1String("ProductName"));
+ dir = QDir(QLatin1String(":/metadata/"));
+ foreach (const QString &i, dir.entryList())
+ verbose() << QString::fromLatin1(":/metadata/%1").arg(i) << std::endl;
+ }
QString controlScript;
- bool isUpdater = false;
QHash<QString, QString> params;
for (int i = 1; i < args.size(); ++i) {
const QString &argument = args.at(i);
@@ -262,9 +216,9 @@ int main(int argc, char *argv[])
if (i < args.size()) {
controlScript = args.at(i);
if (!QFileInfo(controlScript).exists())
- return INST_FAILED;
+ return Installer::Failure;
} else {
- return INST_FAILED;
+ return Installer::Failure;
}
} else if (argument == QLatin1String("--verbose") || argument == QLatin1String("Verbose")) {
installer.setVerbose(true);
@@ -274,103 +228,90 @@ int main(int argc, char *argv[])
#endif
} else if (argument == QLatin1String("--show-virtual-components")
|| argument == QLatin1String("ShowVirtualComponents")) {
- QInstaller::ComponentModel::setVirtualComponentsVisible(true);
QFont f;
f.setItalic(true);
- QInstaller::ComponentModel::setVirtualComponentsFont(f);
- } else if (argument == QLatin1String("--manage-packages")
- || argument == QLatin1String("ManagePackages")) {
+ Installer::setVirtualComponentsFont(f);
+ Installer::setVirtualComponentsVisible(true);
+ } else if ((argument == QLatin1String("--updater")
+ || argument == QLatin1String("Updater")) && installer.isUninstaller()) {
+ installer.setUpdater();
+ } else if ((argument == QLatin1String("--manage-packages")
+ || argument == QLatin1String("ManagePackages")) && installer.isUninstaller()) {
installer.setPackageManager();
- } else if (argument == QLatin1String("--updater") || argument == QLatin1String("Updater")) {
- isUpdater = true && !installer.isInstaller();
} else if (argument == QLatin1String("--help") || argument == QLatin1String("-h")) {
- return INST_SUCCESS;
+ return Installer::Success;
} else if (argument == QLatin1String("--addTempRepository")
|| argument == QLatin1String("--setTempRepository")) {
++i;
- if (i >= args.size()) {
- std::cerr << "No repository specified" << std::endl;
- return INST_FAILED;
- }
-
- QList<Repository> repoList;
- QStringList items = args.at(i).split(QLatin1Char(','));
- foreach(const QString &item, items) {
- verbose() << "Adding custom repository:" << item << std::endl;
- Repository rep;
- rep.setUrl(item);
- rep.setRequired(true);
- repoList.append(rep);
- }
+ QList<Repository> repoList = repositories(args, i);
+ if (repoList.isEmpty())
+ return Installer::Failure;
// We cannot use setRemoteRepositories as that is a synchronous call which "
// tries to get the data from server and this isn't what we want at this point
const bool replace = (argument == QLatin1String("--setTempRepository"));
installer.setTemporaryRepositories(repoList, replace);
+ } else if (argument == QLatin1String("--addRepository")) {
+ ++i;
+ QList<Repository> repoList = repositories(args, i);
+ if (repoList.isEmpty())
+ return Installer::Failure;
+ installer.addRepositories(repoList);
} else if (argument == QLatin1String("--no-force-installations")) {
verbose() << "Use no-force-installations" << std::endl;
} else {
std::cerr << "Unknown option: " << argument << std::endl;
- return INST_FAILED;
+ return Installer::Failure;
}
}
- if (!installer.isInstaller())
- installer.setPackageManager();
-
+ KDUpdater::Application updaterapp;
+ const QString &productName = installer.value(QLatin1String("ProductName"));
updaterapp.packagesInfo()->setApplicationName(productName);
updaterapp.packagesInfo()->setApplicationVersion(installer
.value(QLatin1String("ProductVersion")));
- updaterapp.addUpdateSource(productName, productName, QString(),
- QUrl(QLatin1String("resource://metadata/")), 0);
+ if (content.magicmaker() == MagicInstallerMarker) {
+ updaterapp.addUpdateSource(productName, productName, QString(),
+ QUrl(QLatin1String("resource://metadata/")), 0);
+ }
+ installer.setUpdaterApplication(&updaterapp);
// Create the wizard gui
TabController controller(0);
controller.setInstaller(&installer);
controller.setInstallerParams(params);
- controller.setApplication(&updaterapp);
controller.setControlScript(controlScript);
if (installer.isInstaller()) {
controller.setInstallerGui(new QtInstallerGui(&installer));
} else {
- controller.setTabWidget(new MainTabWidget());
controller.setInstallerGui(new QtUninstallerGui(&installer));
}
- int val = isUpdater ? controller.initUpdater() : controller.initPackageManager();
- if (val != TabController::SUCCESS)
- return val;
+ Installer::Status status = Installer::Status(controller.init());
+ if (status != Installer::Success)
+ return status;
const int result = app.exec();
if (result != 0)
return result;
if (installer.finishedWithSuccess())
- return INST_SUCCESS;
-
- const int status = installer.status();
- const TabController::Status controllerState = controller.getState();
-
- Q_ASSERT(status == Installer::InstallerFailed || status == Installer::InstallerSucceeded
- || status == Installer::InstallerCanceledByUser);
-
- if (controllerState == TabController::SUCCESS)
- return INST_SUCCESS;
+ return Installer::Success;
+ status = installer.status();
switch (status) {
- case Installer::InstallerSucceeded:
- return INST_SUCCESS;
+ case Installer::Success:
+ return status;
- case Installer::InstallerCanceledByUser:
- return INST_CANCELED;
+ case Installer::Canceled:
+ return status;
- case Installer::InstallerFailed:
default:
break;
}
- return INST_FAILED;
+ return Installer::Failure;
} catch(const Error &e) {
std::cerr << qPrintable(e.message()) << std::endl;
} catch (const std::exception &e) {
@@ -379,5 +320,5 @@ int main(int argc, char *argv[])
std::cerr << "Unknown error, aborting." << std::endl;
}
- return INST_FAILED;
+ return Installer::Failure;
}
diff --git a/installerbuilder/installerbase/installerbase.pro b/installerbuilder/installerbase/installerbase.pro
index 80446ed6c..1e34560c7 100644
--- a/installerbuilder/installerbase/installerbase.pro
+++ b/installerbuilder/installerbase/installerbase.pro
@@ -20,13 +20,11 @@ include(../libinstaller/libinstaller.pri)
QT += network
HEADERS += tabcontroller.h \
- installerbasecommons.h \
- maintabwidget.h
+ installerbasecommons.h
SOURCES = installerbase.cpp \
tabcontroller.cpp \
- installerbasecommons.cpp \
- maintabwidget.cpp
+ installerbasecommons.cpp
win32-msvc2005 {
CONFIG += embed_manifest_exe #msvc2008 is doing this automaticaly
diff --git a/installerbuilder/installerbase/installerbasecommons.cpp b/installerbuilder/installerbase/installerbasecommons.cpp
index 54d5d9af0..e43a3e120 100644
--- a/installerbuilder/installerbase/installerbasecommons.cpp
+++ b/installerbuilder/installerbase/installerbasecommons.cpp
@@ -32,20 +32,155 @@
**************************************************************************/
#include "installerbasecommons.h"
+#include <common/installersettings.h>
+#include <messageboxhandler.h>
#include <qinstaller.h>
-#include <qinstallergui.h>
-#include <QFileInfo>
-#include <QLabel>
-#include <QDir>
-#include <QTimer>
-#include <QVBoxLayout>
-
#include <qinstallercomponent.h>
-#include "installerbasecommons.h"
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QTimer>
+
+#include <QtGui/QLabel>
+#include <QtGui/QProgressBar>
+#include <QtGui/QRadioButton>
+#include <QtGui/QStackedWidget>
+#include <QtGui/QVBoxLayout>
+
+using namespace QInstaller;
+
+
+// -- IntroductionPageImpl
+
+IntroductionPageImpl::IntroductionPageImpl(QInstaller::Installer *installer)
+ : QInstaller::IntroductionPage(installer)
+{
+ QWidget *widget = new QWidget(this);
+ QVBoxLayout *layout = new QVBoxLayout(widget);
+
+ m_packageManager = new QRadioButton(tr("Package manager"), this);
+ layout->addWidget(m_packageManager);
+ m_packageManager->setChecked(installer->isPackageManager());
+ connect(m_packageManager, SIGNAL(toggled(bool)), this, SLOT(setPackageManager(bool)));
+
+ m_updateComponents = new QRadioButton(tr("Update components"), this);
+ layout->addWidget(m_updateComponents);
+ m_updateComponents->setChecked(installer->isUpdater());
+ connect(m_updateComponents, SIGNAL(toggled(bool)), this, SLOT(setUpdater(bool)));
+
+ m_removeAllComponents = new QRadioButton(tr("Remove all components"), this);
+ layout->addWidget(m_removeAllComponents);
+ m_removeAllComponents->setChecked(installer->isUninstaller());
+ connect(m_removeAllComponents, SIGNAL(toggled(bool)), this, SLOT(setUninstaller(bool)));
+ connect(m_removeAllComponents, SIGNAL(toggled(bool)), installer, SLOT(setCompleteUninstallation(bool)));
+
+ layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ m_label = new QLabel(this);
+ m_label->setWordWrap(true);
+ m_label->setText(tr("Retrieving information from remote installation sources..."));
+ layout->addWidget(m_label);
+
+ m_progressBar = new QProgressBar(this);
+ m_progressBar->setRange(0, 0);
+ layout->addWidget(m_progressBar);
+
+ layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ widget->setLayout(layout);
+ setWidget(widget);
+
+ installer->setCompleteUninstallation(installer->isUninstaller());
+}
+
+int IntroductionPageImpl::nextId() const
+{
+ if (installer()->isUninstaller())
+ return Installer::ReadyForInstallation;
+
+ if (installer()->isUpdater() || installer()->isPackageManager())
+ return Installer::ComponentSelection;
+
+ return QInstaller::IntroductionPage::nextId();
+}
-TargetDirectoryPageImpl::TargetDirectoryPageImpl(QInstaller::Installer *installer)
- : QInstaller::TargetDirectoryPage(installer)
+void IntroductionPageImpl::showAll()
+{
+ showWidgets(true);
+}
+
+void IntroductionPageImpl::hideAll()
+{
+ showWidgets(false);
+}
+
+void IntroductionPageImpl::showMetaInfoUdate()
+{
+ showWidgets(false);
+ m_label->setVisible(true);
+ m_progressBar->setVisible(true);
+}
+
+void IntroductionPageImpl::showMaintenanceTools()
+{
+ showWidgets(true);
+ m_label->setVisible(false);
+ m_progressBar->setVisible(false);
+}
+
+void IntroductionPageImpl::setMaintenanceToolsEnabled(bool enable)
+{
+ m_packageManager->setEnabled(enable);
+ m_updateComponents->setEnabled(enable);
+ m_removeAllComponents->setEnabled(enable);
+}
+
+void IntroductionPageImpl::message(KDJob *job, const QString &msg)
+{
+ Q_UNUSED(job)
+ m_label->setText(msg);
+}
+
+void IntroductionPageImpl::setUpdater(bool value)
+{
+ if (value) {
+ installer()->setUpdater();
+ emit initUpdater();
+ }
+}
+
+void IntroductionPageImpl::setUninstaller(bool value)
+{
+ if (value) {
+ installer()->setUninstaller();
+ emit initUninstaller();
+ }
+}
+
+void IntroductionPageImpl::setPackageManager(bool value)
+{
+ if (value) {
+ installer()->setPackageManager();
+ emit initPackageManager();
+ }
+}
+
+void IntroductionPageImpl::showWidgets(bool show)
+{
+ m_label->setVisible(show);
+ m_progressBar->setVisible(show);
+ m_packageManager->setVisible(show);
+ m_updateComponents->setVisible(show);
+ m_removeAllComponents->setVisible(show);
+}
+
+
+// -- TargetDirectoryPageImpl
+
+/*!
+ A custom target directory selection based due to the no-space restriction...
+*/
+TargetDirectoryPageImpl::TargetDirectoryPageImpl(Installer *installer)
+ : TargetDirectoryPage(installer)
{
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::red);
@@ -53,19 +188,13 @@ TargetDirectoryPageImpl::TargetDirectoryPageImpl(QInstaller::Installer *installe
m_warningLabel = new QLabel(this);
m_warningLabel->setPalette(palette);
- insertWidget(m_warningLabel, QLatin1String( "MessageLabel" ), 2);
+ insertWidget(m_warningLabel, QLatin1String("MessageLabel"), 2);
}
-QString TargetDirectoryPageImpl::targetDirWarning() const {
- const QString td = targetDir();
- if ( td.contains( QLatin1Char( ' ' ) ) )
+QString TargetDirectoryPageImpl::targetDirWarning() const
+{
+ if (targetDir().contains(QLatin1Char(' ')))
return TargetDirectoryPageImpl::tr("The installation path must not contain any space.");
- const QFileInfo targetDirInfo = QFileInfo( td );
-// if ( targetDirInfo.isDir() && !targetDirInfo.isWritable() )
-// return TargetDirectoryPageImpl::tr("Cannot write to folder %1.").arg( td );
- const QString parentDir = QFileInfo( td ).dir().absolutePath();
-// if ( !targetDirInfo.exists() && !QFileInfo( parentDir ).isWritable() )
-// return TargetDirectoryPageImpl::tr("Cannot write to folder %1.").arg( parentDir );
return QString();
}
@@ -77,164 +206,181 @@ bool TargetDirectoryPageImpl::isComplete() const
return warning.isEmpty();
}
-bool TargetDirectoryPageImpl::askQuestion( const QString& identifier, const QString& message ) {
- QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- identifier,
- TargetDirectoryPageImpl::tr("Warning"),
- message,
- QMessageBox::Yes | QMessageBox::No);
- QTimer::singleShot( 100, wizard()->page( nextId() ), SLOT( repaint() ) );
+bool TargetDirectoryPageImpl::askQuestion(const QString &identifier, const QString &message)
+{
+ QMessageBox::StandardButton bt =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), identifier,
+ TargetDirectoryPageImpl::tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
+ QTimer::singleShot(100, wizard()->page(nextId()), SLOT(repaint()));
return bt == QMessageBox::Yes;
}
-bool TargetDirectoryPageImpl::failWithWarning( const QString& identifier, const QString& message ) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- identifier,
- TargetDirectoryPageImpl::tr("Warning"),
- message);
- QTimer::singleShot( 100, wizard()->page( nextId() ), SLOT( repaint() ) );
+bool TargetDirectoryPageImpl::failWithWarning(const QString &identifier, const QString &message)
+{
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), identifier,
+ TargetDirectoryPageImpl::tr("Warning"), message);
+ QTimer::singleShot(100, wizard()->page(nextId()), SLOT(repaint()));
return false;
}
bool TargetDirectoryPageImpl::validatePage()
{
- if ( !isVisible() )
+ if (!isVisible())
return true;
- const QDir dir( targetDir() );
if (targetDir().isEmpty()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"), tr("Error"),
- tr( "The install directory cannot be empty, please specify a valid folder."),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr( "The install directory cannot be empty, please specify a valid folder"), QMessageBox::Ok);
return false;
}
+
+ const QDir dir(targetDir());
if (dir.isRelative()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"), tr("Error"),
- tr( "The install directory cannot be relative, please specify an absolute path."),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr("The install directory cannot be relative, please specify an absolute path."), QMessageBox::Ok);
return false;
}
- QString checkString;
+ QString checkString = targetDir();
#ifdef Q_OS_WIN
- checkString = targetDir().mid(2);
-#else
- checkString = targetDir();
+ // remove e.g. "c:"
+ checkString = checkString.mid(2);
#endif
+ // check if there are not allowed characters in the target path
if (checkString.contains(QRegExp(QLatin1String("[!@#$%^&*: ,;]")))) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"), tr("Error"),
- tr( "The install directory cannot contain !@#$%^&*:,; or spaces, please specify a valid folder."),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr("The install directory cannot contain !@#$%^&*:,; or spaces, please specify a valid folder."),
+ QMessageBox::Ok);
return false;
}
- QString remove = installer()->value(QLatin1String("RemoveTargetDir"));
+ const QString remove = installer()->value(QLatin1String("RemoveTargetDir"));
if (!QVariant(remove).toBool())
return true;
- const QFileInfo targetDirInfo = QFileInfo(targetDir());
- if (targetDirInfo.isDir()) {
- QFileInfo fi2(targetDir() + QDir::separator() + installer()->uninstallerName());
- // disallow root and home dirs if the target dir is set to be deleted on uninstall
- if ( dir == QDir::root() || dir == QDir::home() )
- {
+ // the directory exists and is empty...
+ if (dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty())
+ return true;
+
+ QFileInfo fi(targetDir());
+ if (fi.isDir()) {
+ if (dir == QDir::root() || dir == QDir::home()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"),
- tr( "Error" ),
- tr( "As the install directory is completely deleted installing in %1 is forbidden" ).arg( QDir::rootPath() ),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr("As the install directory is completely deleted installing in %1 is forbidden")
+ .arg(QDir::rootPath()), QMessageBox::Ok);
return false;
}
- if (fi2.exists())
- return askQuestion( QLatin1String("overwriteTargetDirectory"), TargetDirectoryPageImpl::tr("The folder you selected exists already and "
- "contains an installation.\nDo you want to overwrite it?") );
- else
- return askQuestion( QLatin1String("overwriteTargetDirectory"),
- tr( "You have selected an existing, non-empty folder for installation.\n"
- "Note that it will be completely wiped on uninstallation of this application.\n"
- "It is not advisable to install into this folder as installation might fail.\n"
- "Do you want to continue?" ) );
+
+ QString fileName = installer()->settings().uninstallerName();
+#if defined(Q_WS_MAC)
+ if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())
+ fileName += QLatin1String(".app/Contents/MacOS/") + fileName;
+#elif defined(Q_OS_WIN)
+ fileName += QLatin1String(".exe");
+#endif
+
+ QFileInfo fi2(targetDir() + QDir::separator() + fileName);
+ if (fi2.exists()) {
+ return askQuestion(QLatin1String("overwriteTargetDirectory"),
+ TargetDirectoryPageImpl::tr("The folder you selected exists already and contains an "
+ "installation.\nDo you want to overwrite it?"));
+ }
+
+ return askQuestion(QLatin1String("overwriteTargetDirectory"),
+ tr("You have selected an existing, non-empty folder for installation.\nNote that it will be "
+ "completely wiped on uninstallation of this application.\nIt is not advisable to install into "
+ "this folder as installation might fail.\nDo you want to continue?"));
+ } else if (fi.isFile() || fi.isSymLink()) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("WrongTargetDirectory"), tr("Error"),
+ tr("You have selected an existing file or symlink, please choose a different target for "
+ "installation."), QMessageBox::Ok);
+ return false;
}
return true;
}
-QtInstallerGui::QtInstallerGui(QInstaller::Installer *installer)
- : QInstaller::Gui(installer, 0)
+
+// -- QtInstallerGui
+
+QtInstallerGui::QtInstallerGui(Installer *installer)
+ : Gui(installer, 0)
{
- //addPage(new QInstaller::TargetDirectoryPage(installer));
- setPage( QInstaller::Installer::TargetDirectory, new TargetDirectoryPageImpl( installer ) );
- setPage( QInstaller::Installer::ComponentSelection, new QInstaller::ComponentSelectionPage( m_installer ) );
- setPage( QInstaller::Installer::LicenseCheck, new QInstaller::LicenseAgreementPage( installer ) );
+ setPage(Installer::Introduction, new IntroductionPageImpl(installer));
+ setPage(Installer::TargetDirectory, new TargetDirectoryPageImpl(installer));
+ setPage(Installer::ComponentSelection, new ComponentSelectionPage(m_installer));
+ setPage(Installer::LicenseCheck, new LicenseAgreementPage(installer));
#ifdef Q_OS_WIN
- setPage( QInstaller::Installer::StartMenuSelection, new QInstaller::StartMenuDirectoryPage( installer ) );
+ setPage(Installer::StartMenuSelection, new StartMenuDirectoryPage(installer));
#endif
- setPage( QInstaller::Installer::ReadyForInstallation, new QInstaller::ReadyForInstallationPage( installer ) );
- setPage( QInstaller::Installer::PerformInstallation, new QInstaller::PerformInstallationPage( installer ) );
- setPage( QInstaller::Installer::InstallationFinished, new QInstaller::FinishedPage( installer ) );
+ setPage(Installer::ReadyForInstallation, new ReadyForInstallationPage(installer));
+ setPage(Installer::PerformInstallation, new PerformInstallationPage(installer));
+ setPage(Installer::InstallationFinished, new FinishedPage(installer));
bool ok = false;
- const int startPage = installer->value( QLatin1String( "GuiStartPage" ) ).toInt( &ok );
- if( ok )
- setStartId( startPage );
+ const int startPage = installer->value(QLatin1String("GuiStartPage")).toInt(&ok);
+ if(ok)
+ setStartId(startPage);
}
void QtInstallerGui::init()
{
- if( m_installer->components( true ).count() == 1 )
- {
- wizardPageVisibilityChangeRequested( false, QInstaller::Installer::ComponentSelection );
- Q_ASSERT( ! m_installer->components().isEmpty() );
- m_installer->components().first()->setSelected( true );
- }
+ if (m_installer->components(true, m_installer->runMode()).count() == 1)
+ wizardPageVisibilityChangeRequested(false, Installer::ComponentSelection);
}
+
// -- QtUninstallerGui
-QtUninstallerGui::QtUninstallerGui(QInstaller::Installer *installer)
- : QInstaller::Gui(installer, 0)
+QtUninstallerGui::QtUninstallerGui(Installer *installer)
+ : Gui(installer, 0)
{
- setPage(QInstaller::Installer::ComponentSelection,
- new QInstaller::ComponentSelectionPage(m_installer));
- setPage(QInstaller::Installer::LicenseCheck, new QInstaller::LicenseAgreementPage(installer));
- setPage(QInstaller::Installer::ReadyForInstallation,
- new QInstaller::ReadyForInstallationPage(installer));
- setPage(QInstaller::Installer::PerformInstallation,
- new QInstaller::PerformInstallationPage(installer));
- setPage(QInstaller::Installer::InstallationFinished, new QInstaller::FinishedPage(installer));
-
- if (installer->isPackageManager()) {
- RestartPage* p = new QInstaller::RestartPage(installer);
- connect(p, SIGNAL(restart()), this, SIGNAL(gotRestarted()));
- setPage(QInstaller::Installer::InstallationFinished + 1, p);
- setPage(QInstaller::Installer::InstallationFinished + 2, new QInstaller::Page(installer));
- }
+ IntroductionPageImpl *intro = new IntroductionPageImpl(installer);
+ connect(intro, SIGNAL(initUpdater()), this, SLOT(updateRestartPage()));
+ connect(intro, SIGNAL(initUninstaller()), this, SLOT(updateRestartPage()));
+ connect(intro, SIGNAL(initPackageManager()), this, SLOT(updateRestartPage()));
+
+ setPage(Installer::Introduction, intro);
+ setPage(Installer::ComponentSelection, new ComponentSelectionPage(m_installer));
+ setPage(Installer::LicenseCheck, new LicenseAgreementPage(installer));
+ setPage(Installer::ReadyForInstallation, new ReadyForInstallationPage(installer));
+ setPage(Installer::PerformInstallation, new PerformInstallationPage(installer));
+ setPage(Installer::InstallationFinished, new FinishedPage(installer));
+
+ RestartPage *p = new RestartPage(installer);
+ connect(p, SIGNAL(restart()), this, SIGNAL(gotRestarted()));
+ setPage(Installer::InstallationFinished + 1, p);
+
+ if (installer->isUninstaller())
+ wizardPageVisibilityChangeRequested(false, Installer::InstallationFinished + 1);
}
void QtUninstallerGui::init()
{
- if(m_installer->components().isEmpty()) {
- wizardPageVisibilityChangeRequested(false, QInstaller::Installer::ComponentSelection);
- wizardPageVisibilityChangeRequested(false, QInstaller::Installer::LicenseCheck);
- }
+ const bool visible = !m_installer->components(false, m_installer->runMode()).isEmpty();
+
+ wizardPageVisibilityChangeRequested(visible, Installer::ComponentSelection);
+ wizardPageVisibilityChangeRequested(visible, Installer::LicenseCheck);
}
int QtUninstallerGui::nextId() const
{
const int next = QWizard::nextId();
- if (next == QInstaller::Installer::LicenseCheck) {
+ if (next == Installer::LicenseCheck) {
const int nextNextId = pageIds().value(pageIds().indexOf(next)+ 1, -1);
if (!m_installer->isPackageManager() && !m_installer->isUpdater())
return nextNextId;
- QList<QInstaller::Component*> components = m_installer->componentsToInstall(true);
+ QList<Component*> components = m_installer->componentsToInstall(m_installer->runMode());
if (components.isEmpty())
return nextNextId;
bool foundLicense = false;
- foreach (QInstaller::Component* component, components) {
+ foreach (Component* component, components) {
if (component->isInstalled())
continue;
foundLicense |= !component->licenses().isEmpty();
@@ -244,23 +390,8 @@ int QtUninstallerGui::nextId() const
return next;
}
-// -- GetMetaInfoProgressWidget
-
-GetMetaInfoProgressWidget::GetMetaInfoProgressWidget( QWidget* parent )
- : QWidget( parent )
-{
- QVBoxLayout* layout = new QVBoxLayout( this );
- setLayout(layout);
- m_label = new QLabel;
- m_label->setWordWrap( true );
- m_label->setText( tr("Retrieving information from remote installation sources...") );
- layout->addWidget( m_label );
-}
-QString GetMetaInfoProgressWidget::text() const
-{
- return m_label->text();
-}
-void GetMetaInfoProgressWidget::message( KDJob*, const QString& msg )
+void QtUninstallerGui::updateRestartPage()
{
- m_label->setText( msg );
+ wizardPageVisibilityChangeRequested((m_installer->isUninstaller() ? false : true),
+ Installer::InstallationFinished + 1);
}
diff --git a/installerbuilder/installerbase/installerbasecommons.h b/installerbuilder/installerbase/installerbasecommons.h
index da0502515..dd9888d92 100644
--- a/installerbuilder/installerbase/installerbasecommons.h
+++ b/installerbuilder/installerbase/installerbasecommons.h
@@ -26,51 +26,78 @@
#ifndef INSTALLERBASECOMMONS_H
#define INSTALLERBASECOMMONS_H
-#include <QObject>
#include <qinstallergui.h>
-
-
-class QFileInfo;
+QT_BEGIN_NAMESPACE
class QLabel;
class QString;
-//class
+class QProgressBar;
+QT_END_NAMESPACE
+
+
+// -- IntroductionPageImpl
+
+class IntroductionPageImpl : public QInstaller::IntroductionPage
+{
+ Q_OBJECT
+
+public:
+ explicit IntroductionPageImpl(QInstaller::Installer *installer);
+
+ int nextId() const;
-namespace QInstaller{
- class Installer;
-}
+ void showAll();
+ void hideAll();
+ void showMetaInfoUdate();
+ void showMaintenanceTools();
+ void setMaintenanceToolsEnabled(bool enable);
+
+public Q_SLOTS:
+ void message(KDJob *job, const QString &msg);
+
+Q_SIGNALS:
+ void initUpdater();
+ void initUninstaller();
+ void initPackageManager();
+
+private Q_SLOTS:
+ void setUpdater(bool value);
+ void setUninstaller(bool value);
+ void setPackageManager(bool value);
+
+private:
+ void showWidgets(bool show);
+
+private:
+ QLabel *m_label;
+ QProgressBar *m_progressBar;
+ QRadioButton *m_packageManager;
+ QRadioButton *m_updateComponents;
+ QRadioButton *m_removeAllComponents;
+};
-using namespace QInstaller;
-//using namespace QInstallerCreator;
-// A custom target directory selection based due to the no-space
-// restriction...
+// --TargetDirectoryPageImpl
class TargetDirectoryPageImpl : public QInstaller::TargetDirectoryPage
{
Q_OBJECT
+
public:
explicit TargetDirectoryPageImpl(QInstaller::Installer *installer);
QString targetDirWarning() const;
-
bool isComplete() const;
-
- bool askQuestion( const QString& identifier, const QString& message );
-
- bool failWithWarning( const QString& identifier, const QString& message );
-
+ bool askQuestion(const QString &identifier, const QString &message);
+ bool failWithWarning(const QString &identifier, const QString &message);
bool validatePage();
private:
QLabel *m_warningLabel;
};
-////////////////////////////////////////////////////////////////////
-//
-// QtInstallerGui
-//
-////////////////////////////////////////////////////////////////////
+
+// -- QtInstallerGui
class QtInstallerGui : public QInstaller::Gui
{
@@ -83,11 +110,7 @@ public:
};
-////////////////////////////////////////////////////////////////////
-//
-// QtUninstallerGui
-//
-////////////////////////////////////////////////////////////////////
+// -- QtUninstallerGui
class QtUninstallerGui : public QInstaller::Gui
{
@@ -98,26 +121,9 @@ public:
virtual void init();
virtual int nextId() const;
-};
-class GetMetaInfoProgressWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit GetMetaInfoProgressWidget( QWidget* parent = 0 );
- QString text() const;
-
-public Q_SLOTS:
- void message(KDJob*, const QString & msg);
-
-private:
- QLabel *m_label;
+private Q_SLOTS:
+ void updateRestartPage();
};
-
-const int INST_SUCCESS = 0;
-const int INST_FAILED = 1;
-const int INST_CANCELED = 2;
-
#endif // INSTALLERBASECOMMONS_H
diff --git a/installerbuilder/installerbase/maintabwidget.h b/installerbuilder/installerbase/maintabwidget.h
deleted file mode 100644
index 12c8301dc..000000000
--- a/installerbuilder/installerbase/maintabwidget.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#ifndef MAINTABWIDGET_H
-#define MAINTABWIDGET_H
-
-#include <QTabWidget>
-
-#include <KDToolsCore/pimpl_ptr>
-
-class MainTabWidget : public QTabWidget
-{
-Q_OBJECT
-public:
- explicit MainTabWidget( QWidget* parent = 0 );
- ~MainTabWidget(); //reimpl
- void setCloseWithoutWarning( bool value );
-Q_SIGNALS:
- void closeRequested();
-protected:
- void closeEvent( QCloseEvent * event ); //reimpl
-private:
- class Private;
- kdtools::pimpl_ptr<Private> d;
-};
-
-#endif // MAINTABWIDGET_H
diff --git a/installerbuilder/installerbase/tabcontroller.cpp b/installerbuilder/installerbase/tabcontroller.cpp
index b8bc740f1..03f689029 100644
--- a/installerbuilder/installerbase/tabcontroller.cpp
+++ b/installerbuilder/installerbase/tabcontroller.cpp
@@ -31,103 +31,55 @@
**
**************************************************************************/
#include "tabcontroller.h"
-
#include "installerbasecommons.h"
-#include "maintabwidget.h"
-
-#include <KDUpdater/Application>
-#include <KDUpdater/UpdateFinder>
-#include <KDUpdater/UpdateSourcesInfo>
-#include <KDUpdater/PackagesInfo>
-#include <common/installersettings.h>
#include <common/utils.h>
-#include <common/errors.h>
-
-#include <componentselectiondialog.h>
-#include <getrepositoriesmetainfojob.h>
#include <qinstaller.h>
#include <qinstallercomponent.h>
-#include <updater.h>
-#include <qinstallergui.h>
-#include <QtCore/QDebug>
-#include <QtCore/QHash>
#include <QtCore/QPointer>
-
-#include <QtGui/QDialog>
-#include <QtGui/QProgressDialog>
+#include <QtCore/QTimer>
#include <QtScript/QScriptEngine>
-#include <QtXml/QDomDocument>
-#include <QtXml/QDomElement>
+using namespace QInstaller;
+
+
+// -- TabController::Private
class TabController::Private
{
public:
Private();
~Private();
- void preselectInstalledPackages();
- QHash<QString, QString> m_params;
- bool m_updaterInitialized;
- bool m_packageManagerInitialized;
bool m_init;
+ bool m_updatesFetched;
+ bool m_allPackagesFetched;
+ bool m_introPageConnected;
+
QPointer<QInstaller::Gui> m_gui;
- QScopedPointer <Updater> m_updater;
- MainTabWidget* m_updaterGuiWidget;
QInstaller::Installer *m_installer;
- KDUpdater::Application *m_app;
+
QString m_controlScript;
- int m_Tab_Pos_Updater;
- int m_Tab_Pos_PackageManager;
- TabController::Status m_state;
- bool m_repoReached;
- bool m_repoUpdateNeeded;
+ QHash<QString, QString> m_params;
};
TabController::Private::Private()
- :
- m_updaterInitialized(false),
- m_packageManagerInitialized(false),
- m_init(false),
- m_gui(0),
- m_updater(0),
- m_updaterGuiWidget(0),
- m_installer(0),
- m_app(0),
- m_Tab_Pos_Updater(0),
- m_Tab_Pos_PackageManager(0),
- m_state(SUCCESS),
- m_repoReached(true),
- m_repoUpdateNeeded(true)
+ : m_init(false)
+ , m_updatesFetched(false)
+ , m_allPackagesFetched(false)
+ , m_introPageConnected(false)
+ , m_gui(0)
+ , m_installer(0)
{
}
TabController::Private::~Private()
{
- delete m_updaterGuiWidget;
delete m_gui;
}
-// the package manager should preselect the currently installed packages
-void TabController::Private::preselectInstalledPackages()
-{
- Q_ASSERT(m_installer->isPackageManager());
-
- QList<QInstaller::Component*>::const_iterator it;
- const QList<QInstaller::Component*> components = m_installer->components(true);
- for (it = components.begin(); it != components.end(); ++it) {
- QInstaller::Component* const comp = *it;
-
- //selection is allready done in QInstaller::createComponent method
- //const bool selected = m_app->packagesInfo()->findPackageInfo(comp->name()) > -1;
- //comp->setSelected(selected, InstallerMode, Component::InitializeComponentTreeSelectMode);
- if (!m_repoReached)
- comp->setEnabled(false);
- }
-}
// -- TabController
@@ -139,403 +91,172 @@ TabController::TabController(QObject *parent)
TabController::~TabController()
{
+ d->m_installer->writeUninstaller();
delete d;
}
-void TabController::setCurrentTab(int tab)
-{
- if (!d->m_updaterGuiWidget)
- return;
-
- d->m_updaterGuiWidget->setCurrentIndex((tab == PACKAGE_MANAGER_TAB)
- ? d->m_Tab_Pos_PackageManager : d->m_Tab_Pos_Updater);
- d->m_gui->callControlScriptMethod(QLatin1String((tab == PACKAGE_MANAGER_TAB)
- ? "PackageManagerSelectedCallback" : "UpdaterSelectedCallback"));
-}
-
-void TabController::setInstallerParams(const QHash<QString, QString> &params)
-{
- d->m_params = params;
-}
-
void TabController::setInstallerGui(QInstaller::Gui *gui)
{
d->m_gui = gui;
connect(d->m_gui, SIGNAL(gotRestarted()), this, SLOT(restartWizard()));
}
+void TabController::setControlScript (const QString &script)
+{
+ d->m_controlScript = script;
+}
+
void TabController::setInstaller(QInstaller::Installer *installer)
{
d->m_installer = installer;
}
-void TabController::setTabWidget(MainTabWidget *widget)
+void TabController::setInstallerParams(const QHash<QString, QString> &params)
{
- d->m_updaterGuiWidget = widget;
+ d->m_params = params;
}
-int TabController::initUpdater()
+// -- public slots
+
+int TabController::init()
{
- init(UPDATER_TAB);
+ if (!d->m_init) {
+ d->m_init = true;
+ // this should called as early as possible, to handle error messageboxes for example
+ if (!d->m_controlScript.isEmpty()) {
+ QInstaller::verbose() << "Non-interactive installation using script: "
+ << qPrintable(d->m_controlScript) << std::endl;
+
+ d->m_gui->loadControlScript(d->m_controlScript);
+ QScriptEngine *engine = d->m_gui->controlScriptEngine();
+ engine->globalObject().setProperty(QLatin1String("tabController"),
+ engine->newQObject(this));
+ }
- d->m_updaterGuiWidget->show();
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_PackageManager, false);
+ if (!d->m_installer->isInstaller())
+ d->m_gui->setWindowTitle(d->m_installer->value(QLatin1String("MaintenanceTitle")));
- if (d->m_repoUpdateNeeded) {
- int result = checkRepositories();
- if (result != INST_SUCCESS)
- return result;
+ IntroductionPageImpl *introPage =
+ qobject_cast<IntroductionPageImpl*>(d->m_gui->page(Installer::Introduction));
+ connect(introPage, SIGNAL(initUpdater()), this, SLOT(initUpdater()));
+ connect(introPage, SIGNAL(initPackageManager()), this, SLOT(initPackageManager()));
}
- d->m_updaterInitialized = true;
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_PackageManager, true);
+ d->m_updatesFetched = false;
+ d->m_allPackagesFetched = false;
- return INST_SUCCESS;
-}
+ if (d->m_installer->isUpdater())
+ return initUpdater();
-void TabController::setApplication(KDUpdater::Application *app)
-{
- d->m_app = app;
-}
+ if (d->m_installer->isUninstaller())
+ return initUninstaller();
-void TabController::setControlScript (const QString &script)
-{
- d->m_controlScript = script;
+ return initPackageManager();
}
-void TabController::init(Tabs curTab)
+int TabController::initUpdater()
{
- if (d->m_updaterGuiWidget && !d->m_init) {
- d->m_updater.reset(new Updater);
- d->m_updater->setInstaller(d->m_installer);
-
- ComponentSelectionDialog* w = new ComponentSelectionDialog(d->m_installer);
- d->m_updater->setUpdaterGui(w);
- d->m_updater->init();
- d->m_Tab_Pos_Updater = d->m_updaterGuiWidget->addTab(w, QLatin1String("Updater"));
- d->m_Tab_Pos_PackageManager = d->m_updaterGuiWidget->addTab(d->m_gui,
- QLatin1String("Package manager"));
-
- if (d->m_updaterGuiWidget->widget(d->m_Tab_Pos_Updater)->layout())
- verbose() << " tab widget updater tab has layout " << std::endl;
-
- if (d->m_updaterGuiWidget->widget(d->m_Tab_Pos_PackageManager)->layout())
- verbose() << " tab widget package tab has layout " << std::endl;
-
- if (d->m_updaterGuiWidget->layout())
- verbose() << " tab has layout " << std::endl;
-
- if (curTab == PACKAGE_MANAGER_TAB)
- d->m_updaterGuiWidget->setCurrentIndex(d->m_Tab_Pos_PackageManager);
-
- connect(d->m_updater.data(), SIGNAL(updateFinished(bool)), this, SLOT(updaterFinished(bool)));
- connect(d->m_updater.data(), SIGNAL(updateFinished(bool)), w, SLOT(refreshDialog()));
- connect(w, SIGNAL(rejected()), this, SLOT(updaterFinishedWithError()));
- connect(w, SIGNAL(finished(int)), this, SLOT(updaterFinished(int)));
- connect(this, SIGNAL(refresh()), w, SLOT(refreshDialog()));
- connect(d->m_gui, SIGNAL(accepted()), this, SLOT(finished()));
- connect(d->m_gui, SIGNAL(rejected()), this, SLOT(finished()));
- connect(d->m_updaterGuiWidget, SIGNAL(currentChanged(int)), this, SLOT(changeCurrentTab(int)));
- connect(d->m_updaterGuiWidget, SIGNAL(closeRequested()), this, SLOT(close()),
- Qt::QueuedConnection);
- connect(d->m_installer, SIGNAL(installationStarted()), this, SLOT(disableUpdaterTab()));
- connect(d->m_installer, SIGNAL(uninstallationStarted()), this, SLOT(disableUpdaterTab()));
- d->m_init = true;
- d->m_updaterGuiWidget->setWindowTitle(d->m_installer->value(QLatin1String("MaintenanceTitle")));
- }
-}
+ IntroductionPageImpl *introPage = introductionPage();
-void TabController::close()
-{
- if (d->m_updaterGuiWidget && !d->m_gui.isNull())
- d->m_gui->cancelButtonClicked();
-}
+ introPage->showAll();
+ introPage->setComplete(false);
+ introPage->setMaintenanceToolsEnabled(false);
-void TabController::disableUpdaterTab()
-{
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, false);
-}
+ if (!d->m_introPageConnected) {
+ d->m_introPageConnected = true;
+ connect(d->m_installer, SIGNAL(metaJobInfoMessage(KDJob*,QString)), introPage,
+ SLOT(message(KDJob*, QString)));
+ }
-void TabController::enableUpdaterTab()
-{
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, true);
-}
+ d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->show();
-void TabController::restartWizard()
-{
- enableUpdaterTab();
- d->m_installer->reset(d->m_params);
- checkRepositories();
+ if (!d->m_updatesFetched)
+ d->m_updatesFetched = d->m_installer->fetchUpdaterPackages();
- if (d->m_installer->isPackageManager())
- d->preselectInstalledPackages();
-}
+ // Initialize the gui. Needs to be done after check repositories as only then the ui can handle
+ // hide of pages depenging on the components.
+ d->m_gui->init();
+ d->m_gui->callControlScriptMethod(QLatin1String("UpdaterSelectedCallback"));
+ d->m_gui->triggerControlScriptForCurrentPage();
-void TabController::finished()
-{
- d->m_installer->writeUninstaller();
- d->m_updaterGuiWidget->setCloseWithoutWarning(true);
- bool res = d->m_updaterGuiWidget->close();
- bool res2 = d->m_updaterGuiWidget->close();
- verbose() << " widget was closed ? : " << res << " " << res2 << std::endl;
+ introPage->showMaintenanceTools();
+ introPage->setMaintenanceToolsEnabled(true);
+ introPage->setComplete(true);
+
+ if (d->m_installer->status() == Installer::Canceled)
+ return Installer::Canceled;
+ return Installer::Success;
}
-void TabController::updaterFinishedWithError()
+int TabController::initUninstaller()
{
- d->m_installer->writeUninstaller();
- d->m_state = CANCELED;
+ IntroductionPageImpl *introPage = introductionPage();
- if (d->m_updaterGuiWidget && !d->m_gui.isNull())
- d->m_gui->rejectWithoutPrompt();
+ introPage->setComplete(true);
+ introPage->showMaintenanceTools();
- finished();
-}
+ d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->show();
-TabController::Status TabController::getState() const
-{
- return d->m_state;
+ return Installer::Success;
}
-int TabController::checkRepositories()
+int TabController::initPackageManager()
{
- using namespace QInstaller;
-
- const bool isInstaller = d->m_installer->isInstaller();
- GetRepositoriesMetaInfoJob metaInfoJob(d->m_installer->settings().publicKey(),
- d->m_installer->isPackageManager());
- if ((isInstaller && !d->m_installer->isOfflineOnly()) || (d->m_installer->isPackageManager()))
- metaInfoJob.setRepositories(d->m_installer->settings().repositories());
-
- GetMetaInfoProgressWidget *metaProgress = 0;
- QScopedPointer<QProgressDialog> progressDialog(0);
- if (isInstaller) {
- metaProgress = new GetMetaInfoProgressWidget(d->m_gui->introductionPage());
- d->m_gui->introductionPage()->setWidget(metaProgress);
- // disable the 'next' button while performing update
- d->m_gui->introductionPage()->setComplete(false);
- metaInfoJob.connect(&metaInfoJob, SIGNAL(infoMessage(KDJob*, QString)), metaProgress,
- SLOT(message(KDJob*, QString)));
-
- // show the wizard-gui as early as possible
- d->m_gui->connect(d->m_gui, SIGNAL(rejected()), &metaInfoJob, SLOT(doCancel()),
- Qt::QueuedConnection);
- d->m_gui->setWindowModality(Qt::WindowModal);
- d->m_gui->show();
- } else {
- progressDialog.reset(new QProgressDialog(d->m_updaterGuiWidget));
- progressDialog->setModal(true);
- progressDialog->setLabelText(tr("Checking repository..."));
- progressDialog->setRange(0, 0);
- connect (progressDialog.data(), SIGNAL(canceled()), &metaInfoJob, SLOT(doCancel()),
- Qt::QueuedConnection);
- progressDialog->show();
- }
-
- if (d->m_updaterGuiWidget) {
- d->m_updaterGuiWidget->setWindowModality(Qt::WindowModal);
- d->m_updaterGuiWidget->show();
- } else {
- d->m_gui->setWindowModality(Qt::WindowModal);
- d->m_gui->show();
- }
+ IntroductionPageImpl *introPage = introductionPage();
- // start...
- try {
- metaInfoJob.setAutoDelete(false);
- metaInfoJob.start();
- metaInfoJob.waitForFinished();
- d->m_repoReached = true;
- } catch (const Error &e) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("Unknown error"), tr("Unknown error"), e.message(), QMessageBox::Ok,
- QMessageBox::Ok);
+ introPage->setComplete(false);
+ introPage->showMetaInfoUdate();
+ if (d->m_installer->isPackageManager()) {
+ introPage->showAll();
+ introPage->setMaintenanceToolsEnabled(false);
}
- if (metaInfoJob.isCanceled() || metaInfoJob.error() == KDJob::Canceled)
- return INST_CANCELED;
-
- if (metaInfoJob.error() == GetRepositoriesMetaInfoJob::UserIgnoreError) {
- d->m_repoReached = false;
- } else if (metaInfoJob.error() != KDJob::NoError) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("metaInfoJobError"), QObject::tr("Error"), metaInfoJob.errorString());
- return INST_FAILED;
+ if (!d->m_introPageConnected) {
+ d->m_introPageConnected = true;
+ connect(d->m_installer, SIGNAL(metaJobInfoMessage(KDJob*,QString)), introPage,
+ SLOT(message(KDJob*, QString)));
}
- const QInstaller::TempDirDeleter tempDirDeleter(metaInfoJob.releaseTemporaryDirectories());
- const QStringList tempDirs = tempDirDeleter.paths();
-
- foreach (const QString &i, tempDirs) {
- if (i.isEmpty())
- continue;
- verbose() << "addUpdateSource()" << QUrl::fromLocalFile(i) << std::endl;
- const QString updatesXmlPath = i + QLatin1String("/Updates.xml");
-
- QFile updatesFile(updatesXmlPath);
- try {
- openForRead(&updatesFile, updatesFile.fileName());
- } catch(const Error &e) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("Open error"), tr("Error parsing Updates.xml"), e.message());
- return INST_FAILED;
- }
-
- verbose() << "Path to Update.xml " << qPrintable(updatesXmlPath) << std::endl;
-
- QString err;
- int line = 0;
- int col = 0;
- QDomDocument doc;
- if (!doc.setContent(&updatesFile, &err, &line, &col)) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("parseError"), tr("Error parsing Updates.xml"),
- tr("Parse error in File %4 : %1 at line %2 col %3").arg(err, QString::number(line),
- QString::number(col), updatesFile.fileName()));
- return INST_FAILED;
- }
+ d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->show();
- const QDomNode checksum = doc.documentElement().firstChildElement(QLatin1String("Checksum"));
- if (!checksum.isNull()) {
- const QDomElement checksumElem = checksum.toElement();
- d->m_installer->setTestChecksum(checksumElem.text() == QLatin1String("true"));
- }
+ if (!d->m_allPackagesFetched)
+ d->m_allPackagesFetched = d->m_installer->fetchAllPackages();
- verbose() << "addUpdateSource()" << QUrl::fromLocalFile(i) << std::endl;
- const QString productName = d->m_installer->value(QLatin1String("ProductName"));
- d->m_app->addUpdateSource(productName, productName, QString(), QUrl::fromLocalFile(i), 1);
- }
+ // Initialize the gui. Needs to be done after check repositories as only then the ui can handle
+ // hide of pages depenging on the components.
+ d->m_gui->init();
+ d->m_gui->callControlScriptMethod(QLatin1String("PackageManagerSelectedCallback"));
+ d->m_gui->triggerControlScriptForCurrentPage();
- // The changes done above by adding update source don't count as modification that
- // need to be saved cause they will be re-set on the next start anyway. This does
- // prevent creating of xml files not needed atm. We can still set the modified
- // state later once real things changed that we like to restore at the next startup.
- d->m_app->updateSourcesInfo()->setModified(false);
-
- // create the packages info
- KDUpdater::UpdateFinder* const updateFinder = new KDUpdater::UpdateFinder(d->m_app);
- QObject::connect(updateFinder, SIGNAL(error(int, QString)), d->m_app, SLOT(printError(int, QString)));
- updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
- updateFinder->run();
-
- try {
- // now create installable components
- d->m_installer->createComponents(updateFinder->updates(), metaInfoJob);
- } catch (const Error &e) {
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("createComponentsError"), QObject::tr("Error"), e.message());
+ if (d->m_installer->isPackageManager()) {
+ introPage->showMaintenanceTools();
+ introPage->setMaintenanceToolsEnabled(true);
+ } else {
+ introPage->hideAll();
}
+ introPage->setComplete(true);
- if (d->m_installer->status() == QInstaller::Installer::InstallerFailed)
- return INST_FAILED;
-
- // we need at least one component else the installer makes no
- // sense cause nothing can be installed.
- if (isInstaller)
- Q_ASSERT(!d->m_installer->components().isEmpty());
- d->m_repoUpdateNeeded = false;
-
- if (metaProgress)
- metaProgress->close();
- emit refresh();
-
- if (d->m_updaterGuiWidget)
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, d->m_repoReached);
-
- return INST_SUCCESS;
+ if (d->m_installer->status() == Installer::Canceled)
+ return Installer::Canceled;
+ return Installer::Success;
}
-void TabController::updaterFinished(bool error)
-{
- if (d->m_installer->needsRestart())
- updaterFinishedWithError();
- else if (!error)
- checkRepositories();
-}
+// -- private slots
-void TabController::updaterFinished(int val)
+void TabController::restartWizard()
{
- if (val != QDialog::Accepted) {
- if (d->m_updaterGuiWidget && !d->m_gui.isNull())
- d->m_gui->rejectWithoutPrompt();
- finished();
- }
-}
+ d->m_installer->reset(d->m_params);
-void TabController::canceled()
-{
- d->m_installer->writeUninstaller();
- d->m_updaterGuiWidget->setCloseWithoutWarning(true);
+ // restart and switch back to intro page
+ QTimer::singleShot(0, this, SLOT(init()));
}
-int TabController::initPackageManager()
-{
- init(PACKAGE_MANAGER_TAB);
-
- if (d->m_updaterGuiWidget)
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, false);
-
- // this should called as early as possible, to handle checkRepositories error messageboxes for
- // example
- if (!d->m_controlScript.isEmpty()) {
- verbose() << "Non-interactive installation using script: " << qPrintable(d->m_controlScript)
- << std::endl;
- d->m_gui->loadControlScript(d->m_controlScript);
- QScriptEngine* engine = d->m_gui->controlScriptEngine();
- QScriptValue tabControllerValues = engine->newArray();
-
- tabControllerValues.setProperty(QLatin1String("UPDATER"),
- engine->newVariant(static_cast<int>(TabController::UPDATER_TAB)));
- tabControllerValues.setProperty(QLatin1String("PACKAGE_MANAGER"),
- engine->newVariant(static_cast<int>(TabController::PACKAGE_MANAGER_TAB)));
-
- tabControllerValues.setProperty(QLatin1String("UPDATER_TAB"),
- engine->newVariant(static_cast<int>(TabController::UPDATER_TAB)));
- tabControllerValues.setProperty(QLatin1String("PACKAGE_MANAGER_TAB"),
- engine->newVariant(static_cast<int>(TabController::PACKAGE_MANAGER_TAB)));
-
- engine->globalObject().setProperty(QLatin1String("TabController"), tabControllerValues);
- engine->globalObject().setProperty(QLatin1String("tabController"), engine->newQObject(this));
- if (d->m_updater && d->m_updater->updaterGui()) {
- Q_ASSERT(d->m_updater->updaterGui());
- engine->globalObject().setProperty(QLatin1String("updaterGui"),
- engine->newQObject(d->m_updater->updaterGui() ));
- }
- }
-
- if (d->m_repoUpdateNeeded) {
- int result = checkRepositories();
- if (result != INST_SUCCESS && d->m_repoReached)
- return result;
- }
-
- // initialize the gui.
- d->m_gui->init();
-
- if (d->m_installer->isPackageManager())
- d->preselectInstalledPackages();
-
- if (d->m_installer->isInstaller()) {
- // everything done, enable the 'next' button
- d->m_gui->introductionPage()->setComplete(true);
- }
-
- d->m_packageManagerInitialized = true;
- if (d->m_updaterGuiWidget)
- d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, true);
-
- setCurrentTab(PACKAGE_MANAGER_TAB); //calls callback
- d->m_gui->triggerControlScriptForCurrentPage();
+// -- private
- return INST_SUCCESS;
-}
-
-void TabController::changeCurrentTab(int index)
+IntroductionPageImpl *TabController::introductionPage() const
{
- if (index == d->m_Tab_Pos_PackageManager) {
- if (!d->m_packageManagerInitialized)
- initPackageManager();
- } else {
- if (!d->m_updaterInitialized)
- initUpdater();
- }
+ return qobject_cast<IntroductionPageImpl*> (d->m_gui->page(Installer::Introduction));
}
diff --git a/installerbuilder/installerbase/tabcontroller.h b/installerbuilder/installerbase/tabcontroller.h
index 12a62f73e..cfe8d045f 100644
--- a/installerbuilder/installerbase/tabcontroller.h
+++ b/installerbuilder/installerbase/tabcontroller.h
@@ -30,15 +30,11 @@
#include <QtCore/QObject>
namespace QInstaller {
- class Installer;
class Gui;
+ class Installer;
}
-namespace KDUpdater {
- class Application;
-}
-
-class MainTabWidget;
+class IntroductionPageImpl;
class TabController : public QObject
{
@@ -46,48 +42,25 @@ class TabController : public QObject
Q_DISABLE_COPY(TabController)
public:
- enum Tabs {
- UPDATER_TAB,
- PACKAGE_MANAGER_TAB
- };
-
- enum Status {
- SUCCESS = 0,
- CANCELED = 1,
- FAILED = 2
- };
-
explicit TabController(QObject *parent = 0);
~TabController();
- int initUpdater();
- int initPackageManager();
- int checkRepositories();
- void setInstaller(QInstaller::Installer *installer);
- void setTabWidget(MainTabWidget *widget);
- void setApplication(KDUpdater::Application *app);
+
void setInstallerGui(QInstaller::Gui *gui);
void setControlScript(const QString &script);
+ void setInstaller(QInstaller::Installer *installer);
void setInstallerParams(const QHash<QString, QString> &params);
- Status getState() const;
- Q_INVOKABLE void setCurrentTab(int tab);
-Q_SIGNALS:
- void refresh();
+public Q_SLOTS:
+ int init();
+ int initUpdater();
+ int initUninstaller();
+ int initPackageManager();
private Q_SLOTS:
- void changeCurrentTab(int index);
- void canceled();
- void finished();
void restartWizard();
- void disableUpdaterTab();
- void enableUpdaterTab();
- void updaterFinished(int val = 0);
- void updaterFinished(bool error);
- void updaterFinishedWithError();
- void close();
private:
- void init(Tabs curTab);
+ IntroductionPageImpl *introductionPage() const;
private:
class Private;
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDAutoPointer
index 5203ea2db..5203ea2db 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDAutoPointer
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDByteSize
index e0ee65f30..e0ee65f30 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDByteSize
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDGenericFactory
index 42f06640a..42f06640a 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDGenericFactory
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDJob
index 79fd1dde9..79fd1dde9 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDJob
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDLockfile
index afd9f7ad1..afd9f7ad1 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDLockfile
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDMetaMethodIterator
index cfb58d054..cfb58d054 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDMetaMethodIterator
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDRunOnceChecker
index d5ccad881..d5ccad881 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDRunOnceChecker
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSaveFile
index f7df3f1b5..f7df3f1b5 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSaveFile
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSelfRestarter
index 7de1c2779..7de1c2779 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSelfRestarter
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSysInfo
index 7d5cec1e4..7d5cec1e4 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDSysInfo
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDToolsCore.pri
index 213c8343d..213c8343d 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDToolsCore.pri
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDWatchdog
index 3032c2a37..3032c2a37 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/KDWatchdog
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.cpp
index 3398ac8b8..3398ac8b8 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.h
index 7a0558db0..7a0558db0 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdautopointer.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.cpp
index 0cf06f233..0cf06f233 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.h
index cc8f5a770..d5735632c 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdbytesize.h
@@ -45,7 +45,10 @@ KDTOOLSCORE_EXPORT KDByteSize operator*( const KDByteSize& lhs, int rhs );
KDTOOLS_MAKE_RELATION_OPERATORS( KDByteSize, static inline )
+QT_BEGIN_NAMESPACE
class QDebug;
+QT_END_NAMESPACE
+
KDTOOLSCORE_EXPORT QDebug operator<<( QDebug dbg, const KDByteSize& size );
#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.cpp
index 9352f83cd..9352f83cd 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.h
index 1a0d7f854..1a0d7f854 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdgenericfactory.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.cpp
index d88380ffb..d88380ffb 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.h
index 10cdd6899..10cdd6899 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdjob.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.cpp
index 234bc448e..234bc448e 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.h
index cecbc5cbd..3334f385f 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile.h
@@ -25,7 +25,9 @@
#include <pimpl_ptr.h>
+QT_BEGIN_NAMESPACE
class QString;
+QT_END_NAMESPACE
class KDTOOLSCORE_EXPORT KDLockFile
{
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_p.h
index da4c4dc4c..da4c4dc4c 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_p.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_unix.cpp
index e3d187cbf..e3d187cbf 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_unix.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_win.cpp
index f7fed60ab..f7fed60ab 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdlockfile_win.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.cpp
index 1a0b863c7..1a0b863c7 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.h
index 94bb8f707..94bb8f707 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdmetamethoditerator.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.cpp
index 457a6215a..457a6215a 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.h
index 9e562d3cf..9e562d3cf 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdrunoncechecker.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.cpp
index 38a4b87bf..38a4b87bf 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.h
index 94170608c..94170608c 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsavefile.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.cpp
index fcd66f238..fcd66f238 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.h
index 0582c778d..0582c778d 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdselfrestarter.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.cpp
index e694d79fa..e694d79fa 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.h
index 2324ccfc8..44d1cc71d 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo.h
@@ -106,7 +106,9 @@ public:
static QList< ProcessInfo > runningProcesses();
};
+QT_BEGIN_NAMESPACE
class QDebug;
+QT_END_NAMESPACE
QDebug operator<<( QDebug dbg, KDSysInfo::OperatingSystemType type );
QDebug operator<<( QDebug dbg, KDSysInfo::ArchitectureType type );
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_mac.cpp
index 024d1dd4d..024d1dd4d 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_mac.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_win.cpp
index 3456b89cb..3456b89cb 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_win.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_x11.cpp
index 962bc3093..962bc3093 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdsysinfo_x11.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.cpp
index f41d7974e..f41d7974e 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.h
index 3d687da39..3d687da39 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdtoolsglobal.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.cpp
index 53f91412f..53f91412f 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.h
index b71cb1933..b71cb1933 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdversion.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.cpp
index 7c0abd486..7c0abd486 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.h
index 4319b0e8b..4319b0e8b 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/kdwatchdog.h
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr
index aa2f3984a..aa2f3984a 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.cpp
index 1a7f017a1..1a7f017a1 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.h
index 195b967d1..195b967d1 100644
--- a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDToolsCore/pimpl_ptr.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/Application b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Application
index 7545e9447..7545e9447 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/Application
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Application
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloader
index beca4f9c1..beca4f9c1 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloader
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloaderFactory
index 65dbb7a4e..65dbb7a4e 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/FileDownloaderFactory
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater
index a327ece5b..a327ece5b 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater.pri
index d97399040..3df7ca5c8 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/KDUpdater.pri
@@ -65,7 +65,7 @@ DEFINES += KDUPDATERGUITEXTBROWSER \
QT += gui
TRY_INCLUDEPATHS = /include /usr/include /usr/local/include $$QMAKE_INCDIR $$INCLUDEPATH
-win32:TRY_INCLUDEPATHS += $$PWD/../../3rdparty/openssl-0.9.8k/src/include
+win32:TRY_INCLUDEPATHS += $$PWD/../../openssl-0.9.8k/src/include
linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$INCLUDEPATH
for(p, TRY_INCLUDEPATHS) {
pp = $$join(p, "", "", "/openssl")
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/PackagesInfo
index 8e709882d..8e709882d 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/PackagesInfo
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerificationResult
index 5a71cdfde..5a71cdfde 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerificationResult
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerifier
index 3d9d7f946..3d9d7f946 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/SignatureVerifier
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/Update b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Update
index 8328b020b..8328b020b 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/Update
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/Update
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateFinder
index 71666b90d..71666b90d 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateFinder
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperation
index fd82bafdb..fd82bafdb 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperation
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperationFactory
index bd13c19c5..bd13c19c5 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateOperationFactory
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateSourcesInfo
index b422ec594..b422ec594 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdateSourcesInfo
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdatesDialog
index b1fbb7803..b1fbb7803 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/UpdatesDialog
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/addupdatesourcedialog.ui
index c0de05109..c0de05109 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/addupdatesourcedialog.ui
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.cpp
index c1ddc11f1..f269bba72 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.cpp
@@ -8,11 +8,11 @@ using namespace KDUpdater;
class Environment::Private {
public:
- static Environment* s_instance;
+ static Environment s_instance;
QHash<QString, QString> tempValues;
};
-Environment* Environment::Private::s_instance = 0;
+Environment Environment::Private::s_instance;
Environment::Environment()
: d( new Private )
@@ -23,9 +23,7 @@ Environment::~Environment() {
delete d;
}
-Environment* Environment::instance() {
- if ( !Private::s_instance )
- Private::s_instance = new Environment;
+Environment& Environment::instance() {
return Private::s_instance;
}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.h
index 001afbbc2..2c0d272d1 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/environment.h
@@ -5,14 +5,16 @@
#include <QString>
+QT_BEGIN_NAMESPACE
class QProcess;
class QProcessEnvironment;
+QT_END_NAMESPACE
namespace KDUpdater {
class KDTOOLS_UPDATER_EXPORT Environment {
public:
- static Environment* instance();
+ static Environment& instance();
~Environment();
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdater.h
index 9e0007155..9e0007155 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdater.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.cpp
index cf4379c90..cf4379c90 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.h
index 3970236d3..1d0fca6d9 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterapplication.h
@@ -26,7 +26,9 @@
#include "kdupdater.h"
#include <QObject>
+QT_BEGIN_NAMESPACE
class QUrl;
+QT_END_NAMESPACE
namespace KDUpdater
{
@@ -34,7 +36,8 @@ namespace KDUpdater
class SignatureVerifier;
class UpdateSourcesInfo;
- class ConfigurationInterface {
+ class ConfigurationInterface
+ {
public:
virtual ~ConfigurationInterface();
virtual QVariant value( const QString& key ) const = 0;
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.cpp
index 8e5832084..b5808c9c2 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.cpp
@@ -149,11 +149,10 @@ static QStringList findAllLibSsl()
class KDLibraryLoader : public QObject
{
- static QMutex* mutex;
public:
KDLibraryLoader()
{
- const QMutexLocker ml( mutex );
+ const QMutexLocker ml( &mutex );
if( tempDir.isEmpty() )
{
QTemporaryFile file( QDir::temp().absoluteFilePath( QString::fromLatin1( "templibsXXXXXX" ) ) );
@@ -167,7 +166,7 @@ public:
~KDLibraryLoader()
{
- const QMutexLocker ml( mutex );
+ const QMutexLocker ml( &mutex );
for( QVector< QLibrary* >::const_iterator it = loadedLibraries.begin(); it != loadedLibraries.end(); ++it )
{
QLibrary* const lib = *it;
@@ -187,7 +186,7 @@ public:
bool load( const QString& filename )
{
- const QMutexLocker ml( mutex );
+ const QMutexLocker ml( &mutex );
// does it work out of the box? great!
QLibrary* const lib = new QLibrary;
loadedLibraries.push_back( lib );
@@ -219,7 +218,7 @@ public:
template< typename VERSION >
bool load( const QString& filename, VERSION version )
{
- const QMutexLocker ml( mutex );
+ const QMutexLocker ml( &mutex );
// does it work out of the box? great!
QLibrary* const lib = new QLibrary;
loadedLibraries.push_back( lib );
@@ -251,7 +250,7 @@ public:
void* resolve( const char* symbol )
{
- const QMutexLocker ml( mutex );
+ const QMutexLocker ml( &mutex );
for( QVector< QLibrary* >::const_iterator it = loadedLibraries.begin(); it != loadedLibraries.end(); ++it )
{
QLibrary* const lib = *it;
@@ -265,13 +264,14 @@ public:
private:
QVector< QLibrary* > loadedLibraries;
QStringList temporaryFiles;
+
+ static QMutex mutex;
static QString tempDir;
};
+QMutex KDLibraryLoader::mutex;
QString KDLibraryLoader::tempDir;
-// TODO: this one get leaked
-QMutex* KDLibraryLoader::mutex = new QMutex;
static KDLibraryLoader* loadOpenSsl()
{
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.h
index 15d0011a0..4d94c89fb 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatercrypto.h
@@ -25,10 +25,12 @@
#include "kdupdater.h"
+#include <KDToolsCore/pimpl_ptr.h>
+
+QT_BEGIN_NAMESPACE
class QByteArray;
class QIODevice;
-
-#include <KDToolsCore/pimpl_ptr.h>
+QT_END_NAMESPACE
/**
* Class that provides cryptographic functionality like signing and verifying
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.cpp
index c23badb5b..c23badb5b 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.h
index 754917aa8..754917aa8 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader_p.h
index 516bc3c3d..841e48c03 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloader_p.h
@@ -29,7 +29,9 @@
#include <QtCore/QCryptographicHash>
#include <QtNetwork/QNetworkReply>
+QT_BEGIN_NAMESPACE
class QIODevice;
+QT_END_NAMESPACE
// these classes are not a part of the public API
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp
index cba271e96..cba271e96 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h
index b4c284640..7afc3e35e 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h
@@ -30,7 +30,9 @@
#include <QtCore/QStringList>
#include <QtCore/QUrl>
+QT_BEGIN_NAMESPACE
class QObject;
+QT_END_NAMESPACE
namespace KDUpdater
{
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp
index c6ce195ea..3d19d149a 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp
@@ -521,6 +521,16 @@ void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement& packageE)
}
/*!
+ Clears the installed package list.
+*/
+void PackagesInfo::clearPackageInfoList()
+{
+ d->packageInfoList.clear();
+ d->modified = true;
+ emit reset();
+}
+
+/*!
\fn void KDUpdater::PackagesInfo::reset()
This signal is emitted whenever the contents of this class is refreshed, usually from within
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h
index 8b38dd8d2..56cd77ec3 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h
@@ -72,7 +72,8 @@ namespace KDUpdater
bool isValid() const;
QString errorString() const;
Error error() const;
-
+ void clearPackageInfoList();
+
void setFileName(const QString& fileName);
QString fileName() const;
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.cpp
index 4943c7b72..4943c7b72 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.h
index 8f42b1e19..8f42b1e19 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesview.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp
index 0b1f61a57..0b1f61a57 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.h
index 5319d35f3..6d426c820 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationresult.h
@@ -28,7 +28,9 @@
#include <QtCore/QMetaType>
#include <QtCore/QSharedDataPointer>
+QT_BEGIN_NAMESPACE
class QString;
+QT_END_NAMESPACE
namespace KDUpdater {
class KDTOOLS_UPDATER_EXPORT SignatureVerificationResult {
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp
index 19c6337e4..19c6337e4 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h
index afc201bea..bbad15381 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h
@@ -27,10 +27,12 @@
#include <QtCore/QGenericArgument>
#include <QtCore/QRunnable>
+QT_BEGIN_NAMESPACE
class QByteArray;
class QIODevice;
class QObject;
template <typename T> class QVector;
+QT_END_NAMESPACE
namespace KDUpdater {
class SignatureVerifier;
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.cpp
index 28cba7098..28cba7098 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.h
index dfb8cbddb..ef1da8ae3 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatersignatureverifier.h
@@ -25,9 +25,11 @@
#include "kdupdater.h"
+QT_BEGIN_NAMESPACE
class QByteArray;
class QIODevice;
class QString;
+QT_END_NAMESPACE
namespace KDUpdater {
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.cpp
index ee8d5aca8..6297594c0 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.cpp
@@ -51,6 +51,7 @@ struct KDUpdater::Task::TaskData
paused = false;
stopped = false;
progressPc = 0;
+ autoDelete = true;
}
Task* q;
@@ -64,6 +65,7 @@ struct KDUpdater::Task::TaskData
bool stopped;
int progressPc;
QString progressText;
+ bool autoDelete;
};
/*!
@@ -242,7 +244,8 @@ void KDUpdater::Task::stop()
d->finished = false; // the task is not finished, but was canceled half-way through
emit stopped();
- deleteLater();
+ if (d->autoDelete)
+ deleteLater();
}
/*!
@@ -340,7 +343,8 @@ void KDUpdater::Task::reportError(int errorCode, const QString& errorText)
d->errorText = errorText;
emit error(d->errorCode, d->errorText);
- deleteLater();
+ if (d->autoDelete)
+ deleteLater();
}
/*!
@@ -360,7 +364,18 @@ void KDUpdater::Task::reportDone()
d->errorText.clear();
emit finished();
- deleteLater();
+ if (d->autoDelete)
+ deleteLater();
+}
+
+bool KDUpdater::Task::autoDelete() const
+{
+ return d->autoDelete;
+}
+
+void KDUpdater::Task::setAutoDelete(bool autoDelete)
+{
+ d->autoDelete = autoDelete;
}
/*!
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.h
index 84dada516..311fd84cd 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdatertask.h
@@ -56,6 +56,9 @@ namespace KDUpdater
int progressPercent() const;
QString progressText() const;
+ bool autoDelete() const;
+ void setAutoDelete(bool autoDelete);
+
public Q_SLOTS:
void run();
void stop();
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp
index 4a93b92c2..4a93b92c2 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h
index 65f6ea5cb..6501735f1 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h
@@ -31,8 +31,10 @@
#include <QtCore/QByteArray>
#include <QtCore/QVector>
+QT_BEGIN_NAMESPACE
class QCryptographicHash;
class QDataStream;
+QT_END_NAMESPACE
namespace KDUpdater
{
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor.cpp
index f5c36e44f..f5c36e44f 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor_p.h
index 5800887fc..61c5cca78 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterufuncompressor_p.h
@@ -27,7 +27,9 @@
#include <QtCore/QCoreApplication>
+QT_BEGIN_NAMESPACE
class QString;
+QT_END_NAMESPACE
namespace KDUpdater
{
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.cpp
index 0761e7926..0761e7926 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.h
index 4e4c711d6..4e4c711d6 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdate.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.cpp
index 8d34586e8..8d34586e8 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.h
index 14ebb9c97..e472f42e0 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatefinder.h
@@ -28,7 +28,9 @@
#include <QList>
#include <QMap>
+QT_BEGIN_NAMESPACE
class QUrl;
+QT_END_NAMESPACE
namespace KDUpdater
{
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp
index 3b8d2dbd4..3b8d2dbd4 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.h
index dc3e58e48..dc3e58e48 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateinstaller.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.cpp
index 7c4121e8e..7c4121e8e 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.h
index 53111d23a..53111d23a 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperation.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp
index 076af5273..076af5273 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h
index d42a871c3..d42a871c3 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.cpp
index a1486d34d..769f9a36d 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.cpp
@@ -935,7 +935,7 @@ bool ExecuteOperation::performOperation()
else
#endif
{
- Environment::instance()->applyTo( &process ); //apply non-persistent variables
+ Environment::instance().applyTo( &process ); //apply non-persistent variables
process.start( args.front(), args.mid( 1 ) );
QEventLoop loop;
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.h
index 4f1a2563e..4f1a2563e 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdateoperations.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp
index 2b8d54a6b..2b8d54a6b 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.h
index 85a90a595..85a90a595 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesdialog.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp
index 4e9f60195..4e9f60195 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h
index 4179e3d8d..4179e3d8d 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp
index 14a765a5b..14a765a5b 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h
index 231002ee0..231002ee0 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp
index aec942614..aec942614 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.h
index c2c840d72..c2c840d72 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesourcesview.h
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/updatesdialog.ui
index 52162109e..52162109e 100644
--- a/installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/updatesdialog.ui
diff --git a/installerbuilder/libinstaller/kdtools/LICENSE.LGPL b/installerbuilder/libinstaller/3rdparty/kdtools/LICENSE.LGPL
index ea164db15..ea164db15 100644
--- a/installerbuilder/libinstaller/kdtools/LICENSE.LGPL
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/LICENSE.LGPL
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
index 2ee6f8db2..22002bef6 100644
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
@@ -24,14 +24,13 @@
#include "7zip/UI/Common/Extract.h"
#include "7zip/UI/Common/Update.h"
#include "7zip/UI/Common/ArchiveExtractCallback.h"
+#include "7zip/UI/Common/LoadCodecs.h"
+#include "7zip/UI/Common/PropIDUtils.h"
#include "Windows/Defs.h"
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
-
-#include "7zip/UI/Common/LoadCodecs.h"
-#include "7zip/UI/Common/PropIDUtils.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
index 670071866..2441e3d35 100644
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
@@ -17,8 +17,10 @@
#include "../../installerbuilder/libinstaller/installer_global.h"
+QT_BEGIN_NAMESPACE
class QStringList;
template <typename T> class QVector;
+QT_END_NAMESPACE
namespace Lib7z {
diff --git a/installerbuilder/libinstaller/NQSDevAgreement.txt b/installerbuilder/libinstaller/NQSDevAgreement.txt
deleted file mode 100644
index 27a865f7d..000000000
--- a/installerbuilder/libinstaller/NQSDevAgreement.txt
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-NOKIA CORPORATION DEVELOPER SOFTWARE AGREEMENT
-Version 1.0
-
-This Nokia Corporation Developer Software Agreement ("Agreement") is between You (either an individual or an entity), the developer, and Nokia Corporation ("Nokia"). The Agreement authorizes You to use the Software specified in Clause 1 below, which may be stored on a CD-ROM, sent to You by electronic mail, or downloaded from Nokia's web pages or servers or from other sources under the terms and conditions set forth below.
-
-This is an agreement on end-user rights and not an agreement for sale. Nokia continues to own the copy of the Software and the physical media contained in the sales package and any other copy that You are authorized to make pursuant to this Agreement.
-
-Read this Agreement carefully before accessing, downloading, installing or using the Software or any part of it. By accessing, downloading, installing or using the Software, You agree to the terms and conditions of this Agreement. If You do not agree to all of the terms and conditions of this Agreement, promptly cancel the installation or downloading, or destroy or return the Software and accompanying documentation to Nokia.
-
-1. SOFTWARE
-
-As used in this Agreement, the term "Software" means, collectively: (i) the Qt SDK software product with the exception of Open Source Software (as defined below), (ii) all the contents of the disk(s), CD-ROM(s), electronic mail and its file attachments, or other media with which this Agreement is provided, including the object code form of the software delivered via a CD-ROM, electronic mail, or web page (iii) related explanatory written materials and any other possible documentation related thereto ("Documentation"); (v) fonts, and (vi) upgrades, modified versions, updates, additions, and copies of the Software (collectively "Updates"), if any, provided to You by Nokia under this Agreement.
-
-"Open Source Software" means any software, which is, as included in the Qt SDK, subject to a license terms and conditions currently listed at http://opensource.org/licenses/ or meeting the criteria listed at http://www.opensource.org/docs/definition.php or which is subject to any similar free or open source license terms. Open Source Software contained in the Qt SDK is licensed under the license terms accompanying such Open Source Software and not the terms of this Agreement.
-
-2. USE OF THE SOFTWARE
-
-The Software is made accessible to You for the sole purpose of developing and testing Applications by installing a reasonable number of copies of the Software on computers owned or controlled by You to be used by You or Your authorized users. "Application" means one or more software programs developed by or for You in compliance with the Documentation, including any bug fixes, updates, upgrades, modifications, enhancements, supplements to, revisions, new releases and new versions of such software programs.
-
-You acknowledge that the use of the Software may require licenses to third party patents and that Nokia does not grant any licenses to such third party patents under this Agreement to the You. Also, any and all standards related licenses with respect to Essential Patents (as defined below) are specifically excluded from the scope of this Agreement, and those licenses need to be acquired separately from Nokia or the respective right holders, as the case may be. "Essential Patent" means any patent claiming a feature necessarily and unavoidably required for compliance with industry standards (usually GSM, WCDMA or other similar mobile communications standard), to the limited extent only that infringement or use of such claims of a patent cannot be avoided in remaining compliant with industry standard either for technological reasons or for lack of commercially viable technical alternatives.
-
-No patent licenses to any patents of Nokia and/ or its Affiliates are granted under this Agreement.
-
-3. LIMITATIONS ON END USER RIGHTS
-
-You may not copy, distribute, or make derivative works of the Software except as follows:
-
-(a) You may not use, modify, translate, reproduce, or transfer the right to use the Software or copy the Software except as expressly provided in this Agreement.
-
-(b) You may not resell, sublicense, rent, lease, or lend the Software.
-
-(c) You may not reverse engineer, reverse compile, disassemble, or otherwise attempt to discover the source code of the Software (except to the extent that this restriction is expressly prohibited by law) or create derivative works based on the Software.
-
-(d) You agree that You shall only use the Software in a manner that complies with all applicable laws in the jurisdiction in which You use the Software, including, but not limited to, applicable restrictions concerning copyright and other intellectual property rights.
-
-4. INTELLECTUAL PROPERTY RIGHTS
-
-The Software and all rights, without limitation including title and intellectual property rights therein, are owned by Nokia and/or its licensors and affiliates and are protected by international treaty provisions and all other applicable national laws of the country in which it is being used. The structure, organization, and code of the Software are the valuable trade secrets and confidential information of Nokia and/or its licensors and affiliates. You must not copy the Software, except as set forth in clause 3 (Limitations On End-User Rights). Any copies which You are permitted to make pursuant to this Agreement must contain the same copyright and other proprietary notices that appear on the Software.
-
-5. FEEDBACK
-
-By submitting feedback ("Feedback") to Nokia related to the Software, including but not limited to information on bug fixes or error corrections, you acknowledge and agree that (1) Nokia may have similar development ideas to the Feedback; (2) your Feedback does not contain confidential or proprietary information related to your own activities or those of any third party; (3) Nokia is not under any obligation of confidentiality with respect to the Feedback; and (4) you are not entitled to any compensation of any kind from Nokia. You hereby grant Nokia a worldwide non-exclusive, assignable, fully paid, royalty-free, perpetual and irrevocable license to use, exploit, copy, publicly perform, display, distribute, further develop and modify for any purpose such Feedback, and to prepare derivative works thereof, or incorporate such Feedback into other works as well as sublicense products and services resulting from such works.
-
-6. SUPPORT AND MAINTENANCE
-
-Nokia has no obligation to furnish You with technical or other support unless separately agreed in writing between You and Nokia. In case of such support given by Nokia You understand and agree that the support has been given on "as is" and "as available" basis and Nokia will have no obligations or liabilities related to such support.
-
-Nokia, may, from time to time, make Updates available to You. You may use the previous version for ninety (90) days after You receive the Update in order to assist You in the transition to the Update. After such time You no longer have a right to use the previous version, except for the sole purpose of enabling You to install the Update. However, Nokia may provide You with Updates that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Software and the use of the previous version of the Software may be prevented without installation of the Update.
-
-7. COMMENCEMENT & TERMINATION
-
-This Agreement is effective from the first date You install the Software. You may terminate this Agreement at any time by permanently deleting, destroying, and returning, at Your own costs, the Software, all backup copies, and all related materials provided by Nokia. Your end-user rights automatically and immediately terminate without notice from Nokia if You fail to comply with any provision of this Agreement. In such an event, You must immediately delete, destroy, or return at Your own cost, the Software, all backup copies, and all related material to Nokia.
-
-8. NO WARRANTIES
-
-YOU ACKNOWLEDGE THAT THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW NEITHER NOKIA, ITS LICENSORS OR AFFILIATES, NOR THE COPYRIGHT HOLDERS MAKE ANY REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. THERE IS NO WARRANTY BY NOKIA OR BY ANY OTHER PARTY THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE. YOU ASSUME ALL RESPONSIBILITY AND RISK FOR THE SELECTION OF THE SOFTWARE TO ACHIEVE YOUR INTENDED RESULTS AND FOR THE INSTALLATION, USE, AND RESULTS OBTAINED FROM IT.
-
-9. NO OTHER OBLIGATIONS
-
-This Agreement creates no obligations on the part of Nokia other than as specifically set forth herein.
-
-10. LIMITATION OF LIABILITY
-
-TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES BE LIABLE FOR ANY LOST PROFITS, REVENUE, SALES, DATA, OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, PROPERTY DAMAGE, PERSONAL INJURY, INTERRUPTION OF BUSINESS, LOSS OF BUSINESS INFORMATION, OR FOR ANY SPECIAL, DIRECT, INDIRECT, INCIDENTAL, ECONOMIC, COVER, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND WHETHER ARISING UNDER CONTRACT, TORT, NEGLIGENCE, OR OTHER THEORY OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NOKIA OR ITS LICENSORS OR AFFILIATES ARE ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME COUNTRIES/STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF LIABILITY, BUT MAY ALLOW LIABILITY TO BE LIMITED, IN SUCH CASES, NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES' LIABILITY SHALL BE LIMITED TO U.S. $50. Nothing contained in this Agreement shall prejudice the statutory rights of any party dealing as a consumer. Nothing contained in this Agreement limits Nokia's liability to You in the event of death or personal injury resulting from Nokia's negligence. Nokia is acting on behalf of its employees and licensors or affiliates for the purpose of disclaiming, excluding, and/or restricting obligations, warranties, and liability as provided in this clause 9, but in no other respects and for no other purpose.
-
-11. INDEMNITY
-
-You shall defend, indemnify and hold Nokia and its licensors harmless against any claims, damages, liabilities, losses, costs, suits or expenditures incurred by Nokia, its Affiliates, or licensors as a result of any infringement or alleged infringement of intellectual property rights of a third party caused by Your development or exploitation of the Software.
-
-12. EXPORT CONTROL
-
-You acknowledge that the Software may be subject to export control restrictions of various countries. You shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the Software and/or Applications and shall procure all necessary governmental authorizations, including without limitation, all necessary licenses, approvals, permissions or consents, where necessary for the re-exportation of the Software or Applications.
-
-
-13. GOVERNMENT END USERS
-
-A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if You are a U.S. Government End User. The Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Software with only those rights set forth herein. The Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement.
-
-
-14. NOTICES
-
-All notices and return of the Software and Documentation should be delivered to:
-
-NOKIA CORPORATION
-P.O. Box 100
-FIN-00045 NOKIA GROUP
-FINLAND
-
-15. APPLICABLE LAW AND GENERAL PROVISIONS
-
-This Agreement is governed by the laws of Finland. All disputes arising from or relating to this Agreement shall be settled by a single arbitrator appointed by the Central Chamber of Commerce of Finland. The arbitration procedure shall take place in Helsinki, Finland in the English language. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. This Agreement may only be modified by a writing signed by an authorized officer of Nokia, although Nokia may vary the terms of this Agreement.
-
-This is the entire agreement between Nokia and You relating to the Software, and it supersedes any prior representations, discussions, undertakings, end-user agreements, communications, or advertising relating to the Software.
-
-There are no implied licenses or other implied rights granted under this Agreement, and all rights, save for those expressly granted hereunder, shall remain with Nokia and its licensors. In addition, no licenses or immunities are granted to the combination of the Software with any other software or hardware not delivered by Nokia under this Agreement.
-
-
-OVI MAPS API ADDITIONAL TERMS
-
-In addition to the terms set forth above, the Nokia Privacy Policy and following additional terms shall apply to Your use of the Ovi Maps and related services ("Service"):
-
-
-1. DEFINITIONS
-
-"Ovi Maps Content" means the maps content available from Nokia from time to time for the purpose of being rendered on the Ovi Maps, including data provided by Nokia that originates from third parties.
-
-"Ovi Maps API Service" means the service offered by Nokia that enables You to incorporate the Ovi Maps For Developers and the Ovi Maps Content, as made available by Nokia from time to time, into Your Applications and to have end-users access and use it on such Applications
-
-"Ovi Maps For Developers" means the software, as made available by Nokia from time to time that allows the rendering of Ovi Maps Content within Applications. For clarity, the Ovi Maps For Developers may include software components that are downloaded and installed on the users' mobile device(s) and/or JavaScript libraries that are invoked and downloaded by the Ovi Maps API.
-
-"Ovi Maps API Developer Package" means the Ovi Maps API, documentation and any and all other material made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications and is designated by Nokia as being a part of the Ovi Maps API Developer Package.
-
-"Ovi Maps API(s)" means the interface information made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications.
-
-2. REGISTRATION AND TERMINATION
-
-If registration is required, You agree to provide truthful and complete information when registering for the Service and to keep that information updated. Providing misleading information about Your identity is forbidden. Depending on the use of the Ovi Maps API(s), You may receive an identifier code or developer key in order to use the Service. You are personally responsible for any use of the Ovi Maps API Service. You agree to take due care in protecting Your Application using Ovi Maps API, Your identifier code and/or developer key against misuse by others and promptly notify Nokia about any misuse. Where requested by Nokia, You agree to include and use the identifier code and/or developer key, as applicable, in each request You make to access to the Ovi Maps API(s).
-
-You may terminate Your registration if You no longer wish to use the Service. After termination, You may not access the Service. Nokia may terminate Your registration or restrict Your access to certain parts of the Service if there is an indication that You have breached these terms or with a prior notice if You have not signed into the Service with Your identifier code in the past three (3) months.
-
-3. SERVICE CHANGES
-
-Nokia may, in its sole discretion, change, improve and correct the Service from time to time. Nokia may also provide with updates to the Service that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Service and the use of the previous version of the Service may be prevented without installation of the update. The Service may not be available during maintenance breaks and other times. Nokia may also decide to discontinue the Service or any part thereof in its sole discretion. In such case You will be provided a prior notification and Nokia may terminate the Agreement accordingly.
-
-Except as set forth in Privacy Policy, Nokia shall not be responsible for any removal or loss of the information or content You have submitted ("Material") to the Service when Your registration is terminated. After the Material is removed from the Service by either You or Nokia, traces and copies of the Material may still remain.
-
-
-4. USE OF OVI MAPS API DEVELOPER PACKAGE
-
-The Ovi Maps API Developer Package is made accessible to You for the purposes of incorporating the Ovi Maps Service into Your Application and for the limited purposes of evaluating, testing, and controlling the Ovi Maps For Developers during the term of this Agreement.
-
-When using the Ovi Maps API Developer Package and/or the Ovi Maps Service, You hereby agree that You will not:
-
-(i) use or incorporate the Ovi Maps Service, Ovi Maps API Developer Package or any part thereof, in connection with any Application or other service (a) which has the primary functionality of providing turn-by-turn navigation services, real time navigation or route guidance; or (b) where such Application's functionality is substantially similar to the Ovi Maps or navigation/location-based products distributed by Nokia or its affiliates; or (c) which has the primary purpose of capturing or collecting end user data;
-
-(ii) use, without Nokia's prior written permission, the Ovi Maps Service or Ovi Maps For Developers, or any part thereof, in connection with any internal business Application the purpose of which is directly related to the operation of Your core business and where the users of such Application are Your employees or contractors (e.g. fleet or asset management and tracking);
-
-(iii)remove or obscure any copyright or trademark notices or other similar notices or markings or legends or branding requirements from the Ovi Maps API Developer Package, Ovi Maps For Developers or the Ovi Maps Content whether such notices, markings or legends or other branding requirements originate from Nokia or a third party;
-
-(iv) alter the order of search, geo-coding and/or reverse geo-coding results delivered by or through any Ovi Maps API to or as part of the Application (where applicable);
-
-(v) alter, delete or otherwise change any Ovi Maps Content, including third party content contained in the Ovi Maps Content, that is displayed through the use of the Ovi Maps Service or Ovi Maps For Developers;
-
-(vi) use the Ovi Maps API(s) or Ovi Maps Service to exceed any transaction volume limits (if any) set by Nokia for Applications, Ovi Maps APIs and/or Ovi Maps Services. The amount of the possible transaction volume limit is as set forth in the documentation included in the Ovi Maps API. Nokia may change the limit from time to time in its sole discretion, but will provide You with ninety (90) days' advance notice of a change in the volume limit. Any programmatic methods or other actions intended to circumvent the transaction volume limits shall be considered a material breach of this Agreement;
-
-(vii) access or use the Ovi Maps Service or any Ovi Maps Content through any technology or means other than those provided by the Ovi Maps Service or Ovi Maps API, or through other explicitly authorized means Nokia may designate;
-
-(viii) use the Ovi Maps Service, Ovi Maps API or Ovi Maps For Developers in a manner that gives You or any other person access to mass downloads or bulk fees of any Ovi Maps Content, including but not limited to numerical latitude or longitude coordinates;
-
-(ix) pre-fetch, cache, or store any Ovi Maps Content except that You may store limited amounts of Ovi Maps Content for the purpose of testing your Application, if You do so temporarily, securely, and in a manner that does not permit use of the Ovi Maps Content outside of the Ovi Maps Service; or
-
-(x) use the Ovi Maps API Developer Package, including the Ovi Maps For Developers, or the Ovi Maps Service in any manner or for any purpose that violates this Agreement or any law or regulation, including without limitation, any intellectual property or other proprietary rights, any right of any person, rights of privacy, or rights of personality.
-
-You also agree (i) to comply with these terms, applicable laws and good manners; (ii) not to distribute or post spam, unreasonably large files, chain letters, pyramid schemes, viruses or any other technologies that may harm the Ovi Maps Service, or the interest or property of the Ovi Maps Service users; (iii) not to use the Service in connection with any unlawful, offensive, abusive, pornographic, harassing, libelous or otherwise inappropriate Material and comply with Nokia Content Guidelines as may be provided by Nokia from time to time; and (iv) to respect the privacy of others. You agree to comply with Nokia Technical Guidelines and other guidelines as Nokia may provide from time to time.
-
-5. OVI MAPS CONTENT AND PUBLICATION
-
-Ovi Maps Content is provided to You and Your end users for planning purposes only and Nokia does not guarantee the accuracy or availability of any Ovi Maps Content. You may find that weather conditions, construction projects, closures or other events may cause road conditions, directions, positioning coordinates or other location information to differ from the results depicted in the Ovi Maps Content. All use of Ovi Maps Content is at Your own risk.
-
-6. PRIVACY AND OVI STORE PUBLICATION
-
-You agree that Your use of the Ovi Maps Services and Ovi Maps API will comply with the Nokia Privacy Policy (http://www.nokia.com/privacy-policy).
-
-If your Application enables You or any party to gain access to information about users, including but not limited to personally identifiable information, non-personally identifiable usage information or location information ("Information"), You must provide users with notice about what Information is accessible and how such Information will be used or disclosed so that users may make informed decisions about whether or not to use Your Application. Furthermore, you must make Your privacy policy regarding the use of Information publicly available.
-
-If You intend to publish your Application on Nokia's Ovi Store, please note that Your Application must comply with the Ovi Store Publication Requirements (https://publish.ovi.com/info/).
-
-7. FEES
-
-Your use of the Ovi Maps Service may be or may become subject to charges. Nokia reserves the right to charge for the Ovi Maps Service and to change its fees from time to time, at its discretion, but Nokia will provide You with ninety (90) days' advance notice if charges will be implemented for use of the Ovi Maps Service.
-
-8. AVAILABILITY
-
-The Ovi Maps Service may not be available in all countries and may be provided only in selected languages. The Ovi Maps Service may be network dependent, contact Your network service provider for more information.
-
-9. YOUR SERVICES
-
-You may interact with users, including consumers, on or through the Ovi Maps Service. You agree that any such interactions by You do not involve Nokia and are solely between You and the other user(s).
-
-10. LINKS TO THIRD PARTY SITES, CONTENT AND ADVERTISING
-
-Nokia may include links to sites on the Internet that are owned or operated by third parties and that are not part of the Ovi Maps Service. Upon following a link to such a third-party site, You shall review and agree to that site's rules of use before using such site.
-
-You agree that Nokia has no control over the content of third-party sites and cannot assume any responsibility for services provided or material created or published by such sites. A link to a third-party site does not imply that Nokia endorses the site or the products or services referenced in the site.
-
-In addition, users may create links within the Ovi Maps Service to content that has not otherwise been submitted to the Ovi Maps Service. You agree that Nokia is neither responsible nor liable for any such links. Moreover, Ovi Maps Content made available to You by Nokia, may include content and data that originates from third parties.
-
-Nokia reserves the right, in its sole discretion, to implement advertising in the Ovi Maps For Developers. If Nokia implements advertising, You agree not to remove or otherwise alter or tamper with such advertising. Nokia will provide You with ninety (90) days' advance written notice prior to implementing advertising in the Ovi Maps For Developers.
-
-11. REPORTING
-
-You agree to implement those reporting mechanisms specified by Nokia (if any). For example, if specified by Nokia, You agree to provide Nokia with reports if your Application which utilizes the Ovi Maps API detects its own location through the use of a sensor (including, but not limited to GPS, cell triangulation, WiFi or similar functionality) to display the location of the device on a map or to calculate a route.
-
-12. ADDITIONAL EXPORT CONTROL RESTRICTIONS
-
-The Ovi Maps Service and Ovi Maps API Developer Package, including technical data, includes cryptographic software subject to export controls under the U.S. Export Administration Regulations ("EAR") and may be subject to import or export controls in other countries. The EAR prohibits the use of the Ovi Maps Service and the Ovi Maps API Developer Package and technical data by a Government End User, as defined hereafter, without a license from the U.S. government. A Government End User is defined in Part 772 of the EAR as "any foreign central, regional, or local government department, agency, or other entity performing governmental functions; including governmental research institutions, governmental corporations, or their separate business units (as defined in part 772 of the EAR) which are engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List, and international governmental organizations. This term does not include: utilities, telecommunications companies and Internet service providers; banks and financial institutions; transportation; broadcast or entertainment; educational organizations; civil health and medical organizations; retail or wholesale firms; and manufacturing or industrial entities not engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List. You agree to strictly comply with all applicable import and export regulations and acknowledge that You have the responsibility to obtain licenses to export, re-export, transfer, or import the Ovi Maps Service and the Ovi Maps API Developer Package. You further represent that You are not a Government End User as defined above, and You will not transfer the Ovi Maps Service and the Ovi Maps API Developer Package to any Government End User without a license.
-
-
-Copyright (c) 2010 Nokia Corporation.
-
- Company Confidential
-
diff --git a/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt b/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt
deleted file mode 100644
index 9c25bd3fa..000000000
--- a/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt
+++ /dev/null
@@ -1,1019 +0,0 @@
-Qt SDK Version 1.1
-Open Source Components
-
-The Qt SDK includes several components licensed under the terms of the GNU Lesser General Public License version 2.1. These components are as follows:
-
-Qt libraries
- *Qt for Symbian and Qt for Maemo versions 4.6.3, 4.7.0 and 4.7.1
- *Qt for Desktop (Windows, X11 and Mac OS X) version 4.7.1
-Qt Creator 2.0 and 2.1
-Qt Mobility APIs version 1.1.0
-Madde Tools
-Qt Simulator
-MinGW Maemo USB Networking Driver for Windows
-Installer Framework
-Symbian ^3 with 5.0 support and labelled "Symbian Complementary Package"
-
-----------
-
-The GNU LGPL version 2.1 license:
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
-
- Preamble
-
-The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
-
-This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
-
-When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
-
-To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
-
-For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
-
-We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
-
-To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
-
-Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
-
-Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
-
-When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
-
-We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
-
-For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
-
-In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
-
-Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
-
-The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
-
-GNU LESSER GENERAL PUBLIC LICENSE
-TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
-
-A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
-
-The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
-
-"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
-
-Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
-
-You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
-
-Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
-
-This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
-
-However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
-
-When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
-
- a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
-
- e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
-
-It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
-
- 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
-
- b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
-
-This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
-
-NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
-If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
-
-To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
-
-<one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author>
-
-This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
-
-This library 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
-
-Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-<signature of Ty Coon>, 1 April 1990
-Ty Coon, President of Vice
-
-That's all there is to it!
-___________
-
-In addition, some of the Qt components, as document in the source files, also include the Qt LGPL Exception version 1.1
-
-Nokia Qt LGPL Exception version 1.1
-
-As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that:
-(i) the header files of the Library have not been modified; and
-(ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and
-(iii) you comply with the terms of Section 6 of the GNU Lesser General Public License version 2.1.
-
-Moreover, you may apply this exception to a modified version of the Library, provided that such modification does not involve copying material from the Library into the modified Library's header files unless such material is limited to (i) numerical parameters; (ii) data structure layouts; (iii) accessors; and (iv) small macros, templates and inline functions of five lines or less in length.
-
-Furthermore, you are not required to apply this additional permission to a modified version of the Library.
-____________
-In addition, the above components, as well as some other components included in the Qt SDK, include third party open source components. These components are identified below:
-___________
-Qt Third Party Components:
-FreeType 2 (freetype) version 2.3.6
-The FreeType project is a team of volunteers who develop free, portable and high-quality software solutions for digital typography. We specifically target embedded systems and focus on bringing small, efficient and ubiquitous products. -- quoted from 3rdparty/freetype/docs/freetype2.html.
-See src/3rdparty/freetype/docs/FTL.txt and src/3rdparty/freetype/docs/GPL.txt for license details.
-See also the files in src/3rdparty/opentype, which are used by FreeType.
-Parts of the FreeType projects have been modified and put into Qt for use in the painting subsystem. These files are ftraster.h, ftraster.c, ftgrays.h and ftgrays.c. The following modifications has been made to these files:
-Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name conflicts.
-Removed parts of code not relevant when compiled with _STANDALONE_ defined.
-Changed behavior in ftraster.c to follow X polygon filling rules.
-Implemented support in ftraster.c for winding / odd even polygon fill rules.
-Replaced bitmap generation with span generation in ftraster.c
-Renamed: ftraster.h to qblackraster_p.h
-Renamed: ftraster.c to qblackraster.c
-Renamed: ftgrays.h to qgrayraster_p.h
-Renamed: ftgrays.c to qgrayraster.c
-
-
-__________
-
-The FreeType Project LICENSE
-
- 2006-Jan-27
-
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
-
-Introduction
-============
-
- The FreeType Project is distributed in several archive packages;
- some of them may contain, in addition to the FreeType font engine,
- various tools and contributions which rely on, or relate to, the
- FreeType Project.
-
- This license applies to all files found in such packages, and
- which do not fall under their own explicit license. The license
- affects thus the FreeType font engine, the test programs,
- documentation and makefiles, at the very least.
-
- This license was inspired by the BSD, Artistic, and IJG
- (Independent JPEG Group) licenses, which all encourage inclusion
- and use of free software in commercial and freeware products
- alike. As a consequence, its main points are that:
-
- o We don't promise that this software works. However, we will be
- interested in any kind of bug reports. (`as is' distribution)
-
- o You can use this software for whatever you want, in parts or
- full form, without having to pay us. (`royalty-free' usage)
-
- o You may not pretend that you wrote this software. If you use
- it, or only parts of it, in a program, you must acknowledge
- somewhere in your documentation that you have used the
- FreeType code. (`credits')
-
- We specifically permit and encourage the inclusion of this
- software, with or without modifications, in commercial products.
- We disclaim all warranties covering The FreeType Project and
- assume no liability related to The FreeType Project.
-
-
- Finally, many people asked us for a preferred form for a
- credit/disclaimer to use in compliance with this license. We thus
- encourage you to use the following text:
-
- """
- Portions of this software are copyright <year> The FreeType
- Project (www.freetype.org). All rights reserved.
- """
-
- Please replace <year> with the value from the FreeType version you
- actually use.
-
-
-Legal Terms
-===========
-
-0. Definitions
---------------
-
- Throughout this license, the terms `package', `FreeType Project',
- and `FreeType archive' refer to the set of files originally
- distributed by the authors (David Turner, Robert Wilhelm, and
- Werner Lemberg) as the `FreeType Project', be they named as alpha,
- beta or final release.
-
- `You' refers to the licensee, or person using the project, where
- `using' is a generic term including compiling the project's source
- code as well as linking it to form a `program' or `executable'.
- This program is referred to as `a program using the FreeType
- engine'.
-
- This license applies to all files distributed in the original
- FreeType Project, including all source code, binaries and
- documentation, unless otherwise stated in the file in its
- original, unmodified form as distributed in the original archive.
- If you are unsure whether or not a particular file is covered by
- this license, you must contact us to verify this.
-
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
-
-1. No Warranty
---------------
-
- THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
- USE, OF THE FREETYPE PROJECT.
-
-2. Redistribution
------------------
-
- This license grants a worldwide, royalty-free, perpetual and
- irrevocable right and license to use, execute, perform, compile,
- display, copy, create derivative works of, distribute and
- sublicense the FreeType Project (in both source and object code
- forms) and derivative works thereof for any purpose; and to
- authorize others to exercise some or all of the rights granted
- herein, subject to the following conditions:
-
- o Redistribution of source code must retain this license file
- (`FTL.TXT') unaltered; any additions, deletions or changes to
- the original files must be clearly indicated in accompanying
- documentation. The copyright notices of the unaltered,
- original files must be preserved in all copies of source
- files.
-
- o Redistribution in binary form must provide a disclaimer that
- states that the software is based in part of the work of the
- FreeType Team, in the distribution documentation. We also
- encourage you to put an URL to the FreeType web page in your
- documentation, though this isn't mandatory.
-
- These conditions apply to any software derived from or based on
- the FreeType Project, not just the unmodified files. If you use
- our work, you must acknowledge us. However, no fee need be paid
- to us.
-
-3. Advertising
---------------
-
- Neither the FreeType authors and contributors nor you shall use
- the name of the other for commercial, advertising, or promotional
- purposes without specific prior written permission.
-
- We suggest, but do not require, that you use one or more of the
- following phrases to refer to this software in your documentation
- or advertising materials: `FreeType Project', `FreeType Engine',
- `FreeType library', or `FreeType Distribution'.
-
- As you have not signed this license, you are not required to
- accept it. However, as the FreeType Project is copyrighted
- material, only this license, or another one contracted with the
- authors, grants you the right to use, distribute, and modify it.
- Therefore, by using, distributing, or modifying the FreeType
- Project, you indicate that you understand and accept all the terms
- of this license.
-
-4. Contacts
------------
-
- There are two mailing lists related to FreeType:
-
- o freetype@nongnu.org
-
- Discusses general use and applications of FreeType, as well as
- future and wanted additions to the library and distribution.
- If you are looking for support, start in this list if you
- haven't found anything to help you in the documentation.
-
- o freetype-devel@nongnu.org
-
- Discusses bugs, as well as engine internals, design issues,
- specific licenses, porting, etc.
-
- Our home page can be found at
-
- http://www.freetype.org
-
-__________
-
-Libmng License
-/* ************************************************************************** */
-/* * * */
-/* * COPYRIGHT NOTICE: * */
-/* * * */
-/* * Copyright (c) 2000-2007 Gerard Juyn (gerard@libmng.com) * */
-/* * [You may insert additional notices after this sentence if you modify * */
-/* * this source] * */
-/* * * */
-/* * For the purposes of this copyright and license, "Contributing Authors" * */
-/* * is defined as the following set of individuals: * */
-/* * * */
-/* * Gerard Juyn * */
-/* * Glenn Randers-Pehrson * */
-/* * * */
-/* * The MNG Library is supplied "AS IS". The Contributing Authors * */
-/* * disclaim all warranties, expressed or implied, including, without * */
-/* * limitation, the warranties of merchantability and of fitness for any * */
-/* * purpose. The Contributing Authors assume no liability for direct, * */
-/* * indirect, incidental, special, exemplary, or consequential damages, * */
-/* * which may result from the use of the MNG Library, even if advised of * */
-/* * the possibility of such damage. * */
-/* * * */
-/* * Permission is hereby granted to use, copy, modify, and distribute this * */
-/* * source code, or portions hereof, for any purpose, without fee, subject * */
-/* * to the following restrictions: * */
-/* * * */
-/* * 1. The origin of this source code must not be misrepresented; * */
-/* * you must not claim that you wrote the original software. * */
-/* * * */
-/* * 2. Altered versions must be plainly marked as such and must not be * */
-/* * misrepresented as being the original source. * */
-/* * * */
-/* * 3. This Copyright notice may not be removed or altered from any source * */
-/* * or altered source distribution. * */
-/* * * */
-/* * The Contributing Authors specifically permit, without fee, and * */
-/* * encourage the use of this source code as a component to supporting * */
-/* * the MNG and JNG file format in commercial products. If you use this * */
-/* * source code in a product, acknowledgment would be highly appreciated. * */
-/* * * */
-/* ************************************************************************** */
-/* * * */
-/* * Parts of this software have been adapted from the libpng package. * */
-/* * Although this library supports all features from the PNG specification * */
-/* * (as MNG descends from it) it does not require the libpng package. * */
-/* * It does require the zlib library and optionally the IJG jpeg library, * */
-/* * and/or the "little-cms" library by Marti Maria (depending on the * */
-/* * inclusion of support for JNG and Full-Color-Management respectively. * */
-/* * * */
-/* * This library's function is primarily to read and display MNG * */
-/* * animations. It is not meant as a full-featured image-editing * */
-/* * component! It does however offer creation and editing functionality * */
-/* * at the chunk level. * */
-/* * (future modifications may include some more support for creation * */
-/* * and or editing) * */
-/* * * */
-/* ************************************************************************** */
-
-__________
-Libjpeg License
-In plain English:
-1. We don't promise that this software works. (But if you find any bugs, please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you've used the IJG code.
-In legalese:
-The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy.
-This software is copyright (C) 1991-1998, Thomas G. Lane.
-All Rights Reserved except as specified below.
-Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions:
-(1) If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind.
-These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us.
-Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software".
-We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor.
-ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. ansi2knr.c is NOT covered by the above copyright and conditions, but instead by the usual distribution terms of the Free Software Foundation; principally,that you must include source code if you redistribute it. (See the file ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part of any program generated from the IJG code, this does not limit you more than the foregoing paragraphs do.
-The Unix configuration script "configure" was produced with GNU Autoconf. It is copyright by the Free Software Foundation but is freely distributable. The same holds for its supporting scripts (config.guess, config.sub,
-ltconfig, ltmain.sh). Another support script, install-sh, is copyright by M.I.T. but is also freely distributable.
-It appears that the arithmetic coding option of the JPEG spec is covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot legally be used without obtaining one or more licenses. For this reason, support for arithmetic coding has been removed from the free JPEG software.
-(Since arithmetic coding provides only a marginal gain over the unpatented Huffman mode, it is unlikely that very many implementations will support it.)
-So far as we are aware, there are no patent restrictions on the remaining code.
-The IJG distribution formerly included code to read and write GIF files.
-To avoid entanglement with the Unisys LZW patent, GIF reading support has been removed altogether, and the GIF writer has been simplified to produce "uncompressed GIFs". This technique does not use the LZW algorithm; the resulting GIF files are larger than usual, but are readable by all standard GIF decoders.
-We are required to state that
- "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated."
-__________
-Libpng License
-This copy of the libpng notices is provided for your convenience. In case of any discrepancy between this copy and the notices in the file png.h that is included in the libpng distribution, the latter shall prevail.
-
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
-
-If you modify libpng you may insert additional notices immediately following this sentence.
-
-libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors
-
- Cosmin Truta
-
-libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors
-
- Simon-Pierre Cadieux
- Eric S. Raymond
- Gilles Vollant
-
-and with the following additions to the disclaimer:
-
-There is no warranty against interference with your enjoyment of the library or against infringement. There is no warranty that our efforts or the library will fulfill any of your particular purposes or needs. This library is provided with all faults, and the entire risk of satisfactory quality, performance, accuracy, and effort is with the user.
-
-libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-0.96, with the following individuals added to the list of Contributing Authors:
-
- Tom Lane
- Glenn Randers-Pehrson
- Willem van Schaik
-
-libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996, 1997 Andreas Dilger
-
-Distributed according to the same disclaimer and license as libpng-0.88, with the following individuals added to the list of Contributing Authors:
-
- John Bowler
- Kevin Bracey
- Sam Bushell
- Magnus Holmgren
- Greg Roelofs
- Tom Tanner
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
-
-For the purposes of this copyright and license, "Contributing Authors" is defined as the following set of individuals:
-
- Andreas Dilger
- Dave Martindale
- Guy Eric Schalnat
- Paul Schmidt
- Tim Wegner
-
-The PNG Reference Library is supplied "AS IS". The Contributing Authors and Group 42, Inc. disclaim all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The Contributing Authors and Group 42, Inc. assume no liability for direct, indirect, incidental, special, exemplary, or consequential damages, which may result from the use of the PNG Reference Library, even if advised of the possibility of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions:
-
-1. The origin of this source code must not be misrepresented.
-
-2. Altered versions must be plainly marked as such and must not
- be misrepresented as being the original source.
-
-3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-The Contributing Authors and Group 42, Inc. specifically permit, without fee, and encourage the use of this source code as a component to supporting the PNG file format in commercial products. If you use this source code in a product, acknowledgment is not required but would be appreciated.
-
-
-A "png_get_copyright" function is available, for convenient use in "about" boxes and the like:
-
- printf("%s",png_get_copyright(NULL));
-
-Also, the PNG logo (in PNG format, of course) is supplied in the files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
-
-Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a certification mark of the Open Source Initiative.
-
-Glenn Randers-Pehrson
-glennrp at users.sourceforge.net
-May 8, 2008
-__________
-Zlib License
-
- Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
-This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly jloup@gzip.org
- Mark Adler madler@alumni.caltech.edu
-
-*/
-__________
-Sqlite
-1. 2001 September 15
-2. The author disclaims copyright to this source code. In place of a legal notice, here is a blessing:
-3. May you do good and not eviL.
-4. May you find forgiveness for yourself and forgive others.
-5. May you share freely, never taking more than you give.
-__________
-Wintab
-The text and information contained in this file may be freely used, Copied, or distributed without compensation or licensing restrictions.
-This file is copyright 1991-1998 by LCS/Telegraphics.
-__________
-HarfBuzz (harfbuzz)
-This is HarfBuzz, an OpenType Layout engine.
-It was derived originally from the OpenType code in FreeType-1.x, ported to FreeType2. (This code has been abandoned for FreeType2, but until something better comes along, should serve our purposes.) In addition to porting to FreeType-2, it has been modified in various other ways.
-Please see licensing terms and conditions set forth in Section a) above (i.e. the FreeType License).
-___________
-MD5 (md5.cpp and md5.h)
-This code implements the MD5 message-digest algorithm. The algorithm is due to Ron Rivest. This code was written by Colin Plumb in 1993, no copyright is claimed.
-This code is in the public domain; do with it what you wish.
-___________
-LibTiff
-Copyright (c) 1988-1997 Sam Leffler
-Copyright (c) 1991-1997 Silicon Graphics, Inc.
-Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
-Copyright (c) 1997 Greg Ward Larson
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
-IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-______________
-Copyright (c) 1996-1997 Sam Leffler
-Copyright (c) 1996 Pixar
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Pixar, Sam Leffler and Silicon Graphics.
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-____________
-PTMalloc Version 1.8
-ptmcalloc3 is a scalable concurrent memory allocator suitable for use in multi-threaded programs.
-Copyright (c) 2001-2006 Wolfram Gloger
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the name of Wolfram Gloger may not be used in any advertising or publicity relating to the software.
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-___________
-
-Copyright (C) 1999 Serika Kurusugawa. All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS". ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* Shift-JIS Text Codec
-* ISO 2022-JP (JIS) Text Codec
-* EUC-JP Text Codec
-__________
-Copyright (C) 1999-2000 Mizi Research Inc. All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* EUC-KR Text Codec
-___________
-Copyright (C) 2000 TurboLinux, Inc. Written by Justin Yu and Sean Chen.
-Copyright (C) 2001, 2002 Turbolinux, Inc. Written by James Su.
-Copyright (C) 2001, 2002 ThizLinux Laboratory Ltd. Written by Anthony Fok.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* GBK Text Codec
-____________
-Copyright (C) 2000 Ming-Che Chuang
-Copyright (C) 2001, 2002 James Su, Turbolinux Inc.
-Copyright (C) 2002 WU Yi, HancomLinux Inc.
-Copyright (C) 2001, 2002 Anthony Fok, ThizLinux Laboratory Ltd.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* Big5-HKSCS Text Codec
-____________
-Copyright (C) 2000 Ming-Che Chuang
-Copyright (C) 2002 James Su, Turbolinux Inc.
-Copyright (C) 2002 Anthony Fok, ThizLinux Laboratory Ltd.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* Big5 Text Codec
-__________
-Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
-Copyright (C) 2005 Bjoern Bergstroem
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, modify, market, reproduce, grant sublicenses and distribute subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. These files are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-* Implementation of the Recursive Shadow Casting Algorithm in Qt Designer
-___________
-Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
-Copyright (C) 2005 Roberto Raggi
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, modify, market, reproduce, grant sublicenses and distribute subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. These files are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-* Contributions to the Following qt3to4 Files: treewalker.h, treedump.cpp, treedump.h, treewalker.cpp
-___________
-Copyright (c) 1987 X Consortium
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.
-* QRegion
-___________
-Copyright (c) 1989 The Regents of the University of California. All rights reserved.
-Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by the University of California, Berkeley. The name of the University may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-* QDate::weekNumber()
-___________
-Copyright (c) 1991 by AT&T.
-Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.
-THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
-This product includes software developed by the University of California, Berkeley and its contributors.
-* QLocale
-___________
-Copyright (c) 2000 Hans Petter Bieker. All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* TSCII Text Codec
-____________
-Copyright 1996 Daniel Dardailler.
-Permission to use, copy, modify, distribute, and sell this software for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Daniel Dardailler not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Daniel Dardailler makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
-Modifications Copyright 1999 Matt Koss, under the same license as above.
-* Drag and Drop
-____________
-Copyright 2002 USC/Information Sciences Institute
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Information Sciences Institute not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Information Sciences Institute makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
-INFORMATION SCIENCES INSTITUTE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL INFORMATION SCIENCES INSTITUTE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-* QtSvg Module
-___________
-Copyright (C) The Internet Society (2001). All Rights Reserved.
-This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
-The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
-This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-* Torrent Example
-___________
-Copyright (c) 1998 by Bjorn Reese <breese@imada.ou.dk>
-Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
-THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
-* Parts of the QCrashHandler Class
-___________
-Parts of the FreeType projects have been modified and put into Qt and Qtopia Core for use in the painting subsystem. These files are ftraster.h, ftraster.c, ftgrays.h and ftgrays.c. The following modifications has been made to these files:
-* Renamed FT and ft_symbols to QT_FT_and qt_ft to avoid name conflicts in qrasterdefs_p.h.
-* Removed parts of code not relevant when compiled with _STANDALONE_ defined.
-* Changed behavior in ftraster.c to follow X polygon filling rules.
-* Implemented support in ftraster.c for winding / odd even polygon fill rules.
-* Replaced bitmap generation with span generation in ftraster.c.
-* Renamed ftraster.h as qblackraster_p.h.
-* Renamed ftraster.c as qblackraster.c.
-* Renamed ftgrays.h as qgrayraster_p.h.
-* Renamed ftgrays.c as qgrayraster.c.
-See src/3rdparty/freetype/docs/FTL.txt and src/3rdparty/freetype/docs/GPL.txt for license details.
-__________
-Copyright (c) 1985, 1986, 1987 X Consortium
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.
-* Parts of the Q3PolygonScanner Class Used in Qt for Embedded Linux
-__________
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-* Parts of the Q3PolygonScanner class used in Qt for Embedded Linux
-__________
-OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
-* QGLFormat
-___________
-WebKit is licensed under the GNU Library General Public License. Individual contributor names and copyright dates can be found inline in the code.
-This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
-This library 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 Library General Public License for more details.
-You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-* QtWebKit Module
-____________
-Copyright (C) 2000-2004, International Business Machines
-Corporation and others. All Rights Reserved.
-Copyright (C) 2007 Apple Inc. All rights reserved.
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
-* Parts of WebKit used by the QtWebKit module
-_____________
-Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
-Changes are Copyright(C) 2007 by Trolltech ASA, all rights reserved.
-This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
-This library 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 Lesser General Public License for more details.
-You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-* QtHelp Module
-_____________
-Copyright (C) 2004, 2005 Daniel M. Duley
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* QImage
-____________
-This file is part of the KDE project
-Copyright (C) 2005-2007 Matthias Kretz <kretz@kde.org>
-Copyright (C) 2007-2008 Trolltech ASA.
-This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation.
-This library 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 Library General Public License for more details.
-You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-* Phonon Module
-____________
-Copyright (C) 2007-2008, Apple, Inc.
-All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-* Neither the name of Apple, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-Contributions to the Following QtGui Files:
-* qapplication_cocoa_p.h
-* qapplication_mac.mm
-* qdesktopwidget_mac.mm
-* qeventdispatcher_mac.mm
-* qeventdispatcher_mac_p.h
-* qmacincludes_mac.h
-* qt_cocoa_helpers.mm
-* qt_cocoa_helpers_p.h
-* qwidget_mac.mm
-* qsystemtrayicon_mac.mm
-
-____________
-Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
-This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own license. You may use this file under your Qt license. Following description is copied from their original file headers. Contact immodule-qt@freedesktop.org if any conditions of this licensing are not clear to you.
-* QInputContextFactory
-* QInputContext
-* QInputContextPlugin
-____________
-Copyright (c) 2003, 2006 Matteo Frigo
-Copyright (c) 2003, 2006 Massachusetts Institute of Technology
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-* QTestLib Manual
-____________
-Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-All rights reserved.
-Contact: Qt Development Frameworks Information (qt-info@nokia.com)
-You may use this file under the terms of the BSD license as follows:
-"Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-* Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-* QAxServer Module
-* The qtmain Library
-* QAxContainer Module
-_____________
-Copyright 1985, 1987, 1998 The Open Group
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group.
-* Parts of the internal QKeyMapper class on X11 platforms
-____________
-pnmscale.c - read a portable anymap and scale it
-Copyright (C) 1989, 1991 by Jef Poskanzer.
-Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.
-* Parts of the internal QImageSmoothScaler::scale() function use code based on pnmscale.c by Jef Poskanzer.
-____________
-Qt Creator 3rd Party Components
-___________
-Open Source front-end for C++ (license MIT), enhanced for use in Qt Creator.
-Roberto Raggi <roberto.raggi@gmail.com>
-QtCreator/src/shared/cplusplus
-___________
-Botan, a C++ crypto library. Version 1.8.8
-Copyright (C) 1999-2004 The Botan Project. All rights reserved.
-Copyright (C) 1999-2009 Jack Lloyd
-2001 Peter J Jones
-2004-2007 Justin Karneges
-2005 Matthew Gregan
-2005-2006 Matt Johnston
-2006 Luca Piccarreta
-2007 Yves Jerschow
-2007-2008 FlexSecure GmbH
-2007-2008 Technische Universitat Darmstadt
-2007-2008 Falko Strenzke
-2007-2008 Martin Doering
-2007 Manuel Hartl
-2007 Christoph Ludwig
-2007 Patrick Sona
-All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-The source code of Botan C++ crypto library can be found here:
-QtCreator/src/libs/3rdparty
-http://qt.gitorious.org/qt-creator/qt-creator/trees/master/src/libs/3rdparty
-_________
-NetSieben SSH Library is a Secure Shell client library for C++. Version 1.3.2
-Commercial License: For organizations who do not want to release the source code for their applications as open source/ free software; in other words they do not want to comply with the GNU General Public License (GPL) or Q Public License.
-Non Commercial / Open Source License: NetSieben believes in contributing back to the open source community, thus it has released the SSH Library under Q Public License as it is defined by Trolltech AS of Norway. The Open Source License allows the user to use software under an open source / free software license, and distribute it freely. The software can be used at no charge with the condition that if the user uses the SSH Library in an application they wish to redistribute, then the complete source code for your application must be available and freely redistributable under reasonable conditions. For more information on the used QPL License see: QtCreator/src/libs/3rdparty/net7ssh/LICENSE.QPL
-The source code of NetSieben Secure Shell C++ Library can be found here:
-QtCreator/src/libs/3rdparty
-http://qt.gitorious.org/qt-creator/qt-creator/trees/master/src/libs/3rdparty
-src/plugins/imageviewer/imageview.cpp and src/plugins/imageviewer/imageview.h
-All rights reserved.
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-______________
-Qt Mobility API's
-_____________
-Copyright (c) 2001-2006 Wolfram Gloger
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the name of Wolfram Gloger may not be used in any advertising or publicity relating to the software.
-
-THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>
-IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-See <tt>src/3rdparty/ptmalloc/COPYRIGHT</tt> for license details.
-
-___________
-Copyright (c) 1988-1997 Sam Leffler
-Copyright (c) 1991-1997 Silicon Graphics, Inc.
-Copyright (C) 2004, Andrey Kiselev &lt;dron@ak4719.spb.edu&gt;
-Copyright (c) 1997 Greg Ward Larson
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-____________
-Copyright (c) 1996-1997 Sam Leffler
-Copyright (c) 1996 Pixar
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Pixar, Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>
-IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-See <tt>src/3rdparty/libtiff/COPYRIGHT</tt> for license details.</p>
-
-______________
-Copyright (C) 2000-2004, International Business Machines Corporation and others. All Rights Reserved.
-Copyright (C) 2007 Apple Inc. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
-
-__________
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-____________
- Copyright 1985, 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group.
-___________
-
-Copyright (C) 1989, 1991 by Jef Poskanzer.
-Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is"; without express or implied warranty.
-
-____________
-
-Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
-
-Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-____________
-Madde Tools
-
-Copyright (C) 1999-2004 The Botan Project. All rights reserved.
-Copyright (C) 1999-2009 Jack Lloyd
- 2001 Peter J Jones
- 2004-2007 Justin Karneges
- 2005 Matthew Gregan
- 2005-2006 Matt Johnston
- 2006 Luca Piccarreta
- 2007 Yves Jerschow
- 2007-2008 FlexSecure GmbH
- 2007-2008 Technische Universitat Darmstadt
- 2007-2008 Falko Strenzke
- 2007-2008 Martin Doering
- 2007 Manuel Hartl
- 2007 Christoph Ludwig
- 2007 Patrick Sona
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-____________
-Symbian ^3 with 5.0 support and labelled "Symbian Complementary Package"
-
-This package is under the terms of the Eclipse Public License version 1.0. Open source software contained in this package is licensed under the terms specific in such files included in the source code.
-
-
-
-
-1
-
-
diff --git a/installerbuilder/libinstaller/adminauthorization.cpp b/installerbuilder/libinstaller/adminauthorization.cpp
index fa2a091b1..1fafac9dc 100644
--- a/installerbuilder/libinstaller/adminauthorization.cpp
+++ b/installerbuilder/libinstaller/adminauthorization.cpp
@@ -60,11 +60,3 @@ void AdminAuthorizationBase::setAuthorized()
{
d->authorized = true;
}
-
-#ifdef Q_WS_MAC
-bool AdminAuthorization::hasAdminRights()
-{
- // as this is only required on Windows
- return false;
-}
-#endif
diff --git a/installerbuilder/libinstaller/adminauthorization_mac.cpp b/installerbuilder/libinstaller/adminauthorization_mac.cpp
index 50ba63a25..7e210a2cc 100644
--- a/installerbuilder/libinstaller/adminauthorization_mac.cpp
+++ b/installerbuilder/libinstaller/adminauthorization_mac.cpp
@@ -35,70 +35,85 @@
#include <Security/Authorization.h>
#include <Security/AuthorizationTags.h>
+#include <QtCore/QStringList>
+#include <QtCore/QVector>
+
#include <unistd.h>
-#include <QStringList>
-#include <QVector>
+
+// -- AdminAuthorization::Private
class AdminAuthorization::Private
{
public:
Private()
- : auth( 0 )
- {
- }
+ : auth(0) { }
AuthorizationRef auth;
};
+
+// -- AdminAuthorization
+
AdminAuthorization::AdminAuthorization()
{
- AuthorizationCreate( 0, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &d->auth );
+ AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &d->auth);
}
AdminAuthorization::~AdminAuthorization()
{
- AuthorizationFree( d->auth, kAuthorizationFlagDestroyRights );
+ AuthorizationFree(d->auth, kAuthorizationFlagDestroyRights);
}
bool AdminAuthorization::authorize()
{
- if( geteuid() == 0 )
+ if (geteuid() == 0)
setAuthorized();
- if( isAuthorized() )
+ if (isAuthorized())
return true;
- AuthorizationItem item = { kAuthorizationRightExecute, 0, NULL, 0 };
- const AuthorizationRights rights = { 1, &item };
-
- const AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
-
- const int result = AuthorizationCopyRights( d->auth, &rights, 0, flags, 0 );
- if( result != 0 )
+ AuthorizationItem item;
+ item.name = kAuthorizationRightExecute;
+ item.valueLength = 0;
+ item.value = NULL;
+ item.flags = 0;
+
+ AuthorizationRights rights;
+ rights.count = 1;
+ rights.items = &item;
+
+ const AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed
+ | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
+
+ const OSStatus result = AuthorizationCopyRights(d->auth, &rights, kAuthorizationEmptyEnvironment,
+ flags, 0);
+ if (result != errAuthorizationSuccess)
return false;
- seteuid( 0 );
+ seteuid(0);
setAuthorized();
emit authorized();
return true;
}
-
-bool AdminAuthorization::execute( QWidget*, const QString& program, const QStringList& arguments )
+
+bool AdminAuthorization::execute(QWidget*, const QString& program, const QStringList& arguments)
{
- const QByteArray utf8Program = program.toUtf8();
- const char* const prog = utf8Program.data();
- QVector< QByteArray > utf8Args;
- QVector< char* > args;
- for( QStringList::const_iterator it = arguments.begin(); it != arguments.end(); ++it )
- {
- utf8Args.push_back( it->toUtf8() );
- args.push_back( utf8Args.last().data() );
+ QVector<char* > args;
+ QVector<QByteArray> utf8Args;
+ foreach (const QString &argument, arguments) {
+ utf8Args.push_back(argument.toUtf8());
+ args.push_back(utf8Args.last().data());
}
- args.push_back( 0 );
+ args.push_back(0);
- const AuthorizationFlags flags = kAuthorizationFlagDefaults;
-
- const int result = AuthorizationExecuteWithPrivileges( d->auth, prog, flags, args.data(), 0 );
- return result == 0;
+ const QByteArray utf8Program = program.toUtf8();
+ const OSStatus result = AuthorizationExecuteWithPrivileges(d->auth, utf8Program.data(),
+ kAuthorizationFlagDefaults, args.data(), 0);
+ return result == errAuthorizationSuccess;
+}
+
+bool AdminAuthorization::hasAdminRights()
+{
+ return geteuid() == 0;
}
diff --git a/installerbuilder/libinstaller/adminauthorization_win.cpp b/installerbuilder/libinstaller/adminauthorization_win.cpp
index 99820d160..a734e78cf 100644
--- a/installerbuilder/libinstaller/adminauthorization_win.cpp
+++ b/installerbuilder/libinstaller/adminauthorization_win.cpp
@@ -32,51 +32,14 @@
**************************************************************************/
#include "adminauthorization.h"
-#include "windows.h"
+#include <common/utils.h>
-#include <QDir>
-#include <QStringList>
-#include <QVector>
-#include <QDebug>
-
-// from qprocess_win.cpp
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
-
- for (int i=0; i<arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
- // escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- QString endQuote(QLatin1Char('\"'));
- int i = tmp.length();
- while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
- --i;
- endQuote += QLatin1Char('\\');
- }
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
- } else {
- args += QLatin1Char(' ') + tmp;
- }
- }
- return args;
-}
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QStringList>
+#include <QtCore/QVector>
+#include <windows.h>
class AdminAuthorization::Private
{
@@ -125,9 +88,8 @@ bool AdminAuthorization::hasAdminRights()
bool AdminAuthorization::execute( QWidget*, const QString& program, const QStringList& arguments )
{
qDebug() << Q_FUNC_INFO;
- //const QString file = qt_create_commandline( program, QStringList() );
- const QString args = qt_create_commandline( QString(), arguments );
const QString file = QDir::toNativeSeparators( program );
+ const QString args = QInstaller::createCommandline( QString(), arguments );
const int len = GetShortPathNameW( (wchar_t*)file.utf16(), 0, 0 );
if( len == 0 )
diff --git a/installerbuilder/libinstaller/adminauthorization_x11.cpp b/installerbuilder/libinstaller/adminauthorization_x11.cpp
index e6e9d832e..385e41853 100644
--- a/installerbuilder/libinstaller/adminauthorization_x11.cpp
+++ b/installerbuilder/libinstaller/adminauthorization_x11.cpp
@@ -33,7 +33,6 @@
#include "adminauthorization.h"
#include <QtCore/QFile>
-#include <QtCore/QProcess>
#include <QtGui/QApplication>
#include <QtGui/QInputDialog>
diff --git a/installerbuilder/libinstaller/componentmodel.cpp b/installerbuilder/libinstaller/componentmodel.cpp
new file mode 100644
index 000000000..934f59094
--- /dev/null
+++ b/installerbuilder/libinstaller/componentmodel.cpp
@@ -0,0 +1,408 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "componentmodel.h"
+
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+
+
+namespace QInstaller {
+
+ComponentModel::ComponentModel(int columns, Installer *parent)
+ : QAbstractItemModel(parent)
+ , m_installer(parent)
+ , m_rootIndex(0)
+{
+ m_headerData.insert(0, columns, QVariant());
+
+ connect(this, SIGNAL(modelReset()), this, SLOT(slotModelReset()));
+ connect(this, SIGNAL(checkStateChanged(QModelIndex)), this, SLOT(slotCheckStateChanged(QModelIndex)));
+}
+
+ComponentModel::~ComponentModel()
+{
+}
+
+int ComponentModel::rowCount(const QModelIndex &parent) const
+{
+ if (Component *component = componentFromIndex(parent))
+ return component->childCount();
+ return m_rootComponentList.count();
+}
+
+int ComponentModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_headerData.size();
+}
+
+QModelIndex ComponentModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ if (Component *childComponent = componentFromIndex(child)) {
+ if (Component *parent = childComponent->parentComponent()) {
+ if (!m_rootComponentList.contains(parent))
+ return createIndex(parent->indexInParent(), 0, parent);
+ return createIndex(child.row(), 0, parent);
+ }
+ }
+
+ return QModelIndex();
+}
+
+QModelIndex ComponentModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (parent.isValid() && (row >= rowCount(parent) || column >= columnCount()))
+ return QModelIndex();
+
+ if (Component *parentComponent = componentFromIndex(parent)) {
+ if (Component *childComponent = parentComponent->childAt(row))
+ return createIndex(row, column, childComponent);
+ } else if (row < m_rootComponentList.count()) {
+ return createIndex(row, column, m_rootComponentList.at(row));
+ }
+
+ return QModelIndex();
+}
+
+QVariant ComponentModel::data(const QModelIndex &index, int role) const
+{
+ if (Component *component = componentFromIndex(index)) {
+ if (index.column() > 0) {
+ if (role == Qt::CheckStateRole)
+ return QVariant();
+ if (role == Qt::EditRole || role == Qt::DisplayRole || role == Qt::ToolTipRole)
+ return component->data(Qt::UserRole + index.column());
+ }
+ return component->data(role);
+ }
+ return QVariant();
+}
+
+bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid())
+ return false;
+
+ Component *component = componentFromIndex(index);
+ if (!component)
+ return false;
+
+ component->setData(value, role);
+
+ emit dataChanged(index, index);
+ if (role == Qt::CheckStateRole)
+ emit checkStateChanged(index);
+
+ return true;
+}
+
+QVariant ComponentModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Vertical || section < 0 || section >= columnCount())
+ return QAbstractItemModel::headerData(section, orientation, role);
+ return m_headerData.at(section);
+}
+
+bool ComponentModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
+ int role)
+{
+ if (orientation == Qt::Vertical || section < 0 || section >= columnCount())
+ return QAbstractItemModel::setHeaderData(section, orientation, value, role);
+
+ m_headerData.replace(section, value);
+ emit headerDataChanged(orientation, section, section);
+
+ return true;
+}
+
+Qt::ItemFlags ComponentModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::NoItemFlags;
+
+ if (Component *component = componentFromIndex(index))
+ return component->flags();
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
+}
+
+void ComponentModel::setRootComponents(QList<Component*> rootComponents)
+{
+ beginResetModel();
+
+ m_indexByNameCache.clear();
+ m_rootComponentList.clear();
+ m_initialCheckedList.clear();
+ m_currentCheckedList.clear();
+
+ m_rootIndex = 0;
+ m_rootComponentList = rootComponents;
+
+ endResetModel();
+}
+
+void ComponentModel::appendRootComponents(QList<Component*> rootComponents)
+{
+ beginResetModel();
+
+ m_indexByNameCache.clear();
+
+ m_rootIndex = m_rootComponentList.count() - 1;
+ m_rootComponentList += rootComponents;
+
+ endResetModel();
+}
+
+Installer* ComponentModel::installer() const
+{
+ return m_installer;
+}
+
+bool ComponentModel::defaultCheckState() const
+{
+ return m_initialCheckedList == m_currentCheckedList;
+}
+
+bool ComponentModel::hasCheckedComponents() const
+{
+ return !m_currentCheckedList.isEmpty();
+}
+
+QList<Component*> ComponentModel::checkedComponents() const
+{
+ QList<Component*> list;
+ foreach (const QString &name, m_currentCheckedList)
+ list.append(componentFromIndex(indexFromComponentName(name)));
+ return list;
+}
+
+QModelIndex ComponentModel::indexFromComponentName(const QString &name) const
+{
+ if (m_indexByNameCache.isEmpty()) {
+ for (int i = 0; i < m_rootComponentList.count(); ++i)
+ updateCache(index(i, 0, QModelIndex()));
+ }
+ return m_indexByNameCache.value(name, QModelIndex());
+}
+
+Component* ComponentModel::componentFromIndex(const QModelIndex &index) const
+{
+ if (index.isValid())
+ return static_cast<Component*>(index.internalPointer());
+ return 0;
+}
+
+// -- public slots
+
+void ComponentModel::selectAll()
+{
+ m_currentCheckedList = m_currentCheckedList.unite(select(Qt::Checked));
+ emit defaultCheckStateChanged(m_initialCheckedList != m_currentCheckedList);
+}
+
+void ComponentModel::deselectAll()
+{
+ m_currentCheckedList = m_currentCheckedList.subtract(select(Qt::Unchecked));
+ emit defaultCheckStateChanged(m_initialCheckedList != m_currentCheckedList);
+}
+
+void ComponentModel::selectDefault()
+{
+ m_currentCheckedList = m_currentCheckedList.subtract(select(Qt::Unchecked));
+ foreach (const QString &name, m_initialCheckedList)
+ setData(indexFromComponentName(name), Qt::Checked, Qt::CheckStateRole);
+ emit defaultCheckStateChanged(m_initialCheckedList != m_currentCheckedList);
+}
+
+// -- private slots
+
+void ComponentModel::slotModelReset()
+{
+ if (installer()->runMode() == QInstaller::AllMode) {
+ for (int i = m_rootIndex; i < m_rootComponentList.count(); ++i) {
+ foreach (Component *child, m_rootComponentList.at(i)->childs()) {
+ if (child->checkState() == Qt::Checked && !child->isTristate())
+ m_initialCheckedList.insert(child->name());
+ }
+ }
+ m_currentCheckedList += m_initialCheckedList;
+ select(Qt::Unchecked);
+ } else {
+ foreach (Component *child, m_rootComponentList) {
+ if (child->checkState() == Qt::Checked && !child->isTristate())
+ m_initialCheckedList.insert(child->name());
+ }
+ m_currentCheckedList += m_initialCheckedList;
+ }
+
+ foreach (const QString &name, m_currentCheckedList)
+ setData(indexFromComponentName(name), Qt::Checked, Qt::CheckStateRole);
+}
+
+static Qt::CheckState verifyPartiallyChecked(Component *component)
+{
+ int checked = 0;
+ int unchecked = 0;
+ int virtualChilds = 0;
+
+ const int count = component->childCount();
+ for (int i = 0; i < count; ++i) {
+ Component *const child = component->childAt(i);
+ if (!child->isVirtual()) {
+ switch (component->childAt(i)->checkState()) {
+ case Qt::Checked: {
+ ++checked;
+ } break;
+ case Qt::Unchecked: {
+ ++unchecked;
+ } break;
+ default:
+ break;
+ }
+ } else {
+ ++virtualChilds;
+ }
+ }
+
+ if ((checked + virtualChilds) == count)
+ return Qt::Checked;
+
+ if ((unchecked + virtualChilds) == count)
+ return Qt::Unchecked;
+
+ return Qt::PartiallyChecked;
+}
+
+void ComponentModel::slotCheckStateChanged(const QModelIndex &index)
+{
+ Component *component = componentFromIndex(index);
+ if (!component)
+ return;
+
+ if (component->checkState() == Qt::Checked && !component->isTristate())
+ m_currentCheckedList.insert(component->name());
+ else if (component->checkState() == Qt::Unchecked && !component->isTristate())
+ m_currentCheckedList.remove(component->name());
+ emit defaultCheckStateChanged(m_initialCheckedList != m_currentCheckedList);
+
+ if (component->isVirtual())
+ return;
+
+ const Qt::CheckState state = component->checkState();
+ if (component->isTristate()) {
+ if (state == Qt::PartiallyChecked) {
+ component->setCheckState(verifyPartiallyChecked(component));
+ return;
+ }
+
+ QModelIndexList notCheckable;
+ foreach (Component *child, component->childs()) {
+ const QModelIndex &idx = indexFromComponentName(child->name());
+ if (child->isCheckable()) {
+ if (child->checkState() != state && !child->isVirtual())
+ setData(idx, state, Qt::CheckStateRole);
+ } else {
+ notCheckable.append(idx);
+ }
+ }
+
+ if (state == Qt::Unchecked && !notCheckable.isEmpty()) {
+ foreach (const QModelIndex &idx, notCheckable)
+ setData(idx, idx.data(Qt::CheckStateRole), Qt::CheckStateRole);
+ }
+ } else {
+ QList<Component*> parents;
+ while (0 != component->parentComponent()) {
+ parents.append(component->parentComponent());
+ component = parents.last();
+ }
+
+ foreach (Component *parent, parents) {
+ if (parent->isCheckable()) {
+ const QModelIndex &idx = indexFromComponentName(parent->name());
+ if (parent->checkState() == Qt::PartiallyChecked) {
+ setData(idx, verifyPartiallyChecked(parent), Qt::CheckStateRole);
+ } else {
+ setData(idx, Qt::PartiallyChecked, Qt::CheckStateRole);
+ }
+ }
+ }
+ }
+}
+
+// -- private
+
+QSet<QString> ComponentModel::select(Qt::CheckState state)
+{
+ QSet<QString> changed;
+ for (int i = 0; i < m_rootComponentList.count(); ++i) {
+ const QList<Component*> &children = m_rootComponentList.at(i)->childs();
+ foreach (Component *child, children) {
+ if (child->isCheckable()) {
+ child->setCheckState(state);
+ changed.insert(child->name());
+ }
+ }
+ setData(index(i, 0, QModelIndex()), state, Qt::CheckStateRole);
+ }
+ return changed;
+}
+
+void ComponentModel::updateCache(const QModelIndex &parent) const
+{
+ const QModelIndexList &list = collectComponents(parent);
+ foreach (const QModelIndex &index, list) {
+ if (Component *component = componentFromIndex(index))
+ m_indexByNameCache.insert(component->name(), index);
+ }
+ m_indexByNameCache.insert((static_cast<Component*> (parent.internalPointer()))->name(), parent);
+}
+
+QModelIndexList ComponentModel::collectComponents(const QModelIndex &parent) const
+{
+ QModelIndexList list;
+ for (int i = 0; i < rowCount(parent) ; ++i) {
+ const QModelIndex &next = index(i, 0, parent);
+ if (Component *component = componentFromIndex(next)) {
+ if (component->childCount() > 0)
+ list += collectComponents(next);
+ }
+ list.append(next);
+ }
+ return list;
+}
+
+} // namespace QInstaller
diff --git a/installerbuilder/libinstaller/componentmodel.h b/installerbuilder/libinstaller/componentmodel.h
new file mode 100644
index 000000000..33aee22d9
--- /dev/null
+++ b/installerbuilder/libinstaller/componentmodel.h
@@ -0,0 +1,107 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef COMPONENTMODEL_H
+#define COMPONENTMODEL_H
+
+#include "qinstallerglobal.h"
+
+#include <QtCore/QAbstractItemModel>
+#include <QtCore/QList>
+#include <QtCore/QSet>
+#include <QtCore/QVector>
+
+namespace QInstaller {
+class Component;
+class Installer;
+
+class INSTALLER_EXPORT ComponentModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit ComponentModel(int columns, Installer *parent = 0);
+ ~ComponentModel();
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QModelIndex parent(const QModelIndex &child) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
+ int role = Qt::EditRole);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void setRootComponents(QList<Component*> rootComponents);
+ void appendRootComponents(QList<Component*> rootComponents);
+
+ Installer* installer() const;
+
+ bool defaultCheckState() const;
+ bool hasCheckedComponents() const;
+ QList<Component*> checkedComponents() const;
+
+ QModelIndex indexFromComponentName(const QString &name) const;
+ Component* componentFromIndex(const QModelIndex &index) const;
+
+public Q_SLOTS:
+ void selectAll();
+ void deselectAll();
+ void selectDefault();
+
+Q_SIGNALS:
+ void defaultCheckStateChanged(bool changed);
+ void checkStateChanged(const QModelIndex &index);
+
+private Q_SLOTS:
+ void slotModelReset();
+ void slotCheckStateChanged(const QModelIndex &index);
+
+private:
+ QSet<QString> select(Qt::CheckState state);
+ void updateCache(const QModelIndex &parent) const;
+ QModelIndexList collectComponents(const QModelIndex &parent) const;
+
+private:
+ Installer *m_installer;
+
+ int m_rootIndex;
+ QVector<QVariant> m_headerData;
+ QSet<QString> m_initialCheckedList;
+ QSet<QString> m_currentCheckedList;
+ QList<Component*> m_rootComponentList;
+
+ mutable QMap<QString, QPersistentModelIndex> m_indexByNameCache;
+};
+
+} // namespace QInstaller
+
+#endif // COMPONENTMODEL_H
diff --git a/installerbuilder/libinstaller/componentselectiondialog.cpp b/installerbuilder/libinstaller/componentselectiondialog.cpp
deleted file mode 100644
index a45524ee0..000000000
--- a/installerbuilder/libinstaller/componentselectiondialog.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "componentselectiondialog.h"
-#include "ui_componentselectiondialog.h"
-
-#include <QPushButton>
-#include <QHeaderView>
-
-#include "qinstaller.h"
-#include "qinstallercomponent.h"
-#include "qinstallercomponentmodel.h"
-
-using namespace QInstaller;
-
-class ComponentSelectionDialog::Private : public QObject
-{
- Q_OBJECT
-public:
- Private( ComponentSelectionDialog* qq, Installer* inst )
- : q( qq ),
- installer( inst )
- {
- }
-
- void selectionChanged()
- {
- // no component selected disables the ok button
- const QList< Component* > components = installer->components( true, UpdaterMode );
- int selectionCount = 0;
- for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
- {
- if( (*it)->isSelected( UpdaterMode ) )
- ++selectionCount;
- }
-
- installBtn->setEnabled( selectionCount > 0 );
- installBtn->setText( selectionCount > 1 ? tr( "Install %1 Items" ).arg( selectionCount ) :
- selectionCount == 1 ? tr( "Install 1 Item" ) : tr( "Install" ) );
-
- if (selectionCount > 0) {
- ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Cancel"));
- } else {
- ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Close"));
- }
-
- const QModelIndex index = ui.treeView->currentIndex();
- if( !index.isValid() )
- {
- ui.textBrowser->clear();
- return;
- }
-
- ui.textBrowser->setHtml( index.sibling( index.row(), 0 ).data( Qt::ToolTipRole ).toString() );
- }
-
- void modelReset()
- {
- ui.treeView->header()->resizeSection( 0, ui.labelTitle->sizeHint().width() / 1.5 );
- ui.treeView->header()->setStretchLastSection( true );
- for ( int i = 0; i < ui.treeView->model()->columnCount(); ++i )
- ui.treeView->resizeColumnToContents( i );
-
- bool hasChildren = false;
- const int rowCount = ui.treeView->model()->rowCount();
- for( int row = 0; row < rowCount && !hasChildren; ++row )
- hasChildren = ui.treeView->model()->hasChildren( ui.treeView->model()->index( row, 0 ) );
- ui.treeView->setRootIsDecorated( hasChildren );
- ui.treeView->expandToDepth( 0 );
- selectionChanged();
- }
-
-private:
- ComponentSelectionDialog* const q;
-
-public:
- Ui::ComponentSelectionDialog ui;
- Installer* const installer;
- ComponentModel* componentModel;
- QPushButton* installBtn;
-
-public Q_SLOTS:
- void selectAll();
- void deselectAll();
-};
-
-void ComponentSelectionDialog::Private::selectAll()
-{
- QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
- Q_FOREACH( Component* comp, updaterComponents )
- {
- comp->setSelected( true, UpdaterMode );
- }
-}
-
-void ComponentSelectionDialog::Private::deselectAll()
-{
- QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
- Q_FOREACH( Component* comp, updaterComponents )
- {
- comp->setSelected( false, UpdaterMode );
- }
-}
-
-void ComponentSelectionDialog::refreshDialog()
-{
- d->selectionChanged();
-}
-
-ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidget* parent )
- : QDialog( parent ),
- d( new Private( this, installer ) )
-{
- d->ui.setupUi( this );
- d->componentModel = new ComponentModel( installer, UpdaterMode );
- d->ui.treeView->setModel( d->componentModel );
-
- d->ui.labelLicenseBlurb->setAttribute( Qt::WA_MacSmallSize );
- d->ui.labelSubTitle->setAttribute( Qt::WA_MacSmallSize );
- d->ui.treeView->setAttribute( Qt::WA_MacShowFocusRect, false );
- d->ui.textBrowser->setAttribute( Qt::WA_MacShowFocusRect, false );
- d->ui.splitter->setCollapsible( 0, false );
- d->installBtn = d->ui.buttonBox->addButton( tr( "Install" ), QDialogButtonBox::AcceptRole ) ;
- if ( !d->ui.buttonBox->button( QDialogButtonBox::Cancel )->icon().isNull() )
- d->installBtn->setIcon( style()->standardIcon( QStyle::SP_DialogOkButton ) );
-
- d->ui.icon->setPixmap( windowIcon().pixmap( 48, 48 ) );
-
- connect( d->ui.treeView->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
- this, SLOT( selectionChanged() ) );
- connect( d->ui.treeView->model(), SIGNAL( modelReset() ),
- this, SLOT( modelReset() ) );
- connect( d->ui.treeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ),
- this, SLOT( selectionChanged() ) );
- connect( d->installBtn, SIGNAL( clicked() ), this, SIGNAL( requestUpdate() ) );
- connect( d->ui.selectAll, SIGNAL( clicked() ), d.get(), SLOT( selectAll() ), Qt::QueuedConnection );
- connect( d->ui.deselectAll, SIGNAL( clicked() ), d.get(), SLOT( deselectAll() ), Qt::QueuedConnection );
-
-
- d->ui.treeView->setCurrentIndex( d->ui.treeView->model()->index( 0, 0 ) );
- d->ui.splitter->setStretchFactor( 0, 2 );
- d->ui.splitter->setStretchFactor( 1, 1 );
- d->ui.treeView->header()->setStretchLastSection( true );
- for ( int i = 0; i < d->ui.treeView->model()->columnCount(); ++i )
- d->ui.treeView->resizeColumnToContents( i );
- d->selectionChanged();
- d->modelReset();
-}
-
-ComponentSelectionDialog::~ComponentSelectionDialog()
-{
-}
-
-void ComponentSelectionDialog::selectAll() {
- d->selectAll();
-}
-
-void ComponentSelectionDialog::deselectAll() {
- d->deselectAll();
-}
-
-void ComponentSelectionDialog::install() {
- emit requestUpdate();
-}
-
-void ComponentSelectionDialog::selectComponent( const QString& id ) {
- const QModelIndex idx = d->componentModel->findComponent( id );
- if ( !idx.isValid() )
- return;
- d->componentModel->setData( idx, Qt::Checked );
-}
-
-void ComponentSelectionDialog::deselectComponent( const QString& id ) {
- const QModelIndex idx = d->componentModel->findComponent( id );
- if ( !idx.isValid() )
- return;
- d->componentModel->setData( idx, Qt::Unchecked );
-}
-
-#include "moc_componentselectiondialog.cpp"
-#include "componentselectiondialog.moc"
diff --git a/installerbuilder/libinstaller/copydirectoryoperation.cpp b/installerbuilder/libinstaller/copydirectoryoperation.cpp
index 91a9d847f..2159c4d43 100644
--- a/installerbuilder/libinstaller/copydirectoryoperation.cpp
+++ b/installerbuilder/libinstaller/copydirectoryoperation.cpp
@@ -32,12 +32,23 @@
**************************************************************************/
#include "copydirectoryoperation.h"
-#include <QFileInfo>
-#include <QDir>
-#include <QDirIterator>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFileInfo>
using namespace QInstaller;
+class AutoPush
+{
+public:
+ AutoPush(CopyDirectoryOperation *op)
+ : m_op(op) {}
+ ~AutoPush() { m_op->setValue(QLatin1String("files"), m_files); }
+
+ QStringList m_files;
+ CopyDirectoryOperation *m_op;
+};
+
/*
TRANSLATOR QInstaller::CopyDirectoryOperation
*/
@@ -53,15 +64,6 @@ CopyDirectoryOperation::~CopyDirectoryOperation()
void CopyDirectoryOperation::backup()
{
-
-}
-
-void CopyDirectoryOperation::addFileToFileList(const QString& fileName)
-{
- QStringList files = value(QLatin1String("files")).toStringList();
- files.push_front(fileName);
- setValue(QLatin1String("files"), files);
- emit outputTextChanged(fileName);
}
bool CopyDirectoryOperation::performOperation()
@@ -69,8 +71,8 @@ bool CopyDirectoryOperation::performOperation()
const QStringList args = arguments();
if (args.count() != 2) {
setError(InvalidArguments);
- setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( args.count()));
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.").arg(name())
+ .arg(args.count()));
return false;
}
const QString sourcePath = args.at(0);
@@ -78,20 +80,19 @@ bool CopyDirectoryOperation::performOperation()
const QFileInfo sourceInfo(sourcePath);
const QFileInfo targetInfo(targetPath);
- if (!sourceInfo.exists() || !sourceInfo.isDir()
- || !targetInfo.exists() || !targetInfo.isDir()) {
+ if (!sourceInfo.exists() || !sourceInfo.isDir() || !targetInfo.exists() || !targetInfo.isDir()) {
setError(InvalidArguments);
- setErrorString(tr("Invalid arguments in %0: Directories are invalid: %1 %2")
- .arg(name()).arg(sourcePath).arg(targetPath));
+ setErrorString(tr("Invalid arguments in %0: Directories are invalid: %1 %2").arg(name())
+ .arg(sourcePath).arg(targetPath));
return false;
}
const QDir sourceDir = sourceInfo.absoluteDir();
const QDir targetDir = targetInfo.absoluteDir();
- QDirIterator it(sourceInfo.absoluteFilePath(),
- QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden,
- QDirIterator::Subdirectories);
+ AutoPush autoPush(this);
+ QDirIterator it(sourceInfo.absoluteFilePath(), QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden,
+ QDirIterator::Subdirectories);
while (it.hasNext()) {
const QString itemName = it.next();
const QFileInfo itemInfo(sourceDir.absoluteFilePath(itemName));
@@ -100,15 +101,17 @@ bool CopyDirectoryOperation::performOperation()
// Check if symlink target is inside copied directory
const QString linkTarget = itemInfo.symLinkTarget();
if (linkTarget.startsWith(sourceDir.absolutePath())) {
- // create symlink to copied location
- const QString linkTargetRelative = sourceDir.relativeFilePath(linkTarget);
- QFile(targetDir.absoluteFilePath(linkTargetRelative)).link(targetDir.absoluteFilePath(relativePath));
+ // create symlink to copied location
+ const QString linkTargetRelative = sourceDir.relativeFilePath(linkTarget);
+ QFile(targetDir.absoluteFilePath(linkTargetRelative))
+ .link(targetDir.absoluteFilePath(relativePath));
} else {
- // create symlink pointing to original location
+ // create symlink pointing to original location
QFile(linkTarget).link(targetDir.absoluteFilePath(relativePath));
}
// add file entry
- addFileToFileList(targetDir.absoluteFilePath(relativePath));
+ autoPush.m_files.prepend(targetDir.absoluteFilePath(relativePath));
+ emit outputTextChanged(autoPush.m_files.first());
} else if (itemInfo.isDir()) {
if (!targetDir.mkpath(targetDir.absoluteFilePath(relativePath))) {
setError(InvalidArguments);
@@ -118,12 +121,12 @@ bool CopyDirectoryOperation::performOperation()
} else {
if (!QFile::copy(sourceDir.absoluteFilePath(itemName), targetDir.absoluteFilePath(relativePath))) {
setError(InvalidArguments);
- setErrorString(tr("Could not copy %0 to %1")
- .arg(sourceDir.absoluteFilePath(itemName))
- .arg(targetDir.absoluteFilePath(relativePath)));
+ setErrorString(tr("Could not copy %0 to %1").arg(sourceDir.absoluteFilePath(itemName))
+ .arg(targetDir.absoluteFilePath(relativePath)));
return false;
}
- addFileToFileList(targetDir.absoluteFilePath(relativePath));
+ autoPush.m_files.prepend(targetDir.absoluteFilePath(relativePath));
+ emit outputTextChanged(autoPush.m_files.first());
}
}
return true;
@@ -133,7 +136,7 @@ bool CopyDirectoryOperation::undoOperation()
{
Q_ASSERT(arguments().count() == 2);
- QStringList files = value(QLatin1String("files")).toStringList();
+ const QStringList files = value(QLatin1String("files")).toStringList();
foreach (const QString &file, files) {
if (!QFile::remove(file)) {
setError(InvalidArguments);
@@ -144,8 +147,7 @@ bool CopyDirectoryOperation::undoOperation()
emit outputTextChanged(file);
}
- files.clear();
- setValue(QLatin1String("files"), files);
+ setValue(QLatin1String("files"), QStringList());
return true;
}
diff --git a/installerbuilder/libinstaller/copydirectoryoperation.h b/installerbuilder/libinstaller/copydirectoryoperation.h
index e700c6aca..f5db813e6 100644
--- a/installerbuilder/libinstaller/copydirectoryoperation.h
+++ b/installerbuilder/libinstaller/copydirectoryoperation.h
@@ -26,9 +26,10 @@
#ifndef COPYDIRECTORYOPERATION_H
#define COPYDIRECTORYOPERATION_H
+#include "installer_global.h"
+
#include <KDUpdater/UpdateOperation>
-#include "installer_global.h"
#include <QtCore/QObject>
@@ -46,16 +47,11 @@ public:
bool performOperation();
bool undoOperation();
bool testOperation();
- CopyDirectoryOperation* clone() const;
+ CopyDirectoryOperation *clone() const;
Q_SIGNALS:
- void outputTextChanged( const QString& progress );
//TODO: needs progress signal
-
-private Q_SLOTS:
-
-private:
- void addFileToFileList(const QString& fileName);
+ void outputTextChanged(const QString &progress);
};
}
diff --git a/installerbuilder/libinstaller/createdesktopentryoperation.cpp b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
index d514f761e..37f429400 100644
--- a/installerbuilder/libinstaller/createdesktopentryoperation.cpp
+++ b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
@@ -38,14 +38,11 @@
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
+#include <QProcess>
#if QT_VERSION >= 0x040600
#include <QProcessEnvironment>
-#else
-#include <QProcess>
#endif
-#include <QProcess>
-
using namespace QInstaller;
QString CreateDesktopEntryOperation::absoluteFileName()
diff --git a/installerbuilder/libinstaller/cryptosignatureverifier.h b/installerbuilder/libinstaller/cryptosignatureverifier.h
index 978ac8e44..096c6536e 100644
--- a/installerbuilder/libinstaller/cryptosignatureverifier.h
+++ b/installerbuilder/libinstaller/cryptosignatureverifier.h
@@ -26,39 +26,43 @@
#ifndef CRYPTOSIGNATUREVERIFIER_H
#define CRYPTOSIGNATUREVERIFIER_H
+#include "KDUpdater/kdupdatercrypto.h"
+
#include <KDUpdater/SignatureVerifier>
#include <KDUpdater/SignatureVerificationResult>
-#include "KDUpdater/kdupdatercrypto.h"
class CryptoSignatureVerifier : public KDUpdater::SignatureVerifier
{
public:
- explicit CryptoSignatureVerifier( const QByteArray& publicKey )
- : m_publicKey( publicKey )
+ explicit CryptoSignatureVerifier(const QByteArray &publicKey)
+ : m_publicKey(publicKey)
{
}
+
SignatureVerifier* clone() const
{
- return new CryptoSignatureVerifier( m_publicKey );
+ return new CryptoSignatureVerifier(m_publicKey);
}
- KDUpdater::SignatureVerificationResult verify( const QByteArray &data, const QByteArray& signature ) const
+
+ KDUpdater::SignatureVerificationResult verify(const QByteArray &data, const QByteArray &signature) const
{
KDUpdaterCrypto crypto;
- crypto.setPublicKey( m_publicKey );
+ crypto.setPublicKey(m_publicKey);
KDUpdater::SignatureVerificationResult r;
- r.setValidity( crypto.verify( data, signature ) ? KDUpdater::SignatureVerificationResult::ValidSignature : KDUpdater::SignatureVerificationResult::BadSignature );
- r.setErrorString( QObject::tr( "Bad signature" ) );
+ r.setValidity(crypto.verify(data, signature) ? KDUpdater::SignatureVerificationResult::ValidSignature
+ : KDUpdater::SignatureVerificationResult::BadSignature);
+ r.setErrorString( QObject::tr("Bad signature"));
return r;
}
+
QString type() const
- {
- return QLatin1String( "CryptoSignature" );
+ {
+ return QLatin1String("CryptoSignature");
}
private:
const QByteArray m_publicKey;
- KDUpdaterCrypto *m_crypto;
};
#endif
diff --git a/installerbuilder/libinstaller/downloadarchivesjob.cpp b/installerbuilder/libinstaller/downloadarchivesjob.cpp
index 374e4a3af..0767f82ec 100644
--- a/installerbuilder/libinstaller/downloadarchivesjob.cpp
+++ b/installerbuilder/libinstaller/downloadarchivesjob.cpp
@@ -32,311 +32,299 @@
**************************************************************************/
#include "downloadarchivesjob.h"
-#include <QFile>
-#include <QTimer>
-#include <QMessageBox>
-#include <QDebug>
-#include <QTimerEvent>
-
-#include <KDUpdater/FileDownloader>
-#include <KDUpdater/FileDownloaderFactory>
-
#include "common/binaryformatenginehandler.h"
#include "common/utils.h"
-
#include "cryptosignatureverifier.h"
+#include "messageboxhandler.h"
#include "qinstaller.h"
#include "qinstallercomponent.h"
-#include "messageboxhandler.h"
+
+#include <QtCore/QFile>
using namespace QInstaller;
using namespace KDUpdater;
-/*
-TRANSLATOR QInstaller::DownloadArchivesJob
-*/
-/**
- * Creates a new DownloadArchivesJob with \a parent.
- */
-DownloadArchivesJob::DownloadArchivesJob(const QByteArray& publicKey, Installer* parent )
- : KDJob( parent ),
- cancelled( false ),
- publicKey( publicKey ),
- downloader( 0 ),
- filesToDownload( 0 ),
- filesDownloaded( 0 ),
- parent( parent ),
- lastFileProgress(0),
- progressChangedTimerId(0)
+/*!
+ Creates a new DownloadArchivesJob with \a parent.
+*/
+DownloadArchivesJob::DownloadArchivesJob(const QByteArray &publicKey, Installer *installer)
+ : KDJob(installer),
+ m_installer(installer),
+ m_downloader(0),
+ m_archivesDownloaded(0),
+ m_archivesToDownloadCount(0),
+ m_canceled(false),
+ m_publicKey(publicKey),
+ m_lastFileProgress(0),
+ m_progressChangedTimerId(0)
{
- setCapabilities( Cancelable );
+ setCapabilities(Cancelable);
}
-/**
- * Destroys the DownloadArchivesJob.
- * All temporary files get deleted.
- */
+/*!
+ Destroys the DownloadArchivesJob.
+ All temporary files get deleted.
+*/
DownloadArchivesJob::~DownloadArchivesJob()
{
- for( QStringList::const_iterator it = temporaryFiles.constBegin(); it != temporaryFiles.constEnd(); ++it ) {
- QFile f( *it );
- if ( !f.remove() )
- qWarning( "Could not delete file %s: %s", qPrintable(*it), qPrintable(f.errorString()) );
+ foreach (const QString &fileName, m_temporaryFiles) {
+ QFile file(fileName);
+ if (!file.remove())
+ qWarning("Could not delete file %s: %s", qPrintable(fileName), qPrintable(file.errorString()));
}
- if( downloader != 0 )
- downloader->deleteLater();
+
+ if (m_downloader)
+ m_downloader->deleteLater();
}
-/**
- * Sets the archives to download. The first value of each pair contains the file name to register
- * the file in the installer's internal file system, the second one the source url.
- */
-void DownloadArchivesJob::setArchivesToDownload( const QList< QPair< QString, QString > >& archs )
+/*!
+ Sets the archives to download. The first value of each pair contains the file name to register
+ the file in the installer's internal file system, the second one the source url.
+*/
+void DownloadArchivesJob::setArchivesToDownload(const QList<QPair<QString, QString> > &archives)
{
- filesToDownload = archs.count();
- archives = archs;
+ m_archivesToDownload = archives;
+ m_archivesToDownloadCount = archives.count();
}
-/**
- * \reimp
- */
+/*!
+ \reimp
+*/
void DownloadArchivesJob::doStart()
{
- filesDownloaded = 0;
+ m_archivesDownloaded = 0;
fetchNextArchiveHash();
}
-/**
- * \reimp
- */
+/*!
+ \reimp
+*/
void DownloadArchivesJob::doCancel()
{
- cancelled = true;
- if( downloader != 0 )
- downloader->cancelDownload();
+ m_canceled = true;
+ if (m_downloader != 0)
+ m_downloader->cancelDownload();
}
void DownloadArchivesJob::fetchNextArchiveHash()
{
- if ( parent->testChecksum() )
- {
- if( cancelled )
- {
- finishWithError( tr( "Canceled" ) );
+ if (m_installer->testChecksum()) {
+ if (m_canceled) {
+ finishWithError(tr("Canceled"));
return;
}
- if( archives.isEmpty() )
- {
+ if (m_archivesToDownload.isEmpty()) {
emitFinished();
return;
}
- if( downloader != 0 )
- downloader->deleteLater();
+ if (m_downloader)
+ m_downloader->deleteLater();
- QString hashUrl = archives.first().second;
- hashUrl += QLatin1String( ".sha1" );
- const QUrl url( hashUrl );
- const QUrl sigUrl = publicKey.isEmpty() ? QUrl() : QUrl( archives.first().second + QLatin1String( ".sig" ) );
- const CryptoSignatureVerifier verifier( publicKey );
- downloader = FileDownloaderFactory::instance().create( url.scheme(), publicKey.isEmpty() ? 0 : &verifier, sigUrl, this );
+ QString hashUrl = m_archivesToDownload.first().second;
+ const QUrl url(hashUrl + QLatin1String(".sha1"));
+ const QUrl sigUrl = m_publicKey.isEmpty() ? QUrl() : QUrl(m_archivesToDownload.first().second
+ + QLatin1String(".sig"));
+ const CryptoSignatureVerifier verifier(m_publicKey);
+ m_downloader = FileDownloaderFactory::instance().create(url.scheme(), m_publicKey.isEmpty() ? 0
+ : &verifier, sigUrl, this);
- if ( !downloader ) {
- archives.pop_front();
- const QString errMsg = tr("Scheme not supported: %1 (%2)").arg( url.scheme(), url.toString() );
+ if (!m_downloader) {
+ m_archivesToDownload.pop_front();
+ const QString errMsg = tr("Scheme not supported: %1 (%2)").arg(url.scheme(), url.toString());
verbose() << errMsg << std::endl;
- emit outputTextChanged( errMsg );
- QMetaObject::invokeMethod( this, "fetchNextArchiveHash", Qt::QueuedConnection );
+ emit outputTextChanged(errMsg);
+ QMetaObject::invokeMethod(this, "fetchNextArchiveHash", Qt::QueuedConnection);
return;
}
- connect( downloader, SIGNAL( downloadCompleted() ), this, SLOT( finishedHashDownload() ), Qt::QueuedConnection );
- connect( downloader, SIGNAL( downloadCanceled() ), this, SLOT( downloadCanceled() ) );
- connect( downloader, SIGNAL( downloadAborted( QString ) ), this, SLOT( downloadFailed( QString ) ), Qt::QueuedConnection );
+ connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(finishedHashDownload()),
+ Qt::QueuedConnection);
+ connect(m_downloader, SIGNAL(downloadCanceled()), this, SLOT(downloadCanceled()));
+ connect(m_downloader, SIGNAL(downloadAborted(QString)), this, SLOT(downloadFailed(QString)),
+ Qt::QueuedConnection);
//hashes are not registered as files - so we can't handle this as a normal progress
- //connect( downloader, SIGNAL( downloadProgress( double ) ), this, SLOT( emitDownloadProgress( double ) ) );
- downloader->setUrl( url );
- downloader->setAutoRemoveDownloadedFile( false );
+ //connect(downloader, SIGNAL(downloadProgress(double)), this, SLOT(emitDownloadProgress(double)));
+ m_downloader->setUrl(url);
+ m_downloader->setAutoRemoveDownloadedFile(false);
- const QString comp = QFileInfo( QFileInfo( archives.first().first ).path() ).fileName();
- const Component* const component = parent->componentByName( comp );
+ const QString comp = QFileInfo(QFileInfo(m_archivesToDownload.first().first).path()).fileName();
+ const Component *const component = m_installer->componentByName(comp);
- emit outputTextChanged( tr( "Downloading archive hash for component %1" ).arg( component->displayName() ) );
- downloader->download();
+ emit outputTextChanged(tr("Downloading archive hash for component: %1").arg(component->displayName()));
+ m_downloader->download();
+ } else {
+ QMetaObject::invokeMethod(this, "fetchNextArchive", Qt::QueuedConnection);
}
- else
- QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
}
void DownloadArchivesJob::finishedHashDownload()
{
- Q_ASSERT( downloader != 0 );
+ Q_ASSERT(m_downloader != 0);
- const QString tempFile = downloader->downloadedFileName();
- QFile sha1HashFile( tempFile );
- if ( sha1HashFile.open( QFile::ReadOnly ) )
- currentHash = sha1HashFile.readAll();
+ const QString tempFile = m_downloader->downloadedFileName();
+ QFile sha1HashFile(tempFile);
+ if (sha1HashFile.open(QFile::ReadOnly))
+ m_currentHash = sha1HashFile.readAll();
else
- finishWithError( tr( "Downloading hash signature failed" ) );
+ finishWithError(tr("Downloading hash signature failed."));
- temporaryFiles.push_back( tempFile );
+ m_temporaryFiles.push_back(tempFile);
fetchNextArchive();
}
-/**
- * Fetches the next archive and registers it in the installer.
- */
+/*!
+ Fetches the next archive and registers it in the installer.
+*/
void DownloadArchivesJob::fetchNextArchive()
{
- if( cancelled )
- {
- finishWithError( tr( "Canceled" ) );
+ if (m_canceled) {
+ finishWithError(tr("Canceled"));
return;
}
- if( archives.isEmpty() )
- {
+ if (m_archivesToDownload.isEmpty()) {
emitFinished();
return;
}
- if( downloader != 0 )
- downloader->deleteLater();
+ if (m_downloader != 0)
+ m_downloader->deleteLater();
- const QUrl url( archives.first().second );
- const QUrl sigUrl = publicKey.isEmpty() ? QUrl() : QUrl( archives.first().second + QLatin1String( ".sig" ) );
- const CryptoSignatureVerifier verifier( publicKey );
- downloader = FileDownloaderFactory::instance().create( url.scheme(), publicKey.isEmpty() ? 0 : &verifier, sigUrl, this );
+ const QUrl url(m_archivesToDownload.first().second);
+ const QUrl sigUrl = m_publicKey.isEmpty() ? QUrl() : QUrl(m_archivesToDownload.first().second
+ + QLatin1String(".sig"));
+ const CryptoSignatureVerifier verifier(m_publicKey);
+ m_downloader = FileDownloaderFactory::instance().create(url.scheme(), m_publicKey.isEmpty() ? 0
+ : &verifier, sigUrl, this);
- if ( !downloader ) {
- archives.pop_front();
- const QString errMsg = tr("Scheme not supported: %1 (%2)").arg( url.scheme(), url.toString() );
+ if (!m_downloader) {
+ m_archivesToDownload.pop_front();
+ const QString errMsg = tr("Scheme not supported: %1 (%2)").arg(url.scheme(), url.toString());
verbose() << errMsg;
- emit outputTextChanged( errMsg );
- QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
+ emit outputTextChanged(errMsg);
+ QMetaObject::invokeMethod(this, "fetchNextArchive", Qt::QueuedConnection);
return;
}
- connect( downloader, SIGNAL( downloadCompleted() ), this, SLOT( registerFile() ), Qt::QueuedConnection );
- connect( downloader, SIGNAL( downloadCanceled() ), this, SLOT( downloadCanceled() ) );
- connect( downloader, SIGNAL( downloadAborted( QString ) ), this, SLOT( downloadFailed( QString ) ), Qt::QueuedConnection );
- connect( downloader, SIGNAL( downloadProgress( double ) ), this, SLOT( emitDownloadProgress( double ) ) );
- downloader->setUrl( url );
- downloader->setAutoRemoveDownloadedFile( false );
-
- const QString archive = QFileInfo( archives.first().first ).fileName();
- const QString comp = QFileInfo( QFileInfo( archives.first().first ).path() ).fileName();
- const Component* const component = parent->componentByName( comp );
+ connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(registerFile()), Qt::QueuedConnection);
+ connect(m_downloader, SIGNAL(downloadCanceled()), this, SLOT(downloadCanceled()));
+ connect(m_downloader, SIGNAL(downloadAborted(QString)), this, SLOT(downloadFailed(QString)),
+ Qt::QueuedConnection);
+ connect(m_downloader, SIGNAL(downloadProgress(double)), this, SLOT(emitDownloadProgress(double)));
+ m_downloader->setUrl(url);
+ m_downloader->setAutoRemoveDownloadedFile(false);
+
+ const QString comp = QFileInfo(QFileInfo(m_archivesToDownload.first().first).path()).fileName();
+ const Component* const component = m_installer->componentByName(comp);
- emit outputTextChanged( tr( "Downloading archive for component %1" ).arg( component->displayName() ) );
- emit progressChanged( double(filesDownloaded) / filesToDownload );
- downloader->download();
+ emit outputTextChanged(tr("Downloading archive for component %1").arg(component->displayName()));
+ emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount);
+ m_downloader->download();
}
-/**
- * Emits the global download progress during a single download in a lazy way(uses a timer to reduce to much processChanged).
- */
-void DownloadArchivesJob::emitDownloadProgress( double progress )
+/*!
+ Emits the global download progress during a single download in a lazy way (uses a timer to reduce to
+ much processChanged).
+*/
+void DownloadArchivesJob::emitDownloadProgress(double progress)
{
- lastFileProgress = progress;
- if (!progressChangedTimerId) {
- progressChangedTimerId = startTimer(5);
- }
+ m_lastFileProgress = progress;
+ if (!m_progressChangedTimerId)
+ m_progressChangedTimerId = startTimer(5);
}
-/**
- * this is used to reduce the progressChanged signals
- */
+/*!
+ This is used to reduce the progressChanged signals.
+*/
void DownloadArchivesJob::timerEvent(QTimerEvent *event)
{
- if (event->timerId() == progressChangedTimerId) {
- killTimer(progressChangedTimerId);
- progressChangedTimerId = 0;
- emit progressChanged( ( double(filesDownloaded) + lastFileProgress ) / filesToDownload );
+ if (event->timerId() == m_progressChangedTimerId) {
+ killTimer(m_progressChangedTimerId);
+ m_progressChangedTimerId = 0;
+ emit progressChanged((double(m_archivesDownloaded) + m_lastFileProgress) / m_archivesToDownloadCount);
}
}
-/**
- * Registers the just downloaded file in the intaller's file system.
- */
+/*!
+ Registers the just downloaded file in the intaller's file system.
+*/
void DownloadArchivesJob::registerFile()
{
- Q_ASSERT( downloader != 0 );
- ++filesDownloaded;
- if (progressChangedTimerId) {
- killTimer(progressChangedTimerId);
- progressChangedTimerId = 0;
- emit progressChanged( double(filesDownloaded) / filesToDownload );
+ Q_ASSERT(m_downloader != 0);
+
+ ++m_archivesDownloaded;
+ if (m_progressChangedTimerId) {
+ killTimer(m_progressChangedTimerId);
+ m_progressChangedTimerId = 0;
+ emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount);
}
- const QString tempFile = downloader->downloadedFileName();
- QFile archiveFile( tempFile );
- if ( archiveFile.open( QFile::ReadOnly ) )
- {
- if ( parent->testChecksum() )
- {
- const QByteArray archiveHash = QCryptographicHash::hash( archiveFile.readAll(), QCryptographicHash::Sha1 ).toHex();
- if ( archiveHash != currentHash )
- {
+ const QString tempFile = m_downloader->downloadedFileName();
+ QFile archiveFile(tempFile);
+ if (archiveFile.open(QFile::ReadOnly)) {
+ if (m_installer->testChecksum()) {
+ const QByteArray archiveHash = QCryptographicHash::hash(archiveFile.readAll(),
+ QCryptographicHash::Sha1).toHex();
+ if (archiveHash != m_currentHash) {
//TODO: Maybe we should try to download the file again automatically
- const QMessageBox::Button res = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String( "DownloadError" ),
- tr( "Download Error" ), tr( "Hash verification while downloading failed. This is a temporary error, please retry." ),
- QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel );
- if ( res == QMessageBox::Cancel )
- {
- finishWithError( tr( "Could not verify Hash") );
- return;
- }
- else
- {
- fetchNextArchiveHash();
+ const QMessageBox::Button res =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("DownloadError"), tr("Download Error"), tr("Hash verification while "
+ "downloading failed. This is a temporary error, please retry."),
+ QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel);
+
+ if (res == QMessageBox::Cancel) {
+ finishWithError(tr("Could not verify Hash"));
return;
}
+
+ fetchNextArchiveHash();
+ return;
}
}
+ } else {
+ finishWithError(tr("Could not open %1").arg(tempFile));
}
- else
- {
- finishWithError( tr( "Could not open %1" ).arg( tempFile ) );
- }
- const QString path = archives.first().first;
- archives.pop_front();
- temporaryFiles.push_back( tempFile );
- QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive( path, tempFile );
+ const QString path = m_archivesToDownload.first().first;
+ m_archivesToDownload.pop_front();
+ m_temporaryFiles.push_back(tempFile);
+
+ QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive(path, tempFile);
fetchNextArchiveHash();
}
void DownloadArchivesJob::downloadCanceled()
{
- emitFinishedWithError( Canceled, downloader->errorString() );
+ emitFinishedWithError(KDJob::Canceled, m_downloader->errorString());
}
-void DownloadArchivesJob::downloadFailed( const QString& error )
+void DownloadArchivesJob::downloadFailed(const QString &error)
{
- const QMessageBox::StandardButton b = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("archiveDownloadError"),
- tr("Download Error"),
- tr("Could not download archive %1: %2").arg( archives.first().second, error ),
- QMessageBox::Retry | QMessageBox::Cancel );
- if ( b == QMessageBox::Retry )
- QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
+ const QMessageBox::StandardButton b =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("archiveDownloadError"), tr("Download Error"), tr("Could not download archive: %1 : %2")
+ .arg(m_archivesToDownload.first().second, error), QMessageBox::Retry | QMessageBox::Cancel);
+
+ if (b == QMessageBox::Retry)
+ QMetaObject::invokeMethod(this, "fetchNextArchive", Qt::QueuedConnection);
else
downloadCanceled();
}
-void DownloadArchivesJob::finishWithError( const QString& error )
+void DownloadArchivesJob::finishWithError(const QString &error)
{
- const FileDownloader* const dl = dynamic_cast< const FileDownloader* >( sender() );
- if( dl != 0 )
- emitFinishedWithError( DownloadError, tr( "Could not fetch archives: %1\nError while loading %2" ).arg( error, dl->url().toString() ) );
+ const FileDownloader *const dl = dynamic_cast<const FileDownloader*> (sender());
+ const QString msg = tr("Could not fetch archives: %1\nError while loading %2");
+ if (dl != 0)
+ emitFinishedWithError(QInstaller::DownloadError, msg.arg(error, dl->url().toString()));
else
- emitFinishedWithError( DownloadError, tr( "Could not fetch archives: %1\nError while loading %2" ).arg( error, downloader->url().toString() ) );
+ emitFinishedWithError(QInstaller::DownloadError, msg.arg(error, m_downloader->url().toString()));
}
diff --git a/installerbuilder/libinstaller/downloadarchivesjob.h b/installerbuilder/libinstaller/downloadarchivesjob.h
index 6b4246574..b09f63639 100644
--- a/installerbuilder/libinstaller/downloadarchivesjob.h
+++ b/installerbuilder/libinstaller/downloadarchivesjob.h
@@ -28,41 +28,35 @@
#include <KDToolsCore/KDJob>
-#include <QPair>
-#include <QStringList>
+#include <QtCore/QPair>
+#include <QtCore/QStringList>
-namespace KDUpdater
-{
+QT_BEGIN_NAMESPACE
+class QTimerEvent;
+QT_END_NAMESPACE
+
+namespace KDUpdater {
class FileDownloader;
}
-class QTimer;
+namespace QInstaller {
-namespace QInstaller
-{
-
-class MessageBoxHandler;
class Installer;
+class MessageBoxHandler;
class DownloadArchivesJob : public KDJob
{
Q_OBJECT
+
public:
- enum Error
- {
- InvalidUrl = KDJob::UserDefinedError,
- Timeout,
- DownloadError
- };
-
- explicit DownloadArchivesJob(const QByteArray& publicKey, Installer* parent = 0 );
+ explicit DownloadArchivesJob(const QByteArray &publicKey, Installer *installer = 0);
~DownloadArchivesJob();
- void setArchivesToDownload( const QList< QPair< QString, QString > >& archives );
+ void setArchivesToDownload(const QList<QPair<QString, QString> > &archives);
Q_SIGNALS:
- void progressChanged( double progress );
- void outputTextChanged( const QString& progress );
+ void progressChanged(double progress);
+ void outputTextChanged(const QString &progress);
protected:
void doStart();
@@ -72,27 +66,29 @@ protected:
protected Q_SLOTS:
void registerFile();
void downloadCanceled();
- void downloadFailed( const QString& error );
- void finishWithError( const QString& error );
+ void downloadFailed(const QString &error);
+ void finishWithError(const QString &error);
void fetchNextArchive();
void fetchNextArchiveHash();
void finishedHashDownload();
- void emitDownloadProgress( double progress );
+ void emitDownloadProgress(double progress);
private:
- bool cancelled;
- QList< QPair< QString, QString > > archives;
- const QByteArray publicKey;
- KDUpdater::FileDownloader* downloader;
- QStringList temporaryFiles;
- int filesToDownload;
- int filesDownloaded;
- Installer* parent;
- QByteArray currentHash;
- double lastFileProgress;
- int progressChangedTimerId;
+ Installer *m_installer;
+ KDUpdater::FileDownloader *m_downloader;
+
+ int m_archivesDownloaded;
+ int m_archivesToDownloadCount;
+ QList<QPair<QString, QString> > m_archivesToDownload;
+
+ bool m_canceled;
+ const QByteArray m_publicKey;
+ QStringList m_temporaryFiles;
+ QByteArray m_currentHash;
+ double m_lastFileProgress;
+ int m_progressChangedTimerId;
};
-}
+} // namespace QInstaller
-#endif
+#endif // DOWNLOADARCHIVESJOB_H
diff --git a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
index 95bd6b2b5..7389e6621 100644
--- a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
+++ b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
@@ -33,8 +33,8 @@
#include "elevatedexecuteoperation.h"
#include "environment.h"
-#include "fsengineclient.h"
#include "common/utils.h"
+#include "qprocesswrapper.h"
#include <QThread>
@@ -135,7 +135,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
if (args.count() >= 2 && args.last() == QLatin1String("&"))
{
args.pop_back();
- const bool success = QProcess::startDetached(args.front(), args.mid(1));
+ const bool success = QProcessWrapper::startDetached(args.front(), args.mid(1));
if (!success) {
q->setError(UserDefinedError);
q->setErrorString(tr("Execution failed: Could not start detached: \"%1\"").arg(callstr));
@@ -150,11 +150,12 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
}
QProcessEnvironment penv;
- //there is no way to serialize a QProcessEnvironment properly other than per mangled QStringList :/(i.e. no other way to list all keys)
- process->setEnvironment(KDUpdater::Environment::instance()->applyTo(penv).toStringList());
-
+ // there is no way to serialize a QProcessEnvironment properly other than per mangled QStringList:
+ // (i.e. no other way to list all keys)
+ process->setEnvironment(KDUpdater::Environment::instance().applyTo(penv).toStringList());
+
if (showStandardError)
- process->setProcessChannelMode(QProcess::MergedChannels);
+ process->setProcessChannelMode(QProcessWrapper::MergedChannels);
connect(q, SIGNAL(cancelProcess()), process, SLOT(cancel()));
@@ -193,7 +194,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
}
if (QThread::currentThread() == qApp->thread()) {
- if (process->state() != QProcess::NotRunning) {
+ if (process->state() != QProcessWrapper::NotRunning) {
loop.exec();
}
readProcessOutput();
@@ -201,7 +202,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
q->setValue(QLatin1String("ExitCode"), process->exitCode());
- if (process->exitStatus() == QProcess::CrashExit)
+ if (process->exitStatus() == QProcessWrapper::CrashExit)
{
q->setError(UserDefinedError);
q->setErrorString(tr("Execution failed(Crash): \"%1\"").arg(callstr));
@@ -224,7 +225,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
/*!
Cancels the ElevatedExecuteOperation. This methods tries to terminate the process
- gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
+ gracefully by calling QProcessWrapper::terminate. After 10 seconds, the process gets killed.
*/
void ElevatedExecuteOperation::cancelOperation()
{
diff --git a/installerbuilder/libinstaller/environmentvariablesoperation.cpp b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
index 9bffa429c..4381cd387 100644
--- a/installerbuilder/libinstaller/environmentvariablesoperation.cpp
+++ b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
@@ -31,16 +31,12 @@
**
**************************************************************************/
#include "environmentvariablesoperation.h"
+#include "qsettingswrapper.h"
#include <stdlib.h>
-#include <QtCore/QSettings>
-
#include "KDUpdater/environment.h"
-// this makes us use QSettingsWrapper
-#include "fsengineclient.h"
-
#ifdef Q_WS_WIN
# include <windows.h>
#endif
@@ -92,7 +88,7 @@ UpdateOperation::Error writeSetting(const QString &regPath,
QString *errorString,
QString *oldValue) {
oldValue->clear();
- SettingsType registry(regPath, QSettings::NativeFormat);
+ SettingsType registry(regPath, QSettingsWrapper::NativeFormat);
if (!registry.isWritable()) {
*errorString = QObject::tr("Registry path %1 is not writable").arg(regPath);
return UpdateOperation::UserDefinedError;
@@ -105,7 +101,7 @@ UpdateOperation::Error writeSetting(const QString &regPath,
registry.setValue(name, value);
registry.sync();
- if(registry.status() != QSettings::NoError) {
+ if(registry.status() != QSettingsWrapper::NoError) {
*errorString = QObject::tr("Could not write to registry path %1").arg(regPath);
return UpdateOperation::UserDefinedError;
}
@@ -121,7 +117,7 @@ UpdateOperation::Error undoSetting(const QString &regPath,
QString *errorString) {
QString actual;
{
- SettingsType registry(regPath, QSettings::NativeFormat);
+ SettingsType registry(regPath, QSettingsWrapper::NativeFormat);
actual = registry.value(name).toString();
}
if (actual != value) //key changed, don't undo
@@ -162,7 +158,7 @@ bool EnvironmentVariableOperation::performOperation()
err = isSystemWide
? writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue)
- : writeSetting<QSettings>(regPath, name, value, &errorString, &oldvalue);
+ : writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue);
if (err != NoError) {
setError(err);
setErrorString(errorString);
@@ -176,8 +172,8 @@ bool EnvironmentVariableOperation::performOperation()
#endif
Q_ASSERT( !isPersistent );
- setValue( QLatin1String( "oldvalue" ), Environment::instance()->value( name ) );
- Environment::instance()->setTemporaryValue( name, value );
+ setValue( QLatin1String( "oldvalue" ), Environment::instance().value( name ) );
+ Environment::instance().setTemporaryValue( name, value );
return true;
}
@@ -198,10 +194,10 @@ bool EnvironmentVariableOperation::undoOperation()
#endif
if ( !isPersistent ) {
- const QString actual = Environment::instance()->value( name );
+ const QString actual = Environment::instance().value( name );
const bool doUndo = actual == value;
if ( doUndo )
- Environment::instance()->setTemporaryValue( name, oldvalue );
+ Environment::instance().setTemporaryValue( name, oldvalue );
return doUndo;
}
@@ -215,7 +211,7 @@ bool EnvironmentVariableOperation::undoOperation()
const Error err = isSystemWide
? undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString)
- : undoSetting<QSettings>(regPath, name, value, oldvalue, &errorString);
+ : undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString);
if (err != NoError) {
setError(err);
diff --git a/installerbuilder/libinstaller/extractarchiveoperation_p.h b/installerbuilder/libinstaller/extractarchiveoperation_p.h
index e23b34dff..44a30f1c2 100644
--- a/installerbuilder/libinstaller/extractarchiveoperation_p.h
+++ b/installerbuilder/libinstaller/extractarchiveoperation_p.h
@@ -83,15 +83,15 @@ public Q_SLOTS:
void statusChanged( QInstaller::Installer::Status status )
{
switch( status ) {
- case Installer::InstallerCanceledByUser:
+ case Installer::Canceled:
state = E_ABORT;
break;
- case Installer::InstallerFailed:
+ case Installer::Failure:
state = E_FAIL;
break;
- case Installer::InstallerUnfinished: // fall through
- case Installer::InstallerSucceeded:
- case Installer::InstallerRunning:
+ case Installer::Unfinished: // fall through
+ case Installer::Success:
+ case Installer::Running:
//state = S_OK;
break;
}
diff --git a/installerbuilder/libinstaller/fsengineclient.cpp b/installerbuilder/libinstaller/fsengineclient.cpp
index 9b322900d..8871d8bf1 100644
--- a/installerbuilder/libinstaller/fsengineclient.cpp
+++ b/installerbuilder/libinstaller/fsengineclient.cpp
@@ -32,32 +32,24 @@
**************************************************************************/
#include "fsengineclient.h"
-#undef QSettings
-#undef QProcess
-
#include "adminauthorization.h"
-#include <QAbstractFileEngineHandler>
-#include <QCoreApplication>
-#include <QFSFileEngine>
-#include <QHostAddress>
-#include <QTcpSocket>
-#include <QLocalSocket>
-#include <QDataStream>
-#include <QProcess>
-#include <QMutex>
-#include <QUuid>
-#include <QEventLoop>
-#include <QThread>
-#include <QTimer>
-#include <QDebug>
-
-#include <KDToolsCore/KDMetaMethodIterator>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QMutex>
+#include <QtCore/QProcess>
+#include <QtCore/QThread>
+#include <QtCore/QTimer>
+#include <QtCore/QUuid>
+
+#include <QtNetwork/QHostAddress>
+#include <QtNetwork/QTcpSocket>
+
+
+// -- StillAliveThread
/*!
- This thread convinces the watchdog in the running server that the client has
- not crashed yet.
- */
+ This thread convinces the watchdog in the running server that the client has not crashed yet.
+*/
class StillAliveThread : public QThread
{
Q_OBJECT
@@ -65,27 +57,26 @@ public:
void run()
{
QTimer stillAliveTimer;
- connect( &stillAliveTimer, SIGNAL( timeout() ), this, SLOT( stillAlive() ) );
- stillAliveTimer.start( 1000 );
+ connect(&stillAliveTimer, SIGNAL(timeout()), this, SLOT(stillAlive()));
+ stillAliveTimer.start(1000);
exec();
}
public Q_SLOTS:
void stillAlive()
{
- if( !FSEngineClientHandler::instance()->isServerRunning() )
+ if (!FSEngineClientHandler::instance()->isServerRunning())
return;
// in case of the server not running, this will simply fail
-#ifdef FSENGINE_TCP
QTcpSocket socket;
-#else
- QLocalSocket socket;
-#endif
- FSEngineClientHandler::instance()->connect( &socket );
+ FSEngineClientHandler::instance()->connect(&socket);
}
};
+
+// -- FSEngineClient
+
class FSEngineClient : public QAbstractFileEngine
{
public:
@@ -93,131 +84,114 @@ public:
~FSEngineClient();
bool atEnd() const;
- Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames );
+ Iterator* beginEntryList(QDir::Filters filters, const QStringList &filterNames);
bool caseSensitive() const;
bool close();
- bool copy( const QString& newName );
- QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const;
+ bool copy(const QString &newName);
+ QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
QFile::FileError error() const;
QString errorString() const;
- bool extension( Extension extension, const ExtensionOption* option = 0, ExtensionReturn* output = 0 );
- FileFlags fileFlags( FileFlags type = FileInfoAll ) const;
- QString fileName( FileName file = DefaultName ) const;
+ bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
+ FileFlags fileFlags(FileFlags type = FileInfoAll) const;
+ QString fileName(FileName file = DefaultName) const;
bool flush();
int handle() const;
bool isRelativePath() const;
bool isSequential() const;
- bool link( const QString& newName );
- bool mkdir( const QString& dirName, bool createParentDirectories ) const;
- bool open( QIODevice::OpenMode mode );
- QString owner( FileOwner owner ) const;
- uint ownerId( FileOwner owner ) const;
+ bool link(const QString &newName);
+ bool mkdir(const QString &dirName, bool createParentDirectories) const;
+ bool open(QIODevice::OpenMode mode);
+ QString owner(FileOwner owner) const;
+ uint ownerId(FileOwner owner) const;
qint64 pos() const;
- qint64 read( char* data, qint64 maxlen );
- qint64 readLine( char* data, qint64 maxlen );
+ qint64 read(char *data, qint64 maxlen);
+ qint64 readLine(char *data, qint64 maxlen);
bool remove();
- bool rename( const QString& newName );
- bool rmdir( const QString& dirName, bool recurseParentDirectories ) const;
- bool seek( qint64 offset );
- void setFileName( const QString& fileName );
- bool setPermissions( uint perms );
- bool setSize( qint64 size );
+ bool rename(const QString &newName);
+ bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
+ bool seek(qint64 offset);
+ void setFileName(const QString &fileName);
+ bool setPermissions(uint perms);
+ bool setSize(qint64 size);
qint64 size() const;
- bool supportsExtension( Extension extension ) const;
- qint64 write( const char* data, qint64 len );
+ bool supportsExtension(Extension extension) const;
+ qint64 write(const char *data, qint64 len);
+
+private:
+ template<typename T> T returnWithType() const;
+ template<typename T> T returnWithCastedType() const;
private:
friend class FSEngineClientHandler;
-#ifdef FSENGINE_TCP
+
mutable QTcpSocket* socket;
-#else
- mutable QLocalSocket* socket;
-#endif
mutable QDataStream stream;
};
+template<typename T> T FSEngineClient::returnWithType() const
+{
+ socket->flush();
+ if (!socket->bytesAvailable())
+ socket->waitForReadyRead();
+ quint32 test;
+ stream >> test;
-
-#define RETURN( T ) { \
- socket->flush(); \
- if( !socket->bytesAvailable() ) \
- socket->waitForReadyRead(); \
- quint32 test;\
- stream >> test;\
- T result; \
- stream >> result; \
- return result; \
-}
-
-#define RETURN_VOID { \
- socket->flush(); \
- if( !socket->bytesAvailable() ) \
- socket->waitForReadyRead(); \
- quint32 test;\
- stream >> test;\
- return; \
-}
-
-
-#define RETURN_CASTED( T ) { \
- socket->flush(); \
- if( !socket->bytesAvailable() ) \
- socket->waitForReadyRead(); \
- quint32 test;\
- stream >> test;\
- int result; \
- stream >> result; \
- return static_cast< T >( result ); \
+ T result;
+ stream >> result;
+ return result;
}
-#define RETURN_METHOD( T, NAME ) T FSEngineClient::NAME() const { \
-stream << QString::fromLatin1( "QFSFileEngine::"#NAME ); \
-RETURN( T ); \
-}
+template<typename T> T FSEngineClient::returnWithCastedType() const
+{
+ socket->flush();
+ if (!socket->bytesAvailable())
+ socket->waitForReadyRead();
+ quint32 test;
+ stream >> test;
-#define ENUM_RETURN_METHOD( T, NAME ) T FSEngineClient::NAME() const { \
-stream << QString::fromLatin1( "QFSFileEngine::"#NAME ); \
-RETURN_CASTED( T ) \
+ int result;
+ stream >> result;
+ return static_cast<T>(result);
}
/*!
\internal
- */
+*/
class FSEngineClientIterator : public QAbstractFileEngineIterator
{
public:
- FSEngineClientIterator( QDir::Filters filters, const QStringList& nameFilters, const QStringList& files )
- : QAbstractFileEngineIterator( filters, nameFilters ),
- entries( files ),
- index( -1 )
+ FSEngineClientIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &files)
+ : QAbstractFileEngineIterator(filters, nameFilters),
+ entries(files),
+ index(-1)
{
}
/*!
- \reimp
- */
+ \reimp
+ */
bool hasNext() const
{
return index < entries.size() - 1;
}
/*!
- \reimp
- */
+ \reimp
+ */
QString next()
{
- if( !hasNext() )
+ if (!hasNext())
return QString();
++index;
return currentFilePath();
}
/*!
- \reimp
- */
+ \reimp
+ */
QString currentFileName() const
{
- return entries.at( index );
+ return entries.at(index);
}
private:
@@ -225,376 +199,398 @@ private:
int index;
};
-#ifdef FSENGINE_TCP
-FSEngineClient::FSEngineClient()
- : socket( new QTcpSocket )
-{
- FSEngineClientHandler::instance()->connect( socket );
- stream.setDevice( socket );
- stream.setVersion( QDataStream::Qt_4_2 );
-}
-#else
FSEngineClient::FSEngineClient()
- : socket( new QLocalSocket )
+ : socket(new QTcpSocket)
{
- FSEngineClientHandler::instance()->connect( socket );
- stream.setDevice( socket );
- stream.setVersion( QDataStream::Qt_4_2 );
+ FSEngineClientHandler::instance()->connect(socket);
+ stream.setDevice(socket);
+ stream.setVersion(QDataStream::Qt_4_2);
}
-#endif
FSEngineClient::~FSEngineClient()
{
- if( QThread::currentThread() == socket->thread() )
- {
+ if (QThread::currentThread() == socket->thread()) {
socket->close();
delete socket;
- }
- else
- {
+ } else {
socket->deleteLater();
}
}
/*!
- \reimp
- */
-RETURN_METHOD( bool, atEnd )
+ \reimp
+*/
+bool FSEngineClient::atEnd() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::atEnd");
+ return returnWithType<bool>();
+}
/*!
- \reimp
- */
-QAbstractFileEngine::Iterator* FSEngineClient::beginEntryList( QDir::Filters filters, const QStringList& filterNames )
+ \reimp
+*/
+QAbstractFileEngine::Iterator* FSEngineClient::beginEntryList(QDir::Filters filters,
+ const QStringList &filterNames)
{
- QStringList entries = entryList( filters, filterNames );
- entries.removeAll( QString() );
- return new FSEngineClientIterator( filters, filterNames, entries );
+ QStringList entries = entryList(filters, filterNames);
+ entries.removeAll(QString());
+ return new FSEngineClientIterator(filters, filterNames, entries);
}
/*!
- \reimp
- */
-RETURN_METHOD( bool, caseSensitive )
+ \reimp
+*/
+bool FSEngineClient::caseSensitive() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::caseSensitive");
+ return returnWithType<bool>();
+}
/*!
- \reimp
- */
+ \reimp
+*/
bool FSEngineClient::close()
{
- stream << QString::fromLatin1( "QFSFileEngine::close" );
- RETURN( bool )
+ stream << QString::fromLatin1("QFSFileEngine::close");
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::copy( const QString& newName )
+ \reimp
+*/
+bool FSEngineClient::copy(const QString &newName)
{
- stream << QString::fromLatin1( "QFSFileEngine::copy" );
+ stream << QString::fromLatin1("QFSFileEngine::copy");
stream << newName;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-QStringList FSEngineClient::entryList( QDir::Filters filters, const QStringList& filterNames ) const
+ \reimp
+*/
+QStringList FSEngineClient::entryList(QDir::Filters filters, const QStringList &filterNames) const
{
- stream << QString::fromLatin1( "QFSFileEngine::entryList" );
- stream << static_cast< int >( filters );
+ stream << QString::fromLatin1("QFSFileEngine::entryList");
+ stream << static_cast<int>(filters);
stream << filterNames;
- RETURN( QStringList )
+ return returnWithType<QStringList>();
}
/*!
- \reimp
- */
-ENUM_RETURN_METHOD( QFile::FileError, error )
+ \reimp
+*/
+QFile::FileError FSEngineClient::error() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::error");
+ return returnWithCastedType<QFile::FileError>();
+}
/*!
- \reimp
- */
-RETURN_METHOD( QString, errorString )
+ \reimp
+*/
+QString FSEngineClient::errorString() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::errorString");
+ return returnWithType<QString>();
+}
/*!
- \reimp
- */
-bool FSEngineClient::extension( Extension extension, const ExtensionOption* option, ExtensionReturn* output )
+ \reimp
+*/
+bool FSEngineClient::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output)
{
- Q_UNUSED( extension )
- Q_UNUSED( option )
- Q_UNUSED( output )
+ Q_UNUSED(extension)
+ Q_UNUSED(option)
+ Q_UNUSED(output)
return false;
}
/*!
- \reimp
- */
-QAbstractFileEngine::FileFlags FSEngineClient::fileFlags( FileFlags type ) const
+ \reimp
+*/
+QAbstractFileEngine::FileFlags FSEngineClient::fileFlags(FileFlags type) const
{
- stream << QString::fromLatin1( "QFSFileEngine::fileFlags" );
- stream << static_cast< int >( type );
- RETURN_CASTED( FileFlags )
+ stream << QString::fromLatin1("QFSFileEngine::fileFlags");
+ stream << static_cast<int>(type);
+ return returnWithCastedType<QAbstractFileEngine::FileFlags>();
}
/*!
- \reimp
- */
-QString FSEngineClient::fileName( FileName file ) const
+ \reimp
+*/
+QString FSEngineClient::fileName(FileName file) const
{
- stream << QString::fromLatin1( "QFSFileEngine::fileName" );
- stream << static_cast< int >( file );
- RETURN( QString )
+ stream << QString::fromLatin1("QFSFileEngine::fileName");
+ stream << static_cast<int>(file);
+ return returnWithType<QString>();
}
/*!
- \reimp
- */
+ \reimp
+*/
bool FSEngineClient::flush()
{
- stream << QString::fromLatin1( "QFSFileEngine::flush" );
- RETURN( bool )
+ stream << QString::fromLatin1("QFSFileEngine::flush");
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
+ \reimp
+*/
int FSEngineClient::handle() const
{
- stream << QString::fromLatin1( "QFSFileEngine::handle" );
- RETURN( int )
+ stream << QString::fromLatin1("QFSFileEngine::handle");
+ return returnWithType<int>();
}
/*!
- \reimp
- */
-RETURN_METHOD( bool, isRelativePath )
+ \reimp
+*/
+bool FSEngineClient::isRelativePath() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::isRelativePath");
+ return returnWithType<bool>();
+}
/*!
- \reimp
- */
-RETURN_METHOD( bool, isSequential )
+ \reimp
+*/
+bool FSEngineClient::isSequential() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::isSequential");
+ return returnWithType<bool>();
+}
/*!
- \reimp
- */
-bool FSEngineClient::link( const QString& newName )
+ \reimp
+*/
+bool FSEngineClient::link(const QString &newName)
{
- stream << QString::fromLatin1( "QFSFileEngine::link" );
+ stream << QString::fromLatin1("QFSFileEngine::link");
stream << newName;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::mkdir( const QString& dirName, bool createParentDirectories ) const
+ \reimp
+*/
+bool FSEngineClient::mkdir(const QString &dirName, bool createParentDirectories) const
{
- stream << QString::fromLatin1( "QFSFileEngine::mkdir" );
+ stream << QString::fromLatin1("QFSFileEngine::mkdir");
stream << dirName;
stream << createParentDirectories;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::open( QIODevice::OpenMode mode )
+ \reimp
+*/
+bool FSEngineClient::open(QIODevice::OpenMode mode)
{
- stream << QString::fromLatin1( "QFSFileEngine::open" );
- stream << static_cast< int >( mode );
- RETURN( bool )
+ stream << QString::fromLatin1("QFSFileEngine::open");
+ stream << static_cast<int>(mode);
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-QString FSEngineClient::owner( FileOwner owner ) const
+ \reimp
+*/
+QString FSEngineClient::owner(FileOwner owner) const
{
- stream << QString::fromLatin1( "QFSFileEngine::owner" );
- stream << static_cast< int >( owner );
- RETURN( QString )
+ stream << QString::fromLatin1("QFSFileEngine::owner");
+ stream << static_cast<int>(owner);
+ return returnWithType<QString>();
}
/*!
- \reimp
- */
-uint FSEngineClient::ownerId( FileOwner owner ) const
+ \reimp
+*/
+uint FSEngineClient::ownerId(FileOwner owner) const
{
- stream << QString::fromLatin1( "QFSFileEngine::ownerId" );
- stream << static_cast< int >( owner );
- RETURN( uint )
+ stream << QString::fromLatin1("QFSFileEngine::ownerId");
+ stream << static_cast<int>(owner);
+ return returnWithType<uint>();
}
/*!
- \reimp
- */
-RETURN_METHOD( qint64, pos )
+ \reimp
+*/
+qint64 FSEngineClient::pos() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::pos");
+ return returnWithType<qint64>();
+}
/*!
- \reimp
- */
-qint64 FSEngineClient::read( char* data, qint64 maxlen )
+ \reimp
+*/
+qint64 FSEngineClient::read(char* data, qint64 maxlen)
{
- stream << QString::fromLatin1( "QFSFileEngine::read" );
+ stream << QString::fromLatin1("QFSFileEngine::read");
stream << maxlen;
- socket->flush();
- if( !socket->bytesAvailable() )
+ socket->flush();
+ if (!socket->bytesAvailable())
socket->waitForReadyRead();
quint32 size;
stream >> size;
qint64 result;
stream >> result;
qint64 read = 0;
- while( read < result )
- {
- if( !socket->bytesAvailable() )
+ while (read < result) {
+ if (!socket->bytesAvailable())
socket->waitForReadyRead();
- read += socket->read( data + read, result - read );
+ read += socket->read(data + read, result - read);
}
return result;
}
/*!
- \reimp
- */
-qint64 FSEngineClient::readLine( char* data, qint64 maxlen )
+ \reimp
+*/
+qint64 FSEngineClient::readLine(char* data, qint64 maxlen)
{
- stream << QString::fromLatin1( "QFSFileEngine::readLine" );
+ stream << QString::fromLatin1("QFSFileEngine::readLine");
stream << maxlen;
- socket->flush();
- if( !socket->bytesAvailable() )
+ socket->flush();
+ if (!socket->bytesAvailable())
socket->waitForReadyRead();
quint32 size;
stream >> size;
qint64 result;
stream >> result;
qint64 read = 0;
- while( read < result )
- {
- if( !socket->bytesAvailable() )
+ while (read < result) {
+ if (!socket->bytesAvailable())
socket->waitForReadyRead();
- read += socket->read( data + read, result - read );
+ read += socket->read(data + read, result - read);
}
return result;
}
/*!
- \reimp
- */
-bool FSEngineClient::remove()
+ \reimp
+*/
+bool FSEngineClient::remove()
{
- stream << QString::fromLatin1( "QFSFileEngine::remove" );
- RETURN( bool )
+ stream << QString::fromLatin1("QFSFileEngine::remove");
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::rename( const QString& newName )
+ \reimp
+*/
+bool FSEngineClient::rename(const QString &newName)
{
- stream << QString::fromLatin1( "QFSFileEngine::rename" );
+ stream << QString::fromLatin1("QFSFileEngine::rename");
stream << newName;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::rmdir( const QString& dirName, bool recurseParentDirectories ) const
+ \reimp
+*/
+bool FSEngineClient::rmdir(const QString &dirName, bool recurseParentDirectories) const
{
- stream << QString::fromLatin1( "QFSFileEngine::rmdir" );
+ stream << QString::fromLatin1("QFSFileEngine::rmdir");
stream << dirName;
stream << recurseParentDirectories;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::seek( qint64 offset )
+ \reimp
+*/
+bool FSEngineClient::seek(qint64 offset)
{
- stream << QString::fromLatin1( "QFSFileEngine::seek" );
+ stream << QString::fromLatin1("QFSFileEngine::seek");
stream << offset;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-void FSEngineClient::setFileName( const QString& fileName )
+ \reimp
+*/
+void FSEngineClient::setFileName(const QString &fileName)
{
- stream << QString::fromLatin1( "QFSFileEngine::setFileName" );
+ stream << QString::fromLatin1("QFSFileEngine::setFileName");
stream << fileName;
- RETURN_VOID
-}
+
+ socket->flush();
+ if (!socket->bytesAvailable())
+ socket->waitForReadyRead();
+ quint32 test;
+ stream >> test;
+}
/*!
- \reimp
- */
-bool FSEngineClient::setPermissions( uint perms )
+ \reimp
+*/
+bool FSEngineClient::setPermissions(uint perms)
{
- stream << QString::fromLatin1( "QFSFileEngine::setPermissions" );
+ stream << QString::fromLatin1("QFSFileEngine::setPermissions");
stream << perms;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-bool FSEngineClient::setSize( qint64 size )
+ \reimp
+*/
+bool FSEngineClient::setSize(qint64 size)
{
- stream << QString::fromLatin1( "QFSFileEngine::setSize" );
+ stream << QString::fromLatin1("QFSFileEngine::setSize");
stream << size;
- RETURN( bool )
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-RETURN_METHOD( qint64, size )
+ \reimp
+*/
+qint64 FSEngineClient::size() const
+{
+ stream << QString::fromLatin1("QFSFileEngine::size");
+ return returnWithType<qint64>();
+}
/*!
- \reimp
- */
-bool FSEngineClient::supportsExtension( Extension extension ) const
+ \reimp
+*/
+bool FSEngineClient::supportsExtension(Extension extension) const
{
- stream << QString::fromLatin1( "QFSFileEngine::supportsExtension" );
- stream << static_cast< int >( extension );
- RETURN( bool )
+ stream << QString::fromLatin1("QFSFileEngine::supportsExtension");
+ stream << static_cast<int>(extension);
+ return returnWithType<bool>();
}
/*!
- \reimp
- */
-qint64 FSEngineClient::write( const char* data, qint64 len )
+ \reimp
+*/
+qint64 FSEngineClient::write(const char* data, qint64 len)
{
- stream << QString::fromLatin1( "QFSFileEngine::write" );
+ stream << QString::fromLatin1("QFSFileEngine::write");
stream << len;
qint64 written = 0;
- while( written < len )
- {
- written += socket->write( data, len - written );
+ while (written < len) {
+ written += socket->write(data, len - written);
socket->waitForBytesWritten();
}
- RETURN( qint64 )
+ return returnWithType<qint64>();
}
class FSEngineClientHandler::Private
{
public:
Private()
- : mutex( QMutex::Recursive ),
- port( 0 ),
- startServerAsAdmin( false ),
- serverStarted( false ),
- serverStarting( false ),
- active( false ),
- thread( new StillAliveThread )
+ : mutex(QMutex::Recursive),
+ port(0),
+ startServerAsAdmin(false),
+ serverStarted(false),
+ serverStarting(false),
+ active(false),
+ thread(new StillAliveThread)
{
- thread->moveToThread( thread );
+ thread->moveToThread(thread);
}
-
+
void maybeStartServer();
void maybeStopServer();
@@ -618,23 +614,22 @@ public:
FSEngineClientHandler* FSEngineClientHandler::Private::instance = 0;
/*!
- Creates a new FSEngineClientHandler with no connection.
- */
+ Creates a new FSEngineClientHandler with no connection.
+*/
FSEngineClientHandler::FSEngineClientHandler()
- : d( new Private )
+ : d(new Private)
{
- //don't do this in the Private ctor as createUuid() accesses QFileEngine, which accesses this half-constructed handler -> Crash
- //KDNDK-248
+ //don't do this in the Private ctor as createUuid() accesses QFileEngine, which accesses this
+ // half-constructed handler -> Crash (KDNDK-248)
d->key = QUuid::createUuid().toString();
Private::instance = this;
}
-#ifdef FSENGINE_TCP
/*!
- Creates a new FSEngineClientHandler connection to \a port on address \a.
- */
-FSEngineClientHandler::FSEngineClientHandler( quint16 port, const QHostAddress& a )
- : d( new Private )
+ Creates a new FSEngineClientHandler connection to \a port on address \a.
+*/
+FSEngineClientHandler::FSEngineClientHandler(quint16 port, const QHostAddress& a)
+ : d(new Private)
{
d->address = a;
d->port = port;
@@ -642,56 +637,33 @@ FSEngineClientHandler::FSEngineClientHandler( quint16 port, const QHostAddress&
Private::instance = this;
}
-void FSEngineClientHandler::init( quint16 port, const QHostAddress& a )
-{
- d->address = a;
- d->port = port;
- d->thread->start();
-}
-#else
-/*!
- Creates a new FSEngineClientHandler connecting to \a socket.
- */
-FSEngineClientHandler::FSEngineClientHandler( const QString& socket )
- : d( new Private )
+void FSEngineClientHandler::enableTestMode()
{
- d->socket = socket;
- Private::instance = this;
+ d->key = QLatin1String("testAuthorizationKey");
+ d->serverStarted = true;
}
-void FSEngineClientHandler::init( const QString& socket )
+void FSEngineClientHandler::init(quint16 port, const QHostAddress& a)
{
- d->socket = socket;
+ d->address = a;
+ d->port = port;
d->thread->start();
}
-#endif
-#ifdef FSENGINE_TCP
-bool FSEngineClientHandler::connect( QTcpSocket* socket )
+bool FSEngineClientHandler::connect(QTcpSocket *socket)
{
int tries = 3;
- while ( tries > 0 )
- {
- socket->connectToHost( d->address, d->port );
-#else
-bool FSEngineClientHandler::connect( QLocalSocket* socket )
-{
- int tries = 5;
- while ( tries > 0 )
- {
- socket->connectToServer( d->socket );
-#endif
-
- if( !socket->waitForConnected( 10000 ) )
- {
- if( static_cast< QAbstractSocket::SocketError >( socket->error() ) != QAbstractSocket::UnknownSocketError )
+ while (tries > 0) {
+ socket->connectToHost(d->address, d->port);
+ if (!socket->waitForConnected(10000)) {
+ if (static_cast<QAbstractSocket::SocketError>(socket->error()) != QAbstractSocket::UnknownSocketError)
--tries;
qApp->processEvents();
continue;
}
- QDataStream stream( socket );
- stream << QString::fromLatin1( "authorize" );
+ QDataStream stream(socket);
+ stream << QString::fromLatin1("authorize");
stream << d->key;
socket->flush();
return true;
@@ -700,50 +672,50 @@ bool FSEngineClientHandler::connect( QLocalSocket* socket )
}
/*!
- Destroys the FSEngineClientHandler. If the handler started a server instance, it gets shut down.
- */
+ Destroys the FSEngineClientHandler. If the handler started a server instance, it gets shut down.
+*/
FSEngineClientHandler::~FSEngineClientHandler()
{
- QMetaObject::invokeMethod( d->thread, "quit" );
+ QMetaObject::invokeMethod(d->thread, "quit");
//d->maybeStopServer();
delete d;
Private::instance = 0;
}
/*!
- Returns a previously created FSEngineClientHandler instance.
- */
+ Returns a previously created FSEngineClientHandler instance.
+*/
FSEngineClientHandler* FSEngineClientHandler::instance()
{
- if (!Private::instance) {
+ if (!Private::instance)
Private::instance = new FSEngineClientHandler();
- }
return Private::instance;
}
/*!
- Returns a created authorization key which is sent to the server when connecting via the "authorize" command
- after the server was started.
- */
+ Returns a created authorization key which is sent to the server when connecting via the "authorize"
+ command after the server was started.
+*/
QString FSEngineClientHandler::authorizationKey() const
{
return d->key;
}
/*!
- Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set,
- it is executed with admin privilegies.
- */
-void FSEngineClientHandler::setStartServerCommand( const QString& command, bool startAsAdmin )
+ Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set,
+ it is executed with admin privilegies.
+*/
+void FSEngineClientHandler::setStartServerCommand(const QString &command, bool startAsAdmin)
{
- setStartServerCommand( command, QStringList(), startAsAdmin );
+ setStartServerCommand(command, QStringList(), startAsAdmin);
}
/*!
- Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set,
- it is executed with admin privilegies. A list of \a arguments is passed to the process.
- */
-void FSEngineClientHandler::setStartServerCommand( const QString& command, const QStringList& arguments, bool startAsAdmin )
+ Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set, it is
+ executed with admin privilegies. A list of \a arguments is passed to the process.
+*/
+void FSEngineClientHandler::setStartServerCommand(const QString &command, const QStringList &arguments,
+ bool startAsAdmin)
{
d->maybeStopServer();
@@ -753,882 +725,113 @@ void FSEngineClientHandler::setStartServerCommand( const QString& command, const
}
/*!
- \reimp
- */
-QAbstractFileEngine* FSEngineClientHandler::create( const QString& fileName ) const
+ \reimp
+*/
+QAbstractFileEngine* FSEngineClientHandler::create(const QString &fileName) const
{
- if( d->serverStarting || !d->active )
+ if (d->serverStarting || !d->active)
return 0;
d->maybeStartServer();
- static QRegExp re( QLatin1String( "^[a-z0-9]*://.*$" ) );
- if( re.exactMatch( fileName ) ) // stuff like installer:// 7z:// and so on
+ static QRegExp re(QLatin1String("^[a-z0-9]*://.*$"));
+ if (re.exactMatch(fileName)) // stuff like installer:// 7z:// and so on
return 0;
- if( fileName.isEmpty() || fileName.startsWith( QLatin1String( ":" ) ) )
+
+ if (fileName.isEmpty() || fileName.startsWith(QLatin1String(":")))
return 0; // empty filename or Qt resource
FSEngineClient* const client = new FSEngineClient;
// authorize
- client->stream << QString::fromLatin1( "authorize" );
+ client->stream << QString::fromLatin1("authorize");
client->stream << d->key;
client->socket->flush();
- client->setFileName( fileName );
+ client->setFileName(fileName);
return client;
}
/*!
- Sets the FSEngineClientHandler to \a active. I.e. to actually return FSEngineClients if asked for.
- */
-void FSEngineClientHandler::setActive( bool active )
+ Sets the FSEngineClientHandler to \a active. I.e. to actually return FSEngineClients if asked for.
+*/
+void FSEngineClientHandler::setActive(bool active)
{
d->active = active;
- if( active )
- {
+ if (active) {
d->maybeStartServer();
d->active = d->serverStarted;
}
}
/*!
- Returns, wheter this FSEngineClientHandler is active or not.
- */
+ Returns, wheter this FSEngineClientHandler is active or not.
+*/
bool FSEngineClientHandler::isActive() const
{
return d->active;
}
/*!
- Returns true, when the server already has been started.
- */
+ Returns true, when the server already has been started.
+*/
bool FSEngineClientHandler::isServerRunning() const
{
return d->serverStarted;
}
/*!
- Starts the server if a command was set and it isn't already started.
- \internal
+ \internal
+ Starts the server if a command was set and it isn't already started.
*/
void FSEngineClientHandler::Private::maybeStartServer()
{
- if( serverStarted || serverCommand.isEmpty() )
+ if (serverStarted || serverCommand.isEmpty())
return;
- const QMutexLocker ml( &mutex );
- if( serverStarted )
+ const QMutexLocker ml(&mutex);
+ if (serverStarted)
return;
serverStarting = true;
- if( startServerAsAdmin )
- {
+ if (startServerAsAdmin) {
AdminAuthorization auth;
- serverStarted = auth.authorize() && auth.execute( 0, serverCommand, serverArguments );
- }
- else
- {
- serverStarted = QProcess::startDetached( serverCommand, serverArguments );
+ serverStarted = auth.authorize() && auth.execute(0, serverCommand, serverArguments);
+ } else {
+ serverStarted = QProcess::startDetached(serverCommand, serverArguments);
}
// now wait for the socket to arrive
-#ifdef FSENGINE_TCP
QTcpSocket s;
- while( serverStarting && serverStarted )
- {
- if( instance->connect( &s ) )
- serverStarting = false;
- }
-
-#else
- QLocalSocket s;
- while( serverStarting && serverStarted )
- {
- if( instance->connect( &s ) )
+ while (serverStarting && serverStarted) {
+ if (instance->connect(&s))
serverStarting = false;
}
-#endif
-
serverStarting = false;
}
/*!
- Stops the server if it was started before.
- */
+ Stops the server if it was started before.
+*/
void FSEngineClientHandler::Private::maybeStopServer()
{
- if( !serverStarted )
+ if (!serverStarted)
return;
- const QMutexLocker ml( &mutex );
- if( !serverStarted )
+ const QMutexLocker ml(&mutex);
+ if (!serverStarted)
return;
-#ifdef FSENGINE_TCP
QTcpSocket s;
-#else
- QLocalSocket s;
-#endif
- if( instance->connect( &s ) )
- {
- QDataStream stream( &s );
- stream.setVersion( QDataStream::Qt_4_2 );
- stream << QString::fromLatin1( "authorize" );
+ if (instance->connect(&s)) {
+ QDataStream stream(&s);
+ stream.setVersion(QDataStream::Qt_4_2);
+ stream << QString::fromLatin1("authorize");
stream << key;
- stream << QString::fromLatin1( "shutdown" );
+ stream << QString::fromLatin1("shutdown");
s.flush();
}
-
serverStarted = false;
}
-class QSettingsWrapper::Private
-{
-public:
- Private( const QString& organization, const QString& application )
- : native( true ),
- settings( organization, application ),
- socket( 0 )
- {
- }
- Private( QSettings::Scope scope, const QString& organization, const QString& application )
- : native( true ),
- settings( scope, organization, application ),
- socket( 0 )
- {
- }
- Private( QSettings::Format format, QSettings::Scope scope, const QString& organization, const QString& application )
- : native( format == QSettings::NativeFormat ),
- settings( format, scope, organization, application ),
- socket( 0 )
- {
- }
- Private( const QString& fileName, QSettings::Format format )
- : native( format == QSettings::NativeFormat ),
- fileName( fileName ),
- settings( fileName, format ),
- socket( 0 )
- {
- }
- Private()
- : native( true ),
- socket( 0 )
- {
- }
-
- bool createSocket()
- {
- if( !native || !FSEngineClientHandler::instance()->isActive() )
- return false;
- if( socket != 0 && socket->state() == static_cast< int >( QLocalSocket::ConnectedState ) )
- return true;
- if( socket != 0 )
- delete socket;
-#ifdef FSENGINE_TCP
- socket = new QTcpSocket;
-#else
- socket = new QLocalSocket;
-#endif
- if( !FSEngineClientHandler::instance()->connect( socket ) )
- return false;
- stream.setDevice( socket );
- stream.setVersion( QDataStream::Qt_4_2 );
-
- stream << QString::fromLatin1( "createQSettings" );
- stream << this->fileName;
- socket->flush();
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
- return true;
- }
-
- const bool native;
- const QString fileName;
- QSettings settings;
-#ifdef FSENGINE_TCP
- mutable QTcpSocket* socket;
-#else
- mutable QLocalSocket* socket;
-#endif
- mutable QDataStream stream;
-};
-
-QSettingsWrapper::QSettingsWrapper( const QString& organization, const QString& application, QObject* parent )
- : QObject( parent ),
- d( new Private( organization, application ) )
-{
-}
-
-QSettingsWrapper::QSettingsWrapper( QSettingsWrapper::Scope scope, const QString& organization, const QString& application, QObject* parent )
- : QObject( parent ),
- d( new Private( static_cast< QSettings::Scope >( scope ), organization, application ) )
-{
-}
-
-QSettingsWrapper::QSettingsWrapper( QSettingsWrapper::Format format, QSettingsWrapper::Scope scope, const QString& organization, const QString& application, QObject* parent )
- : QObject( parent ),
- d( new Private( static_cast< QSettings::Format >( format ), static_cast< QSettings::Scope >( scope ), organization, application ) )
-{
-}
-
-QSettingsWrapper::QSettingsWrapper( const QString& fileName, QSettingsWrapper::Format format, QObject* parent )
- : QObject( parent ),
- d( new Private( fileName, static_cast< QSettings::Format >( format ) ) )
-{
-}
-
-QSettingsWrapper::QSettingsWrapper( QObject* parent )
- : QObject( parent ),
- d( new Private )
-{
-}
-
-QSettingsWrapper::~QSettingsWrapper()
-{
- if( d->socket != 0 )
- {
- d->stream << QString::fromLatin1( "destroyQSettings" );
- d->socket->flush();
- quint32 result;
- d->stream >> result;
-
- if( QThread::currentThread() == d->socket->thread() )
- {
- d->socket->close();
- delete d->socket;
- }
- else
- {
- d->socket->deleteLater();
- }
- }
- delete d;
-}
-
-void callRemoteVoidMethod( QDataStream& stream, const QString& name )
-{
- stream.device()->readAll();
- stream << name;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
- return;
-}
-
-template< typename T >
-void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T& param1 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
- return;
-}
-
-template< typename T1, typename T2 >
-void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream << param2;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
- return;
-}
-
-template< typename T1, typename T2, typename T3 >
-void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2, const T3& param3 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream << param2;
- stream << param3;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
- return;
-}
-
-template< typename RESULT >
-RESULT callRemoteMethod( QDataStream& stream, const QString& name )
-{
- stream.device()->readAll();
- stream << name;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- RESULT result;
- stream >> result;
- stream.device()->readAll();
- return result;
-}
-
-template< typename RESULT, typename T >
-RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T& param1 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- RESULT result;
- stream >> result;
- stream.device()->readAll();
- return result;
-}
-
-template< typename RESULT, typename T1, typename T2 >
-RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream << param2;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- RESULT result;
- stream >> result;
- stream.device()->readAll();
- return result;
-}
-
-template< typename RESULT, typename T1, typename T2, typename T3 >
-RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2, const T3& param3 )
-{
- stream.device()->readAll();
- stream << name;
- stream << param1;
- stream << param2;
- stream << param3;
- stream.device()->waitForBytesWritten( -1 );
- if( !stream.device()->bytesAvailable() )
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- RESULT result;
- stream >> result;
- stream.device()->readAll();
- return result;
-}
-
-static QDataStream& operator>>( QDataStream& stream, QSettingsWrapper::Status& status )
-{
- int s;
- stream >> s;
- status = static_cast< QSettingsWrapper::Status >( s );
- return stream;
-}
-
-#define RETURN_NO_ARGS_CONST( RESULT, NAME ) \
-RESULT QSettingsWrapper::NAME() const \
-{ \
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ) ); \
- else \
- return static_cast< RESULT >( d->settings.NAME() ); \
-}
-
-#define RETURN_ONE_ARG( RESULT, NAME, TYPE1 ) \
-RESULT QSettingsWrapper::NAME( TYPE1 param1 ) \
-{ \
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
- else \
- return d->settings.NAME( param1 ); \
-}
-
-#define RETURN_ONE_ARG_CONST( RESULT, NAME, TYPE1 ) \
-RESULT QSettingsWrapper::NAME( TYPE1 param1 ) const \
-{ \
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
- else \
- return d->settings.NAME( param1 ); \
-}
-
-#define RETURN_TWO_ARGS_CONST( RESULT, NAME, TYPE1, TYPE2 ) \
-RESULT QSettingsWrapper::NAME( TYPE1 param1, TYPE2 param2 ) const \
-{ \
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1, param2 ); \
- else \
- return d->settings.NAME( param1, param2 ); \
-}
-
-#define VOID_NO_ARGS( NAME ) \
-void QSettingsWrapper::NAME() \
-{ \
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ) ); \
- else \
- d->settings.NAME(); \
-}
-
-#define VOID_ONE_ARG( NAME, TYPE1 ) \
-void QSettingsWrapper::NAME( TYPE1 param1 ) \
-{ \
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
- else \
- d->settings.NAME( param1 ); \
-}
-
-#define VOID_TWO_ARGS( NAME, TYPE1, TYPE2 ) \
-void QSettingsWrapper::NAME( TYPE1 param1, TYPE2 param2 ) \
-{ \
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ), param1, param2 ); \
- else \
- d->settings.NAME( param1, param2 ); \
-}
-
-RETURN_NO_ARGS_CONST( QStringList, allKeys )
-RETURN_NO_ARGS_CONST( QString, applicationName )
-VOID_ONE_ARG( beginGroup, const QString& )
-RETURN_ONE_ARG( int, beginReadArray, const QString& )
-VOID_TWO_ARGS( beginWriteArray, const QString&, int )
-RETURN_NO_ARGS_CONST( QStringList, childGroups )
-RETURN_NO_ARGS_CONST( QStringList, childKeys )
-VOID_NO_ARGS( clear )
-RETURN_ONE_ARG_CONST( bool, contains, const QString& )
-VOID_NO_ARGS( endArray )
-VOID_NO_ARGS( endGroup )
-RETURN_NO_ARGS_CONST( bool, fallbacksEnabled )
-RETURN_NO_ARGS_CONST( QString, fileName )
-
-QSettingsWrapper::Format QSettingsWrapper::format() const
-{
- return static_cast< QSettingsWrapper::Format >( d->settings.format() );
-}
-
-RETURN_NO_ARGS_CONST( QString, group )
-
-QTextCodec* QSettingsWrapper::iniCodec() const
-{
- return d->settings.iniCodec();
-}
-
-RETURN_NO_ARGS_CONST( bool, isWritable )
-RETURN_NO_ARGS_CONST( QString, organizationName )
-VOID_ONE_ARG( remove, const QString& )
-
-QSettingsWrapper::Scope QSettingsWrapper::scope() const
-{
- return static_cast< QSettingsWrapper::Scope >( d->settings.scope() );
-}
-
-VOID_ONE_ARG( setArrayIndex, int )
-VOID_ONE_ARG( setFallbacksEnabled, bool )
-
-void QSettingsWrapper::setIniCodec( QTextCodec* codec )
-{
- d->settings.setIniCodec( codec );
-}
-
-void QSettingsWrapper::setIniCodec( const char* codecName )
-{
- d->settings.setIniCodec( codecName );
-}
-
-VOID_TWO_ARGS( setValue, const QString&, const QVariant& )
-RETURN_NO_ARGS_CONST( QSettingsWrapper::Status, status );
-VOID_NO_ARGS( sync )
-RETURN_TWO_ARGS_CONST( QVariant, value, const QString&, const QVariant& )
-
-class QProcessWrapper::Private
-{
-public:
- Private( QProcessWrapper* qq )
- : q( qq ),
- ignoreTimer( false ),
- socket( 0 )
- {
- }
-
- bool createSocket()
- {
- if( !FSEngineClientHandler::instance()->isActive() )
- return false;
- if( socket != 0 && socket->state() == static_cast< int >( QLocalSocket::ConnectedState ) )
- return true;
- if( socket != 0 )
- delete socket;
-#ifdef FSENGINE_TCP
- socket = new QTcpSocket;
-#else
- socket = new QLocalSocket;
-#endif
- if( !FSEngineClientHandler::instance()->connect( socket ) )
- return false;
- stream.setDevice( socket );
- stream.setVersion( QDataStream::Qt_4_2 );
-
- stream << QString::fromLatin1( "createQProcess" );
- socket->flush();
- stream.device()->waitForReadyRead( -1 );
- quint32 test;
- stream >> test;
- stream.device()->readAll();
-
- q->startTimer( 250 );
-
- return true;
- }
-
- class TimerBlocker
- {
- public:
- explicit TimerBlocker( const QProcessWrapper* wrapper )
- : w( const_cast< QProcessWrapper* >( wrapper ) )
- {
- w->d->ignoreTimer = true;
- }
- ~TimerBlocker()
- {
- w->d->ignoreTimer = false;
- }
-
- private:
- QProcessWrapper* const w;
- };
-
-private:
- QProcessWrapper* const q;
-
-public:
- bool ignoreTimer;
-
- QProcess process;
-#ifdef FSENGINE_TCP
- mutable QTcpSocket* socket;
-#else
- mutable QLocalSocket* socket;
-#endif
- mutable QDataStream stream;
-};
-
-QProcessWrapper::QProcessWrapper( QObject* parent )
- : QObject( parent ),
- d( new Private( this ) )
-{
- KDMetaMethodIterator it( QProcess::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods );
- while( it.hasNext() )
- {
- it.next();
- connect( &d->process, it.connectableSignature(), this, it.connectableSignature() );
- }
-}
-
-QProcessWrapper::~QProcessWrapper()
-{
- if( d->socket != 0 )
- {
- d->stream << QString::fromLatin1( "destroyQProcess" );
- d->socket->flush();
- quint32 result;
- d->stream >> result;
-
- if( QThread::currentThread() == d->socket->thread() )
- {
- d->socket->close();
- delete d->socket;
- }
- else
- {
- d->socket->deleteLater();
- }
- }
- delete d;
-}
-
-void QProcessWrapper::timerEvent( QTimerEvent* event )
-{
- Q_UNUSED( event )
-
- if( d->ignoreTimer )
- return;
-
- QList< QVariant > receivedSignals;
-
- {
- const Private::TimerBlocker blocker( this );
-
- d->stream << QString::fromLatin1( "getQProcessSignals" );
- d->socket->flush();
- d->stream.device()->waitForReadyRead( -1 );
- quint32 test;
- d->stream >> test;
- d->stream >> receivedSignals;
- d->stream.device()->readAll();
- }
-
- while( !receivedSignals.isEmpty() )
- {
- const QString name = receivedSignals.takeFirst().toString();
- if( name == QLatin1String( "started" ) )
- {
- emit started();
- }
- else if( name == QLatin1String( "readyRead" ) )
- {
- emit readyRead();
- }
- else if( name == QLatin1String( "stateChanged" ) )
- {
- const QProcess::ProcessState newState = static_cast< QProcess::ProcessState >( receivedSignals.takeFirst().toInt() );
- emit stateChanged( newState );
- }
- else if( name == QLatin1String( "finished" ) )
- {
- const int exitCode = receivedSignals.takeFirst().toInt();
- const QProcess::ExitStatus exitStatus = static_cast< QProcess::ExitStatus >( receivedSignals.takeFirst().toInt() );
- emit finished( exitCode );
- emit finished( exitCode, exitStatus );
- }
- }
-}
-
-static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessState& state )
-{
- int s;
- stream >> s;
- state = static_cast< QProcessWrapper::ProcessState >( s );
- return stream;
-}
-
-static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ExitStatus& status )
-{
- int s;
- stream >> s;
- status = static_cast< QProcessWrapper::ExitStatus >( s );
- return stream;
-}
-
-static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessChannelMode& status )
-{
- int s;
- stream >> s;
- status = static_cast< QProcessWrapper::ProcessChannelMode >( s );
- return stream;
-}
-
-static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessChannel& status )
-{
- int s;
- stream >> s;
- status = static_cast< QProcessWrapper::ProcessChannel >( s );
- return stream;
-}
-
-#undef RETURN_NO_ARGS_CONST
-#define RETURN_NO_ARGS_CONST( RESULT, NAME ) \
-RESULT QProcessWrapper::NAME() const \
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
- else \
- return static_cast< RESULT >( d->process.NAME() ); \
-}
-
-#define RETURN_NO_ARGS( RESULT, NAME ) \
-RESULT QProcessWrapper::NAME() \
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
- else \
- return d->process.NAME(); \
-}
-
-#undef RETURN_ONE_ARG
-#define RETURN_ONE_ARG( RESULT, NAME, TYPE1 ) \
-RESULT QProcessWrapper::NAME( TYPE1 param1 ) \
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
- else \
- return d->process.NAME( param1 ); \
-}
-
-#undef RETURN_ONE_ARG_CONST
-#define RETURN_ONE_ARG_CONST( RESULT, NAME, TYPE1 ) \
-RESULT QProcessWrapper::NAME( TYPE1 param1 ) const \
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
- else \
- return d->process.NAME( param1 ); \
-}
-
-#undef RETURN_TWO_ARGS_CONST
-#define RETURN_TWO_ARGS_CONST( RESULT, NAME, TYPE1, TYPE2 ) \
-RESULT QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2 ) const \
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2 ); \
- else \
- return d->process.NAME( param1, param2 ); \
-}
-
-#undef VOID_NO_ARGS
-#define VOID_NO_ARGS( NAME ) \
-void QProcessWrapper::NAME() \
-{ \
- qDebug() << Q_FUNC_INFO; \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
- else \
- d->process.NAME(); \
-}
-
-#undef VOID_ONE_ARG
-#define VOID_ONE_ARG( NAME, TYPE1 ) \
-void QProcessWrapper::NAME( TYPE1 param1 ) \
-{ \
- qDebug() << Q_FUNC_INFO; \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
- else \
- d->process.NAME( param1 ); \
-}
-
-#undef VOID_TWO_ARGS
-#define VOID_TWO_ARGS( NAME, TYPE1, TYPE2 ) \
-void QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2 ) \
-{ \
- qDebug() << Q_FUNC_INFO; \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2 ); \
- else \
- d->process.NAME( param1, param2 ); \
-}
-
-#define VOID_THREE_ARGS( NAME, TYPE1, TYPE2, TYPE3 ) \
-void QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2, TYPE3 param3 ) \
-{ \
- qDebug() << Q_FUNC_INFO; \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2, param3 ); \
- else \
- d->process.NAME( param1, param2, param3 ); \
-}
-
-VOID_NO_ARGS( closeWriteChannel );
-RETURN_NO_ARGS_CONST( int, exitCode );
-RETURN_NO_ARGS_CONST( QProcessWrapper::ExitStatus, exitStatus );
-VOID_NO_ARGS( kill )
-RETURN_NO_ARGS( QByteArray, readAll );
-RETURN_NO_ARGS( QByteArray, readAllStandardOutput );
-VOID_THREE_ARGS( start, const QString&, const QStringList&, QIODevice::OpenMode )
-VOID_ONE_ARG( start, const QString& )
-
-bool startDetached( const QString& program, const QStringList& args, const QString& workingDirectory, qint64* pid );
-
-bool QProcessWrapper::startDetached( const QString& program, const QStringList& arguments, const QString& workingDirectory, qint64* pid )
-{
- QProcessWrapper w;
- if( w.d->createSocket() )
- {
- const QPair< bool, qint64 > result = callRemoteMethod< QPair< bool, qint64 > >( w.d->stream, QLatin1String( "QProcess::startDetached" ), program, arguments, workingDirectory );
- if( pid != 0 )
- *pid = result.second;
- return result.first;
- }
- else
- {
- return ::startDetached( program, arguments, workingDirectory, pid );
- }
-}
-
-bool QProcessWrapper::startDetached( const QString& program, const QStringList& arguments )
-{
- return startDetached( program, arguments, QDir::currentPath() );
-}
-
-bool QProcessWrapper::startDetached( const QString& program )
-{
- return startDetached( program, QStringList() );
-}
-
-void QProcessWrapper::setProcessChannelMode( QProcessWrapper::ProcessChannelMode mode )
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::setProcessChannelMode" ), static_cast<QProcess::ProcessChannelMode>( mode ) ); \
- else \
- d->process.setProcessChannelMode( static_cast<QProcess::ProcessChannelMode>( mode ) ); \
-}
-
-/*!
- Cancels the process. This methods tries to terminate the process
- gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
- */
-void QProcessWrapper::cancel()
-{
- if( state() == QProcessWrapper::Running )
- terminate();
- if( !waitForFinished( 10000 ) )
- kill();
-}
-
-void QProcessWrapper::setReadChannel( QProcessWrapper::ProcessChannel chan )
-{ \
- const Private::TimerBlocker blocker( this );\
- if( d->createSocket() ) \
- callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::setReadChannel" ), static_cast<QProcess::ProcessChannel>( chan ) ); \
- else \
- d->process.setReadChannel( static_cast<QProcess::ProcessChannel>( chan ) ); \
-}
-
-RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessState, state )
-VOID_NO_ARGS( terminate )
-RETURN_ONE_ARG( bool, waitForFinished, int )
-RETURN_ONE_ARG( bool, waitForStarted, int )
-RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessChannel, readChannel )
-RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessChannelMode, processChannelMode )
-RETURN_NO_ARGS_CONST( QString, workingDirectory )
-RETURN_ONE_ARG( qint64, write, const QByteArray& )
-VOID_ONE_ARG( setEnvironment, const QStringList& )
-#ifdef Q_OS_WIN
-VOID_ONE_ARG( setNativeArguments, const QString& )
-#endif
-VOID_ONE_ARG( setWorkingDirectory, const QString& )
-
-#include "moc_fsengineclient.cpp"
#include "fsengineclient.moc"
diff --git a/installerbuilder/libinstaller/fsengineclient.h b/installerbuilder/libinstaller/fsengineclient.h
index 9065f3741..acdf096aa 100644
--- a/installerbuilder/libinstaller/fsengineclient.h
+++ b/installerbuilder/libinstaller/fsengineclient.h
@@ -26,209 +26,44 @@
#ifndef FSENGINECLIENT_H
#define FSENGINECLIENT_H
+#include "installer_global.h"
+
#include <QtCore/QAbstractFileEngineHandler>
-#include <QtCore/QProcess>
-#include <QtCore/QSettings>
-#ifdef FSENGINE_TCP
#include <QtNetwork/QHostAddress>
-class QTcpSocket;
-#else
-class QLocalSocket;
-#endif
-#include "installer_global.h"
+QT_BEGIN_NAMESPACE
+class QTcpSocket;
+QT_END_NAMESPACE
class INSTALLER_EXPORT FSEngineClientHandler : public QAbstractFileEngineHandler
{
public:
FSEngineClientHandler();
-#ifdef FSENGINE_TCP
- FSEngineClientHandler( quint16 port, const QHostAddress& a = QHostAddress::LocalHost );
- void init( quint16 port, const QHostAddress& a = QHostAddress::LocalHost );
-
-#else
- FSEngineClientHandler( const QString& socket );
- void init( const QString& socket );
-#endif
+ FSEngineClientHandler(quint16 port, const QHostAddress &a = QHostAddress::LocalHost);
~FSEngineClientHandler();
+ void init(quint16 port, const QHostAddress &a = QHostAddress::LocalHost);
+
static FSEngineClientHandler* instance();
- QAbstractFileEngine* create( const QString& fileName ) const;
+ QAbstractFileEngine* create(const QString &fileName) const;
- void setActive( bool active );
+ void enableTestMode();
+ void setActive(bool active);
bool isActive() const;
bool isServerRunning() const;
QString authorizationKey() const;
- void setStartServerCommand( const QString& command, bool startAsAdmin = false );
- void setStartServerCommand( const QString& command, const QStringList& arguments, bool startAsAdmin = false );
+ void setStartServerCommand(const QString &command, bool startAsAdmin = false);
+ void setStartServerCommand(const QString &command, const QStringList &arguments, bool startAsAdmin = false);
-#ifdef FSENGINE_TCP
- bool connect( QTcpSocket* socket );
-#else
- bool connect( QLocalSocket* socket );
-#endif
+ bool connect(QTcpSocket *socket);
private:
class Private;
- Private* d;
+ Private *d;
};
-class INSTALLER_EXPORT QSettingsWrapper : public QObject
-{
- Q_OBJECT
-public:
- enum Format
- {
- NativeFormat,
- IniFormat,
- InvalidFormat
- };
-
- enum Status
- {
- NoError,
- AccessError,
- FormatError
- };
-
- enum Scope
- {
- UserScope,
- SystemScope
- };
-
- explicit QSettingsWrapper( const QString& organization, const QString& application = QString(), QObject* parent = 0 );
- QSettingsWrapper( QSettingsWrapper::Scope scope, const QString& organization, const QString& application = QString(), QObject* parent = 0 );
- QSettingsWrapper( QSettingsWrapper::Format format, QSettingsWrapper::Scope scope, const QString& organization, const QString& application = QString(), QObject* parent = 0 );
- QSettingsWrapper( const QString& fileName, QSettingsWrapper::Format format, QObject* parent = 0 );
- explicit QSettingsWrapper( QObject* parent = 0 );
- ~QSettingsWrapper();
-
- QStringList allKeys() const;
- QString applicationName() const;
- void beginGroup( const QString& prefix );
- int beginReadArray( const QString& prefix );
- void beginWriteArray( const QString& prefix, int size = -1 );
- QStringList childGroups() const;
- QStringList childKeys() const;
- void clear();
- bool contains( const QString& key ) const;
- void endArray();
- void endGroup();
- bool fallbacksEnabled() const;
- QString fileName() const;
- QSettingsWrapper::Format format() const;
- QString group() const;
- QTextCodec* iniCodec() const;
- bool isWritable() const;
- QString organizationName() const;
- void remove( const QString& key );
- QSettingsWrapper::Scope scope() const;
- void setArrayIndex( int i );
- void setFallbacksEnabled( bool b );
- void setIniCodec( QTextCodec* codec );
- void setIniCodec( const char* codecName );
- void setValue( const QString& key, const QVariant& value );
- QSettingsWrapper::Status status() const;
- void sync();
- QVariant value( const QString& key, const QVariant& defaultValue = QVariant() ) const;
-
-private:
- class Private;
- Private* d;
-};
-
-#define QSettings QSettingsWrapper
-
-class INSTALLER_EXPORT QProcessWrapper : public QObject
-{
- Q_OBJECT
-public:
- enum ProcessState
- {
- NotRunning,
- Starting,
- Running
- };
-
- enum ExitStatus
- {
- NormalExit,
- CrashExit
- };
-
- enum ProcessChannel
- {
- StandardOutput = 0,
- StandardError = 1
- };
-
- enum ProcessChannelMode
- {
- SeparateChannels = 0,
- MergedChannels = 1,
- ForwardedChannels = 2
- };
-
- explicit QProcessWrapper( QObject* parent = 0 );
- ~QProcessWrapper();
-
- void closeWriteChannel();
- int exitCode() const;
- ExitStatus exitStatus() const;
- void kill();
- QByteArray readAll();
- QByteArray readAllStandardOutput();
- void setWorkingDirectory( const QString& dir );
- void start( const QString& program, const QStringList& arguments, QIODevice::OpenMode mode = QIODevice::ReadWrite );
- void start( const QString& program );
- static bool startDetached( const QString& program, const QStringList& arguments, const QString& workingDirectory, qint64* pid = 0 );
- static bool startDetached( const QString& program, const QStringList& arguments );
- static bool startDetached( const QString& program );
-
- ProcessState state() const;
- void terminate();
- bool waitForFinished( int msecs = 30000 );
- bool waitForStarted( int msecs = 30000 );
- void setEnvironment( const QStringList& environment );
- QString workingDirectory() const;
- qint64 write( const QByteArray& byteArray );
- QProcessWrapper::ProcessChannel readChannel() const;
- void setReadChannel( QProcessWrapper::ProcessChannel channel );
- QProcessWrapper::ProcessChannelMode processChannelMode() const;
- void setProcessChannelMode( QProcessWrapper::ProcessChannelMode channel );
-#ifdef Q_OS_WIN
- void setNativeArguments(const QString& arguments);
-#endif
-
-Q_SIGNALS:
- void bytesWritten( qint64 );
- void aboutToClose();
- void readChannelFinished();
- void error( QProcess::ProcessError );
- void readyReadStandardOutput();
- void readyReadStandardError();
- void finished( int exitCode );
- void finished( int exitCode, QProcess::ExitStatus exitStatus );
- void readyRead();
- void started();
- void stateChanged( QProcess::ProcessState newState );
-
-public Q_SLOTS:
- void cancel();
-
-protected:
- void timerEvent( QTimerEvent* event );
-
-private:
- class Private;
- Private* d;
-};
-
-#define QProcess QProcessWrapper
-
#endif
diff --git a/installerbuilder/libinstaller/fsengineserver.cpp b/installerbuilder/libinstaller/fsengineserver.cpp
index 1be880156..3a81b11ef 100644
--- a/installerbuilder/libinstaller/fsengineserver.cpp
+++ b/installerbuilder/libinstaller/fsengineserver.cpp
@@ -32,92 +32,50 @@
**************************************************************************/
#include "fsengineserver.h"
-#include <QCoreApplication>
-#include <QFSFileEngine>
-#include <QLocalSocket>
-#include <QDataStream>
-#include <QProcess>
-#include <QSettings>
-#include <QTcpSocket>
-#include <QThread>
-#include <QVariant>
-
-#ifdef FSENGINE_TCP
-typedef int descriptor_t;
-#else
-typedef quintptr descriptor_t;
-#endif
+#include <common/utils.h>
-#ifdef Q_WS_WIN
-#include <windows.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFSFileEngine>
+#include <QtCore/QProcess>
+#include <QtCore/QSettings>
+#include <QtCore/QStringList>
+#include <QtCore/QThread>
-// stolen from qprocess_win.cpp
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
+#include <QtNetwork/QTcpSocket>
- for (int i=0; i<arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
- // escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- QString endQuote(QLatin1Char('\"'));
- int i = tmp.length();
- while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
- --i;
- endQuote += QLatin1Char('\\');
- }
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
- } else {
- args += QLatin1Char(' ') + tmp;
- }
- }
- return args;
-}
+typedef int descriptor_t;
+
+#ifdef Q_WS_WIN
+# include <windows.h>
#endif
-bool startDetached( const QString& program, const QStringList& args, const QString& workingDirectory, qint64* pid )
+bool startDetached(const QString &program, const QStringList& args, const QString &workingDirectory,
+ qint64* pid)
{
#ifdef Q_WS_WIN
- const QString arguments = qt_create_commandline( program, args );
-
- PROCESS_INFORMATION pinfo;
-
- STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
- static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
- static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
- 0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
- };
- const bool success = CreateProcess( 0, const_cast< wchar_t* >( static_cast< const wchar_t* >( arguments.utf16() ) ),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
- 0, (wchar_t*)workingDirectory.utf16(),
- &startupInfo, &pinfo );
- if( success )
- {
- CloseHandle( pinfo.hThread );
- CloseHandle( pinfo.hProcess );
- if( pid )
- *pid = pinfo.dwProcessId;
- }
-
- return success;
-
+ PROCESS_INFORMATION pinfo;
+ STARTUPINFOW startupInfo = { sizeof(STARTUPINFO), 0, 0, 0,
+ static_cast<ulong> (CW_USEDEFAULT), static_cast<ulong> (CW_USEDEFAULT),
+ static_cast<ulong> (CW_USEDEFAULT), static_cast<ulong> (CW_USEDEFAULT),
+ 0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
+ };
+
+ const QString arguments = QInstaller::createCommandline(program, args);
+ const bool success = CreateProcess(0, const_cast<wchar_t*> (static_cast<const wchar_t*>(arguments.utf16())),
+ 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
+ 0, (wchar_t*)workingDirectory.utf16(),
+ &startupInfo, &pinfo);
+
+ if (success) {
+ CloseHandle(pinfo.hThread);
+ CloseHandle(pinfo.hProcess);
+ if (pid)
+ *pid = pinfo.dwProcessId;
+ }
+
+ return success;
#else
- return QProcess::startDetached( program, args, workingDirectory, pid );
+ return QProcess::startDetached(program, args, workingDirectory, pid);
#endif
}
@@ -125,48 +83,47 @@ class QProcessSignalReceiver : public QObject
{
Q_OBJECT
public:
- QProcessSignalReceiver( QObject* parent = 0 )
- : QObject( parent )
- {
- connect( parent, SIGNAL( finished( int, QProcess::ExitStatus ) ),
- this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
- connect( parent, SIGNAL( error( QProcess::ProcessError ) ),
- this, SLOT( processError( QProcess::ProcessError ) ) );
- connect( parent, SIGNAL( readyRead() ),
- this, SLOT( processReadyRead() ) );
- connect( parent, SIGNAL( started() ),
- this, SLOT( processStarted() ) );
- connect( parent, SIGNAL( stateChanged( QProcess::ProcessState ) ),
- this, SLOT( processStateChanged( QProcess::ProcessState ) ) );
+ QProcessSignalReceiver(QObject* parent = 0)
+ : QObject(parent)
+ {
+ connect(parent, SIGNAL(finished(int, QProcess::ExitStatus)), this,
+ SLOT(processFinished(int, QProcess::ExitStatus)));
+ connect(parent, SIGNAL(error(QProcess::ProcessError)), this,
+ SLOT(processError(QProcess::ProcessError)));
+ connect(parent, SIGNAL(readyRead()), this, SLOT(processReadyRead()));
+ connect(parent, SIGNAL(started()), this, SLOT(processStarted()));
+ connect(parent, SIGNAL(stateChanged(QProcess::ProcessState)), this,
+ SLOT(processStateChanged(QProcess::ProcessState)));
}
+
~QProcessSignalReceiver()
{
}
-
- QList< QVariant > receivedSignals;
+
+ QList<QVariant> receivedSignals;
private Q_SLOTS:
- void processError( QProcess::ProcessError error );
- void processFinished( int exitCode, QProcess::ExitStatus exitStatus );
+ void processError(QProcess::ProcessError error);
+ void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
void processReadyRead();
void processStarted();
- void processStateChanged( QProcess::ProcessState newState );
+ void processStateChanged(QProcess::ProcessState newState);
};
/*!
- \internal
- */
+ \internal
+*/
class FSEngineConnectionThread : public QThread
{
Q_OBJECT
public:
- FSEngineConnectionThread( descriptor_t socketDescriptor, QObject* parent )
- : QThread( parent ),
- descriptor( socketDescriptor ),
- settings( 0 ),
- process( 0 ),
- signalReceiver( 0 )
+ FSEngineConnectionThread(descriptor_t socketDescriptor, QObject *parent)
+ : QThread(parent),
+ descriptor(socketDescriptor),
+ settings(0),
+ process(0),
+ signalReceiver(0)
{
}
@@ -176,94 +133,71 @@ public:
protected:
void run();
-
+
private:
- QByteArray handleCommand( const QString& command );
+ QByteArray handleCommand(const QString &command);
QFSFileEngine engine;
const descriptor_t descriptor;
QDataStream receivedStream;
QSettings* settings;
-
- QProcess* process;
- QProcessSignalReceiver* signalReceiver;
+
+ QProcess *process;
+ QProcessSignalReceiver *signalReceiver;
};
-#ifdef FSENGINE_TCP
-FSEngineServer::FSEngineServer( quint16 port, QObject* parent )
- : QTcpServer( parent )
-{
- listen( QHostAddress::LocalHost, port );
- watchdog.setTimeoutInterval( 30000 );
- connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
-}
-FSEngineServer::FSEngineServer( const QHostAddress& address, quint16 port, QObject* parent )
- : QTcpServer( parent )
+FSEngineServer::FSEngineServer(quint16 port, QObject *parent)
+ : QTcpServer(parent)
{
- listen( address, port );
- watchdog.setTimeoutInterval( 30000 );
- connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
+ listen(QHostAddress::LocalHost, port);
+ watchdog.setTimeoutInterval(30000);
+ connect(&watchdog, SIGNAL(timeout()), qApp, SLOT(quit()));
}
-#else
-/*!
- Creates a new FSEngineServer with \a parent. The server will listen on \a socket.
- */
-FSEngineServer::FSEngineServer( const QString& socket, QObject* parent )
- : QLocalServer( parent )
+FSEngineServer::FSEngineServer(const QHostAddress &address, quint16 port, QObject *parent)
+ : QTcpServer(parent)
{
- removeServer( socket );
- listen( socket );
- QFile( socket ).setPermissions( static_cast< QFile::Permissions >( 0x6666 ) );
- watchdog.setTimeoutInterval( 30000 );
- connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
+ listen(address, port);
+ watchdog.setTimeoutInterval(30000);
+ connect(&watchdog, SIGNAL(timeout()), qApp, SLOT(quit()));
}
-#endif
-
/*!
- Destroys the FSEngineServer.
- */
+ Destroys the FSEngineServer.
+*/
FSEngineServer::~FSEngineServer()
{
- const QList< QThread* > threads = findChildren< QThread* >();
- for( QList< QThread* >::const_iterator it = threads.begin(); it != threads.end(); ++it )
- (*it)->wait();
+ const QList<QThread*> threads = findChildren<QThread*>();
+ foreach (QThread *thread, threads)
+ thread->wait();
}
-#ifdef FSENGINE_TCP
/*!
- \reimp
- */
-void FSEngineServer::incomingConnection( int socketDescriptor )
-{
+ \reimp
+*/
+void FSEngineServer::incomingConnection(int socketDescriptor)
+{
qApp->processEvents();
- QThread* const thread = new FSEngineConnectionThread( socketDescriptor, this );
- connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) );
+ QThread* const thread = new FSEngineConnectionThread(socketDescriptor, this);
+ connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
watchdog.resetTimeoutTimer();
}
-#else
-
-/*!
- \reimp
- */
-void FSEngineServer::incomingConnection( quintptr socketDescriptor )
-{
- qApp->processEvents();
- QThread* const thread = new FSEngineConnectionThread( socketDescriptor, this );
- connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) );
- thread->start();
- watchdog.resetTimeoutTimer();
+void FSEngineServer::enableTestMode()
+{
+ setAuthorizationKey(QLatin1String("testAuthorizationKey"));
+ //we don't want to kill the server,
+ //maybe we should introduce a call where the client can kill the server
+ watchdog.disconnect();
}
-#endif
-
+
+
/*!
- Sets the authorization key this server is asking the clients for to \a authorizationKey.
- */
-void FSEngineServer::setAuthorizationKey( const QString& authorizationKey )
+ Sets the authorization key this server is asking the clients for to \a authorizationKey.
+*/
+void FSEngineServer::setAuthorizationKey(const QString &authorizationKey)
{
key = authorizationKey;
}
@@ -272,91 +206,78 @@ QString FSEngineServer::authorizationKey() const
{
return key;
}
-
-void QProcessSignalReceiver::processError( QProcess::ProcessError error )
+
+void QProcessSignalReceiver::processError(QProcess::ProcessError error)
{
- receivedSignals.push_back( QLatin1String( "error" ) );
- receivedSignals.push_back( static_cast< int >( error ) );
+ receivedSignals.push_back(QLatin1String("error"));
+ receivedSignals.push_back(static_cast<int> (error));
}
-void QProcessSignalReceiver::processFinished( int exitCode, QProcess::ExitStatus exitStatus )
+void QProcessSignalReceiver::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
- receivedSignals.push_back( QLatin1String( "finished" ) );
- receivedSignals.push_back( exitCode );
- receivedSignals.push_back( static_cast< int >( exitStatus ) );
+ receivedSignals.push_back(QLatin1String("finished"));
+ receivedSignals.push_back(exitCode);
+ receivedSignals.push_back(static_cast<int> (exitStatus));
}
void QProcessSignalReceiver::processStarted()
{
- receivedSignals.push_back( QLatin1String( "started" ) );
+ receivedSignals.push_back(QLatin1String("started"));
}
void QProcessSignalReceiver::processReadyRead()
{
- receivedSignals.push_back( QLatin1String( "readyRead" ) );
+ receivedSignals.push_back(QLatin1String("readyRead"));
}
-
-void QProcessSignalReceiver::processStateChanged( QProcess::ProcessState newState )
+
+void QProcessSignalReceiver::processStateChanged(QProcess::ProcessState newState)
{
- receivedSignals.push_back( QLatin1String( "stateChanged" ) );
- receivedSignals.push_back( static_cast< int >( newState ) );
+ receivedSignals.push_back(QLatin1String("stateChanged"));
+ receivedSignals.push_back(static_cast<int> (newState));
}
/*!
- \reimp
- */
+ \reimp
+*/
void FSEngineConnectionThread::run()
{
-#ifdef FSENGINE_TCP
QTcpSocket socket;
-#else
- QLocalSocket socket;
-#endif
- socket.setSocketDescriptor( descriptor );
+ socket.setSocketDescriptor(descriptor);
+
+ receivedStream.setDevice(&socket);
+ receivedStream.setVersion(QDataStream::Qt_4_2);
- receivedStream.setDevice( &socket );
- receivedStream.setVersion( QDataStream::Qt_4_2 );
-
bool authorized = false;
- while( static_cast< QLocalSocket::LocalSocketState >( socket.state() ) == QLocalSocket::ConnectedState )
- {
- if( !socket.bytesAvailable() && !socket.waitForReadyRead( 250 ) )
+ while (static_cast<QAbstractSocket::SocketState>(socket.state()) == QAbstractSocket::ConnectedState) {
+ if (!socket.bytesAvailable() && !socket.waitForReadyRead(250))
continue;
QString command;
receivedStream >> command;
- if( authorized && command == QLatin1String( "shutdown" ) )
- {
+ if (authorized && command == QLatin1String("shutdown")) {
// this is a graceful shutdown
socket.close();
parent()->deleteLater();
return;
- }
- else if( command == QLatin1String( "authorize" ) )
- {
+ } else if (command == QLatin1String("authorize")) {
QString k;
receivedStream >> k;
- if( k != dynamic_cast< FSEngineServer* >( parent() )->authorizationKey() )
- {
+ if (k != dynamic_cast<FSEngineServer*> (parent())->authorizationKey()) {
// this is closing the connection... auth failed
socket.close();
return;
}
authorized = true;
- }
- else if( authorized )
- {
- if( command.isEmpty() )
+ } else if (authorized) {
+ if (command.isEmpty())
continue;
- const QByteArray result = handleCommand( command );
- receivedStream << static_cast< quint32 >( result.size() );
- if( !result.isEmpty() )
- receivedStream.writeRawData( result.data(), result.size() );
- }
- else
- {
+ const QByteArray result = handleCommand(command);
+ receivedStream << static_cast<quint32> (result.size());
+ if (!result.isEmpty())
+ receivedStream.writeRawData(result.data(), result.size());
+ } else {
// authorization failed, connection not wanted
socket.close();
return;
@@ -364,185 +285,121 @@ void FSEngineConnectionThread::run()
}
}
-static QDataStream& operator<<( QDataStream& stream, const QSettings::Status& status )
+static QDataStream& operator<<(QDataStream& stream, const QSettings::Status& status)
{
- return stream << static_cast< int >( status );
+ return stream << static_cast<int> (status);
}
/*!
- Handles \a command and returns a QByteArray which has the result streamed into it.
- */
-QByteArray FSEngineConnectionThread::handleCommand( const QString& command )
+ Handles \a command and returns a QByteArray which has the result streamed into it.
+*/
+QByteArray FSEngineConnectionThread::handleCommand(const QString &command)
{
QByteArray block;
- QDataStream returnStream( &block, QIODevice::WriteOnly );
- returnStream.setVersion( QDataStream::Qt_4_2 );
-
+ QDataStream returnStream(&block, QIODevice::WriteOnly);
+ returnStream.setVersion(QDataStream::Qt_4_2);
+
// first, QSettings handling
- if( command == QLatin1String( "createQSettings" ) )
- {
+ if (command == QLatin1String("createQSettings")) {
QString fileName;
receivedStream >> fileName;
- settings = new QSettings( fileName, QSettings::NativeFormat );
- }
- else if( command == QLatin1String( "destroyQSettings" ) )
- {
+ settings = new QSettings(fileName, QSettings::NativeFormat);
+ } else if (command == QLatin1String("destroyQSettings")) {
delete settings;
settings = 0;
- }
- else if( command == QLatin1String( "QSettings::allKeys" ) )
- {
+ } else if (command == QLatin1String("QSettings::allKeys")) {
returnStream << settings->allKeys();
- }
- else if( command == QLatin1String( "QSettings::beginGroup" ) )
- {
+ } else if (command == QLatin1String("QSettings::beginGroup")) {
QString prefix;
receivedStream >> prefix;
- settings->beginGroup( prefix );
- }
- else if( command == QLatin1String( "QSettings::beginReadArray" ) )
- {
+ settings->beginGroup(prefix);
+ } else if (command == QLatin1String("QSettings::beginReadArray")) {
QString prefix;
int size;
receivedStream >> prefix;
receivedStream >> size;
- settings->beginWriteArray( prefix, size );
- }
- else if( command == QLatin1String( "QSettings::beginWriteArray" ) )
- {
+ settings->beginWriteArray(prefix, size);
+ } else if (command == QLatin1String("QSettings::beginWriteArray")) {
QString prefix;
receivedStream >> prefix;
- returnStream << settings->beginReadArray( prefix );
- }
- else if( command == QLatin1String( "QSettings::childGroups" ) )
- {
+ returnStream << settings->beginReadArray(prefix);
+ } else if (command == QLatin1String("QSettings::childGroups")) {
returnStream << settings->childGroups();
- }
- else if( command == QLatin1String( "QSettings::childKeys" ) )
- {
+ } else if (command == QLatin1String("QSettings::childKeys")) {
returnStream << settings->childKeys();
- }
- else if( command == QLatin1String( "QSettings::clear" ) )
- {
+ } else if (command == QLatin1String("QSettings::clear")) {
settings->clear();
- }
- else if( command == QLatin1String( "QSettings::contains" ) )
- {
+ } else if (command == QLatin1String("QSettings::contains")) {
QString key;
receivedStream >> key;
- returnStream << settings->contains( key );
- }
- else if( command == QLatin1String( "QSettings::endArray" ) )
- {
+ returnStream << settings->contains(key);
+ } else if (command == QLatin1String("QSettings::endArray")) {
settings->endArray();
- }
- else if( command == QLatin1String( "QSettings::endGroup" ) )
- {
+ } else if (command == QLatin1String("QSettings::endGroup")) {
settings->endGroup();
- }
- else if( command == QLatin1String( "QSettings::fallbacksEnabled" ) )
- {
+ } else if (command == QLatin1String("QSettings::fallbacksEnabled")) {
returnStream << settings->fallbacksEnabled();
- }
- else if( command == QLatin1String( "QSettings::fileName" ) )
- {
+ } else if (command == QLatin1String("QSettings::fileName")) {
returnStream << settings->fileName();
- }
- else if( command == QLatin1String( "QSettings::group" ) )
- {
+ } else if (command == QLatin1String("QSettings::group")) {
returnStream << settings->group();
- }
- else if( command == QLatin1String( "QSettings::isWritable" ) )
- {
+ } else if (command == QLatin1String("QSettings::isWritable")) {
returnStream << settings->isWritable();
- }
- else if( command == QLatin1String( "QSettings::remove" ) )
- {
+ } else if (command == QLatin1String("QSettings::remove")) {
QString key;
receivedStream >> key;
- settings->remove( key );
- }
- else if( command == QLatin1String( "QSettings::setArrayIndex" ) )
- {
+ settings->remove(key);
+ } else if (command == QLatin1String("QSettings::setArrayIndex")) {
int i;
receivedStream >> i;
- settings->setArrayIndex( i );
- }
- else if( command == QLatin1String( "QSettings::setFallbacksEnabled" ) )
- {
+ settings->setArrayIndex(i);
+ } else if (command == QLatin1String("QSettings::setFallbacksEnabled")) {
bool b;
receivedStream >> b;
- settings->setFallbacksEnabled( b );
- }
- else if( command == QLatin1String( "QSettings::status" ) )
- {
+ settings->setFallbacksEnabled(b);
+ } else if (command == QLatin1String("QSettings::status")) {
returnStream << settings->status();
- }
- else if( command == QLatin1String( "QSettings::sync" ) )
- {
+ } else if (command == QLatin1String("QSettings::sync")) {
settings->sync();
- }
- else if( command == QLatin1String( "QSettings::setValue" ) )
- {
+ } else if (command == QLatin1String("QSettings::setValue")) {
QString key;
QVariant value;
receivedStream >> key;
receivedStream >> value;
- settings->setValue( key, value );
- }
- else if( command == QLatin1String( "QSettings::value" ) )
- {
+ settings->setValue(key, value);
+ } else if (command == QLatin1String("QSettings::value")) {
QString key;
QVariant defaultValue;
receivedStream >> key;
receivedStream >> defaultValue;
- returnStream << settings->value( key, defaultValue );
+ returnStream << settings->value(key, defaultValue);
}
// from here, QProcess handling
- else if( command == QLatin1String( "createQProcess" ) )
- {
+ else if (command == QLatin1String("createQProcess")) {
process = new QProcess;
- signalReceiver = new QProcessSignalReceiver( process );
- }
- else if( command == QLatin1String( "destroyQProcess" ) )
- {
+ signalReceiver = new QProcessSignalReceiver(process);
+ } else if (command == QLatin1String("destroyQProcess")) {
signalReceiver->receivedSignals.clear();
process->deleteLater();
process = 0;
- }
- else if( command == QLatin1String( "getQProcessSignals" ) )
- {
+ } else if (command == QLatin1String("getQProcessSignals")) {
returnStream << signalReceiver->receivedSignals;
signalReceiver->receivedSignals.clear();
qApp->processEvents();
- }
- else if( command == QLatin1String( "QProcess::closeWriteChannel" ) )
- {
+ } else if (command == QLatin1String("QProcess::closeWriteChannel")) {
process->closeWriteChannel();
- }
- else if( command == QLatin1String( "QProcess::exitCode" ) )
- {
+ } else if (command == QLatin1String("QProcess::exitCode")) {
returnStream << process->exitCode();
- }
- else if( command == QLatin1String( "QProcess::exitStatus" ) )
- {
- returnStream << static_cast< int >( process->exitStatus() );
- }
- else if( command == QLatin1String( "QProcess::kill" ) )
- {
+ } else if (command == QLatin1String("QProcess::exitStatus")) {
+ returnStream << static_cast<int> (process->exitStatus());
+ } else if (command == QLatin1String("QProcess::kill")) {
process->kill();
- }
- else if( command == QLatin1String( "QProcess::readAll" ) )
- {
+ } else if (command == QLatin1String("QProcess::readAll")) {
returnStream << process->readAll();
- }
- else if( command == QLatin1String( "QProcess::readAllStandardOutput" ) )
- {
+ } else if (command == QLatin1String("QProcess::readAllStandardOutput")) {
returnStream << process->readAllStandardOutput();
- }
- else if( command == QLatin1String( "QProcess::startDetached" ) )
- {
+ } else if (command == QLatin1String("QProcess::startDetached")) {
QString program;
QStringList arguments;
QString workingDirectory;
@@ -550,277 +407,190 @@ QByteArray FSEngineConnectionThread::handleCommand( const QString& command )
receivedStream >> arguments;
receivedStream >> workingDirectory;
qint64 pid;
- const bool result = startDetached( program, arguments, workingDirectory, &pid );
- returnStream << qMakePair< bool, qint64 >( result, pid );
- }
- else if( command == QLatin1String( "QProcess::setWorkingDirectory" ) )
- {
+ const bool result = startDetached(program, arguments, workingDirectory, &pid);
+ returnStream << qMakePair< bool, qint64> (result, pid);
+ } else if (command == QLatin1String("QProcess::setWorkingDirectory")) {
QString dir;
receivedStream >> dir;
- process->setWorkingDirectory( dir );
- }
- else if( command == QLatin1String( "QProcess::setEnvironment" ) )
- {
+ process->setWorkingDirectory(dir);
+ } else if (command == QLatin1String("QProcess::setEnvironment")) {
QStringList env;
receivedStream >> env;
- process->setEnvironment( env );
- }
- else if( command == QLatin1String( "QProcess::start" ) )
- {
+ process->setEnvironment(env);
+ } else if (command == QLatin1String("QProcess::start")) {
QString program;
QStringList arguments;
int mode;
receivedStream >> program;
receivedStream >> arguments;
receivedStream >> mode;
- process->start( program, arguments, static_cast< QIODevice::OpenMode >( mode ) );
- }
- else if( command == QLatin1String( "QProcess::state" ) )
- {
- returnStream << static_cast< int >( process->state() );
- }
- else if( command == QLatin1String( "QProcess::terminate" ) )
- {
+ process->start(program, arguments, static_cast<QIODevice::OpenMode> (mode));
+ } else if (command == QLatin1String("QProcess::state")) {
+ returnStream << static_cast<int> (process->state());
+ } else if (command == QLatin1String("QProcess::terminate")) {
process->terminate();
- }
- else if( command == QLatin1String( "QProcess::waitForFinished" ) )
- {
+ } else if (command == QLatin1String("QProcess::waitForFinished")) {
int msecs;
receivedStream >> msecs;
- returnStream << process->waitForFinished( msecs );
- }
- else if( command == QLatin1String( "QProcess::waitForStarted" ) )
- {
+ returnStream << process->waitForFinished(msecs);
+ } else if (command == QLatin1String("QProcess::waitForStarted")) {
int msecs;
receivedStream >> msecs;
- returnStream << process->waitForStarted( msecs );
- }
- else if( command == QLatin1String( "QProcess::workingDirectory" ) )
- {
+ returnStream << process->waitForStarted(msecs);
+ } else if (command == QLatin1String("QProcess::workingDirectory")) {
returnStream << process->workingDirectory();
- }
- else if( command == QLatin1String( "QProcess::write" ) )
- {
+ } else if (command == QLatin1String("QProcess::write")) {
QByteArray byteArray;
receivedStream >> byteArray;
- returnStream << process->write( byteArray );
- }
- else if( command == QLatin1String( "QProcess::readChannel" ) )
- {
- returnStream << static_cast< int >( process->readChannel() );
- }
- else if( command == QLatin1String( "QProcess::setReadChannel" ) )
- {
+ returnStream << process->write(byteArray);
+ } else if (command == QLatin1String("QProcess::readChannel")) {
+ returnStream << static_cast<int> (process->readChannel());
+ } else if (command == QLatin1String("QProcess::setReadChannel")) {
int processChannel;
receivedStream >> processChannel;
- process->setReadChannel( static_cast<QProcess::ProcessChannel>(processChannel) );
- }
- else if( command == QLatin1String( "QProcess::write" ) )
- {
+ process->setReadChannel(static_cast<QProcess::ProcessChannel>(processChannel));
+ } else if (command == QLatin1String("QProcess::write")) {
QByteArray byteArray;
receivedStream >> byteArray;
- returnStream << process->write( byteArray );
+ returnStream << process->write(byteArray);
}
// from here, QFSEngine handling
- else if( command == QLatin1String( "QFSFileEngine::atEnd" ) )
- {
+ else if (command == QLatin1String("QFSFileEngine::atEnd")) {
returnStream << engine.atEnd();
- }
- else if( command == QLatin1String( "QFSFileEngine::caseSensitive" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::caseSensitive")) {
returnStream << engine.caseSensitive();
- }
- else if( command == QLatin1String( "QFSFileEngine::close" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::close")) {
returnStream << engine.close();
- }
- else if( command == QLatin1String( "QFSFileEngine::copy" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::copy")) {
QString newName;
receivedStream >> newName;
- returnStream << engine.copy( newName );
- }
- else if( command == QLatin1String( "QFSFileEngine::entryList" ) )
- {
+ returnStream << engine.copy(newName);
+ } else if (command == QLatin1String("QFSFileEngine::entryList")) {
int filters;
QStringList filterNames;
receivedStream >> filters;
receivedStream >> filterNames;
- returnStream << engine.entryList( static_cast< QDir::Filters >( filters ), filterNames );
- }
- else if( command == QLatin1String( "QFSFileEngine::error" ) )
- {
- returnStream << static_cast< int >( engine.error() );
- }
- else if( command == QLatin1String( "QFSFileEngine::errorString" ) )
- {
+ returnStream << engine.entryList(static_cast<QDir::Filters> (filters), filterNames);
+ } else if (command == QLatin1String("QFSFileEngine::error")) {
+ returnStream << static_cast<int> (engine.error());
+ } else if (command == QLatin1String("QFSFileEngine::errorString")) {
returnStream << engine.errorString();
}
// extension
- else if( command == QLatin1String( "QFSFileEngine::fileFlags" ) )
- {
+ else if (command == QLatin1String("QFSFileEngine::fileFlags")) {
int flags;
receivedStream >> flags;
- returnStream << static_cast< int >( engine.fileFlags( static_cast< QAbstractFileEngine::FileFlags >( flags ) ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::fileName" ) )
- {
+ returnStream << static_cast<int>(engine.fileFlags(static_cast<QAbstractFileEngine::FileFlags>(flags)));
+ } else if (command == QLatin1String("QFSFileEngine::fileName")) {
int file;
receivedStream >> file;
- returnStream << engine.fileName( static_cast< QAbstractFileEngine::FileName >( file ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::flush" ) )
- {
+ returnStream << engine.fileName(static_cast<QAbstractFileEngine::FileName> (file));
+ } else if (command == QLatin1String("QFSFileEngine::flush")) {
returnStream << engine.flush();
- }
- else if( command == QLatin1String( "QFSFileEngine::handle" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::handle")) {
returnStream << engine.handle();
- }
- else if( command == QLatin1String( "QFSFileEngine::isRelativePath" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::isRelativePath")) {
returnStream << engine.isRelativePath();
- }
- else if( command == QLatin1String( "QFSFileEngine::isSequential" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::isSequential")) {
returnStream << engine.isSequential();
- }
- else if( command == QLatin1String( "QFSFileEngine::link" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::link")) {
QString newName;
receivedStream >> newName;
- returnStream << engine.link( newName );
- }
- else if( command == QLatin1String( "QFSFileEngine::mkdir" ) )
- {
+ returnStream << engine.link(newName);
+ } else if (command == QLatin1String("QFSFileEngine::mkdir")) {
QString dirName;
bool createParentDirectories;
receivedStream >> dirName;
receivedStream >> createParentDirectories;
- returnStream << engine.mkdir( dirName, createParentDirectories );
- }
- else if( command == QLatin1String( "QFSFileEngine::open" ) )
- {
+ returnStream << engine.mkdir(dirName, createParentDirectories);
+ } else if (command == QLatin1String("QFSFileEngine::open")) {
int openMode;
receivedStream >> openMode;
- returnStream << engine.open( static_cast< QIODevice::OpenMode >( openMode ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::owner" ) )
- {
+ returnStream << engine.open(static_cast<QIODevice::OpenMode> (openMode));
+ } else if (command == QLatin1String("QFSFileEngine::owner")) {
int owner;
receivedStream >> owner;
- returnStream << engine.owner( static_cast< QAbstractFileEngine::FileOwner >( owner ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::ownerId" ) )
- {
+ returnStream << engine.owner(static_cast<QAbstractFileEngine::FileOwner> (owner));
+ } else if (command == QLatin1String("QFSFileEngine::ownerId")) {
int owner;
receivedStream >> owner;
- returnStream << engine.ownerId( static_cast< QAbstractFileEngine::FileOwner >( owner ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::pos" ) )
- {
+ returnStream << engine.ownerId(static_cast<QAbstractFileEngine::FileOwner> (owner));
+ } else if (command == QLatin1String("QFSFileEngine::pos")) {
returnStream << engine.pos();
- }
- else if( command == QLatin1String( "QFSFileEngine::read" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::read")) {
qint64 maxlen;
receivedStream >> maxlen;
- QByteArray ba( maxlen, '\0' );
- const qint64 result = engine.read( ba.data(), maxlen );
+ QByteArray ba(maxlen, '\0');
+ const qint64 result = engine.read(ba.data(), maxlen);
returnStream << result;
int written = 0;
- while( written < result )
- written += returnStream.writeRawData( ba.data() + written, result - written );
- }
- else if( command == QLatin1String( "QFSFileEngine::readLine" ) )
- {
+ while (written < result)
+ written += returnStream.writeRawData(ba.data() + written, result - written);
+ } else if (command == QLatin1String("QFSFileEngine::readLine")) {
qint64 maxlen;
receivedStream >> maxlen;
- QByteArray ba( maxlen, '\0' );
- const qint64 result = engine.readLine( ba.data(), maxlen );
+ QByteArray ba(maxlen, '\0');
+ const qint64 result = engine.readLine(ba.data(), maxlen);
returnStream << result;
int written = 0;
- while( written < result )
- written += returnStream.writeRawData( ba.data() + written, result - written );
- }
- else if( command == QLatin1String( "QFSFileEngine::remove" ) )
- {
+ while (written < result)
+ written += returnStream.writeRawData(ba.data() + written, result - written);
+ } else if (command == QLatin1String("QFSFileEngine::remove")) {
returnStream << engine.remove();
- }
- else if( command == QLatin1String( "QFSFileEngine::rename" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::rename")) {
QString newName;
receivedStream >> newName;
- returnStream << engine.rename( newName );
- }
- else if( command == QLatin1String( "QFSFileEngine::rmdir" ) )
- {
+ returnStream << engine.rename(newName);
+ } else if (command == QLatin1String("QFSFileEngine::rmdir")) {
QString dirName;
bool recurseParentDirectories;
receivedStream >> dirName;
receivedStream >> recurseParentDirectories;
- returnStream << engine.rmdir( dirName, recurseParentDirectories );
- }
- else if( command == QLatin1String( "QFSFileEngine::seek" ) )
- {
+ returnStream << engine.rmdir(dirName, recurseParentDirectories);
+ } else if (command == QLatin1String("QFSFileEngine::seek")) {
quint64 offset;
receivedStream >> offset;
- returnStream << engine.seek( offset );
- }
- else if( command == QLatin1String( "QFSFileEngine::setFileName" ) )
- {
+ returnStream << engine.seek(offset);
+ } else if (command == QLatin1String("QFSFileEngine::setFileName")) {
QString fileName;
receivedStream >> fileName;
- engine.setFileName( fileName );
- }
- else if( command == QLatin1String( "QFSFileEngine::setPermissions" ) )
- {
+ engine.setFileName(fileName);
+ } else if (command == QLatin1String("QFSFileEngine::setPermissions")) {
uint perms;
receivedStream >> perms;
- returnStream << engine.setPermissions( perms );
- }
- else if( command == QLatin1String( "QFSFileEngine::setSize" ) )
- {
+ returnStream << engine.setPermissions(perms);
+ } else if (command == QLatin1String("QFSFileEngine::setSize")) {
qint64 size;
receivedStream >> size;
- returnStream << engine.setSize( size );
- }
- else if( command == QLatin1String( "QFSFileEngine::size" ) )
- {
+ returnStream << engine.setSize(size);
+ } else if (command == QLatin1String("QFSFileEngine::size")) {
returnStream << engine.size();
- }
- else if( command == QLatin1String( "QFSFileEngine::supportsExtension" ) )
- {
+ } else if (command == QLatin1String("QFSFileEngine::supportsExtension")) {
int extension;
receivedStream >> extension;
- returnStream << false;//engine.supportsExtension( static_cast< QAbstractFileEngine::Extension >( extension ) );
- }
- else if( command == QLatin1String( "QFSFileEngine::write" ) )
- {
+ //returnStream << engine.supportsExtension(static_cast<QAbstractFileEngine::Extension> (extension));
+ returnStream << false;
+ } else if (command == QLatin1String("QFSFileEngine::write")) {
qint64 length;
receivedStream >> length;
qint64 read = 0;
qint64 written = 0;
- QByteArray buffer( 65536, '\0' );
- while( read < length )
- {
- if( !receivedStream.device()->bytesAvailable() )
- receivedStream.device()->waitForReadyRead( -1 );
- const qint64 r = receivedStream.readRawData( buffer.data(), qMin( length - read, static_cast< qint64 >( buffer.length() ) ) );
+ QByteArray buffer(65536, '\0');
+ while (read < length) {
+ if (!receivedStream.device()->bytesAvailable())
+ receivedStream.device()->waitForReadyRead(-1);
+ const qint64 r = receivedStream.readRawData(buffer.data(), qMin(length - read,
+ static_cast<qint64> (buffer.length())));
read += r;
qint64 w = 0;
- while( w < r )
- w += engine.write( buffer.data(), r );
+ while (w < r)
+ w += engine.write(buffer.data(), r);
written += r;
}
-
returnStream << written;
- }
- else if( !command.isEmpty() )
- {
+ } else if (!command.isEmpty()) {
qDebug() << "unknown command:" << command;
- // unknown command...
}
return block;
diff --git a/installerbuilder/libinstaller/fsengineserver.h b/installerbuilder/libinstaller/fsengineserver.h
index 20909f9e9..526f52870 100644
--- a/installerbuilder/libinstaller/fsengineserver.h
+++ b/installerbuilder/libinstaller/fsengineserver.h
@@ -30,51 +30,27 @@
#include <KDToolsCore/KDWatchdog>
-#ifdef FSENGINE_TCP
-
#include <QtNetwork/QTcpServer>
class INSTALLER_EXPORT FSEngineServer : public QTcpServer
{
Q_OBJECT
-public:
- explicit FSEngineServer( quint16 port, QObject* parent = 0 );
- FSEngineServer( const QHostAddress& address, quint16 port, QObject* parent = 0 );
- ~FSEngineServer();
-
- void setAuthorizationKey( const QString& key );
- QString authorizationKey() const;
-
-protected:
- void incomingConnection( int socketDescriptor );
-
-private:
- QString key;
- KDWatchdog watchdog;
-};
-
-#else
-
-
-#include <QtNetwork/QLocalServer>
-class INSTALLER_EXPORT FSEngineServer : public QLocalServer
-{
- Q_OBJECT
public:
- explicit FSEngineServer( const QString& socket, QObject* parent = 0 );
+ explicit FSEngineServer(quint16 port, QObject *parent = 0);
+ FSEngineServer(const QHostAddress &address, quint16 port, QObject *parent = 0);
~FSEngineServer();
-
- void setAuthorizationKey( const QString& key );
+
+ void enableTestMode();
+ void setAuthorizationKey(const QString &key);
QString authorizationKey() const;
protected:
- void incomingConnection( quintptr socketDescriptor );
+ void incomingConnection(int socketDescriptor);
private:
QString key;
KDWatchdog watchdog;
};
-#endif
#endif
diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp
index 6c8b2f545..383c2af44 100644
--- a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp
+++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp
@@ -31,20 +31,21 @@
**
**************************************************************************/
#include "getrepositoriesmetainfojob.h"
-#include "getrepositorymetainfojob.h"
-#include <cassert>
+#include "getrepositorymetainfojob.h"
+#include "qinstallerglobal.h"
using namespace KDUpdater;
using namespace QInstaller;
-GetRepositoriesMetaInfoJob::GetRepositoriesMetaInfoJob(const QByteArray &publicKey,
- bool packageManager, QObject *parent)
+
+// -- GetRepositoriesMetaInfoJob
+
+GetRepositoriesMetaInfoJob::GetRepositoriesMetaInfoJob(const QByteArray &publicKey, QObject *parent)
: KDJob(parent),
m_publicKey(publicKey),
m_canceled(false),
m_silentRetries(3),
- m_packageManager(packageManager),
m_haveIgnoredError(false)
{
setCapabilities(Cancelable);
@@ -58,6 +59,7 @@ QList< Repository > GetRepositoriesMetaInfoJob::repositories() const
void GetRepositoriesMetaInfoJob::setRepositories(const QList<Repository>& repos)
{
m_repositories = repos;
+ m_tmpRepositories = repos;
}
QStringList GetRepositoriesMetaInfoJob::temporaryDirectories() const
@@ -116,34 +118,31 @@ void GetRepositoriesMetaInfoJob::fetchNextRepo()
}
if (m_canceled) {
- emitFinished();
+ emitFinishedWithError(KDJob::Canceled, m_errorString);
return;
}
- if (m_repositories.isEmpty()) {
+
+ if (m_tmpRepositories.isEmpty()) {
if (m_haveIgnoredError)
- emitFinishedWithError(UserIgnoreError, m_errorString);
+ emitFinishedWithError(QInstaller::UserIgnoreError, m_errorString);
else
emitFinished();
return;
}
- const Repository r = m_repositories.back();
- m_repositories.pop_back();
- m_job = new GetRepositoryMetaInfoJob(m_publicKey, m_packageManager, this);
- m_job->setRepository(r);
+
+ m_job = new GetRepositoryMetaInfoJob(m_publicKey, this);
m_job->setSilentRetries(silentRetries());
+ m_job->setRepository(m_tmpRepositories.takeLast());
connect(m_job, SIGNAL(finished(KDJob*)), this, SLOT(jobFinished(KDJob*)));
+ connect(m_job, SIGNAL(infoMessage(KDJob*, QString)), this, SIGNAL(infoMessage(KDJob*, QString)));
m_job->start();
}
-void GetRepositoriesMetaInfoJob::slotInfoMessage(KDJob*, const QString& msg)
-{
- emit infoMessage(this, msg);
-}
-
void GetRepositoriesMetaInfoJob::jobFinished(KDJob* j)
{
const GetRepositoryMetaInfoJob* const job = qobject_cast<const GetRepositoryMetaInfoJob*>(j);
- assert(job);
+ Q_ASSERT(job);
+
if(job->error() != KDJob::NoError && !job->temporaryDirectory().isEmpty()) {
try {
removeDirectory(job->temporaryDirectory());
@@ -156,26 +155,20 @@ void GetRepositoriesMetaInfoJob::jobFinished(KDJob* j)
return;
}
- if (job->error() == GetRepositoryMetaInfoJob::UserIgnoreError) {
+ if (job->error() == QInstaller::UserIgnoreError) {
m_haveIgnoredError = true;
m_errorString = job->errorString();
QMetaObject::invokeMethod(this, "fetchNextRepo", Qt::QueuedConnection);
return;
}
- if (job->error() == GetRepositoryMetaInfoJob::InvalidMetaInfo) {
+ if (job->error() == QInstaller::InvalidMetaInfo) {
emitFinishedWithError(KDJob::UserDefinedError, tr("Error while accessing online "
"repository: %1. Please try again later").arg(job->errorString()));
return;
}
- if (job->error() != KDJob::NoError && job->repository().required()) {
- emitFinishedWithError(KDJob::UserDefinedError, tr("Error while accessing online "
- "repository: %1").arg(job->errorString()));
- return;
- }
-
- const QString tmpdir = job->releaseTemporaryDirectory();
+ const QString &tmpdir = job->releaseTemporaryDirectory();
job->m_tempDirDeleter.passAndRelease(m_tempDirDeleter, tmpdir);
m_repositoryByTemporaryDirectory.insert(tmpdir, job->repository());
diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.h b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h
index 4391dc151..5db616eef 100644
--- a/installerbuilder/libinstaller/getrepositoriesmetainfojob.h
+++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h
@@ -51,15 +51,10 @@ class INSTALLER_EXPORT GetRepositoriesMetaInfoJob : public KDJob
Q_OBJECT
public:
- enum Error {
- UserIgnoreError=KDJob::UserDefinedError + 1
- };
+ explicit GetRepositoriesMetaInfoJob(const QByteArray &publicKey, QObject *parent = 0);
- explicit GetRepositoriesMetaInfoJob(const QByteArray &publicKey, bool packageManager = false,
- QObject *parent = 0);
-
- QList< Repository > repositories() const;
- void setRepositories(const QList<Repository> &repos);
+ QList<Repository> repositories() const;
+ void setRepositories(const QList<Repository> &repositories);
QStringList temporaryDirectories() const;
QStringList releaseTemporaryDirectories() const;
@@ -78,15 +73,14 @@ private Q_SLOTS:
void fetchNextRepo();
void jobFinished(KDJob*);
- void slotInfoMessage(KDJob*, const QString&);
private:
QPointer<GetRepositoryMetaInfoJob> m_job;
const QByteArray m_publicKey;
bool m_canceled;
int m_silentRetries;
- bool m_packageManager;
QList<Repository> m_repositories;
+ QList<Repository> m_tmpRepositories;
QHash<QString, Repository> m_repositoryByTemporaryDirectory;
bool m_haveIgnoredError;
QString m_errorString;
diff --git a/installerbuilder/libinstaller/getrepositorymetainfojob.cpp b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp
index 8cb2b394f..6223537ea 100644
--- a/installerbuilder/libinstaller/getrepositorymetainfojob.cpp
+++ b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp
@@ -37,12 +37,10 @@
#include "cryptosignatureverifier.h"
#include "lib7z_facade.h"
#include "messageboxhandler.h"
+#include "qinstallerglobal.h"
#include <KDUpdater/FileDownloader>
#include <KDUpdater/FileDownloaderFactory>
-#include <KDUpdater/SignatureVerifier>
-#include <KDUpdater/SignatureVerificationResult>
-#include <KDUpdater/kdupdatercrypto.h>
#include <QtCore/QFile>
#include <QtCore/QTimer>
@@ -53,18 +51,17 @@
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
-#include <cassert>
-
using namespace KDUpdater;
using namespace QInstaller;
-GetRepositoryMetaInfoJob::GetRepositoryMetaInfoJob(const QByteArray &publicKey,
- bool packageManager, QObject *parent)
+
+// -- GetRepositoryMetaInfoJob
+
+GetRepositoryMetaInfoJob::GetRepositoryMetaInfoJob(const QByteArray &publicKey, QObject *parent)
: KDJob(parent),
m_canceled(false),
m_silentRetries(3),
m_retriesLeft(m_silentRetries),
- m_packageManager(packageManager),
m_publicKey(publicKey),
m_downloader()
{
@@ -132,17 +129,17 @@ void GetRepositoryMetaInfoJob::startUpdatesXmlDownload()
const QUrl url = m_repository.url();
if (url.isEmpty()) {
- emitFinishedWithError(InvalidUrl, tr("empty repository URL"));
+ emitFinishedWithError(QInstaller::InvalidUrl, tr("empty repository URL"));
return;
}
if (!url.isValid()) {
- emitFinishedWithError(InvalidUrl, tr("invalid repository URL"));
+ emitFinishedWithError(QInstaller::InvalidUrl, tr("invalid repository URL"));
return;
}
m_downloader = FileDownloaderFactory::instance().create(url.scheme(), 0, QUrl(), this);
if (!m_downloader) {
- emitFinishedWithError(InvalidUrl, tr("URL scheme not supported: %1 (%2)").arg(url.scheme(),
- url.toString()));
+ emitFinishedWithError(QInstaller::InvalidUrl, tr("URL scheme not supported: %1 (%2)")
+ .arg(url.scheme(), url.toString()));
return;
}
@@ -157,67 +154,58 @@ void GetRepositoryMetaInfoJob::startUpdatesXmlDownload()
void GetRepositoryMetaInfoJob::updatesXmlDownloadCanceled()
{
- emitFinishedWithError(Canceled, m_downloader->errorString());
+ emitFinishedWithError(KDJob::Canceled, m_downloader->errorString());
}
void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished()
{
+ emit infoMessage(this, tr("Retrieving component meta information..."));
+
const QString fn = m_downloader->downloadedFileName();
+ Q_ASSERT(!fn.isEmpty());
+ Q_ASSERT(QFile::exists(fn));
- assert(!fn.isEmpty());
- assert(QFile::exists(fn));
try {
m_temporaryDirectory = createTemporaryDirectory(QLatin1String("remoterepo"));
m_tempDirDeleter.add(m_temporaryDirectory);
} catch (const QInstaller::Error& e) {
- emitFinishedWithError(ExtractionError, e.message());
+ emitFinishedWithError(QInstaller::ExtractionError, e.message());
return;
}
QFile file(fn);
const QString updatesXmlPath = m_temporaryDirectory + QLatin1String("/Updates.xml");
if (!file.rename(updatesXmlPath)) {
- emitFinishedWithError(DownloadError,
+ emitFinishedWithError(QInstaller::DownloadError,
tr("Could not move Updates.xml to target location: %1").arg(file.errorString()));
return;
}
QFile updatesFile(updatesXmlPath);
if (!updatesFile.open(QIODevice::ReadOnly)) {
- emitFinishedWithError(DownloadError,
+ emitFinishedWithError(QInstaller::DownloadError,
tr("Could not open Updates.xml for reading: %1").arg(updatesFile.errorString()));
return;
}
- QDomDocument doc;
QString err;
- int line = 0;
- int col = 0;
- if (!doc.setContent(&updatesFile, &err, &line, &col)) {
- QMessageBox::StandardButtons buttons = QMessageBox::Cancel;
- QString packageManagerMessage;
- if (m_packageManager) {
- buttons |= QMessageBox::Ok;
- packageManagerMessage = tr("\nOnly uninstallation is possible.");
- }
+ QDomDocument doc;
+ if (!doc.setContent(&updatesFile, &err)) {
+ const QString msg = tr("Could not fetch a valid version of Updates.xml from repository %1, Error: %2")
+ .arg(m_repository.url().toString(), err);
+ verbose() << msg << std::endl;
+
const QMessageBox::StandardButton b =
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not fetch a "
- "valid version of Updates.xml: %1%2").arg(err, packageManagerMessage), buttons);
-
- if (b == QMessageBox::Cancel) {
- emitFinishedWithError(KDJob::Canceled, tr("Could not fetch Updates.xml: %1").arg(err));
- return;
- }
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), msg, QMessageBox::Cancel);
- if (b == QMessageBox::Ok) {
- emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("Could not fetch "
- "Updates.xml: %1").arg(err));
+ if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) {
+ emitFinishedWithError(KDJob::Canceled, msg);
return;
}
- //emitFinishedWithError(InvalidMetaInfo, tr("Could not parse component index: %1:%2: %3")
- // .arg(QString::number(line), QString::number(col), err));
}
+ emit infoMessage(this, tr("Parsing component meta information..."));
+
const QDomElement root = doc.documentElement();
const QDomNodeList children = root.childNodes();
for (int i = 0; i < children.count(); ++i) {
@@ -242,32 +230,26 @@ void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished()
emitFinished();
return;
}
- emit infoMessage(this, tr("Retrieving component meta information..."));
+
+ emit infoMessage(this, tr("Finished updating component meta information..."));
+
fetchNextMetaInfo();
}
void GetRepositoryMetaInfoJob::updatesXmlDownloadError(const QString &err)
{
if (m_retriesLeft <= 0) {
+ const QString msg = tr("Could not fetch Updates.xml from repository %1, Error: %2")
+ .arg(m_repository.url().toString(), err);
+ verbose() << msg << std::endl;
+
QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel;
- QString packageManagerMessage;
- if (m_packageManager) {
- buttons |= QMessageBox::Ok;
- packageManagerMessage = tr("\nOnly uninstallation is possible.");
- }
const QMessageBox::StandardButton b =
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not fetch "
- "Updates.xml: %1%2").arg(err, packageManagerMessage), buttons);
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), msg, buttons);
if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) {
- emitFinishedWithError(KDJob::Canceled, tr("Could not fetch Updates.xml: %1").arg(err));
- return;
- }
-
- if (b == QMessageBox::Ok) {
- emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("Could not fetch "
- "Updates.xml: %1").arg(err));
+ emitFinishedWithError(KDJob::Canceled, msg);
return;
}
}
@@ -280,8 +262,12 @@ void GetRepositoryMetaInfoJob::updatesXmlDownloadError(const QString &err)
void GetRepositoryMetaInfoJob::fetchNextMetaInfo()
{
- if (m_canceled)
+ emit infoMessage(this, tr("Retrieving component information from remote repository..."));
+
+ if (m_canceled) {
+ metaDownloadCanceled();
return;
+ }
if (m_packageNames.isEmpty() && m_currentPackageName.isEmpty()) {
emitFinished();
@@ -291,11 +277,9 @@ void GetRepositoryMetaInfoJob::fetchNextMetaInfo()
QString next = m_currentPackageName;
QString nextVersion = m_currentPackageVersion;
if (next.isEmpty()) {
- next = m_packageNames.back();
- m_packageNames.pop_back();
m_retriesLeft = m_silentRetries;
- nextVersion = m_packageVersions.back();
- m_packageVersions.pop_back();
+ next = m_packageNames.takeLast();
+ nextVersion = m_packageVersions.takeLast();
}
verbose() << "fetching metadata of " << next << " in version " << nextVersion << std::endl;
@@ -338,24 +322,22 @@ void GetRepositoryMetaInfoJob::fetchNextMetaInfo()
Qt::QueuedConnection);
m_downloader->download();
-
- emit infoMessage(this, tr("Retrieving component information from remote repositories..."));
}
void GetRepositoryMetaInfoJob::metaDownloadCanceled()
{
- updatesXmlDownloadCanceled();
+ emitFinishedWithError(KDJob::Canceled, m_downloader->errorString());
}
void GetRepositoryMetaInfoJob::metaDownloadFinished()
{
const QString fn = m_downloader->downloadedFileName();
- assert(!fn.isEmpty());
+ Q_ASSERT(!fn.isEmpty());
QFile arch(fn);
if (!arch.open(QIODevice::ReadOnly)) {
- emitFinishedWithError(ExtractionError, tr("Could not open meta info archive %1: %2").arg(fn,
- arch.errorString()));
+ emitFinishedWithError(QInstaller::ExtractionError,
+ tr("Could not open meta info archive %1: %2").arg(fn, arch.errorString()));
return;
}
@@ -379,8 +361,8 @@ void GetRepositoryMetaInfoJob::metaDownloadFinished()
if (!arch.remove())
qWarning("Could not delete file %s: %s", qPrintable(fn), qPrintable(arch.errorString()));
} catch (const Lib7z::SevenZipException& e) {
- emitFinishedWithError(ExtractionError, tr("Could not open meta info archive %1: %2").arg(fn,
- e.message()));
+ emitFinishedWithError(QInstaller::ExtractionError,
+ tr("Could not open meta info archive %1: %2").arg(fn, e.message()));
return;
}
@@ -396,26 +378,17 @@ void GetRepositoryMetaInfoJob::metaDownloadError(const QString &err)
emit infoMessage(this, tr("The hash of one component does not match the expected one."));
if (m_retriesLeft <= 0) {
- QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel;
- QString packageManagerMessage;
- if (m_packageManager) {
- buttons |= QMessageBox::Ok;
- packageManagerMessage = tr("\nOnly uninstallation is possible.");
- }
+ const QString msg = tr("Could not download meta information for component %1, Error: %2")
+ .arg(m_currentPackageName, err);
+ verbose() << msg << std::endl;
+ QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel;
const QMessageBox::StandardButton b =
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not download "
- "information for component %1: %2%3") .arg(m_currentPackageName, err,
- packageManagerMessage), buttons);
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), msg, buttons);
- if (b == QMessageBox::Cancel) {
- emitFinishedWithError(Canceled, tr("Canceled"));
- return;
- }
-
- if (b == QMessageBox::Ok) {
- emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("%1").arg(err));
+ if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) {
+ emitFinishedWithError(KDJob::Canceled, msg);
return;
}
}
diff --git a/installerbuilder/libinstaller/getrepositorymetainfojob.h b/installerbuilder/libinstaller/getrepositorymetainfojob.h
index a428f3b20..64bf32e28 100644
--- a/installerbuilder/libinstaller/getrepositorymetainfojob.h
+++ b/installerbuilder/libinstaller/getrepositorymetainfojob.h
@@ -51,17 +51,7 @@ class INSTALLER_EXPORT GetRepositoryMetaInfoJob : public KDJob
friend class ::QInstaller::GetRepositoriesMetaInfoJob;
public:
- enum Error {
- InvalidUrl = KDJob::UserDefinedError,
- DownloadError,
- InvalidUpdatesXml,
- InvalidMetaInfo,
- ExtractionError,
- UserIgnoreError
- };
-
- explicit GetRepositoryMetaInfoJob(const QByteArray &publicKey = QByteArray(),
- bool packageManager = false, QObject *parent = 0);
+ explicit GetRepositoryMetaInfoJob(const QByteArray &publicKey = QByteArray(), QObject *parent = 0);
~GetRepositoryMetaInfoJob();
Repository repository() const;
@@ -92,7 +82,6 @@ private:
bool m_canceled;
int m_silentRetries;
int m_retriesLeft;
- bool m_packageManager;
const QByteArray m_publicKey;
Repository m_repository;
QStringList m_packageNames;
diff --git a/installerbuilder/libinstaller/globalsettingsoperation.cpp b/installerbuilder/libinstaller/globalsettingsoperation.cpp
index d3cf99797..e3eb35885 100644
--- a/installerbuilder/libinstaller/globalsettingsoperation.cpp
+++ b/installerbuilder/libinstaller/globalsettingsoperation.cpp
@@ -31,7 +31,7 @@
**
**************************************************************************/
#include "globalsettingsoperation.h"
-#include "fsengineclient.h"
+#include "qsettingswrapper.h"
using namespace QInstaller;
@@ -65,7 +65,7 @@ bool GlobalSettingsOperation::performOperation()
settings->setValue(key, value);
settings->sync();
- if (settings->status() != QSettings::NoError) {
+ if (settings->status() != QSettingsWrapper::NoError) {
setError(UserDefinedError);
setErrorString(tr("Failed to write settings"));
return false;
@@ -118,7 +118,7 @@ QSettingsWrapper* GlobalSettingsOperation::setup(QString *key, QString *value,
const QString &filename = arguments.at(0);
*key = arguments.at(1);
*value = arguments.at(2);
- return new QSettingsWrapper(filename, QSettings::NativeFormat);
+ return new QSettingsWrapper(filename, QSettingsWrapper::NativeFormat);
}
setError(InvalidArguments);
diff --git a/installerbuilder/libinstaller/globalsettingsoperation.h b/installerbuilder/libinstaller/globalsettingsoperation.h
index e8c16117a..82cf3cd2f 100644
--- a/installerbuilder/libinstaller/globalsettingsoperation.h
+++ b/installerbuilder/libinstaller/globalsettingsoperation.h
@@ -29,7 +29,6 @@
#include <KDUpdater/UpdateOperation>
class QSettingsWrapper;
-class QStringList;
namespace QInstaller {
diff --git a/installerbuilder/libinstaller/installationprogressdialog.h b/installerbuilder/libinstaller/installationprogressdialog.h
index 5523b28f3..712a7794a 100644
--- a/installerbuilder/libinstaller/installationprogressdialog.h
+++ b/installerbuilder/libinstaller/installationprogressdialog.h
@@ -28,26 +28,34 @@
#include <QtGui/QDialog>
+QT_BEGIN_NAMESPACE
class QDialogButtonBox;
+QT_END_NAMESPACE
namespace QInstaller {
class PerformInstallationForm;
-class InstallationProgressDialog : public QDialog{
+class InstallationProgressDialog : public QDialog
+{
Q_OBJECT
+
public:
explicit InstallationProgressDialog( QWidget* parent=0 );
~InstallationProgressDialog();
//bool isShowingDetails() const;
+
Q_SIGNALS:
void canceled();
private Q_SLOTS:
void finished();
+
private:
PerformInstallationForm *m_performInstallationForm;
QDialogButtonBox* m_dialogBtns;
};
-} //namespace QInstaller
+
+} // namespace QInstaller
+
#endif
diff --git a/installerbuilder/libinstaller/installer_global.h b/installerbuilder/libinstaller/installer_global.h
index 691cfe26e..1da1013bf 100644
--- a/installerbuilder/libinstaller/installer_global.h
+++ b/installerbuilder/libinstaller/installer_global.h
@@ -38,14 +38,4 @@
#define INSTALLER_EXPORT
#endif
-namespace QInstaller {
- enum RunModes
- {
- UpdaterMode,
- InstallerMode,
- AllMode //this is a kind of doesn't matter mode
- };
- //Q_ENUMS(InstallerMode)
-}
-
#endif //INSTALLER_GLOBAL_H
diff --git a/installerbuilder/libinstaller/installerbase.qrc b/installerbuilder/libinstaller/installerbase.qrc
deleted file mode 100644
index f863bd93f..000000000
--- a/installerbuilder/libinstaller/installerbase.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>translations/qt_de.qm</file>
- <file>translations/de_de.qm</file>
- <file>translations/qt_sv.qm</file>
- <file>translations/sv_se.qm</file>
-</qresource>
-</RCC>
diff --git a/installerbuilder/libinstaller/installiconsoperation.cpp b/installerbuilder/libinstaller/installiconsoperation.cpp
index 7b1bfe85a..91cff906c 100644
--- a/installerbuilder/libinstaller/installiconsoperation.cpp
+++ b/installerbuilder/libinstaller/installiconsoperation.cpp
@@ -175,7 +175,7 @@ bool InstallIconsOperation::performOperation()
qApp->processEvents();
const int status = installer->status();
- if (status == Installer::InstallerCanceledByUser || status == Installer::InstallerFailed)
+ if(status == Installer::Canceled || status == Installer::Failure)
return true;
const QString source = it.next();
diff --git a/installerbuilder/libinstaller/kdmmappedfileiodevice.h b/installerbuilder/libinstaller/kdmmappedfileiodevice.h
index 06aa18819..d4c5e51d5 100644
--- a/installerbuilder/libinstaller/kdmmappedfileiodevice.h
+++ b/installerbuilder/libinstaller/kdmmappedfileiodevice.h
@@ -30,10 +30,14 @@
#include "installer_global.h"
+QT_BEGIN_NAMESPACE
class QFile;
+QT_END_NAMESPACE
-class INSTALLER_EXPORT KDMMappedFileIODevice : public QIODevice {
+class INSTALLER_EXPORT KDMMappedFileIODevice : public QIODevice
+{
Q_OBJECT
+
public:
KDMMappedFileIODevice( QFile* file, qint64 offset, qint64 length, QObject* parent=0 );
KDMMappedFileIODevice( const QString& filename, qint64 offset, qint64 length, QObject* parent=0 );
diff --git a/installerbuilder/libinstaller/libinstaller.pri b/installerbuilder/libinstaller/libinstaller.pri
index 7654a98a0..afede9b97 100644
--- a/installerbuilder/libinstaller/libinstaller.pri
+++ b/installerbuilder/libinstaller/libinstaller.pri
@@ -4,19 +4,16 @@ DEFINES += FSENGINE_TCP
INCLUDEPATH += $$PWD \
$$PWD/.. \
- $$PWD/kdtools
+ $$PWD/3rdparty/kdtools \
+ $$PWD/3rdparty/p7zip_9.04 \
+ $$PWD/3rdparty/p7zip_9.04/unix/CPP
DEPENDPATH += $$PWD \
$$PWD/.. \
- $$PWD/kdtools/KDToolsCore \
- $$PWD/kdtools/KDUpdater
-
-
-INCLUDEPATH += $$PWD/3rdparty/p7zip_9.04/unix/CPP \
- $$PWD/3rdparty/p7zip_9.04
-
-DEPENDPATH += $$PWD/3rdparty/p7zip_9.04/unix/CPP \
- $$PWD/3rdparty/p7zip_9.04
+ $$PWD/3rdparty/p7zip_9.04 \
+ $$PWD/3rdparty/p7zip_9.04/unix/CPP \
+ $$PWD/3rdparty/kdtools/KDUpdater \
+ $$PWD/3rdparty/kdtools/KDToolsCore \
CONFIG( shared, static|shared ):DEFINES += LIB_INSTALLER_SHARED
CONFIG( shared, static|shared ):DEFINES += KDTOOLS_SHARED
diff --git a/installerbuilder/libinstaller/libinstaller.pro b/installerbuilder/libinstaller/libinstaller.pro
index ec2a1f5cd..98541cc8a 100644
--- a/installerbuilder/libinstaller/libinstaller.pro
+++ b/installerbuilder/libinstaller/libinstaller.pro
@@ -3,18 +3,17 @@ TARGET = installer
DEPENDPATH += . \
.. \
../common \
- kdtools/KDToolsCore \
- kdtools/KDUpdater
+ 3rdparty/kdtools/KDToolsCore \
+ 3rdparty/kdtools/KDUpdater
INCLUDEPATH += . \
.. \
- kdtools
+ 3rdparty/kdtools
DESTDIR = $$OUT_PWD/../lib
DLLDESTDIR = $$OUT_PWD/../bin
DEFINES += QT_NO_CAST_FROM_ASCII \
- BUILD_LIB_INSTALLER \
- FSENGINE_TCP
+ BUILD_LIB_INSTALLER
CONFIG( shared, static|shared ){
DEFINES += KDTOOLS_SHARED
@@ -28,23 +27,22 @@ CONFIG += help uitools
QTPLUGIN += qsqlite
include(3rdparty/p7zip_9.04/p7zip.pri)
-include(kdtools/KDToolsCore/KDToolsCore.pri)
-include(kdtools/KDUpdater/KDUpdater.pri)
+include(3rdparty/kdtools/KDUpdater/KDUpdater.pri)
+include(3rdparty/kdtools/KDToolsCore/KDToolsCore.pri)
HEADERS += $$PWD/qinstaller.h \
+ $$PWD/qinstaller_p.h \
$$PWD/qinstallergui.h \
../common/binaryformat.h \
../common/binaryformatengine.h \
../common/binaryformatenginehandler.h \
../common/repository.h \
../common/zipjob.h \
- ../common/kd7zengine.h \
- ../common/kd7zenginehandler.h \
../common/utils.h \
../common/errors.h \
kdmmappedfileiodevice.h \
qinstallercomponent.h \
- qinstallercomponentmodel.h \
+ componentmodel.h \
qinstallerglobal.h \
qtpatch.h \
persistentsettings.h \
@@ -77,11 +75,7 @@ HEADERS += $$PWD/qinstaller.h \
downloadarchivesjob.h \
init.h \
updater.h \
- updateagent.h \
updatesettings.h \
- updatesettingsdialog.h \
- updatesettingswidget.h \
- componentselectiondialog.h \
adminauthorization.h \
fsengineclient.h \
fsengineserver.h \
@@ -95,26 +89,28 @@ HEADERS += $$PWD/qinstaller.h \
messageboxhandler.h \
getrepositoriesmetainfojob.h \
licenseoperation.h \
+ qinstallercomponent_p.h \
qtcreator_constants.h \
qtcreatorpersistentsettings.h \
registerdefaultdebuggeroperation.h \
- updatecreatorsettingsfrom21to22operation.h
+ updatecreatorsettingsfrom21to22operation.h \
+ qprocesswrapper.h \
+ qsettingswrapper.h
SOURCES += $$PWD/qinstaller.cpp \
+ $$PWD/qinstaller_p.cpp \
$$PWD/qinstallergui.cpp \
../common/binaryformat.cpp \
../common/binaryformatengine.cpp \
../common/binaryformatenginehandler.cpp \
../common/repository.cpp \
../common/zipjob.cpp \
- ../common/kd7zengine.cpp \
- ../common/kd7zenginehandler.cpp \
../common/installersettings.cpp \
../common/fileutils.cpp \
../common/utils.cpp \
kdmmappedfileiodevice.cpp \
qinstallercomponent.cpp \
- qinstallercomponentmodel.cpp \
+ componentmodel.cpp \
qtpatch.cpp \
persistentsettings.cpp \
qtpatchoperation.cpp \
@@ -143,11 +139,7 @@ SOURCES += $$PWD/qinstaller.cpp \
downloadarchivesjob.cpp \
init.cpp \
updater.cpp \
- updateagent.cpp \
updatesettings.cpp \
- updatesettingsdialog.cpp \
- updatesettingswidget.cpp \
- componentselectiondialog.cpp \
adminauthorization.cpp \
fsengineclient.cpp \
fsengineserver.cpp \
@@ -161,9 +153,13 @@ SOURCES += $$PWD/qinstaller.cpp \
messageboxhandler.cpp \
getrepositoriesmetainfojob.cpp \
licenseoperation.cpp \
+ qinstallercomponent_p.cpp \
qtcreatorpersistentsettings.cpp \
registerdefaultdebuggeroperation.cpp \
- updatecreatorsettingsfrom21to22operation.cpp
+ updatecreatorsettingsfrom21to22operation.cpp \
+ qprocesswrapper.cpp \
+ templates.cpp \
+ qsettingswrapper.cpp
macx {
HEADERS += macrelocateqt.h \
@@ -191,10 +187,9 @@ CONFIG( shared, static|shared ): {
}
macx: LIBS += -framework Security
-
-TRANSLATIONS += de_de.ts \
- sv_se.ts
-RESOURCES += ../common/openssl.qrc \
- patch_file_lists.qrc
-FORMS += componentselectiondialog.ui updatesettingsdialog.ui updatesettingswidget.ui
+TRANSLATIONS += translations/de_de.ts \
+ translations/sv_se.ts
+
+RESOURCES += ../common/openssl.qrc \
+ resources/patch_file_lists.qrc
diff --git a/installerbuilder/libinstaller/macrelocateqt.cpp b/installerbuilder/libinstaller/macrelocateqt.cpp
index 4f59e9f2f..d04d86c78 100644
--- a/installerbuilder/libinstaller/macrelocateqt.cpp
+++ b/installerbuilder/libinstaller/macrelocateqt.cpp
@@ -33,11 +33,11 @@
#include "macrelocateqt.h"
#include "common/utils.h"
#include "fsengineclient.h"
+#include "qprocesswrapper.h"
#include <QtCore/QDirIterator>
#include <QtCore/QDebug>
#include <QtCore/QBuffer>
-#include <QtCore/QProcess>
using namespace QInstaller;
@@ -115,7 +115,7 @@ bool Relocator::containsOriginalBuildDir(const QString &dirName)
void Relocator::extractExecutableInfo(const QString& fileName, QStringList& frameworks)
{
verbose() << "Relocator calling otool -l for " << fileName << std::endl;
- QProcess otool;
+ QProcessWrapper otool;
otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << fileName);
if (!otool.waitForStarted()) {
mErrorMessage = QLatin1String("Can't start otool. Is Xcode installed?");
diff --git a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp
index 377b58688..652540fa8 100644
--- a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp
+++ b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp
@@ -32,11 +32,11 @@
**************************************************************************/
#include "macreplaceinstallnamesoperation.h"
#include "fsengineclient.h"
+#include "qprocesswrapper.h"
#include <QtCore/QDirIterator>
#include <QtCore/QDebug>
#include <QtCore/QBuffer>
-#include <QtCore/QProcess>
using namespace QInstaller;
@@ -104,7 +104,7 @@ bool MacReplaceInstallNamesOperation::apply(const QString& indicator, const QStr
void MacReplaceInstallNamesOperation::extractExecutableInfo(const QString& fileName, QString& frameworkId, QStringList& frameworks)
{
- QProcess otool;
+ QProcessWrapper otool;
otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << fileName);
if (!otool.waitForStarted()) {
setError(UserDefinedError, tr("Can't invoke otool."));
diff --git a/installerbuilder/libinstaller/messageboxhandler.cpp b/installerbuilder/libinstaller/messageboxhandler.cpp
index 2428843cd..10249ded2 100644
--- a/installerbuilder/libinstaller/messageboxhandler.cpp
+++ b/installerbuilder/libinstaller/messageboxhandler.cpp
@@ -32,51 +32,86 @@
**************************************************************************/
#include "messageboxhandler.h"
-#include <QApplication>
-#include <QScriptValue>
-#include <QScriptEngine>
-#include <QDebug>
+#include <QtCore/QDebug>
-QScriptValue QInstaller::registerMessageBox( QScriptEngine* scriptEngine ) {
- QScriptValue messageBox = scriptEngine->newQObject(MessageBoxHandler::instance());
+#include <QtGui/QApplication>
+#include <QtGui/QPushButton>
+#include <QtGui/QDialogButtonBox>
+
+#include <QtScript/QScriptEngine>
+#include <QtScript/QScriptValue>
+
+QScriptValue QInstaller::registerMessageBox(QScriptEngine *scriptEngine)
+{
// register QMessageBox::StandardButton enum in the script connection
- messageBox.setProperty( QLatin1String( "Ok" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Yes ) ) );
- messageBox.setProperty( QLatin1String( "Open" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Open ) ) );
- messageBox.setProperty( QLatin1String( "Save" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Save ) ) );
- messageBox.setProperty( QLatin1String( "Cancel" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Cancel ) ) );
- messageBox.setProperty( QLatin1String( "Close" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Close ) ) );
- messageBox.setProperty( QLatin1String( "Discard" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Discard ) ) );
- messageBox.setProperty( QLatin1String( "Apply" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Apply ) ) );
- messageBox.setProperty( QLatin1String( "Reset" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Reset ) ) );
- messageBox.setProperty( QLatin1String( "RestoreDefaults" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::RestoreDefaults ) ) );
- messageBox.setProperty( QLatin1String( "Help" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Help ) ) );
- messageBox.setProperty( QLatin1String( "SaveAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::SaveAll ) ) );
- messageBox.setProperty( QLatin1String( "Yes" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Yes ) ) );
- messageBox.setProperty( QLatin1String( "YesToAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::YesToAll ) ) );
- messageBox.setProperty( QLatin1String( "No" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::No ) ) );
- messageBox.setProperty( QLatin1String( "NoToAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::NoToAll ) ) );
- messageBox.setProperty( QLatin1String( "Abort" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Abort ) ) );
- messageBox.setProperty( QLatin1String( "Retry" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Retry ) ) );
- messageBox.setProperty( QLatin1String( "Ignore" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Ignore ) ) );
- messageBox.setProperty( QLatin1String( "NoButton" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::NoButton ) ) );
- scriptEngine->globalObject().setProperty( QLatin1String("QMessageBox"), messageBox );
+ QScriptValue messageBox = scriptEngine->newQObject(MessageBoxHandler::instance());
+ messageBox.setProperty(QLatin1String("Ok"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Yes)));
+ messageBox.setProperty(QLatin1String("Open"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Open)));
+ messageBox.setProperty(QLatin1String("Save"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Save)));
+ messageBox.setProperty(QLatin1String("Cancel"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Cancel)));
+ messageBox.setProperty(QLatin1String("Close"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Close)));
+ messageBox.setProperty(QLatin1String("Discard"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Discard)));
+ messageBox.setProperty(QLatin1String("Apply"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Apply)));
+ messageBox.setProperty(QLatin1String("Reset"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Reset)));
+ messageBox.setProperty(QLatin1String("RestoreDefaults"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::RestoreDefaults)));
+ messageBox.setProperty(QLatin1String("Help"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Help)));
+ messageBox.setProperty(QLatin1String("SaveAll"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::SaveAll)));
+ messageBox.setProperty(QLatin1String("Yes"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Yes)));
+ messageBox.setProperty(QLatin1String("YesToAll"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::YesToAll)));
+ messageBox.setProperty(QLatin1String("No"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::No)));
+ messageBox.setProperty(QLatin1String("NoToAll"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::NoToAll)));
+ messageBox.setProperty(QLatin1String("Abort"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Abort)));
+ messageBox.setProperty(QLatin1String("Retry"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Retry)));
+ messageBox.setProperty(QLatin1String("Ignore"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::Ignore)));
+ messageBox.setProperty(QLatin1String("NoButton"),
+ scriptEngine->newVariant(static_cast<int>(QMessageBox::NoButton)));
+ scriptEngine->globalObject().setProperty(QLatin1String("QMessageBox"), messageBox);
+
return messageBox;
}
using namespace QInstaller;
-MessageBoxHandler *MessageBoxHandler::m_instance = 0;
+template <typename T>
+static QList<T> reversed(const QList<T> &list)
+{
+ QList<T> res = list;
+ qCopyBackward(list.begin(), list.end(), res.end());
+ return res;
+}
+
+
+// -- MessageBoxHandler
+MessageBoxHandler *MessageBoxHandler::m_instance = 0;
MessageBoxHandler::MessageBoxHandler(QObject *parent)
- : QObject(parent), m_defaultAction( MessageBoxHandler::AskUser )
+ : QObject(parent)
+ , m_defaultAction(MessageBoxHandler::AskUser)
{
-
}
+// -- public
MessageBoxHandler::~MessageBoxHandler()
{
-
}
MessageBoxHandler* MessageBoxHandler::instance()
@@ -86,131 +121,176 @@ MessageBoxHandler* MessageBoxHandler::instance()
return m_instance;
}
-void MessageBoxHandler::setAutomaticAnswer(const QString& identifier, QMessageBox::StandardButton answer)
+QWidget* MessageBoxHandler::currentBestSuitParent()
{
- m_automaticAnswers.insert( identifier, answer );
-}
+ if (QApplication::type() == QApplication::Tty) {
+ Q_ASSERT_X(false, Q_FUNC_INFO, "We can't find a parent widget if we are a console application.");
+ return 0;
+ }
-template <typename T>
-static QList<T> reversed( const QList<T>& list ) {
- QList<T> res = list;
- qCopyBackward( list.begin(), list.end(), res.end() );
- return res;
+ if (qApp->activeModalWidget())
+ return qApp->activeModalWidget();
+
+ return qApp->activeWindow();
}
void MessageBoxHandler::setDefaultAction(DefaultAction defaultAction)
{
- if ( m_defaultAction == defaultAction )
+ if (m_defaultAction == defaultAction)
return;
m_defaultAction = defaultAction;
+
m_buttonOrder.clear();
- if ( m_defaultAction != AskUser )
+ if (m_defaultAction != AskUser) {
m_buttonOrder << QMessageBox::YesToAll << QMessageBox::Yes << QMessageBox::Ok << QMessageBox::Apply
- << QMessageBox::SaveAll << QMessageBox::Save <<QMessageBox::Retry << QMessageBox::Ignore
- << QMessageBox::Help << QMessageBox::RestoreDefaults << QMessageBox::Reset << QMessageBox::Open
- << QMessageBox::Cancel << QMessageBox::Close << QMessageBox::Abort << QMessageBox::Discard
- << QMessageBox::No << QMessageBox::NoToAll;
- if ( m_defaultAction == Reject ) {
- //if we want to reject everything, we need the lowest button
- //for example if Cancel existing it could use Cancel, but if Close existing
- //it will use Close
- m_buttonOrder = reversed( m_buttonOrder );
- }
-}
-
-QMessageBox::StandardButton MessageBoxHandler::autoReply( QMessageBox::StandardButtons buttons ) const {
- if ( buttons == QMessageBox::NoButton )
- return QMessageBox::NoButton;
- foreach (const QMessageBox::StandardButton& currentButton, m_buttonOrder)
- if ( (buttons & currentButton) != 0 )
- return currentButton;
- Q_ASSERT( !"the list must have all possible buttons" );
- return QMessageBox::NoButton;
-}
-
-QWidget* MessageBoxHandler::currentBestSuitParent()
-{
- if (QApplication::type() == QApplication::Tty) {
- Q_ASSERT_X(false, Q_FUNC_INFO, "We can't find a parent widget if we are a console application.");
- return 0;
+ << QMessageBox::SaveAll << QMessageBox::Save <<QMessageBox::Retry << QMessageBox::Ignore
+ << QMessageBox::Help << QMessageBox::RestoreDefaults << QMessageBox::Reset << QMessageBox::Open
+ << QMessageBox::Cancel << QMessageBox::Close << QMessageBox::Abort << QMessageBox::Discard
+ << QMessageBox::No << QMessageBox::NoToAll;
}
- if (qApp->activeModalWidget())
- return qApp->activeModalWidget();
- return qApp->activeWindow();
+ if (m_defaultAction == Reject) {
+ // If we want to reject everything, we need the lowest button. For example, if Cancel is existing it
+ // could use Cancel, but if Close is existing it will use Close.
+ m_buttonOrder = reversed(m_buttonOrder);
+ }
}
-QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messageType, QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+void MessageBoxHandler::setAutomaticAnswer(const QString &identifier, QMessageBox::StandardButton answer)
{
- if (QApplication::type() == QApplication::Tty)
- return button;
- if ( m_automaticAnswers.contains( identifier ) )
- return m_automaticAnswers.value( identifier );
- if ( m_defaultAction == AskUser ) {
- if (!identifier.isEmpty())
- qDebug() << QString(QLatin1String("create message box with identifier: '%1'")).arg(identifier);
- switch( messageType ) {
- case criticalType:
- return QMessageBox::critical( parent, title, text, buttons, button );
- case informationType:
- return QMessageBox::information( parent, title, text, buttons, button );
- case questionType:
- return QMessageBox::question( parent, title, text, buttons, button );
- case warningType:
- return QMessageBox::warning( parent, title, text, buttons, button );
- }
- }
- else
- return autoReply( buttons );
- Q_ASSERT_X(false, Q_FUNC_INFO, "Something went realy wrong.");
- return button;
+ m_automaticAnswers.insert(identifier, answer);
}
-QMessageBox::StandardButton MessageBoxHandler::critical(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+// -- static
+
+QMessageBox::StandardButton MessageBoxHandler::critical(QWidget* parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton button)
{
return instance()->showMessageBox(criticalType, parent, identifier, title, text, buttons, button);
}
-QMessageBox::StandardButton MessageBoxHandler::information(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+QMessageBox::StandardButton MessageBoxHandler::information(QWidget* parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton button)
{
return instance()->showMessageBox(informationType, parent, identifier, title, text, buttons, button);
}
-QMessageBox::StandardButton MessageBoxHandler::question(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+QMessageBox::StandardButton MessageBoxHandler::question(QWidget* parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton button)
{
return instance()->showMessageBox(questionType, parent, identifier, title, text, buttons, button);
}
-QMessageBox::StandardButton MessageBoxHandler::warning(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+QMessageBox::StandardButton MessageBoxHandler::warning(QWidget* parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton button)
{
return instance()->showMessageBox(warningType, parent, identifier, title, text, buttons, button);
}
-int MessageBoxHandler::critical(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+// -- invokable
+
+int MessageBoxHandler::critical(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
{
return showMessageBox(criticalType, currentBestSuitParent(), identifier, title, text, buttons, button);
}
-int MessageBoxHandler::information(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+int MessageBoxHandler::information(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
{
return showMessageBox(informationType, currentBestSuitParent(), identifier, title, text, buttons, button);
}
-int MessageBoxHandler::question(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+int MessageBoxHandler::question(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
{
return showMessageBox(questionType, currentBestSuitParent(), identifier, title, text, buttons, button);
}
-int MessageBoxHandler::warning(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+int MessageBoxHandler::warning(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
{
return showMessageBox(warningType, currentBestSuitParent(), identifier, title, text, buttons, button);
}
+
+// -- private
+
+QMessageBox::StandardButton MessageBoxHandler::autoReply(QMessageBox::StandardButtons buttons) const
+{
+ if (buttons == QMessageBox::NoButton)
+ return QMessageBox::NoButton;
+
+ foreach (const QMessageBox::StandardButton &currentButton, m_buttonOrder) {
+ if ((buttons & currentButton) != 0)
+ return currentButton;
+ }
+ Q_ASSERT(!"the list must have all possible buttons");
+ return QMessageBox::NoButton;
+}
+
+static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton defaultButton)
+{
+ QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ uint mask = QMessageBox::FirstButton;
+ while (mask <= QMessageBox::LastButton) {
+ uint sb = buttons & mask;
+ mask <<= 1;
+ if (!sb)
+ continue;
+ QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
+ // Choose the first accept role as the default
+ if (msgBox.defaultButton())
+ continue;
+ if ((defaultButton == QMessageBox::NoButton
+ && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
+ || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton))) {
+ msgBox.setDefaultButton(button);
+ }
+ }
+#if defined(Q_WS_MAC)
+ msgBox.setWindowModality(Qt::WindowModal);
+#endif
+ if (msgBox.exec() == -1)
+ return QMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messageType, QWidget *parent,
+ const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton button) const
+{
+ if (QApplication::type() == QApplication::Tty)
+ return button;
+
+ if (m_automaticAnswers.contains(identifier))
+ return m_automaticAnswers.value(identifier);
+
+ if (m_defaultAction == AskUser) {
+ if (!identifier.isEmpty())
+ qDebug() << QString(QLatin1String("create message box with identifier: '%1'")).arg(identifier);
+ switch (messageType) {
+ case criticalType:
+ return showNewMessageBox(parent, QMessageBox::Critical, title, text, buttons, button);
+ case informationType:
+ return showNewMessageBox(parent, QMessageBox::Information, title, text, buttons, button);
+ case questionType:
+ return showNewMessageBox(parent, QMessageBox::Question, title, text, buttons, button);
+ case warningType:
+ return showNewMessageBox(parent, QMessageBox::Warning, title, text, buttons, button);
+ }
+ } else {
+ return autoReply(buttons);
+ }
+
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Something went realy wrong.");
+ return button;
+}
diff --git a/installerbuilder/libinstaller/messageboxhandler.h b/installerbuilder/libinstaller/messageboxhandler.h
index 43e4ac93d..58e36afa0 100644
--- a/installerbuilder/libinstaller/messageboxhandler.h
+++ b/installerbuilder/libinstaller/messageboxhandler.h
@@ -28,16 +28,16 @@
#include <installer_global.h>
-#include <QObject>
-#include <QScriptable>
-#include <QMessageBox>
-#include <QHash>
+#include <QtCore/QHash>
+#include <QtCore/QObject>
-class QString;
+#include <QtGui/QMessageBox>
+
+#include <QtScript/QScriptable>
namespace QInstaller {
-QScriptValue registerMessageBox( QScriptEngine* scriptEngine );
+QScriptValue registerMessageBox(QScriptEngine *scriptEngine);
class INSTALLER_EXPORT MessageBoxHandler : public QObject, private QScriptable
{
@@ -49,6 +49,7 @@ public:
Accept,
Reject
};
+
enum MessageType{
criticalType,
informationType,
@@ -60,49 +61,63 @@ public:
static MessageBoxHandler* instance();
static QWidget* currentBestSuitParent();
- void setAutomaticAnswer(const QString& identifier, QMessageBox::StandardButton answer);
void setDefaultAction(DefaultAction defaultAction);
+ void setAutomaticAnswer(const QString &identifier, QMessageBox::StandardButton answer);
+
+ static QMessageBox::StandardButton critical(QWidget *parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton);
+
+ static QMessageBox::StandardButton information(QWidget *parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button=QMessageBox::NoButton);
+
+ static QMessageBox::StandardButton question(QWidget *parent, const QString &identifier,
+ const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton);
+
+ static QMessageBox::StandardButton warning(QWidget *parent, const QString &identifier,
+ const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton);
+
+ Q_INVOKABLE int critical(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+
+ Q_INVOKABLE int information(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+
+ Q_INVOKABLE int question(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+
+ Q_INVOKABLE int warning(const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
- static QMessageBox::StandardButton critical(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton );
- static QMessageBox::StandardButton information(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button=QMessageBox::NoButton );
- static QMessageBox::StandardButton question(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
- QMessageBox::StandardButton button = QMessageBox::NoButton );
- static QMessageBox::StandardButton warning(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton);
-
- Q_INVOKABLE int critical(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton) const;
- Q_INVOKABLE int information(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton) const;
- Q_INVOKABLE int question(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
- QMessageBox::StandardButton button = QMessageBox::NoButton) const;
- Q_INVOKABLE int warning(const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton) const;
-//this removes the slot from the script area
private Q_SLOTS:
- virtual void deleteLater() {QObject::deleteLater();}
+ //this removes the slot from the script area
+ virtual void deleteLater() {
+ QObject::deleteLater();
+ }
private:
- MessageBoxHandler(QObject *parent);
- QMessageBox::StandardButton showMessageBox(MessageType messageType, QWidget* parent, const QString& identifier, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons = QMessageBox::Ok,
- QMessageBox::StandardButton button = QMessageBox::NoButton) const;
- QMessageBox::StandardButton autoReply( QMessageBox::StandardButtons buttons ) const;
+ explicit MessageBoxHandler(QObject *parent);
+ QMessageBox::StandardButton autoReply(QMessageBox::StandardButtons buttons) const;
+ QMessageBox::StandardButton showMessageBox(MessageType messageType, QWidget *parent,
+ const QString &identifier, const QString &title, const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+
+private:
static MessageBoxHandler *m_instance;
- QList<QMessageBox::Button> m_buttonOrder;
+
DefaultAction m_defaultAction;
- QHash<QString,QMessageBox::StandardButton> m_automaticAnswers;
+ QList<QMessageBox::Button> m_buttonOrder;
+ QHash<QString, QMessageBox::StandardButton> m_automaticAnswers;
};
}
diff --git a/installerbuilder/libinstaller/performinstallationform.h b/installerbuilder/libinstaller/performinstallationform.h
index 35f894a46..9a17fa73a 100644
--- a/installerbuilder/libinstaller/performinstallationform.h
+++ b/installerbuilder/libinstaller/performinstallationform.h
@@ -30,11 +30,13 @@
class LazyPlainTextEdit;
+QT_BEGIN_NAMESPACE
class QWidget;
class QPushButton;
class QProgressBar;
class QLabel;
class QTimer;
+QT_END_NAMESPACE
namespace QInstaller {
diff --git a/installerbuilder/libinstaller/progresscoordinator.cpp b/installerbuilder/libinstaller/progresscoordinator.cpp
index e0cc9ff1f..a492ff30a 100644
--- a/installerbuilder/libinstaller/progresscoordinator.cpp
+++ b/installerbuilder/libinstaller/progresscoordinator.cpp
@@ -32,19 +32,20 @@
**************************************************************************/
#include "progresscoordinator.h"
-#include <QCoreApplication>
-#include <QDebug>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
using namespace QInstaller;
+QT_BEGIN_NAMESPACE
uint qHash(QPointer<QObject> key)
{
return qHash(key.data());
}
+QT_END_NAMESPACE
-
-ProgressCoordninator::ProgressCoordninator(QObject *parent) :
- QObject(parent),
+ProgressCoordninator::ProgressCoordninator(QObject *parent)
+ : QObject(parent),
m_currentCompletePercentage(0),
m_currentBasePercentage(0),
m_manualAddedPercentage(0),
@@ -52,8 +53,7 @@ ProgressCoordninator::ProgressCoordninator(QObject *parent) :
m_undoMode(false),
m_reachedPercentageBeforeUndo(0)
{
- //it have to be in the main thread
- //to be able refresh the ui with processEvents
+ // it has to be in the main thread to be able refresh the ui with processEvents
Q_ASSERT(thread() == qApp->thread());
}
@@ -64,17 +64,14 @@ ProgressCoordninator::~ProgressCoordninator()
ProgressCoordninator* ProgressCoordninator::instance()
{
static ProgressCoordninator* instance = 0;
- if (instance == 0) {
+ if (instance == 0)
instance = new ProgressCoordninator(qApp);
- }
return instance;
}
void ProgressCoordninator::reset()
{
disconnectAllSenders();
- m_senderPendingCalculatedPercentageHash.clear();
- m_senderPartProgressSizeHash.clear();
m_installationLabelText.clear();
m_currentCompletePercentage = 0;
m_currentBasePercentage = 0;
@@ -100,12 +97,15 @@ void ProgressCoordninator::registerPartProgress(QObject *sender, const char *sig
void ProgressCoordninator::partProgressChanged(double fraction)
{
if (fraction < 0 || fraction > 1) {
- qWarning() << QString(QLatin1String("The fraction is outside from possible value ")) << QString::number(fraction);
+ qWarning() << QString(QLatin1String("The fraction is outside from possible value:"))
+ << QString::number(fraction);
return;
}
+
double partProgressSize = m_senderPartProgressSizeHash.value(sender(), 0);
if (partProgressSize == 0) {
- qWarning() << QString(QLatin1String("it seems that this sender was not registered in the right way: ")) << sender();
+ qWarning() << QString(QLatin1String("It seems that this sender was not registered in the right way:"))
+ << sender();
return;
}
@@ -114,7 +114,9 @@ void ProgressCoordninator::partProgressChanged(double fraction)
double maxSize = m_reachedPercentageBeforeUndo * partProgressSize;
double pendingCalculatedPartPercentage = maxSize * fraction;
- double newCurrentCompletePercentage = m_currentBasePercentage - pendingCalculatedPartPercentage + allPendingCalculatedPartPercentages(sender()); //allPendingCalculatedPartPercentages has negative values
+ // allPendingCalculatedPartPercentages has negative values
+ double newCurrentCompletePercentage = m_currentBasePercentage - pendingCalculatedPartPercentage
+ + allPendingCalculatedPartPercentages(sender());
//we can't check this here, because some round issues can make it little bit under 0 or over 100
//Q_ASSERT(newCurrentCompletePercentage >= 0);
@@ -127,6 +129,7 @@ void ProgressCoordninator::partProgressChanged(double fraction)
qDebug() << newCurrentCompletePercentage << " is bigger then 100 - this should happen max once";
newCurrentCompletePercentage = 100;
}
+
if (qRound(m_currentCompletePercentage) < qRound(newCurrentCompletePercentage)) {
qFatal("This should not happen!");
}
@@ -144,10 +147,8 @@ void ProgressCoordninator::partProgressChanged(double fraction)
double pendingCalculatedPartPercentage = availablePercentagePoints * partProgressSize * fraction;
//double checkValue = allPendingCalculatedPartPercentages(sender());
- double newCurrentCompletePercentage = m_manualAddedPercentage +
- m_currentBasePercentage +
- pendingCalculatedPartPercentage +
- allPendingCalculatedPartPercentages(sender());
+ double newCurrentCompletePercentage = m_manualAddedPercentage + m_currentBasePercentage
+ + pendingCalculatedPartPercentage + allPendingCalculatedPartPercentages(sender());
//we can't check this here, because some round issues can make it little bit under 0 or over 100
//Q_ASSERT(newCurrentCompletePercentage >= 0);
@@ -156,10 +157,12 @@ void ProgressCoordninator::partProgressChanged(double fraction)
qDebug() << newCurrentCompletePercentage << " is smaller then 0 - this should happen max once";
newCurrentCompletePercentage = 0;
}
+
if (newCurrentCompletePercentage > 100) {
qDebug() << newCurrentCompletePercentage << " is bigger then 100 - this should happen max once";
newCurrentCompletePercentage = 100;
}
+
if (qRound(m_currentCompletePercentage) > qRound(newCurrentCompletePercentage)) {
qFatal("This should not happen!");
}
@@ -176,8 +179,8 @@ void ProgressCoordninator::partProgressChanged(double fraction)
/*!
- * Contains the installation progress percentage.
- */
+ Contains the installation progress percentage.
+*/
int ProgressCoordninator::progressInPercentage() const
{
int currentValue = qRound(m_currentCompletePercentage);
@@ -188,13 +191,15 @@ int ProgressCoordninator::progressInPercentage() const
void ProgressCoordninator::disconnectAllSenders()
{
- foreach(QPointer<QObject> sender, m_senderPartProgressSizeHash.keys()) {
+ foreach (QPointer<QObject> sender, m_senderPartProgressSizeHash.keys()) {
if (!sender.isNull()) {
bool isDisconnected = sender->disconnect(this);
Q_UNUSED(isDisconnected);
Q_ASSERT(isDisconnected);
}
}
+ m_senderPartProgressSizeHash.clear();
+ m_senderPendingCalculatedPercentageHash.clear();
}
void ProgressCoordninator::setUndoMode()
@@ -203,8 +208,6 @@ void ProgressCoordninator::setUndoMode()
m_undoMode = true;
disconnectAllSenders();
- m_senderPendingCalculatedPercentageHash.clear();
-
m_reachedPercentageBeforeUndo = progressInPercentage();
m_currentBasePercentage = m_reachedPercentageBeforeUndo;
}
@@ -216,7 +219,11 @@ void ProgressCoordninator::addManualPercentagePoints(int value)
//we don't do other things in the undomode, maybe later if the last percentage point comes to early
return;
}
+
m_currentCompletePercentage = m_currentCompletePercentage + value;
+ if (m_currentCompletePercentage > 100.0)
+ m_currentCompletePercentage = 100.0;
+
qApp->processEvents(); //makes the result available in the ui
}
@@ -233,8 +240,8 @@ void ProgressCoordninator::setLabelText(const QString &text)
}
/*!
- * Contains the installation progress label text.
- */
+ Contains the installation progress label text.
+*/
QString ProgressCoordninator::labelText() const
{
return m_installationLabelText;
@@ -255,12 +262,10 @@ void ProgressCoordninator::emitLabelAndDetailTextChanged(const QString &text)
double ProgressCoordninator::allPendingCalculatedPartPercentages(QObject *excludeKeyObject)
{
double result = 0;
-
QHash<QPointer<QObject>, double>::iterator it = m_senderPendingCalculatedPercentageHash.begin();
- while ( it != m_senderPendingCalculatedPercentageHash.end() ) {
- if (it.key() != excludeKeyObject) {
- result = result + it.value();
- }
+ while (it != m_senderPendingCalculatedPercentageHash.end()) {
+ if (it.key() != excludeKeyObject)
+ result += it.value();
it++;
}
return result;
diff --git a/installerbuilder/libinstaller/progresscoordinator.h b/installerbuilder/libinstaller/progresscoordinator.h
index 89c7b925a..904c17853 100644
--- a/installerbuilder/libinstaller/progresscoordinator.h
+++ b/installerbuilder/libinstaller/progresscoordinator.h
@@ -26,43 +26,50 @@
#ifndef PROGRESSCOORDNINATOR_H
#define PROGRESSCOORDNINATOR_H
-#include <QObject>
-#include <QHash>
-#include <QPointer>
+#include <QtCore/QHash>
+#include <QtCore/QObject>
+#include <QtCore/QPointer>
namespace QInstaller {
class ProgressCoordninator : public QObject
{
Q_OBJECT
+
public:
static ProgressCoordninator* instance();
~ProgressCoordninator();
void registerPartProgress(QObject *sender, const char *signal, double partProgressSize);
-signals:
- void detailTextChanged(const QString &text);
- void detailTextResetNeeded();
public slots:
void reset();
+ void setUndoMode();
+
+ QString labelText() const;
+ void setLabelText(const QString &text);
+
int progressInPercentage() const;
+ void partProgressChanged(double fraction);
- void setUndoMode();
void addManualPercentagePoints(int value);
void addReservePercentagePoints(int value);
- void setLabelText(const QString &text);
- QString labelText() const;
+
void emitDetailTextChanged(const QString &text);
void emitLabelAndDetailTextChanged(const QString &text);
- void partProgressChanged(double fraction);
+
+signals:
+ void detailTextChanged(const QString &text);
+ void detailTextResetNeeded();
protected:
explicit ProgressCoordninator(QObject *parent);
+
private:
double allPendingCalculatedPartPercentages(QObject *excludeKeyObject = 0);
void disconnectAllSenders();
+private:
QHash<QPointer<QObject>, double> m_senderPendingCalculatedPercentageHash;
QHash<QPointer<QObject>, double> m_senderPartProgressSizeHash;
QString m_installationLabelText;
diff --git a/installerbuilder/libinstaller/qinstaller.cpp b/installerbuilder/libinstaller/qinstaller.cpp
index 0137b50dd..7b396d435 100644
--- a/installerbuilder/libinstaller/qinstaller.cpp
+++ b/installerbuilder/libinstaller/qinstaller.cpp
@@ -31,67 +31,31 @@
**
**************************************************************************/
#include "qinstaller.h"
-#include "qinstallergui.h"
-#include "qinstallerglobal.h"
-#include "qinstallercomponent.h"
+
+#include "adminauthorization.h"
+#include "common/binaryformat.h"
+#include "common/errors.h"
+#include "common/installersettings.h"
+#include "common/utils.h"
#include "downloadarchivesjob.h"
+#include "fsengineclient.h"
#include "getrepositoriesmetainfojob.h"
-#include "adminauthorization.h"
#include "messageboxhandler.h"
#include "progresscoordinator.h"
+#include "qinstaller_p.h"
+#include "qinstallercomponent.h"
+#include "qinstallerglobal.h"
+#include "qprocesswrapper.h"
+#include "qsettingswrapper.h"
-#include "common/installersettings.h"
-#include "common/binaryformat.h"
-#include "common/utils.h"
-
-#include "fsengineclient.h"
-#include "fsengineserver.h"
-
-#include <QtCore/QBuffer>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDateTime>
-#include <QtCore/QDir>
-#include <QtCore/QDirIterator>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtCore/QHash>
-#include <QtCore/QLocale>
-#include <QtCore/QPointer>
-#include <QtCore/QProcess>
-#include <QtCore/QResource>
-#include <QtCore/QSettings>
-#include <QtCore/QVector>
#include <QtCore/QTemporaryFile>
-#include <QtCore/QTranslator>
-#include <QtCore/QUrl>
-#include <QtCore/QThread>
-#include <QtCore/QSet>
+
#include <QtGui/QDesktopServices>
-#include <QtGui/QMessageBox>
-#include <QtUiTools/QUiLoader>
+
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptContext>
-#include <QtScript/QScriptContextInfo>
-#include <QFuture>
-#include <QFutureWatcher>
-#include <QtConcurrentRun>
-
-#include <KDUpdater/KDUpdater>
-#include <KDUpdater/Application>
-#include <KDUpdater/PackagesInfo>
-#include <KDToolsCore/KDSaveFile>
#include <KDToolsCore/KDSysInfo>
-#include <KDToolsCore/KDSelfRestarter>
-
-#include "common/errors.h"
-#include "common/fileutils.h"
-
-#include <cassert>
-#include <cerrno>
-#include <functional>
-#include <memory>
-#include <algorithm>
#ifdef Q_OS_WIN
#include "qt_windows.h"
@@ -99,46 +63,8 @@
using namespace QInstaller;
-namespace {
- enum OperationType {
- Backup,
- Perform,
- Undo
- };
-
- static bool runOperation(KDUpdater::UpdateOperation *op, OperationType type) {
- switch (type)
- {
- case(Backup):
- op->backup();
- return true;
- case (Perform):
- return op->performOperation();
- case (Undo) :
- return op->undoOperation();
- }
- Q_ASSERT(!"unexpected operation type");
- return false;
- }
-
- template <typename T>
- void letTheUiRunTillFinished(const QFuture<T>& f) {
- QFutureWatcher<T> futureWatcher;
- futureWatcher.setFuture(f);
- QEventLoop loop;
- loop.connect(&futureWatcher, SIGNAL(finished()), SLOT(quit()), Qt::QueuedConnection);
- if (!f.isFinished())
- loop.exec();
- }
-
-}
-
-static bool performOperationThreaded(KDUpdater::UpdateOperation *op, OperationType type=Perform)
-{
- QFuture<bool> future = QtConcurrent::run(runOperation, op, type);
- letTheUiRunTillFinished(future);
- return future.result();
-}
+static QFont s_virtualComponentsFont;
+static bool s_virtualComponentsVisible = false;
static QScriptValue checkArguments(QScriptContext* context, int amin, int amax)
{
@@ -154,44 +80,6 @@ static QScriptValue checkArguments(QScriptContext* context, int amin, int amax)
return QScriptValue();
}
-#ifdef Q_WS_WIN
-static void deferredRename(const QString& oldName, const QString& newName, bool restart = false)
-{
- QString batchfile;
-
- QStringList arguments;
- arguments << QDir::toNativeSeparators(batchfile)
- << QDir::toNativeSeparators(oldName)
- << QDir::toNativeSeparators(QFileInfo(oldName).dir().absoluteFilePath(newName));
-
- {
- QTemporaryFile f(QDir::temp().absoluteFilePath(QLatin1String("deferredrenameXXXXXX.vbs")));
- openForWrite(&f, f.fileName());
- f.setAutoRemove(false);
-
- batchfile = f.fileName();
-
- QTextStream batch(&f);
- batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
- batch << "Set tmp = WScript.CreateObject(\"WScript.Shell\")\n";
- batch << QString::fromLatin1("file = \"%1\"\n").arg(arguments[2]);
- batch << "on error resume next\n";
-
- batch << "while fso.FileExists(file)\n";
- batch << " fso.DeleteFile(file)\n";
- batch << " WScript.Sleep(1000)\n";
- batch << "wend\n";
- batch << QString::fromLatin1("fso.MoveFile \"%1\", file\n").arg(arguments[1]);
- if (restart)
- batch << QString::fromLatin1("tmp.exec \"%1 --updater\"\n").arg(arguments[2]);
- batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
- }
-
- QProcess::startDetached(QLatin1String("cscript"), QStringList() << QLatin1String("//Nologo")
- << QDir::toNativeSeparators(batchfile));
-}
-#endif // Q_WS_WIN
-
/*!
Appends \a comp preceded by its dependencies to \a components. Makes sure components contains
every component only once.
@@ -203,15 +91,56 @@ static void appendComponentAndMissingDependencies(QList<Component*>& components,
return;
const QList<Component*> deps = comp->installer()->missingDependencies(comp);
- for (QList<Component*>::const_iterator it = deps.begin(); it != deps.end(); ++it)
- appendComponentAndMissingDependencies(components, *it);
+ foreach (Component *component, deps)
+ appendComponentAndMissingDependencies(components, component);
+
if (!components.contains(comp))
components.push_back(comp);
}
+static bool componentMatches(const Component *component, const QString &name,
+ const QString& version = QString())
+{
+ if (name.isEmpty() || component->name() != name)
+ return false;
+
+ if (version.isEmpty())
+ return true;
+
+ return Installer::versionMatches(component->value(QLatin1String("Version")), version);
+}
+
+Component* Installer::subComponentByName(const QInstaller::Installer *installer, const QString &name,
+ const QString &version, Component *check)
+{
+ if (name.isEmpty())
+ return 0;
+
+ if (check != 0 && componentMatches(check, name, version))
+ return check;
+
+ if (installer->runMode() == AllMode) {
+ const QList<Component*> rootComponents = check == 0 ? installer->components(false, AllMode)
+ : check->childComponents(false, AllMode);
+ foreach (QInstaller::Component* component, rootComponents) {
+ Component* const result = subComponentByName(installer, name, version, component);
+ if (result != 0)
+ return result;
+ }
+ } else {
+ const QList<Component*> updaterComponents = installer->components(false, UpdaterMode)
+ + installer->d->m_updaterComponentsDeps;
+ foreach (QInstaller::Component *component, updaterComponents) {
+ if (componentMatches(component, name, version))
+ return component;
+ }
+ }
+ return 0;
+}
+
/*!
- Scriptable version of Installer::componentByName(QString).
- \sa Installer::componentByName
+ Scriptable version of Installer::componentByName(QString).
+ \sa Installer::componentByName
*/
QScriptValue QInstaller::qInstallerComponentByName(QScriptContext* context, QScriptEngine* engine)
{
@@ -269,10 +198,10 @@ QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine/*, const
//if (!context.isEmpty())
// errorString.prepend(context + QLatin1String(": "));
- //usually the linenumber is in the backtrace
+ //usually the line number is in the backtrace
errorString = errorString.arg(/*QString::number(scriptEngine->uncaughtExceptionLineNumber()),*/
- scriptEngine->uncaughtException().toString(),
- scriptEngine->uncaughtExceptionBacktrace().join(QLatin1String("\n")));
+ scriptEngine->uncaughtException().toString(), scriptEngine->uncaughtExceptionBacktrace()
+ .join(QLatin1String("\n")));
return errorString;
}
@@ -325,216 +254,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
*/
-/*!
- Initializes the created FSEngineClientHandler instance \a handler.
- \internal
- */
-static void initEngineHandler(FSEngineClientHandler* handler)
-{
-#ifdef FSENGINE_TCP
- const int port = 30000 + qrand() % 1000;
- handler->init(port);
- handler->setStartServerCommand(qApp->applicationFilePath(), QStringList()
- << QLatin1String("--startserver") << QString::number(port) << handler->authorizationKey(),
- true);
-#else
- const QString name = QInstaller::generateTemporaryFileName();
- handler->init(name);
- handler->setStartServerCommand(qApp->applicationFilePath(), QStringList()
- << QLatin1String("--startserver") << name << handler->authorizationKey(), true);
-#endif
-}
-
-
-
-/*!
- Creates and initializes a FSEngineClientHandler -> makes us get admin rights for QFile
- operations.
- \internal
- */
-static FSEngineClientHandler* createEngineClientHandler()
-{
- static FSEngineClientHandler* clientHandlerInstance = 0;
- if (clientHandlerInstance == 0)
- {
- clientHandlerInstance = new FSEngineClientHandler;
- initEngineHandler(clientHandlerInstance);
- }
- return clientHandlerInstance;
-}
-
-
-// -- Installer::Private
-
-
-class QInstaller::Installer::Private : public QObject
-{
- Q_OBJECT
-
-private:
- Installer* const q;
-
-public:
- //used by operation runner to get a fake installer,
- //can be removed if installerbase can do what operation runner does
- Private() : q(0), engineClientHandler(0) {}
-
- explicit Private(Installer *q, qint64 magicmaker,
- QVector<KDUpdater::UpdateOperation*> performedOperations);
- ~Private();
-
- void initialize();
-
- bool statusCanceledOrFailed() const;
- void setStatus(Installer::Status);
-
- void writeUninstaller(QVector<KDUpdater::UpdateOperation*> performedOperations);
- QString targetDir() const { return q->value(QLatin1String("TargetDir")); }
-
- QString configurationFileName() const {
- return q->value(QLatin1String("TargetConfigurationFile"),
- QString::fromLatin1("components.xml"));
- }
-
- QString componentsXmlPath() const
- {
- return QDir::toNativeSeparators(QDir(QDir::cleanPath(targetDir()))
- .absoluteFilePath(configurationFileName()));
- }
-
- QString localComponentsXmlPath() const
- {
- const QString &appDirPath = QCoreApplication::applicationDirPath();
- if (QFileInfo(appDirPath + QLatin1String("/../..")).isBundle()) {
- return QDir::toNativeSeparators(QFileInfo(QDir::cleanPath(appDirPath
- + QLatin1String("/../../../") + configurationFileName())).absoluteFilePath());
- }
- return componentsXmlPath();
- }
-
- void runInstaller();
- void runUninstaller();
- void runPackageUpdater();
- void deleteUninstaller();
- QString uninstallerName() const;
- QString replaceVariables(const QString &str) const;
- QByteArray replaceVariables(const QByteArray &str) const;
- QString registerPath() const;
- void registerInstaller();
- void unregisterInstaller();
- QString installerBinaryPath() const;
- bool isInstaller() const;
- bool isUninstaller() const;
- bool isPackageManager() const;
- Installer *installer() const { return q; }
- KDUpdater::UpdateOperation* createOwnedOperation(const QString& type);
- void readUninstallerIniFile(const QString& targetDir);
- void stopProcessesForUpdates(const QList<Component*>& components);
- int countProgressOperations(const QList<Component*>& components);
- int countProgressOperations(const QList<KDUpdater::UpdateOperation*>& operations);
- void connectOperationToInstaller(KDUpdater::UpdateOperation* const operation,
- double progressOperationPartSize);
- void registerPathesForUninstallation(const QList<QPair<QString, bool> > &pathesForUninstallation,
- const QString& componentName);
-
- void addPerformed(KDUpdater::UpdateOperation* op) {
- m_performedOperationsCurrentSession.push_back(op);
- }
-
- void commitSessionOperations() {
- m_performedOperationsOld += m_performedOperationsCurrentSession;
- m_performedOperationsCurrentSession.clear();
- }
-
-signals:
- void installationStarted();
- void installationFinished();
- void uninstallationStarted();
- void uninstallationFinished();
-
-public:
- TempDirDeleter tempDirDeleter;
-
- FSEngineClientHandler* const engineClientHandler;
-
- QHash<QString, QString> m_vars;
- QHash<QString, bool> m_sharedFlags;
- Installer::Status m_status;
-
- bool packageManagingMode;
- bool m_completeUninstall;
-
- qint64 m_firstComponentStart;
- qint64 m_componentsCount;
- qint64 m_componentOffsetTableStart;
-
- qint64 m_firstComponentDictStart;
- qint64 m_componentsDictCount;
- qint64 m_componentDictOffsetTableStart;
-
- qint64 m_globalDictOffset;
- qint64 m_magicInstallerMarker;
-
- KDUpdater::Application * m_app;
-
- //this is a Hack, we don't need this in the refactor branch
- QList< QPointer<QInstaller::Component> > componentDeleteList;
-
- // Owned. Indexed by component name
- QList<Component*> m_rootComponents;
- QHash<QString, Component*> m_componentHash;
-
- QList<Component*> m_updaterComponents;
- QList<Component*> m_packageManagerComponents;
-
- //a hack to get the will be replaced components extra
- QList<QInstaller::Component*> willBeReplacedComponents;
-
- QList<KDUpdater::UpdateOperation*> ownedOperations;
- QVector<KDUpdater::UpdateOperation*> m_performedOperationsOld;
- QVector<KDUpdater::UpdateOperation*> m_performedOperationsCurrentSession;
- InstallerSettings m_settings;
- QString installerBaseBinaryUnreplaced;
- bool linearComponentList;
- bool m_launchedAsRoot;
- int m_silentRetries;
- bool m_forceRestart;
- bool m_needToWriteUninstaller;
- bool m_testChecksum;
-};
-
-Installer::Private::Private(Installer *q, qint64 magicmaker,
- QVector<KDUpdater::UpdateOperation*> performedOperations)
- : q(q),
- engineClientHandler(createEngineClientHandler()),
- m_status(Installer::InstallerUnfinished),
- packageManagingMode(false),
- m_completeUninstall(false),
- m_magicInstallerMarker(magicmaker),//? magicmaker : MagicInstallerMarker),
- m_performedOperationsOld(performedOperations),
- linearComponentList(false),
- m_launchedAsRoot(AdminAuthorization::hasAdminRights()),
- m_silentRetries(3),
- m_forceRestart (false),
- m_needToWriteUninstaller(false),
- m_testChecksum(false)
-{
- connect(this, SIGNAL(installationStarted()), q, SIGNAL(installationStarted()));
- connect(this, SIGNAL(installationFinished()), q, SIGNAL(installationFinished()));
- connect(this, SIGNAL(uninstallationStarted()), q, SIGNAL(uninstallationStarted()));
- connect(this, SIGNAL(uninstallationFinished()), q, SIGNAL(uninstallationFinished()));
- verbose() << "has admin rights ? : " << engineClientHandler->isActive() << std::endl;
-}
-
-Installer::Private::~Private()
-{
- qDeleteAll(componentDeleteList);
- componentDeleteList.clear();
-
- qDeleteAll(m_performedOperationsOld);
- qDeleteAll(m_performedOperationsCurrentSession);
-}
-
KDUpdater::Application& Installer::updaterApplication() const
{
return *d->m_app;
@@ -548,10 +267,8 @@ void Installer::setUpdaterApplication(KDUpdater::Application *app)
void Installer::writeUninstaller()
{
if (d->m_needToWriteUninstaller) {
- bool error = false;
- QString errorMsg;
try {
- d->writeUninstaller(d->m_performedOperationsOld + d->m_performedOperationsCurrentSession);
+ d->writeUninstaller(d->m_performedOperationsOld + d->m_performedOperationsCurrentSession);
bool gainedAdminRights = false;
QTemporaryFile tempAdminFile(d->targetDir()
@@ -564,14 +281,9 @@ void Installer::writeUninstaller()
if (gainedAdminRights)
dropAdminRights();
d->m_needToWriteUninstaller = false;
- } catch (const Error& e) {
- error = true;
- errorMsg = e.message();
- }
-
- if (error) {
+ } catch (const Error &error) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("WriteError"), tr("Error writing Uninstaller"), errorMsg,
+ QLatin1String("WriteError"), tr("Error writing Uninstaller"), error.message(),
QMessageBox::Ok, QMessageBox::Ok);
}
}
@@ -581,732 +293,20 @@ void Installer::reset(const QHash<QString, QString> &params)
{
d->m_completeUninstall = false;
d->m_forceRestart = false;
- d->m_status = Installer::InstallerUnfinished;
- d->installerBaseBinaryUnreplaced.clear();
+ d->m_status = Installer::Unfinished;
+ d->m_installerBaseBinaryUnreplaced.clear();
d->m_vars.clear();
d->m_vars = params;
d->initialize();
}
-void Installer::Private::initialize()
-{
- try {
- m_settings = InstallerSettings::fromFileAndPrefix(
- QLatin1String(":/metadata/installer-config/config.xml"),
- QLatin1String(":/metadata/installer-config/"));
- } catch (const Error &e) {
- qCritical("Could not parse Config: %s", qPrintable(e.message()));
- //TODO try better error handling
- return;
- }
-
- // first set some common variables that may used e.g. as placeholder
- // in some of the settings variables or in a script or...
- m_vars.insert(QLatin1String("rootDir"), QDir::rootPath());
- m_vars.insert(QLatin1String("homeDir"), QDir::homePath());
-
-#ifdef Q_WS_WIN
- m_vars.insert(QLatin1String("os"), QLatin1String("win"));
-#elif defined(Q_WS_MAC)
- m_vars.insert(QLatin1String("os"), QLatin1String("mac"));
-#elif defined(Q_WS_X11)
- m_vars.insert(QLatin1String("os"), QLatin1String("x11"));
-#elif defined(Q_WS_QWS)
- m_vars.insert(QLatin1String("os"), QLatin1String("Qtopia"));
-#else
- //TODO add more platforms as needed...
-#endif
-
- // fill the variables defined in the settings
- m_vars.insert(QLatin1String("ProductName"), m_settings.applicationName());
- m_vars.insert(QLatin1String("ProductVersion"), m_settings.applicationVersion());
- m_vars.insert(QLatin1String("Title"), m_settings.title());
- m_vars.insert(QLatin1String("MaintenanceTitle"), m_settings.maintenanceTitle());
- m_vars.insert(QLatin1String("Publisher"), m_settings.publisher());
- m_vars.insert(QLatin1String("Url"), m_settings.url());
- m_vars.insert(QLatin1String("StartMenuDir"), m_settings.startMenuDir());
-
- m_vars.insert(QLatin1String("LogoPixmap"), m_settings.logo());
- m_vars.insert(QLatin1String("LogoSmallPixmap"), m_settings.logoSmall());
- m_vars.insert(QLatin1String("WatermarkPixmap"), m_settings.watermark());
-
- m_vars.insert(QLatin1String("TargetConfigurationFile"), m_settings.configurationFileName());
- m_vars.insert(QLatin1String("RunProgram"), replaceVariables(m_settings.runProgram()));
- const QString desc = m_settings.runProgramDescription();
- if (!desc.isEmpty())
- m_vars.insert(QLatin1String("RunProgramDescription"), desc);
-#ifdef Q_WS_X11
- if (m_launchedAsRoot)
- m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.adminTargetDir()));
- else
-#endif
- m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.targetDir()));
- m_vars.insert(QLatin1String("RemoveTargetDir"), replaceVariables(m_settings.removeTargetDir()));
-
- QSettings creatorSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"),
- QLatin1String("QtCreator"));
- QFileInfo info(creatorSettings.fileName());
- if (info.exists())
- m_vars.insert(QLatin1String("QtCreatorSettingsFile"), info.absoluteFilePath());
-
- if (!q->isInstaller()) {
-#ifdef Q_WS_MAC
- readUninstallerIniFile(QCoreApplication::applicationDirPath() + QLatin1String("/../../.."));
-#else
- readUninstallerIniFile(QCoreApplication::applicationDirPath());
-#endif
- }
-
- foreach (KDUpdater::UpdateOperation* currentOperation, m_performedOperationsOld) {
- currentOperation->setValue(QLatin1String("installer"), QVariant::fromValue(q));
- }
-
- connect(this, SIGNAL(installationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
- connect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
-}
-
/*!
- * Sets the uninstallation to be \a complete. If \a complete is false, only components deselected
- * by the user will be uninstalled.
- * This option applies only on uninstallation.
+ Sets the uninstallation to be \a complete. If \a complete is false, only components deselected
+ by the user will be uninstalled. This option applies only on uninstallation.
*/
void Installer::setCompleteUninstallation(bool complete)
{
d->m_completeUninstall = complete;
- d->packageManagingMode = !d->m_completeUninstall;
-}
-
-QString Installer::Private::installerBinaryPath() const
-{
- return qApp->applicationFilePath();
-}
-
-bool Installer::Private::isInstaller() const
-{
- return m_magicInstallerMarker == MagicInstallerMarker;
-}
-
-bool Installer::Private::isUninstaller() const
-{
- return m_magicInstallerMarker == MagicUninstallerMarker && !packageManagingMode;
-}
-
-bool Installer::Private::isPackageManager() const
-{
- return m_magicInstallerMarker == MagicUninstallerMarker && packageManagingMode;
-}
-
-bool Installer::Private::statusCanceledOrFailed() const
-{
- return m_status == Installer::InstallerCanceledByUser
- || m_status == Installer::InstallerFailed;
-}
-
-void Installer::Private::setStatus(Installer::Status status)
-{
- if (m_status != status) {
- m_status = status;
- emit q->statusChanged(m_status);
- }
-}
-
-QString Installer::Private::replaceVariables(const QString &str) const
-{
- static const QChar at = QLatin1Char('@');
- QString res;
- int pos = 0;
- while (true) {
- const int pos1 = str.indexOf(at, pos);
- if (pos1 == -1)
- break;
- const int pos2 = str.indexOf(at, pos1 + 1);
- if (pos2 == -1)
- break;
- res += str.mid(pos, pos1 - pos);
- const QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
- res += q->value(name);
- pos = pos2 + 1;
- }
- res += str.mid(pos);
- return res;
-}
-
-QByteArray Installer::Private::replaceVariables(const QByteArray &ba) const
-{
- static const QChar at = QLatin1Char('@');
- QByteArray res;
- int pos = 0;
- while (true) {
- const int pos1 = ba.indexOf(at, pos);
- if (pos1 == -1)
- break;
- const int pos2 = ba.indexOf(at, pos1 + 1);
- if (pos2 == -1)
- break;
- res += ba.mid(pos, pos1 - pos);
- const QString name = QString::fromLocal8Bit(ba.mid(pos1 + 1, pos2 - pos1 - 1));
- res += q->value(name).toLocal8Bit();
- pos = pos2 + 1;
- }
- res += ba.mid(pos);
- return res;
-}
-
-/*!
- Creates an update operation owned by the installer, not by any component.
- \internal
- */
-KDUpdater::UpdateOperation* Installer::Private::createOwnedOperation(const QString &type)
-{
- KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create(type);
- ownedOperations.push_back(op);
- return op;
-}
-
-QString Installer::Private::uninstallerName() const
-{
- QString filename = m_settings.uninstallerName();
-#if defined(Q_WS_MAC)
- if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())
- filename += QLatin1String(".app/Contents/MacOS/") + filename;
-#elif defined(Q_OS_WIN)
- filename += QLatin1String(".exe");
-#endif
- return QString::fromLatin1("%1/%2").arg(targetDir()).arg(filename);
-}
-
-void Installer::Private::readUninstallerIniFile(const QString &targetDir)
-{
- const QString iniPath = targetDir + QLatin1Char('/') + m_settings.uninstallerIniFile();
- QSettings cfg(iniPath, QSettings::IniFormat);
- const QVariantHash vars = cfg.value(QLatin1String("Variables")).toHash();
- QHash<QString, QVariant>::ConstIterator it = vars.constBegin();
- while (it != vars.constEnd()) {
- m_vars.insert(it.key(), it.value().toString());
- ++it;
- }
-}
-
-/*!
- Copied from QInstaller with some adjustments
- Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive.
-*/
-static bool isProcessRunning(const QString& name, const QList<KDSysInfo::ProcessInfo> &processes)
-{
- QList<KDSysInfo::ProcessInfo>::const_iterator it;
- for (it = processes.constBegin(); it != processes.constEnd(); ++it) {
- if (it->name.isEmpty())
- continue;
-
-#ifndef Q_WS_WIN
- if (it->name == name)
- return true;
- const QFileInfo fi(it->name);
- if (fi.fileName() == name || fi.baseName() == name)
- return true;
-#else
- if (it->name.toLower() == name.toLower())
- return true;
- if (it->name.toLower() == QDir::toNativeSeparators(name.toLower()))
- return true;
- const QFileInfo fi(it->name);
- if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower())
- return true;
-#endif
- }
- return false;
-}
-
-static QStringList checkRunningProcessesFromList(const QStringList &processList)
-{
- const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
- QStringList stillRunningProcesses;
- foreach (const QString &process, processList) {
- if (!process.isEmpty() && isProcessRunning(process, allProcesses)) {
- stillRunningProcesses.append(process);
- }
- }
- return stillRunningProcesses;
-}
-
-void Installer::Private::stopProcessesForUpdates(const QList<Component*> &components)
-{
- QStringList processList;
- foreach (const Component* const i, components)
- processList << q->replaceVariables(i->stopProcessForUpdateRequests());
-
- qSort(processList);
- processList.erase(std::unique(processList.begin(), processList.end()), processList.end());
- if (processList.isEmpty())
- return;
-
- while (true) {
- const QStringList processes = checkRunningProcessesFromList(processList);
- if (processes.isEmpty())
- return;
-
- const QMessageBox::StandardButton button =
- MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("stopProcessesForUpdates"), tr("Stop Processes"), tr("These processes "
- "should be stopped to continue:\n\n%1").arg(QDir::toNativeSeparators(processes
- .join(QLatin1String("\n")))), QMessageBox::Retry | QMessageBox::Ignore
- | QMessageBox::Cancel, QMessageBox::Retry);
- if (button == QMessageBox::Ignore)
- return;
- if (button == QMessageBox::Cancel) {
- q->setCanceled();
- throw Error(tr("Installation canceled by user"));
- }
- }
-}
-
-int Installer::Private::countProgressOperations(const QList<KDUpdater::UpdateOperation*> &operations)
-{
- int operationCount = 0;
- QList<KDUpdater::UpdateOperation*>::const_iterator oIt;
- for (oIt = operations.constBegin(); oIt != operations.constEnd(); oIt++) {
- KDUpdater::UpdateOperation* const operation = *oIt;
- QObject* const operationObject = dynamic_cast< QObject* >(operation);
- if (operationObject != 0) {
- const QMetaObject* const mo = operationObject->metaObject();
- if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1)
- operationCount++;
- }
- }
- return operationCount;
-}
-
-int Installer::Private::countProgressOperations(const QList<Component*> &components)
-{
- int operationCount = 0;
- for (QList<Component*>::const_iterator It = components.begin(); It != components.end(); ++It)
- operationCount = operationCount + countProgressOperations((*It)->operations());
-
- return operationCount;
-}
-
-void Installer::Private::connectOperationToInstaller(KDUpdater::UpdateOperation* const operation,
- double progressOperationPartSize)
-{
- Q_ASSERT(progressOperationPartSize);
- QObject* const operationObject = dynamic_cast< QObject* >(operation);
- if (operationObject != 0) {
- const QMetaObject* const mo = operationObject->metaObject();
- if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) {
- connect(operationObject, SIGNAL(outputTextChanged(QString)),
- ProgressCoordninator::instance(), SLOT(emitDetailTextChanged(QString)));
- }
-
- if (mo->indexOfSlot(QMetaObject::normalizedSignature("cancelOperation()")) > -1)
- connect(q, SIGNAL(installationInterrupted()), operationObject, SLOT(cancelOperation()));
-
- if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1) {
- ProgressCoordninator::instance()->registerPartProgress(operationObject,
- SIGNAL(progressChanged(double)), progressOperationPartSize);
- }
- }
-}
-
-/*!
- This creates fake operations which remove stuff which was registered for uninstallation afterwards
-*/
-void Installer::Private::registerPathesForUninstallation(
- const QList<QPair<QString, bool> > &pathesForUninstallation, const QString &componentName)
-{
- if (pathesForUninstallation.isEmpty())
- return;
-
- QList<QPair<QString, bool> >::const_iterator it;
- for (it = pathesForUninstallation.begin(); it != pathesForUninstallation.end(); ++it) {
- const QString path = replaceVariables(it->first);
- const bool wipe = it->second;
- const QFileInfo fi(path);
-
- // create a copy operation with the file as target -> it will get deleted on undo
- KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String(fi.isDir()
- ? "Mkdir" : "Copy"));
- if (fi.isDir()) {
- op->setValue(QLatin1String("createddir"), fi.absoluteFilePath());
- op->setValue(QLatin1String("forceremoval"), wipe ? QLatin1String("true")
- : QLatin1String("false"));
- }
- op->setArguments(fi.isDir() ? QStringList() << fi.absoluteFilePath()
- : QStringList() << QString() << fi.absoluteFilePath());
- op->setValue(QLatin1String("component"), componentName);
- addPerformed(op);
-
- // get recursive afterwards
- if (fi.isDir() && !wipe) {
- QDirIterator dirIt(path, QDir::Hidden | QDir::AllEntries | QDir::System
- | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
- while (dirIt.hasNext()) {
- dirIt.next();
- const QFileInfo fi = dirIt.fileInfo();
- if (fi.isDir()) {
- // create an mkdir operation with the dir as target -> it will get deleted on undo
- KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String("Mkdir"));
- op->setArguments(QStringList() << fi.absoluteFilePath());
- op->setValue(QLatin1String("createddir"), fi.absoluteFilePath());
- op->setValue(QLatin1String("component"), componentName);
- addPerformed(op);
- } else {
- // create a copy operation with the file as target -> it will get deleted on undo
- KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String("Copy"));
- op->setArguments(QStringList() << QString() << fi.absoluteFilePath());
- op->setValue(QLatin1String("component"), componentName);
- addPerformed(op);
- }
- }
- }
- }
-}
-
-void Installer::Private::writeUninstaller(QVector<KDUpdater::UpdateOperation*> performedOperations)
-{
- bool gainedAdminRights = false;
- QTemporaryFile tempAdminFile(targetDir() + QString::fromLatin1("/testjsfdjlkdsjflkdsjfldsjlfds")
- + QString::number(qrand() % 1000));
- if (!tempAdminFile.open() || !tempAdminFile.isWritable()) {
- q->gainAdminRights();
- gainedAdminRights = true;
- }
-
- verbose() << "QInstaller::Installer::Private::writeUninstaller uninstaller=" << uninstallerName()
- << std::endl;
-
- // create the directory containing the uninstaller (like a bundle structor, on Mac...)
- KDUpdater::UpdateOperation* op = createOwnedOperation(QLatin1String("Mkdir"));
- op->setArguments(QStringList() << QFileInfo(uninstallerName()).path());
- performOperationThreaded(op, Backup);
- performOperationThreaded(op);
- performedOperations.push_back(op);
-
- {
- // write current state (variables) to the uninstaller ini file
- const QString iniPath = targetDir() + QLatin1Char('/') + m_settings.uninstallerIniFile();
- QSettings cfg(iniPath, QSettings::IniFormat);
- QVariantHash vars;
- QHash<QString, QString>::ConstIterator it = m_vars.constBegin();
- while (it != m_vars.constEnd()) {
- const QString &key = it.key();
- if (key != QLatin1String("RunProgramDescription") && key != QLatin1String("RunProgram"))
- vars.insert(key, it.value());
- ++it;
- }
- cfg.setValue(QLatin1String("Variables"), vars);
- cfg.sync();
- if (cfg.status() != QSettings::NoError) {
- const QString reason = cfg.status() == QSettings::AccessError ? tr("Access error")
- : tr("Format error");
- throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason));
- }
- }
-
-#ifdef Q_WS_MAC
- // if it is a bundle, we need some stuff in it...
- if (isInstaller()
- && QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle()) {
- op = createOwnedOperation(QLatin1String("Copy"));
- op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
- + QLatin1String("/../PkgInfo")) << (QFileInfo(uninstallerName()).path()
- + QLatin1String("/../PkgInfo")));
- performOperationThreaded(op, Backup);
- performOperationThreaded(op);
-
- op = createOwnedOperation(QLatin1String("Copy"));
- op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
- + QLatin1String("/../Info.plist")) << (QFileInfo(uninstallerName()).path()
- + QLatin1String("/../Info.plist")));
- performOperationThreaded(op, Backup);
- performOperationThreaded(op);
-
- verbose() << "Checking for qt_menu.nib" << std::endl;
- QString sourceDirName = QCoreApplication::applicationDirPath()
- + QLatin1String("/../Resources/qt_menu.nib");
- if (QFileInfo(sourceDirName).exists()) {
- verbose() << "qt_menu.nib has been found. Isn't it great?" << std::endl;
- QString targetDirName = QFileInfo(QFileInfo(uninstallerName()).path()
- + QLatin1String("/../Resources/qt_menu.nib")).absoluteFilePath();
-
- // IFW has been built with a static Cocoa Qt. The app bundle must contain the qt_menu.nib.
- // ### use the CopyDirectory operation in 1.1
- op = createOwnedOperation(QLatin1String("Mkdir"));
- op->setArguments(QStringList() << targetDirName);
- if (!op->performOperation()) {
- verbose() << "ERROR in Mkdir operation: " << op->errorString() << std::endl;
- }
-
- QDir sourceDir(sourceDirName);
- foreach (const QString &filename, sourceDir.entryList(QDir::Files)) {
- QString src = sourceDirName + QLatin1String("/") + filename;
- QString dst = targetDirName + QLatin1String("/") + filename;
- op = createOwnedOperation(QLatin1String("Copy"));
- op->setArguments(QStringList() << src << dst);
- if (!op->performOperation())
- verbose() << "ERROR in Copy operation: copy " << src << " to " << dst << std::endl
- << "error message: " << op->errorString() << std::endl;
- }
- }
-
- // patch the Info.plist while copying it
- QFile sourcePlist(QCoreApplication::applicationDirPath() + QLatin1String("/../Info.plist"));
- openForRead(&sourcePlist, sourcePlist.fileName());
- QFile targetPlist(QFileInfo(uninstallerName()).path() + QLatin1String("/../Info.plist"));
- openForWrite(&targetPlist, targetPlist.fileName());
-
- QTextStream in(&sourcePlist);
- QTextStream out(&targetPlist);
-
- while (!in.atEnd())
- {
- QString line = in.readLine();
- line = line.replace(QLatin1String("<string>")
- + QFileInfo(QCoreApplication::applicationFilePath()).baseName()
- + QLatin1String("</string>"), QLatin1String("<string>")
- + QFileInfo(uninstallerName()).baseName() + QLatin1String("</string>"));
- out << line << endl;
- }
-
- op = createOwnedOperation(QLatin1String("Mkdir"));
- op->setArguments(QStringList() << (QFileInfo(QFileInfo(uninstallerName()).path()).path()
- + QLatin1String("/Resources")));
- performOperationThreaded(op, Backup);
- performOperationThreaded(op);
-
- const QString icon = QFileInfo(QCoreApplication::applicationFilePath()).baseName()
- + QLatin1String(".icns");
- op = createOwnedOperation(QLatin1String("Copy"));
- op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
- + QLatin1String("/../Resources/") + icon) << (QFileInfo(uninstallerName()).path()
- + QLatin1String("/../Resources/") + icon));
- performOperationThreaded(op, Backup);
- performOperationThreaded(op);
-
- // finally, copy everything within Frameworks and plugins
- if (QDir(QCoreApplication::applicationDirPath() + QLatin1String("/../Frameworks")).exists()) {
- copyDirectoryContents(QCoreApplication::applicationDirPath()
- + QLatin1String("/../Frameworks"), QFileInfo(uninstallerName()).path()
- + QLatin1String("/../Frameworks"));
- }
-
- if (QDir(QCoreApplication::applicationDirPath() + QLatin1String("/../plugins")).exists()) {
- copyDirectoryContents(QCoreApplication::applicationDirPath()
- + QLatin1String("/../plugins"), QFileInfo(uninstallerName()).path()
- + QLatin1String("/../plugins"));
- }
- }
-#endif
-
- QFile in;
- if (isInstaller() || isUninstaller() || isPackageManager())
- in.setFileName(installerBinaryPath());
- else
- in.setFileName(uninstallerName()); // we're the updater
-
- const QString installerBaseBinary = q->replaceVariables(installerBaseBinaryUnreplaced);
- if (!installerBaseBinary.isEmpty())
- verbose() << "Got a replacement installer base binary: " << installerBaseBinary << std::endl;
-
- const bool haveSeparateExec = QFile::exists(installerBaseBinary) && !installerBaseBinary.isEmpty();
- verbose() << "Need to restart after exit: " << haveSeparateExec << " "
- << qPrintable(installerBaseBinary) << std::endl;
-
-#ifdef Q_WS_WIN
- KDSaveFile out(uninstallerName() + QLatin1String(".org"));
-#else
- KDSaveFile out(uninstallerName());
-#endif
-
- try {
- ifVerbose("CREATING UNINSTALLER " << performedOperations.size());
-
- QFile* execIn = &in;
- qint64 execSize = 0;
- QFile ibbIn;
- if (haveSeparateExec) {
- ibbIn.setFileName(installerBaseBinary);
- openForRead(&ibbIn, ibbIn.fileName());
- execIn = &ibbIn;
- execSize = ibbIn.size();
- }
-
- openForRead(&in, in.fileName());
- openForWrite(&out, out.fileName());
-
- const qint64 magicCookiePos = findMagicCookie(&in);
- if (magicCookiePos < 0) {
- throw Error(QObject::tr("Can not find the magic cookie in file %1. Are you sure this "
- "is a valid installer?").arg(installerBinaryPath()));
- }
-
- if (!in.seek(magicCookiePos - 7 * sizeof(qint64))) {
- throw Error(QObject::tr("Failed to seek in file %1: %2").arg(installerBinaryPath(),
- in.errorString()));
- }
-
- qint64 resourceStart = retrieveInt64(&in);
- const qint64 resourceLength = retrieveInt64(&in);
- Q_ASSERT(resourceLength >= 0);
- const qint64 _operationsStart = retrieveInt64(&in);
- Q_UNUSED(_operationsStart);
- Q_ASSERT(_operationsStart >= 0);
- const qint64 _operationsLength = retrieveInt64(&in);
- Q_UNUSED(_operationsLength);
- Q_ASSERT(_operationsLength >= 0);
- const qint64 count = retrieveInt64(&in); // atm always "1"
- Q_ASSERT(count == 1); // we have just 1 resource atm
- const qint64 dataBlockSize = retrieveInt64(&in);
- const qint64 dataBlockStart = magicCookiePos + sizeof(qint64) - dataBlockSize;
- resourceStart += dataBlockStart;
- if (!haveSeparateExec)
- execSize = dataBlockStart;
-
- // consider size difference between old and new installerbase executable (if updated)
- const qint64 newResourceStart = execSize;
- const qint64 magicmarker = retrieveInt64(&in);
- Q_UNUSED(magicmarker);
- Q_ASSERT(magicmarker == MagicInstallerMarker || magicmarker == MagicUninstallerMarker);
-
-
-
- if (!execIn->seek(0)) {
- throw Error(QObject::tr("Failed to seek in file %1: %2").arg(execIn->fileName(),
- execIn->errorString()));
- }
- appendData(&out, execIn, execSize);
-
- // copy the first few bytes to take the executable+resources over to the uninstaller.
- if (! in.seek(resourceStart)) {
- throw Error(QObject::tr("Failed to seek in file %1: %2").arg(in.fileName(),
- in.errorString()));
- }
- Q_ASSERT(in.pos() == resourceStart && out.pos() == execSize);
-
- appendData(&out, &in, resourceLength);
- const qint64 uninstallerDataBlockStart = out.pos();
- // compared to the installer we do not have component data but details about
- // the performed operations during the installation to allow to undo them.
- const qint64 operationsStart = out.pos();
- appendInt64(&out, performedOperations.count());
- foreach (KDUpdater::UpdateOperation *op, performedOperations) {
- // the installer can't be put into XML, remove it first
- op->clearValue(QLatin1String("installer"));
-
- appendString(&out, op->name());
- appendString(&out, op->toXml().toString());
-
- // for the ui not to get blocked
- qApp->processEvents();
- }
- appendInt64(&out, performedOperations.count());
- const qint64 operationsEnd = out.pos();
-
- // we dont save any component-indexes.
- const qint64 numComponents = 0;
- appendInt64(&out, numComponents); // for the indexes
- // we dont save any components.
- const qint64 compIndexStart = out.pos();
- appendInt64(&out, numComponents); // and 2 times number of components,
- appendInt64(&out, numComponents); // one before and one after the components
- const qint64 compIndexEnd = out.pos();
-
- appendInt64Range(&out, Range<qint64>::fromStartAndEnd(compIndexStart, compIndexEnd)
- .moved(-uninstallerDataBlockStart));
- appendInt64Range(&out, Range<qint64>::fromStartAndLength(newResourceStart, resourceLength)
- .moved(-uninstallerDataBlockStart));
- appendInt64Range(&out, Range<qint64>::fromStartAndEnd(operationsStart, operationsEnd)
- .moved(-uninstallerDataBlockStart));
- appendInt64(&out, count);
- //data block size, from end of .exe to end of file
- appendInt64(&out, out.pos() + 3 * sizeof(qint64) - uninstallerDataBlockStart);
- appendInt64(&out, MagicUninstallerMarker);
- appendInt64(&out, MagicCookie);
-
- out.setPermissions(out.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther
- | QFile::ExeOther | QFile::ExeGroup | QFile::ExeUser);
-
- if (!out.commit(KDSaveFile::OverwriteExistingFile)) {
- throw Error(tr("Could not write uninstaller to %1: %2").arg(uninstallerName(),
- out.errorString()));
- }
-
- //delete the installerbase binary temporarily installed for the uninstaller update
- if (haveSeparateExec) {
- QFile tmp(installerBaseBinary);
- // Is there anything more sensible we can do with this error? I think not.
- // It's not serious enough for throwing/aborting.
- if (!tmp.remove()) {
- verbose() << "Could not remove installerbase binary (" << installerBaseBinary
- << ") after updating the uninstaller: " << tmp.errorString() << std::endl;
- }
- installerBaseBinaryUnreplaced.clear();
- }
-
-#ifdef Q_WS_WIN
- deferredRename(out.fileName(), QFileInfo(uninstallerName()).fileName(),
- haveSeparateExec && !isInstaller());
-#else
- verbose() << " preparing restart " << std::endl;
- if (haveSeparateExec && !isInstaller())
- KDSelfRestarter::setRestartOnQuit(true);
-#endif
- } catch (const Error &err) {
- setStatus(InstallerFailed);
- if (gainedAdminRights)
- q->dropAdminRights();
- m_needToWriteUninstaller = false;
- throw err;
- }
-
- if (gainedAdminRights)
- q->dropAdminRights();
-
- commitSessionOperations();
-
- m_needToWriteUninstaller = false;
-}
-
-QString Installer::Private::registerPath() const
-{
- QString productName = m_vars.value(QLatin1String("ProductName"));
- if (productName.isEmpty())
- throw Error(tr("ProductName should be set"));
-
- QString path = QLatin1String("HKEY_CURRENT_USER");
- if (m_vars.value(QLatin1String("AllUsers")) == QLatin1String("true"))
- path = QLatin1String("HKEY_LOCAL_MACHINE");
-
- return path + QLatin1String("\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\")
- + productName;
-}
-
-void Installer::Private::registerInstaller()
-{
-#ifdef Q_OS_WIN
- QSettings settings(registerPath(), QSettings::NativeFormat);
- settings.setValue(QLatin1String("DisplayName"), m_vars.value(QLatin1String("ProductName")));
- settings.setValue(QLatin1String("DisplayVersion"), m_vars.value(QLatin1String("ProductVersion")));
- const QString uninstaller = QDir::toNativeSeparators(uninstallerName());
- settings.setValue(QLatin1String("DisplayIcon"), uninstaller);
- settings.setValue(QLatin1String("Publisher"), m_vars.value(QLatin1String("Publisher")));
- settings.setValue(QLatin1String("UrlInfoAbout"), m_vars.value(QLatin1String("Url")));
- settings.setValue(QLatin1String("Comments"), m_vars.value(QLatin1String("Title")));
- settings.setValue(QLatin1String("InstallDate"), QDateTime::currentDateTime().toString());
- settings.setValue(QLatin1String("InstallLocation"), QDir::toNativeSeparators(targetDir()));
- settings.setValue(QLatin1String("UninstallString"), uninstaller);
- settings.setValue(QLatin1String("ModifyPath"), uninstaller + QLatin1String(" --manage-packages"));
- settings.setValue(QLatin1String("EstimatedSize"), QFileInfo(installerBinaryPath()).size());
- settings.setValue(QLatin1String("NoModify"), 1); // TODO: set to 0 and support modify
- settings.setValue(QLatin1String("NoRepair"), 1);
-#endif
-}
-
-void Installer::Private::unregisterInstaller()
-{
-#ifdef Q_OS_WIN
- QSettings settings(registerPath(), QSettings::NativeFormat);
- settings.remove(QString());
-#endif
}
void Installer::autoAcceptMessageBoxes()
@@ -1325,14 +325,17 @@ void Installer::setMessageBoxAutomaticAnswer(const QString &identifier, int butt
static_cast<QMessageBox::Button>(button));
}
+// TODO: figure out why we have this function at all
void Installer::installSelectedComponents()
{
- d->setStatus(InstallerRunning);
+ d->setStatus(Installer::Running);
// download
double downloadPartProgressSize = double(1)/3;
double componentsInstallPartProgressSize = double(2)/3;
// get the list of packages we need to install in proper order and do it for the updater
+
+ // TODO: why only updater mode???
const int downloadedArchivesCount = downloadNeededArchives(UpdaterMode, downloadPartProgressSize);
//if there was no download we have the whole progress for installing components
@@ -1342,7 +345,7 @@ void Installer::installSelectedComponents()
}
// get the list of packages we need to install in proper order
- const QList<Component*> components = calculateComponentOrder(UpdaterMode);
+ const QList<Component*> components = componentsToInstall(runMode());
if (!isInstaller() && !QFileInfo(installerBinaryPath()).isWritable())
gainAdminRights();
@@ -1351,30 +354,28 @@ void Installer::installSelectedComponents()
int progressOperationCount = d->countProgressOperations(components);
double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
- //TODO: devide this in undo steps and install steps (2 "for" loops) for better progress calculation
- for (QList<Component*>::const_iterator it = components.begin(); it != components.end(); ++it) {
+ // TODO: divide this in undo steps and install steps (2 "for" loops) for better progress calculation
+ foreach (Component* const currentComponent, components) {
if (d->statusCanceledOrFailed())
throw Error(tr("Installation canceled by user"));
- Component* const currentComponent = *it;
ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nRemoving the old "
"version of: %1").arg(currentComponent->name()));
- if (isUpdater() && currentComponent->removeBeforeUpdate()) {
+ if ((isUpdater() || isPackageManager()) && currentComponent->removeBeforeUpdate()) {
QString replacesAsString = currentComponent->value(QLatin1String("Replaces"));
- QStringList possibleNames(replacesAsString.split(QLatin1String(","),
- QString::SkipEmptyParts));
+ QStringList possibleNames(replacesAsString.split(QLatin1String(","), QString::SkipEmptyParts));
possibleNames.append(currentComponent->name());
+
// undo all operations done by this component upon installation
for (int i = d->m_performedOperationsOld.count() - 1; i >= 0; --i) {
- KDUpdater::UpdateOperation* const op = d->m_performedOperationsOld[i];
+ KDUpdater::UpdateOperation* const op = d->m_performedOperationsOld.at(i);
if (!possibleNames.contains(op->value(QLatin1String("component")).toString()))
continue;
- const bool becameAdmin = !d->engineClientHandler->isActive()
+ const bool becameAdmin = !d->m_FSEngineClientHandler->isActive()
&& op->value(QLatin1String("admin")).toBool() && gainAdminRights();
- performOperationThreaded(op, Undo);
+ InstallerPrivate::performOperationThreaded(op, InstallerPrivate::Undo);
if (becameAdmin)
dropAdminRights();
- d->m_performedOperationsOld.remove(i);
- delete op;
+ delete d->m_performedOperationsOld.takeAt(i);
}
foreach(const QString possilbeName, possibleNames)
d->m_app->packagesInfo()->removePackage(possilbeName);
@@ -1383,82 +384,62 @@ void Installer::installSelectedComponents()
ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(
tr("\nInstalling the new version of: %1").arg(currentComponent->name()));
installComponent(currentComponent, progressOperationSize);
- //commit all operations for this allready updated/installed component
- //so an undo during the installComponent function only undos the uncomplete installed one
+ //commit all operations for this already updated/installed component
+ //so an undo during the installComponent function only undoes the uncompleted installed one
d->commitSessionOperations();
d->m_needToWriteUninstaller = true;
}
- d->setStatus(InstallerSucceeded);
+ d->setStatus(Installer::Success);
ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nUpdate finished!"));
emit updateFinished();
}
+quint64 size(QInstaller::Component *component, const QString &value)
+{
+ if (!component->isSelected() || component->isInstalled())
+ return quint64(0);
+ return component->value(value).toLongLong();
+}
+
quint64 Installer::requiredDiskSpace() const
{
quint64 result = 0;
- QList<Component*>::const_iterator it;
- const QList<Component*> availableComponents = components(true);
- for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
- Component* const comp = *it;
- if (!comp->isSelected())
- continue;
- if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
- continue;
- result += comp->value(QLatin1String("UncompressedSize")).toLongLong();
- }
+
+ const QList<Component*> availableComponents = components(true, runMode());
+ foreach (QInstaller::Component *component, availableComponents)
+ result += size(component, QLatin1String("UncompressedSize"));
+
return result;
}
quint64 Installer::requiredTemporaryDiskSpace() const
{
quint64 result = 0;
- QList<Component*>::const_iterator it;
- const QList<Component*> availableComponents = components(true);
- for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
- Component* const comp = *it;
- if (!comp->isSelected())
- continue;
- if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
- continue;
- result += comp->value(QLatin1String("CompressedSize")).toLongLong();
- }
+
+ const QList<Component*> availableComponents = components(true, runMode());
+ foreach (QInstaller::Component *component, availableComponents)
+ result += size(component, QLatin1String("CompressedSize"));
+
return result;
}
/*!
Returns the will be downloaded archives count
*/
-int Installer::downloadNeededArchives(RunModes runMode, double partProgressSize)
+int Installer::downloadNeededArchives(RunMode runMode, double partProgressSize)
{
Q_ASSERT(partProgressSize >= 0 && partProgressSize <= 1);
- QList<Component*> neededComponents;
QList<QPair<QString, QString> > archivesToDownload;
-
- QList<Component*>::const_iterator it;
- const QList<Component*> availableComponents = components(true, runMode);
- for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
- Component* const comp = *it;
- if (!comp->isSelected(runMode))
- continue;
- if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed")
- && runMode == InstallerMode) {
- continue;
- }
- appendComponentAndMissingDependencies(neededComponents, comp);
- }
-
- for (it = neededComponents.begin(); it != neededComponents.end(); ++it) {
- Component* const comp = *it;
-
+ QList<Component*> neededComponents = componentsToInstall(runMode);
+ foreach (Component *component, neededComponents) {
// collect all archives to be downloaded
- const QStringList toDownload = comp->downloadableArchives();
- for (QStringList::const_iterator it2 = toDownload.begin(); it2 != toDownload.end(); ++it2) {
- QString versionFreeString(*it2);
+ const QStringList toDownload = component->downloadableArchives();
+ foreach (const QString &versionFreeString, toDownload) {
archivesToDownload.push_back(qMakePair(QString::fromLatin1("installer://%1/%2")
- .arg(comp->name(), versionFreeString), QString::fromLatin1("%1/%2/%3")
- .arg(comp->repositoryUrl().toString(), comp->name(), versionFreeString)));
+ .arg(component->name(), versionFreeString), QString::fromLatin1("%1/%2/%3")
+ .arg(component->repositoryUrl().toString(), component->name(), versionFreeString)));
}
}
@@ -1468,132 +449,47 @@ int Installer::downloadNeededArchives(RunModes runMode, double partProgressSize)
ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nDownloading packages..."));
// don't have it on the stack, since it keeps the temporary files
- DownloadArchivesJob* const archivesJob = new DownloadArchivesJob(d->m_settings.publicKey(), this);
- archivesJob->setArchivesToDownload(archivesToDownload);
+ DownloadArchivesJob* const archivesJob =
+ new DownloadArchivesJob(d->m_installerSettings.publicKey(), this);
archivesJob->setAutoDelete(false);
+ archivesJob->setArchivesToDownload(archivesToDownload);
+ connect(this, SIGNAL(installationInterrupted()), archivesJob, SLOT(cancel()));
connect(archivesJob, SIGNAL(outputTextChanged(QString)), ProgressCoordninator::instance(),
SLOT(emitLabelAndDetailTextChanged(QString)));
- ProgressCoordninator::instance()->registerPartProgress(archivesJob,
- SIGNAL(progressChanged(double)), partProgressSize);
- connect(this, SIGNAL(installationInterrupted()), archivesJob, SLOT(cancel()));
+
+ ProgressCoordninator::instance()->registerPartProgress(archivesJob, SIGNAL(progressChanged(double)),
+ partProgressSize);
+
archivesJob->start();
archivesJob->waitForFinished();
if (archivesJob->error() == KDJob::Canceled)
interrupt();
- else if (archivesJob->error() != DownloadArchivesJob::NoError)
+ else if (archivesJob->error() != KDJob::NoError)
throw Error(archivesJob->errorString());
+
if (d->statusCanceledOrFailed())
throw Error(tr("Installation canceled by user"));
return archivesToDownload.count();
}
-QList<Component*> Installer::calculateComponentOrder(RunModes runMode) const
-{
- return componentsToInstall(true, true, runMode);
-}
-
-void Installer::installComponent(Component* comp, double progressOperationSize)
+void Installer::installComponent(Component *component, double progressOperationSize)
{
Q_ASSERT(progressOperationSize);
- d->setStatus(InstallerRunning);
- const QList<KDUpdater::UpdateOperation*> operations = comp->operations();
-
- // show only component which are doing something, MinimumProgress is only for progress
- // calculation safeness
- if (operations.count() > 1
- || (operations.count() == 1 && operations.at(0)->name() != QLatin1String("MinimumProgress"))) {
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstalling component %1")
- .arg(comp->displayName()));
- }
-
- if (!comp->operationsCreatedSuccessfully())
- setCanceled();
-
- QList<KDUpdater::UpdateOperation*>::const_iterator op;
- for (op = operations.begin(); op != operations.end(); ++op) {
- if (d->statusCanceledOrFailed())
- throw Error(tr("Installation canceled by user"));
-
- KDUpdater::UpdateOperation* const operation = *op;
- d->connectOperationToInstaller(operation, progressOperationSize);
-
- // maybe this operations wants us to be admin...
- const bool becameAdmin = !d->engineClientHandler->isActive()
- && operation->value(QLatin1String("admin")).toBool() && gainAdminRights();
- // perform the operation
- if (becameAdmin)
- verbose() << operation->name() << " as admin: " << becameAdmin << std::endl;
-
- // allow the operation to backup stuff before performing the operation
- performOperationThreaded(operation, Backup);
-
- bool ignoreError = false;
- bool ok = performOperationThreaded(operation);
- while (!ok && !ignoreError && status() != InstallerCanceledByUser) {
- verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
- .arg(operation->name(), operation->arguments().join(QLatin1String("; ")),
- operation->errorString()) << std::endl;;
- const QMessageBox::StandardButton button =
- MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
- tr("Error during installation process(%1):\n%2").arg(comp->name(),
- operation->errorString()),
- QMessageBox::Retry | QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Retry);
-
- if (button == QMessageBox::Retry)
- ok = performOperationThreaded(operation);
- else if (button == QMessageBox::Ignore)
- ignoreError = true;
- else if (button == QMessageBox::Cancel)
- interrupt();
- }
-
- if (ok || operation->error() > KDUpdater::UpdateOperation::InvalidArguments) {
- // remember that the operation was performed what allows us to undo it if a
- // following operaton fails or if this operation failed but still needs
- // an undo call to cleanup.
- d->addPerformed(operation);
- operation->setValue(QLatin1String("component"), comp->name());
+ d->setStatus(Installer::Running);
+ try {
+ d->installComponent(component, progressOperationSize);
+ d->setStatus(Installer::Success);
+ } catch (const Error &error) {
+ if (status() != Installer::Canceled) {
+ d->setStatus(Installer::Failure);
+ verbose() << "INSTALLER FAILED: " << error.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), error.message());
}
-
- if (becameAdmin)
- dropAdminRights();
-
- if (!ok && !ignoreError)
- throw Error(operation->errorString());
-
- if (comp->value(QLatin1String("Important"), QLatin1String("false")) == QLatin1String("true"))
- d->m_forceRestart = true;
- }
-
- d->registerPathesForUninstallation(comp->pathesForUninstallation(), comp->name());
-
- if (!comp->stopProcessForUpdateRequests().isEmpty()) {
- KDUpdater::UpdateOperation *stopProcessForUpdatesOp =
- KDUpdater::UpdateOperationFactory::instance().create(QLatin1String("FakeStopProcessForUpdate"));
- const QStringList arguments(comp->stopProcessForUpdateRequests().join(QLatin1String(",")));
- stopProcessForUpdatesOp->setArguments(arguments);
- d->addPerformed(stopProcessForUpdatesOp);
- stopProcessForUpdatesOp->setValue(QLatin1String("component"), comp->name());
}
-
- // now mark the component as installed
- KDUpdater::PackagesInfo* const packages = d->m_app->packagesInfo();
- const bool forcedInstall =
- comp->value(QLatin1String("ForcedInstallation")).toLower() == QLatin1String("true")
- ? true : false;
- const bool virtualComponent =
- comp->value(QLatin1String ("Virtual")).toLower() == QLatin1String("true") ? true : false;
- packages->installPackage(comp->value(QLatin1String("Name")),
- comp->value(QLatin1String("Version")), comp->value(QLatin1String("DisplayName")),
- comp->value(QLatin1String("Description")), comp->dependencies(), forcedInstall,
- virtualComponent, comp->value(QLatin1String ("UncompressedSize")).toULongLong());
-
- comp->setValue(QLatin1String("CurrentState"), QLatin1String("Installed"));
- comp->markAsPerformedInstallation();
}
/*!
@@ -1612,11 +508,10 @@ void Installer::rollBackInstallation()
//this unregisters all operation progressChanged connects
ProgressCoordninator::instance()->setUndoMode();
- int progressOperationCount =
- d->countProgressOperations(d->m_performedOperationsCurrentSession.toList());
- double progressOperationSize = double(1) / progressOperationCount;
+ const int progressOperationCount = d->countProgressOperations(d->m_performedOperationsCurrentSession);
+ const double progressOperationSize = double(1) / progressOperationCount;
- //reregister all the undooperations with the new size to the ProgressCoordninator
+ //re register all the undo operations with the new size to the ProgressCoordninator
foreach (KDUpdater::UpdateOperation* const operation, d->m_performedOperationsCurrentSession) {
QObject* const operationObject = dynamic_cast<QObject*>(operation);
if (operationObject != 0) {
@@ -1630,12 +525,10 @@ void Installer::rollBackInstallation()
while (!d->m_performedOperationsCurrentSession.isEmpty()) {
try {
- KDUpdater::UpdateOperation* const operation = d->m_performedOperationsCurrentSession.last();
- d->m_performedOperationsCurrentSession.pop_back();
-
- const bool becameAdmin = !d->engineClientHandler->isActive()
+ KDUpdater::UpdateOperation* const operation = d->m_performedOperationsCurrentSession.takeLast();
+ const bool becameAdmin = !d->m_FSEngineClientHandler->isActive()
&& operation->value(QLatin1String("admin")).toBool() && gainAdminRights();
- performOperationThreaded(operation, Undo);
+ InstallerPrivate::performOperationThreaded(operation, InstallerPrivate::Undo);
if (becameAdmin)
dropAdminRights();
} catch(const Error &e) {
@@ -1647,604 +540,398 @@ void Installer::rollBackInstallation()
}
}
-void Installer::Private::runInstaller()
+bool Installer::isFileExtensionRegistered(const QString& extension) const
{
- try {
- setStatus(InstallerRunning);
- emit installationStarted(); //resets also the ProgressCoordninator
-
- //to have some progress for writeUninstaller
- ProgressCoordninator::instance()->addReservePercentagePoints(1);
-
- const QString target = targetDir();
- if (target.isEmpty())
- throw Error(tr("Variable 'TargetDir' not set."));
-
- // add the operation to create the target directory
- bool installToAdminDirectory = false;
- if (!QDir(target).exists()) {
- QScopedPointer<KDUpdater::UpdateOperation> mkdirOp(createOwnedOperation(QLatin1String("Mkdir")));
- mkdirOp->setValue(QLatin1String("forceremoval"), true);
- Q_ASSERT(mkdirOp.data());
- mkdirOp->setArguments(QStringList() << target);
- performOperationThreaded(mkdirOp.data(), Backup);
- if (!performOperationThreaded(mkdirOp.data())) {
- // if we cannot create the target dir, we try to activate the admin rights
- installToAdminDirectory = true;
- if (!q->gainAdminRights() || !performOperationThreaded(mkdirOp.data()))
- throw Error(mkdirOp->errorString());
- }
- QString remove = q->value(QLatin1String("RemoveTargetDir"));
- if (QVariant(remove).toBool())
- addPerformed(mkdirOp.take());
- } else {
- QTemporaryFile tempAdminFile(target + QLatin1String("/adminrights"));
- if (!tempAdminFile.open() || !tempAdminFile.isWritable())
- installToAdminDirectory = q->gainAdminRights();
- }
-
- // to show that there was some work
- ProgressCoordninator::instance()->addManualPercentagePoints(1);
-
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
- const QList<Component*> componentsToInstall = q->calculateComponentOrder();
- verbose() << "Install size: " << componentsToInstall.size() << " components" << std::endl;
-
- // check if we need admin rights and ask before the action happens
- for (QList<Component*>::const_iterator it = componentsToInstall.begin();
- it != componentsToInstall.end() && !installToAdminDirectory; ++it) {
- Component* const component = *it;
- bool requiredAdmin = false;
-
- if (component->value(QLatin1String("RequiresAdminRights"),
- QLatin1String("false")) == QLatin1String("true")) {
- requiredAdmin = q->gainAdminRights();
- }
-
- if (requiredAdmin) {
- q->dropAdminRights();
- break;
- }
- }
-
- const double downloadPartProgressSize = double(1) / 3;
- double componentsInstallPartProgressSize = double(2) / 3;
- const int downloadedArchivesCount = q->downloadNeededArchives(InstallerMode,
- downloadPartProgressSize);
-
- //if there was no download we have the whole progress for installing components
- if (!downloadedArchivesCount) {
- //componentsInstallPartProgressSize + downloadPartProgressSize;
- componentsInstallPartProgressSize = double(1);
- }
-
- // put the installed packages info into the target dir
- KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
- packages->setFileName(componentsXmlPath());
- packages->setApplicationName(m_settings.applicationName());
- packages->setApplicationVersion(m_settings.applicationVersion());
-
- stopProcessesForUpdates(componentsToInstall);
-
- const int progressOperationCount = countProgressOperations(componentsToInstall);
- double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
-
- QList<Component*>::const_iterator it;
- for (it = componentsToInstall.begin(); it != componentsToInstall.end(); ++it)
- q->installComponent(*it, progressOperationSize);
-
- registerInstaller();
-
- emit q->titleMessageChanged(tr("Creating Uninstaller"));
+ QSettingsWrapper settings(QLatin1String("HKEY_CLASSES_ROOT"), QSettingsWrapper::NativeFormat);
+ return settings.value(QString::fromLatin1(".%1/Default").arg(extension)).isValid();
+}
- m_app->packagesInfo()->writeToDisk();
- writeUninstaller(m_performedOperationsOld + m_performedOperationsCurrentSession);
- //this is the reserved one from the beginning
- ProgressCoordninator::instance()->addManualPercentagePoints(1);
+// -- QInstaller
- setStatus(InstallerSucceeded);
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
+/*!
+ Used by operation runner to get a fake installer, can be removed if installerbase can do what operation
+ runner does.
+*/
+Installer::Installer()
+ : d(new InstallerPrivate())
+{
+}
- emit installationFinished();
+Installer::Installer(qint64 magicmaker,
+ const QVector<KDUpdater::UpdateOperation*>& performedOperations)
+ : d(new InstallerPrivate(this, magicmaker, performedOperations.toList()))
+{
+ qRegisterMetaType< QInstaller::Installer::Status >("QInstaller::Installer::Status");
+ qRegisterMetaType< QInstaller::Installer::WizardPage >("QInstaller::Installer::WizardPage");
- // disable the FSEngineClientHandler afterwards
- engineClientHandler->setActive(false);
- } catch (const Error &err) {
- if (q->status() != InstallerCanceledByUser) {
- setStatus(InstallerFailed);
- verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationError"), tr("Error"), err.message());
- verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
- << std::endl;
- }
+ d->initialize();
+}
- q->rollBackInstallation();
+Installer::~Installer()
+{
+ if (!isUninstaller() && !(isInstaller() && status() == Installer::Canceled)) {
+ QDir targetDir(value(QLatin1String("TargetDir")));
+ QString logFileName = targetDir.absoluteFilePath(value(QLatin1String("LogFileName"),
+ QLatin1String("InstallationLog.txt")));
+ QInstaller::VerboseWriter::instance()->setOutputStream(logFileName);
+ }
+ delete d;
+}
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
- emit installationFinished();
+QFont Installer::virtualComponentsFont()
+{
+ return s_virtualComponentsFont;
+}
- // disable the FSEngineClientHandler afterwards
- engineClientHandler->setActive(false);
- throw;
- }
+void Installer::setVirtualComponentsFont(const QFont &font)
+{
+ s_virtualComponentsFont = font;
}
-void Installer::Private::deleteUninstaller()
+bool Installer::virtualComponentsVisible()
{
-#ifdef Q_OS_WIN
- // Since Windows does not support that the uninstaller deletes itself we have to go with a
- // rather dirty hack. What we do is to create a batchfile that will try to remove the uninstaller
- // once per second. Then we start that batchfile detached, finished our job and close outself.
- // Once that's done the batchfile will succeed in deleting our uninstall.exe and, if the
- // installation directory was created but us and if it's empty after the uninstall, deletes
- // the installation-directory.
- const QString batchfile = QDir::toNativeSeparators(QFileInfo(QDir::tempPath(),
- QLatin1String("uninstall.vbs")).absoluteFilePath());
- QFile f(batchfile);
- if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
- throw Error(tr("Cannot prepare uninstall"));
-
- QTextStream batch(&f);
- batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
- batch << "file = WScript.Arguments.Item(0)\n";
- batch << "folderpath = WScript.Arguments.Item(1)\n";
- batch << "Set folder = fso.GetFolder(folderpath)\n";
- batch << "on error resume next\n";
-
- batch << "while fso.FileExists(file)\n";
- batch << " fso.DeleteFile(file)\n";
- batch << " WScript.Sleep(1000)\n";
- batch << "wend\n";
-// batch << "if folder.SubFolders.Count = 0 and folder.Files.Count = 0 then\n";
- batch << " Set folder = Nothing\n";
- batch << " fso.DeleteFolder folderpath, true\n";
-// batch << "end if\n";
- batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
-
- f.close();
-
- QStringList arguments;
- arguments << QLatin1String("//Nologo") << batchfile; // execute the batchfile
- arguments << QDir::toNativeSeparators(QFileInfo(installerBinaryPath()).absoluteFilePath());
- if (!m_performedOperationsOld.isEmpty()) {
- const KDUpdater::UpdateOperation* const op = m_performedOperationsOld.first();
- if (op->name() == QLatin1String("Mkdir")) // the target directory name
- arguments << QDir::toNativeSeparators(QFileInfo(op->arguments().first()).absoluteFilePath());
- }
+ return s_virtualComponentsVisible;
+}
- if (!QProcess::startDetached(QLatin1String("cscript"), arguments, QDir::rootPath()))
- throw Error(tr("Cannot start uninstall"));
-#else
- // every other platform has no problem if we just delete ourself now
- QFile uninstaller(QFileInfo(installerBinaryPath()).absoluteFilePath());
- uninstaller.remove();
-#ifdef Q_WS_MAC
- const QLatin1String cdUp("/../../..");
- if (QFileInfo(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath()).isBundle()) {
- removeDirectoryThreaded(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath());
- QFile::remove(QFileInfo(installerBinaryPath() + cdUp).absolutePath()
- + QLatin1String("/") + configurationFileName());
- }
- else
-#endif
-#endif
- {
- // finally remove the components.xml, since it still exists now
- QFile::remove(QFileInfo(installerBinaryPath()).absolutePath() + QLatin1String("/") + configurationFileName());
- }
+void Installer::setVirtualComponentsVisible(bool visible)
+{
+ s_virtualComponentsVisible = visible;
}
-bool Installer::isFileExtensionRegistered(const QString& extension) const
+RunMode Installer::runMode() const
{
- QSettings settings(QLatin1String("HKEY_CLASSES_ROOT"), QSettings::NativeFormat);
- return settings.value(QString::fromLatin1(".%1/Default").arg(extension)).isValid();
+ return isUpdater() ? UpdaterMode : AllMode;
}
-void Installer::Private::runPackageUpdater()
+/*!
+ Returns a hash containing the installed package name and it's associated package information. If
+ the application is running in installer mode or the local components file could not be parsed, the
+ hash is empty.
+*/
+QHash<QString, KDUpdater::PackageInfo> Installer::localInstalledPackages()
{
- try {
- if (m_completeUninstall) {
- // well... I guess we would call that an uninstall, no? :-)
- packageManagingMode = !m_completeUninstall;
- runUninstaller();
- return;
+ QHash<QString, KDUpdater::PackageInfo> installedPackages;
+
+ if (!isInstaller()) {
+ KDUpdater::PackagesInfo &packagesInfo = *d->m_app->packagesInfo();
+ if (!setAndParseLocalComponentsFile(packagesInfo)) {
+ verbose() << tr("Could not parse local components xml file: %1")
+ .arg(d->localComponentsXmlPath());
+ return installedPackages;
}
+ packagesInfo.setApplicationName(d->m_installerSettings.applicationName());
+ packagesInfo.setApplicationVersion(d->m_installerSettings.applicationVersion());
- setStatus(InstallerRunning);
- emit installationStarted(); //resets also the ProgressCoordninator
+ foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos())
+ installedPackages.insert(info.name, info);
+ }
- //to have some progress for the cleanup/write component.xml step
- ProgressCoordninator::instance()->addReservePercentagePoints(1);
+ return installedPackages;
+}
- if (!QFileInfo(installerBinaryPath()).isWritable())
- q->gainAdminRights();
+GetRepositoriesMetaInfoJob* Installer::fetchMetaInformation(const QInstaller::InstallerSettings &settings)
+{
+ GetRepositoriesMetaInfoJob *metaInfoJob = new GetRepositoriesMetaInfoJob(settings.publicKey());
+ if ((isInstaller() && !isOfflineOnly()) || (isUpdater() || isPackageManager()))
+ metaInfoJob->setRepositories(settings.repositories());
- KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
- packages->setFileName(componentsXmlPath());
- packages->setApplicationName(m_settings.applicationName());
- packages->setApplicationVersion(m_settings.applicationVersion());
+ connect(metaInfoJob, SIGNAL(infoMessage(KDJob*, QString)), this,
+ SIGNAL(metaJobInfoMessage(KDJob*, QString)));
+ connect(this, SIGNAL(cancelMetaInfoJob()), metaInfoJob, SLOT(doCancel()));
- const QString packagesXml = componentsXmlPath();
- if (!QFile(packagesXml).open(QIODevice::Append))
- q->gainAdminRights();
+ try {
+ metaInfoJob->setAutoDelete(false);
+ metaInfoJob->start();
+ metaInfoJob->waitForFinished();
+ } catch (Error &error) {
+ verbose() << tr("Could not retrieve meta information: %1").arg(error.message()) << std::endl;
+ }
- // first check, if we need admin rights for the installation part
- QList<Component*>::const_iterator it;
- QList<Component*> availableComponents = q->components(true, InstallerMode);
- for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
- // check if we need admin rights and ask before the action happens
- Component* const currentComponent = *it;
- if (!currentComponent->isSelected(InstallerMode))
- continue;
+ return metaInfoJob;
+}
- // we only need the uninstalled components
- if (currentComponent->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
- continue;
+bool Installer::addUpdateResourcesFrom(GetRepositoriesMetaInfoJob *metaInfoJob, const InstallerSettings &settings,
+ bool parseChecksum)
+{
+ const QString &appName = settings.applicationName();
+ const QStringList tempDirs = metaInfoJob->temporaryDirectories();
+ foreach (const QString &tmpDir, tempDirs) {
+ if (tmpDir.isEmpty())
+ continue;
- bool requiredAdmin = false;
- if (currentComponent->value(QLatin1String("RequiresAdminRights"),
- QLatin1String("false")) == QLatin1String("true")) {
- requiredAdmin = q->gainAdminRights();
+ if (parseChecksum) {
+ const QString updatesXmlPath = tmpDir + QLatin1String("/Updates.xml");
+ QFile updatesFile(updatesXmlPath);
+ try {
+ openForRead(&updatesFile, updatesFile.fileName());
+ } catch(const Error &e) {
+ verbose() << tr("Error opening Updates.xml: ") << e.message() << std::endl;
+ return false;
}
- if (requiredAdmin) {
- q->dropAdminRights();
- break;
+ int line = 0;
+ int column = 0;
+ QString error;
+ QDomDocument doc;
+ if (!doc.setContent(&updatesFile, &error, &line, &column)) {
+ verbose() << tr("Parse error in File %4 : %1 at line %2 col %3").arg(error,
+ QString::number(line), QString::number(column), updatesFile.fileName()) << std::endl;
+ return false;
}
- }
- //to have 1/5 for undoOperationProgressSize and 2/5 for componentsInstallPartProgressSize
- const double downloadPartProgressSize = double(2) / 5;
- // following, we download the needed archives
- q->downloadNeededArchives(InstallerMode, downloadPartProgressSize);
-
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Removing deselected components..."));
- QVector< KDUpdater::UpdateOperation* > nonRevertedOperations;
-
- QList<KDUpdater::UpdateOperation*> undoOperations;
- for (int i = m_performedOperationsOld.count() - 1; i >= 0; --i) {
- KDUpdater::UpdateOperation* const currentOperation = m_performedOperationsOld[i];
-
- const QString componentName = currentOperation->value(QLatin1String("component")).toString();
- Component* comp = q->componentByName(componentName);
-
- // if we're _not_ removing everything an this component is still selected, -> next
- if (comp == 0 || comp->isSelected()) {
- nonRevertedOperations.push_front(currentOperation);
- continue;
+ const QDomNode checksum = doc.documentElement().firstChildElement(QLatin1String("Checksum"));
+ if (!checksum.isNull()) {
+ const QDomElement checksumElem = checksum.toElement();
+ setTestChecksum(checksumElem.text().toLower() == QLatin1String("true"));
}
- undoOperations.append(currentOperation);
- }
-
- double undoOperationProgressSize = 0;
- int progressUndoOperationCount = 0;
- double progressUndoOperationSize = 0;
- double componentsInstallPartProgressSize = double(2) / 5;
- if (undoOperations.count() > 0) {
- componentsInstallPartProgressSize = double(2) / 5;
- undoOperationProgressSize = double(1) / 5;
- progressUndoOperationCount = countProgressOperations(undoOperations);
- progressUndoOperationSize = undoOperationProgressSize / progressUndoOperationCount;
- } else {
- componentsInstallPartProgressSize = double(3) / 5;
}
+ d->m_app->addUpdateSource(appName, appName, QString(), QUrl::fromLocalFile(tmpDir), 1);
+ }
+ d->m_app->updateSourcesInfo()->setModified(false);
- QSet<Component*> uninstalledComponents;
- foreach (KDUpdater::UpdateOperation* const currentOperation, undoOperations) {
- if (statusCanceledOrFailed())
- throw Error(tr("Installation canceled by user"));
- connectOperationToInstaller(currentOperation, progressUndoOperationSize);
-
- const QString componentName = currentOperation->value(QLatin1String("component")).toString();
- Component* comp = q->componentByName(componentName);
-
- verbose() << "undo operation=" << currentOperation->name() << std::endl;
- uninstalledComponents |= comp;
-
- const bool becameAdmin = !engineClientHandler->isActive()
- && currentOperation->value(QLatin1String("admin")).toBool() && q->gainAdminRights();
-
- bool ignoreError = false;
- performOperationThreaded(currentOperation, Undo);
- bool ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError
- || componentName == QLatin1String("");
- while (!ok && !ignoreError && q->status() != InstallerCanceledByUser) {
- verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
- .arg(currentOperation->name(), currentOperation->arguments()
- .join(QLatin1String("; ")), currentOperation->errorString()) << std::endl;;
-
- const QMessageBox::StandardButton button =
- MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
- tr("Error during installation process(%1):\n%2").arg(componentName,
- currentOperation->errorString()),
- QMessageBox::Retry | QMessageBox::Ignore, QMessageBox::Retry);
-
- if (button == QMessageBox::Retry) {
- performOperationThreaded(currentOperation, Undo);
- ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError;
- }
- else if (button == QMessageBox::Ignore)
- ignoreError = true;
- }
+ return true;
+}
- if (becameAdmin)
- q->dropAdminRights();
+bool Installer::fetchAllPackages()
+{
+ if (isUninstaller() || isUpdater())
+ return false;
- delete currentOperation;
- }
+ QHash<QString, KDUpdater::PackageInfo> installedPackages = localInstalledPackages();
- const QList<Component*> allComponents = q->components(true, InstallerMode);
- foreach (Component *comp, allComponents) {
- if (!comp->isSelected())
- uninstalledComponents |= comp;
+ QScopedPointer <GetRepositoriesMetaInfoJob> metaInfoJob(fetchMetaInformation(d->m_installerSettings));
+ if (metaInfoJob->isCanceled() || metaInfoJob->error() != KDJob::NoError) {
+ if (metaInfoJob->error() != QInstaller::UserIgnoreError) {
+ verbose() << tr("Could not retrieve updates: %1").arg(metaInfoJob->errorString()) << std::endl;
+ return false;
}
+ }
- QSet<Component*>::const_iterator it2;
- for (it2 = uninstalledComponents.begin(); it2 != uninstalledComponents.end(); ++it2) {
- packages->removePackage((*it2)->name());
- (*it2)->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
+ if (!metaInfoJob->temporaryDirectories().isEmpty()) {
+ if (!addUpdateResourcesFrom(metaInfoJob.data(), d->m_installerSettings, true)) {
+ verbose() << tr("Could not add temporary update source information.") << std::endl;
+ return false;
}
+ }
- // these are all operations left: those which were not reverted
- m_performedOperationsOld = nonRevertedOperations;
+ if (d->m_app->updateSourcesInfo()->updateSourceInfoCount() == 0) {
+ verbose() << tr("Could not find any update source information.") << std::endl;
+ return false;
+ }
- //write components.xml in case the user cancels the update
- packages->writeToDisk();
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
+ KDUpdater::UpdateFinder updateFinder(d->m_app);
+ updateFinder.setAutoDelete(false);
+ updateFinder.setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
+ updateFinder.run();
- const QList<Component*> componentsToInstall = q->calculateComponentOrder();
+ const QList<KDUpdater::Update*> &packages = updateFinder.updates();
+ if (packages.isEmpty()) {
+ verbose() << tr("Could not retrieve components: %1").arg(updateFinder.errorString());
+ return false;
+ }
- verbose() << "Install size: " << componentsToInstall.size() << " components " << std::endl;
+ emit startAllComponentsReset();
- stopProcessesForUpdates(componentsToInstall);
+ qDeleteAll(d->m_rootComponents);
+ d->m_rootComponents.clear();
- int progressOperationCount = countProgressOperations(componentsToInstall);
- double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+ QMap<QString, QInstaller::Component*> components;
- for (it = componentsToInstall.begin(); it != componentsToInstall.end(); ++it)
- q->installComponent(*it, progressOperationSize);
+ Data data;
+ data.components = &components;
+ data.metaInfoJob = metaInfoJob.data();
+ data.installedPackages = &installedPackages;
- packages->writeToDisk();
+ foreach (KDUpdater::Update *package, packages) {
+ QScopedPointer<QInstaller::Component> component(new QInstaller::Component(this));
- emit q->titleMessageChanged(tr("Creating Uninstaller"));
+ data.package = package;
+ component->loadDataFromUpdate(package);
+ if (updateComponentData(data, component.data())) {
+ const QString name = component->name();
+ components.insert(name, component.take());
+ }
+ }
- commitSessionOperations(); //end session, move ops to "old"
- m_needToWriteUninstaller = true;
+ // remove all components that got a replacement
+ foreach (const QString &component, data.componentsToReplace)
+ delete components.take(component);
- //this is the reserved one from the beginning
- ProgressCoordninator::instance()->addManualPercentagePoints(1);
+ // now append all components to their respective parents
+ QMap<QString, QInstaller::Component*>::const_iterator it;
+ for (it = components.begin(); it != components.end(); ++it) {
+ QString id = it.key();
+ QInstaller::Component *component = it.value();
+ while (!id.isEmpty() && component->parentComponent() == 0) {
+ id = id.section(QLatin1Char('.'), 0, -2);
+ if (components.contains(id))
+ components[id]->appendComponent(component);
+ }
+ }
- setStatus(InstallerSucceeded);
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
- emit installationFinished();
+ // append all components w/o parent to the direct list
+ foreach (QInstaller::Component *component, components) {
+ if (component->parentComponent() == 0)
+ appendRootComponent(component, AllMode);
+ }
- // disable the FSEngineClientHandler afterwards
- engineClientHandler->setActive(false);
- } catch(const Error &err) {
- if (q->status() != InstallerCanceledByUser) {
- setStatus(InstallerFailed);
- verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationError"), tr("Error"), err.message());
- verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
- << std::endl;
+ // after everything is set up, load the scripts
+ foreach (QInstaller::Component *component, components)
+ component->loadComponentScript();
+
+ // now set the checked state for all components without child
+ for (int i = 0; i < rootComponentCount(AllMode); ++i) {
+ QList<Component*> children = rootComponent(i, AllMode)->childs();
+ foreach (Component *child, children) {
+ if (child->isCheckable() && !child->isTristate()) {
+ if (child->isInstalled() || child->isDefault())
+ child->setCheckState(Qt::Checked);
+ }
}
+ }
- q->rollBackInstallation();
-
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
- emit installationFinished();
+ emit finishAllComponentsReset();
- // disable the FSEngineClientHandler afterwards
- engineClientHandler->setActive(false);
- throw;
- }
+ return true;
}
-void Installer::Private::runUninstaller()
+bool Installer::fetchUpdaterPackages()
{
- try {
- emit uninstallationStarted();
+ if (!isUpdater())
+ return false;
- if (!QFileInfo(installerBinaryPath()).isWritable())
- q->gainAdminRights();
+ QHash<QString, KDUpdater::PackageInfo> installedPackages = localInstalledPackages();
- const QString packagesXml = componentsXmlPath();
- if (!QFile(packagesXml).open(QIODevice::Append))
- q->gainAdminRights();
+ QScopedPointer <GetRepositoriesMetaInfoJob> metaInfoJob(fetchMetaInformation(d->m_installerSettings));
+ if (metaInfoJob->isCanceled() || metaInfoJob->error() != KDJob::NoError) {
+ if (metaInfoJob->error() != QInstaller::UserIgnoreError) {
+ verbose() << tr("Could not retrieve updates: %1").arg(metaInfoJob->errorString()) << std::endl;
+ return false;
+ }
+ }
- KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
- packages->setFileName(componentsXmlPath());
- packages->setApplicationName(m_settings.applicationName());
- packages->setApplicationVersion(m_settings.applicationVersion());
+ if (!metaInfoJob->temporaryDirectories().isEmpty()) {
+ if (!addUpdateResourcesFrom(metaInfoJob.data(), d->m_installerSettings, true)) {
+ verbose() << tr("Could not add temporary update source information.") << std::endl;
+ return false;
+ }
+ }
- // iterate over all components - if they're all marked for uninstall, it's a complete uninstall
- const QList<Component*> allComponents = q->components(true);
- bool allMarkedForUninstall = true;
+ if (d->m_app->updateSourcesInfo()->updateSourceInfoCount() == 0) {
+ verbose() << tr("Could not find any update source information.") << std::endl;
+ return false;
+ }
- QList<KDUpdater::UpdateOperation*> uninstallOperations;
- QVector<KDUpdater::UpdateOperation*> nonRevertedOperations;
+ KDUpdater::UpdateFinder updateFinder(d->m_app);
+ updateFinder.setAutoDelete(false);
+ updateFinder.setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
+ updateFinder.run();
- // just rollback all operations done before
- for (int i = m_performedOperationsOld.count() - 1; i >= 0; --i) {
- KDUpdater::UpdateOperation* const operation = m_performedOperationsOld[i];
+ const QList<KDUpdater::Update*> &updates = updateFinder.updates();
+ if (updates.isEmpty()) {
+ verbose() << tr("Could not retrieve updates: %1").arg(updateFinder.errorString());
+ return false;
+ }
- const QString componentName = operation->value(QLatin1String("component")).toString();
- const Component* const comp = q->componentByName(componentName);
+ emit startUpdaterComponentsReset();
- // if we're _not_ removing everything an this component is still selected, -> next
- if (!m_completeUninstall && (comp == 0 || !comp->isSelected())) {
- nonRevertedOperations.push_front(operation);
- continue;
- }
- uninstallOperations.append(operation);
- }
+ qDeleteAll(d->m_updaterComponents);
+ d->m_updaterComponents.clear();
- const int progressUninstallOperationCount = countProgressOperations(uninstallOperations);
- const double progressUninstallOperationSize = double(1) / progressUninstallOperationCount;
-
- foreach (KDUpdater::UpdateOperation* const currentOperation, uninstallOperations) {
- if (statusCanceledOrFailed())
- throw Error(tr("Installation canceled by user"));
-
- connectOperationToInstaller(currentOperation, progressUninstallOperationSize);
- verbose() << "undo operation=" << currentOperation->name() << std::endl;
-
- const QString componentName = currentOperation->value(QLatin1String("component")).toString();
-
- const bool becameAdmin = !engineClientHandler->isActive()
- && currentOperation->value(QLatin1String("admin")).toBool() && q->gainAdminRights();
-
- bool ignoreError = false;
- performOperationThreaded(currentOperation, Undo);
- bool ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError
- || componentName == QLatin1String("");
- while (!ok && !ignoreError && q->status() != InstallerCanceledByUser) {
- verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
- .arg(currentOperation->name(), currentOperation->arguments()
- .join(QLatin1String("; ")), currentOperation->errorString()) << std::endl;;
- const QMessageBox::StandardButton button =
- MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
- tr("Error during installation process(%1):\n%2").arg(componentName,
- currentOperation->errorString()),
- QMessageBox::Retry | QMessageBox::Ignore, QMessageBox::Retry);
-
- if (button == QMessageBox::Retry) {
- performOperationThreaded(currentOperation, Undo);
- ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError;
- } else if (button == QMessageBox::Ignore)
- ignoreError = true;
- }
+ qDeleteAll(d->m_updaterComponentsDeps);
+ d->m_updaterComponentsDeps.clear();
- if (becameAdmin)
- q->dropAdminRights();
+ QMap<QString, QInstaller::Component*> components;
- if (!m_completeUninstall)
- delete currentOperation;
- }
+ Data data;
+ data.components = &components;
+ data.metaInfoJob = metaInfoJob.data();
+ data.installedPackages = &installedPackages;
- if (!m_completeUninstall) {
- QList<Component*>::const_iterator it;
- for (it = allComponents.begin(); it != allComponents.end(); ++it) {
- Component* const comp = *it;
- if (comp->isSelected()) {
- allMarkedForUninstall = false;
- } else {
- packages->removePackage(comp->name());
- comp->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
- }
- }
- m_completeUninstall = m_completeUninstall || allMarkedForUninstall;
- packageManagingMode = ! m_completeUninstall;
- }
+ bool importantUpdates = false;
+ foreach (KDUpdater::Update *update, updates) {
+ QScopedPointer<QInstaller::Component> component(new QInstaller::Component(this));
- const QString startMenuDir = m_vars.value(QLatin1String("StartMenuDir"));
- if (!startMenuDir.isEmpty()) {
- errno = 0;
- if (!QDir().rmdir(startMenuDir)) {
- verbose() << "Could not remove " << startMenuDir << " : "
- << QLatin1String(strerror(errno)) << std::endl;
- } else {
- verbose() << "Startmenu dir not set" << std::endl;
- }
- }
+ data.package = update;
+ component->loadDataFromUpdate(update);
+ if (updateComponentData(data, component.data())) {
+ // Keep a reference so we can resolve dependencies during update.
+ d->m_updaterComponentsDeps.append(component.take());
- if (m_completeUninstall) {
- // this will also delete the TargetDir on Windows
- deleteUninstaller();
- QList<Component*>::const_iterator it;
- for (it = allComponents.begin(); it != allComponents.end(); ++it) {
- packages->removePackage((*it)->name());
- (*it)->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
- }
- QString remove = q->value(QLatin1String("RemoveTargetDir"));
- if(QVariant(remove).toBool())
- {
- // on !Windows, we need to remove TargetDir manually
- packageManagingMode = ! m_completeUninstall;
- verbose() << "Complete Uninstallation is chosen" << std::endl;
- const QString target = targetDir();
- if (!target.isEmpty()) {
- if (engineClientHandler->isServerRunning() && !engineClientHandler->isActive()) {
- // we were root at least once, so we remove the target dir as root
- q->gainAdminRights();
- removeDirectoryThreaded(target, true);
- q->dropAdminRights();
- } else {
- removeDirectoryThreaded(target, true);
- }
- }
+ const QString isNew = update->data(QLatin1String("NewComponent")).toString();
+ if (isNew.toLower() != QLatin1String("true"))
+ continue;
+
+ const QString &name = d->m_updaterComponentsDeps.last()->name();
+ const QString replaces = data.package->data(QLatin1String("Replaces")).toString();
+ bool isValidUpdate = installedPackages.contains(name);
+ if (!isValidUpdate && !replaces.isEmpty()) {
+ const QStringList possibleNames = replaces.split(QLatin1String(","), QString::SkipEmptyParts);
+ foreach (const QString &possibleName, possibleNames)
+ isValidUpdate |= installedPackages.contains(possibleName);
}
- unregisterInstaller();
- m_needToWriteUninstaller = false;
- } else {
- // rewrite the uninstaller with the operation we did not undo
- writeUninstaller(nonRevertedOperations);
- }
+ if (!isValidUpdate)
+ continue; // Update for not installed package found, skip it.
- setStatus(InstallerSucceeded);
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nDeinstallation finished"));
- engineClientHandler->setActive(false);
- } catch (const Error &err) {
- if (q->status() != InstallerCanceledByUser) {
- setStatus(InstallerFailed);
- verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
- MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("installationError"), tr("Error"), err.message());
- verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
- << std::endl;
- }
+ const KDUpdater::PackageInfo &info = installedPackages.value(name);
+ const QString updateVersion = update->data(QLatin1String("Version")).toString();
+ if (KDUpdater::compareVersion(updateVersion, info.version) <= 0)
+ continue;
- ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
- emit installationFinished();
+ // It is quite possible that we may have already installed the update. Lets check the last
+ // update date of the package and the release date of the update. This way we can compare and
+ // figure out if the update has been installed or not.
+ const QDate updateDate = update->data(QLatin1String("ReleaseDate")).toDate();
+ if (info.lastUpdateDate > updateDate)
+ continue;
- // disable the FSEngineClientHandler afterwards
- engineClientHandler->setActive(false);
- throw;
+ // this is not a dependency, it is a real update
+ components.insert(name, d->m_updaterComponentsDeps.takeLast());
+ }
}
- emit uninstallationFinished();
-}
+ // remove all components that got a replacement
+ foreach (const QString &component, data.componentsToReplace)
+ delete components.take(component);
-// -- QInstaller
-
-//used by operation runner to get a fake installer,
-//can be removed if installerbase can do what operation runner does
-Installer::Installer()
- : d(new Private())
-{
-}
-
-Installer::Installer(qint64 magicmaker,
- const QVector<KDUpdater::UpdateOperation*>& performedOperations)
- : d(new Private(this, magicmaker, performedOperations))
-{
- qRegisterMetaType< QInstaller::Installer::Status >("QInstaller::Installer::Status");
- qRegisterMetaType< QInstaller::Installer::WizardPage >("QInstaller::Installer::WizardPage");
+ // remove all unimportant components
+ QList<QInstaller::Component*> updaterComponents = components.values();
+ if (importantUpdates) {
+ for (int i = updaterComponents.count() - 1; i >= 0; --i) {
+ const QString important = updaterComponents.at(i)->value(QLatin1String("Important"));
+ if (important.toLower() == QLatin1String("false") || important.isEmpty())
+ delete updaterComponents.takeAt(i);
+ }
+ }
- d->initialize();
-}
+ if (!updaterComponents.isEmpty()) {
+ // load the scripts and append all components w/o parent to the direct list
+ foreach (QInstaller::Component *component, updaterComponents) {
+ component->loadComponentScript();
+ component->setCheckState(Qt::Checked);
+ appendRootComponent(component, UpdaterMode);
+ }
-Installer::~Installer()
-{
- if (!isUninstaller() && !(isInstaller() && status() == InstallerCanceledByUser)) {
- QDir targetDir(value(QLatin1String("TargetDir")));
- QString logFileName = targetDir.absoluteFilePath(value(QLatin1String("LogFileName"),
- QLatin1String("InstallationLog.txt")));
- QInstaller::VerboseWriter::instance()->setOutputStream(logFileName);
+ // after everything is set up, check installed components
+ foreach (QInstaller::Component *component, d->m_updaterComponentsDeps) {
+ if (component->isInstalled()) {
+ // since we do not put them into the model, which would force a update of e.g. tri state
+ // components, we have to check all installed components ourself
+ component->setCheckState(Qt::Checked);
+ }
+ }
+ } else {
+ // we have no updates, no need to store possible dependencies
+ qDeleteAll(d->m_updaterComponentsDeps);
+ d->m_updaterComponentsDeps.clear();
}
- //check for fake installer case
- if (d->engineClientHandler) {
- d->engineClientHandler->setActive(false);
- }
- delete d;
+ emit finishUpdaterComponentsReset();
+
+ return true;
}
/*!
@@ -2312,54 +999,9 @@ bool Installer::removeWizardPageItem(Component *component, const QString &name)
return false;
}
-void Installer::setRemoteRepositories(const QList<Repository> &repositories)
+void Installer::addRepositories(const QList<Repository> &repositories)
{
- GetRepositoriesMetaInfoJob metaInfoJob(d->m_settings.publicKey(), isPackageManager());
- metaInfoJob.setRepositories(repositories);
-
- // start...
- metaInfoJob.setAutoDelete(false);
- metaInfoJob.start();
- metaInfoJob.waitForFinished();
-
- if (metaInfoJob.isCanceled())
- return;
-
- if (metaInfoJob.error() != KDJob::NoError)
- throw Error(tr("Could not retrieve updates: %1").arg(metaInfoJob.errorString()));
-
- KDUpdater::Application &updaterApp = *d->m_app;
-
- const QStringList tempDirs = metaInfoJob.temporaryDirectories();
- d->tempDirDeleter.add(tempDirs);
- foreach (const QString &tmpDir, tempDirs) {
- if (tmpDir.isEmpty())
- continue;
- const QString &applicationName = d->m_settings.applicationName();
- updaterApp.addUpdateSource(applicationName, applicationName, QString(),
- QUrl::fromLocalFile(tmpDir), 1);
- }
-
- if (updaterApp.updateSourcesInfo()->updateSourceInfoCount() == 0)
- throw Error(tr("Could not reach any update sources."));
-
- if (!setAndParseLocalComponentsFile(*updaterApp.packagesInfo()))
- return;
-
- // The changes done above by adding update source don't count as modification that
- // need to be saved cause they will be re-set on the next start anyway. This does
- // prevent creating of xml files not needed atm. We can still set the modified
- // state later once real things changed that we like to restore at the next startup.
- updaterApp.updateSourcesInfo()->setModified(false);
-
- // create the packages info
- KDUpdater::UpdateFinder* const updateFinder = new KDUpdater::UpdateFinder(&updaterApp);
- connect(updateFinder, SIGNAL(error(int, QString)), &updaterApp, SLOT(printError(int, QString)));
- updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
- updateFinder->run();
-
- // now create installable componets
- createComponents(updateFinder->updates(), metaInfoJob);
+ d->m_installerSettings.addUserRepositories(repositories);
}
/*!
@@ -2368,663 +1010,204 @@ void Installer::setRemoteRepositories(const QList<Repository> &repositories)
*/
void Installer::setTemporaryRepositories(const QList<Repository> &repositories, bool replace)
{
- d->m_settings.setTemporaryRepositories(repositories, replace);
+ d->m_installerSettings.setTemporaryRepositories(repositories, replace);
}
/*!
- Defines if the downloader should try to download sha1 checksums for archives
+ checks if the downloader should try to download sha1 checksums for archives
*/
-void Installer::setTestChecksum(bool test)
+bool Installer::testChecksum() const
{
- d->m_testChecksum = test;
+ return d->m_testChecksum;
}
/*!
- checks if the downloader should try to download sha1 checksums for archives
+ Defines if the downloader should try to download sha1 checksums for archives
*/
-bool Installer::testChecksum()
+void Installer::setTestChecksum(bool test)
{
- return d->m_testChecksum;
+ d->m_testChecksum = test;
}
/*!
- Creates components from the \a updates found by KDUpdater.
+ Returns the number of components in the list depending on the run mode \a runMode.
*/
-void Installer::createComponentsV2(const QList<KDUpdater::Update*> &updates,
- const GetRepositoriesMetaInfoJob &metaInfoJob)
+int Installer::rootComponentCount(RunMode runMode) const
{
- verbose() << "entered create components V2 in installer" << std::endl;
-
- emit componentsAboutToBeCleared();
-
- qDeleteAll(d->m_componentHash);
- d->m_rootComponents.clear();
- d->m_updaterComponents.clear();
- d->m_componentHash.clear();
- QStringList importantUpdates;
-
- KDUpdater::Application &updaterApp = *d->m_app;
- KDUpdater::PackagesInfo &packagesInfo = *updaterApp.packagesInfo();
-
- if (isUninstaller() || isPackageManager()) {
- //reads all installed components from components.xml
- if (!setAndParseLocalComponentsFile(packagesInfo))
- return;
- packagesInfo.setApplicationName(d->m_settings.applicationName());
- packagesInfo.setApplicationVersion(d->m_settings.applicationVersion());
- }
-
- QHash<QString, KDUpdater::PackageInfo> alreadyInstalledPackagesHash;
- foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos()) {
- alreadyInstalledPackagesHash.insert(info.name, info);
- }
-
- QStringList globalUnNeededList;
- QList<Component*> componentsToSelectInPackagemanager;
- foreach (KDUpdater::Update * const update, updates) {
- const QString name = update->data(QLatin1String("Name")).toString();
- Q_ASSERT(!name.isEmpty());
- QInstaller::Component* component(new QInstaller::Component(this));
- d->componentDeleteList.append(component);
- component->loadDataFromUpdate(update);
-
- QString installedVersion;
-
- //to find the installed version number we need to check for all possible names
- QStringList possibleInstalledNameList;
- if (!update->data(QLatin1String("Replaces")).toString().isEmpty()) {
- QString replacesAsString = update->data(QLatin1String("Replaces")).toString();
- QStringList replaceList(replacesAsString.split(QLatin1String(","),
- QString::SkipEmptyParts));
- possibleInstalledNameList.append(replaceList);
- globalUnNeededList.append(replaceList);
- }
- if (alreadyInstalledPackagesHash.contains(name)) {
- possibleInstalledNameList.append(name);
- }
- foreach(const QString &possibleName, possibleInstalledNameList) {
- if (alreadyInstalledPackagesHash.contains(possibleName)) {
- if (!installedVersion.isEmpty()) {
- qCritical("If installed version is not empty there are more then one package " \
- "which would be replaced and this is completly wrong");
- Q_ASSERT(false);
- }
- installedVersion = alreadyInstalledPackagesHash.value(possibleName).version;
- }
- //if we have newer data in the repository we don't need the data from harddisk
- alreadyInstalledPackagesHash.remove(name);
- }
-
- component->setLocalTempPath(QInstaller::pathFromUrl(update->sourceInfo().url));
- const Repository currentUsedRepository = metaInfoJob.repositoryForTemporaryDirectory(
- component->localTempPath());
- component->setRepositoryUrl(currentUsedRepository.url());
-
- // the package manager should preselect the currently installed packages
- if (isPackageManager()) {
-
- //reset PreviousState and CurrentState to have a chance to get a diff, after the user
- //changed something
- if (installedVersion.isEmpty()) {
- setValue(QLatin1String("PreviousState"), QLatin1String("Uninstalled"));
- setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
- if (component->value(QLatin1String("NewComponent")) == QLatin1String("true")) {
- d->m_updaterComponents.append(component);
- }
- } else {
- setValue(QLatin1String("PreviousState"), QLatin1String("Installed"));
- setValue(QLatin1String("CurrentState"), QLatin1String("Installed"));
- const QString updateVersion = update->data(QLatin1String("Version")).toString();
- //check if it is an update
- if (KDUpdater::compareVersion(installedVersion, updateVersion) > 0) {
- d->m_updaterComponents.append(component);
- }
- if (update->data(QLatin1String("Important"), false).toBool())
- importantUpdates.append(name);
- componentsToSelectInPackagemanager.append(component);
- }
- }
-
- d->m_componentHash[name] = component;
- } //foreach (KDUpdater::Update * const update, updates)
-
- if (!importantUpdates.isEmpty()) {
- //ups, there was an important update - then we only want to show these
- d->m_updaterComponents.clear();
- //maybe in future we have more then one
- foreach (const QString &importantUpdate, importantUpdates) {
- d->m_updaterComponents.append(d->m_componentHash[importantUpdate]);
- }
- }
-
- // now append all components to their respective parents and loads the scripts,
- // except the components which are aimed for replace to another name(globalUnNeededList)
- QHash<QString, QInstaller::Component*>::iterator it;
- for (it = d->m_componentHash.begin(); it != d->m_componentHash.end(); ++it) {
- QInstaller::Component* currentComponent = *it;
- QString id = it.key();
- if (globalUnNeededList.contains(id))
- continue; //we don't want to append the unneeded components
- while (!id.isEmpty() && currentComponent->parentComponent() == 0) {
- id = id.section(QChar::fromLatin1('.'), 0, -2);
- //is there a component which is called like a parent
- if (d->m_componentHash.contains(id))
- d->m_componentHash[id]->appendComponent(currentComponent);
- else
- d->m_rootComponents.append(currentComponent);
- }
- currentComponent->loadComponentScript();
- }
-
- // select all components in the updater model
- foreach (QInstaller::Component* const i, d->m_updaterComponents)
- i->setSelected(true, UpdaterMode, Component::InitializeComponentTreeSelectMode);
-
- // select all components in the package manager model
- foreach (QInstaller::Component* const i, componentsToSelectInPackagemanager)
- i->setSelected(true, InstallerMode, Component::InitializeComponentTreeSelectMode);
-
- //signals for the qinstallermodel
- emit rootComponentsAdded(d->m_rootComponents);
- emit updaterComponentsAdded(d->m_updaterComponents);
+ if (runMode == UpdaterMode)
+ return d->m_updaterComponents.size();
+ return d->m_rootComponents.size();
}
/*!
- Creates components from the \a updates found by KDUpdater.
+ Returns the component at index position i in the components list. i must be a valid index
+ position in the list (i.e., 0 <= i < rootComponentCount(...)).
*/
-void Installer::createComponents(const QList<KDUpdater::Update*> &updates,
- const GetRepositoriesMetaInfoJob &metaInfoJob)
+Component *Installer::rootComponent(int i, RunMode runMode) const
{
- verbose() << "entered create components in installer" << std::endl;
-
- emit componentsAboutToBeCleared();
-
- qDeleteAll(d->componentDeleteList);
- d->componentDeleteList.clear();
-
- d->m_rootComponents.clear();
- d->m_updaterComponents.clear();
- d->m_packageManagerComponents.clear();
- d->m_componentHash.clear();
-
- KDUpdater::Application &updaterApp = *d->m_app;
- KDUpdater::PackagesInfo &packagesInfo = *updaterApp.packagesInfo();
-
- if (isUninstaller() || isPackageManager()) {
- if (!setAndParseLocalComponentsFile(packagesInfo))
- return;
- packagesInfo.setApplicationName(d->m_settings.applicationName());
- packagesInfo.setApplicationVersion(d->m_settings.applicationVersion());
- }
-
- bool containsImportantUpdates = false;
- QMap<QInstaller::Component*, QString> scripts;
- QMap<QString, QInstaller::Component*> components;
- QList<Component*> componentsToSelectUpdater, componentsToSelectInstaller;
-
-// new from createComponentV2
- //use this hash instead of the plain list of packageinfos
- QHash<QString, KDUpdater::PackageInfo> alreadyInstalledPackagesHash;
- foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos()) {
- alreadyInstalledPackagesHash.insert(info.name, info);
- }
- QStringList globalUnNeededList;
-// END - new from createComponentV2
-
- //why do we need to add the components if there was a metaInfoJob.error()?
- //will this happen if there is no internet connection?
- //ok usually there should be the installed and the online tree
- if (metaInfoJob.error() == KDJob::UserDefinedError) {
- foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos()) {
- QScopedPointer<QInstaller::Component> component(new QInstaller::Component(this));
- d->componentDeleteList.append(component.data());
-
- if (components.contains(info.name)) {
- qCritical("Could not register component! Component with identifier %s already "
- "registered", qPrintable(info.name));
- } else {
- component->loadDataFromPackageInfo(info);
- components.insert(info.name, component.take());
- }
- }
- } else {
- foreach (KDUpdater::Update * const update, updates) {
- const QString newComponentName = update->data(QLatin1String("Name")).toString();
-
-// new from createComponentV2
- const QString name(newComponentName);
-
- //TODO: use installed version on component
- QString installedVersion;
-
- //to find the installed version number we need to check for all possible names
- QStringList possibleInstalledNameList;
- if (!update->data(QLatin1String("Replaces")).toString().isEmpty()) {
- QString replacesAsString = update->data(QLatin1String("Replaces")).toString();
- QStringList replaceList(replacesAsString.split(QLatin1String(","),
- QString::SkipEmptyParts));
- possibleInstalledNameList.append(replaceList);
- globalUnNeededList.append(replaceList);
- }
- if (alreadyInstalledPackagesHash.contains(name)) {
- possibleInstalledNameList.append(name);
- }
- foreach(const QString &possibleName, possibleInstalledNameList) {
- if (alreadyInstalledPackagesHash.contains(possibleName)) {
- if (!installedVersion.isEmpty()) {
- qCritical("If installed version is not empty there are more then one package " \
- "which would be replaced and this is completly wrong");
- Q_ASSERT(false);
- }
- installedVersion = alreadyInstalledPackagesHash.value(possibleName).version;
- }
- }
-// END - new from createComponentV2
-
-/////////// old code as a check that the new one is working
- const int indexOfPackage = packagesInfo.findPackageInfo(newComponentName);
-
- QScopedPointer<QInstaller::Component> component(new QInstaller::Component(this));
- d->componentDeleteList.append(component.data());
-
- if (indexOfPackage > -1) {
- Q_ASSERT(packagesInfo.packageInfo(indexOfPackage).version == installedVersion);
- }
-/////////// END - old code as a check that the new one is working
-
- component->loadDataFromUpdate(update);
- component->setValue(QLatin1String("InstalledVersion"), installedVersion);
- const Repository currentUsedRepository = metaInfoJob.repositoryForTemporaryDirectory(
- QInstaller::pathFromUrl(update->sourceInfo().url));
- component->setRepositoryUrl(currentUsedRepository.url());
-
- bool isUpdate = true;
- // the package manager should preselect the currently installed packages
- if (isPackageManager()) {
-
-// new from createComponentV2
- bool newSelect = false;
- foreach(const QString &possibleName, possibleInstalledNameList) {
- if (alreadyInstalledPackagesHash.contains(possibleName)) {
- newSelect = true;
- break;
- }
- }
-// END - new from createComponentV2
-
-/////////// old code as a check that the new one is working
- {
- const bool selected = indexOfPackage > -1;
- if (possibleInstalledNameList.count() == 1 &&
- possibleInstalledNameList.at(0) == newComponentName) {
- Q_ASSERT(newSelect == selected);
- }
- /////////// END - old code as a check that the new one is working
-
- component->updateState(newSelect);
-
- if (newSelect)
- componentsToSelectInstaller.append(component.data());
- }
-/////////// END - old code as a check that the new one is working
- const QString pkgVersion = packagesInfo.packageInfo(indexOfPackage).version;
- const QString updateVersion = update->data(QLatin1String("Version")).toString();
- if (KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0)
- isUpdate = false;
-
- // It is quite possible that we may have already installed the update.
- // Lets check the last update date of the package and the release date
- // of the update. This way we can compare and figure out if the update
- // has been installed or not.
- const QDate updateDate = update->data(QLatin1String("ReleaseDate")).toDate();
- const QDate pkgDate = packagesInfo.packageInfo(indexOfPackage).lastUpdateDate;
- if (pkgDate > updateDate)
- isUpdate = false;
- }
-
- if (!components.contains(newComponentName)) {
- const QString script = update->data(QLatin1String("Script")).toString();
- if (!script.isEmpty()) {
- scripts.insert(component.data(), QString::fromLatin1("%1/%2/%3").arg(
- QInstaller::pathFromUrl(update->sourceInfo().url), newComponentName, script));
- }
-
- Component *tmpComponent = component.data();
- const bool isInstalled = tmpComponent->value(QLatin1String("PreviousState"))
- == QLatin1String("Installed");
- const bool isNewComponent = tmpComponent->value(QLatin1String("NewComponent"))
- == QLatin1String("true") ? true : false;
- const bool newPackageForUpdater = !isInstalled && isNewComponent;
- isUpdate = isUpdate && isInstalled;
-
- if (newPackageForUpdater) {
- d->m_updaterComponents.push_back(component.data());
- d->m_componentHash[newComponentName] = tmpComponent;
- components.insert(newComponentName, component.data());
- } else {
- components.insert(newComponentName, component.data());
- }
-
- if (isPackageManager() && (isUpdate || newPackageForUpdater)) {
- if (update->data(QLatin1String("Important")).toBool())
- containsImportantUpdates = true;
- componentsToSelectUpdater.append(tmpComponent);
- d->m_packageManagerComponents.push_back(tmpComponent);
- }
- } else {
- qCritical("Could not register component! Component with identifier %s already "
- "registered", qPrintable(newComponentName));
- }
- component.take();
- }
- }
-
- if (containsImportantUpdates) {
- foreach (QInstaller::Component *c, d->m_packageManagerComponents) {
- if (c->value(QLatin1String("Important")).toLower() == QLatin1String ("false")
- || c->value(QLatin1String("Important")).isEmpty()) {
- if (isPackageManager())
- d->m_packageManagerComponents.removeAll(c);
- componentsToSelectUpdater.removeAll(c);
- }
- }
- }
-
- // now append all components to their respective parents
- QMap<QString, QInstaller::Component*>::const_iterator it;
- for (it = components.begin(); !d->linearComponentList && it != components.end(); ++it) {
- QInstaller::Component* const comp = *it;
- QString id = it.key();
- if (globalUnNeededList.contains(id))
- continue; //we don't want to append the unneeded components
- while (!id.isEmpty() && comp->parentComponent() == 0) {
- id = id.section(QChar::fromLatin1('.'), 0, -2);
- if (components.contains(id))
- components[id]->appendComponent(comp);
- }
- }
-
- // append all components w/o parent to the direct list
- for (it = components.begin(); it != components.end(); ++it) {
- if (globalUnNeededList.contains((*it)->name())) {
- //yes const cast is bad, but it is only a hack
- QInstaller::Component* yeahComponent(*it);
- d->willBeReplacedComponents.append(yeahComponent);
- continue; //we don't want to append the unneeded components
- }
- if (d->linearComponentList || (*it)->parentComponent() == 0)
- appendComponent(*it);
- }
-
- // after everything is set up, load the scripts
- QMapIterator< QInstaller::Component*, QString > scriptIt(scripts);
- while (scriptIt.hasNext()) {
- scriptIt.next();
- QInstaller::Component* const component = scriptIt.key();
- const QString script = scriptIt.value();
- verbose() << "Loading script for component " << component->name() << " (" << script << ")"
- << std::endl;
- component->loadComponentScript(script);
- }
-
- // select all components in the updater model
- foreach (QInstaller::Component* const i, componentsToSelectUpdater)
- i->setSelected(true, UpdaterMode, Component::InitializeComponentTreeSelectMode);
-
- // select all components in the package manager model
- foreach (QInstaller::Component* const i, componentsToSelectInstaller) {
- i->setSelected(true, InstallerMode, Component::InitializeComponentTreeSelectMode);
- }
-
- emit updaterComponentsAdded(d->m_packageManagerComponents);
- emit rootComponentsAdded(d->m_rootComponents);
+ if (runMode == UpdaterMode)
+ return d->m_updaterComponents.value(i, 0);
+ return d->m_rootComponents.value(i, 0);
}
-void Installer::appendComponent(Component *component)
+/*!
+ Appends a new root components \a component based on the current run mode \a runMode to the
+ installers internal lists of components.
+*/
+void Installer::appendRootComponent(Component *component, RunMode runMode)
{
- d->m_rootComponents.append(component);
- d->m_componentHash[component->name()] = component;
+ if (runMode == AllMode)
+ d->m_rootComponents.append(component);
+ else
+ d->m_updaterComponents.append(component);
emit componentAdded(component);
}
-int Installer::componentCount(RunModes runMode) const
+/*!
+ Returns a component matching \a name. \a name can also contains a version requirement.
+ E.g. "com.nokia.sdk.qt" returns any component with that name, "com.nokia.sdk.qt->=4.5" requires
+ the returned component to have at least version 4.5.
+ If no component matches the requirement, 0 is returned.
+*/
+Component* Installer::componentByName(const QString &name) const
{
- if (runMode == UpdaterMode)
- return d->m_packageManagerComponents.size();
- return d->m_rootComponents.size();
-}
+ if (name.isEmpty())
+ return 0;
-Component *Installer::component(int i, RunModes runMode) const
-{
- if (runMode == UpdaterMode)
- return d->m_packageManagerComponents.at(i);
- return d->m_rootComponents.at(i);
-}
+ if (name.contains(QChar::fromLatin1('-'))) {
+ // the last part is considered to be the version, then
+ const QString version = name.section(QLatin1Char('-'), 1);
+ return subComponentByName(this, name.section(QLatin1Char('-'), 0, 0), version);
+ }
-Component *Installer::component(const QString &name) const
-{
- return d->m_componentHash.contains(name) ? d->m_componentHash[name] : 0;
+ return subComponentByName(this, name);
}
-QList<Component*> Installer::components(bool recursive, RunModes runMode) const
+QList<Component*> Installer::components(bool recursive, RunMode runMode) const
{
if (runMode == UpdaterMode)
- return d->m_packageManagerComponents;
+ return d->m_updaterComponents;
if (!recursive)
return d->m_rootComponents;
QList<Component*> result;
- QList<Component*>::const_iterator it;
- for (it = d->m_rootComponents.begin(); it != d->m_rootComponents.end(); ++it) {
- result.push_back(*it);
- result += (*it)->components(true);
- }
-
- if (runMode == AllMode) {
- for (it = d->m_updaterComponents.begin(); it != d->m_updaterComponents.end(); ++it) {
- result.push_back(*it);
- result += (*it)->components(false);
- }
+ foreach (QInstaller::Component *component, d->m_rootComponents) {
+ result.push_back(component);
+ result += component->childComponents(true, runMode);
}
return result;
}
-QList<Component*> Installer::componentsToInstall(bool recursive, bool sort, RunModes runMode) const
+QList<Component*> Installer::componentsToInstall(RunMode runMode) const
{
- QList<Component*> availableComponents = components(recursive, runMode);
- if (sort) {
- std::sort(availableComponents.begin(), availableComponents.end(),
- Component::PriorityLessThan());
- }
+ QList<Component*> availableComponents = components(true, runMode);
+ std::sort(availableComponents.begin(), availableComponents.end(),
+ Component::InstallPriorityLessThan());
- QList<Component*>::const_iterator it;
QList<Component*> componentsToInstall;
- for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
- Component* const comp = *it;
- if (!comp->isSelected(runMode))
+ foreach (QInstaller::Component *component, availableComponents) {
+ if (!component->installationRequested())
continue;
-
- // it was already installed before, so don't add it
- if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed")
- && runMode == InstallerMode) // TODO: is the last condition right ????
- continue;
-
- appendComponentAndMissingDependencies(componentsToInstall, comp);
+ appendComponentAndMissingDependencies(componentsToInstall, component);
}
return componentsToInstall;
}
-static bool componentMatches(const Component *component, const QString &name,
- const QString& version = QString())
-{
- if (!name.isEmpty() && component->name() != name)
- return false;
-
- if (version.isEmpty())
- return true;
-
- return Installer::versionMatches(component->value(QLatin1String("Version")), version);
-}
-
-static Component* subComponentByName(const Installer *installer, const QString &name,
- const QString &version = QString(), Component *check = 0)
-{
- if (check != 0 && componentMatches(check, name, version))
- return check;
-
- const QList<Component*> comps = check == 0 ? installer->components() : check->components();
- for (QList<Component*>::const_iterator it = comps.begin(); it != comps.end(); ++it) {
- Component* const result = subComponentByName(installer, name, version, *it);
- if (result != 0)
- return result;
- }
-
- const QList<Component*> uocomps =
- check == 0 ? installer->components(false, UpdaterMode) : check->components(false, UpdaterMode);
- for (QList<Component*>::const_iterator it = uocomps.begin(); it != uocomps.end(); ++it) {
- Component* const result = subComponentByName(installer, name, version, *it);
- if (result != 0)
- return result;
- }
-
- return 0;
-}
-
-void Installer::setLinearComponentList(bool showlinear)
-{
- d->linearComponentList = showlinear;
-}
-
-bool Installer::hasLinearComponentList() const
-{
- return d->linearComponentList;
-}
-
-/*!
- Returns a component matching \a name. \a name can also contains a version requirement.
- E.g. "com.nokia.sdk.qt" returns any component with that name, "com.nokia.sdk.qt->=4.5" requires
- the returned component to have at least version 4.5.
- If no component matches the requirement, 0 is returned.
-*/
-Component* Installer::componentByName(const QString &name) const
-{
- if (name.contains(QChar::fromLatin1('-'))) {
- // the last part is considered to be the version, then
- const QString version = name.section(QLatin1Char('-'), 1);
- return subComponentByName(this, name.section(QLatin1Char('-'), 0, 0), version);
- }
-
- QHash< QString, QInstaller::Component* >::ConstIterator it = d->m_componentHash.constFind(name);
- Component * comp = 0;
- if (it != d->m_componentHash.constEnd())
- comp = *it;
- if (d->m_updaterComponents.contains(comp))
- return comp;
-
- return subComponentByName(this, name);
-}
-
/*!
Returns a list of packages depending on \a component.
*/
QList<Component*> Installer::dependees(const Component *component) const
{
- QList<Component*> result;
+ QList<Component*> allComponents = components(true, runMode());
+ if (runMode() == UpdaterMode)
+ allComponents += d->m_updaterComponentsDeps;
- const QList<Component*> allComponents = components(true, AllMode);
- for (QList<Component*>::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it) {
- Component* const c = *it;
-
- const QStringList deps = c->value(QString::fromLatin1("Dependencies"))
+ QList<Component*> result;
+ foreach (Component *comp, allComponents) {
+ const QStringList dependencies = comp->value(QString::fromLatin1("Dependencies"))
.split(QChar::fromLatin1(','), QString::SkipEmptyParts);
const QLatin1Char dash('-');
- for (QStringList::const_iterator it2 = deps.begin(); it2 != deps.end(); ++it2) {
+ foreach (const QString &dependency, dependencies) {
// the last part is considered to be the version, then
- const QString id = it2->contains(dash) ? it2->section(dash, 0, 0) : *it2;
- const QString version = it2->contains(dash) ? it2->section(dash, 1) : QString();
- if (componentMatches(component, id, version))
- result.push_back(c);
+ const QString name = dependency.contains(dash) ? dependency.section(dash, 0, 0) : dependency;
+ const QString version = dependency.contains(dash) ? dependency.section(dash, 1) : QString();
+ if (componentMatches(component, name, version))
+ result.append(comp);
}
}
return result;
}
-InstallerSettings Installer::settings() const
-{
- return d->m_settings;
-}
-
-/*!
- Returns a list of dependencies for \a component.
- If there's a dependency which cannot be fullfilled, the list contains 0 values.
-*/
-QList<Component*> Installer::dependencies(const Component *component,
- QStringList *missingPackageNames) const
-{
- QList<Component*> result;
- const QStringList deps = component->value(QString::fromLatin1("Dependencies"))
- .split(QChar::fromLatin1(','), QString::SkipEmptyParts);
-
- for (QStringList::const_iterator it = deps.begin(); it != deps.end(); ++it) {
- const QString name = *it;
- Component* comp = componentByName(*it);
- if (!comp && missingPackageNames)
- missingPackageNames->append(name);
- else
- result.push_back(comp);
- }
- return result;
-}
-
/*!
Returns the list of all missing (not installed) dependencies for \a component.
*/
QList<Component*> Installer::missingDependencies(const Component *component) const
{
- QList<Component*> result;
- const QStringList deps = component->value(QString::fromLatin1("Dependencies"))
+ QList<Component*> allComponents = components(true, runMode());
+ if (runMode() == UpdaterMode)
+ allComponents += d->m_updaterComponentsDeps;
+
+ const QStringList dependencies = component->value(QString::fromLatin1("Dependencies"))
.split(QChar::fromLatin1(','), QString::SkipEmptyParts);
+ QList<Component*> result;
const QLatin1Char dash('-');
- for (QStringList::const_iterator it = deps.begin(); it != deps.end(); ++it) {
- const bool containsVersionString = it->contains(dash);
- const QString version = containsVersionString ? it->section(dash, 1) : QString();
- const QString name = containsVersionString ? it->section(dash, 0, 0) : *it;
+ foreach (const QString &dependency, dependencies) {
+ const bool hasVersionString = dependency.contains(dash);
+ const QString name = hasVersionString ? dependency.section(dash, 0, 0) : dependency;
bool installed = false;
- const QList<Component*> compList = components(true);
- foreach (const Component* comp, compList) {
- if (!name.isEmpty() && comp->name() == name && !version.isEmpty()) {
- if (Installer::versionMatches(comp->value(QLatin1String("InstalledVersion")), version))
- installed = true;
- } else if (comp->name() == name) {
- installed = true;
- }
- }
-
- foreach (const Component *comp, d->m_updaterComponents) {
- if (!name.isEmpty() && comp->name() == name && !version.isEmpty()) {
- if (Installer::versionMatches(comp->value(QLatin1String("InstalledVersion")), version))
+ foreach (Component *comp, allComponents) {
+ if (comp->name() == name) {
+ if (hasVersionString) {
+ const QString version = dependency.section(dash, 1);
+ if (Installer::versionMatches(comp->value(QLatin1String("InstalledVersion")), version))
+ installed = true;
+ } else if (comp->isInstalled()) {
installed = true;
- } else if (comp->name() == name) {
- installed = true;
+ }
}
}
if (!installed) {
- if (Component *comp = componentByName(name))
- result.push_back(comp);
+ if (Component *comp = componentByName(dependency))
+ result.append(comp);
}
}
return result;
}
/*!
+ Returns a list of dependencies for \a component. If there's a dependency which cannot be fulfilled,
+ \a missingComponents will contain the missing components.
+*/
+QList<Component*> Installer::dependencies(const Component *component, QStringList &missingComponents) const
+{
+ QList<Component*> result;
+ const QStringList dependencies = component->value(QString::fromLatin1("Dependencies"))
+ .split(QChar::fromLatin1(','), QString::SkipEmptyParts);
+
+ foreach (const QString &dependency, dependencies) {
+ Component *component = componentByName(dependency);
+ if (component)
+ result.append(component);
+ else
+ missingComponents.append(dependency);
+ }
+ return result;
+}
+
+const InstallerSettings &Installer::settings() const
+{
+ return d->m_installerSettings;
+}
+
+/*!
This method tries to gain admin rights. On success, it returns true.
*/
bool Installer::gainAdminRights()
@@ -3032,8 +1215,8 @@ bool Installer::gainAdminRights()
if (AdminAuthorization::hasAdminRights())
return true;
- d->engineClientHandler->setActive(true);
- if (!d->engineClientHandler->isActive())
+ d->m_FSEngineClientHandler->setActive(true);
+ if (!d->m_FSEngineClientHandler->isActive())
throw Error(QObject::tr("Error while elevating access rights."));
return true;
}
@@ -3043,32 +1226,16 @@ bool Installer::gainAdminRights()
*/
void Installer::dropAdminRights()
{
- d->engineClientHandler->setActive(false);
+ d->m_FSEngineClientHandler->setActive(false);
}
/*!
- Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive.
+ Return true, if a process with \a name is running. On Windows, the comparison
+ is case-insensitive.
*/
bool Installer::isProcessRunning(const QString &name) const
{
- QList<KDSysInfo::ProcessInfo>::const_iterator it;
- const QList<KDSysInfo::ProcessInfo> processes = KDSysInfo::runningProcesses();
- for (it = processes.begin(); it != processes.end(); ++it) {
-#ifndef Q_WS_WIN
- if (it->name == name)
- return true;
- const QFileInfo fi(it->name);
- if (fi.fileName() == name || fi.baseName() == name)
- return true;
-#else
- if (it->name.toLower() == name.toLower())
- return true;
- const QFileInfo fi(it->name);
- if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower())
- return true;
-#endif
- }
- return false;
+ return InstallerPrivate::isProcessRunning(name, KDSysInfo::runningProcesses());
}
/*!
@@ -3081,11 +1248,16 @@ bool Installer::isProcessRunning(const QString &name) const
command as first item, the return code as second item.
\note On Unix, the output is just the output to stdout, not to stderr.
*/
+
QList<QVariant> Installer::execute(const QString &program, const QStringList &arguments,
const QString &stdIn) const
{
- QProcess p;
+ QEventLoop loop;
+ QProcessWrapper p;
+
+ connect(&p, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
p.start(program, arguments, stdIn.isNull() ? QIODevice::ReadOnly : QIODevice::ReadWrite);
+
if (!p.waitForStarted())
return QList< QVariant >();
@@ -3094,9 +1266,8 @@ QList<QVariant> Installer::execute(const QString &program, const QStringList &ar
p.closeWriteChannel();
}
- QEventLoop loop;
- connect(&p, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
- loop.exec();
+ if (p.state() != QProcessWrapper::NotRunning)
+ loop.exec();
return QList< QVariant >() << QString::fromLatin1(p.readAllStandardOutput()) << p.exitCode();
}
@@ -3121,7 +1292,7 @@ QString Installer::environmentVariable(const QString &name) const
}
/*!
- Instantly performns an operation \a name with \a arguments.
+ Instantly performs an operation \a name with \a arguments.
\sa Component::addOperation
*/
bool Installer::performOperation(const QString &name, const QStringList &arguments)
@@ -3133,8 +1304,8 @@ bool Installer::performOperation(const QString &name, const QStringList &argumen
op->setArguments(arguments);
op->backup();
- if (!performOperationThreaded(op.data())) {
- performOperationThreaded(op.data(), Undo);
+ if (!InstallerPrivate::performOperationThreaded(op.data())) {
+ InstallerPrivate::performOperationThreaded(op.data(), InstallerPrivate::Undo);
return false;
}
return true;
@@ -3142,7 +1313,7 @@ bool Installer::performOperation(const QString &name, const QStringList &argumen
/*!
Returns true when \a version matches the \a requirement.
- \a requirement can be a fixed version number or it can be prefix by the comparaters '>', '>=',
+ \a requirement can be a fixed version number or it can be prefix by the comparators '>', '>=',
'<', '<=' and '='.
*/
bool Installer::versionMatches(const QString &version, const QString &requirement)
@@ -3178,26 +1349,18 @@ QString Installer::findLibrary(const QString &name, const QStringList &pathes)
QStringList findPathes = pathes;
#if defined(Q_WS_WIN)
return findPath(QString::fromLatin1("%1.lib").arg(name), findPathes);
-#elif defined(Q_WS_MAC)
+#else
if (findPathes.isEmpty()) {
findPathes.push_back(QLatin1String("/lib"));
findPathes.push_back(QLatin1String("/usr/lib"));
findPathes.push_back(QLatin1String("/usr/local/lib"));
findPathes.push_back(QLatin1String("/opt/local/lib"));
}
-
+#if defined(Q_WS_MAC)
const QString dynamic = findPath(QString::fromLatin1("lib%1.dylib").arg(name), findPathes);
- if (!dynamic.isEmpty())
- return dynamic;
- return findPath(QString::fromLatin1("lib%1.a").arg(name), findPathes);
#else
- if (findPathes.isEmpty()) {
- findPathes.push_back(QLatin1String("/lib"));
- findPathes.push_back(QLatin1String("/usr/lib"));
- findPathes.push_back(QLatin1String("/usr/local/lib"));
- findPathes.push_back(QLatin1String("/opt/local/lib"));
- }
const QString dynamic = findPath(QString::fromLatin1("lib%1.so*").arg(name), findPathes);
+#endif
if (!dynamic.isEmpty())
return dynamic;
return findPath(QString::fromLatin1("lib%1.a").arg(name), findPathes);
@@ -3211,8 +1374,8 @@ QString Installer::findLibrary(const QString &name, const QStringList &pathes)
*/
QString Installer::findPath(const QString &name, const QStringList &pathes)
{
- for (QStringList::const_iterator it = pathes.begin(); it != pathes.end(); ++it) {
- const QDir dir(*it);
+ foreach (const QString &path, pathes) {
+ const QDir dir(path);
const QStringList entries = dir.entryList(QStringList() << name, QDir::Files | QDir::Hidden);
if (entries.isEmpty())
continue;
@@ -3230,7 +1393,7 @@ QString Installer::findPath(const QString &name, const QStringList &pathes)
void Installer::setInstallerBaseBinary(const QString &path)
{
d->m_forceRestart = true;
- d->installerBaseBinaryUnreplaced = path;
+ d->m_installerBaseBinaryUnreplaced = path;
}
/*!
@@ -3244,7 +1407,7 @@ QString Installer::value(const QString &key, const QString &defaultValue) const
static const QRegExp regex(QLatin1String("\\\\|/"));
const QString filename = key.section(regex, 0, -2);
const QString regKey = key.section(regex, -1);
- const QSettings registry(filename, QSettings::NativeFormat);
+ const QSettingsWrapper registry(filename, QSettingsWrapper::NativeFormat);
if (!filename.isEmpty() && !regKey.isEmpty() && registry.contains(regKey))
return registry.value(regKey).toString();
}
@@ -3253,8 +1416,7 @@ QString Installer::value(const QString &key, const QString &defaultValue) const
const QString dir = d->m_vars.value(key, defaultValue);
if (dir.startsWith(QLatin1String("~/")))
return QDir::home().absoluteFilePath(dir.mid(2));
- else
- return dir;
+ return dir;
}
#endif
return d->m_vars.value(key, defaultValue);
@@ -3300,35 +1462,33 @@ void Installer::setVerbose(bool on)
QInstaller::setVerbose(on);
}
-int Installer::status() const
+Installer::Status Installer::status() const
{
- return d->m_status;
+ return Installer::Status(d->m_status);
}
/*!
- returns true if at least one complete installation/update
- was successfull, even if the user cancelled the newest
- installation process.
+ Returns true if at least one complete installation/update was successful, even if the user cancelled the
+ newest installation process.
*/
bool Installer::finishedWithSuccess() const
{
- return (d->m_status == InstallerSucceeded) || d->m_needToWriteUninstaller;
+ return (d->m_status == Installer::Success) || d->m_needToWriteUninstaller;
}
void Installer::interrupt()
{
- verbose() << "INTERRUPT INSTALLER" << std::endl;
- d->setStatus(InstallerCanceledByUser);
+ setCanceled();
emit installationInterrupted();
}
void Installer::setCanceled()
{
- d->setStatus(InstallerCanceledByUser);
+ d->setStatus(Installer::Canceled);
+ emit cancelMetaInfoJob();
}
/*!
- Replaces all variables within \a str by their respective values and
- returns the result.
+ Replaces all variables within \a str by their respective values and returns the result.
*/
QString Installer::replaceVariables(const QString &str) const
{
@@ -3336,23 +1496,21 @@ QString Installer::replaceVariables(const QString &str) const
}
/*!
- Replaces all variables in any of \a str by their respective values and
- returns the results.
\overload
+ Replaces all variables in any of \a str by their respective values and returns the results.
*/
QStringList Installer::replaceVariables(const QStringList &str) const
{
QStringList result;
- for (QStringList::const_iterator it = str.begin(); it != str.end(); ++it)
- result.push_back(d->replaceVariables(*it));
+ foreach (const QString &s, str)
+ result.push_back(d->replaceVariables(s));
return result;
}
/*!
- Replaces all variables within \a ba by their respective values and
- returns the result.
\overload
+ Replaces all variables within \a ba by their respective values and returns the result.
*/
QByteArray Installer::replaceVariables(const QByteArray &ba) const
{
@@ -3376,43 +1534,52 @@ bool Installer::isInstaller() const
}
/*!
- Returns true when this is the uninstaller running.
+ Returns true if this is an offline-only installer.
*/
-bool Installer::isUninstaller() const
+bool Installer::isOfflineOnly() const
{
- return d->isUninstaller();
+ QSettingsWrapper confInternal(QLatin1String(":/config/config-internal.ini"), QSettingsWrapper::IniFormat);
+ return confInternal.value(QLatin1String("offlineOnly")).toBool();
+}
+
+void Installer::setUninstaller()
+{
+ d->m_magicBinaryMarker = QInstaller::MagicUninstallerMarker;
}
/*!
- Returns true when this is the package manager running.
+ Returns true when this is the uninstaller running.
*/
-bool Installer::isPackageManager() const
+bool Installer::isUninstaller() const
{
- return d->isPackageManager();
+ return d->isUninstaller();
}
+void Installer::setUpdater()
+{
+ d->m_magicBinaryMarker = QInstaller::MagicUpdaterMarker;
+}
/*!
- Returns true if this is an offline-only installer.
+ Returns true when this is neither an installer nor an uninstaller running.
+ Must be an updater, then.
*/
-bool Installer::isOfflineOnly() const
+bool Installer::isUpdater() const
{
- QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
- return confInternal.value(QLatin1String("offlineOnly")).toBool();
+ return d->isUpdater();
}
void Installer::setPackageManager()
{
- d->packageManagingMode = true;
+ d->m_magicBinaryMarker = QInstaller::MagicPackageManagerMarker;
}
/*!
- Returns thrue when this is neither an installer nor an uninstaller running.
- Must be an updater, then.
+ Returns true when this is the package manager running.
*/
-bool Installer::isUpdater() const
+bool Installer::isPackageManager() const
{
- return !d->isInstaller() && !d->isUninstaller();
+ return d->isPackageManager();
}
/*!
@@ -3460,13 +1627,13 @@ bool Installer::runPackageUpdater()
*/
void Installer::languageChanged()
{
- const QList<Component*> comps = components(true);
+ const QList<Component*> comps = components(true, runMode());
foreach (Component* component, comps)
component->languageChanged();
}
/*!
- Runs the installer or uninstaller, depending on the type of this binary.
+ Runs the installer, un-installer, updater or package manager, depending on the type of this binary.
*/
bool Installer::run()
{
@@ -3475,7 +1642,7 @@ bool Installer::run()
d->runInstaller();
else if (isUninstaller())
d->runUninstaller();
- else if (isPackageManager())
+ else if (isPackageManager() || isUpdater())
d->runPackageUpdater();
return true;
} catch (const Error &err) {
@@ -3485,7 +1652,7 @@ bool Installer::run()
}
/*!
- Returns the path name of the ininstaller binary.
+ Returns the path name of the uninstaller binary.
*/
QString Installer::uninstallerName() const
{
@@ -3497,7 +1664,7 @@ bool Installer::setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packages
packagesInfo.setFileName(d->localComponentsXmlPath());
const QString localComponentsXml = d->localComponentsXmlPath();
- // handle errors occured by loading components.xml
+ // handle errors occurred by loading components.xml
QFileInfo componentFileInfo(localComponentsXml);
int silentRetries = d->m_silentRetries;
while (!componentFileInfo.exists()) {
@@ -3505,7 +1672,7 @@ bool Installer::setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packages
--silentRetries;
} else {
Status status = handleComponentsFileSetOrParseError(localComponentsXml);
- if (status == InstallerCanceledByUser)
+ if (status == Installer::Canceled)
return false;
}
packagesInfo.setFileName(localComponentsXml);
@@ -3517,7 +1684,7 @@ bool Installer::setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packages
--silentRetries;
} else {
Status status = handleComponentsFileSetOrParseError(localComponentsXml);
- if (status == InstallerCanceledByUser)
+ if (status == Installer::Canceled)
return false;
}
packagesInfo.setFileName(localComponentsXml);
@@ -3535,7 +1702,7 @@ bool Installer::setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packages
}
Status status = handleComponentsFileSetOrParseError(componentFileInfo.fileName(),
packagesInfo.errorString(), retry);
- if (status == InstallerCanceledByUser)
+ if (status == Installer::Canceled)
return false;
}
packagesInfo.setFileName(localComponentsXml);
@@ -3558,10 +1725,56 @@ Installer::Status Installer::handleComponentsFileSetOrParseError(const QString &
buttons);
if (button == QMessageBox::Cancel) {
- d->m_status = InstallerFailed;
- return InstallerCanceledByUser;
+ d->m_status = Installer::Failure;
+ return Installer::Canceled;
}
- return InstallerUnfinished;
+ return Installer::Unfinished;
}
-#include "qinstaller.moc"
+bool Installer::updateComponentData(struct Data &data, Component *component)
+{
+ try {
+ const QString name = data.package->data(QLatin1String("Name")).toString();
+ if (data.components->contains(name)) {
+ qCritical("Could not register component! Component with identifier %s already registered.",
+ qPrintable(name));
+ return false;
+ }
+
+ if (!data.installedPackages->contains(name)) {
+ const QString replaces = data.package->data(QLatin1String("Replaces")).toString();
+ if (!replaces.isEmpty() && runMode() == AllMode) {
+ const QStringList components = replaces.split(QLatin1String(","), QString::SkipEmptyParts);
+ foreach (const QString &componentName, components) {
+ if (data.installedPackages->contains(componentName)) {
+ component->setInstalled();
+ component->setValue(QLatin1String("InstalledVersion"),
+ data.package->data(QLatin1String("Version")).toString());
+ data.componentsToReplace.append(components);
+ break; // break as soon as we know we replace at least one other component
+ } else {
+ component->setUninstalled();
+ }
+ }
+ } else {
+ component->setUninstalled();
+ }
+ } else {
+ component->setInstalled();
+ component->setValue(QLatin1String("InstalledVersion"), data.installedPackages->value(name).version);
+ }
+
+ const QString &localPath = component->localTempPath();
+ if (isVerbose()) {
+ static QString lastLocalPath;
+ if (lastLocalPath != localPath)
+ verbose() << "Url is : " << localPath << std::endl;
+ lastLocalPath = localPath;
+ }
+ component->setRepositoryUrl(data.metaInfoJob->repositoryForTemporaryDirectory(localPath).url());
+ } catch (...) {
+ return false;
+ }
+
+ return true;
+}
diff --git a/installerbuilder/libinstaller/qinstaller.h b/installerbuilder/libinstaller/qinstaller.h
index f8a34e118..a46cdfcf8 100644
--- a/installerbuilder/libinstaller/qinstaller.h
+++ b/installerbuilder/libinstaller/qinstaller.h
@@ -26,6 +26,11 @@
#ifndef QINSTALLER_H
#define QINSTALLER_H
+#include "common/repository.h"
+#include "qinstallerglobal.h"
+
+#include <KDUpdater/KDUpdater>
+
#include <QtCore/QAbstractItemModel>
#include <QtCore/QObject>
#include <QtCore/QStringList>
@@ -37,10 +42,6 @@
#include <QtScript/QScriptable>
#include <QtScript/QScriptValue>
-#include "common/repository.h"
-
-#include "installer_global.h"
-
namespace KDUpdater {
class Application;
class PackagesInfo;
@@ -48,9 +49,11 @@ namespace KDUpdater {
class UpdateOperation;
}
+QT_BEGIN_NAMESPACE
class QDir;
class QFile;
class QIODevice;
+QT_END_NAMESPACE
class KDJob;
@@ -63,6 +66,7 @@ namespace QInstaller {
class Component;
class GetRepositoriesMetaInfoJob;
+class InstallerPrivate;
class InstallerSettings;
class MessageBoxHandler;
@@ -70,19 +74,53 @@ class INSTALLER_EXPORT Installer : public QObject
{
Q_OBJECT
- Q_PROPERTY(int status READ status NOTIFY statusChanged)
Q_ENUMS(Status WizardPage)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
public:
Installer();
- explicit Installer(qint64 magicmaker,
- const QVector<KDUpdater::UpdateOperation*> &performedOperations
+ explicit Installer(qint64 magicmaker, const QVector<KDUpdater::UpdateOperation*> &performedOperations
= QVector< KDUpdater::UpdateOperation*>());
~Installer();
- void writeUninstaller();
+ // status
+ enum Status {
+ Success = EXIT_SUCCESS,
+ Failure = EXIT_FAILURE,
+ Running,
+ Canceled,
+ Unfinished
+ };
+ Status status() const;
+
+ enum WizardPage {
+ Introduction = 0x1000,
+ TargetDirectory = 0x2000,
+ ComponentSelection = 0x3000,
+ LicenseCheck = 0x4000,
+ StartMenuSelection = 0x5000,
+ ReadyForInstallation = 0x6000,
+ PerformInstallation = 0x7000,
+ InstallationFinished = 0x8000,
+ End = 0xffff
+ };
+
+ static QFont virtualComponentsFont();
+ static void setVirtualComponentsFont(const QFont &font);
+
+ static bool virtualComponentsVisible();
+ static void setVirtualComponentsVisible(bool visible);
+
+ QHash<QString, KDUpdater::PackageInfo> localInstalledPackages();
+ GetRepositoriesMetaInfoJob* fetchMetaInformation(const InstallerSettings &settings);
+ bool addUpdateResourcesFrom(GetRepositoriesMetaInfoJob *metaInfoJob, const InstallerSettings &settings,
+ bool parseChecksum);
+
+ bool fetchAllPackages();
+ bool fetchUpdaterPackages();
bool run();
+ RunMode runMode() const;
void reset(const QHash<QString, QString> &params);
Q_INVOKABLE QList<QVariant> execute(const QString &program,
@@ -104,31 +142,26 @@ public:
Q_INVOKABLE bool containsValue(const QString &key) const;
//a way to have global flags share able from a component script to another one
- Q_INVOKABLE void setSharedFlag(const QString &key, bool value = true);
Q_INVOKABLE bool sharedFlag(const QString &key) const;
+ Q_INVOKABLE void setSharedFlag(const QString &key, bool value = true);
QString replaceVariables(const QString &str) const;
- QStringList replaceVariables(const QStringList &str) const;
QByteArray replaceVariables(const QByteArray &str) const;
- QString installerBinaryPath() const;
- QString uninstallerName() const;
+ QStringList replaceVariables(const QStringList &str) const;
- bool isRemoteRepositoryMetaInfoRetrieved() const;
+ void writeUninstaller();
+ QString uninstallerName() const;
+ QString installerBinaryPath() const;
+ bool testChecksum() const;
void setTestChecksum(bool test);
- bool testChecksum();
KDUpdater::Application &updaterApplication() const;
void setUpdaterApplication(KDUpdater::Application *app);
- void setRemoteRepositories(const QList<Repository> &repositories);
+ void addRepositories(const QList<Repository> &repositories);
void setTemporaryRepositories(const QList<Repository> &repositories, bool replace = false);
- void createComponentsV2(const QList<KDUpdater::Update*> &updates,
- const GetRepositoriesMetaInfoJob& metaInfoJob);
- void createComponents(const QList<KDUpdater::Update*> &updates,
- const GetRepositoriesMetaInfoJob& metaInfoJob);
-
Q_INVOKABLE void autoAcceptMessageBoxes();
Q_INVOKABLE void autoRejectMessageBoxes();
Q_INVOKABLE void setMessageBoxAutomaticAnswer(const QString &identifier, int button);
@@ -137,28 +170,30 @@ public:
public:
// component handling
- void appendComponent(Component *components);
- int componentCount(RunModes runMode = InstallerMode) const;
- Component *component(int i, RunModes runMode = InstallerMode) const;
- Component *component(const QString &name) const;
- QList<Component*> components(bool recursive = false, RunModes runMode = InstallerMode) const;
- QList<Component*> componentsToInstall(bool recursive = false, bool sort = true,
- RunModes runMode = InstallerMode) const;
+ int rootComponentCount(RunMode runMode) const;
+ Component *rootComponent(int i, RunMode runMode) const;
+ void appendRootComponent(Component *components, RunMode runMode);
Component *componentByName(const QString &identifier) const;
- QList<Component*> dependencies(const Component *component,
- QStringList *missingPackageNames = 0) const;
- QList<Component*> missingDependencies (const Component *component) const;
+ QList<Component*> components(bool recursive, RunMode runMode) const;
+ QList<Component*> componentsToInstall(RunMode runMode) const;
+
QList<Component*> dependees(const Component *component) const;
+ QList<Component*> missingDependencies(const Component *component) const;
+ QList<Component*> dependencies(const Component *component, QStringList &missingComponents) const;
// convenience
Q_INVOKABLE bool isInstaller() const;
+ Q_INVOKABLE bool isOfflineOnly() const;
+
+ Q_INVOKABLE void setUninstaller();
Q_INVOKABLE bool isUninstaller() const;
+
+ Q_INVOKABLE void setUpdater();
Q_INVOKABLE bool isUpdater() const;
- Q_INVOKABLE bool isPackageManager() const;
- Q_INVOKABLE bool isOfflineOnly() const;
- void setPackageManager();
+ Q_INVOKABLE void setPackageManager();
+ Q_INVOKABLE bool isPackageManager() const;
bool isVerbose() const;
void setVerbose(bool on);
@@ -171,29 +206,7 @@ public:
Q_INVOKABLE bool isProcessRunning(const QString &name) const;
- InstallerSettings settings() const;
-
- // status
- enum Status {
- InstallerUnfinished,
- InstallerCanceledByUser,
- InstallerRunning,
- InstallerFailed,
- InstallerSucceeded,
- };
- int status() const;
-
- enum WizardPage {
- Introduction = 0x1000,
- TargetDirectory = 0x2000,
- ComponentSelection = 0x3000,
- LicenseCheck = 0x4000,
- StartMenuSelection = 0x5000,
- ReadyForInstallation = 0x6000,
- PerformInstallation = 0x7000,
- InstallationFinished = 0x8000,
- End = 0xffff
- };
+ const InstallerSettings &settings() const;
Q_INVOKABLE bool addWizardPage(QInstaller::Component *component, const QString &name, int page);
Q_INVOKABLE bool removeWizardPage(QInstaller::Component *component, const QString &name);
@@ -204,15 +217,11 @@ public:
void installSelectedComponents();
void rollBackInstallation();
- int downloadNeededArchives(RunModes runMode, double partProgressSize/* = double(1)/3 */);
- QList<Component*> calculateComponentOrder(RunModes runMode = InstallerMode) const;
- void installComponent(Component *comp, double progressOperationSize);
+ int downloadNeededArchives(RunMode runMode, double partProgressSize);
+ void installComponent(Component *component, double progressOperationSize);
- void setLinearComponentList(bool showlinear);
- bool hasLinearComponentList() const;
-
- bool finishedWithSuccess() const;
bool needsRestart() const;
+ bool finishedWithSuccess() const;
public Q_SLOTS:
bool runInstaller();
@@ -221,7 +230,6 @@ public Q_SLOTS:
void interrupt();
void setCanceled();
void languageChanged();
-
void setCompleteUninstallation(bool complete);
Q_SIGNALS:
@@ -234,6 +242,14 @@ Q_SIGNALS:
void currentPageChanged(int page);
void finishButtonClicked();
+ void cancelMetaInfoJob();
+ void metaJobInfoMessage(KDJob* job, const QString &message);
+
+ void startAllComponentsReset();
+ void finishAllComponentsReset();
+
+ void startUpdaterComponentsReset();
+ void finishUpdaterComponentsReset();
void installationStarted();
void installationInterrupted();
@@ -256,10 +272,20 @@ private:
Installer::Status handleComponentsFileSetOrParseError(const QString &arg1,
const QString &arg2 = QString(), bool withRetry = true);
+ struct Data {
+ KDUpdater::Update *package;
+ QStringList componentsToReplace;
+ QMap<QString, Component*> *components;
+ GetRepositoriesMetaInfoJob *metaInfoJob;
+ QHash<QString, KDUpdater::PackageInfo> *installedPackages;
+ };
+ bool updateComponentData(struct Data &data, QInstaller::Component *component);
+ static Component *subComponentByName(const QInstaller::Installer *installer, const QString &name,
+ const QString &version = QString(), Component *check = 0);
+
private:
- class Private;
- Private* const d;
- friend class Component;
+ InstallerPrivate* const d;
+ friend class InstallerPrivate;
};
}
diff --git a/installerbuilder/libinstaller/qinstaller_p.cpp b/installerbuilder/libinstaller/qinstaller_p.cpp
new file mode 100644
index 000000000..8cca59af5
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstaller_p.cpp
@@ -0,0 +1,1583 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qinstaller_p.h"
+
+#include "adminauthorization.h"
+#include "common/binaryformat.h"
+#include "common/errors.h"
+#include "common/fileutils.h"
+#include "common/utils.h"
+#include "fsengineclient.h"
+#include "messageboxhandler.h"
+#include "progresscoordinator.h"
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+#include "qprocesswrapper.h"
+#include "qsettingswrapper.h"
+
+#include <KDToolsCore/KDSaveFile>
+#include <KDToolsCore/KDSelfRestarter>
+
+#include <KDUpdater/KDUpdater>
+
+#include <QtCore/QtConcurrentRun>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFuture>
+#include <QtCore/QFutureWatcher>
+#include <QtCore/QTemporaryFile>
+
+#include <errno.h>
+
+namespace QInstaller {
+
+static bool runOperation(KDUpdater::UpdateOperation *op, InstallerPrivate::OperationType type)
+{
+ switch (type) {
+ case InstallerPrivate::Backup:
+ op->backup();
+ return true;
+ case InstallerPrivate::Perform:
+ return op->performOperation();
+ case InstallerPrivate::Undo:
+ return op->undoOperation();
+ default:
+ Q_ASSERT(!"unexpected operation type");
+ }
+ return false;
+}
+
+/*!
+ \internal
+ Initializes the created FSEngineClientHandler instance \a handler.
+*/
+static void initEngineHandler(/*QInstaller::*/FSEngineClientHandler *handler)
+{
+ const int port = 30000 + qrand() % 1000;
+ handler->init(port);
+ handler->setStartServerCommand(QCoreApplication::applicationFilePath(), QStringList()
+ << QLatin1String("--startserver") << QString::number(port) << handler->authorizationKey(),
+ true);
+}
+
+/*!
+ \internal
+ Creates and initializes a FSEngineClientHandler -> makes us get admin rights for QFile operations
+*/
+static /*QInstaller::*/FSEngineClientHandler* createEngineClientHandler()
+{
+ static FSEngineClientHandler* clientHandlerInstance = 0;
+ if (clientHandlerInstance == 0) {
+ clientHandlerInstance = new FSEngineClientHandler;
+ initEngineHandler(clientHandlerInstance);
+ }
+ return clientHandlerInstance;
+}
+
+static QStringList checkRunningProcessesFromList(const QStringList &processList)
+{
+ const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
+ QStringList stillRunningProcesses;
+ foreach (const QString &process, processList) {
+ if (!process.isEmpty() && InstallerPrivate::isProcessRunning(process, allProcesses))
+ stillRunningProcesses.append(process);
+ }
+ return stillRunningProcesses;
+}
+
+static void deferredRename(const QString &oldName, const QString &newName, bool restart = false)
+{
+#ifdef Q_OS_WIN
+ QStringList arguments;
+ {
+ QTemporaryFile f(QDir::temp().absoluteFilePath(QLatin1String("deferredrenameXXXXXX.vbs")));
+ openForWrite(&f, f.fileName());
+ f.setAutoRemove(false);
+
+ arguments << QDir::toNativeSeparators(f.fileName()) << QDir::toNativeSeparators(oldName)
+ << QDir::toNativeSeparators(QFileInfo(oldName).dir().absoluteFilePath(QFileInfo(newName)
+ .fileName()));
+
+ QTextStream batch(&f);
+ batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
+ batch << "Set tmp = WScript.CreateObject(\"WScript.Shell\")\n";
+ batch << QString::fromLatin1("file = \"%1\"\n").arg(arguments[2]);
+ batch << "on error resume next\n";
+
+ batch << "while fso.FileExists(file)\n";
+ batch << " fso.DeleteFile(file)\n";
+ batch << " WScript.Sleep(1000)\n";
+ batch << "wend\n";
+ batch << QString::fromLatin1("fso.MoveFile \"%1\", file\n").arg(arguments[1]);
+ if (restart)
+ batch << QString::fromLatin1("tmp.exec \"%1 --updater\"\n").arg(arguments[2]);
+ batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
+ }
+
+ QProcessWrapper::startDetached(QLatin1String("cscript"), QStringList() << QLatin1String("//Nologo")
+ << arguments[0]);
+#else
+ QFile::remove(newName);
+ QFile::rename(oldName, newName);
+ KDSelfRestarter::setRestartOnQuit(restart);
+#endif
+}
+
+
+// -- InstallerPrivate
+
+InstallerPrivate::InstallerPrivate()
+ : m_tempDirDeleter(0)
+ , m_FSEngineClientHandler(0)
+ , q(0)
+{
+}
+
+InstallerPrivate::InstallerPrivate(Installer *installer, qint64 magicInstallerMaker,
+ const QList<KDUpdater::UpdateOperation*> &performedOperations)
+ : m_app(0)
+ , m_tempDirDeleter(new TempDirDeleter())
+ , m_FSEngineClientHandler(createEngineClientHandler())
+ , m_status(Installer::Unfinished)
+ , m_forceRestart(false)
+ , m_silentRetries(3)
+ , m_testChecksum(false)
+ , m_launchedAsRoot(AdminAuthorization::hasAdminRights())
+ , m_completeUninstall(false)
+ , m_needToWriteUninstaller(false)
+ , m_performedOperationsOld(performedOperations)
+ , q(installer)
+ , m_magicBinaryMarker(magicInstallerMaker)
+{
+ connect(this, SIGNAL(installationStarted()), q, SIGNAL(installationStarted()));
+ connect(this, SIGNAL(installationFinished()), q, SIGNAL(installationFinished()));
+ connect(this, SIGNAL(uninstallationStarted()), q, SIGNAL(uninstallationStarted()));
+ connect(this, SIGNAL(uninstallationFinished()), q, SIGNAL(uninstallationFinished()));
+}
+
+InstallerPrivate::~InstallerPrivate()
+{
+ qDeleteAll(m_rootComponents);
+ qDeleteAll(m_updaterComponents);
+ qDeleteAll(m_updaterComponentsDeps);
+
+ qDeleteAll(m_ownedOperations);
+ qDeleteAll(m_performedOperationsOld);
+ qDeleteAll(m_performedOperationsCurrentSession);
+
+ // check for fake installer case
+ if (m_FSEngineClientHandler)
+ m_FSEngineClientHandler->setActive(false);
+
+
+ delete m_tempDirDeleter;
+ delete m_FSEngineClientHandler;
+}
+
+/*!
+ Return true, if a process with \a name is running. On Windows, comparison is case-insensitive.
+*/
+/* static */
+bool InstallerPrivate::isProcessRunning(const QString &name,
+ const QList<KDSysInfo::ProcessInfo> &processes)
+{
+ QList<KDSysInfo::ProcessInfo>::const_iterator it;
+ for (it = processes.constBegin(); it != processes.constEnd(); ++it) {
+ if (it->name.isEmpty())
+ continue;
+
+#ifndef Q_WS_WIN
+ if (it->name == name)
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName() == name || fi.baseName() == name)
+ return true;
+#else
+ if (it->name.toLower() == name.toLower())
+ return true;
+ if (it->name.toLower() == QDir::toNativeSeparators(name.toLower()))
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower())
+ return true;
+#endif
+ }
+ return false;
+}
+
+/* static */
+bool InstallerPrivate::performOperationThreaded(KDUpdater::UpdateOperation *op, OperationType type)
+{
+ QFutureWatcher<bool> futureWatcher;
+ const QFuture<bool> future = QtConcurrent::run(runOperation, op, type);
+
+ QEventLoop loop;
+ loop.connect(&futureWatcher, SIGNAL(finished()), SLOT(quit()), Qt::QueuedConnection);
+ futureWatcher.setFuture(future);
+
+ if (!future.isFinished())
+ loop.exec();
+
+ return future.result();
+}
+
+QString InstallerPrivate::targetDir() const
+{
+ return q->value(QLatin1String("TargetDir"));
+}
+
+QString InstallerPrivate::configurationFileName() const
+{
+ return q->value(QLatin1String("TargetConfigurationFile"), QString::fromLatin1("components.xml"));
+}
+
+QString InstallerPrivate::componentsXmlPath() const
+{
+ return QDir::toNativeSeparators(QDir(QDir::cleanPath(targetDir()))
+ .absoluteFilePath(configurationFileName()));
+}
+
+QString InstallerPrivate::localComponentsXmlPath() const
+{
+ const QString &appDirPath = QCoreApplication::applicationDirPath();
+ if (QFileInfo(appDirPath + QLatin1String("/../..")).isBundle()) {
+ return QDir::toNativeSeparators(QFileInfo(QDir::cleanPath(appDirPath
+ + QLatin1String("/../../../") + configurationFileName())).absoluteFilePath());
+ }
+ return componentsXmlPath();
+}
+
+void InstallerPrivate::initialize()
+{
+ try {
+ m_installerSettings = InstallerSettings(InstallerSettings::fromFileAndPrefix(QLatin1String
+ (":/metadata/installer-config/config.xml"), QLatin1String(":/metadata/installer-config/")));
+ } catch (const Error &e) {
+ qCritical("Could not parse Config: %s", qPrintable(e.message()));
+ // TODO: try better error handling
+ return;
+ }
+
+ // first set some common variables that may used e.g. as placeholder
+ // in some of the settings variables or in a script or...
+ m_vars.insert(QLatin1String("rootDir"), QDir::rootPath());
+ m_vars.insert(QLatin1String("homeDir"), QDir::homePath());
+
+#ifdef Q_WS_WIN
+ m_vars.insert(QLatin1String("os"), QLatin1String("win"));
+#elif defined(Q_WS_MAC)
+ m_vars.insert(QLatin1String("os"), QLatin1String("mac"));
+#elif defined(Q_WS_X11)
+ m_vars.insert(QLatin1String("os"), QLatin1String("x11"));
+#elif defined(Q_WS_QWS)
+ m_vars.insert(QLatin1String("os"), QLatin1String("Qtopia"));
+#else
+ // TODO: add more platforms as needed...
+#endif
+
+ // fill the variables defined in the settings
+ m_vars.insert(QLatin1String("ProductName"), m_installerSettings.applicationName());
+ m_vars.insert(QLatin1String("ProductVersion"), m_installerSettings.applicationVersion());
+ m_vars.insert(QLatin1String("Title"), m_installerSettings.title());
+ m_vars.insert(QLatin1String("MaintenanceTitle"), m_installerSettings.maintenanceTitle());
+ m_vars.insert(QLatin1String("Publisher"), m_installerSettings.publisher());
+ m_vars.insert(QLatin1String("Url"), m_installerSettings.url());
+ m_vars.insert(QLatin1String("StartMenuDir"), m_installerSettings.startMenuDir());
+
+ m_vars.insert(QLatin1String("TargetConfigurationFile"), m_installerSettings.configurationFileName());
+ m_vars.insert(QLatin1String("LogoPixmap"), m_installerSettings.logo());
+ m_vars.insert(QLatin1String("LogoSmallPixmap"), m_installerSettings.logoSmall());
+ m_vars.insert(QLatin1String("WatermarkPixmap"), m_installerSettings.watermark());
+
+ m_vars.insert(QLatin1String("RunProgram"), replaceVariables(m_installerSettings.runProgram()));
+ const QString desc = m_installerSettings.runProgramDescription();
+ if (!desc.isEmpty())
+ m_vars.insert(QLatin1String("RunProgramDescription"), desc);
+#ifdef Q_WS_X11
+ if (m_launchedAsRoot)
+ m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_installerSettings.adminTargetDir()));
+ else
+#endif
+ m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_installerSettings.targetDir()));
+ m_vars.insert(QLatin1String("RemoveTargetDir"), replaceVariables(m_installerSettings.removeTargetDir()));
+
+ QSettingsWrapper creatorSettings(QSettingsWrapper::IniFormat, QSettingsWrapper::UserScope,
+ QLatin1String("Nokia"), QLatin1String("QtCreator"));
+ QFileInfo info(creatorSettings.fileName());
+ if (info.exists())
+ m_vars.insert(QLatin1String("QtCreatorSettingsFile"), info.absoluteFilePath());
+
+ if (!q->isInstaller()) {
+#ifdef Q_WS_MAC
+ readUninstallerIniFile(QCoreApplication::applicationDirPath() + QLatin1String("/../../.."));
+#else
+ readUninstallerIniFile(QCoreApplication::applicationDirPath());
+#endif
+ }
+
+ foreach (KDUpdater::UpdateOperation *currentOperation, m_performedOperationsOld)
+ currentOperation->setValue(QLatin1String("installer"), QVariant::fromValue(q));
+
+ disconnect(this, SIGNAL(installationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+ connect(this, SIGNAL(installationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+ disconnect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+ connect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+}
+
+QString InstallerPrivate::installerBinaryPath() const
+{
+ return qApp->applicationFilePath();
+}
+
+bool InstallerPrivate::isInstaller() const
+{
+ return m_magicBinaryMarker == MagicInstallerMarker;
+}
+
+bool InstallerPrivate::isUninstaller() const
+{
+ return m_magicBinaryMarker == MagicUninstallerMarker;
+}
+
+bool InstallerPrivate::isUpdater() const
+{
+ return m_magicBinaryMarker == MagicUpdaterMarker;
+}
+
+bool InstallerPrivate::isPackageManager() const
+{
+ return m_magicBinaryMarker == MagicPackageManagerMarker;
+}
+
+bool InstallerPrivate::statusCanceledOrFailed() const
+{
+ return m_status == Installer::Canceled || m_status == Installer::Failure;
+}
+
+void InstallerPrivate::setStatus(int status)
+{
+ if (m_status != status) {
+ m_status = status;
+ emit q->statusChanged(Installer::Status(m_status));
+ }
+}
+
+QString InstallerPrivate::replaceVariables(const QString &str) const
+{
+ static const QChar at = QLatin1Char('@');
+ QString res;
+ int pos = 0;
+ while (true) {
+ const int pos1 = str.indexOf(at, pos);
+ if (pos1 == -1)
+ break;
+ const int pos2 = str.indexOf(at, pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += str.mid(pos, pos1 - pos);
+ const QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
+ res += q->value(name);
+ pos = pos2 + 1;
+ }
+ res += str.mid(pos);
+ return res;
+}
+
+QByteArray InstallerPrivate::replaceVariables(const QByteArray &ba) const
+{
+ static const QChar at = QLatin1Char('@');
+ QByteArray res;
+ int pos = 0;
+ while (true) {
+ const int pos1 = ba.indexOf(at, pos);
+ if (pos1 == -1)
+ break;
+ const int pos2 = ba.indexOf(at, pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += ba.mid(pos, pos1 - pos);
+ const QString name = QString::fromLocal8Bit(ba.mid(pos1 + 1, pos2 - pos1 - 1));
+ res += q->value(name).toLocal8Bit();
+ pos = pos2 + 1;
+ }
+ res += ba.mid(pos);
+ return res;
+}
+
+/*!
+ \internal
+ Creates an update operation owned by the installer, not by any component.
+ */
+KDUpdater::UpdateOperation* InstallerPrivate::createOwnedOperation(const QString &type)
+{
+ m_ownedOperations.append(KDUpdater::UpdateOperationFactory::instance().create(type));
+ return m_ownedOperations.last();
+}
+
+/*!
+ \internal
+ Removes \a opertion from the operations owned by the installer, returns the very same operation if the
+ operation was found, otherwise 0.
+ */
+KDUpdater::UpdateOperation* InstallerPrivate::takeOwnedOperation(KDUpdater::UpdateOperation *operation)
+{
+ if (!m_ownedOperations.contains(operation))
+ return 0;
+
+ m_ownedOperations.removeAll(operation);
+ return operation;
+}
+
+QString InstallerPrivate::uninstallerName() const
+{
+ QString filename = m_installerSettings.uninstallerName();
+#if defined(Q_WS_MAC)
+ if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())
+ filename += QLatin1String(".app/Contents/MacOS/") + filename;
+#elif defined(Q_OS_WIN)
+ filename += QLatin1String(".exe");
+#endif
+ return QString::fromLatin1("%1/%2").arg(targetDir()).arg(filename);
+}
+
+void InstallerPrivate::readUninstallerIniFile(const QString &targetDir)
+{
+ const QString iniPath = targetDir + QLatin1Char('/') + m_installerSettings.uninstallerIniFile();
+ QSettingsWrapper cfg(iniPath, QSettingsWrapper::IniFormat);
+ const QVariantHash vars = cfg.value(QLatin1String("Variables")).toHash();
+ QHash<QString, QVariant>::ConstIterator it = vars.constBegin();
+ while (it != vars.constEnd()) {
+ m_vars.insert(it.key(), it.value().toString());
+ ++it;
+ }
+
+ QList<Repository> repositories;
+ const QStringList list = cfg.value(QLatin1String("Repositories")).toStringList();
+ foreach (const QString &url, list)
+ repositories.append(Repository(url));
+ m_installerSettings.addUserRepositories(repositories);
+}
+
+void InstallerPrivate::stopProcessesForUpdates(const QList<Component*> &components)
+{
+ QStringList processList;
+ foreach (const Component* const i, components)
+ processList << q->replaceVariables(i->stopProcessForUpdateRequests());
+
+ qSort(processList);
+ processList.erase(std::unique(processList.begin(), processList.end()), processList.end());
+ if (processList.isEmpty())
+ return;
+
+ while (true) {
+ const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
+ const QStringList processes = checkRunningProcessesFromList(processList);
+ if (processes.isEmpty())
+ return;
+
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("stopProcessesForUpdates"), tr("Stop Processes"), tr("These processes "
+ "should be stopped to continue:\n\n%1").arg(QDir::toNativeSeparators(processes
+ .join(QLatin1String("\n")))), QMessageBox::Retry | QMessageBox::Ignore
+ | QMessageBox::Cancel, QMessageBox::Retry);
+ if (button == QMessageBox::Ignore)
+ return;
+ if (button == QMessageBox::Cancel) {
+ q->setCanceled();
+ throw Error(tr("Installation canceled by user"));
+ }
+ }
+}
+
+int InstallerPrivate::countProgressOperations(const QList<KDUpdater::UpdateOperation*> &operations)
+{
+ int operationCount = 0;
+ foreach (KDUpdater::UpdateOperation *operation, operations) {
+ if (QObject *operationObject = dynamic_cast<QObject*> (operation)) {
+ const QMetaObject *const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1)
+ operationCount++;
+ }
+ }
+ return operationCount;
+}
+
+int InstallerPrivate::countProgressOperations(const QList<Component*> &components)
+{
+ int operationCount = 0;
+ foreach (Component* component, components)
+ operationCount += countProgressOperations(component->operations());
+
+ return operationCount;
+}
+
+void InstallerPrivate::connectOperationToInstaller(KDUpdater::UpdateOperation *const operation,
+ double progressOperationPartSize)
+{
+ Q_ASSERT(progressOperationPartSize);
+ QObject* const operationObject = dynamic_cast< QObject* >(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) {
+ connect(operationObject, SIGNAL(outputTextChanged(QString)), ProgressCoordninator::instance(),
+ SLOT(emitDetailTextChanged(QString)));
+ }
+
+ if (mo->indexOfSlot(QMetaObject::normalizedSignature("cancelOperation()")) > -1)
+ connect(q, SIGNAL(installationInterrupted()), operationObject, SLOT(cancelOperation()));
+
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1) {
+ ProgressCoordninator::instance()->registerPartProgress(operationObject,
+ SIGNAL(progressChanged(double)), progressOperationPartSize);
+ }
+ }
+}
+
+KDUpdater::UpdateOperation* InstallerPrivate::createPathOperation(const QFileInfo &fileInfo,
+ const QString &componentName)
+{
+ const bool isDir = fileInfo.isDir();
+ // create an operation with the dir/ file as target, it will get deleted on undo
+ KDUpdater::UpdateOperation *op = createOwnedOperation(QLatin1String(isDir ? "Mkdir" : "Copy"));
+ if (isDir)
+ op->setValue(QLatin1String("createddir"), fileInfo.absoluteFilePath());
+ op->setValue(QLatin1String("component"), componentName);
+ op->setArguments(isDir ? QStringList() << fileInfo.absoluteFilePath()
+ : QStringList() << QString() << fileInfo.absoluteFilePath());
+ return op;
+}
+
+/*!
+ This creates fake operations which remove stuff which was registered for uninstallation afterwards
+*/
+void InstallerPrivate::registerPathesForUninstallation(
+ const QList<QPair<QString, bool> > &pathesForUninstallation, const QString &componentName)
+{
+ if (pathesForUninstallation.isEmpty())
+ return;
+
+ QList<QPair<QString, bool> >::const_iterator it;
+ for (it = pathesForUninstallation.begin(); it != pathesForUninstallation.end(); ++it) {
+ const bool wipe = it->second;
+ const QString path = replaceVariables(it->first);
+
+ const QFileInfo fi(path);
+ // create a copy operation with the file as target -> it will get deleted on undo
+ KDUpdater::UpdateOperation *op = createPathOperation(fi, componentName);
+ if (fi.isDir()) {
+ op->setValue(QLatin1String("forceremoval"), wipe ? QLatin1String("true")
+ : QLatin1String("false"));
+ }
+ addPerformed(takeOwnedOperation(op));
+
+ // get recursive afterwards
+ if (fi.isDir() && !wipe) {
+ QDirIterator dirIt(path, QDir::Hidden | QDir::AllEntries | QDir::System
+ | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (dirIt.hasNext()) {
+ dirIt.next();
+ op = createPathOperation(dirIt.fileInfo(), componentName);
+ addPerformed(takeOwnedOperation(op));
+ }
+ }
+ }
+}
+
+void InstallerPrivate::writeUninstallerBinary(QFile *const input, qint64 size, bool writeBinaryLayout)
+{
+ verbose() << "Writing uninstaller: " << (uninstallerName() + QLatin1String(".new")) << std::endl;
+
+ KDSaveFile out(uninstallerName() + QLatin1String(".new"));
+ openForWrite(&out, out.fileName()); // throws an exception in case of error
+
+ if (!input->seek(0))
+ throw Error(QObject::tr("Failed to seek in file %1: %2").arg(input->fileName(), input->errorString()));
+
+ appendData(&out, input, size);
+ if (writeBinaryLayout) {
+ appendInt64(&out, 0); // resource count
+ appendInt64(&out, 4 * sizeof(qint64)); // data block size
+ appendInt64(&out, QInstaller::MagicUninstallerMarker);
+ appendInt64(&out, QInstaller::MagicCookie);
+ }
+ out.setPermissions(out.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther
+ | QFile::ExeOther | QFile::ExeGroup | QFile::ExeUser);
+
+ if (!out.commit(KDSaveFile::OverwriteExistingFile))
+ throw Error(tr("Could not write uninstaller to %1: %2").arg(out.fileName(), out.errorString()));
+}
+
+void InstallerPrivate::writeUninstallerBinaryData(QIODevice *output, QFile *const input,
+ const QList<KDUpdater::UpdateOperation*> &performedOperations, const BinaryLayout &layout,
+ bool compressOperations, bool forceUncompressedResources)
+{
+ const qint64 dataBlockStart = output->pos();
+
+ QVector<Range<qint64> >resourceSegments;
+ foreach (const Range<qint64> segment, layout.metadataResourceSegments) {
+ input->seek(segment.start());
+ if (isInstaller()) {
+ const qint64 compressedSize = appendCompressedData(output, input, segment.length());
+ resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos() - compressedSize,
+ compressedSize));
+ } else if (forceUncompressedResources) {
+ QBuffer resource;
+ resource.setData(retrieveCompressedData(input, segment.length()));
+ resource.open(QIODevice::ReadOnly);
+ resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), resource.size()));
+ appendData(output, &resource, resource.size());
+ } else {
+ resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), segment.length()));
+ appendData(output, input, segment.length());
+ }
+ }
+
+ const qint64 operationsStart = output->pos();
+ appendInt64(output, performedOperations.count());
+ foreach (KDUpdater::UpdateOperation *op, performedOperations) {
+ // the installer can't be put into XML, remove it first
+ op->clearValue(QLatin1String("installer"));
+
+ appendString(output, op->name());
+ compressOperations ? appendByteArray(output, qCompress(op->toXml().toByteArray()))
+ : appendString(output, op->toXml().toString());
+
+ // for the ui not to get blocked
+ qApp->processEvents();
+ }
+ appendInt64(output, performedOperations.count());
+ const qint64 operationsEnd = output->pos();
+
+ // we don't save any component-indexes.
+ const qint64 numComponents = 0;
+ appendInt64(output, numComponents); // for the indexes
+ // we don't save any components.
+ const qint64 compIndexStart = output->pos();
+ appendInt64(output, numComponents); // and 2 times number of components,
+ appendInt64(output, numComponents); // one before and one after the components
+ const qint64 compIndexEnd = output->pos();
+
+ appendInt64Range(output, Range<qint64>::fromStartAndEnd(compIndexStart, compIndexEnd)
+ .moved(-dataBlockStart));
+ foreach (const Range<qint64> segment, resourceSegments)
+ appendInt64Range(output, segment.moved(-dataBlockStart));
+ appendInt64Range(output, Range<qint64>::fromStartAndEnd(operationsStart, operationsEnd)
+ .moved(-dataBlockStart));
+ appendInt64(output, layout.resourceCount);
+ //data block size, from end of .exe to end of file
+ appendInt64(output, output->pos() + 3 * sizeof(qint64) - dataBlockStart);
+ appendInt64(output, MagicUninstallerMarker);
+}
+
+void InstallerPrivate::writeUninstaller(QList<KDUpdater::UpdateOperation*> performedOperations)
+{
+ bool gainedAdminRights = false;
+ QTemporaryFile tempAdminFile(targetDir() + QString::fromLatin1("/testjsfdjlkdsjflkdsjfldsjlfds")
+ + QString::number(qrand() % 1000));
+ if (!tempAdminFile.open() || !tempAdminFile.isWritable()) {
+ q->gainAdminRights();
+ gainedAdminRights = true;
+ }
+
+ const QString filePath = QFileInfo(uninstallerName()).path();
+ if (!QDir().exists(filePath)) {
+ // create the directory containing the uninstaller (like a bundle structor, on Mac...)
+ KDUpdater::UpdateOperation* op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << filePath);
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+ performedOperations.append(takeOwnedOperation(op));
+ }
+
+ {
+ // write current state (variables) to the uninstaller ini file
+ const QString iniPath = targetDir() + QLatin1Char('/') + m_installerSettings.uninstallerIniFile();
+ QSettingsWrapper cfg(iniPath, QSettingsWrapper::IniFormat);
+ QVariantHash vars;
+ QHash<QString, QString>::ConstIterator it = m_vars.constBegin();
+ while (it != m_vars.constEnd()) {
+ const QString &key = it.key();
+ if (key != QLatin1String("RunProgramDescription") && key != QLatin1String("RunProgram"))
+ vars.insert(key, it.value());
+ ++it;
+ }
+ cfg.setValue(QLatin1String("Variables"), vars);
+
+ QStringList list;
+ foreach (const Repository &repository, m_installerSettings.userRepositories())
+ list.append(repository.url().toString());
+ cfg.setValue(QLatin1String("Repositories"), list);
+
+ cfg.sync();
+ if (cfg.status() != QSettingsWrapper::NoError) {
+ const QString reason = cfg.status() == QSettingsWrapper::AccessError ? tr("Access error")
+ : tr("Format error");
+ throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason));
+ }
+ }
+
+#ifdef Q_WS_MAC
+ // if it is a bundle, we need some stuff in it...
+ const QString appDirPath = QCoreApplication::applicationDirPath();
+ if (isInstaller() && QFileInfo(appDirPath + QLatin1String("/../..")).isBundle()) {
+ KDUpdater::UpdateOperation* op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (appDirPath + QLatin1String("/../PkgInfo"))
+ << (filePath + QLatin1String("/../PkgInfo")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (appDirPath + QLatin1String("/../Info.plist")) << (filePath
+ + QLatin1String("/../Info.plist")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ verbose() << "Checking for qt_menu.nib" << std::endl;
+ QString sourceDirName = appDirPath + QLatin1String("/../Resources/qt_menu.nib");
+ if (QFileInfo(sourceDirName).exists()) {
+ verbose() << "qt_menu.nib has been found. Isn't it great?" << std::endl;
+ const QString targetDirName = QFileInfo(filePath + QLatin1String("/../Resources/qt_menu.nib"))
+ .absoluteFilePath();
+
+ // IFW has been built with a static Cocoa Qt. The app bundle must contain the qt_menu.nib.
+ // ### use the CopyDirectory operation in 1.1
+ op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << targetDirName);
+ if (!op->performOperation())
+ verbose() << "ERROR in Mkdir operation: " << op->errorString() << std::endl;
+
+ QDir sourceDir(sourceDirName);
+ foreach (const QString &filename, sourceDir.entryList(QDir::Files)) {
+ const QString src = sourceDirName + QLatin1String("/") + filename;
+ const QString dst = targetDirName + QLatin1String("/") + filename;
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << src << dst);
+ if (!op->performOperation())
+ verbose() << "ERROR in Copy operation: copy " << src << " to " << dst << std::endl
+ << "error message: " << op->errorString() << std::endl;
+ }
+ }
+
+ // patch the Info.plist while copying it
+ QFile sourcePlist(appDirPath + QLatin1String("/../Info.plist"));
+ openForRead(&sourcePlist, sourcePlist.fileName());
+ QFile targetPlist(filePath + QLatin1String("/../Info.plist"));
+ openForWrite(&targetPlist, targetPlist.fileName());
+
+ QTextStream in(&sourcePlist);
+ QTextStream out(&targetPlist);
+
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ line = line.replace(QLatin1String("<string>")
+ + QFileInfo(QCoreApplication::applicationFilePath()).baseName()
+ + QLatin1String("</string>"), QLatin1String("<string>")
+ + QFileInfo(uninstallerName()).baseName() + QLatin1String("</string>"));
+ out << line << endl;
+ }
+
+ op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << (QFileInfo(filePath).path() + QLatin1String("/Resources")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ const QString icon = QFileInfo(QCoreApplication::applicationFilePath()).baseName()
+ + QLatin1String(".icns");
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (appDirPath + QLatin1String("/../Resources/") + icon)
+ << (filePath + QLatin1String("/../Resources/") + icon));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ // finally, copy everything within Frameworks and plugins
+ if (QDir(appDirPath + QLatin1String("/../Frameworks")).exists()) {
+ copyDirectoryContents(appDirPath + QLatin1String("/../Frameworks"), filePath
+ + QLatin1String("/../Frameworks"));
+ }
+
+ if (QDir(appDirPath + QLatin1String("/../plugins")).exists()) {
+ copyDirectoryContents(appDirPath + QLatin1String("/../plugins"), filePath
+ + QLatin1String("/../plugins"));
+ }
+ }
+#endif
+
+ try {
+ // 1 - check if we have a installer base replacement
+ // |--- if so, write out the new tool and remove the replacement
+ // |--- remember to restart and that we need to replace the original binary
+ //
+ // 2 - if we do not have a replacement, try to open the binary data file as input
+ // |--- try to read the binary layout
+ // |--- on error (see 2.1)
+ // |--- remember we might to append uncompressed resource data (see 3)
+ // |--- set the installer or maintenance binary as input to take over binary data
+ // |--- in case we did not have a replacement, write out an new maintenance tool binary
+ // |--- remember that we need to replace the original binary
+ //
+ // 3 - open a new binary data file
+ // |--- try to write out the binary data based on the loaded input file (see 2)
+ // |--- on error (see 3.1)
+ // |--- if we wrote a new maintenance tool, take this as output - if not, write out a new
+ // one and set it as output file, remember we did this
+ // |--- append the binary data based on the loaded input file (see 2), make sure we force
+ // uncompression of the resource section if we read from a binary data file (see 4.1).
+ //
+ // 4 - force a deferred rename on the .dat file (see 4.1)
+ // 5 - force a deferred rename on the maintenance file (see 5.1)
+
+ // 2.1 - Error cases are: no data file (in fact we are the installer or an old installation),
+ // could not find the data file magic cookie (unknown .dat file), failed to read binary
+ // layout (mostly likely the resource section or we couldn't seek inside the file)
+ //
+ // 3.1 - most likely the commit operation will fail
+ // 4.1 - if 3 failed, this makes sure the .dat file will get removed and on the next run all
+ // binary data is read from the maintenance tool, otherwise it get replaced be the new one
+ // 5.1 - this will only happen -if- we wrote out a new binary
+
+ bool newBinaryWritten = false;
+ bool replacementExists = false;
+ const QString installerBaseBinary = q->replaceVariables(m_installerBaseBinaryUnreplaced);
+ if (!installerBaseBinary.isEmpty() && QFileInfo(installerBaseBinary).exists()) {
+ verbose() << "Got a replacement installer base binary: " << installerBaseBinary << std::endl;
+
+ QFile replacementBinary(installerBaseBinary);
+ try {
+ openForRead(&replacementBinary, replacementBinary.fileName());
+ writeUninstallerBinary(&replacementBinary, replacementBinary.size(), true);
+
+ newBinaryWritten = true;
+ replacementExists = true;
+ } catch (const Error &error) {
+ verbose() << error.message() << std::endl;
+ }
+
+ if (!replacementBinary.remove()) {
+ // Is there anything more sensible we can do with this error? I think not. It's not serious
+ // enough for throwing/ aborting the process.
+ verbose() << "Could not remove installer base binary (" << installerBaseBinary
+ << ") after updating the uninstaller: " << replacementBinary.errorString() << std::endl;
+ }
+ m_installerBaseBinaryUnreplaced.clear();
+ }
+
+ QFile input;
+ BinaryLayout layout;
+ bool forceUncompressedResourcesOnError = false;
+ const QString dataFile = targetDir() + QLatin1Char('/') + m_installerSettings.uninstallerName()
+ + QLatin1String(".dat");
+ try {
+ input.setFileName(dataFile);
+ openForRead(&input, input.fileName());
+ if (isInstaller()) {
+ throw Error(tr("Found a binary data file, but we are the installer and we should read the "
+ "binary resource from our very own binary!"));
+ }
+ layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookieDat));
+ forceUncompressedResourcesOnError = true;
+ } catch (const Error &error) {
+ verbose() << error.message() << std::endl;
+ input.setFileName(isInstaller() ? installerBinaryPath() : uninstallerName());
+ openForRead(&input, input.fileName());
+ layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookie));
+ if (!newBinaryWritten) {
+ newBinaryWritten = true;
+ writeUninstallerBinary(&input, layout.endOfData - layout.dataBlockSize, true);
+ }
+ }
+
+ try {
+ KDSaveFile file(dataFile + QLatin1String(".new"));
+ openForWrite(&file, file.fileName());
+ writeUninstallerBinaryData(&file, &input, performedOperations, layout, true, false);
+ appendInt64(&file, MagicCookieDat);
+ file.setPermissions(file.permissions() | QFile::WriteUser | QFile::ReadGroup
+ | QFile::ReadOther);
+ if (!file.commit(KDSaveFile::OverwriteExistingFile)) {
+ throw Error(tr("Could not write uninstaller binary data to %1: %2").arg(file.fileName(),
+ file.errorString()));
+ }
+ } catch (const Error &error) {
+ verbose() << error.message() << std::endl;
+ if (!newBinaryWritten) {
+ newBinaryWritten = true;
+ QFile tmp(isInstaller() ? installerBinaryPath() : uninstallerName());
+ openForRead(&tmp, tmp.fileName());
+ BinaryLayout tmpLayout = BinaryContent::readBinaryLayout(&tmp, findMagicCookie(&tmp, MagicCookie));
+ writeUninstallerBinary(&tmp, tmpLayout.endOfData - tmpLayout.dataBlockSize, false);
+ }
+
+ QFile file(uninstallerName() + QLatin1String(".new"));
+ openForAppend(&file, file.fileName());
+ file.seek(file.size());
+ writeUninstallerBinaryData(&file, &input, performedOperations, layout, false,
+ forceUncompressedResourcesOnError);
+ appendInt64(&file, MagicCookie);
+ }
+ input.close();
+ deferredRename(dataFile + QLatin1String(".new"), dataFile, false);
+
+ if (newBinaryWritten) {
+ verbose() << "Needs restart: " << (replacementExists && isUpdater()) << std::endl;
+ deferredRename(uninstallerName() + QLatin1String(".new"), uninstallerName(),
+ replacementExists && isUpdater());
+ }
+ } catch (const Error &err) {
+ setStatus(Installer::Failure);
+ if (gainedAdminRights)
+ q->dropAdminRights();
+ m_needToWriteUninstaller = false;
+ throw err;
+ }
+
+ if (gainedAdminRights)
+ q->dropAdminRights();
+
+ commitSessionOperations();
+
+ m_needToWriteUninstaller = false;
+}
+
+QString InstallerPrivate::registerPath() const
+{
+#ifdef Q_OS_WIN
+ QString productName = m_vars.value(QLatin1String("ProductName"));
+ if (productName.isEmpty())
+ throw Error(tr("ProductName should be set"));
+
+ QString path = QLatin1String("HKEY_CURRENT_USER");
+ if (m_vars.value(QLatin1String("AllUsers")) == QLatin1String("true"))
+ path = QLatin1String("HKEY_LOCAL_MACHINE");
+
+ return path + QLatin1String("\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\")
+ + productName;
+#endif
+ return QString();
+}
+
+void InstallerPrivate::runInstaller()
+{
+ bool adminRightsGained = false;
+ try {
+ setStatus(Installer::Running);
+ emit installationStarted(); //resets also the ProgressCoordninator
+
+ //to have some progress for writeUninstaller
+ ProgressCoordninator::instance()->addReservePercentagePoints(1);
+
+ const QString target = targetDir();
+ if (target.isEmpty())
+ throw Error(tr("Variable 'TargetDir' not set."));
+
+ if (!QDir(target).exists()) {
+ QTemporaryFile tempAdminFile(target + QLatin1String("/adminrights"));
+ if (!tempAdminFile.open() || !tempAdminFile.isWritable())
+ adminRightsGained = q->gainAdminRights();
+ }
+
+ // add the operation to create the target directory
+ KDUpdater::UpdateOperation *mkdirOp = createOwnedOperation(QLatin1String("Mkdir"));
+ mkdirOp->setArguments(QStringList() << target);
+ mkdirOp->setValue(QLatin1String("forceremoval"), true);
+ mkdirOp->setValue(QLatin1String("uninstall-only"), true);
+
+ performOperationThreaded(mkdirOp, Backup);
+ if (!performOperationThreaded(mkdirOp)) {
+ // if we cannot create the target dir, we try to activate the admin rights
+ adminRightsGained = q->gainAdminRights();
+ if (!performOperationThreaded(mkdirOp))
+ throw Error(mkdirOp->errorString());
+ }
+ const QString remove = q->value(QLatin1String("RemoveTargetDir"));
+ if (QVariant(remove).toBool())
+ addPerformed(takeOwnedOperation(mkdirOp));
+
+ // to show that there was some work
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
+
+ const QList<Component*> componentsToInstall = q->componentsToInstall(AllMode);
+ verbose() << "Install size: " << componentsToInstall.size() << " components" << std::endl;
+
+ if (!adminRightsGained) {
+ QList<Component*> componentsToInstall = q->componentsToInstall(q->runMode());
+ foreach (Component *component, componentsToInstall) {
+ if (component->value(QLatin1String("RequiresAdminRights"),
+ QLatin1String("false")) == QLatin1String("false")) {
+ continue;
+ }
+
+ q->gainAdminRights();
+ q->dropAdminRights();
+ break;
+ }
+ }
+
+ const double downloadPartProgressSize = double(1) / double(3);
+ double componentsInstallPartProgressSize = double(2) / double(3);
+ const int downloadedArchivesCount = q->downloadNeededArchives(AllMode,
+ downloadPartProgressSize);
+
+ // if there was no download we have the whole progress for installing components
+ if (!downloadedArchivesCount)
+ componentsInstallPartProgressSize = double(1);
+
+ // put the installed packages info into the target dir
+ KDUpdater::PackagesInfo *const packages = m_app->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();
+ packages->setApplicationName(m_installerSettings.applicationName());
+ packages->setApplicationVersion(m_installerSettings.applicationVersion());
+
+ stopProcessesForUpdates(componentsToInstall);
+
+ const int progressOperationCount = countProgressOperations(componentsToInstall);
+ double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+
+ foreach (Component *component, componentsToInstall)
+ installComponent(component, progressOperationSize, adminRightsGained);
+
+ emit q->titleMessageChanged(tr("Creating Uninstaller"));
+
+ writeUninstaller(m_performedOperationsOld + m_performedOperationsCurrentSession);
+ registerUninstaller();
+
+ // this is the reserved one from the beginning
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+
+ setStatus(Installer::Success);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+
+ emit installationFinished();
+ } catch (const Error &err) {
+ if (q->status() != Installer::Canceled) {
+ setStatus(Installer::Failure);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
+ << std::endl;
+ }
+
+ q->rollBackInstallation();
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+ emit installationFinished();
+
+ throw;
+ }
+}
+
+void InstallerPrivate::runPackageUpdater()
+{
+ bool adminRightsGained = false;
+ try {
+ if (m_completeUninstall) {
+ runUninstaller();
+ return;
+ }
+
+ setStatus(Installer::Running);
+ emit installationStarted(); //resets also the ProgressCoordninator
+
+ //to have some progress for the cleanup/write component.xml step
+ ProgressCoordninator::instance()->addReservePercentagePoints(1);
+
+ const QString packagesXml = componentsXmlPath();
+ // check if we need admin rights and ask before the action happens
+ if (!QFileInfo(installerBinaryPath()).isWritable() || !QFileInfo(packagesXml).isWritable())
+ adminRightsGained = q->gainAdminRights();
+
+ const QList<Component*> componentsToInstall = q->componentsToInstall(q->runMode());
+ verbose() << "Install size: " << componentsToInstall.size() << " components " << std::endl;
+
+ bool updateAdminRights = false;
+ if (!adminRightsGained) {
+ foreach (Component *component, componentsToInstall) {
+ if (component->value(QLatin1String("RequiresAdminRights"),
+ QLatin1String("false")) == QLatin1String("false")) {
+ continue;
+ }
+
+ updateAdminRights = true;
+ break;
+ }
+ }
+
+ QHash<QString, Component*> componentsByName;
+ QList<KDUpdater::UpdateOperation*> undoOperations;
+ QList<KDUpdater::UpdateOperation*> nonRevertedOperations;
+
+ // build a list of undo operations based on the checked state of the component
+ foreach (KDUpdater::UpdateOperation *op, m_performedOperationsOld) {
+ const QString &name = op->value(QLatin1String("component")).toString();
+ Component *comp = componentsByName.value(name, 0);
+ if (!comp)
+ comp = q->componentByName(name);
+ if (comp) {
+ componentsByName.insert(name, comp);
+ // if we're _not_ removing everything and this component is still selected, -> next
+ if (comp->isSelected()) {
+ nonRevertedOperations.append(op);
+ continue;
+ }
+ }
+ // Filter out the create target dir undo operation, it's only needed for full uninstall.
+ if (op->value(QLatin1String("uninstall-only")).toBool()) {
+ nonRevertedOperations.append(op);
+ continue;
+ }
+
+ undoOperations.prepend(op);
+ updateAdminRights |= op->value(QLatin1String("admin")).toBool();
+ }
+
+ // we did not request admin rights till we found out that a component/ undo needs admin rights
+ if (updateAdminRights && !adminRightsGained) {
+ q->gainAdminRights();
+ q->dropAdminRights();
+ }
+
+ double undoOperationProgressSize = 0;
+ const double downloadPartProgressSize = double(2) / double(5);
+ double componentsInstallPartProgressSize = double(3) / double(5);
+ if (undoOperations.count() > 0) {
+ undoOperationProgressSize = double(1) / double(5);
+ componentsInstallPartProgressSize = downloadPartProgressSize;
+ undoOperationProgressSize /= countProgressOperations(undoOperations);
+ }
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Removing deselected components..."));
+
+ runUndoOperations(undoOperations, undoOperationProgressSize, adminRightsGained, true);
+ m_performedOperationsOld = nonRevertedOperations; // these are all operations left: those not reverted
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
+
+ // following, we download the needed archives
+ q->downloadNeededArchives(AllMode, downloadPartProgressSize);
+
+ stopProcessesForUpdates(componentsToInstall);
+
+ const double progressOperationCount = countProgressOperations(componentsToInstall);
+ const double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+
+ KDUpdater::PackagesInfo *packages = m_app->packagesInfo();
+ packages->setFileName(packagesXml);
+ packages->setApplicationName(m_installerSettings.applicationName());
+ packages->setApplicationVersion(m_installerSettings.applicationVersion());
+
+ foreach (Component *component, componentsToInstall)
+ installComponent(component, progressOperationSize, adminRightsGained);
+
+ emit q->titleMessageChanged(tr("Creating Uninstaller"));
+
+ commitSessionOperations(); //end session, move ops to "old"
+ m_needToWriteUninstaller = true;
+
+ //this is the reserved one from the beginning
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+
+ setStatus(Installer::Success);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+
+ emit installationFinished();
+ } catch (const Error &err) {
+ if (q->status() != Installer::Canceled) {
+ setStatus(Installer::Failure);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
+ << std::endl;
+ }
+
+ q->rollBackInstallation();
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+ emit installationFinished();
+
+ throw;
+ }
+}
+
+void InstallerPrivate::runUninstaller()
+{
+ bool adminRightsGained = false;
+ try {
+ setStatus(Installer::Running);
+ emit uninstallationStarted();
+
+ // check if we need administration rights and ask before the action happens
+ if (!QFileInfo(installerBinaryPath()).isWritable() || !QFileInfo(componentsXmlPath()).isWritable())
+ adminRightsGained = q->gainAdminRights();
+
+ bool updateAdminRights = false;
+ QList<KDUpdater::UpdateOperation*> undoOperations;
+ foreach (KDUpdater::UpdateOperation *op, m_performedOperationsOld) {
+ undoOperations.prepend(op);
+ updateAdminRights |= op->value(QLatin1String("admin")).toBool();
+ }
+
+ // we did not request administration rights till we found out that a undo needs administration rights
+ if (updateAdminRights && !adminRightsGained) {
+ q->gainAdminRights();
+ q->dropAdminRights();
+ }
+
+ const int uninstallOperationCount = countProgressOperations(undoOperations);
+ const double undoOperationProgressSize = double(1) / double(uninstallOperationCount);
+
+ runUndoOperations(undoOperations, undoOperationProgressSize, adminRightsGained, false);
+ // No operation delete here, as all old undo operations are deleted in the destructor.
+
+ const QString startMenuDir = m_vars.value(QLatin1String("StartMenuDir"));
+ if (!startMenuDir.isEmpty()) {
+ try {
+ QInstaller::removeDirectory(startMenuDir);
+ } catch (const Error &error) {
+ verbose() << "Could not remove " << startMenuDir << ": " << error.message() << std::endl;
+ }
+ } else {
+ verbose() << "Start menu dir not set." << std::endl;
+ }
+
+ // this will also delete the TargetDir on Windows
+ deleteUninstaller();
+
+ QString remove = q->value(QLatin1String("RemoveTargetDir"));
+ if (QVariant(remove).toBool()) {
+ // on !Windows, we need to remove TargetDir manually
+ verbose() << "Complete uninstallation is chosen" << std::endl;
+ const QString target = targetDir();
+ if (!target.isEmpty()) {
+ if (updateAdminRights && !adminRightsGained) {
+ // we were root at least once, so we remove the target dir as root
+ q->gainAdminRights();
+ removeDirectoryThreaded(target, true);
+ q->dropAdminRights();
+ } else {
+ removeDirectoryThreaded(target, true);
+ }
+ }
+ }
+
+ unregisterUninstaller();
+ m_needToWriteUninstaller = false;
+
+ setStatus(Installer::Success);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nDeinstallation finished"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+ emit uninstallationFinished();
+ } catch (const Error &err) {
+ if (q->status() != Installer::Canceled) {
+ setStatus(Installer::Failure);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ }
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ if (adminRightsGained)
+ q->dropAdminRights();
+ emit installationFinished();
+
+ throw;
+ }
+}
+
+void InstallerPrivate::installComponent(Component *component, double progressOperationSize,
+ bool adminRightsGained)
+{
+ const QList<KDUpdater::UpdateOperation*> operations = component->operations();
+ if (!component->operationsCreatedSuccessfully())
+ q->setCanceled();
+
+ const int opCount = operations.count();
+ // show only components which do something, MinimumProgress is only for progress calculation safeness
+ if (opCount > 1 || (opCount == 1 && operations.at(0)->name() != QLatin1String("MinimumProgress"))) {
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstalling component %1")
+ .arg(component->displayName()));
+ }
+
+ foreach (KDUpdater::UpdateOperation *operation, operations) {
+ if (statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+
+ // maybe this operations wants us to be admin...
+ bool becameAdmin = false;
+ if (!adminRightsGained && operation->value(QLatin1String("admin")).toBool()) {
+ becameAdmin = q->gainAdminRights();
+ verbose() << operation->name() << " as admin: " << becameAdmin << std::endl;
+ }
+
+ connectOperationToInstaller(operation, progressOperationSize);
+ // allow the operation to backup stuff before performing the operation
+ InstallerPrivate::performOperationThreaded(operation, InstallerPrivate::Backup);
+
+ bool ignoreError = false;
+ bool ok = InstallerPrivate::performOperationThreaded(operation);
+ while (!ok && !ignoreError && q->status() != Installer::Canceled) {
+ verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
+ .arg(operation->name(), operation->arguments().join(QLatin1String("; ")),
+ operation->errorString()) << std::endl;;
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
+ tr("Error during installation process (%1):\n%2").arg(component->name(),
+ operation->errorString()),
+ QMessageBox::Retry | QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Retry);
+
+ if (button == QMessageBox::Retry)
+ ok = InstallerPrivate::performOperationThreaded(operation);
+ else if (button == QMessageBox::Ignore)
+ ignoreError = true;
+ else if (button == QMessageBox::Cancel)
+ q->interrupt();
+ }
+
+ if (ok || operation->error() > KDUpdater::UpdateOperation::InvalidArguments) {
+ // remember that the operation was performed what allows us to undo it if a
+ // following operation fails or if this operation failed but still needs
+ // an undo call to cleanup.
+ addPerformed(operation);
+ operation->setValue(QLatin1String("component"), component->name());
+ }
+
+ if (becameAdmin)
+ q->dropAdminRights();
+
+ if (!ok && !ignoreError)
+ throw Error(operation->errorString());
+
+ if (component->value(QLatin1String("Important"), QLatin1String("false")) == QLatin1String("true"))
+ m_forceRestart = true;
+ }
+
+ registerPathesForUninstallation(component->pathesForUninstallation(), component->name());
+
+ if (!component->stopProcessForUpdateRequests().isEmpty()) {
+ KDUpdater::UpdateOperation *stopProcessForUpdatesOp =
+ KDUpdater::UpdateOperationFactory::instance().create(QLatin1String("FakeStopProcessForUpdate"));
+ const QStringList arguments(component->stopProcessForUpdateRequests().join(QLatin1String(",")));
+ stopProcessForUpdatesOp->setArguments(arguments);
+ addPerformed(stopProcessForUpdatesOp);
+ stopProcessForUpdatesOp->setValue(QLatin1String("component"), component->name());
+ }
+
+ // now mark the component as installed
+ KDUpdater::PackagesInfo *const packages = m_app->packagesInfo();
+ packages->installPackage(component->name(), component->value(QLatin1String("Version")),
+ component->value(QLatin1String("DisplayName")), component->value(QLatin1String("Description")),
+ component->dependencies(), component->forcedInstallation(), component->isVirtual(),
+ component->value(QLatin1String("UncompressedSize")).toULongLong());
+ packages->writeToDisk();
+
+ component->setInstalled();
+ component->markAsPerformedInstallation();
+}
+
+// -- private
+
+void InstallerPrivate::deleteUninstaller()
+{
+#ifdef Q_OS_WIN
+ // Since Windows does not support that the uninstaller deletes itself we have to go with a rather dirty
+ // hack. What we do is to create a batchfile that will try to remove the uninstaller once per second. Then
+ // we start that batchfile detached, finished our job and close ourself. Once that's done the batchfile
+ // will succeed in deleting our uninstall.exe and, if the installation directory was created but us and if
+ // it's empty after the uninstall, deletes the installation-directory.
+ const QString batchfile = QDir::toNativeSeparators(QFileInfo(QDir::tempPath(),
+ QLatin1String("uninstall.vbs")).absoluteFilePath());
+ QFile f(batchfile);
+ if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
+ throw Error(tr("Cannot prepare uninstall"));
+
+ QTextStream batch(&f);
+ batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
+ batch << "file = WScript.Arguments.Item(0)\n";
+ batch << "folderpath = WScript.Arguments.Item(1)\n";
+ batch << "Set folder = fso.GetFolder(folderpath)\n";
+ batch << "on error resume next\n";
+
+ batch << "while fso.FileExists(file)\n";
+ batch << " fso.DeleteFile(file)\n";
+ batch << " WScript.Sleep(1000)\n";
+ batch << "wend\n";
+// batch << "if folder.SubFolders.Count = 0 and folder.Files.Count = 0 then\n";
+ batch << " Set folder = Nothing\n";
+ batch << " fso.DeleteFolder folderpath, true\n";
+// batch << "end if\n";
+ batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
+
+ f.close();
+
+ QStringList arguments;
+ arguments << QLatin1String("//Nologo") << batchfile; // execute the batchfile
+ arguments << QDir::toNativeSeparators(QFileInfo(installerBinaryPath()).absoluteFilePath());
+ if (!m_performedOperationsOld.isEmpty()) {
+ const KDUpdater::UpdateOperation* const op = m_performedOperationsOld.first();
+ if (op->name() == QLatin1String("Mkdir")) // the target directory name
+ arguments << QDir::toNativeSeparators(QFileInfo(op->arguments().first()).absoluteFilePath());
+ }
+
+ if (!QProcessWrapper::startDetached(QLatin1String("cscript"), arguments, QDir::rootPath()))
+ throw Error(tr("Cannot start uninstall"));
+#else
+ // every other platform has no problem if we just delete ourself now
+ QFile uninstaller(QFileInfo(installerBinaryPath()).absoluteFilePath());
+ uninstaller.remove();
+# ifdef Q_WS_MAC
+ const QLatin1String cdUp("/../../..");
+ if (QFileInfo(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath()).isBundle()) {
+ removeDirectoryThreaded(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath());
+ QFile::remove(QFileInfo(installerBinaryPath() + cdUp).absolutePath()
+ + QLatin1String("/") + configurationFileName());
+ } else
+# endif
+#endif
+ {
+ // finally remove the components.xml, since it still exists now
+ QFile::remove(QFileInfo(installerBinaryPath()).absolutePath() + QLatin1String("/")
+ + configurationFileName());
+ }
+}
+
+void InstallerPrivate::registerUninstaller()
+{
+#ifdef Q_OS_WIN
+ QSettingsWrapper settings(registerPath(), QSettingsWrapper::NativeFormat);
+ settings.setValue(QLatin1String("DisplayName"), m_vars.value(QLatin1String("ProductName")));
+ settings.setValue(QLatin1String("DisplayVersion"), m_vars.value(QLatin1String("ProductVersion")));
+ const QString uninstaller = QDir::toNativeSeparators(uninstallerName());
+ settings.setValue(QLatin1String("DisplayIcon"), uninstaller);
+ settings.setValue(QLatin1String("Publisher"), m_vars.value(QLatin1String("Publisher")));
+ settings.setValue(QLatin1String("UrlInfoAbout"), m_vars.value(QLatin1String("Url")));
+ settings.setValue(QLatin1String("Comments"), m_vars.value(QLatin1String("Title")));
+ settings.setValue(QLatin1String("InstallDate"), QDateTime::currentDateTime().toString());
+ settings.setValue(QLatin1String("InstallLocation"), QDir::toNativeSeparators(targetDir()));
+ settings.setValue(QLatin1String("UninstallString"), uninstaller);
+ settings.setValue(QLatin1String("ModifyPath"), uninstaller + QLatin1String(" --manage-packages"));
+ settings.setValue(QLatin1String("EstimatedSize"), QFileInfo(installerBinaryPath()).size());
+ settings.setValue(QLatin1String("NoModify"), 0);
+ settings.setValue(QLatin1String("NoRepair"), 1);
+#endif
+}
+
+void InstallerPrivate::unregisterUninstaller()
+{
+#ifdef Q_OS_WIN
+ QSettingsWrapper settings(registerPath(), QSettingsWrapper::NativeFormat);
+ settings.remove(QString());
+#endif
+}
+
+void InstallerPrivate::runUndoOperations(const QList<KDUpdater::UpdateOperation*> &undoOperations,
+ double undoOperationProgressSize, bool adminRightsGained, bool deleteOperation)
+{
+ KDUpdater::PackagesInfo *const packages = m_app->packagesInfo();
+ packages->setFileName(componentsXmlPath());
+ packages->setApplicationName(m_installerSettings.applicationName());
+ packages->setApplicationVersion(m_installerSettings.applicationVersion());
+
+ try {
+ foreach (KDUpdater::UpdateOperation *undoOperation, undoOperations) {
+ if (statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+
+ bool becameAdmin = false;
+ if (!adminRightsGained && undoOperation->value(QLatin1String("admin")).toBool())
+ becameAdmin = q->gainAdminRights();
+
+ connectOperationToInstaller(undoOperation, undoOperationProgressSize);
+ verbose() << "undo operation=" << undoOperation->name() << std::endl;
+ performOperationThreaded(undoOperation, InstallerPrivate::Undo);
+
+ const QString componentName = undoOperation->value(QLatin1String("component")).toString();
+ if (undoOperation->error() != KDUpdater::UpdateOperation::NoError) {
+ if (!componentName.isEmpty()) {
+ bool run = true;
+ while (run && q->status() != Installer::Canceled) {
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
+ tr("Error during uninstallation process:\n%1").arg(undoOperation->errorString()),
+ QMessageBox::Retry | QMessageBox::Ignore, QMessageBox::Retry);
+
+ if (button == QMessageBox::Retry) {
+ performOperationThreaded(undoOperation, Undo);
+ if (undoOperation->error() == KDUpdater::UpdateOperation::NoError)
+ run = false;
+ } else if (button == QMessageBox::Ignore) {
+ run = false;
+ }
+ }
+ }
+ }
+
+ if (!componentName.isEmpty()) {
+ if (Component *component = q->componentByName(componentName)) {
+ component->setUninstalled();
+ packages->removePackage(component->name());
+ packages->writeToDisk();
+ }
+ }
+
+ if (becameAdmin)
+ q->dropAdminRights();
+
+ if (deleteOperation)
+ delete undoOperation;
+ }
+ } catch (const Error &error) {
+ packages->writeToDisk();
+ throw Error(error.message());
+ } catch (...) {
+ packages->writeToDisk();
+ throw Error(tr("Unknown error"));
+ }
+}
+
+} // QInstaller
diff --git a/installerbuilder/libinstaller/qinstaller_p.h b/installerbuilder/libinstaller/qinstaller_p.h
new file mode 100644
index 000000000..e58bd72c8
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstaller_p.h
@@ -0,0 +1,205 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_P_H
+#define QINSTALLER_P_H
+
+#include "common/installersettings.h"
+
+#include <KDToolsCore/KDSysInfo>
+
+#include <QtCore/QHash>
+#include <QtCore/QObject>
+#include <QtCore/QPair>
+#include <QtCore/QPointer>
+
+class FSEngineClientHandler;
+QT_FORWARD_DECLARE_CLASS(QFile)
+QT_FORWARD_DECLARE_CLASS(QFileInfo)
+
+namespace KDUpdater {
+ class Application;
+ class UpdateOperation;
+}
+
+namespace QInstaller {
+
+struct BinaryLayout;
+
+class Component;
+class Installer;
+class TempDirDeleter;
+
+class InstallerPrivate : public QObject
+{
+ Q_OBJECT;
+ friend class Installer;
+
+public:
+ enum OperationType {
+ Backup,
+ Perform,
+ Undo
+ };
+
+ InstallerPrivate();
+ explicit InstallerPrivate(Installer *q, qint64 magicInstallerMaker,
+ const QList<KDUpdater::UpdateOperation*> &performedOperations);
+ ~InstallerPrivate();
+
+ static bool isProcessRunning(const QString &name,
+ const QList<KDSysInfo::ProcessInfo> &processes);
+
+ static bool performOperationThreaded(KDUpdater::UpdateOperation *op,
+ InstallerPrivate::OperationType type = InstallerPrivate::Perform);
+
+ void initialize();
+
+ void setStatus(int status);
+ bool statusCanceledOrFailed() const;
+
+ QString targetDir() const;
+ QString registerPath() const;
+
+ QString uninstallerName() const;
+ QString installerBinaryPath() const;
+ void readUninstallerIniFile(const QString &targetDir);
+ void writeUninstaller(QList<KDUpdater::UpdateOperation*> performedOperations);
+
+ QString configurationFileName() const;
+ QString componentsXmlPath() const;
+ QString localComponentsXmlPath() const;
+
+ Installer *installer() const { return q; }
+
+ void runInstaller();
+ bool isInstaller() const;
+
+ void runUninstaller();
+ bool isUninstaller() const;
+
+ void runUpdater();
+ bool isUpdater() const;
+
+ void runPackageUpdater();
+ bool isPackageManager() const;
+
+ QString replaceVariables(const QString &str) const;
+ QByteArray replaceVariables(const QByteArray &str) const;
+
+ void stopProcessesForUpdates(const QList<Component*> &components);
+ int countProgressOperations(const QList<Component*> &components);
+ int countProgressOperations(const QList<KDUpdater::UpdateOperation*> &operations);
+ void connectOperationToInstaller(KDUpdater::UpdateOperation* const operation,
+ double progressOperationPartSize);
+
+ KDUpdater::UpdateOperation* createOwnedOperation(const QString &type);
+ KDUpdater::UpdateOperation* takeOwnedOperation(KDUpdater::UpdateOperation *operation);
+
+ KDUpdater::UpdateOperation* createPathOperation(const QFileInfo &fileInfo,
+ const QString &componentName);
+ void registerPathesForUninstallation(const QList<QPair<QString, bool> > &pathesForUninstallation,
+ const QString &componentName);
+
+ void addPerformed(KDUpdater::UpdateOperation* op) {
+ m_performedOperationsCurrentSession.append(op);
+ }
+
+ void commitSessionOperations() {
+ m_performedOperationsOld += m_performedOperationsCurrentSession;
+ m_performedOperationsCurrentSession.clear();
+ }
+
+ void installComponent(Component *component, double progressOperationSize, bool adminRightsGained = false);
+
+signals:
+ void installationStarted();
+ void installationFinished();
+ void uninstallationStarted();
+ void uninstallationFinished();
+
+public:
+ KDUpdater::Application *m_app;
+ TempDirDeleter *m_tempDirDeleter;
+ FSEngineClientHandler *m_FSEngineClientHandler;
+
+ int m_status;
+ bool m_forceRestart;
+ int m_silentRetries;
+ bool m_testChecksum;
+ bool m_launchedAsRoot;
+ bool m_completeUninstall;
+ bool m_needToWriteUninstaller;
+ QHash<QString, QString> m_vars;
+ QHash<QString, bool> m_sharedFlags;
+ InstallerSettings m_installerSettings;
+ QString m_installerBaseBinaryUnreplaced;
+
+ qint64 m_globalDictOffset;
+
+ qint64 m_componentsCount;
+ qint64 m_firstComponentStart;
+ qint64 m_componentOffsetTableStart;
+
+ qint64 m_componentsDictCount;
+ qint64 m_firstComponentDictStart;
+ qint64 m_componentDictOffsetTableStart;
+
+ QList<Component*> m_rootComponents;
+ QList<Component*> m_updaterComponents;
+ QList<Component*> m_updaterComponentsDeps;
+
+ QList<KDUpdater::UpdateOperation*> m_ownedOperations;
+ QList<KDUpdater::UpdateOperation*> m_performedOperationsOld;
+ QList<KDUpdater::UpdateOperation*> m_performedOperationsCurrentSession;
+
+private:
+ void deleteUninstaller();
+ void registerUninstaller();
+ void unregisterUninstaller();
+
+ void writeUninstallerBinary(QFile *const input, qint64 size, bool writeBinaryLayout);
+ void writeUninstallerBinaryData(QIODevice *output, QFile *const input,
+ const QList<KDUpdater::UpdateOperation*> &performedOperations, const BinaryLayout &layout,
+ bool compressOperations, bool forceUncompressedResources);
+
+ void runUndoOperations(const QList<KDUpdater::UpdateOperation*> &undoOperations,
+ double undoOperationProgressSize, bool adminRightsGained, bool deleteOperation);
+
+private:
+ Installer *q;
+ qint64 m_magicBinaryMarker;
+};
+
+} // QInstaller
+
+#endif // QINSTALLER_P_H
diff --git a/installerbuilder/libinstaller/qinstallercomponent.cpp b/installerbuilder/libinstaller/qinstallercomponent.cpp
index c7987f96b..53749d575 100644
--- a/installerbuilder/libinstaller/qinstallercomponent.cpp
+++ b/installerbuilder/libinstaller/qinstallercomponent.cpp
@@ -31,13 +31,16 @@
**
**************************************************************************/
#include "qinstallercomponent.h"
-#include "qinstallerglobal.h"
-#include "messageboxhandler.h"
#include "common/errors.h"
#include "common/fileutils.h"
-
+#include "common/utils.h"
+#include "fsengineclient.h"
#include "lib7z_facade.h"
+#include "qinstaller.h"
+#include "qinstallercomponent_p.h"
+#include "qinstallerglobal.h"
+#include "messageboxhandler.h"
#include <KDUpdater/Update>
#include <KDUpdater/UpdateSourcesInfo>
@@ -45,363 +48,247 @@
#include <KDUpdater/UpdateOperationFactory>
#include <KDUpdater/PackagesInfo>
-#include <QApplication>
-#include <QDesktopServices>
-#include <QDir>
-#include <QDirIterator>
-#include <QHash>
-#include <QMessageBox>
-#include <QtCore/QPair>
-#include <QScriptEngine>
-#include <QScriptValue>
-#include <QTextStream>
-#include <QTranslator>
-#include <QUiLoader>
-
-#include <memory>
+#include <QtCore/QDirIterator>
+#include <QtCore/QTranslator>
-#include "common/utils.h"
-#include "fsengineclient.h"
+#include <QtGui/QApplication>
+
+#include <QtUiTools/QUiLoader>
+
+#include <algorithm>
using namespace QInstaller;
+static const QLatin1String skName("Name");
+static const QLatin1String skDisplayName("DisplayName");
+static const QLatin1String skDescription("Description");
+static const QLatin1String skDefault("Default");
+static const QLatin1String skCompressedSize("CompressedSize");
+static const QLatin1String skUncompressedSize("UncompressedSize");
+static const QLatin1String skVersion("Version");
+static const QLatin1String skDependencies("Dependencies");
+static const QLatin1String skReleaseDate("ReleaseDate");
+static const QLatin1String skReplaces("Replaces");
+static const QLatin1String skVirtual("Virtual");
+static const QLatin1String skSortingPriority("SortingPriority");
+static const QLatin1String skInstallPriority("InstallPriority");
+static const QLatin1String skImportant("Important");
+static const QLatin1String skForcedInstallation("ForcedInstallation");
+static const QLatin1String skUpdateText("UpdateText");
+static const QLatin1String skRequiresAdminRights("RequiresAdminRights");
+static const QLatin1String skNewComponent("NewComponent");
+static const QLatin1String skScript("Script");
+static const QLatin1String skInstalledVersion("InstalledVersion");
+
+static const QLatin1String skTrue("true");
+static const QLatin1String skFalse("false");
+
+static const QLatin1String skInstalled("Installed");
+static const QLatin1String skUninstalled("Uninstalled");
+static const QLatin1String skCurrentState("CurrentState");
+
/*
-TRANSLATOR QInstaller::Component
+ TRANSLATOR QInstaller::Component
*/
/*!
- \class QInstaller::Component
- Component describes a component within the installer.
+ \class QInstaller::Component
+ Component describes a component within the installer.
*/
-class QInstaller::Component::Private
-{
- QInstaller::Component* const q;
-public:
- Private( Installer* installer, QInstaller::Component* qq )
- : q( qq ),
- m_installer( installer ),
- m_parent( 0 ),
- m_offsetInInstaller( 0 ),
- autoCreateOperations( true ),
- operationsCreated( false ),
- removeBeforeUpdate( true ),
- enabled( true ),
- isCheckedFromUpdater( false ),
- m_newlyInstalled ( false ),
- operationsCreatedSuccessfully( true ),
- minimumProgressOperation(0),
- m_licenseOperation(0)
- {
- }
-
- static QMap< const Component*, Qt::CheckState > cachedCheckStates;
-
- Installer *m_installer;
- QHash<QString,QString> m_vars;
- QList< Component* > m_components;
- QList< KDUpdater::UpdateOperation* > operations;
-
- QList< QPair< QString, bool > > pathesForUninstallation;
-
- QMap< QString, QWidget* > userInterfaces;
-
- QUrl repositoryUrl;
- QString localTempPath;
- QStringList downloadableArchives;
- QStringList stopProcessForUpdateRequests;
-
- Component* m_parent;
-
- // filled before intaller runs
- qint64 m_offsetInInstaller;
-
- bool autoCreateOperations;
- bool operationsCreated;
-
- bool removeBeforeUpdate;
-
- bool enabled;
- bool isCheckedFromUpdater;
-
- bool m_newlyInstalled;
-
- bool operationsCreatedSuccessfully;
-
- QScriptEngine scriptEngine;
- QScriptValue scriptComponent;
-
- QHash< QString, bool > unexistingScriptMethods;
-
- void init();
- void setSelectedOnComponentList(const QList<Component*> &componentList,
- bool selected, RunModes runMode, SelectMode selectMode);
- KDUpdater::UpdateOperation* minimumProgressOperation;
-
- // < display name, < file name, file content > >
- QHash<QString, QPair<QString, QString> > m_licenses;
- KDUpdater::UpdateOperation *m_licenseOperation;
-};
-
-QMap< const Component*, Qt::CheckState > Component::Private::cachedCheckStates;
-
-void Component::Private::init()
+/*!
+ Constructor. Creates a new Component inside of \a installer.
+*/
+Component::Component(Installer *installer)
+ : d(new ComponentPrivate(installer, this))
{
- // register translation stuff
- scriptEngine.installTranslatorFunctions();
-
- // register QMessageBox::StandardButton enum in the script connection
- registerMessageBox( &scriptEngine );
-
- // register QDesktopServices in the script cennoction
- QScriptValue desktopServices = scriptEngine.newArray();
- desktopServices.setProperty( QLatin1String( "DesktopLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DesktopLocation ) ) );
- desktopServices.setProperty( QLatin1String( "DocumentsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DocumentsLocation ) ) );
- desktopServices.setProperty( QLatin1String( "FontsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::FontsLocation ) ) );
- desktopServices.setProperty( QLatin1String( "ApplicationsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::ApplicationsLocation ) ) );
- desktopServices.setProperty( QLatin1String( "MusicLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::MusicLocation ) ) );
- desktopServices.setProperty( QLatin1String( "MoviesLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::MoviesLocation ) ) );
- desktopServices.setProperty( QLatin1String( "PicturesLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::PicturesLocation ) ) );
- desktopServices.setProperty( QLatin1String( "TempLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::TempLocation ) ) );
- desktopServices.setProperty( QLatin1String( "HomeLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::HomeLocation ) ) );
- desktopServices.setProperty( QLatin1String( "DataLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DataLocation ) ) );
- desktopServices.setProperty( QLatin1String( "CacheLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::CacheLocation ) ) );
-
- desktopServices.setProperty( QLatin1String( "openUrl" ), scriptEngine.newFunction( qDesktopServicesOpenUrl ) );
- desktopServices.setProperty( QLatin1String( "displayName" ), scriptEngine.newFunction( qDesktopServicesDisplayName ) );
- desktopServices.setProperty( QLatin1String( "storageLocation" ), scriptEngine.newFunction( qDesktopServicesStorageLocation ) );
- scriptEngine.globalObject().setProperty( QLatin1String( "QDesktopServices" ), desktopServices );
-
- // register ::WizardPage enum in the script connection
- QScriptValue qinstaller = scriptEngine.newArray();
- qinstaller.setProperty( QLatin1String( "Introduction" ), scriptEngine.newVariant( static_cast< int >( Installer::Introduction ) ) );
- qinstaller.setProperty( QLatin1String( "LicenseCheck" ), scriptEngine.newVariant( static_cast< int >( Installer::LicenseCheck ) ) );
- qinstaller.setProperty( QLatin1String( "TargetDirectory" ), scriptEngine.newVariant( static_cast< int >( Installer::TargetDirectory ) ) );
- qinstaller.setProperty( QLatin1String( "ComponentSelection" ), scriptEngine.newVariant( static_cast< int >( Installer::ComponentSelection ) ) );
- qinstaller.setProperty( QLatin1String( "StartMenuSelection" ), scriptEngine.newVariant( static_cast< int >( Installer::StartMenuSelection ) ) );
- qinstaller.setProperty( QLatin1String( "ReadyForInstallation" ), scriptEngine.newVariant( static_cast< int >( Installer::ReadyForInstallation ) ) );
- qinstaller.setProperty( QLatin1String( "PerformInstallation" ), scriptEngine.newVariant( static_cast< int >( Installer::PerformInstallation ) ) );
- qinstaller.setProperty( QLatin1String( "InstallationFinished" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallationFinished ) ) );
- qinstaller.setProperty( QLatin1String( "End" ), scriptEngine.newVariant( static_cast< int >( Installer::End ) ) );
-
- // register ::Status enum in the script connection
- qinstaller.setProperty( QLatin1String( "InstallerUnfinished" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerUnfinished ) ) );
- qinstaller.setProperty( QLatin1String( "InstallerCanceledByUser" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerCanceledByUser ) ) );
- qinstaller.setProperty( QLatin1String( "InstallerFailed" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerFailed ) ) );
- qinstaller.setProperty( QLatin1String( "InstallerSucceeded" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerSucceeded ) ) );
-
- scriptEngine.globalObject().setProperty( QLatin1String( "QInstaller" ), qinstaller );
+ d->init();
+ setPrivate(d);
- scriptEngine.globalObject().setProperty( QLatin1String( "component" ), scriptEngine.newQObject( q ) );
- QScriptValue installerObject = scriptEngine.newQObject( m_installer );
- installerObject.setProperty( QLatin1String( "componentByName" ), scriptEngine.newFunction( qInstallerComponentByName, 1 ) );
- scriptEngine.globalObject().setProperty( QLatin1String( "installer" ), installerObject );
+ connect(this, SIGNAL(valueChanged(QString, QString)), this, SLOT(updateModelData(QString, QString)));
}
-void Component::Private::setSelectedOnComponentList(const QList<Component*> &componentList,
- bool selected, RunModes runMode, SelectMode selectMode)
+Component::Component(KDUpdater::Update* update, Installer* installer)
+ : d(new ComponentPrivate(installer, this))
{
- for( QList< Component* >::const_iterator it = componentList.begin(); it != componentList.end(); ++it )
- {
- Component* const comp = *it;
- if( comp->isSelected( runMode ) != selected)
- comp->setSelected( selected, runMode, selectMode );
- }
-}
+ Q_ASSERT(update);
-/*!
- Constructor. Creates a new Component inside of \a installer.
-*/
-Component::Component(Installer *installer)
- : d(new Component::Private( installer, this ) )
-{
d->init();
+ setPrivate(d);
+ connect(this, SIGNAL(valueChanged(QString, QString)), this, SLOT(updateModelData(QString, QString)));
+
+ loadDataFromUpdate(update);
}
/*!
- Destroys the Component.
+ Destroys the Component.
*/
Component::~Component()
{
- if( parentComponent() != 0 )
- d->m_parent->d->m_components.removeAll( this );
+ if (parentComponent() != 0)
+ d->m_parentComponent->d->m_allComponents.removeAll(this);
if (!d->m_newlyInstalled)
- qDeleteAll(d->operations);
+ qDeleteAll(d->m_operations);
- qDeleteAll( d->m_components );
+ qDeleteAll(d->m_allComponents);
delete d;
}
-//package info is that what is saved inside the packagemanager on harddisk
+// package info is that what is saved inside the package manager on hard disk
void Component::loadDataFromPackageInfo(const KDUpdater::PackageInfo &packageInfo)
{
- setValue(QLatin1String("Name"), packageInfo.name);
- setValue(QLatin1String("DisplayName"), packageInfo.title);
- setValue(QLatin1String("Description"), packageInfo.description);
- setValue(QLatin1String("UncompressedSize"),
- QString::number(packageInfo.uncompressedSize));
- setValue(QLatin1String("Version"), packageInfo.version);
- setValue(QLatin1String("Virtual"),
- packageInfo.virtualComp ? QLatin1String ("true") : QLatin1String ("false"));
+ setValue(skName, packageInfo.name);
+ setValue(skDisplayName, packageInfo.title);
+ setValue(skDescription, packageInfo.description);
+ setValue(skUncompressedSize, QString::number(packageInfo.uncompressedSize));
+ setValue(skVersion, packageInfo.version);
+ setValue(skVirtual, packageInfo.virtualComp ? skTrue : skFalse);
+
QString dependstr = QLatin1String("");
foreach (const QString& val, packageInfo.dependencies)
- dependstr += val + QLatin1String(",");
+ dependstr += val + QLatin1String(",");
+
if (packageInfo.dependencies.count() > 0)
dependstr.chop(1);
- setValue(QLatin1String("Dependencies"), dependstr);
- if (packageInfo.forcedInstallation)
- setValue(QLatin1String("ForcedInstallation"),
- packageInfo.forcedInstallation ? QLatin1String ("true") : QLatin1String ("false"));
+ setValue(skDependencies, dependstr);
+
+ setValue(skForcedInstallation, packageInfo.forcedInstallation ? skTrue : skFalse);
+ if (packageInfo.forcedInstallation) {
+ setEnabled(false);
+ setCheckable(false);
+ setCheckState(Qt::Checked);
+ }
}
-//update means it is the packageinfo from server
+// update means it is the package info from server
void Component::loadDataFromUpdate(KDUpdater::Update* update)
{
Q_ASSERT(update);
Q_ASSERT(!update->name().isEmpty());
- setValue(QLatin1String("Name"),
- update->data(QLatin1String("Name")).toString());
- setValue(QLatin1String("DisplayName"),
- update->data(QLatin1String("DisplayName")).toString());
- setValue(QLatin1String("Description"),
- update->data( QLatin1String("Description")).toString());
- setValue(QLatin1String("UncompressedSize"),
- QString::number(update->uncompressedSize()));
- setValue(QLatin1String("Version"),
- update->data(QLatin1String("Version")).toString());
- setValue(QLatin1String("ReleaseDate"),
- update->data(QLatin1String("ReleaseDate")).toString());
- setValue(QLatin1String("Dependencies"),
- update->data(QLatin1String("Dependencies")).toString());
- setValue(QLatin1String("Replaces"),
- update->data(QLatin1String("Replaces")).toString());
- setValue(QLatin1String("Virtual"),
- update->data(QLatin1String("Virtual")).toString());
- setValue(QLatin1String("SortingPriority"),
- update->data(QLatin1String("SortingPriority")).toString());
- setValue(QLatin1String("InstallPriority"),
- update->data(QLatin1String("InstallPriority")).toString());
- setValue(QLatin1String("AutoSelectOn"),
- update->data(QLatin1String("AutoSelectOn")).toString());
- setValue(QLatin1String("Important"),
- update->data(QLatin1String("Important")).toString());
-
+ setValue(skName, update->data(skName).toString());
+ setValue(skDisplayName, update->data(skDisplayName).toString());
+ setValue(skDescription, update->data(skDescription).toString());
+ setValue(skDefault, update->data(skDefault).toString());
+ setValue(skCompressedSize, QString::number(update->compressedSize()));
+ setValue(skUncompressedSize, QString::number(update->uncompressedSize()));
+ setValue(skVersion, update->data(skVersion).toString());
+ setValue(skDependencies, update->data(skDependencies).toString());
+ setValue(skVirtual, update->data(skVirtual).toString());
+ setValue(skSortingPriority, update->data(skSortingPriority).toString());
+ setValue(skInstallPriority, update->data(skInstallPriority).toString());
+
+ setValue(skImportant, update->data(skImportant).toString());
+ setValue(skUpdateText, update->data(skUpdateText).toString());
+ setValue(skNewComponent, update->data(skNewComponent).toString());
+ setValue(skRequiresAdminRights, update->data(skRequiresAdminRights).toString());
+
+ setValue(skScript, update->data(skScript).toString());
+ setValue(skReplaces, update->data(skReplaces).toString());
+ setValue(skReleaseDate, update->data(skReleaseDate).toString());
+
+ QString forced = update->data(skForcedInstallation, skFalse).toString().toLower();
if (qApp->arguments().contains(QLatin1String("--no-force-installations")))
- setValue(QLatin1String("ForcedInstallation"), QLatin1String("false"));
- else
- setValue(QLatin1String("ForcedInstallation"),
- update->data(QLatin1String("ForcedInstallation")).toString());
-
- setValue(QLatin1String("UpdateText"),
- update->data(QLatin1String("UpdateText")).toString());
- setValue(QLatin1String("RequiresAdminRights"),
- update->data(QLatin1String("RequiresAdminRights")).toString());
- setValue(QLatin1String("NewComponent"),
- update->data(QLatin1String("NewComponent")).toString());
- setValue(QLatin1String("Script"),
- update->data(QLatin1String("Script")).toString());
-
- const QString localPath = QInstaller::pathFromUrl(update->sourceInfo().url);
-
- //TODO: move this verbose output for the url to a location
- //where we don't need to check that is a newer url(so it would be better where the updates
- //are created)
- static QString lastLocalPath;
- if (lastLocalPath != localPath)
- verbose() << "Url is : " << localPath << std::endl;
- lastLocalPath = localPath;
+ forced = skFalse;
+ setValue(skForcedInstallation, forced);
+ if (forced == skTrue) {
+ setEnabled(false);
+ setCheckable(false);
+ setCheckState(Qt::Checked);
+ }
+ setLocalTempPath(QInstaller::pathFromUrl(update->sourceInfo().url));
const QStringList uis = update->data(QLatin1String("UserInterfaces")).toString()
.split(QString::fromLatin1(","), QString::SkipEmptyParts);
- if (!uis.isEmpty()) {
- verbose() << "Loading User Interface definitions for component " << name() << std::endl;
- loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localPath, name())), uis);
- }
+ if (!uis.isEmpty())
+ loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis);
const QStringList qms = update->data(QLatin1String("Translations")).toString()
.split(QString::fromLatin1(","), QString::SkipEmptyParts);
- if (!qms.isEmpty()) {
- verbose() << "Loading translations for component " << name() << std::endl;
- loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localPath, name())), qms);
- }
+ if (!qms.isEmpty())
+ loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms);
QHash<QString, QVariant> licenseHash = update->data(QLatin1String("Licenses")).toHash();
- if (!licenseHash.isEmpty()) {
- verbose() << "Loading licenses for component " << name() << std::endl;
- loadLicenses(QString::fromLatin1("%1/%2/").arg(localPath, name()), licenseHash);
- }
-
+ if (!licenseHash.isEmpty())
+ loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash);
}
-void Component::updateState(const bool selected)
+QString Component::uncompressedSize() const
{
- setValue(QLatin1String("PreviousState"),
- selected ? QLatin1String("Installed") : QLatin1String("Uninstalled"));
- setValue(QLatin1String("CurrentState"),
- value(QLatin1String("PreviousState")));
+ double size = value(skUncompressedSize).toDouble();
+ if (size < 10000.0)
+ return tr("%L1 Bytes").arg(size);
+ size /= 1024.0;
+ if (size < 10000.0)
+ return tr("%L1 kBytes").arg(size, 0, 'f', 1);
+ size /= 1024.0;
+ if (size < 10000.0)
+ return tr("%L1 MBytes").arg(size, 0, 'f', 1);
+ size /= 1024.0;
+ return tr("%L1 GBytes").arg(size, 0, 'f', 1);
}
-
-
void Component::markAsPerformedInstallation()
{
d->m_newlyInstalled = true;
}
/*!
- \property Component::removeBeforeUpdate
- Specifies wheter this component gets removed by the installer system before it gets updated.
- Get this property's value by using %removeBeforeUpdate(), and set it
- using %setRemoveBeforeUpdate(). The default value is true.
- */
+ \property Component::removeBeforeUpdate
+ Specifies whether this component gets removed by the installer system before it gets updated. Get this
+ property's value by using %removeBeforeUpdate(), and set it using %setRemoveBeforeUpdate(). The default
+ value is true.
+*/
bool Component::removeBeforeUpdate() const
{
- return d->removeBeforeUpdate;
+ return d->m_removeBeforeUpdate;
}
-void Component::setRemoveBeforeUpdate( bool removeBeforeUpdate )
+void Component::setRemoveBeforeUpdate(bool removeBeforeUpdate)
{
- d->removeBeforeUpdate = removeBeforeUpdate;
+ d->m_removeBeforeUpdate = removeBeforeUpdate;
}
QList<Component*> Component::dependees() const
{
- return d->m_installer->dependees( this );
+ return d->m_installer->dependees(this);
}
/*
- Returns a key/value based hash of all variables set for this component.
- */
+ Returns a key/value based hash of all variables set for this component.
+*/
QHash<QString,QString> Component::variables() const
{
return d->m_vars;
}
/*!
- Returns the value of variable name \a key. If \a key is not known yet, \a defaultValue is returned.
- */
-QString Component::value(const QString &key,
- const QString &defaultValue) const
+ Returns the value of variable name \a key.
+ If \a key is not known yet, \a defaultValue is returned.
+*/
+QString Component::value(const QString &key, const QString &defaultValue) const
{
return d->m_vars.value(key, defaultValue);
}
/*!
- Sets the value of the variable with \a key to \a value.
+ Sets the value of the variable with \a key to \a value.
*/
void Component::setValue(const QString &key, const QString &value)
{
- if( d->m_vars.value(key) == value )
+ if (d->m_vars.value(key) == value)
return;
- d->m_vars[ key ] = value;
- emit valueChanged( key, value );
+ if (key == QLatin1String("Name"))
+ d->m_componentName = value;
+
+ d->m_vars[key] = value;
+ emit valueChanged(key, value);
}
/*!
- Returnst the installer this component belongs to.
+ Returns the installer this component belongs to.
*/
Installer* Component::installer() const
{
@@ -409,103 +296,124 @@ Installer* Component::installer() const
}
/*!
- Returns the parent of this component. If this component is com.nokia.sdk.qt, its
- parent is com.nokia.sdk, as far as this exists.
- */
-Component* Component::parentComponent( RunModes runMode ) const
+ Returns the parent of this component. If this component is com.nokia.sdk.qt, its
+ parent is com.nokia.sdk, as far as this exists.
+*/
+Component* Component::parentComponent() const
{
- if ( runMode == UpdaterMode )
- return 0;
- else
- return d->m_parent;
+ return d->m_parentComponent;
}
/*!
Appends \a component as a child of this component. If \a component already has a parent,
it is removed from the previous parent.
- */
-void Component::appendComponent( Component* component )
+*/
+void Component::appendComponent(Component* component)
{
- d->m_components.append( component );
- if( component->parentComponent() != 0 )
- component->d->m_parent->d->m_components.removeAll( component );
- component->d->m_parent = this;
+ if (!component->isVirtual()) {
+ d->m_components.append(component);
+ std::sort(d->m_components.begin(), d->m_components.end(), Component::SortingPriorityLessThan());
+ } else {
+ d->m_virtualComponents.append(component);
+ }
+
+ d->m_allComponents = d->m_components + d->m_virtualComponents;
+ if (Component *parent = component->parentComponent())
+ parent->removeComponent(component);
+ component->d->m_parentComponent = this;
+ setTristate(d->m_components.count() > 0);
}
/*!
- Returns a list of child components. If \a recursive is set to true, the returned list
- contains not only the direct children, but all ancestors.
- */
-QList< Component* > Component::components( bool recursive, RunModes runMode ) const
-{
- if ( runMode == UpdaterMode )
- return QList < Component* >();
- if( !recursive )
- return d->m_components;
-
- QList< Component* > result;
- for( QList< Component* >::const_iterator it = d->m_components.begin(); it != d->m_components.end(); ++it )
- {
- result.append( *it );
- result += (*it)->components( true );
+ Removes \a component if it is a child of this component. The component object still exists after the
+ function returns. It's up to the caller to delete the passed component.
+*/
+void Component::removeComponent(Component *component)
+{
+ if (component->parentComponent() == this) {
+ component->d->m_parentComponent = 0;
+ d->m_components.removeAll(component);
+ d->m_virtualComponents.removeAll(component);
+ d->m_allComponents = d->m_components + d->m_virtualComponents;
+ }
+}
+
+/*!
+ Returns a list of child components. If \a recursive is set to true, the returned list
+ contains not only the direct children, but all ancestors.
+*/
+QList<Component*> Component::childComponents(bool recursive, RunMode runMode) const
+{
+ QList<Component*> result;
+ if (runMode == UpdaterMode)
+ return result;
+
+ if (!recursive)
+ return d->m_allComponents;
+
+ foreach (Component *component, d->m_allComponents) {
+ result.append(component);
+ result += component->childComponents(true, runMode);
}
return result;
}
/*!
- Contains this component's name (unique identifier).
- */
+ Contains this component's name (unique identifier).
+*/
QString Component::name() const
{
- return value( QLatin1String( "Name" ) );
+ return d->m_componentName;
}
/*!
- Contains this component's display name (as visible to the user).
- */
+ Contains this component's display name (as visible to the user).
+*/
QString Component::displayName() const
{
- return value( QLatin1String( "DisplayName" ) );
+ return value(skDisplayName);
}
void Component::loadComponentScript()
{
- const QString script = value(QLatin1String("Script"));
- if (!localTempPath().isEmpty() && !script.isEmpty()) {
- loadComponentScript(QString::fromLatin1("%1/%2/%3").arg(
- d->localTempPath, name(), script));
- }
+ const QString script = value(skScript);
+ if (!localTempPath().isEmpty() && !script.isEmpty())
+ loadComponentScript(QString::fromLatin1("%1/%2/%3").arg(localTempPath(), name(), script));
}
/*!
- Loads the script at \a fileName into this component's script engine.
- The installer and all its components as well as other useful stuff are being exported into the script.
- Read \link componentscripting Component Scripting \endlink for details.
- \throws Error when either the script at \a fileName couldn't be opened, or the QScriptEngine couldn't evaluate the script.
- */
-void Component::loadComponentScript( const QString& fileName )
-{
- QFile file( fileName );
- if( !file.open( QIODevice::ReadOnly ) )
- throw Error( QObject::tr( "Could not open the requested script file at %1: %2" ).arg( fileName, file.errorString() ) );
- d->scriptEngine.evaluate( QLatin1String( file.readAll() ), fileName );
- if( d->scriptEngine.hasUncaughtException() ) {
- throw Error( QObject::tr( "Exception while loading the component script %1" )
- .arg(uncaughtExceptionString(&(d->scriptEngine)/*, QFileInfo(file).absoluteFilePath()*/)) );
+ Loads the script at \a fileName into this component's script engine. The installer and all its
+ components as well as other useful stuff are being exported into the script.
+ Read \link componentscripting Component Scripting \endlink for details.
+ \throws Error when either the script at \a fileName couldn't be opened, or the QScriptEngine
+ couldn't evaluate the script.
+*/
+void Component::loadComponentScript(const QString &fileName)
+{
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly)) {
+ throw Error(QObject::tr("Could not open the requested script file at %1: %2").arg(fileName,
+ file.errorString()));
}
- const QList< Component* > components = d->m_installer->components( true );
- QScriptValue comps = d->scriptEngine.newArray( components.count() );
- for( int i = 0; i < components.count(); ++i ) {
- comps.setProperty( i, d->scriptEngine.newQObject( components[ i ] ) );
+ d->m_scriptEngine.evaluate(QLatin1String(file.readAll()), fileName);
+ if (d->m_scriptEngine.hasUncaughtException()) {
+ throw Error(QObject::tr("Exception while loading the component script %1")
+ .arg(uncaughtExceptionString(&(d->m_scriptEngine)/*, QFileInfo(file).absoluteFilePath()*/)));
}
- d->scriptEngine.globalObject().property( QLatin1String( "installer" ) ).setProperty( QLatin1String( "components" ), comps );
- QScriptValue comp = d->scriptEngine.evaluate( QLatin1String( "Component" ) );
- if( !d->scriptEngine.hasUncaughtException() )
- {
- d->scriptComponent = comp;
- d->scriptComponent.construct();
+ const QList<Component*> components = d->m_installer->components(true, d->m_installer->runMode());
+ QScriptValue comps = d->m_scriptEngine.newArray(components.count());
+ for (int i = 0; i < components.count(); ++i)
+ comps.setProperty(i, d->m_scriptEngine.newQObject(components[i]));
+
+ d->m_scriptEngine.globalObject().property(QLatin1String("installer"))
+ .setProperty(QLatin1String("components"), comps);
+
+ QScriptValue comp = d->m_scriptEngine.evaluate(QLatin1String("Component"));
+ if (!d->m_scriptEngine.hasUncaughtException()) {
+ d->m_scriptComponent = comp;
+ d->m_scriptComponent.construct();
}
emit loaded();
@@ -513,89 +421,91 @@ void Component::loadComponentScript( const QString& fileName )
}
/*!
- \internal
- Calls the script method \link retranslateUi() \endlink, if any. This is done whenever a QTranslator file is being loaded.
- */
+ \internal
+ Calls the script method \link retranslateUi() \endlink, if any. This is done whenever a
+ QTranslator file is being loaded.
+*/
void Component::languageChanged()
{
- callScriptMethod( QLatin1String( "retranslateUi" ) );
+ callScriptMethod(QLatin1String("retranslateUi"));
}
/*!
- Tries to call the method with \a name within the script and returns the result.
- If the method doesn't exist, an invalid result is returned. If the method has an uncaught exception, its string
- representation is thrown as an Error exception.
- \note The method is not called, if the current script context is the same method, to avoid infinite recursion.
- */
-QScriptValue Component::callScriptMethod( const QString& methodName, const QScriptValueList& arguments )
-{
- if( !d->unexistingScriptMethods.value( methodName, true ) )
+ Tries to call the method with \a name within the script and returns the result. If the method
+ doesn't exist, an invalid result is returned. If the method has an uncaught exception, its
+ string representation is thrown as an Error exception.
+
+ \note The method is not called, if the current script context is the same method, to avoid
+ infinite recursion.
+*/
+QScriptValue Component::callScriptMethod(const QString &methodName, const QScriptValueList& arguments) const
+{
+ if (!d->m_unexistingScriptMethods.value(methodName, true))
return QScriptValue();
// don't allow such a recursion
- if( d->scriptEngine.currentContext()->backtrace().first().startsWith( methodName ) )
+ if (d->m_scriptEngine.currentContext()->backtrace().first().startsWith(methodName))
return QScriptValue();
- QScriptValue method = d->scriptComponent.property( QString::fromLatin1( "prototype" ) ).property( methodName );
-
- if( !method.isValid() ) // this marks the method to be called not any longer
- d->unexistingScriptMethods[ methodName ] = false;
-
- const QScriptValue result = method.call( d->scriptComponent, arguments );
+ QScriptValue method = d->m_scriptComponent.property(QString::fromLatin1("prototype"))
+ .property(methodName);
+ if (!method.isValid()) // this marks the method to be called not any longer
+ d->m_unexistingScriptMethods[methodName] = false;
- if( !result.isValid() )
+ const QScriptValue result = method.call(d->m_scriptComponent, arguments);
+ if (!result.isValid())
return result;
- if( d->scriptEngine.hasUncaughtException() )
- throw Error( uncaughtExceptionString(&(d->scriptEngine)/*, name()*/) );
+ if (d->m_scriptEngine.hasUncaughtException())
+ throw Error(uncaughtExceptionString(&(d->m_scriptEngine)/*, name()*/));
return result;
}
/*!
- Loads the translations matching the name filters \a qms inside \a directory.
- Only translations with a \link QFileInfo::baseName() baseName \endlink matching the
- current locales \link QLocale::name() name \endlink are loaded.
- Read \ref componenttranslation for details.
- */
-void Component::loadTranslations( const QDir& directory, const QStringList& qms )
-{
- QDirIterator it( directory.path(), qms, QDir::Files );
- while( it.hasNext() )
- {
+ Loads the translations matching the name filters \a qms inside \a directory. Only translations
+ with a \link QFileInfo::baseName() baseName \endlink matching the current locales \link
+ QLocale::name() name \endlink are loaded.
+ Read \ref componenttranslation for details.
+*/
+void Component::loadTranslations(const QDir& directory, const QStringList& qms)
+{
+ QDirIterator it(directory.path(), qms, QDir::Files);
+ while (it.hasNext()) {
const QString filename = it.next();
- if( QFileInfo( filename ).baseName().toLower() != QLocale().name().toLower() )
+ if (QFileInfo(filename).baseName().toLower() != QLocale().name().toLower())
continue;
- std::auto_ptr<QTranslator> translator( new QTranslator( this ) );
- if( !translator->load( filename ) )
- throw Error( tr( "Could not open the requested translation file at %1" ).arg( filename ) );
- qApp->installTranslator( translator.release() );
+ QScopedPointer<QTranslator> translator(new QTranslator(this));
+ if (!translator->load(filename))
+ throw Error(tr("Could not open the requested translation file at %1").arg(filename));
+ qApp->installTranslator(translator.take());
}
}
/*!
- Loads the user interface files matching the name filters \a uis inside \a directory.
- The loaded interface can be accessed via userInterfaces by using the class name set in the ui file.
- Read \ref componentuserinterfaces for details.
- */
-void Component::loadUserInterfaces( const QDir& directory, const QStringList& uis )
+ Loads the user interface files matching the name filters \a uis inside \a directory. The loaded
+ interface can be accessed via userInterfaces by using the class name set in the ui file.
+ Read \ref componentuserinterfaces for details.
+*/
+void Component::loadUserInterfaces(const QDir& directory, const QStringList& uis)
{
- if( QApplication::type() == QApplication::Tty )
+ if (QApplication::type() == QApplication::Tty)
return;
- QDirIterator it( directory.path(), uis, QDir::Files );
- while( it.hasNext() )
- {
- QFile file( it.next() );
- if( !file.open( QIODevice::ReadOnly ) )
- throw Error( tr( "Could not open the requested UI file at %1: %2" ).arg( it.fileName(), file.errorString() ) );
+ QDirIterator it(directory.path(), uis, QDir::Files);
+ while (it.hasNext()) {
+ QFile file(it.next());
+ if (!file.open(QIODevice::ReadOnly)) {
+ throw Error(tr("Could not open the requested UI file at %1: %2").arg(it.fileName(),
+ file.errorString()));
+ }
static QUiLoader loader;
- loader.setTranslationEnabled( true );
- loader.setLanguageChangeEnabled( true );
- QWidget* const w = loader.load( &file );
- d->userInterfaces[ w->objectName() ] = w;
+ loader.setTranslationEnabled(true);
+ loader.setLanguageChangeEnabled(true);
+ QWidget* const w = loader.load(&file, MessageBoxHandler::currentBestSuitParent());
+ d->m_userInterfaces.insert(w->objectName(), w);
}
}
@@ -606,8 +516,8 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
for (it = licenseHash.begin(); it != licenseHash.end(); ++it) {
const QString &fileName = it.value().toString();
QFile file(directory + fileName);
- if(!file.open(QIODevice::ReadOnly)) {
- throw Error(tr("Could not open the requested license file at %1: %2" ).arg(fileName,
+ if (!file.open(QIODevice::ReadOnly)) {
+ throw Error(tr("Could not open the requested license file at %1: %2").arg(fileName,
file.errorString()));
}
d->m_licenses.insert(it.key(), qMakePair(fileName, QTextStream(&file).readAll()));
@@ -615,11 +525,11 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
}
/*!
- Contains a list of all user interface class names known to this component.
- */
+ Contains a list of all user interface class names known to this component.
+*/
QStringList Component::userInterfaces() const
{
- return d->userInterfaces.keys();
+ return d->m_userInterfaces.keys();
}
QHash<QString, QPair<QString, QString> > Component::licenses() const
@@ -628,225 +538,230 @@ QHash<QString, QPair<QString, QString> > Component::licenses() const
}
/*!
- Returns the QWidget created for class \a name.
- */
-QWidget* Component::userInterface( const QString& name ) const
+ Returns the QWidget created for class \a name.
+*/
+QWidget* Component::userInterface(const QString &name) const
{
- return d->userInterfaces.value( name );
+ return d->m_userInterfaces.value(name);
}
/*!
- Creates all operations needed to install this component's \a path.
- \a path is a full qualified filename including the component's name.
- This metods gets called from Component::createOperationsForArchive.
- You can override this method by providing a method with the same name in the component script.
- \note If you call this method from a script, it won't call the scripts method with the same name.
- \note RSA signature files are omitted by this method.
+ Creates all operations needed to install this component's \a path. \a path is a full qualified
+ filename including the component's name. This methods gets called from
+ Component::createOperationsForArchive. You can override this method by providing a method with
+ the same name in the component script.
- The default implemention is recursively creating Copy and Mkdir operations for all files
- and folders within \a path.
- */
-void Component::createOperationsForPath( const QString& path )
+ \note RSA signature files are omitted by this method.
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+
+ The default implementation is recursively creating Copy and Mkdir operations for all files
+ and folders within \a path.
+*/
+void Component::createOperationsForPath(const QString &path)
{
- const QFileInfo fi( path );
+ const QFileInfo fi(path);
// don't copy over a signature
- if( fi.suffix() == QLatin1String( "sig" ) && QFileInfo( fi.dir(), fi.completeBaseName() ).exists() )
+ if (fi.suffix() == QLatin1String("sig") && QFileInfo(fi.dir(), fi.completeBaseName()).exists())
return;
// the script can override this method
- if( callScriptMethod( QLatin1String( "createOperationsForPath" ), QScriptValueList() << path ).isValid() )
+ if (callScriptMethod(QLatin1String("createOperationsForPath"), QScriptValueList() << path).isValid())
return;
- static const QString zipPrefix = QString::fromLatin1( "7z://installer://" );
- static const QString prefix = QString::fromLatin1( "installer://" );
QString target;
- if ( path.startsWith( zipPrefix ) ) { // if the path is an archive, remove the archive file name from the target path
- target = path.mid( zipPrefix.length() + name().length() + 1 ); // + 1 for the /
- const int nextSlash = target.indexOf( QLatin1Char('/') );
- if ( nextSlash != -1 )
- target = target.mid( nextSlash );
+ static const QString zipPrefix = QString::fromLatin1("7z://installer://");
+ // if the path is an archive, remove the archive file name from the target path
+ if (path.startsWith(zipPrefix)) {
+ target = path.mid(zipPrefix.length() + name().length() + 1); // + 1 for the /
+ const int nextSlash = target.indexOf(QLatin1Char('/'));
+ if (nextSlash != -1)
+ target = target.mid(nextSlash);
else
target.clear();
target.prepend(QLatin1String("@TargetDir@"));
+ } else {
+ static const QString prefix = QString::fromLatin1("installer://");
+ target = QString::fromLatin1("@TargetDir@%1").arg(path.mid(prefix.length() + name().length()));
}
- else
- target = QString::fromLatin1( "@TargetDir@%1" ).arg( path.mid( prefix.length() + name().length() ) );
- static const QString copy = QString::fromLatin1( "Copy" );
- static const QString mkdir = QString::fromLatin1( "Mkdir" );
- if( fi.isFile() )
- {
- addOperation( copy, fi.filePath(), target );
- }
- else if( fi.isDir() )
- {
+
+ if (fi.isFile()) {
+ static const QString copy = QString::fromLatin1("Copy");
+ addOperation(copy, fi.filePath(), target);
+ } else if (fi.isDir()) {
qApp->processEvents();
- addOperation( mkdir, target );
- QDirIterator it( fi.filePath() );
- while( it.hasNext() )
- createOperationsForPath( it.next() );
- }
+ static const QString mkdir = QString::fromLatin1("Mkdir");
+ addOperation(mkdir, target);
+ QDirIterator it(fi.filePath());
+ while (it.hasNext())
+ createOperationsForPath(it.next());
+ }
}
/*!
- Creates all operations needed to install this component's \a archive.
- This metods gets called from Component::createOperations.
- You can override this method by providing a method with the same name in the component script.
- \note If you call this method from a script, it won't call the scripts method with the same name.
-
- The default implementation calls createOperationsForPath for everything contained in the archive.
- If \a archive is a compressed archive known to the installer system, an Extract operation is created, instead.
- */
-void Component::createOperationsForArchive( const QString& archive )
+ Creates all operations needed to install this component's \a archive. This metods gets called
+ from Component::createOperations. You can override this method by providing a method with the
+ same name in the component script.
+
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+
+ The default implementation calls createOperationsForPath for everything contained in the archive.
+ If \a archive is a compressed archive known to the installer system, an Extract operation is
+ created, instead.
+*/
+void Component::createOperationsForArchive(const QString &archive)
{
// the script can override this method
- if( callScriptMethod( QLatin1String( "createOperationsForArchive" ), QScriptValueList() << archive ).isValid() )
+ if (callScriptMethod(QLatin1String("createOperationsForArchive"), QScriptValueList() << archive).isValid())
return;
- const QFileInfo fi( QString::fromLatin1( "installer://%1/%2").arg( name(), archive ) );
- const bool isZip = Lib7z::isSupportedArchive( fi.filePath() );
+ const QFileInfo fi(QString::fromLatin1("installer://%1/%2").arg(name(), archive));
+ const bool isZip = Lib7z::isSupportedArchive(fi.filePath());
- if( !isZip )
- createOperationsForPath( fi.filePath() );
- else
+ if (isZip) {
// archives get completely extracted per default (if the script isn't doing other stuff)
- addOperation( QLatin1String( "Extract" ), fi.filePath(), QLatin1String( "@TargetDir@" ) );
+ addOperation(QLatin1String("Extract"), fi.filePath(), QLatin1String("@TargetDir@"));
+ } else {
+ createOperationsForPath(fi.filePath());
+ }
}
/*!
- Creates all operations needed to install this component.
- You can override this method by providing a method with the same name in the component script.
- \note If you call this method from a script, it won't call the scripts method with the same name.
-
- The default implementation calls createOperationsForArchive for all archives in this component.
+ Creates all operations needed to install this component.
+ You can override this method by providing a method with the same name in the component script.
+
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+
+ The default implementation calls createOperationsForArchive for all archives in this component.
*/
void Component::createOperations()
{
// the script can override this method
- if( callScriptMethod( QLatin1String( "createOperations" ) ).isValid() )
- {
- d->operationsCreated = true;
+ if (callScriptMethod(QLatin1String("createOperations")).isValid()) {
+ d->m_operationsCreated = true;
return;
}
- const QDir dir( QString::fromLatin1( "installer://%1/" ).arg( name() ) );
- const QStringList archives = dir.entryList();
- for( QStringList::const_iterator it = archives.begin(); it != archives.end(); ++it )
- createOperationsForArchive( *it );
+ foreach (const QString &archive, archives())
+ createOperationsForArchive(archive);
- d->operationsCreated = true;
+ d->m_operationsCreated = true;
}
/*!
- Registers the file or directory at \a path for being removed when this component gets uninstalled.
- In case of a directory, this will be recursive.
- If \a wipe is set to true, the directory will also be deleted if it contains changes done by the user
- after installation.
+ Registers the file or directory at \a path for being removed when this component gets uninstalled.
+ In case of a directory, this will be recursive. If \a wipe is set to true, the directory will
+ also be deleted if it contains changes done by the user after installation.
*/
-void Component::registerPathForUninstallation( const QString& path, bool wipe )
+void Component::registerPathForUninstallation(const QString &path, bool wipe)
{
- d->pathesForUninstallation.append( qMakePair( path, wipe ) );
+ d->m_pathesForUninstallation.append(qMakePair(path, wipe));
}
/*!
- Returns the list of pathes previously registered for uninstallation with #registerPathForUninstallation.
+ Returns the list of paths previously registered for uninstallation with
+ #registerPathForUninstallation.
*/
-QList< QPair< QString, bool > > Component::pathesForUninstallation() const
+QList<QPair<QString, bool> > Component::pathesForUninstallation() const
{
- return d->pathesForUninstallation;
+ return d->m_pathesForUninstallation;
}
/*!
- Contains the names of all archives known to this component. This does not contain archives added
- with #addDownloadableArchive.
- */
+ Contains the names of all archives known to this component. This does not contain archives added
+ with #addDownloadableArchive.
+*/
QStringList Component::archives() const
{
- return QDir( QString::fromLatin1( "installer://%1/" ).arg( name() ) ).entryList();
+ return QDir(QString::fromLatin1("installer://%1/").arg(name())).entryList();
}
/*!
- Adds the archive \a path to this component. This can only be called when this component was downloaded from
- an online repository. When adding \a path, it will be downloaded from the repository when the installation starts.
- Read \ref sec_repogen for details.
- \sa fromOnlineRepository
- */
-void Component::addDownloadableArchive( const QString& path )
-{
- Q_ASSERT( isFromOnlineRepository() );
- const QString versionPrefix = value( QLatin1String( "Version" ) );
+ Adds the archive \a path to this component. This can only be called when this component was
+ downloaded from an online repository. When adding \a path, it will be downloaded from the
+ repository when the installation starts.
+
+ Read \ref sec_repogen for details. \sa fromOnlineRepository
+*/
+void Component::addDownloadableArchive(const QString &path)
+{
+ Q_ASSERT(isFromOnlineRepository());
+
+ const QString versionPrefix = value(skVersion);
verbose() << "addDownloadable " << path << std::endl;
- d->downloadableArchives.append( versionPrefix + path );
+ d->m_downloadableArchives.append(versionPrefix + path);
}
-
+
/*!
- Removes the archive \a path previously added via addDownloadableArchive from this component. This can oly be
- called when this component was downloaded from an online repository. Read \ref sec_repogen for details.
- */
-void Component::removeDownloadableArchive( const QString& path )
+ Removes the archive \a path previously added via addDownloadableArchive from this component.
+ This can oly be called when this component was downloaded from an online repository.
+
+ Read \ref sec_repogen for details.
+*/
+void Component::removeDownloadableArchive(const QString &path)
{
- Q_ASSERT( isFromOnlineRepository() );
- d->downloadableArchives.removeAll( path );
+ Q_ASSERT(isFromOnlineRepository());
+ d->m_downloadableArchives.removeAll(path);
}
/*!
- Returns the archives to be downloaded from the online repository before installation.
- */
+ Returns the archives to be downloaded from the online repository before installation.
+*/
QStringList Component::downloadableArchives() const
{
- return d->downloadableArchives;
+ return d->m_downloadableArchives;
}
/*!
- * Adds a request for quitting the process @p process before installing/updating/uninstalling the
- * component.
- */
-void Component::addStopProcessForUpdateRequest( const QString& process )
+ Adds a request for quitting the process @p process before installing/updating/uninstalling the
+ component.
+*/
+void Component::addStopProcessForUpdateRequest(const QString &process)
{
- d->stopProcessForUpdateRequests.append( process );
+ d->m_stopProcessForUpdateRequests.append(process);
}
/*!
-* Removes the request for quitting the process @p process again.
+ Removes the request for quitting the process @p process again.
*/
-void Component::removeStopProcessForUpdateRequest( const QString& process )
+void Component::removeStopProcessForUpdateRequest(const QString &process)
{
- d->stopProcessForUpdateRequests.removeAll( process );
+ d->m_stopProcessForUpdateRequests.removeAll(process);
}
/*!
-* Convenience: Add/remove request depending on @p requested (add if @p true, remove if @p false).
+ Convenience: Add/remove request depending on @p requested (add if @p true, remove if @p false).
*/
-void Component::setStopProcessForUpdateRequest( const QString& process, bool requested )
+void Component::setStopProcessForUpdateRequest(const QString &process, bool requested)
{
- if ( requested )
- addStopProcessForUpdateRequest( process );
+ if (requested)
+ addStopProcessForUpdateRequest(process);
else
- removeStopProcessForUpdateRequest( process );
+ removeStopProcessForUpdateRequest(process);
}
/*!
- * The list of processes this component needs to be closed before installing/updating/uninstalling
- */
+ The list of processes this component needs to be closed before installing/updating/uninstalling
+*/
QStringList Component::stopProcessForUpdateRequests() const
{
- return d->stopProcessForUpdateRequests;
+ return d->m_stopProcessForUpdateRequests;
}
/*!
- Returns the operations needed to install this component. If autoCreateOperations is true, createOperations
- is called, if no operations have been auto-created yet.
- */
-QList< KDUpdater::UpdateOperation* > Component::operations() const
+ Returns the operations needed to install this component. If autoCreateOperations is true,
+ createOperations is called, if no operations have been auto-created yet.
+*/
+QList<KDUpdater::UpdateOperation*> Component::operations() const
{
- if (d->autoCreateOperations && !d->operationsCreated) {
- const_cast< Component* >( this )->createOperations();
+ if (d->m_autoCreateOperations && !d->m_operationsCreated) {
+ const_cast<Component*>(this)->createOperations();
- if (!d->minimumProgressOperation) {
- d->minimumProgressOperation = KDUpdater::UpdateOperationFactory::instance()
+ if (!d->m_minimumProgressOperation) {
+ d->m_minimumProgressOperation = KDUpdater::UpdateOperationFactory::instance()
.create(QLatin1String("MinimumProgress"));
- d->operations.append(d->minimumProgressOperation);
+ d->m_operations.append(d->m_minimumProgressOperation);
}
if (!d->m_licenses.isEmpty()) {
@@ -860,390 +775,302 @@ QList< KDUpdater::UpdateOperation* > Component::operations() const
for (int i = 0; i < values.count(); ++i)
licenses.insert(values.at(i).first, values.at(i).second);
d->m_licenseOperation->setValue(QLatin1String("licenses"), licenses);
- d->operations.append(d->m_licenseOperation);
+ d->m_operations.append(d->m_licenseOperation);
}
}
- return d->operations;
+ return d->m_operations;
}
/*!
- Adds \a operation to the list of operations needed to install this component.
- */
-void Component::addOperation( KDUpdater::UpdateOperation* operation )
+ Adds \a operation to the list of operations needed to install this component.
+*/
+void Component::addOperation(KDUpdater::UpdateOperation* operation)
{
- d->operations.append( operation );
- if( FSEngineClientHandler::instance()->isActive() )
- operation->setValue( QLatin1String( "admin" ), true );
+ d->m_operations.append(operation);
+ if (FSEngineClientHandler::instance()->isActive())
+ operation->setValue(QLatin1String("admin"), true);
}
/*!
- Adds \a operation to the list of operations needed to install this component. \a operation
- is executed with elevated rights.
- */
-void Component::addElevatedOperation( KDUpdater::UpdateOperation* operation )
+ Adds \a operation to the list of operations needed to install this component. \a operation
+ is executed with elevated rights.
+*/
+void Component::addElevatedOperation(KDUpdater::UpdateOperation* operation)
{
- addOperation( operation );
- operation->setValue( QLatin1String( "admin" ), true );
+ addOperation(operation);
+ operation->setValue(QLatin1String("admin"), true);
}
bool Component::operationsCreatedSuccessfully() const
{
- return d->operationsCreatedSuccessfully;
-}
+ return d->m_operationsCreatedSuccessfully;
+}
+
+KDUpdater::UpdateOperation* Component::createOperation(const QString &operation,
+ const QString &parameter1, const QString &parameter2, const QString &parameter3,
+ const QString &parameter4, const QString &parameter5, const QString &parameter6,
+ const QString &parameter7, const QString &parameter8, const QString &parameter9,
+ const QString &parameter10)
+{
+ KDUpdater::UpdateOperation* op = KDUpdater::UpdateOperationFactory::instance().create(operation);
+ if (op == 0) {
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("OperationDoesNotExistError"), tr("Error"),
+ tr("Error: Operation %1 does not exist").arg(operation),
+ QMessageBox::Abort | QMessageBox::Ignore);
+ if (button == QMessageBox::Abort)
+ d->m_operationsCreatedSuccessfully = false;
+ return op;
+ }
+
+ if (op->name() == QLatin1String("Delete"))
+ op->setValue(QLatin1String("performUndo"), false);
+ op->setValue(QLatin1String("installer"), qVariantFromValue(d->m_installer));
+ QStringList arguments;
+ if (!parameter1.isNull())
+ arguments.append(parameter1);
+ if (!parameter2.isNull())
+ arguments.append(parameter2);
+ if (!parameter3.isNull())
+ arguments.append(parameter3);
+ if (!parameter4.isNull())
+ arguments.append(parameter4);
+ if (!parameter5.isNull())
+ arguments.append(parameter5);
+ if (!parameter6.isNull())
+ arguments.append(parameter6);
+ if (!parameter7.isNull())
+ arguments.append(parameter7);
+ if (!parameter8.isNull())
+ arguments.append(parameter8);
+ if (!parameter9.isNull())
+ arguments.append(parameter9);
+ if (!parameter10.isNull())
+ arguments.append(parameter10);
+ op->setArguments(d->m_installer->replaceVariables(arguments));
+
+ return op;
+}
/*!
- Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6
- The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained.
- \sa installeroperations
- */
-bool Component::addOperation( const QString& operation, const QString& parameter1, const QString& parameter2, const QString& parameter3, const QString& parameter4, const QString& parameter5, const QString& parameter6, const QString& parameter7, const QString& parameter8, const QString& parameter9, const QString& parameter10 )
-{
- KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( operation );
- if( op == 0 )
- {
- const QMessageBox::StandardButton button = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String( "operationDoesNotExistError" ), tr( "Error" ),
- tr( "Error: Operation %1 does not exist" ).arg( operation ),
- QMessageBox::Abort | QMessageBox::Ignore );
- if ( button == QMessageBox::Abort )
- {
- d->operationsCreatedSuccessfully = false;
- }
- return false;
+ Creates and adds an installation operation for \a operation. Add any number of \a parameter1,
+ \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6. The contents of
+ the parameters get variables like "@TargetDir@" replaced with their values, if contained.
+ \sa installeroperations
+*/
+bool Component::addOperation(const QString &operation, const QString &parameter1,
+ const QString &parameter2, const QString &parameter3, const QString &parameter4,
+ const QString &parameter5, const QString &parameter6, const QString &parameter7,
+ const QString &parameter8, const QString &parameter9, const QString &parameter10)
+{
+ if (KDUpdater::UpdateOperation *op = createOperation(operation, parameter1, parameter2,
+ parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9,
+ parameter10)) {
+ addOperation(op);
+ return true;
}
- if ( op->name() == QLatin1String( "Delete" ) )
- op->setValue( QLatin1String( "performUndo" ), false );
- op->setValue( QLatin1String( "installer" ), qVariantFromValue( d->m_installer ) );
-
- QStringList arguments;
- if( !parameter1.isNull() )
- arguments.append( parameter1 );
- if( !parameter2.isNull() )
- arguments.append( parameter2 );
- if( !parameter3.isNull() )
- arguments.append( parameter3 );
- if( !parameter4.isNull() )
- arguments.append( parameter4 );
- if( !parameter5.isNull() )
- arguments.append( parameter5 );
- if( !parameter6.isNull() )
- arguments.append( parameter6 );
- if( !parameter7.isNull() )
- arguments.append( parameter7 );
- if( !parameter8.isNull() )
- arguments.append( parameter8 );
- if( !parameter9.isNull() )
- arguments.append( parameter9 );
- if( !parameter10.isNull() )
- arguments.append( parameter10 );
- op->setArguments( d->m_installer->replaceVariables( arguments ) );
-
- addOperation( op );
-
- return true;
+
+ return false;
}
/*!
- Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6
- The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained. \a operation is executed with
- elevated rights.
- \sa installeroperations
- */
-bool Component::addElevatedOperation( const QString& operation, const QString& parameter1, const QString& parameter2, const QString& parameter3, const QString& parameter4, const QString& parameter5, const QString& parameter6, const QString& parameter7, const QString& parameter8, const QString& parameter9, const QString& parameter10 )
-{
- KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( operation );
- if( op == 0 )
- return false;
-
- op->setValue( QLatin1String( "installer" ), qVariantFromValue( d->m_installer ) );
-
- QStringList arguments;
- if( !parameter1.isNull() )
- arguments.append( parameter1 );
- if( !parameter2.isNull() )
- arguments.append( parameter2 );
- if( !parameter3.isNull() )
- arguments.append( parameter3 );
- if( !parameter4.isNull() )
- arguments.append( parameter4 );
- if( !parameter5.isNull() )
- arguments.append( parameter5 );
- if( !parameter6.isNull() )
- arguments.append( parameter6 );
- if( !parameter7.isNull() )
- arguments.append( parameter7 );
- if( !parameter8.isNull() )
- arguments.append( parameter8 );
- if( !parameter9.isNull() )
- arguments.append( parameter9 );
- if( !parameter10.isNull() )
- arguments.append( parameter10 );
- op->setArguments( d->m_installer->replaceVariables( arguments ) );
-
- addElevatedOperation( op );
-
- return true;
-}
+ Creates and adds an installation operation for \a operation. Add any number of \a parameter1,
+ \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6. The contents of
+ the parameters get variables like "@TargetDir@" replaced with their values, if contained.
+ \a operation is executed with elevated rights.
+ \sa installeroperations
+*/
+bool Component::addElevatedOperation(const QString &operation, const QString &parameter1, const QString &parameter2, const QString &parameter3, const QString &parameter4, const QString &parameter5, const QString &parameter6, const QString &parameter7, const QString &parameter8, const QString &parameter9, const QString &parameter10)
+{
+ if (KDUpdater::UpdateOperation *op = createOperation(operation, parameter1, parameter2,
+ parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9,
+ parameter10)) {
+ addElevatedOperation(op);
+ return true;
+ }
+ return false;
+}
/*!
- Specifies wheter operations should be automatically created when the installation starts. This would be done by calling #createOperations.
- If you set this to false, it's completely up to the component's script to create all operations.
- */
+ Specifies whether operations should be automatically created when the installation starts. This
+ would be done by calling #createOperations. If you set this to false, it's completely up to the
+ component's script to create all operations.
+*/
bool Component::autoCreateOperations() const
{
- return d->autoCreateOperations;
+ return d->m_autoCreateOperations;
}
-void Component::setAutoCreateOperations( bool autoCreateOperations )
+void Component::setAutoCreateOperations(bool autoCreateOperations)
{
- d->autoCreateOperations = autoCreateOperations;
+ d->m_autoCreateOperations = autoCreateOperations;
}
-Qt::CheckState Component::checkState( RunModes runMode ) const
+bool Component::isVirtual() const
{
- if ( runMode == UpdaterMode )
- return d->isCheckedFromUpdater ? Qt::Checked : Qt::Unchecked;
- const QMap< const Component*, Qt::CheckState >::const_iterator it = Private::cachedCheckStates.find( this );
- if( it != Private::cachedCheckStates.end() )
- return *it;
- const Qt::CheckState state = componentCheckState( this, runMode );
- Private::cachedCheckStates[ this ] = state;
- return state;
+ return value(skVirtual, skFalse).toLower() == skTrue;
}
/*!
- \property Component::selected
- Specifies wheter this component is selected for installation.
- Get this property's value by using %isSelected(), and set it
- using %setSelected().
- */
-bool Component::isSelected( RunModes runMode ) const
-{
- const Qt::CheckState state = checkState( runMode );
- return state != Qt::Unchecked;
-}
-
-//SelectMode means:
-//NormalSelectMode - dependency errors and selectionChanged SIGNAL are emitted
-//InitializeComponentTreeSelectMode - no dependency errors(maybe some components are not ready initialized),
-// no selectionChanged SIGNAL needed and no recursion
-void Component::setSelected(bool selected, RunModes runMode, SelectMode selectMode)
-{
- if ( runMode == UpdaterMode )
- {
- verbose() << "Update selection" << std::endl;
- QStringList missingNames;
- d->m_installer->dependencies( this, &missingNames );
-
- if ( !missingNames.isEmpty() )
- {
- const QString missingPackages = missingNames.join( QLatin1String( " " ) );
- if ( selectMode == NormalSelectMode ) {
- MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String( "DependenciesMissingError" ), tr( "Dependencies Missing" ),
- tr( "The following required packages could not be found : %1!" ).arg( missingPackages ),
- QMessageBox::Ok );
- }
- verbose() << "Error occured missing dependencies" << missingPackages << std::endl;
- return;
- } else {
- verbose() << "No Error occured" << std::endl;
- }
- const Qt::CheckState previousState = checkState( UpdaterMode );
- const Qt::CheckState newState = selected ? Qt::Checked : Qt::Unchecked;
- d->isCheckedFromUpdater = selected;
- // we have to select all dependees as well
- if ( selected )
- {
- verbose() << "Update selected for " << name() <<std::endl;
- const QList< Component* > dependees = d->m_installer->missingDependencies( this );
- d->setSelectedOnComponentList(dependees, true, runMode, selectMode);
- }
- if( !selected )
- {
- // if it got deselected, we have to deselect all dependees as well
- verbose() << "Update deselected" << name() << std::endl;
- const QList< Component* > dependees = d->m_installer->dependees( this );
- d->setSelectedOnComponentList(dependees, false, runMode, selectMode);
- }
- //we need selectedChanged even it is not in the NormalSelectMode to check the running processes from script side
- //for installpart it is working because we are selecting the components in the script as well
- //TODO: change this ^ behaviour in scripts and code
- if( /*selectMode == NormalSelectMode && */newState != previousState )
- QMetaObject::invokeMethod( this, "selectedChanged", Qt::QueuedConnection, Q_ARG( bool, newState == Qt::Checked ) );
-
- } else {
- QMap< Component*, Qt::CheckState > previousStates;
- const QList< Component* > allComponents = d->m_installer->components( true );
- for( QList< Component* >::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it )
- previousStates[ *it ] = (*it)->checkState();
-
- setValue( QString::fromLatin1( "WantedState" ), selected ? QString::fromLatin1( "Installed" ) : QString::fromLatin1( "Uninstalled" ) );
- Private::cachedCheckStates.clear();
-
- if ( selected )
- {
- verbose() << "Update selected for " << name() << std::endl;
- const QList< Component* > dependees = d->m_installer->missingDependencies( this );
- d->setSelectedOnComponentList(dependees, true, runMode, selectMode);
- }
-
- if( !selected )
- {
- // if it got deselected, we have to deselect all dependees as well
- const QList< Component* > dependees = d->m_installer->dependees( this );
- d->setSelectedOnComponentList(dependees, false, runMode, selectMode);
-
- //if we are the last visible component, we need to check our virtual siblings
- if (parentComponent() && value(QLatin1String("Virtual"), QLatin1String("false")).toLower()
- == QLatin1String("false"))
- {
- QList<Component*> virtualSiblingComponents;
- QString parentComponentName = parentComponent()->name();
- QList<Component*> siblingComponents = parentComponent()->components(true, runMode);
- foreach (Component* currentComponent, siblingComponents) {
- //if there is one visible selected component, we don't want to unselect other components
- if (currentComponent->isSelected() &&
- currentComponent->value(QLatin1String("Virtual"), QLatin1String("false"))
- .toLower() == QLatin1String("false")) {
- virtualSiblingComponents.clear();
- break;
- }
- if (currentComponent->isSelected() &&
- currentComponent->value(QLatin1String("Virtual"), QLatin1String("false"))
- .toLower() == QLatin1String("true")) {
- virtualSiblingComponents.append(currentComponent);
- }
- }
- d->setSelectedOnComponentList(virtualSiblingComponents, false, runMode,
- Component::InitializeComponentTreeSelectMode);
- }
+ \property Component::selected
+ Specifies whether this component is selected for installation. Get this property's value by using
+ %isSelected(), and set it using %setSelected().
+*/
+bool Component::isSelected() const
+{
+ return checkState() != Qt::Unchecked;
+}
- }
+bool Component::forcedInstallation() const
+{
+ return value(skForcedInstallation, skFalse).toLower() == skTrue;
+}
- // and all children
- if ( selectMode == NormalSelectMode )
- {
- const QList< Component* > children = components( true );
- for( QList< Component* >::const_iterator it = children.begin(); it != children.end(); ++it )
- {
- Component* const comp = *it;
- comp->setValue( QString::fromLatin1( "WantedState" ), selected ? QString::fromLatin1( "Installed" ) : QString::fromLatin1( "Uninstalled" ) );
- }
-
- //now all needed components are selected so we can emit the signals
- for( QList< Component* >::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it )
- {
- const Qt::CheckState newCheckState = (*it)->checkState();
- if( previousStates[ *it ] != newCheckState )
- QMetaObject::invokeMethod( *it, "selectedChanged", Qt::QueuedConnection, Q_ARG( bool, newCheckState == Qt::Checked ) );
- //emit (*it)->selectedChanged( state == Qt::Checked );
- }
- }
- }
+/*!
+ Marks the component for installation. Emits the selectedChanged() signal if the check state changes.
+*/
+void Component::setSelected(bool selected)
+{
+ Q_UNUSED(selected)
+ verbose() << Q_FUNC_INFO << qPrintable(QString(QLatin1String("on \"%1\" is deprecated!!!")).arg(
+ d->m_componentName)) << std::endl;
}
/*!
- * Contains this component dependencies.
- * Read \ref componentdependencies for details.
- */
+ Contains this component dependencies.
+ Read \ref componentdependencies for details.
+*/
QStringList Component::dependencies() const
{
- return value( QLatin1String( "Dependencies" ) ).split( QLatin1Char( ',' ) );
+ return value(skDependencies).split(QLatin1Char(','));
}
/*!
- * Determines if the component is installed
- */
-bool Component::isInstalled() const
+ Set's the components state to installed.
+*/
+void Component::setInstalled()
{
- return QLatin1String( "Installed" ) == value( QLatin1String( "CurrentState" ) );
+ setValue(skCurrentState, skInstalled);
}
/*!
- * Determines if the user wants to install the component
- */
-bool Component::installationRequested() const
+ Determines if the component is a default one.
+*/
+bool Component::isDefault() const
{
- return ( QLatin1String( "Installed" ) == value( QLatin1String( "WantedState" ) ) && ( !isInstalled() || isSelected( UpdaterMode ) ) );
+ // the script can override this method
+ if (value(skDefault).compare(QLatin1String("script"), Qt::CaseInsensitive) == 0) {
+ const QScriptValue valueFromScript = callScriptMethod(QLatin1String("isDefault"));
+ if (valueFromScript.isValid()) {
+ return valueFromScript.toBool();
+ }
+ verbose() << "value from script is not valid " << std::endl;
+ return false;
+ }
+
+ return value(skDefault).compare(QLatin1String("true"), Qt::CaseInsensitive) == 0;
}
/*!
- * Determines if the user wants to install the component
- */
-bool Component::uninstallationRequested() const
+ Determines if the component is installed.
+*/
+bool Component::isInstalled() const
{
- return QLatin1String( "Uninstalled" ) == value( QLatin1String( "WantedState" ) ) && isInstalled();
+ return skInstalled == value(skCurrentState);
}
/*!
- * Determines if the component was installed recently
- */
-bool Component::wasInstalled() const
+ Determines if the user wants to install the component
+*/
+bool Component::installationRequested() const
{
- return QLatin1String( "Uninstalled" ) == value( QLatin1String( "PreviousState" ) ) && isInstalled();
+ return !isInstalled() && isSelected();
}
/*!
- * Determines if the component was removed recently
- */
-bool Component::wasUninstalled() const
+ Set's the components state to uninstalled.
+*/
+void Component::setUninstalled()
{
- return QLatin1String( "Installed" ) == value( QLatin1String( "PreviousState" ) ) && !isInstalled();
+ setValue(skCurrentState, skUninstalled);
}
/*!
- * Determines if the components installations status can be changed.
- */
-bool Component::isEnabled() const
+ Determines if the component is uninstalled.
+*/
+bool Component::isUninstalled() const
{
- return d->enabled;
+ return skUninstalled == value(skCurrentState);
}
+
/*!
- * Enables oder disables ability to change the components installations status.
- */
-void Component::setEnabled( bool enabled )
+ Determines if the user wants to uninstall the component.
+*/
+bool Component::uninstallationRequested() const
{
- d->enabled = enabled;
+ return isInstalled() && !isSelected();
}
/*!
- * \property Component::fromOnlineRepository
- * Determines wheter this component has been loaded from an online repository.
- * Get this property's value by usinng %isFromOnlineRepository.
- * \sa addDownloadableArchive
- */
+ \property Component::fromOnlineRepository
+
+ Determines whether this component has been loaded from an online repository. Get this property's
+ value by using %isFromOnlineRepository. \sa addDownloadableArchive
+*/
bool Component::isFromOnlineRepository() const
{
return !repositoryUrl().isEmpty();
}
/*!
- * Contains the repository Url this component is downloaded from.
- * When this component is not downloaded from an online repository, returns an empty #QUrl.
- */
+ Contains the repository Url this component is downloaded from.
+ When this component is not downloaded from an online repository, returns an empty #QUrl.
+*/
QUrl Component::repositoryUrl() const
{
- return d->repositoryUrl;
+ return d->m_repositoryUrl;
}
/*!
- \internal
- Sets this components #repositoryUrl.
+ Sets this components #repositoryUrl.
*/
-void Component::setRepositoryUrl( const QUrl& url )
+void Component::setRepositoryUrl(const QUrl& url)
{
- d->repositoryUrl = url;
+ d->m_repositoryUrl = url;
}
QString Component::localTempPath() const
{
- return d->localTempPath;
+ return d->m_localTempPath;
}
void Component::setLocalTempPath(const QString &tempLocalPath)
{
- d->localTempPath = tempLocalPath;
+ d->m_localTempPath = tempLocalPath;
+}
+
+void Component::updateModelData(const QString &key, const QString &data)
+{
+ if (key == skVirtual) {
+ if (data.toLower() == skTrue)
+ setData(installer()->virtualComponentsFont(), Qt::FontRole);
+ }
+
+ if (key == skVersion)
+ setData(data, NewVersion);
+
+ if (key == skDisplayName)
+ setData(data, Qt::DisplayRole);
+
+ if (key == skInstalledVersion)
+ setData(data, InstalledVersion);
+
+ if (key == skUncompressedSize)
+ setData(uncompressedSize(), UncompressedSize);
+
+ setData(value(skDescription) + QLatin1String("<br><br>Update Info: ") + value(skUpdateText),
+ Qt::ToolTipRole);
}
diff --git a/installerbuilder/libinstaller/qinstallercomponent.h b/installerbuilder/libinstaller/qinstallercomponent.h
index dda43f5b0..de775d5ec 100644
--- a/installerbuilder/libinstaller/qinstallercomponent.h
+++ b/installerbuilder/libinstaller/qinstallercomponent.h
@@ -1,38 +1,41 @@
/**************************************************************************
**
-** This file is part of Qt SDK**
+* *This file is part of Qt SDK**
**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+* *Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
**
-** Contact: Nokia Corporation qt-info@nokia.com**
+* *Contact: Nokia Corporation qt-info@nokia.com**
**
-** GNU Lesser General Public License Usage
+* *GNU Lesser General Public License Usage
**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+* *This file may be used under the terms of the GNU Lesser General Public
+* *License version 2.1 as published by the Free Software Foundation and
+* *appearing in the file LICENSE.LGPL included in the packaging of this file.
+* *Please review the following information to ensure the GNU Lesser General
+* *Public License version 2.1 requirements will be met:
+* *http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+* *In addition, as a special exception, Nokia gives you certain additional
+* *rights. These rights are described in the Nokia Qt LGPL Exception version
+* *1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
+* *If you are unsure which license is appropriate for your use, please contact
+* *(qt-info@nokia.com).
**
**************************************************************************/
#ifndef QINSTALLER_COMPONENT_H
#define QINSTALLER_COMPONENT_H
-#include <QObject>
-#include <QScriptable>
-#include <QUrl>
+#include "qinstallerglobal.h"
+#include "qinstallercomponent_p.h"
-#include "qinstaller.h" // friend QInstaller::Private
+#include <QtCore/QDir>
+#include <QtCore/QMetaType>
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
-class QDir;
+#include <QtScript/QScriptable>
+#include <QtScript/QScriptValueList>
namespace KDUpdater {
class Update;
@@ -41,168 +44,186 @@ namespace KDUpdater {
}
namespace QInstaller {
-
class Installer;
-class INSTALLER_EXPORT Component : public QObject, public QScriptable
+class INSTALLER_EXPORT Component : public QObject, public QScriptable, public ComponentModelHelper
{
Q_OBJECT
- Q_PROPERTY( QString name READ name )
- Q_PROPERTY( QString displayName READ displayName )
- Q_PROPERTY( bool selected READ isSelected WRITE setSelected )
- Q_PROPERTY( bool autoCreateOperations READ autoCreateOperations WRITE setAutoCreateOperations )
- Q_PROPERTY( QStringList archives READ archives )
- Q_PROPERTY( QStringList userInterfaces READ userInterfaces )
- Q_PROPERTY( QStringList dependencies READ dependencies )
- Q_PROPERTY( bool fromOnlineRepository READ isFromOnlineRepository )
- Q_PROPERTY( QUrl repositoryUrl READ repositoryUrl )
- Q_PROPERTY( bool removeBeforeUpdate READ removeBeforeUpdate WRITE setRemoveBeforeUpdate )
- Q_PROPERTY( bool installed READ isInstalled )
- Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled)
+ Q_DISABLE_COPY(Component);
+
+ Q_PROPERTY(QString name READ name)
+ Q_PROPERTY(QString displayName READ displayName)
+ Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
+ Q_PROPERTY(bool autoCreateOperations READ autoCreateOperations WRITE setAutoCreateOperations)
+ Q_PROPERTY(QStringList archives READ archives)
+ Q_PROPERTY(QStringList userInterfaces READ userInterfaces)
+ Q_PROPERTY(QStringList dependencies READ dependencies)
+ Q_PROPERTY(bool fromOnlineRepository READ isFromOnlineRepository)
+ Q_PROPERTY(QUrl repositoryUrl READ repositoryUrl)
+ Q_PROPERTY(bool removeBeforeUpdate READ removeBeforeUpdate WRITE setRemoveBeforeUpdate)
+ Q_PROPERTY(bool default READ isDefault)
+ Q_PROPERTY(bool installed READ isInstalled)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
public:
- enum SelectMode{NormalSelectMode, InitializeComponentTreeSelectMode};
- explicit Component( Installer *installer );
+ explicit Component(Installer *installer);
+ explicit Component(KDUpdater::Update *update, Installer *installer);
~Component();
- void loadDataFromPackageInfo(const KDUpdater::PackageInfo &packageInfo);
- void loadDataFromUpdate(KDUpdater::Update* update);
+ struct IsVirtual
+ {
+ bool operator() (const Component *comp) const
+ {
+ return comp->value(QLatin1String("Virtual"), QLatin1String("false"))
+ .toLower() == QLatin1String("true");
+ }
+ };
- //TODO: remove this, it makes no sense
- void updateState(const bool selected);
+ struct InstallPriorityLessThan
+ {
+ bool operator() (const Component *lhs, const Component *rhs)
+ {
+ const QLatin1String priority("InstallPriority");
+ return lhs->value(priority).toInt() < rhs->value(priority).toInt();
+ }
+ };
- struct PriorityLessThan
+ struct SortingPriorityLessThan
{
- bool operator()( const Component* lhs, const Component* rhs )
+ bool operator() (const Component *lhs, const Component *rhs) const
{
- return lhs->value( QLatin1String( "InstallPriority" ) ).toInt() < rhs->value( QLatin1String( "InstallPriority" ) ).toInt();
+ const QLatin1String priority("SortingPriority");
+ return lhs->value(priority).toInt() < rhs->value(priority).toInt();
}
};
- Q_INVOKABLE void setValue(const QString &key, const QString &value);
- Q_INVOKABLE QString value(const QString &key,
- const QString &defaultValue = QString()) const;
+ void loadDataFromPackageInfo(const KDUpdater::PackageInfo &packageInfo);
+ void loadDataFromUpdate(KDUpdater::Update* update);
+
QHash<QString, QString> variables() const;
+ Q_INVOKABLE void setValue(const QString &key, const QString &value);
+ Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
QStringList archives() const;
+ Installer *installer() const;
- Installer* installer() const;
- Component* parentComponent( RunModes runMode = InstallerMode ) const;
- void appendComponent( Component* component );
- QList<Component*> components( bool recursive = false, RunModes runMode = InstallerMode ) const;
+ Component *parentComponent() const;
+ void appendComponent(Component *component);
+ void removeComponent(Component *component);
+ QList<Component*> childComponents(bool recursive, RunMode runMode) const;
void loadComponentScript();
//move this to private
- void loadComponentScript( const QString& fileName );
- void loadTranslations( const QDir& directory, const QStringList& qms );
- void loadUserInterfaces( const QDir& directory, const QStringList& uis );
+ void loadComponentScript(const QString &fileName);
+ void loadTranslations(const QDir &directory, const QStringList &qms);
+ void loadUserInterfaces(const QDir &directory, const QStringList &uis);
void loadLicenses(const QString &directory, const QHash<QString, QVariant> &hash);
void markAsPerformedInstallation();
QStringList userInterfaces() const;
QHash<QString, QPair<QString, QString> > licenses() const;
- Q_INVOKABLE QWidget* userInterface( const QString& name ) const;
+ Q_INVOKABLE QWidget *userInterface(const QString &name) const;
Q_INVOKABLE virtual void createOperations();
- Q_INVOKABLE virtual void createOperationsForArchive( const QString& archive );
- Q_INVOKABLE virtual void createOperationsForPath( const QString& path );
-
- Q_INVOKABLE void registerPathForUninstallation( const QString& path, bool wipe = false );
- Q_INVOKABLE QList< QPair< QString, bool > > pathesForUninstallation() const;
-
- QList< KDUpdater::UpdateOperation* > operations() const;
- void addOperation( KDUpdater::UpdateOperation* operation );
- void addElevatedOperation( KDUpdater::UpdateOperation* operation );
- Q_INVOKABLE bool addOperation( const QString& operation, const QString& parameter1 = QString(),
- const QString& parameter2 = QString(),
- const QString& parameter3 = QString(),
- const QString& parameter4 = QString(),
- const QString& parameter5 = QString(),
- const QString& parameter6 = QString(),
- const QString& parameter7 = QString(),
- const QString& parameter8 = QString(),
- const QString& parameter9 = QString(),
- const QString& parameter10 = QString() );
-
- Q_INVOKABLE bool addElevatedOperation( const QString& operation, const QString& parameter1 = QString(),
- const QString& parameter2 = QString(),
- const QString& parameter3 = QString(),
- const QString& parameter4 = QString(),
- const QString& parameter5 = QString(),
- const QString& parameter6 = QString(),
- const QString& parameter7 = QString(),
- const QString& parameter8 = QString(),
- const QString& parameter9 = QString(),
- const QString& parameter10 = QString() );
-
-
- Q_INVOKABLE void addDownloadableArchive( const QString& path );
- Q_INVOKABLE void removeDownloadableArchive( const QString& path );
+ Q_INVOKABLE virtual void createOperationsForArchive(const QString &archive);
+ Q_INVOKABLE virtual void createOperationsForPath(const QString &path);
+
+ Q_INVOKABLE QList<QPair<QString, bool> > pathesForUninstallation() const;
+ Q_INVOKABLE void registerPathForUninstallation(const QString &path, bool wipe = false);
+
+ QList<KDUpdater::UpdateOperation*> operations() const;
+
+ void addOperation(KDUpdater::UpdateOperation *operation);
+ Q_INVOKABLE bool addOperation(const QString &operation, const QString &parameter1 = QString(),
+ const QString &parameter2 = QString(), const QString &parameter3 = QString(),
+ const QString &parameter4 = QString(), const QString &parameter5 = QString(),
+ const QString &parameter6 = QString(), const QString &parameter7 = QString(),
+ const QString &parameter8 = QString(), const QString &parameter9 = QString(),
+ const QString &parameter10 = QString());
+
+ void addElevatedOperation(KDUpdater::UpdateOperation *operation);
+ Q_INVOKABLE bool addElevatedOperation(const QString &operation,
+ const QString &parameter1 = QString(), const QString &parameter2 = QString(),
+ const QString &parameter3 = QString(), const QString &parameter4 = QString(),
+ const QString &parameter5 = QString(), const QString &parameter6 = QString(),
+ const QString &parameter7 = QString(), const QString &parameter8 = QString(),
+ const QString &parameter9 = QString(), const QString &parameter10 = QString());
QStringList downloadableArchives() const;
-
- Q_INVOKABLE void addStopProcessForUpdateRequest( const QString& process );
- Q_INVOKABLE void removeStopProcessForUpdateRequest( const QString& process );
- Q_INVOKABLE void setStopProcessForUpdateRequest( const QString& process, bool requested );
+ Q_INVOKABLE void addDownloadableArchive(const QString &path);
+ Q_INVOKABLE void removeDownloadableArchive(const QString &path);
QStringList stopProcessForUpdateRequests() const;
+ Q_INVOKABLE void addStopProcessForUpdateRequest(const QString &process);
+ Q_INVOKABLE void removeStopProcessForUpdateRequest(const QString &process);
+ Q_INVOKABLE void setStopProcessForUpdateRequest(const QString &process, bool requested);
QString name() const;
QString displayName() const;
+ QString uncompressedSize() const;
QUrl repositoryUrl() const;
- void setRepositoryUrl( const QUrl& url );
- QString localTempPath() const;
- void setLocalTempPath(const QString &tempPath);
-
- bool removeBeforeUpdate() const;
- void setRemoveBeforeUpdate( bool removeBeforeUpdate );
+ void setRepositoryUrl(const QUrl &url);
- Q_INVOKABLE bool isFromOnlineRepository() const;
+ bool removeBeforeUpdate() const;
+ void setRemoveBeforeUpdate(bool removeBeforeUpdate);
QStringList dependencies() const;
+ QList<Component*> dependees() const;
+
+ void languageChanged();
+ QString localTempPath() const;
bool autoCreateOperations() const;
- bool isSelected( RunModes runMode = InstallerMode ) const;
+ bool operationsCreatedSuccessfully() const;
+
+ Q_INVOKABLE void setInstalled();
+ Q_INVOKABLE bool isDefault() const;
Q_INVOKABLE bool isInstalled() const;
Q_INVOKABLE bool installationRequested() const;
- Q_INVOKABLE bool uninstallationRequested() const;
- Q_INVOKABLE bool wasInstalled() const;
- Q_INVOKABLE bool wasUninstalled() const;
- bool isEnabled() const;
- void setEnabled( bool enabled );
- bool operationsCreatedSuccessfully() const;
+ Q_INVOKABLE void setUninstalled();
+ Q_INVOKABLE bool isUninstalled() const;
+ Q_INVOKABLE bool uninstallationRequested() const;
- Qt::CheckState checkState( RunModes runMode = InstallerMode ) const;
+ Q_INVOKABLE bool isFromOnlineRepository() const;
- void languageChanged();
+ bool isVirtual() const;
+ bool isSelected() const;
+ bool forcedInstallation() const;
- QList<Component*> dependees() const;
-
- friend class ::QInstaller::Installer;
- friend class ::QInstaller::Installer::Private;
+public Q_SLOTS:
+ void setSelected(bool selected);
+ void setAutoCreateOperations(bool autoCreateOperations);
Q_SIGNALS:
- void valueChanged( const QString& key, const QString& value );
- void selectedChanged( bool selected );
void loaded();
-
-public Q_SLOTS:
- void setAutoCreateOperations( bool autoCreateOperations );
- void setSelected(bool selected, RunModes runMode = InstallerMode, SelectMode selectMode = NormalSelectMode );
+ void selectedChanged(bool selected);
+ void valueChanged(const QString &key, const QString &value);
protected:
- QScriptValue callScriptMethod( const QString& name, const QScriptValueList& parameters = QScriptValueList() );
+ QScriptValue callScriptMethod(const QString &name,
+ const QScriptValueList &parameters = QScriptValueList()) const;
+
+private Q_SLOTS:
+ void updateModelData(const QString &key, const QString &value);
private:
- Q_DISABLE_COPY(Component);
- class Private;
- Private* const d;
+ void setLocalTempPath(const QString &tempPath);
+
+ KDUpdater::UpdateOperation *createOperation(const QString &operation,
+ const QString &parameter1 = QString(), const QString &parameter2 = QString(),
+ const QString &parameter3 = QString(), const QString &parameter4 = QString(),
+ const QString &parameter5 = QString(), const QString &parameter6 = QString(),
+ const QString &parameter7 = QString(), const QString &parameter8 = QString(),
+ const QString &parameter9 = QString(), const QString &parameter10 = QString());
+
+private:
+ ComponentPrivate *d;
};
-}
+} // namespace QInstaller
-Q_DECLARE_METATYPE( QInstaller::Component* );
+Q_DECLARE_METATYPE(QInstaller::Component*);
#endif // QINSTALLER_COMPONENT_H
diff --git a/installerbuilder/libinstaller/qinstallercomponent_p.cpp b/installerbuilder/libinstaller/qinstallercomponent_p.cpp
new file mode 100644
index 000000000..02fdf1e10
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponent_p.cpp
@@ -0,0 +1,333 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qinstallercomponent_p.h"
+
+#include "messageboxhandler.h"
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+
+#include <QtGui/QApplication>
+#include <QtGui/QDesktopServices>
+
+namespace QInstaller {
+
+// -- ComponentPrivate
+
+ComponentPrivate::ComponentPrivate(Installer* installer, Component* qq)
+ : q(qq),
+ m_installer(installer),
+ m_parentComponent(0),
+ m_licenseOperation(0),
+ m_minimumProgressOperation(0),
+ m_newlyInstalled (false),
+ m_operationsCreated(false),
+ m_removeBeforeUpdate(true),
+ m_autoCreateOperations(true),
+ m_operationsCreatedSuccessfully(true)
+{
+}
+
+void ComponentPrivate::init()
+{
+ // register translation stuff
+ m_scriptEngine.installTranslatorFunctions();
+
+ // register QMessageBox::StandardButton enum in the script connection
+ registerMessageBox(&m_scriptEngine);
+
+ // register QDesktopServices in the script connection
+ QScriptValue desktopServices = m_scriptEngine.newArray();
+ setProperty(desktopServices, QLatin1String("DesktopLocation"), QDesktopServices::DesktopLocation);
+ setProperty(desktopServices, QLatin1String("DocumentsLocation"), QDesktopServices::DocumentsLocation);
+ setProperty(desktopServices, QLatin1String("FontsLocation"), QDesktopServices::FontsLocation);
+ setProperty(desktopServices, QLatin1String("ApplicationsLocation"), QDesktopServices::ApplicationsLocation);
+ setProperty(desktopServices, QLatin1String("MusicLocation"), QDesktopServices::MusicLocation);
+ setProperty(desktopServices, QLatin1String("MoviesLocation"), QDesktopServices::MoviesLocation);
+ setProperty(desktopServices, QLatin1String("PicturesLocation"), QDesktopServices::PicturesLocation);
+ setProperty(desktopServices, QLatin1String("TempLocation"), QDesktopServices::TempLocation);
+ setProperty(desktopServices, QLatin1String("HomeLocation"), QDesktopServices::HomeLocation);
+ setProperty(desktopServices, QLatin1String("DataLocation"), QDesktopServices::DataLocation);
+ setProperty(desktopServices, QLatin1String("CacheLocation"), QDesktopServices::CacheLocation);
+
+ desktopServices.setProperty(QLatin1String("openUrl"), m_scriptEngine.newFunction(qDesktopServicesOpenUrl));
+ desktopServices.setProperty(QLatin1String("displayName"),
+ m_scriptEngine.newFunction(qDesktopServicesDisplayName));
+ desktopServices.setProperty(QLatin1String("storageLocation"),
+ m_scriptEngine.newFunction(qDesktopServicesStorageLocation));
+
+ // register ::WizardPage enum in the script connection
+ QScriptValue qinstaller = m_scriptEngine.newArray();
+ setProperty(qinstaller, QLatin1String("Introduction"), Installer::Introduction);
+ setProperty(qinstaller, QLatin1String("LicenseCheck"), Installer::LicenseCheck);
+ setProperty(qinstaller, QLatin1String("TargetDirectory"), Installer::TargetDirectory);
+ setProperty(qinstaller, QLatin1String("ComponentSelection"), Installer::ComponentSelection);
+ setProperty(qinstaller, QLatin1String("StartMenuSelection"), Installer::StartMenuSelection);
+ setProperty(qinstaller, QLatin1String("ReadyForInstallation"), Installer::ReadyForInstallation);
+ setProperty(qinstaller, QLatin1String("PerformInstallation"), Installer::PerformInstallation);
+ setProperty(qinstaller, QLatin1String("InstallationFinished"), Installer::InstallationFinished);
+ setProperty(qinstaller, QLatin1String("End"), Installer::End);
+
+ // register ::Status enum in the script connection
+ setProperty(qinstaller, QLatin1String("InstallerSuccess"), Installer::Success);
+ setProperty(qinstaller, QLatin1String("InstallerSucceeded"), Installer::Success);
+ setProperty(qinstaller, QLatin1String("InstallerFailed"), Installer::Failure);
+ setProperty(qinstaller, QLatin1String("InstallerFailure"), Installer::Failure);
+ setProperty(qinstaller, QLatin1String("InstallerRunning"), Installer::Running);
+ setProperty(qinstaller, QLatin1String("InstallerCanceled"), Installer::Canceled);
+ setProperty(qinstaller, QLatin1String("InstallerCanceledByUser"), Installer::Canceled);
+ setProperty(qinstaller, QLatin1String("InstallerUnfinished"), Installer::Unfinished);
+
+ QScriptValue installerObject = m_scriptEngine.newQObject(m_installer);
+ installerObject.setProperty(QLatin1String("componentByName"),
+ m_scriptEngine.newFunction(qInstallerComponentByName, 1));
+
+ m_scriptEngine.globalObject().setProperty(QLatin1String("QInstaller"), qinstaller);
+ m_scriptEngine.globalObject().setProperty(QLatin1String("installer"), installerObject);
+ m_scriptEngine.globalObject().setProperty(QLatin1String("QDesktopServices"), desktopServices);
+ m_scriptEngine.globalObject().setProperty(QLatin1String("component"), m_scriptEngine.newQObject(q));
+}
+
+void ComponentPrivate::setProperty(QScriptValue &scriptValue, const QString &propertyName, int value)
+{
+ scriptValue.setProperty(propertyName, m_scriptEngine.newVariant(value));
+}
+
+
+// -- ComponentModelHelper
+
+ComponentModelHelper::ComponentModelHelper()
+{
+ setCheckState(Qt::Unchecked);
+ setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
+}
+
+ComponentModelHelper::~ComponentModelHelper()
+{
+}
+
+/*!
+ Returns the number of child components.
+*/
+int ComponentModelHelper::childCount() const
+{
+ if (m_componentPrivate->m_installer->virtualComponentsVisible())
+ return m_componentPrivate->m_allComponents.count();
+ return m_componentPrivate->m_components.count();
+}
+
+/*!
+ Returns the index of this component as seen from it's parent.
+*/
+int ComponentModelHelper::indexInParent() const
+{
+ int index = 0;
+ if (Component *parent = m_componentPrivate->m_parentComponent->parentComponent())
+ index = parent->childComponents(false, AllMode).indexOf(m_componentPrivate->m_parentComponent);
+ return (index >= 0 ? index : 0);
+}
+
+/*!
+ Returns all children and whose children depending if virtual components are visible or not.
+*/
+QList<Component*> ComponentModelHelper::childs() const
+{
+ QList<Component*> *components = &m_componentPrivate->m_components;
+ if (m_componentPrivate->m_installer->virtualComponentsVisible())
+ components = &m_componentPrivate->m_allComponents;
+
+ QList<Component*> result;
+ foreach (Component *component, *components) {
+ result.append(component);
+ result += component->childComponents(true, AllMode);
+ }
+ return result;
+}
+
+/*!
+ Returns the component at index position in the list. Index must be a valid position in
+ the list (i.e., index >= 0 && index < childCount()). Otherwise it returns 0.
+*/
+Component* ComponentModelHelper::childAt(int index) const
+{
+ if (index >= 0 && index < childCount()) {
+ if (m_componentPrivate->m_installer->virtualComponentsVisible())
+ return m_componentPrivate->m_allComponents.value(index, 0);
+ return m_componentPrivate->m_components.value(index, 0);
+ }
+ return 0;
+}
+
+/*!
+ Determines if the components installations status can be changed. The default value is true.
+*/
+bool ComponentModelHelper::isEnabled() const
+{
+ return (flags() & Qt::ItemIsEnabled) != 0;
+}
+
+/*!
+ Enables oder disables ability to change the components installations status.
+*/
+void ComponentModelHelper::setEnabled(bool enabled)
+{
+ changeFlags(enabled, Qt::ItemIsEnabled);
+}
+
+/*!
+ Returns whether the component is tristate; that is, if it's checkable with three separate states.
+ The default value is false.
+*/
+bool ComponentModelHelper::isTristate() const
+{
+ return (flags() & Qt::ItemIsTristate) != 0;
+}
+
+/*!
+ Sets whether the component is tristate. If tristate is true, the component is checkable with three
+ separate states; otherwise, the component is checkable with two states.
+
+ (Note that this also requires that the component is checkable; see isCheckable().)
+*/
+void ComponentModelHelper::setTristate(bool tristate)
+{
+ changeFlags(tristate, Qt::ItemIsTristate);
+}
+
+/*!
+ Returns whether the component is user-checkable. The default value is true.
+*/
+bool ComponentModelHelper::isCheckable() const
+{
+ return (flags() & Qt::ItemIsUserCheckable) != 0;
+}
+
+/*!
+ Sets whether the component is user-checkable. If checkable is true, the component can be checked by the
+ user; otherwise, the user cannot check the component. The delegate will render a checkable component
+ with a check box next to the component's text.
+*/
+void ComponentModelHelper::setCheckable(bool checkable)
+{
+ if (checkable && !isCheckable()) {
+ // make sure there's data for the check state role
+ if (!data(Qt::CheckStateRole).isValid())
+ setData(Qt::Unchecked, Qt::CheckStateRole);
+ }
+ changeFlags(checkable, Qt::ItemIsUserCheckable);
+}
+
+/*!
+ Returns whether the component is selectable by the user. The default value is true.
+*/
+bool ComponentModelHelper::isSelectable() const
+{
+ return (flags() & Qt::ItemIsSelectable) != 0;
+}
+
+/*!
+ Sets whether the component is selectable. If selectable is true, the component can be selected by the
+ user; otherwise, the user cannot select the component.
+*/
+void ComponentModelHelper::setSelectable(bool selectable)
+{
+ changeFlags(selectable, Qt::ItemIsSelectable);
+}
+
+/*!
+ Returns the item flags for the component. The item flags determine how the user can interact with the
+ component.
+*/
+Qt::ItemFlags ComponentModelHelper::flags() const
+{
+ QVariant variant = data(Qt::UserRole - 1);
+ if (!variant.isValid())
+ return (Qt::ItemIsEnabled | Qt::ItemIsSelectable| Qt::ItemIsUserCheckable);
+ return Qt::ItemFlags(variant.toInt());
+}
+
+/*!
+ Sets the item flags for the component to flags. The item flags determine how the user can interact with
+ the component. This is often used to disable an component.
+*/
+void ComponentModelHelper::setFlags(Qt::ItemFlags flags)
+{
+ setData(int(flags), Qt::UserRole - 1);
+}
+
+/*!
+ Returns the checked state of the component.
+*/
+Qt::CheckState ComponentModelHelper::checkState() const
+{
+ return Qt::CheckState(qvariant_cast<int>(data(Qt::CheckStateRole)));
+}
+
+/*!
+ Sets the check state of the component to be state.
+*/
+void ComponentModelHelper::setCheckState(Qt::CheckState state)
+{
+ setData(state, Qt::CheckStateRole);
+}
+
+/*!
+ Returns the component's data for the given role, or an invalid QVariant if there is no data for role.
+*/
+QVariant ComponentModelHelper::data(int role) const
+{
+ return m_values.value((role == Qt::EditRole ? Qt::DisplayRole : role), QVariant());
+}
+
+/*!
+ Sets the component's data for the given role to the specified value.
+*/
+void ComponentModelHelper::setData(const QVariant &value, int role)
+{
+ m_values.insert((role == Qt::EditRole ? Qt::DisplayRole : role), value);
+}
+
+// -- protected
+
+void ComponentModelHelper::setPrivate(ComponentPrivate *componentPrivate)
+{
+ m_componentPrivate = componentPrivate;
+}
+
+// -- private
+
+void ComponentModelHelper::changeFlags(bool enable, Qt::ItemFlags itemFlags)
+{
+ setFlags(enable ? flags() |= itemFlags : flags() &= ~itemFlags);
+}
+
+} // namespace QInstaller
diff --git a/installerbuilder/libinstaller/qinstallercomponent_p.h b/installerbuilder/libinstaller/qinstallercomponent_p.h
new file mode 100644
index 000000000..3a92da6a4
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponent_p.h
@@ -0,0 +1,155 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_COMPONENT_P_H
+#define QINSTALLER_COMPONENT_P_H
+
+#include "qinstallerglobal.h"
+
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+
+#include <QtScript/QScriptEngine>
+
+namespace KDUpdater {
+ class UpdateOperation;
+}
+
+namespace QInstaller {
+class Component;
+class Installer;
+
+class ComponentPrivate
+{
+ QInstaller::Component* const q;
+
+public:
+ explicit ComponentPrivate(Installer* installer, Component* qq);
+
+ void init();
+ void setProperty(QScriptValue &scriptValue, const QString &propertyName, int value);
+
+ Installer *m_installer;
+ Component *m_parentComponent;
+ KDUpdater::UpdateOperation *m_licenseOperation;
+ KDUpdater::UpdateOperation *m_minimumProgressOperation;
+
+ bool m_newlyInstalled;
+ bool m_operationsCreated;
+ bool m_removeBeforeUpdate;
+ bool m_autoCreateOperations;
+ bool m_operationsCreatedSuccessfully;
+
+ QString m_componentName;
+ QUrl m_repositoryUrl;
+ QString m_localTempPath;
+ QScriptEngine m_scriptEngine;
+ QScriptValue m_scriptComponent;
+ QHash<QString, QString> m_vars;
+ QList<Component*> m_components;
+ QList<Component*> m_allComponents;
+ QStringList m_downloadableArchives;
+ QList<Component*> m_virtualComponents;
+ QMap<QString, QWidget*> m_userInterfaces;
+ QStringList m_stopProcessForUpdateRequests;
+ QHash<QString, bool> m_unexistingScriptMethods;
+ QList<KDUpdater::UpdateOperation*> m_operations;
+ // < display name, < file name, file content > >
+ QHash<QString, QPair<QString, QString> > m_licenses;
+ QList<QPair<QString, bool> > m_pathesForUninstallation;
+};
+
+
+// -- ComponentModelHelper
+
+class ComponentModelHelper
+{
+public:
+ enum Roles {
+ InstalledVersion = Qt::UserRole + 1,
+ NewVersion = InstalledVersion + 1,
+ UncompressedSize = NewVersion + 1
+ };
+
+ enum Column {
+ NameColumn = 0,
+ InstalledVersionColumn,
+ NewVersionColumn,
+ UncompressedSizeColumn
+ };
+
+ explicit ComponentModelHelper();
+ ~ComponentModelHelper();
+
+ int childCount() const;
+ int indexInParent() const;
+
+ QList<Component*> childs() const;
+ Component* childAt(int index) const;
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ bool isTristate() const;
+ void setTristate(bool tristate);
+
+ bool isCheckable() const;
+ void setCheckable(bool checkable);
+
+ bool isSelectable() const;
+ void setSelectable(bool selectable);
+
+ Qt::ItemFlags flags() const;
+ void setFlags(Qt::ItemFlags flags);
+
+ Qt::CheckState checkState() const;
+ void setCheckState(Qt::CheckState state);
+
+ QVariant data(int role = Qt::UserRole + 1) const;
+ void setData(const QVariant &value, int role = Qt::UserRole + 1);
+
+protected:
+ void setPrivate(ComponentPrivate *componentPrivate);
+
+private:
+ void changeFlags(bool enable, Qt::ItemFlags itemFlags);
+
+private:
+ QHash<int, QVariant> m_values;
+
+ ComponentPrivate *m_componentPrivate;
+};
+
+
+} // namespace QInstaller
+
+#endif // QINSTALLER_COMPONENT_P_H
diff --git a/installerbuilder/libinstaller/qinstallercomponentmodel.cpp b/installerbuilder/libinstaller/qinstallercomponentmodel.cpp
deleted file mode 100644
index 9bca06a36..000000000
--- a/installerbuilder/libinstaller/qinstallercomponentmodel.cpp
+++ /dev/null
@@ -1,522 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "qinstallercomponentmodel.h"
-
-#include <algorithm>
-
-#include "qinstallercomponent.h"
-#include "qinstallerglobal.h"
-
-#include "common/utils.h"
-
-#include <QApplication>
-#include <QFont>
-#include <QScriptEngine>
-
-using namespace QInstaller;
-
-struct ComponentIsVirtual
-{
- bool operator()( const Component* comp ) const
- {
- return comp->value( QLatin1String( "Virtual" ), QLatin1String( "false" ) ).toLower() == QLatin1String( "true" );
- }
-};
-
-struct ComponentPriorityLessThan
-{
- bool operator()( const Component* lhs, const Component* rhs ) const
- {
- return lhs->value( QLatin1String( "SortingPriority" ) ).toInt() <
- rhs->value( QLatin1String( "SortingPriority" ) ).toInt();
- }
-};
-
-bool checkCompleteUninstallation( const QInstaller::Component* component )
-{
- const QList< QInstaller::Component* > components = component->components( true );
- bool nonSelected = true;
- Q_FOREACH( const QInstaller::Component* comp, components )
- {
- if ( comp->isSelected() )
- nonSelected = false;
- if ( !checkCompleteUninstallation( comp ) )
- nonSelected = false;
- }
- return nonSelected;
-}
-
-bool checkWorkRequest( const QInstaller::Component* component )
-{
- //first check the component itself
- QString componentName = component->name();
- QString wantedState = component->value( QLatin1String( "WantedState" ) );
- QString currentState = component->value( QLatin1String( "CurrentState" ) );
- if (!wantedState.isEmpty() && !currentState.isEmpty() && wantedState != currentState ) {
- verbose() << QLatin1String("request work for ") << componentName << QString(QLatin1String(" because WantedState(%1)!=CurrentState(%2)")).arg(wantedState, currentState)<<std::endl;
- return true;
- }
-
- //now checkWorkRequest for all childs
- const QList< QInstaller::Component* > components = component->components( true );
- Q_FOREACH( const QInstaller::Component* currentComponent, components )
- {
- if ( checkWorkRequest( currentComponent ) )
- return true;
- }
- return false;
-}
-
-ComponentModel::ComponentModel( Installer* parent, RunModes runMode )
- : QAbstractItemModel( parent ), m_runMode( runMode )
-{
-
- if ( runMode == InstallerMode )
- connect( parent, SIGNAL( rootComponentsAdded( QList< QInstaller::Component* > ) ), this, SLOT( addRootComponents(QList< QInstaller::Component* > ) ) );
- else
- connect( parent, SIGNAL( updaterComponentsAdded( QList< QInstaller::Component* > ) ), this, SLOT( addRootComponents(QList< QInstaller::Component* > ) ) );
- connect( parent, SIGNAL( componentsAboutToBeCleared() ), this, SLOT( clear() ) );
- connect( parent, SIGNAL( componentAdded( QInstaller::Component* ) ), this, SLOT( componentAdded( QInstaller::Component* ) ) );
-}
-
-void ComponentModel::addRootComponents( QList< Component* > rootComponents )
-{
- beginResetModel();
- bool requestWork = false;
- Q_FOREACH( Component* currentRootComponent, rootComponents )
- {
- if ( !m_components.contains( currentRootComponent ) )
- m_components.push_back( currentRootComponent );
- if ( checkWorkRequest( currentRootComponent ) ) {
- requestWork = true;
- break;
- }
- }
- endResetModel();
- emit workRequested( requestWork );
-}
-void ComponentModel::clear()
-{
- beginResetModel();
- m_components.clear();
- seenComponents.clear();
- endResetModel();
-}
-
-ComponentModel::~ComponentModel()
-{
-}
-
-void ComponentModel::selectedChanged( bool checked )
-{
- Q_UNUSED( checked )
- Component *comp = dynamic_cast<Component*>( QObject::sender() );
- Q_ASSERT( comp );
- bool requestWork = false;
- Q_FOREACH( Component *c, comp->components( false, m_runMode ) ) {
- if( !seenComponents.contains( c ) )
- {
- connect( c, SIGNAL( selectedChanged( bool ) ), this, SLOT( selectedChanged( bool ) ) );
- seenComponents.push_back( c );
- }
- }
- Q_FOREACH( const Component * currentComponent, m_components )
- {
- if ( checkWorkRequest( currentComponent ) ) {
- requestWork = true;
- break;
- }
- }
- emit workRequested( requestWork );
- emit dataChanged( this->index( 0, 0 ), QModelIndex() );
-}
-
-void ComponentModel::componentAdded( Component* comp )
-{
- Q_UNUSED( comp )
- reset();
-}
-
-/*!
- \reimpl
-*/
-QModelIndex ComponentModel::index( int row, int column, const QModelIndex& parent ) const
-{
- if( row < 0 || row >= rowCount( parent ) )
- return QModelIndex();
- if( column < 0 || column >= columnCount( parent ) )
- return QModelIndex();
-
- QList< Component* > components = !parent.isValid() ? m_components
- : reinterpret_cast< Component* >( parent.internalPointer() )->components( false, m_runMode );
- // don't count virtual components
- if( !virtualComponentsVisible() && m_runMode == InstallerMode )
- components.erase( std::remove_if( components.begin(), components.end(), ComponentIsVirtual() ), components.end() );
-
- // sort by priority
- std::sort( components.begin(), components.end(), ComponentPriorityLessThan() );
-
- Component* const comp = components[ row ];
-
- QModelIndex index = createIndex( row, column, comp );
-
- if( !seenComponents.contains( comp ) )
- {
- connect( comp, SIGNAL( selectedChanged( bool ) ), this, SLOT( selectedChanged( bool ) ) );
- seenComponents.push_back( comp );
- }
-
- return index;
-}
-
-/*!
- \reimpl
-*/
-QModelIndex ComponentModel::parent( const QModelIndex& index ) const
-{
- if( !index.isValid() )
- return QModelIndex();
- const Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
- Component* const parentComponent = component->parentComponent( m_runMode );
- if( parentComponent == 0 )
- return QModelIndex();
- QList< Component* > parentSiblings = parentComponent->parentComponent() == 0 ? m_components
- : parentComponent->parentComponent()->components( false, m_runMode );
- // don't count virtual components
- if( !virtualComponentsVisible() && m_runMode == InstallerMode )
- parentSiblings.erase( std::remove_if( parentSiblings.begin(), parentSiblings.end(), ComponentIsVirtual() ), parentSiblings.end() );
-
- // sort by priority
- std::sort( parentSiblings.begin(), parentSiblings.end(), ComponentPriorityLessThan() );
-
- return createIndex( parentSiblings.indexOf( parentComponent ), 0, parentComponent );
-}
-
-/*!
- \reimpl
-*/
-int ComponentModel::columnCount( const QModelIndex& parent ) const
-{
- Q_UNUSED( parent );
- return 4;
-}
-
-/*!
- \reimpl
-*/
-int ComponentModel::rowCount( const QModelIndex& parent ) const
-{
- if( parent.column() > 0 )
- return 0;
-
- QList< Component* > components = !parent.isValid() ? m_components
- : reinterpret_cast< Component* >( parent.internalPointer() )->components( false, m_runMode );
-
- // don't count virtual components
- if( !virtualComponentsVisible() && m_runMode == InstallerMode )
- components.erase( std::remove_if( components.begin(), components.end(), ComponentIsVirtual() ), components.end() );
-
- return components.count();
-}
-
-/*!
- \reimpl
-*/
-Qt::ItemFlags ComponentModel::flags( const QModelIndex& index ) const
-{
- Qt::ItemFlags result = QAbstractItemModel::flags( index );
- if ( !index.isValid() )
- return result;
- const Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
- const bool forcedInstallation = QVariant( component->value( QLatin1String( "ForcedInstallation" ) ) ).toBool();
-
- if (m_runMode == UpdaterMode || !forcedInstallation)
- result |= Qt::ItemIsUserCheckable;
- if ( !component->isEnabled() )
- result &= Qt::ItemIsDropEnabled;
- if (m_runMode == InstallerMode && forcedInstallation) {
- result &= ~Qt::ItemIsEnabled; //now it should look like a disabled item
- }
- return result;
-}
-
-/*!
- \reimpl
-*/
-bool ComponentModel::setData( const QModelIndex& index, const QVariant& data, int role )
-{
- if( !index.isValid() )
- return false;
-
- Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
- switch( role )
- {
- case Qt::CheckStateRole: {
- if( !( flags( index ) & Qt::ItemIsUserCheckable ) )
- return false;
- const bool check = data.toInt() == Qt::Checked;
- component->setSelected( check, m_runMode );
- bool requestWork = false;
- bool nonSelected = true;
- Q_FOREACH( const QInstaller::Component* currentComponent, m_components )
- {
- if ( checkWorkRequest( currentComponent ) ) {
- requestWork |= true;
- }
- if ( currentComponent->isSelected() )
- nonSelected = false;
- if ( !checkCompleteUninstallation( currentComponent ) )
- nonSelected = false;
- }
- if ( m_runMode == InstallerMode )
- {
- Installer* installer = dynamic_cast< Installer* > ( QObject::parent() );
- installer->setCompleteUninstallation( nonSelected );
- }
- emit workRequested( requestWork );
- return true;
- }
- default:
- return false;
- }
-}
-
-Qt::CheckState QInstaller::componentCheckState( const Component* component, RunModes runMode )
-{
- if( QVariant( component->value( QLatin1String( "ForcedInstallation" ) ) ).toBool() )
- return Qt::Checked;
-
- QString autoSelect = component->value( QLatin1String( "AutoSelectOn" ) );
- // check the auto select expression
- if( !autoSelect.isEmpty() )
- {
- QScriptEngine engine;
- const QList< Component* > components = component->installer()->components( true, runMode );
- for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
- {
- const Component* const c = *it;
- if( c == component )
- continue;
- QString name = c->name();
- name.replace( QLatin1String( "." ), QLatin1String( "___" ) );
- engine.evaluate( QString::fromLatin1( "%1 = %2;" ).arg( name, QVariant( c ->isSelected() ).toString() ) );
- }
- autoSelect.replace( QLatin1String( "." ), QLatin1String( "___" ) );
- if( engine.evaluate( autoSelect ).toBool() )
- return Qt::Checked;
- }
-
- // if one of our dependees is checked, we are checked
- const QList< Component* > dependees = component->dependees();
- for( QList< Component* >::const_iterator it = dependees.begin(); it != dependees.end(); ++it )
- {
- if( *it == component )
- {
- verbose() << "Infinite loop in dependencies detected, bailing out..." << std::endl;
- return Qt::Unchecked;
- }
- const Qt::CheckState state = (*it)->checkState();
- if( state == Qt::Checked )
- return state;
- }
-
- // if the component has children then we need to check if all children are selected
- // to set the state to either checked if all children are selected or to unchecked
- // if no children are selected or otherwise to partially checked.
- bool foundChecked = false;
- bool foundUnchecked = false;
- QList< Component* > children = component->components( true, runMode );
- // don't count virtual components
- children.erase( std::remove_if( children.begin(), children.end(), ComponentIsVirtual() ), children.end() );
- if( !children.isEmpty() )
- {
- for( QList< Component* >::const_iterator it = children.begin(); it != children.end(); ++it )
- {
- const Qt::CheckState state = (*it)->checkState();
- foundChecked = foundChecked || state == Qt::Checked || state == Qt::PartiallyChecked;
- foundUnchecked = foundUnchecked || state == Qt::Unchecked;
- }
- if( foundChecked && foundUnchecked )
- return Qt::PartiallyChecked;
- else if( foundChecked && ! foundUnchecked )
- return Qt::Checked;
- else if( foundUnchecked && ! foundChecked )
- return Qt::Unchecked;
- //else fall through
- }
-
- // explicitely selected
- if( component->value( QString::fromLatin1( "WantedState" ) ) == QString::fromLatin1( "Installed" ) )
- return Qt::Checked;
-
- // explicitely unselected
- else if ( component->value( QString::fromLatin1( "WantedState" ) ) == QString::fromLatin1( "Uninstalled" ) )
- return Qt::Unchecked;
-
- // no decision made, use the predefined:
- const QString suggestedState = component->value( QString::fromLatin1( "SuggestedState" ) );
- if( suggestedState == QString::fromLatin1( "Installed" ) )
- return Qt::Checked;
- return Qt::Unchecked;
-}
-
-/*!
- \reimp
-*/
-QVariant ComponentModel::data( const QModelIndex& index, int role ) const
-{
- if( !index.isValid() )
- return QVariant();
-
- Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
-
- switch( index.column() )
- {
- case NameColumn:
- switch( role )
- {
- case Qt::EditRole:
- case Qt::DisplayRole:
- return component->displayName();
- case Qt::CheckStateRole:
- return component->checkState( m_runMode );
- case Qt::ToolTipRole:
- return component->value( QString::fromLatin1( "Description" ) ) + QLatin1String( "<br><br> Update Info: " ) + component->value( QLatin1String ( "UpdateText" ) ) ;
- case Qt::FontRole:
- return component->value( QLatin1String( "Virtual" ), QLatin1String( "false" ) ).toLower() == QLatin1String( "true" ) ? virtualComponentsFont() : QFont();
- case ComponentRole:
- return qVariantFromValue( component );
- case IdRole:
- return component->name();
- default:
- return QVariant();
- }
- case VersionColumn:
- if( role == Qt::DisplayRole )
- return component->value( QLatin1String( "Version" ) );
- break;
- case InstalledVersionColumn:
- if( role == Qt::DisplayRole )
- return component->value( QLatin1String( "InstalledVersion" ) );
- break;
- case SizeColumn:
- if( role == Qt::DisplayRole )
- {
- double size = component->value( QLatin1String( "UncompressedSize" ) ).toDouble();
- if( size < 10000.0 )
- return tr( "%L1 Bytes" ).arg( size );
- size /= 1024.0;
- if( size < 10000.0 )
- return tr( "%L1 kB" ).arg( size, 0, 'f', 1 );
- size /= 1024.0;
- if( size < 10000.0 )
- return tr( "%L1 MB" ).arg( size, 0, 'f', 1 );
- size /= 1024.0;
- return tr( "%L1 GB" ).arg( size, 0, 'f', 1 );
- }
- break;
- }
- return QVariant();
-}
-
-/*!
- \reimp
-*/
-QVariant ComponentModel::headerData( int section, Qt::Orientation orientation, int role ) const
-{
- if( orientation != Qt::Horizontal || role != Qt::DisplayRole )
- return QAbstractItemModel::headerData( section, orientation, role );
-
- switch( section )
- {
- case NameColumn:
- return tr( "Name" );
- case InstalledVersionColumn:
- return tr( "Installed Version" );
- case VersionColumn:
- return tr( "New Version" );
- case SizeColumn:
- return tr( "Size" );
- default:
- return QAbstractItemModel::headerData( section, orientation, role );
- }
-}
-
-static bool s_virtualComponentsVisible = false;
-
-bool ComponentModel::virtualComponentsVisible()
-{
- return s_virtualComponentsVisible;
-}
-
-void ComponentModel::setVirtualComponentsVisible( bool visible )
-{
- s_virtualComponentsVisible = visible;
-}
-
-static QFont s_virtualComponentsFont;
-
-QFont ComponentModel::virtualComponentsFont()
-{
- return s_virtualComponentsFont;
-}
-
-void ComponentModel::setVirtualComponentsFont( const QFont& f )
-{
- s_virtualComponentsFont = f;
-}
-
-QModelIndex ComponentModel::findComponent( const QString& id ) const
-{
- QModelIndex idx = index( 0, NameColumn );
- while ( idx.isValid() && idx.data( IdRole ).toString() != id ) {
- if ( rowCount( idx ) > 0 ) {
- idx = idx.child( 0, NameColumn );
- continue;
- }
-
- bool foundNext = false;
-
- while ( !foundNext ) {
- const int oldRow = idx.row();
- idx = idx.parent();
- const int rc = rowCount( idx );
- if ( oldRow < rc - 1 ) {
- idx = index( oldRow + 1, NameColumn, idx );
- foundNext = true;
- } else if ( !idx.isValid() )
- return idx;
- }
- }
- return idx;
-}
diff --git a/installerbuilder/libinstaller/qinstallercomponentmodel.h b/installerbuilder/libinstaller/qinstallercomponentmodel.h
deleted file mode 100644
index bad7a4271..000000000
--- a/installerbuilder/libinstaller/qinstallercomponentmodel.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#ifndef QINSTALLER_COMPONENTMODEL_H
-#define QINSTALLER_COMPONENTMODEL_H
-
-#include <QAbstractItemModel>
-#include <QList>
-
-#include "installer_global.h"
-
-namespace QInstaller {
-class Installer;
-class Component;
-
-class INSTALLER_EXPORT ComponentModel : public QAbstractItemModel
-{
- Q_OBJECT
-public:
- enum Role {
- ComponentRole=Qt::UserRole,
- IdRole
- };
-
- enum Column {
- NameColumn=0,
- InstalledVersionColumn,
- VersionColumn,
- SizeColumn
- };
-
- explicit ComponentModel( Installer* parent, RunModes runMode = InstallerMode);
- ~ComponentModel();
-
- QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
- QModelIndex parent( const QModelIndex& index ) const;
-
- int columnCount( const QModelIndex& parent = QModelIndex() ) const;
- int rowCount( const QModelIndex& parent = QModelIndex() ) const;
-
- Qt::ItemFlags flags( const QModelIndex& index ) const;
-
- bool setData( const QModelIndex& index, const QVariant& data, int role = Qt::CheckStateRole );
- QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
- QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
-
- static bool virtualComponentsVisible();
- static void setVirtualComponentsVisible( bool visible );
-
- static QFont virtualComponentsFont();
- static void setVirtualComponentsFont( const QFont& f );
-
- QModelIndex findComponent( const QString& id ) const;
-Q_SIGNALS:
- void workRequested( bool value );
-
-public Q_SLOTS:
- void addRootComponents(QList< QInstaller::Component* > components );
- void clear();
-
-private Q_SLOTS:
- void componentAdded( QInstaller::Component* comp );
- void selectedChanged( bool checked );
-
-private:
- mutable QList< Component* > seenComponents;
- QList< Component* > m_components;
- RunModes m_runMode;
-};
-
-}
-
-#endif // QINSTALLER_COMPONENTMODEL_H
diff --git a/installerbuilder/libinstaller/qinstallerglobal.h b/installerbuilder/libinstaller/qinstallerglobal.h
index 4f23af95f..3794dcc0e 100644
--- a/installerbuilder/libinstaller/qinstallerglobal.h
+++ b/installerbuilder/libinstaller/qinstallerglobal.h
@@ -28,49 +28,40 @@
#include <installer_global.h>
-#include <QtGlobal>
-#include <qnamespace.h>
-
-#define ifVerbose(s) if (!installer()->isVerbose()) {} else { qDebug() << s; }
-
-class QIODevice;
-class QFile;
-template <typename T> class QList;
+QT_BEGIN_NAMESPACE
class QScriptContext;
class QScriptEngine;
class QScriptValue;
+QT_END_NAMESPACE
namespace QInstaller {
class Component;
-#if 0
-// Faster or not?
-static void appendFileData(QIODevice *out, const QString &fileName)
+enum INSTALLER_EXPORT RunMode
{
- QFile file(fileName);
- openForRead(file);
- qint64 size = file.size();
- QInstaller::appendInt(out, size);
- if (size == 0)
- return;
- uchar *data = file.map(0, size);
- if (!data)
- throw Error(QInstaller::tr("Cannot map file %1").arg(file.fileName()));
- rawWrite(out, (const char *)data, size);
- if (!file.unmap(data))
- throw Error(QInstaller::tr("Cannot unmap file %1").arg(file.fileName()));
-}
-#endif
+ AllMode,
+ UpdaterMode
+};
+
+enum INSTALLER_EXPORT JobError
+{
+ InvalidUrl = 0x24B04,
+ Timeout,
+ DownloadError,
+ InvalidUpdatesXml,
+ InvalidMetaInfo,
+ ExtractionError,
+ UserIgnoreError
+};
+
+QString uncaughtExceptionString(QScriptEngine *scriptEngine);
+QScriptValue qInstallerComponentByName(QScriptContext *context, QScriptEngine *engine);
- QScriptValue qDesktopServicesOpenUrl( QScriptContext* context, QScriptEngine* engine );
- QScriptValue qDesktopServicesDisplayName( QScriptContext* context, QScriptEngine* engine );
- QScriptValue qDesktopServicesStorageLocation( QScriptContext* context, QScriptEngine* engine );
-
- QScriptValue qInstallerComponentByName( QScriptContext* context, QScriptEngine* engine );
+QScriptValue qDesktopServicesOpenUrl(QScriptContext *context, QScriptEngine *engine);
+QScriptValue qDesktopServicesDisplayName(QScriptContext *context, QScriptEngine *engine);
+QScriptValue qDesktopServicesStorageLocation(QScriptContext *context, QScriptEngine *engine);
- Qt::CheckState componentCheckState( const Component* component, RunModes runMode = InstallerMode );
- QString uncaughtExceptionString(QScriptEngine *scriptEngine/*, const QString &context*/);
}
#endif // QINSTALLER_GLOBAL_H
diff --git a/installerbuilder/libinstaller/qinstallergui.cpp b/installerbuilder/libinstaller/qinstallergui.cpp
index a934297c7..931c415f8 100644
--- a/installerbuilder/libinstaller/qinstallergui.cpp
+++ b/installerbuilder/libinstaller/qinstallergui.cpp
@@ -30,13 +30,12 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-
#include "qinstallergui.h"
+#include "componentmodel.h"
#include "qinstaller.h"
#include "qinstallerglobal.h"
#include "qinstallercomponent.h"
-#include "qinstallercomponentmodel.h"
#include "progresscoordinator.h"
#include "performinstallationform.h"
@@ -121,20 +120,20 @@ TRANSLATOR QInstaller::FinishedPage
class DynamicInstallerPage : public Page
{
public:
- explicit DynamicInstallerPage( QWidget* widget, Installer* parent = 0 )
- : Page( parent ),
- m_widget( widget )
+ explicit DynamicInstallerPage(QWidget* widget, Installer* parent = 0)
+ : Page(parent)
+ , m_widget(widget)
{
- setObjectName( QLatin1String("Dynamic") + widget->objectName() );
+ setObjectName(QLatin1String("Dynamic") + widget->objectName());
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
- setLayout( new QVBoxLayout );
- setTitle( widget->windowTitle() );
- m_widget->setProperty( "complete", true );
- m_widget->setProperty( "final", false );
- widget->installEventFilter( this );
- layout()->addWidget( widget );
+ setLayout(new QVBoxLayout);
+ setTitle(widget->windowTitle());
+ m_widget->setProperty("complete", true);
+ m_widget->setProperty("final", false);
+ widget->installEventFilter(this);
+ layout()->addWidget(widget);
}
QWidget* widget() const
@@ -144,140 +143,124 @@ public:
bool isComplete() const
{
- return m_widget->property( "complete" ).toBool();
+ return m_widget->property("complete").toBool();
}
protected:
- bool eventFilter( QObject* obj, QEvent* event )
+ bool eventFilter(QObject* obj, QEvent* event)
{
- if( obj == m_widget )
- {
- switch( event->type() )
- {
+ if (obj == m_widget) {
+ switch(event->type()) {
case QEvent::WindowTitleChange:
- setTitle( m_widget->windowTitle() );
+ setTitle(m_widget->windowTitle());
break;
+
case QEvent::DynamicPropertyChange:
emit completeChanged();
- if( m_widget->property( "final" ).toBool() != isFinalPage() )
- setFinalPage( m_widget->property( "final" ).toBool() );
+ if (m_widget->property("final").toBool() != isFinalPage())
+ setFinalPage(m_widget->property("final").toBool());
break;
+
default:
break;
}
}
- return Page::eventFilter( obj, event );
+ return Page::eventFilter(obj, event);
}
private:
QWidget* const m_widget;
};
-////////////////////////////////////////////////////////////////////
-//
-// Gui
-//
-////////////////////////////////////////////////////////////////////
+// -- Gui::Private
class Gui::Private
{
public:
Private()
- : autoSwitchPage(true),
- modified( false )
- {
+ : m_modified(false)
+ , m_autoSwitchPage(true)
+ { }
- }
+ bool m_modified;
+ bool m_autoSwitchPage;
+ QMap<int, QWizardPage*> m_defaultPages;
+ QMap<int, QString> m_defaultButtonText;
- QScriptEngine controlScriptEngine;
- QScriptValue controlScript;
- bool autoSwitchPage;
- bool modified;
+ QScriptValue m_controlScript;
+ QScriptEngine m_controlScriptEngine;
};
+
+// -- Gui
+
QScriptEngine* Gui::controlScriptEngine() const
{
- return &d->controlScriptEngine;
+ return &d->m_controlScriptEngine;
}
/*!
- \class QInstaller::Gui
- Is the "gui" object in a none interactive installation
- */
-
+ \class QInstaller::Gui
+ Is the "gui" object in a none interactive installation
+*/
Gui::Gui(Installer *installer, QWidget *parent)
: QWizard(parent)
- , m_installer( installer )
- , d( new Private )
- , m_introPage( new IntroductionPage( installer ) )
+ , m_installer(installer)
+ , d(new Private)
{
- if ( installer->isInstaller() )
- setWindowTitle(tr("%1 Setup").arg(m_installer->value(QLatin1String( "Title" ) ) ) );
+ if (installer->isInstaller())
+ setWindowTitle(tr("%1 Setup").arg(m_installer->value(QLatin1String("Title"))));
else
- setWindowTitle(tr("%1").arg(m_installer->value(QLatin1String( "maintenanceTitle") ) ) );
+ setWindowTitle(tr("%1").arg(m_installer->value(QLatin1String("maintenanceTitle"))));
#ifndef Q_WS_MAC
- setWindowIcon( QIcon( m_installer->settings().icon() ) );
- setWizardStyle( QWizard::ModernStyle );
+ setWindowIcon(QIcon(m_installer->settings().icon()));
+ setWizardStyle(QWizard::ModernStyle);
#else
- setPixmap( QWizard::BackgroundPixmap, m_installer->settings().background() );
+ setPixmap(QWizard::BackgroundPixmap, m_installer->settings().background());
#endif
setOption(QWizard::NoBackButtonOnStartPage);
setOption(QWizard::NoBackButtonOnLastPage);
-// setOption(QWizard::IndependentPages);
- setLayout( new QVBoxLayout( this ) );
- if ( installer->isInstaller() )
- setPage( Installer::Introduction, m_introPage );
+ setLayout(new QVBoxLayout(this));
+ connect(this, SIGNAL(rejected()), installer, SLOT(setCanceled()));
connect(this, SIGNAL(interrupted()), installer, SLOT(interrupt()));
- connect(this, SIGNAL(rejected()), installer, SLOT(setCanceled()) );
- // both queued to show the finished page once everything is done
- connect(installer, SIGNAL(installationFinished()), this,
- SLOT(showFinishedPage()), Qt::QueuedConnection);
- connect(installer, SIGNAL(uninstallationFinished()), this,
- SLOT(showFinishedPage()), Qt::QueuedConnection);
-
- connect( this, SIGNAL( currentIdChanged( int ) ), this, SLOT( slotCurrentPageChanged( int ) ) );
- connect( this, SIGNAL( currentIdChanged( int ) ), m_installer, SIGNAL( currentPageChanged( int ) ) );
- connect( button( QWizard::FinishButton ), SIGNAL( clicked() ), this, SIGNAL( finishButtonClicked() ) );
- connect( this, SIGNAL( finishButtonClicked() ), installer, SIGNAL( finishButtonClicked() ) );
- // make sure the QUiLoader's retranslateUi is executed first, then the script
- connect( this, SIGNAL( languageChanged() ),
- installer, SLOT( languageChanged() ), Qt::QueuedConnection );
-
- connect( installer, SIGNAL( wizardPageInsertionRequested( QWidget*, Installer::WizardPage ) ),
- this, SLOT( wizardPageInsertionRequested( QWidget*, Installer::WizardPage ) ) );
- connect( installer, SIGNAL( wizardPageRemovalRequested( QWidget* ) ),
- this, SLOT( wizardPageRemovalRequested( QWidget* ) ) );
- connect( installer, SIGNAL( wizardWidgetInsertionRequested( QWidget*, Installer::WizardPage ) ),
- this, SLOT( wizardWidgetInsertionRequested( QWidget*, Installer::WizardPage ) ) );
- connect( installer, SIGNAL( wizardWidgetRemovalRequested( QWidget* ) ),
- this, SLOT( wizardWidgetRemovalRequested( QWidget* ) ) );
- connect( installer, SIGNAL( wizardPageVisibilityChangeRequested( bool, int ) ),
- this, SLOT( wizardPageVisibilityChangeRequested( bool, int ) ), Qt::QueuedConnection );
-
- connect( installer, SIGNAL( setAutomatedPageSwitchEnabled( bool ) ),
- this, SLOT( setAutomatedPageSwitchEnabled( bool ) ) );
+ // both queued to show the finished page once everything is done
+ connect(installer, SIGNAL(installationFinished()), this, SLOT(showFinishedPage()), Qt::QueuedConnection);
+ connect(installer, SIGNAL(uninstallationFinished()), this, SLOT(showFinishedPage()), Qt::QueuedConnection);
-#ifdef Q_WS_MAC
- setButtonText( QWizard::BackButton, tr( "&Go Back" ) );
- setButtonText( QWizard::NextButton, tr( "&Continue" ) );
- setButtonText( QWizard::FinishButton, tr( "&Done" ) );
-#else
- setButtonText( QWizard::BackButton, tr( "&Back" ) );
- setButtonText( QWizard::NextButton, tr( "&Next" ) );
- setButtonText( QWizard::FinishButton, tr( "&Finish" ) );
-#endif
- setButtonText( QWizard::CancelButton, tr( "&Cancel" ) );
+ connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentPageChanged(int)));
+ connect(this, SIGNAL(currentIdChanged(int)), m_installer, SIGNAL(currentPageChanged(int)));
+ connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SIGNAL(finishButtonClicked()));
+ connect(button(QWizard::FinishButton), SIGNAL(clicked()), installer, SIGNAL(finishButtonClicked()));
- dynamic_cast< QPushButton* >( button( QWizard::NextButton ) )->setDefault( true );
+ // make sure the QUiLoader's retranslateUi is executed first, then the script
+ connect(this, SIGNAL(languageChanged()), installer, SLOT(languageChanged()), Qt::QueuedConnection);
+ connect(this, SIGNAL(languageChanged()), this, SLOT(onLanguageChanged()), Qt::QueuedConnection);
+
+ connect(installer, SIGNAL(wizardPageInsertionRequested(QWidget*, Installer::WizardPage)), this,
+ SLOT(wizardPageInsertionRequested(QWidget*, Installer::WizardPage)));
+ connect(installer, SIGNAL(wizardPageRemovalRequested(QWidget*)),this,
+ SLOT(wizardPageRemovalRequested(QWidget*)));
+ connect(installer, SIGNAL(wizardWidgetInsertionRequested(QWidget*, Installer::WizardPage)), this,
+ SLOT(wizardWidgetInsertionRequested(QWidget*, Installer::WizardPage)));
+ connect(installer, SIGNAL(wizardWidgetRemovalRequested(QWidget*)), this,
+ SLOT(wizardWidgetRemovalRequested(QWidget*)));
+ connect(installer, SIGNAL(wizardPageVisibilityChangeRequested(bool, int)), this,
+ SLOT(wizardPageVisibilityChangeRequested(bool, int)), Qt::QueuedConnection);
+
+ connect(installer, SIGNAL(setAutomatedPageSwitchEnabled(bool)), this,
+ SLOT(setAutomatedPageSwitchEnabled(bool)));
+
+ for (int i = QWizard::BackButton; i < QWizard::CustomButton1; ++i)
+ d->m_defaultButtonText.insert(i, buttonText(QWizard::WizardButton(i)));
#ifdef Q_WS_MAC
- resize( sizeHint() * 1.25 );
+ resize(sizeHint() * 1.25);
#else
- resize( sizeHint() );
+ resize(sizeHint());
#endif
}
@@ -286,195 +269,204 @@ Gui::~Gui()
delete d;
}
-void Gui::setAutomatedPageSwitchEnabled( bool request )
+void Gui::setAutomatedPageSwitchEnabled(bool request)
{
- d->autoSwitchPage = request;
+ d->m_autoSwitchPage = request;
}
+QString Gui::defaultButtonText(int wizardButton) const
+{
+ return d->m_defaultButtonText.value(wizardButton);
+}
-void Gui::clickButton( int wb, int delay )
+void Gui::clickButton(int wb, int delay)
{
- if ( QAbstractButton* b = button( static_cast<QWizard::WizardButton>( wb ) ) )
- QTimer::singleShot( delay, b, SLOT(click()) );
- else {
- //TODO we should probably abort immediately here (faulty test script)
+ if (QAbstractButton* b = button(static_cast<QWizard::WizardButton>(wb) )) {
+ QTimer::singleShot(delay, b, SLOT(click()));
+ } else {
+ // TODO: we should probably abort immediately here (faulty test script)
verbose() << "Button " << wb << " not found!" << std::endl;
}
}
/*!
- * Loads a script to perform the installation non-interactively.
- *
- * @throws QInstaller::Error if the script is not readable/cannot be parsed
- */
-void Gui::loadControlScript( const QString& scriptPath )
+ Loads a script to perform the installation non-interactively.
+ @throws QInstaller::Error if the script is not readable/cannot be parsed
+*/
+void Gui::loadControlScript(const QString& scriptPath)
{
- QFile file( scriptPath );
- if( !file.open( QIODevice::ReadOnly ) )
- throw Error( QObject::tr( "Could not open the requested script file at %1: %2" ).arg( scriptPath, file.errorString() ) );
+ QFile file(scriptPath);
+ if (!file.open(QIODevice::ReadOnly)) {
+ throw Error(QObject::tr("Could not open the requested script file at %1: %2")
+ .arg(scriptPath, file.errorString()));
+ }
- d->controlScriptEngine.globalObject().setProperty( QLatin1String( "installer" ), d->controlScriptEngine.newQObject( m_installer ) );
- d->controlScriptEngine.globalObject().setProperty( QLatin1String( "gui" ), d->controlScriptEngine.newQObject( this ) );
- registerMessageBox( &d->controlScriptEngine );
+ d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("installer"),
+ d->m_controlScriptEngine.newQObject(m_installer));
+ d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("gui"),
+ d->m_controlScriptEngine.newQObject(this));
+ registerMessageBox(&d->m_controlScriptEngine);
#undef REGISTER_BUTTON
-#define REGISTER_BUTTON(x) buttons.setProperty( QLatin1String( #x ), d->controlScriptEngine.newVariant( static_cast<int>( QWizard::x ) ) );
-
- QScriptValue buttons = d->controlScriptEngine.newArray();
- REGISTER_BUTTON( BackButton )
- REGISTER_BUTTON( NextButton )
- REGISTER_BUTTON( CommitButton )
- REGISTER_BUTTON( FinishButton )
- REGISTER_BUTTON( CancelButton )
- REGISTER_BUTTON( HelpButton )
- REGISTER_BUTTON( CustomButton1 )
- REGISTER_BUTTON( CustomButton2 )
- REGISTER_BUTTON( CustomButton3 )
+#define REGISTER_BUTTON(x) buttons.setProperty(QLatin1String(#x), \
+ d->m_controlScriptEngine.newVariant(static_cast<int>(QWizard::x)));
+
+ QScriptValue buttons = d->m_controlScriptEngine.newArray();
+ REGISTER_BUTTON(BackButton)
+ REGISTER_BUTTON(NextButton)
+ REGISTER_BUTTON(CommitButton)
+ REGISTER_BUTTON(FinishButton)
+ REGISTER_BUTTON(CancelButton)
+ REGISTER_BUTTON(HelpButton)
+ REGISTER_BUTTON(CustomButton1)
+ REGISTER_BUTTON(CustomButton2)
+ REGISTER_BUTTON(CustomButton3)
#undef REGISTER_BUTTON
- d->controlScriptEngine.globalObject().setProperty( QLatin1String( "buttons" ), buttons );
+ d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("buttons"), buttons);
- d->controlScriptEngine.evaluate( QLatin1String( file.readAll() ), scriptPath );
- if( d->controlScriptEngine.hasUncaughtException() ) {
- throw Error( QObject::tr( "Exception while loading the control script %1" )
- .arg(uncaughtExceptionString(&(d->controlScriptEngine)/*, scriptPath*/)) );
+ d->m_controlScriptEngine.evaluate(QLatin1String(file.readAll()), scriptPath);
+ if (d->m_controlScriptEngine.hasUncaughtException()) {
+ throw Error(QObject::tr("Exception while loading the control script %1")
+ .arg(uncaughtExceptionString(&(d->m_controlScriptEngine)/*, scriptPath*/)));
}
- QScriptValue comp = d->controlScriptEngine.evaluate( QLatin1String( "Controller" ) );
- if( d->controlScriptEngine.hasUncaughtException() ) {
- throw Error( QObject::tr( "Exception while loading the control script %1" )
- .arg(uncaughtExceptionString(&(d->controlScriptEngine)/*, scriptPath*/)) );
+ QScriptValue comp = d->m_controlScriptEngine.evaluate(QLatin1String("Controller"));
+ if (d->m_controlScriptEngine.hasUncaughtException()) {
+ throw Error(QObject::tr("Exception while loading the control script %1")
+ .arg(uncaughtExceptionString(&(d->m_controlScriptEngine)/*, scriptPath*/)));
}
- d->controlScript = comp;
- d->controlScript.construct();
+ d->m_controlScript = comp;
+ d->m_controlScript.construct();
verbose() << "Loaded control script " << qPrintable(scriptPath) << std::endl;
}
void Gui::triggerControlScriptForCurrentPage()
{
- slotCurrentPageChanged( currentId() );
+ slotCurrentPageChanged(currentId());
}
-void Gui::slotCurrentPageChanged( int id )
+void Gui::slotCurrentPageChanged(int id)
{
- QMetaObject::invokeMethod( this, "delayedControlScriptExecution", Qt::QueuedConnection, Q_ARG( int, id ) );
+ QMetaObject::invokeMethod(this, "delayedControlScriptExecution", Qt::QueuedConnection,
+ Q_ARG(int, id));
}
-void Gui::callControlScriptMethod( const QString& methodName )
+void Gui::callControlScriptMethod(const QString& methodName)
{
- QScriptValue method = d->controlScript.property( QLatin1String( "prototype" ) ).property( methodName );
+ QScriptValue method = d->m_controlScript.property(QLatin1String("prototype")).property(methodName);
- if ( !method.isValid() ) {
- verbose() << "Control script callback " << qPrintable(methodName) << " does not exist." << std::endl;
+ if (!method.isValid()) {
+ verbose() << "Control script callback " << qPrintable(methodName) << " does not exist."
+ << std::endl;
return;
}
verbose() << "Calling control script callback " << qPrintable(methodName) << std::endl;
- method.call( d->controlScript );
+ method.call(d->m_controlScript);
- if( d->controlScriptEngine.hasUncaughtException() )
- qCritical() << uncaughtExceptionString(&(d->controlScriptEngine)/*, QLatin1String("control script")*/);
- //TODO handle error
+ if (d->m_controlScriptEngine.hasUncaughtException()) {
+ qCritical()
+ << uncaughtExceptionString(&(d->m_controlScriptEngine) /*, QLatin1String("control script")*/);
+ // TODO: handle error
+ }
}
-void Gui::delayedControlScriptExecution( int id )
+void Gui::delayedControlScriptExecution(int id)
{
- Page* const p = qobject_cast<Page*>( page( id ) );
- if ( !p )
- return;
- const QString methodName = p->objectName() + QLatin1String("Callback");
- callControlScriptMethod( methodName );
+ if (Page* const p = qobject_cast<Page*>(page(id)))
+ callControlScriptMethod(p->objectName() + QLatin1String("Callback"));
}
-
-IntroductionPage* Gui::introductionPage() const
+void Gui::onLanguageChanged()
{
- return m_introPage;
+ d->m_defaultButtonText.clear();
+ for (int i = QWizard::BackButton; i < QWizard::CustomButton1; ++i)
+ d->m_defaultButtonText.insert(i, buttonText(QWizard::WizardButton(i)));
}
-bool Gui::event( QEvent* event )
+bool Gui::event(QEvent* event)
{
- switch( event->type() )
- {
+ switch(event->type()) {
case QEvent::LanguageChange:
emit languageChanged();
break;
default:
break;
}
- return QWizard::event( event );
+ return QWizard::event(event);
}
-void Gui::wizardPageInsertionRequested( QWidget* widget, Installer::WizardPage page )
+void Gui::wizardPageInsertionRequested(QWidget* widget, Installer::WizardPage page)
{
// just in case it was already in there...
- wizardPageRemovalRequested( widget );
+ wizardPageRemovalRequested(widget);
// now find a suitable ID lower than page
- int p = static_cast< int >( page ) - 1;
- while( QWizard::page( p ) != 0 )
+ int p = static_cast<int>(page) - 1;
+ while (QWizard::page(p) != 0)
--p;
- // ad it
- setPage( p, new DynamicInstallerPage( widget, m_installer ) );
+ // add it
+ setPage(p, new DynamicInstallerPage(widget, m_installer));
}
-void Gui::wizardPageRemovalRequested( QWidget* widget )
+void Gui::wizardPageRemovalRequested(QWidget* widget)
{
- const QList< int > pages = pageIds();
- for( QList< int >::const_iterator it = pages.begin(); it != pages.end(); ++it )
- {
- QWizardPage* const p = page( *it );
- DynamicInstallerPage* const dynamicPage = dynamic_cast< DynamicInstallerPage* >( p );
- if( dynamicPage == 0 )
+ const QList<int> pages = pageIds();
+ for (QList<int>::const_iterator it = pages.begin(); it != pages.end(); ++it) {
+ QWizardPage* const p = page(*it);
+ DynamicInstallerPage* const dynamicPage = dynamic_cast<DynamicInstallerPage*>(p);
+ if (dynamicPage == 0)
continue;
- if( dynamicPage->widget() != widget )
+ if (dynamicPage->widget() != widget)
continue;
- removePage( *it );
+ removePage(*it);
}
}
-void Gui::wizardWidgetInsertionRequested( QWidget* widget, Installer::WizardPage page )
+void Gui::wizardWidgetInsertionRequested(QWidget* widget, Installer::WizardPage page)
{
Q_ASSERT(widget);
- QWizardPage* const p = QWizard::page( page );
- if (p)
- p->layout()->addWidget( widget );
+ if (QWizardPage* const p = QWizard::page(page))
+ p->layout()->addWidget(widget);
}
-void Gui::wizardWidgetRemovalRequested( QWidget* widget )
+void Gui::wizardWidgetRemovalRequested(QWidget* widget)
{
Q_ASSERT(widget);
- widget->setParent( 0 );
+ widget->setParent(0);
}
-void Gui::wizardPageVisibilityChangeRequested( bool visible, int p )
+void Gui::wizardPageVisibilityChangeRequested(bool visible, int p)
{
- if( visible && page( p ) == 0 )
- {
- setPage( p, defaultPages[ p ] );
- }
- else if( !visible && page( p ) != 0 )
- {
- defaultPages[ p ] = page( p );
- removePage( p );
+ if (visible && page(p) == 0) {
+ setPage(p, d->m_defaultPages[p]);
+ } else if (!visible && page(p) != 0) {
+ d->m_defaultPages[p] = page(p);
+ removePage(p);
}
}
-QWidget* Gui::pageWidgetByObjectName( const QString& name ) const
+Page* Gui::page(int pageId) const
+{
+ return qobject_cast<Page*>(QWizard::page(pageId));
+}
+
+QWidget* Gui::pageWidgetByObjectName(const QString& name) const
{
const QList<int> ids = pageIds();
- Q_FOREACH( const int i, ids ) {
- Page* const p = qobject_cast<Page*>( page( i ) );
- if ( p && p->objectName() == name ) {
- // For dynamic pages, return the contained widget (as read from the UI file), not the wrapper page
- if ( DynamicInstallerPage* dp = dynamic_cast<DynamicInstallerPage*>( p ) )
+ foreach (const int i, ids) {
+ Page* const p = qobject_cast<Page*>(page(i));
+ if (p && p->objectName() == name) {
+ // For dynamic pages, return the contained widget (as read from the UI file), not the
+ // wrapper page
+ if (DynamicInstallerPage* dp = dynamic_cast<DynamicInstallerPage*>(p))
return dp->widget();
- else
- return p;
+ return p;
}
}
verbose() << "No page found for object name " << name << std::endl;
@@ -488,39 +480,32 @@ QWidget* Gui::currentPageWidget() const
void Gui::cancelButtonClicked()
{
- const bool doIgnore = m_installer->isInstaller()
- ? m_installer->status() == Installer::InstallerCanceledByUser || m_installer->status() == Installer::InstallerSucceeded
- : m_installer->status() == Installer::InstallerCanceledByUser;
-
- //if the user canceled (all modes) or the installation is finished (installer mode only), ignore
- //clicks on cancel.
- if ( doIgnore )
- return;
-
- //close the manager without asking if nothing was modified, always ask for the installer
- if ( !m_installer->isInstaller() && !d->modified ) {
- QDialog::reject();
- return;
- }
-
- Page* const page = qobject_cast< Page* >( currentPage() );
- verbose() << "CANCEL CLICKED" << currentPage() << page << std::endl;
- if (page && page->isInterruptible()) {
- const QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("cancelInstallation"),
- tr("Warning"),
- tr("Do you want to abort the %1 process?").arg( m_installer->isUninstaller() ? tr( "uninstallation" ) : tr( "installation" ) ),
- QMessageBox::Yes | QMessageBox::No);
- if (bt == QMessageBox::Yes)
- emit interrupted();
+ if (currentId() != Installer::InstallationFinished) {
+ Page* const page = qobject_cast<Page*>(currentPage());
+ if (page && page->isInterruptible()) {
+ const QMessageBox::StandardButton bt =
+ MessageBoxHandler::question(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("cancelInstallation"), tr("Question"),
+ tr("Do you want to abort the %1 process?").arg(m_installer->isUninstaller()
+ ? tr("uninstallation") : tr("installation")), QMessageBox::Yes | QMessageBox::No);
+ if (bt == QMessageBox::Yes)
+ emit interrupted();
+ } else {
+ QString app = tr("installer");
+ if (m_installer->isUninstaller())
+ app = tr("uninstaller");
+ if (m_installer->isUpdater() || m_installer->isPackageManager())
+ app = tr("maintenance");
+
+ const QMessageBox::StandardButton bt =
+ MessageBoxHandler::question(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("cancelInstallation"), tr("Question"),
+ tr("Do you want to abort the %1 application?").arg(app), QMessageBox::Yes | QMessageBox::No);
+ if (bt == QMessageBox::Yes)
+ QDialog::reject();
+ }
} else {
- const QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("cancelInstallation"),
- tr("Warning"),
- tr("Do you want to abort the %1 application?").arg( m_installer->isUninstaller() ? tr( "uninstaller" ) : tr( "installer" ) ),
- QMessageBox::Yes | QMessageBox::No);
- if (bt == QMessageBox::Yes)
- QDialog::reject();
+ QDialog::reject();
}
}
@@ -534,31 +519,31 @@ void Gui::reject()
{
cancelButtonClicked();
}
-void Gui::setModified( bool value )
+
+void Gui::setModified(bool value)
{
- d->modified = value;
+ d->m_modified = value;
}
void Gui::showFinishedPage()
{
verbose() << "SHOW FINISHED PAGE" << std::endl;
- if (d->autoSwitchPage){
+ if (d->m_autoSwitchPage)
next();
- }else{
- dynamic_cast< QPushButton* >( button( QWizard::CancelButton ) )->setEnabled( false );
- }
+ else
+ qobject_cast<QPushButton*>(button(QWizard::CancelButton))->setEnabled(false);
}
-////////////////////////////////////////////////////////////////////
-//
-// Page
-//
-////////////////////////////////////////////////////////////////////
+
+// -- Page
Page::Page(Installer *installer)
- : m_installer(installer), m_fresh(true), m_complete(true)
+ : m_installer(installer)
+ , m_fresh(true)
+ , m_complete(true)
{
- setSubTitle( QLatin1String( " " ) ); // otherwise the colors will screw up
+ // otherwise the colors will screw up
+ setSubTitle(QLatin1String(" "));
}
Installer *Page::installer() const
@@ -568,17 +553,17 @@ Installer *Page::installer() const
QPixmap Page::watermarkPixmap() const
{
- return QPixmap(m_installer->value( QLatin1String( "WatermarkPixmap" ) ) );
+ return QPixmap(m_installer->value(QLatin1String("WatermarkPixmap")));
}
QPixmap Page::logoPixmap() const
{
- return QPixmap(m_installer->value( QLatin1String( "LogoPixmap" ) ) );
+ return QPixmap(m_installer->value(QLatin1String("LogoPixmap")));
}
QString Page::productName() const
{
- return m_installer->value( QLatin1String( "ProductName" ) );
+ return m_installer->value(QLatin1String("ProductName"));
}
bool Page::isComplete() const
@@ -589,27 +574,26 @@ bool Page::isComplete() const
void Page::setComplete(bool complete)
{
m_complete = complete;
+ if (QWizard *w = wizard()) {
+ if (QAbstractButton *cancel = w->button(QWizard::CancelButton)) {
+ if (cancel->hasFocus()) {
+ if (QAbstractButton *next = w->button(QWizard::NextButton))
+ next->setFocus();
+ }
+ }
+ }
emit completeChanged();
- if( wizard() == 0 )
- return;
- if( wizard()->button( QWizard::CancelButton ) == 0 )
- return;
- if( wizard()->button( QWizard::NextButton ) == 0 )
- return;
- if( wizard()->button( QWizard::CancelButton )->hasFocus() )
- wizard()->button( QWizard::NextButton )->setFocus();
}
-void Page::insertWidget(QWidget *widget, const QString &siblingName,
- int offset)
+void Page::insertWidget(QWidget *widget, const QString &siblingName, int offset)
{
QWidget *sibling = findChild<QWidget *>(siblingName);
QWidget *parent = sibling ? sibling->parentWidget() : 0;
QLayout *layout = parent ? parent->layout() : 0;
QBoxLayout *blayout = qobject_cast<QBoxLayout *>(layout);
- //qDebug() << "FOUND: " << sibling << parent << layout << blayout;
+
if (blayout) {
- int index = blayout->indexOf(sibling) + offset;
+ const int index = blayout->indexOf(sibling) + offset;
blayout->insertWidget(index, widget);
}
}
@@ -619,16 +603,23 @@ QWidget *Page::findWidget(const QString &objectName) const
return findChild<QWidget *>(objectName);
}
+/*!
+ \reimp
+ \Overwritten to support some kind of initializePage() in the case the wizard has been set
+ to QWizard::IndependentPages. If that option has been set, initializePage() would be only called
+ once. So we provide entering() and leaving() based on this overwritten function.
+*/
void Page::setVisible(bool visible)
{
QWizardPage::setVisible(visible);
qApp->processEvents();
- //qDebug() << "VISIBLE: " << visible << objectName() << installer();
+
if (m_fresh && !visible) {
- //qDebug() << "SUPRESSED...";
+ // this is only hit once when the page gets added to the wizard
m_fresh = false;
return;
}
+
if (visible)
entering();
else
@@ -637,33 +628,31 @@ void Page::setVisible(bool visible)
int Page::nextId() const
{
- //qDebug() << "NEXTID";
return QWizardPage::nextId();
}
-////////////////////////////////////////////////////////////////////
-//
-// QInstallerIntroductionPage
-//
-////////////////////////////////////////////////////////////////////
+
+// -- QInstallerIntroductionPage
IntroductionPage::IntroductionPage(Installer *inst)
- : Page(inst), m_widget(0)
+ : Page(inst)
+ , m_widget(0)
{
- setObjectName( QLatin1String( "IntroductionPage" ) );
+ setObjectName(QLatin1String("IntroductionPage"));
setTitle(tr("Setup - %1").arg(productName()));
setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
setSubTitle(QString());
m_msgLabel = new QLabel(this);
- m_msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
m_msgLabel->setWordWrap(true);
m_msgLabel->setText(tr("Welcome to the %1 Setup Wizard.")
.arg(productName()));
- QVBoxLayout *layout = new QVBoxLayout( this );
+ QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
- layout->addWidget( m_msgLabel );
+ layout->addWidget(m_msgLabel);
+ layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
void IntroductionPage::setText(const QString &text)
@@ -673,38 +662,35 @@ void IntroductionPage::setText(const QString &text)
void IntroductionPage::setWidget(QWidget *w)
{
- if(m_widget) {
+ if (m_widget) {
layout()->removeWidget(m_widget);
delete m_widget;
}
m_widget = w;
- if(m_widget) {
+ if (m_widget)
static_cast<QVBoxLayout*>(layout())->addWidget(m_widget, 1);
- }
}
-////////////////////////////////////////////////////////////////////
-//
-// LicenseAgreementPage
-//
-////////////////////////////////////////////////////////////////////
+
+// -- LicenseAgreementPage
LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
: Page(inst)
{
setTitle(tr("License Agreement"));
+ setSubTitle(tr("Please read the following license agreement(s). You must accept the terms contained "
+ "in these agreement(s) before continuing with the installation."));
+
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("LicenseAgreementPage"));
- QLabel *msgLabel = new QLabel(tr("Please read the following license agreement(s). You must "
- "accept the terms contained in these agreement(s) before continuing with the installation."));
- msgLabel->setWordWrap(true);
-
+#if !defined(Q_WS_MAC)
QGroupBox *licenseBox = new QGroupBox(this);
licenseBox->setObjectName(QString::fromUtf8("licenseBox"));
+#endif
- m_licenseListWidget = new QListWidget(licenseBox);
+ m_licenseListWidget = new QListWidget(this);
connect(m_licenseListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(currentItemChanged(QListWidgetItem *)));
@@ -712,20 +698,28 @@ LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
sizePolicy.setHeightForWidth(m_licenseListWidget->sizePolicy().hasHeightForWidth());
m_licenseListWidget->setSizePolicy(sizePolicy);
- m_textBrowser = new QTextBrowser(licenseBox);
+ m_textBrowser = new QTextBrowser(this);
m_textBrowser->setReadOnly(true);
- m_textBrowser->setOpenExternalLinks(true);
m_textBrowser->setOpenLinks(false);
+ m_textBrowser->setOpenExternalLinks(true);
connect(m_textBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(openLicenseUrl(QUrl)));
QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Expanding);
sizePolicy2.setHeightForWidth(m_textBrowser->sizePolicy().hasHeightForWidth());
m_textBrowser->setSizePolicy(sizePolicy2);
- QHBoxLayout *licenseBoxLayout = new QHBoxLayout(licenseBox);
+ QHBoxLayout *licenseBoxLayout = new QHBoxLayout();
licenseBoxLayout->addWidget(m_licenseListWidget);
licenseBoxLayout->addWidget(m_textBrowser);
+ QVBoxLayout *layout = new QVBoxLayout(this);
+#if !defined(Q_WS_MAC)
+ layout->addWidget(licenseBox);
+ licenseBox->setLayout(licenseBoxLayout);
+#else
+ layout->addLayout(licenseBoxLayout);
+#endif
+
m_acceptRadioButton = new QRadioButton(this);
m_acceptRadioButton->setObjectName(QString::fromUtf8("acceptLicenseRB"));
@@ -740,8 +734,8 @@ LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
m_rejectRadioButton = new QRadioButton(this);
m_rejectRadioButton->setObjectName(QString::fromUtf8("rejectLicenseRB"));
- m_rejectRadioButton->setShortcut(QKeySequence(tr("Alt+N", "do not agree license")));
- QLabel *rejectLabel = new QLabel(tr("I do <u>n</u>ot accept the terms and conditions of the above "
+ m_rejectRadioButton->setShortcut(QKeySequence(tr("Alt+D", "do not agree license")));
+ QLabel *rejectLabel = new QLabel(tr("I <u>d</u>o not accept the terms and conditions of the above "
"listed license agreements. Please note by checking the box, you must cancel the "
"installation or downloading the Qt SDK and must destroy all copies, or portions thereof, "
"of the Qt SDK in your possessions."));
@@ -761,7 +755,6 @@ LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
QFont labelFont(font());
labelFont.setPixelSize(9);
- msgLabel->setFont(labelFont);
acceptLabel->setFont(labelFont);
rejectLabel->setFont(labelFont);
#endif
@@ -772,28 +765,25 @@ LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
gridLayout->addWidget(acceptLabel, 0, 1);
gridLayout->addWidget(m_rejectRadioButton, 1, 0);
gridLayout->addWidget(rejectLabel, 1, 1);
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->addWidget(msgLabel);
- layout->addWidget(licenseBox);
layout->addLayout(gridLayout);
- connect(m_acceptRadioButton, SIGNAL(toggled(bool)), this,
- SIGNAL(completeChanged()));
- connect(m_rejectRadioButton, SIGNAL(toggled(bool)), this,
- SIGNAL(completeChanged()));
+ connect(m_acceptRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(completeChanged()));
+ connect(m_rejectRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(completeChanged()));
m_rejectRadioButton->setChecked(true);
}
-void LicenseAgreementPage::initializePage()
+void LicenseAgreementPage::entering()
{
m_licenseListWidget->clear();
m_textBrowser->setText(QLatin1String(""));
- // TODO: this needs to be fixed once we support several root components
+ RunMode runMode = installer()->runMode();
+ QList<QInstaller::Component*> components = installer()->components(false, runMode);
+
QInstaller::Component *rootComponent = 0;
- foreach (QInstaller::Component* root, installer()->components()) {
+ // TODO: this needs to be fixed once we support several root components
+ foreach (QInstaller::Component* root, components) {
if (root->isInstalled())
continue;
@@ -804,7 +794,7 @@ void LicenseAgreementPage::initializePage()
}
}
- QList<QInstaller::Component*> components = installer()->componentsToInstall(true);
+ components = installer()->componentsToInstall(runMode);
foreach (QInstaller::Component* component, components) {
if (rootComponent != component && !component->isInstalled())
addLicenseItem(component->licenses());
@@ -839,30 +829,8 @@ void LicenseAgreementPage::addLicenseItem(const QHash<QString, QPair<QString, QS
}
}
-////////////////////////////////////////////////////////////////////
-//
-// ComponentSelectionPage
-//
-////////////////////////////////////////////////////////////////////
-
-inline QString unitSizeText(const qint64 size) {
- if (size < 10000)
- return QString::number(size) + QLatin1Char(' ') + ComponentSelectionPage::tr("Bytes");
- if (size < 1024 * 10000)
- return QString::number(size / 1024) + QLatin1Char(' ') + ComponentSelectionPage::tr("kBytes");
- return QString::number(size / 1024 / 1024) + QLatin1Char(' ') + ComponentSelectionPage::tr("MBytes");
-}
-
-static QString niceSizeText(const QString &str)
-{
- const qint64 size = str.toLongLong();
- if( size == 0 )
- return QString();
- QString msg = ComponentSelectionPage::tr(
- "This component will occupy approximately %1 on your harddisk.");
- return msg.arg(unitSizeText(size));
-}
+// -- ComponentSelectionPage::Private
class ComponentSelectionPage::Private : public QObject
{
@@ -870,241 +838,245 @@ class ComponentSelectionPage::Private : public QObject
public:
Private(ComponentSelectionPage *qq, Installer *installer)
- : q( qq ),
- wasshown( false ),
- modified( false ),
- connected( false ),
- m_model( new ComponentModel( installer ) ),
- m_installer( installer ),
- m_treeView( new QTreeView( q ) )
+ : q(qq)
+ , m_installer(installer)
+ , m_treeView(new QTreeView(q))
+ , m_allModel(new ComponentModel(5, m_installer))
+ , m_updaterModel(new ComponentModel(5, m_installer))
{
- m_treeView->setObjectName( QLatin1String( "TreeView" ) );
- m_treeView->setMouseTracking(true);
- m_treeView->setHeaderHidden( true );
+ m_treeView->setObjectName(QLatin1String("ComponentTreeView"));
+
+ int i = 0;
+ m_currentModel = m_allModel;
+ ComponentModel *list[] = { m_allModel, m_updaterModel, 0 };
+ while (ComponentModel *model = list[i++]) {
+ connect(model, SIGNAL(defaultCheckStateChanged(bool)), q, SLOT(setModified(bool)));
+ model->setHeaderData(ComponentModelHelper::NameColumn, Qt::Horizontal, tr("Name"));
+ model->setHeaderData(ComponentModelHelper::InstalledVersionColumn, Qt::Horizontal,
+ tr("Installed Version"));
+ model->setHeaderData(ComponentModelHelper::NewVersionColumn, Qt::Horizontal, tr("New Version"));
+ model->setHeaderData(ComponentModelHelper::UncompressedSizeColumn, Qt::Horizontal, tr("Size"));
+ }
- m_treeView->setModel( m_model );
- for( int i = 1; i < m_treeView->model()->columnCount(); ++i )
- m_treeView->setColumnHidden( i, true );
+ QHBoxLayout *hlayout = new QHBoxLayout;
+ hlayout->addWidget(m_treeView, 3);
m_descriptionLabel = new QLabel(q);
m_descriptionLabel->setWordWrap(true);
+ m_descriptionLabel->setObjectName(QLatin1String("ComponentDescriptionLabel"));
- m_sizeLabel = new QLabel(q);
- m_sizeLabel->setWordWrap(true);
-
- QVBoxLayout *layout = new QVBoxLayout( q );
- if( !installer->isInstaller() )
- {
- QRadioButton* const uninstallAll = new QRadioButton( tr( "Remove all components" ) );
- uninstallAll->setObjectName( QLatin1String("uninstallAllComponentsRB") );
- QRadioButton* const keepChecked = new QRadioButton( installer->isUninstaller() ? tr( "Keep selected components" ) : tr( "Install selected components" ) );
- keepChecked->setObjectName( QLatin1String("keepSelectedComponentsRB") );
- layout->addWidget( uninstallAll );
- layout->addWidget( keepChecked );
- connect( uninstallAll, SIGNAL( toggled( bool ) ), m_treeView, SLOT( setDisabled( bool ) ) );
- connect( uninstallAll, SIGNAL( toggled( bool ) ), m_descriptionLabel, SLOT( setDisabled( bool ) ) );
- connect( uninstallAll, SIGNAL( toggled( bool ) ), m_installer, SLOT( setCompleteUninstallation( bool ) ) );
- connect( uninstallAll, SIGNAL( toggled( bool ) ), q, SIGNAL( completeChanged() ), Qt::QueuedConnection );
- connect( uninstallAll, SIGNAL( toggled( bool ) ), this, SLOT( fullUninstallToggled( bool ) ), Qt::QueuedConnection );
- uninstallAll->setChecked( installer->isUninstaller() );
- keepChecked->setChecked( installer->isPackageManager() );
- m_installer->setCompleteUninstallation( installer->isUninstaller() );
- }
- //layout->addWidget(msgLabel);
- QHBoxLayout *hlayout = new QHBoxLayout;
- hlayout->addWidget(m_treeView, 3);
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->addWidget(m_descriptionLabel);
+
+ m_sizeLabel = new QLabel(q);
+ m_sizeLabel->setWordWrap(true);
vlayout->addWidget(m_sizeLabel);
- vlayout->addSpacerItem(new QSpacerItem(1, 1,
- QSizePolicy::MinimumExpanding,
+ m_sizeLabel->setObjectName(QLatin1String("ComponentSizeLabel"));
+
+ vlayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding));
hlayout->addLayout(vlayout, 2);
- layout->addLayout(hlayout);
- connect( m_treeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ),
- this, SLOT( selectionChanged() ) );
+ QVBoxLayout *layout = new QVBoxLayout(q);
+ layout->addLayout(hlayout, 1);
+
+ QPushButton *button;
+ hlayout = new QHBoxLayout;
+ if (m_installer->isInstaller()) {
+ hlayout->addWidget(button = new QPushButton(tr("Default")));
+ connect(button, SIGNAL(clicked()), this, SLOT(selectDefault()));
+ }
+ hlayout->addWidget(button = new QPushButton(tr("Select All")));
+ connect(button, SIGNAL(clicked()), this, SLOT(selectAll()));
+ hlayout->addWidget(button = new QPushButton(tr("Deselect All")));
+ connect(button, SIGNAL(clicked()), this, SLOT(deselectAll()));
+ hlayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding,
+ QSizePolicy::MinimumExpanding));
+ layout->addLayout(hlayout);
- connect( m_treeView->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
- q, SIGNAL( completeChanged() ), Qt::QueuedConnection );
+ connect(m_installer, SIGNAL(finishAllComponentsReset()), this, SLOT(allComponentsChanged()),
+ Qt::QueuedConnection);
+ connect(m_installer, SIGNAL(finishUpdaterComponentsReset()), this, SLOT(updaterComponentsChanged()),
+ Qt::QueuedConnection);
}
-protected Q_SLOTS:
- void selectionChanged()
+ void updateTreeView()
{
- const QModelIndex index = m_treeView->currentIndex();
- if( !index.isValid() )
- {
- m_descriptionLabel->clear();
- m_sizeLabel->clear();
- return;
+ m_currentModel = m_installer->isUpdater() ? m_updaterModel : m_allModel;
+ m_treeView->setModel(m_currentModel);
+
+ if (m_installer->isInstaller()) {
+ m_treeView->setHeaderHidden(true);
+ for (int i = 1; i < m_currentModel->columnCount(); ++i)
+ m_treeView->hideColumn(i);
+ } else {
+ m_treeView->header()->setStretchLastSection(true);
+ for (int i = 0; i < m_currentModel->columnCount(); ++i)
+ m_treeView->resizeColumnToContents(i);
}
- m_descriptionLabel->setText( index.data( Qt::ToolTipRole ).toString() );
- if( !m_installer->isUninstaller() )
- m_sizeLabel->setText( niceSizeText( qVariantValue< Component* >( index.data( Qt::UserRole ) )->value( QString::fromLatin1( "UncompressedSize" ) ) ) );
+ bool hasChildren = false;
+ const int rowCount = m_currentModel->rowCount();
+ for (int row = 0; row < rowCount && !hasChildren; ++row)
+ hasChildren = m_currentModel->hasChildren(m_currentModel->index(row, 0));
+ m_treeView->setRootIsDecorated(hasChildren);
+
+ disconnect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentChanged(QModelIndex)));
+ connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentChanged(QModelIndex)));
+
+ m_treeView->setCurrentIndex(m_currentModel->index(0, 0));
+ m_treeView->setExpanded(m_currentModel->index(0, 0), true);
}
- void fullUninstallToggled( bool value )
+
+public slots:
+ void currentChanged(const QModelIndex &current)
{
- if ( value )
- {
- emit workRequested( value );
- q->setModified( value );
- }
- else
- {
- const QModelIndex index = m_model->index( 0, 0 );
- const QVariant data = m_model->data( index, Qt::CheckStateRole );
- m_model->setData( index, data, Qt::CheckStateRole );
+ m_sizeLabel->clear();
+ m_descriptionLabel->clear();
+
+ if (current.isValid()) {
+ m_descriptionLabel->setText(m_currentModel->data(m_currentModel->index(current.row(),
+ ComponentModelHelper::NameColumn, current.parent()), Qt::ToolTipRole).toString());
+ if (!m_installer->isUninstaller()) {
+ m_sizeLabel->setText(tr("This component will occupy approximately %1 on your "
+ "hard disk.").arg(m_currentModel->data(m_currentModel->index(current.row(),
+ ComponentModelHelper::UncompressedSizeColumn, current.parent())).toString()));
+ }
}
}
-Q_SIGNALS:
- void workRequested( bool );
+ void selectAll()
+ {
+ m_currentModel->selectAll();
+ }
-public:
- ComponentSelectionPage* const q;
-
- bool wasshown;
- bool modified;
- bool connected;
- ComponentModel* const m_model;
- Installer* const m_installer;
- QTreeView* const m_treeView;
- QLabel *m_descriptionLabel;
- QLabel *m_sizeLabel;
-};
+ void deselectAll()
+ {
+ m_currentModel->deselectAll();
+ }
-void ComponentSelectionPage::entering()
-{
- wizard()->button( QWizard::CancelButton )->setEnabled( true );
- if( !d->connected )
+ void selectDefault()
{
- Gui* par = dynamic_cast< Gui* > ( wizard() );
- if ( par )
- {
- verbose() << "connect Models" << std::endl;
- connect( d->m_model, SIGNAL( workRequested( bool ) ), par, SLOT( setModified( bool ) ), Qt::QueuedConnection );
- connect( d->m_model, SIGNAL( workRequested( bool ) ), this, SLOT( setModified( bool ) ), Qt::QueuedConnection );
- connect( d.get(), SIGNAL( workRequested( bool) ), par, SLOT( setModified( bool ) ), Qt::QueuedConnection );
- connect( d->m_model, SIGNAL( modelReset() ), this, SLOT( modelWasReseted() ), Qt::QueuedConnection );
- d->connected = true;
- }
- if ( !d->m_installer->isInstaller() )
- setButtonText( QWizard::CancelButton, tr( "&Close" ) );
+ m_currentModel->selectDefault();
}
-}
-/*!
- \class QInstaller::ComponentSelectionPage
- On this page the user can select and deselect what he wants to be installed.
- */
-ComponentSelectionPage::ComponentSelectionPage( Installer* installer )
- : Page( installer ),
- d( new Private( this, installer ) )
-{
- setObjectName( QLatin1String( "ComponentSelectionPage" ) );
- if( !installer->isUninstaller() )
+private slots:
+ void allComponentsChanged()
{
- setTitle( tr( "Select Components" ) );
- setSubTitle( tr( "Please select the components you want to install." ) );
+ m_allModel->setRootComponents(m_installer->components(false, AllMode));
}
- else
+
+ void updaterComponentsChanged()
{
- setTitle( tr( "Select Components" ) );
- setSubTitle( tr( "Please select the components you want to uninstall." ) );
+ m_updaterModel->setRootComponents(m_installer->components(false, UpdaterMode));
}
- setPixmap( QWizard::LogoPixmap, logoPixmap() );
- setPixmap( QWizard::WatermarkPixmap, QPixmap() );
+
+public:
+ ComponentSelectionPage *q;
+ Installer *m_installer;
+ QTreeView *m_treeView;
+ ComponentModel *m_allModel;
+ ComponentModel *m_updaterModel;
+ ComponentModel *m_currentModel;
+ QLabel *m_sizeLabel;
+ QLabel *m_descriptionLabel;
+};
+
+
+// -- ComponentSelectionPage
+
+/*!
+ \class QInstaller::ComponentSelectionPage
+ On this page the user can select and deselect what he wants to be installed.
+*/
+ComponentSelectionPage::ComponentSelectionPage(Installer* installer)
+ : Page(installer)
+ , d(new Private(this, installer))
+{
+ setTitle(tr("Select Components"));
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+ setObjectName(QLatin1String("ComponentSelectionPage"));
+
+ if (installer->isInstaller())
+ setSubTitle(tr("Please select the components you want to install."));
+ if (installer->isUninstaller())
+ setSubTitle(tr("Please select the components you want to uninstall."));
+
+ if (installer->isUpdater())
+ setSubTitle(tr("Please select the components you want to update."));
+ if (installer->isPackageManager())
+ setSubTitle(tr("Please (de)select the components you want to (un)install."));
}
ComponentSelectionPage::~ComponentSelectionPage()
{
+ delete d;
}
-void ComponentSelectionPage::modelWasReseted()
+void ComponentSelectionPage::entering()
{
- if( d->m_treeView->model()->rowCount() == 1 )
- {
- d->m_treeView->setExpanded( d->m_treeView->model()->index( 0, 0 ), true );
- d->wasshown = true;
- }
+ d->updateTreeView();
+ setModified(isComplete());
}
-void ComponentSelectionPage::showEvent( QShowEvent* event )
+void ComponentSelectionPage::selectAll()
{
- if( !d->wasshown && d->m_treeView->model()->rowCount() == 1 )
- {
- d->m_treeView->setExpanded( d->m_treeView->model()->index( 0, 0 ), true );
- d->wasshown = true;
- }
- Page::showEvent( event );
+ d->selectAll();
}
+void ComponentSelectionPage::deselectAll()
+{
+ d->deselectAll();
+}
+
+void ComponentSelectionPage::selectDefault()
+{
+ if (installer()->isInstaller())
+ d->selectDefault();
+}
/*!
- Selects the component with /a id in the component tree.
- */
-void ComponentSelectionPage::selectComponent( const QString& id ) {
- const QModelIndex idx = d->m_model->findComponent( id );
- if ( !idx.isValid() )
- return;
- d->m_model->setData( idx, Qt::Checked );
+ Selects the component with /a id in the component tree.
+*/
+void ComponentSelectionPage::selectComponent(const QString& id)
+{
+ const QModelIndex &idx = d->m_currentModel->indexFromComponentName(id);
+ if (idx.isValid())
+ d->m_currentModel->setData(idx, Qt::Checked, Qt::CheckStateRole);
}
/*!
- Deselects the component with /a id in the component tree.
- */
-void ComponentSelectionPage::deselectComponent( const QString& id ) {
- const QModelIndex idx = d->m_model->findComponent( id );
- if ( !idx.isValid() )
- return;
- d->m_model->setData( idx, Qt::Unchecked );
+ Deselects the component with /a id in the component tree.
+*/
+void ComponentSelectionPage::deselectComponent(const QString& id)
+{
+ const QModelIndex &idx = d->m_currentModel->indexFromComponentName(id);
+ if (idx.isValid())
+ d->m_currentModel->setData(idx, Qt::Unchecked, Qt::CheckStateRole);
}
-void ComponentSelectionPage::setModified( bool value )
+void ComponentSelectionPage::setModified(bool modified)
{
- d->modified = value;
- if (d->m_installer->isInstaller() || value)
- setButtonText( QWizard::CancelButton, tr( "&Cancel" ) );
- else
- setButtonText( QWizard::CancelButton, tr( "C&lose" ) );
+ setComplete(modified);
}
bool ComponentSelectionPage::isComplete() const
{
- // uninstall all
- if( !d->m_treeView->isEnabled() )
- return true;
-
- if( d->m_installer->isPackageManager() )
- {
- // at least component should be different from its previous state
- if ( d->modified )
- return true;
- else
- return false;
- }
- // at least one component needs to be selected for (un)installation
- const QList< Component* > components = d->m_installer->components( true );
- for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
- {
- if( (*it)->isSelected() == d->m_installer->isInstaller() )
- return true;
- }
- return false;
+ if (installer()->isInstaller() || installer()->isUpdater())
+ return d->m_currentModel->hasCheckedComponents();
+ return !d->m_currentModel->defaultCheckState();
}
-////////////////////////////////////////////////////////////////////
-//
-// TargetDirectoryPage
-//
-////////////////////////////////////////////////////////////////////
+
+// -- TargetDirectoryPage
TargetDirectoryPage::TargetDirectoryPage(Installer *installer)
: Page(installer)
{
- setObjectName( QLatin1String( "TargetDirectoryPage" ) );
+ setObjectName(QLatin1String("TargetDirectoryPage"));
setTitle(tr("Installation Folder"));
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
@@ -1113,14 +1085,14 @@ TargetDirectoryPage::TargetDirectoryPage(Installer *installer)
msgLabel->setText(tr("Please specify the folder where %1 "
"will be installed.").arg(productName()));
msgLabel->setWordWrap(true);
- msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ msgLabel->setObjectName(QLatin1String("MessageLabel"));
m_lineEdit = new QLineEdit(this);
- m_lineEdit->setObjectName( QLatin1String("targetDirectoryLE") );
+ m_lineEdit->setObjectName(QLatin1String("targetDirectoryLE"));
QPushButton *browseButton = new QPushButton(this);
- browseButton->setObjectName( QLatin1String( "BrowseButton" ) );
- browseButton->setText( tr( "Browse..." ) );
+ browseButton->setObjectName(QLatin1String("BrowseButton"));
+ browseButton->setText(tr("Browse..."));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(msgLabel);
@@ -1131,8 +1103,7 @@ TargetDirectoryPage::TargetDirectoryPage(Installer *installer)
setLayout(layout);
connect(browseButton, SIGNAL(clicked()), this, SLOT(dirRequested()));
- connect(m_lineEdit, SIGNAL(textChanged(QString)), this,
- SIGNAL(completeChanged()));
+ connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
}
QString TargetDirectoryPage::targetDir() const
@@ -1147,15 +1118,15 @@ void TargetDirectoryPage::setTargetDir(const QString &dirName)
void TargetDirectoryPage::initializePage()
{
- QString targetDir = installer()->value( QLatin1String( "TargetDir" ) );
- if( targetDir.isEmpty() )
- {
+ QString targetDir = installer()->value(QLatin1String("TargetDir"));
+ if (targetDir.isEmpty()) {
targetDir = QDir::homePath() + QDir::separator();
- if( targetDir.contains( QLatin1Char( ' ' ) ) ) // prevent spaces in the default target directory
+ // prevent spaces in the default target directory
+ if (targetDir.contains(QLatin1Char(' ')))
targetDir = QDir::rootPath();
- targetDir += productName().remove( QLatin1Char( ' ' ) );
+ targetDir += productName().remove(QLatin1Char(' '));
}
- m_lineEdit->setText( QDir::toNativeSeparators( QDir( targetDir ).absolutePath() ) );
+ m_lineEdit->setText(QDir::toNativeSeparators(QDir(targetDir).absolutePath()));
Page::initializePage();
}
@@ -1164,25 +1135,22 @@ bool TargetDirectoryPage::validatePage()
{
if (targetDir().isEmpty()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"), tr("Error"),
- tr( "The install directory cannot be empty, please specify a valid folder"),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr( "The install directory cannot be empty, please specify a valid folder"), QMessageBox::Ok);
return false;
}
- const QDir dir( targetDir() );
-
- if( dir.exists() && dir.entryList( QDir::NoDotAndDotDot ).isEmpty() ) // it exists, but is empty (might be created by the Browse button (getExistingDirectory)
- {
+
+ const QDir dir(targetDir());
+ // it exists, but is empty (might be created by the Browse button (getExistingDirectory)
+ if (dir.exists() && dir.entryList(QDir::NoDotAndDotDot).isEmpty()) {
return true;
- }
- else if( dir.exists() && dir.isReadable() ) // it exists, but is not empty
- {
- if ( dir == QDir::root() )
- {
+ } else if (dir.exists() && dir.isReadable()) {
+ // it exists, but is not empty
+ if (dir == QDir::root()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("forbiddenTargetDirectory"), tr( "Error" ),
- tr( "As the install directory is completely deleted installing in %1 is forbidden" ).arg( QDir::rootPath() ),
- QMessageBox::Ok);
+ QLatin1String("forbiddenTargetDirectory"), tr("Error"),
+ tr("As the install directory is completely deleted installing in %1 is forbidden")
+ .arg(QDir::rootPath()), QMessageBox::Ok);
return false;
}
@@ -1191,17 +1159,13 @@ bool TargetDirectoryPage::validatePage()
return true;
return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("overwriteTargetDirectory"), tr( "Warning" ),
- tr( "You have selected an existing, non-empty folder for installation.\n"
- "Note that it will be completely wiped on uninstallation of this application.\n"
- "It is not advisable to install into this folder as installation might fail.\n"
- "Do you want to continue?" ),
- QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes;
- }
- else
- {
- return true;
+ QLatin1String("overwriteTargetDirectory"), tr("Warning"),
+ tr("You have selected an existing, non-empty folder for installation.\n"
+ "Note that it will be completely wiped on uninstallation of this application.\n"
+ "It is not advisable to install into this folder as installation might fail.\n"
+ "Do you want to continue?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
}
+ return true;
}
void TargetDirectoryPage::entering()
@@ -1210,7 +1174,7 @@ void TargetDirectoryPage::entering()
void TargetDirectoryPage::leaving()
{
- installer()->setValue( QLatin1String( "TargetDir" ), targetDir());
+ installer()->setValue(QLatin1String("TargetDir"), targetDir());
}
void TargetDirectoryPage::targetDirSelected()
@@ -1219,70 +1183,60 @@ void TargetDirectoryPage::targetDirSelected()
void TargetDirectoryPage::dirRequested()
{
- //qDebug() << "DIR REQUESTED";
- QString newDirName = QFileDialog::getExistingDirectory(this,
- tr("Select Installation Folder"), targetDir()
- /*, Options options = ShowDirsOnly*/);
+ QString newDirName = QFileDialog::getExistingDirectory(this, tr("Select Installation Folder"),
+ targetDir());
if (newDirName.isEmpty() || newDirName == targetDir())
return;
- m_lineEdit->setText( QDir::toNativeSeparators( newDirName ) );
+ m_lineEdit->setText(QDir::toNativeSeparators(newDirName));
}
-// #pragma mark -- StartMenuDirectoryPage
-
+// -- StartMenuDirectoryPage
StartMenuDirectoryPage::StartMenuDirectoryPage(Installer *installer)
: Page(installer)
{
- setObjectName( QLatin1String( "StartMenuDirectoryPage" ) );
setTitle(tr("Start Menu shortcuts"));
-
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
-
- QString msg = tr("Select the Start Menu in which you would like to "
- "create the program's shortcuts. You can also enter a name to "
- "create a new folder.");
-
- QLabel *msgLabel = new QLabel(this);
- msgLabel->setText(msg);
- msgLabel->setWordWrap(true);
- msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ setObjectName(QLatin1String("StartMenuDirectoryPage"));
+ setSubTitle(tr("Select the Start Menu in which you would like to create the program's shortcuts. You can "
+ "also enter a name to create a new folder."));
m_lineEdit = new QLineEdit(this);
- m_lineEdit->setObjectName( QLatin1String( "LineEdit" ) );
+ m_lineEdit->setObjectName(QLatin1String("LineEdit"));
- QString startMenuDir = installer->value( QLatin1String( "StartMenuDir" ) );
+ QString startMenuDir = installer->value(QLatin1String("StartMenuDir"));
if (startMenuDir.isEmpty())
startMenuDir = productName();
m_lineEdit->setText(startMenuDir);
// grab existing start menu folders
- QSettings user(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft\\"
- "Windows\\CurrentVersion\\Explorer\\User Shell Folders"),
- QSettings::NativeFormat);
- //User Shell Folders uses %USERPROFILE%
- startMenuPath = replaceWindowsEnvironmentVariables( user.value(QLatin1String("Programs"), QString()).toString() );
- installer->setValue( QLatin1String( "DesktopDir" ), replaceWindowsEnvironmentVariables( user.value( QLatin1String( "Desktop" ) ).toString() ) );
+ QSettings user(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\"
+ "Explorer\\User Shell Folders"), QSettings::NativeFormat);
+ // User Shell Folders uses %USERPROFILE%
+ startMenuPath = replaceWindowsEnvironmentVariables(user.value(QLatin1String("Programs"),
+ QString()).toString());
+ installer->setValue(QLatin1String("DesktopDir"),
+ replaceWindowsEnvironmentVariables(user.value(QLatin1String("Desktop")).toString()));
QDir dir(startMenuPath); // user only dirs
QStringList dirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
- if (installer->value(QLatin1String("AllUsers")) == QLatin1String( "true" ) ) {
+ if (installer->value(QLatin1String("AllUsers")) == QLatin1String("true")) {
verbose() << "AllUsers set. Using HKEY_LOCAL_MACHINE" << std::endl;
- QSettings system(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\"
- "Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
- QSettings::NativeFormat);
- startMenuPath = system.value(QLatin1String("Common Programs"),
- QString()).toString();
- installer->setValue( QLatin1String( "DesktopDir" ), system.value( QLatin1String( "Desktop" ) ).toString() );
+ QSettings system(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\"
+ "CurrentVersion\\Explorer\\Shell Folders"), QSettings::NativeFormat);
+ startMenuPath = system.value(QLatin1String("Common Programs"), QString()).toString();
+ installer->setValue(QLatin1String("DesktopDir"),
+ system.value(QLatin1String("Desktop")).toString());
dir.setPath(startMenuPath); // system only dirs
dirs += dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
}
+
verbose() << "StartMenuPath: " << startMenuPath;
- verbose() << "DesktopDir:" << installer->value( QLatin1String("DesktopDir") ) << std::endl;
+ verbose() << "DesktopDir:" << installer->value(QLatin1String("DesktopDir")) << std::endl;
m_listWidget = new QListWidget(this);
if (!dirs.isEmpty()) {
@@ -1292,63 +1246,66 @@ StartMenuDirectoryPage::StartMenuDirectoryPage(Installer *installer)
}
QVBoxLayout *layout = new QVBoxLayout(this);
- layout->addWidget(msgLabel);
layout->addWidget(m_lineEdit);
layout->addWidget(m_listWidget);
setLayout(layout);
- connect(m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
- QListWidgetItem*)), this, SLOT(currentItemChanged(QListWidgetItem*)));
+ connect(m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this,
+ SLOT(currentItemChanged(QListWidgetItem*)));
}
-QString
-StartMenuDirectoryPage::startMenuDir() const
+QString StartMenuDirectoryPage::startMenuDir() const
{
return m_lineEdit->text();
}
-void
-StartMenuDirectoryPage::setStartMenuDir(const QString &startMenuDir)
+void StartMenuDirectoryPage::setStartMenuDir(const QString &startMenuDir)
{
m_lineEdit->setText(startMenuDir);
}
-void
-StartMenuDirectoryPage::leaving()
+void StartMenuDirectoryPage::leaving()
{
- installer()->setValue( QLatin1String( "StartMenuDir" ), startMenuPath + QDir::separator() + startMenuDir());
+ installer()->setValue(QLatin1String("StartMenuDir"), startMenuPath + QDir::separator()
+ + startMenuDir());
}
-void
-StartMenuDirectoryPage::currentItemChanged(QListWidgetItem* current)
+void StartMenuDirectoryPage::currentItemChanged(QListWidgetItem* current)
{
if (current) {
QString dir = current->data(Qt::DisplayRole).toString();
if (!dir.isEmpty())
dir += QDir::separator();
- setStartMenuDir(dir + installer()->value( QLatin1String( "StartMenuDir" ) ) );
+ setStartMenuDir(dir + installer()->value(QLatin1String("StartMenuDir")));
}
}
-////////////////////////////////////////////////////////////////////
-//
-// ReadyForInstallationPage
-//
-////////////////////////////////////////////////////////////////////
+// -- ReadyForInstallationPage
-ReadyForInstallationPage::ReadyForInstallationPage( Installer* installer )
- : Page(installer),
- msgLabel( new QLabel )
+inline QString unitSizeText(const qint64 size)
+{
+ if (size < 10000)
+ return QString::number(size) + QLatin1Char(' ') + ReadyForInstallationPage::tr("Bytes");
+
+ if (size < 1024 * 10000)
+ return QString::number(size / 1024) + QLatin1Char(' ') + ReadyForInstallationPage::tr("kBytes");
+
+ return QString::number(size / 1024 / 1024) + QLatin1Char(' ') + ReadyForInstallationPage::tr("MBytes");
+}
+
+ReadyForInstallationPage::ReadyForInstallationPage(Installer* installer)
+ : Page(installer)
+ , msgLabel(new QLabel)
{
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
- setObjectName( QLatin1String( "ReadyForInstallationPage" ) );
+ setObjectName(QLatin1String("ReadyForInstallationPage"));
- msgLabel->setWordWrap( true );
- msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ msgLabel->setWordWrap(true);
+ msgLabel->setObjectName(QLatin1String("MessageLabel"));
QLayout *layout = new QVBoxLayout(this);
layout->addWidget(msgLabel);
@@ -1356,154 +1313,140 @@ ReadyForInstallationPage::ReadyForInstallationPage( Installer* installer )
}
/*!
- \reimp
- */
-void ReadyForInstallationPage::initializePage()
+ \reimp
+*/
+void ReadyForInstallationPage::entering()
{
- setCommitPage( true );
-
- if( installer()->isUninstaller() )
- {
+ setCommitPage(true);
+ const QString target = installer()->value(QLatin1String("TargetDir"));
+
+ if (installer()->isUninstaller()) {
setTitle(tr("Ready to Uninstall"));
setButtonText(QWizard::CommitButton, tr("U&ninstall"));
- msgLabel->setText( tr( "Setup is now ready to begin removing %1 "
- "from your computer.\n"
- "The program dir %2 will be deleted completely, including "
- "all content in that directory!").arg( productName(),
- QDir::toNativeSeparators( QDir( installer()->value( QLatin1String( "TargetDir" ) ) ).absolutePath() ) ) );
- }
- else if( installer()->isPackageManager() )
- {
- setTitle( tr( "Ready to Update Packages" ) );
- setButtonText( QWizard::CommitButton, tr( "U&pdate" ) );
- msgLabel->setText( tr( "Setup is now ready to begin installing the additional components you selected." ) );
- }
- else
- {
+ msgLabel->setText(tr("Setup is now ready to begin removing %1 from your computer.\nThe "
+ "program dir %2 will be deleted completely, including all content in that directory!")
+ .arg(productName(), QDir::toNativeSeparators(QDir(target).absolutePath())));
+ return;
+ } else if (installer()->isPackageManager() || installer()->isUpdater()) {
+ setTitle(tr("Ready to Update Packages"));
+ setButtonText(QWizard::CommitButton, tr("U&pdate"));
+ msgLabel->setText(tr("Setup is now ready to begin updating your installation."));
+ } else {
Q_ASSERT(installer()->isInstaller());
setTitle(tr("Ready to Install"));
setButtonText(QWizard::CommitButton, tr("&Install"));
- msgLabel->setText(tr("Setup is now ready to begin installing %1 "
- "on your computer.").arg(productName()));
+ msgLabel->setText(tr("Setup is now ready to begin installing %1 on your computer.")
+ .arg(productName()));
}
- }
-
-
-/*!
- \reimp
- */
-void ReadyForInstallationPage::entering()
-{
- initializePage();
-
- if( installer()->isUninstaller() )
- return;
-
- const QString target = installer()->value( QLatin1String( "TargetDir" ) );
- const KDSysInfo::Volume vol = KDSysInfo::Volume::fromPath( target );
- const KDSysInfo::Volume tempVolume = KDSysInfo::Volume::fromPath( QInstaller::generateTemporaryFileName() );
+ const KDSysInfo::Volume vol = KDSysInfo::Volume::fromPath(target);
+ const KDSysInfo::Volume tempVolume =
+ KDSysInfo::Volume::fromPath(QInstaller::generateTemporaryFileName());
const bool tempOnSameVolume = vol == tempVolume;
- if ( vol.size().size() == 0 && vol.availableSpace().size() == 0 ) { //there is no better way atm to check this
- verbose() << "Could not determine available space on device " << target << ". Continue silently." << std::endl;
+ // there is no better way atm to check this
+ if (vol.size().size() == 0 && vol.availableSpace().size() == 0) {
+ verbose() << "Could not determine available space on device " << target
+ << ". Continue silently." << std::endl;
return;
}
- const KDByteSize required( installer()->requiredDiskSpace() );
- const KDByteSize tempRequired( installer()->requiredTemporaryDiskSpace() );
+ const KDByteSize required(installer()->requiredDiskSpace());
+ const KDByteSize tempRequired(installer()->requiredTemporaryDiskSpace());
const KDByteSize available = vol.availableSpace();
const KDByteSize tempAvailable = tempVolume.availableSpace();
- const KDByteSize realRequiredTempSpace = KDByteSize( 0.1 * tempRequired + tempRequired );
- const KDByteSize realRequiredSpace = KDByteSize( 2 * required );
+ const KDByteSize realRequiredTempSpace = KDByteSize(0.1 * tempRequired + tempRequired);
+ const KDByteSize realRequiredSpace = KDByteSize(2 * required);
- const bool tempInstFailure = tempOnSameVolume && available < realRequiredSpace + realRequiredTempSpace;
+ const bool tempInstFailure = tempOnSameVolume && available < realRequiredSpace
+ + realRequiredTempSpace;
- verbose() << "Disk space check on " << target << ": required=" << required.size() << " available=" << available.size() << " size=" << vol.size().size() << std::endl;
+ verbose() << "Disk space check on " << target << ": required=" << required.size()
+ << " available=" << available.size() << " size=" << vol.size().size() << std::endl;
QString tempString;
- if ( tempAvailable < realRequiredTempSpace || tempInstFailure )
- {
- if ( tempOnSameVolume )
- {
- tempString = tr( "Not enough diskspace to store temporary files and the installation, at least %1 are required" ).arg( unitSizeText(realRequiredTempSpace + realRequiredSpace) );
- }
- else
- {
- tempString = tr( "Not enough diskspace to store temporary files, at least %1 are required" ).arg( unitSizeText(realRequiredTempSpace.size()) );
+ if (tempAvailable < realRequiredTempSpace || tempInstFailure) {
+ if (tempOnSameVolume) {
+ tempString = tr("Not enough disk space to store temporary files and the installation, "
+ "at least %1 are required").arg(unitSizeText(realRequiredTempSpace + realRequiredSpace));
+ } else {
+ tempString = tr("Not enough disk space to store temporary files, at least %1 are required")
+ .arg(unitSizeText(realRequiredTempSpace.size()));
}
}
// error on not enough space
- if( available < required || tempInstFailure )
- {
- if ( tempOnSameVolume )
- msgLabel->setText( tempString );
- else
- msgLabel->setText( tr( "The volume you selected for installation has insufficient space for the selected components.\n\n"
- "The installation requires approximately %1." ).arg( required.toString() ) + tempString );
- setCommitPage( false );
- }
- // warn for less than 1% of the volume's space being free
- else if( available - required < 0.01 * vol.size() )
- {
- msgLabel->setText( tr( "The volume you selected for installation seems to have sufficient space for installation,\n"
- "but there will be less than 1% of the volume's space available afterwards.\n\n%1" ).arg( msgLabel->text() ) );
- }
- // warn for less than 100MB being free
- else if( available - required < 100*1024*1024LL )
- {
- msgLabel->setText( tr( "The volume you selected for installation seems to have sufficient space for installation,\n"
- "but there will be less than 100 MB available afterwards.\n\n%1" ).arg( msgLabel->text() ) );
+ if (available < required || tempInstFailure) {
+ if (tempOnSameVolume) {
+ msgLabel->setText(tempString);
+ } else {
+ msgLabel->setText(tr("The volume you selected for installation has insufficient space "
+ "for the selected components.\n\nThe installation requires approximately %1.")
+ .arg(required.toString()) + tempString);
+ }
+ setCommitPage(false);
+ } else if (available - required < 0.01 * vol.size()) {
+ // warn for less than 1% of the volume's space being free
+ msgLabel->setText(tr("The volume you selected for installation seems to have sufficient space for "
+ "installation,\nbut there will be less than 1% of the volume's space available afterwards.\n\n%1")
+ .arg(msgLabel->text()));
+ } else if (available - required < 100*1024*1024LL) {
+ // warn for less than 100MB being free
+ msgLabel->setText(tr("The volume you selected for installation seems to have sufficient space for "
+ "installation,\nbut there will be less than 100 MB available afterwards.\n\n%1")
+ .arg(msgLabel->text()));
}
}
+void ReadyForInstallationPage::leaving()
+{
+ setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::CommitButton));
+}
+
/*!
- \reimp
- */
+ \reimp
+*/
bool ReadyForInstallationPage::isComplete() const
{
return isCommitPage();
}
+
+// -- PerformInstallationPage
+
/*!
- \class QInstaller::PerformInstallationPage
- On this page the user can see on a progressbar how far the current installation is.
- */
+ \class QInstaller::PerformInstallationPage
+ On this page the user can see on a progress bar how far the current installation is.
+*/
PerformInstallationPage::PerformInstallationPage(Installer *gui)
- : Page(gui),
- m_performInstallationForm(new PerformInstallationForm(this))
+ : Page(gui)
+ , m_performInstallationForm(new PerformInstallationForm(this))
{
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
- setObjectName( QLatin1String( "PerformInstallationPage" ) );
- setCommitPage(true);
+ setObjectName(QLatin1String("PerformInstallationPage"));
m_performInstallationForm->setupUi(this);
- m_performInstallationForm->setDetailsWidgetVisible( installer()->isInstaller() || installer()->isPackageManager() );
- connect(ProgressCoordninator::instance(), SIGNAL( detailTextChanged( QString ) ),
- m_performInstallationForm, SLOT( appendProgressDetails( QString ) ) );
+ m_performInstallationForm->setDetailsWidgetVisible(installer()->isInstaller()
+ || installer()->isPackageManager() || installer()->isUpdater());
+ connect(ProgressCoordninator::instance(), SIGNAL(detailTextChanged(QString)),
+ m_performInstallationForm, SLOT(appendProgressDetails(QString)));
connect(ProgressCoordninator::instance(), SIGNAL(detailTextResetNeeded()),
- m_performInstallationForm, SLOT(clearDetailsBrowser()));
+ m_performInstallationForm, SLOT(clearDetailsBrowser()));
- connect(m_performInstallationForm, SIGNAL(showDetailsChanged()),
- this, SLOT(toggleDetailsWereChanged()));
+ connect(m_performInstallationForm, SIGNAL(showDetailsChanged()), this,
+ SLOT(toggleDetailsWereChanged()));
- connect(installer(), SIGNAL(installationStarted()),
- this, SLOT(installationStarted()));
- connect(installer(), SIGNAL(uninstallationStarted()),
- this, SLOT(installationStarted()));
- connect(installer(), SIGNAL(installationFinished()),
- this, SLOT(installationFinished()));
- connect(installer(), SIGNAL(uninstallationFinished()),
- this, SLOT(installationFinished()));
- connect( installer(), SIGNAL( titleMessageChanged( QString ) ),
- this, SLOT( setTitleMessage( QString ) ) );
- connect( this, SIGNAL( setAutomatedPageSwitchEnabled( bool ) ),
- installer(), SIGNAL( setAutomatedPageSwitchEnabled( bool ) ) );
+ connect(installer(), SIGNAL(installationStarted()), this, SLOT(installationStarted()));
+ connect(installer(), SIGNAL(uninstallationStarted()), this, SLOT(installationStarted()));
+ connect(installer(), SIGNAL(installationFinished()), this, SLOT(installationFinished()));
+ connect(installer(), SIGNAL(uninstallationFinished()), this, SLOT(installationFinished()));
+ connect(installer(), SIGNAL(titleMessageChanged(QString)), this, SLOT(setTitleMessage(QString)));
+ connect(this, SIGNAL(setAutomatedPageSwitchEnabled(bool)), installer(),
+ SIGNAL(setAutomatedPageSwitchEnabled(bool)));
}
PerformInstallationPage::~PerformInstallationPage()
@@ -1511,59 +1454,56 @@ PerformInstallationPage::~PerformInstallationPage()
delete m_performInstallationForm;
}
+bool PerformInstallationPage::isAutoSwitching() const
+{
+ return !m_performInstallationForm->isShowingDetails();
+}
+
+// -- protected
+
void PerformInstallationPage::entering()
{
setComplete(false);
+ setCommitPage(true);
- if( installer()->isUninstaller() )
- {
- setTitle(tr("Uninstalling %1").arg(installer()->value( QLatin1String( "ProductName" ) )));
- setButtonText(QWizard::CommitButton, tr("U&ninstall"));
- }
- else if( installer()->isPackageManager() )
- {
- setTitle( tr( "Updating component configuration of %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
- setButtonText( QWizard::CommitButton, tr( "U&pdate" ) );
- }
- else
- {
- Q_ASSERT(installer()->isInstaller());
- setTitle(tr("Installing %1").arg(installer()->value( QLatin1String( "ProductName" ) )));
- setButtonText(QWizard::CommitButton, tr("&Install"));
+ if (installer()->isUninstaller()) {
+ m_commitBtnText = tr("&Uninstall");
+ setButtonText(QWizard::CommitButton, m_commitBtnText);
+ setTitle(tr("Uninstalling %1").arg(installer()->value(QLatin1String("ProductName"))));
+
+ QTimer::singleShot(30, installer(), SLOT(runUninstaller()));
+ } else if (installer()->isPackageManager() || installer()->isUpdater()) {
+ m_commitBtnText = tr ("&Update");
+ setButtonText(QWizard::CommitButton, m_commitBtnText);
+ setTitle(tr("Updating components of %1").arg(installer()->value(QLatin1String("ProductName"))));
+
+ QTimer::singleShot(30, installer(), SLOT(runPackageUpdater()));
+ } else {
+ m_commitBtnText = tr("&Install");
+ setButtonText(QWizard::CommitButton, m_commitBtnText);
+ setTitle(tr("Installing %1").arg(installer()->value(QLatin1String("ProductName"))));
+
+ QTimer::singleShot(30, installer(), SLOT(runInstaller()));
}
+
m_performInstallationForm->enableDetails();
- emit setAutomatedPageSwitchEnabled( true );
+ emit setAutomatedPageSwitchEnabled(true);
}
-void PerformInstallationPage::initializePage()
+void PerformInstallationPage::leaving()
{
- QWizardPage::initializePage();
- if( installer()->isUninstaller() )
- {
- wizard()->removePage( QInstaller::Installer::InstallationFinished + 1 );
- wizard()->removePage( QInstaller::Installer::InstallationFinished + 2 );
- setTitle( tr( "Uninstalling %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
- m_commitBtnText = tr( "U&ninstall" );
- setButtonText( QWizard::CommitButton, m_commitBtnText );
- QTimer::singleShot( 30, installer(), SLOT( runUninstaller() ) );
- }
- else if( installer()->isPackageManager() )
- {
- setTitle(tr("Updating components of %1").arg( installer()->value( QLatin1String( "ProductName" ) )));
- m_commitBtnText = tr ( "U&pdate" );
- setButtonText( QWizard::CommitButton, m_commitBtnText );
- QTimer::singleShot( 30, installer(), SLOT( runPackageUpdater() ) );
- }
- else
- {
- Q_ASSERT( installer()->isInstaller() );
- setTitle( tr( "Installing %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
- m_commitBtnText = tr( "&Install" );
- setButtonText( QWizard::CommitButton, m_commitBtnText );
- QTimer::singleShot( 30, installer(), SLOT( runInstaller() ) );
- }
+ setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::CommitButton));
+}
+
+// -- public slots
+
+void PerformInstallationPage::setTitleMessage(const QString& title)
+{
+ setTitle(title);
}
+// -- private slots
+
void PerformInstallationPage::installationStarted()
{
m_performInstallationForm->startUpdateProgress();
@@ -1572,58 +1512,46 @@ void PerformInstallationPage::installationStarted()
void PerformInstallationPage::installationFinished()
{
m_performInstallationForm->stopUpdateProgress();
- if (!isAutoSwitching()){
+ if (!isAutoSwitching()) {
m_performInstallationForm->scrollDetailsToTheEnd();
- m_performInstallationForm->setDetailsButtonEnabled( false );
- setButtonText( QWizard::NextButton, tr( "&Next" ) );
- setButtonText( QWizard::CommitButton, tr( "&Next" ) );
- setComplete( true );
- }
-}
+ m_performInstallationForm->setDetailsButtonEnabled(false);
-bool PerformInstallationPage::isAutoSwitching() const
-{
- return !m_performInstallationForm->isShowingDetails();
+ setComplete(true);
+ setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::NextButton));
+ }
}
void PerformInstallationPage::toggleDetailsWereChanged()
{
const bool needAutoSwitching = isAutoSwitching();
- setButtonText( QWizard::CommitButton, needAutoSwitching ? m_commitBtnText : tr( "&Next" ) );
- emit setAutomatedPageSwitchEnabled( needAutoSwitching );
+ setButtonText(QWizard::CommitButton, needAutoSwitching ? m_commitBtnText
+ : gui()->defaultButtonText(QWizard::NextButton));
+ emit setAutomatedPageSwitchEnabled(needAutoSwitching);
}
-void PerformInstallationPage::setTitleMessage( const QString& title )
-{
- setTitle( title );
-}
-////////////////////////////////////////////////////////////////////
-//
-// FinishedPage
-//
-////////////////////////////////////////////////////////////////////
+// -- FinishedPage
FinishedPage::FinishedPage(Installer *installer)
: Page(installer)
{
- //setCommitPage( true );
- setObjectName( QLatin1String( "FinishedPage" ) );
- setTitle(tr("Completing the %1 Setup Wizard").arg(productName()));
+ setObjectName(QLatin1String("FinishedPage"));
+ setTitle(tr("Completing the %1 Wizard").arg(productName()));
setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
setSubTitle(QString());
m_msgLabel = new QLabel(this);
- m_msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
m_msgLabel->setWordWrap(true);
+ m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
+
#ifdef Q_WS_MAC
- m_msgLabel->setText(tr("Click Done to exit the Setup Wizard"));
+ m_msgLabel->setText(tr("Click Done to exit the %1 Wizard.").arg(productName()));
#else
- m_msgLabel->setText(tr("Click Finish to exit the Setup Wizard"));
+ m_msgLabel->setText(tr("Click Finish to exit the %1 Wizard.").arg(productName()));
#endif
m_runItCheckBox = new QCheckBox(this);
- m_runItCheckBox->setObjectName( QLatin1String( "RunItCheckBox" ) );
+ m_runItCheckBox->setObjectName(QLatin1String("RunItCheckBox"));
m_runItCheckBox->setChecked(true);
QVBoxLayout *layout = new QVBoxLayout(this);
@@ -1634,105 +1562,95 @@ FinishedPage::FinishedPage(Installer *installer)
void FinishedPage::entering()
{
- if ( wizard()->button( QWizard::BackButton ) )
- wizard()->button( QWizard::BackButton )->setVisible( false );
- if ( installer()->isPackageManager() )
- {
- setButtonText( QWizard::CommitButton, QLatin1String( "&Finish" ) );
- wizard()->button( QWizard::CommitButton )->disconnect( this );
- connect( wizard()->button( QWizard::CommitButton ), SIGNAL( clicked() ),
- this, SLOT( handleFinishClicked() ) );
- Gui* par = dynamic_cast< Gui* > ( wizard() );
- if ( par )
- {
- connect( this, SIGNAL( finishClicked() ), par, SIGNAL( finishButtonClicked() ) );
- }
- }
verbose() << "FINISHED ENTERING: " << std::endl;
- connect( wizard()->button( QWizard::FinishButton ), SIGNAL( clicked() ),
- this, SLOT( handleFinishClicked() ) );
- wizard()->setOption(QWizard::NoCancelButton, true);
- if (installer()->status() == Installer::InstallerSucceeded) {
+ setCommitPage(true);
+ if (installer()->isUpdater() || installer()->isPackageManager()) {
+#ifdef Q_WS_MAC
+ wizard()->setOption(QWizard::NoCancelButton, false);
+#endif
+ gui()->button(QWizard::CancelButton)->setEnabled(true);
+ setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::NextButton));
+ setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::FinishButton));
+ } else {
+ wizard()->setOption(QWizard::NoCancelButton, true);
+ }
+
+ if (QAbstractButton *commit = wizard()->button(QWizard::CommitButton)) {
+ disconnect(commit, SIGNAL(clicked()), this, SLOT(handleFinishClicked()));
+ connect(commit, SIGNAL(clicked()), this, SLOT(handleFinishClicked()));
+ }
- const QString finishedtext = installer()->value( QLatin1String( "FinishedText" ) );
- if( ! finishedtext.isEmpty() )
- m_msgLabel->setText( finishedtext );
+ if (installer()->status() == Installer::Success) {
+ const QString finishedtext = installer()->value(QLatin1String("FinishedText"));
+ if (!finishedtext.isEmpty())
+ m_msgLabel->setText(finishedtext);
- if ( ! installer()->value( QLatin1String( "RunProgram" ) ).isEmpty() ) {
+ if (!installer()->value(QLatin1String("RunProgram")).isEmpty()) {
m_runItCheckBox->show();
- m_runItCheckBox->setText( installer()->value( QLatin1String( "RunProgramDescription" ), tr( "Run %1 now." ).arg( productName() ) ) );
+ m_runItCheckBox->setText(installer()->value(QLatin1String("RunProgramDescription"),
+ tr("Run %1 now.").arg(productName())));
return; // job done
}
-
} else {
- setTitle(tr("The %1 Setup Wizard failed").arg(productName()));
+ setTitle(tr("The %1 Wizard failed.").arg(productName()));
}
- m_runItCheckBox->hide();
- m_runItCheckBox->setChecked( false );
-}
-void FinishedPage::initializePage()
-{
- setCommitPage( true );
- if ( wizard()->button( QWizard::BackButton ) )
- wizard()->button( QWizard::BackButton )->setVisible( false );
- if ( installer()->isPackageManager() )
- {
- setButtonText( QWizard::CommitButton, QLatin1String( "&Finish" ) );
- setButtonText( QWizard::NextButton, QLatin1String( "&Finish" ) );
- }
+ m_runItCheckBox->hide();
+ m_runItCheckBox->setChecked(false);
}
void FinishedPage::leaving()
{
- disconnect( wizard(), SIGNAL( customButtonClicked( int ) ),
- this, SLOT( handleFinishClicked() ) );
- if ( installer()->isPackageManager() )
- {
- disconnect( wizard()->button( QWizard::CommitButton ), SIGNAL( clicked() ),
- this, SLOT( handleFinishClicked() ) );
- Gui* par = dynamic_cast< Gui* > ( wizard() );
- if ( par )
- {
- disconnect( this, SIGNAL( finishClicked() ), par, SIGNAL( finishButtonClicked() ) );
- }
- }
+#ifdef Q_WS_MAC
+ wizard()->setOption(QWizard::NoCancelButton, true);
+#endif
+
+ setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::CommitButton));
+ setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton));
+
+ if (QAbstractButton *commit = wizard()->button(QWizard::CommitButton))
+ disconnect(commit, SIGNAL(clicked()), this, SLOT(handleFinishClicked()));
+ disconnect(wizard(), SIGNAL(customButtonClicked(int)), this, SLOT(handleFinishClicked()));
}
void FinishedPage::handleFinishClicked()
{
- QString program = installer()->value( QLatin1String( "RunProgram" ) );
- if ( !m_runItCheckBox->isChecked() || program.isEmpty() )
+ QString program = installer()->value(QLatin1String("RunProgram"));
+ if (!m_runItCheckBox->isChecked() || program.isEmpty())
return;
- program = installer()->replaceVariables( program );
+ program = installer()->replaceVariables(program);
verbose() << "STARTING " << program << std::endl;
- QProcess::startDetached( program );
+ QProcess::startDetached(program);
}
-////////////////////////////////////////////////////////////////////
-//
-// RestartPage
-//
-////////////////////////////////////////////////////////////////////
+
+// -- RestartPage
RestartPage::RestartPage(Installer *installer)
: Page(installer)
{
- setObjectName( QLatin1String( "RestartPage" ) );
- setTitle(tr("Completing the %1 Setup Wizard").arg( productName() ) );
+ setObjectName(QLatin1String("RestartPage"));
+ setTitle(tr("Completing the %1 Setup Wizard").arg(productName()));
setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle( QString() );
- setFinalPage( false );
+ setSubTitle(QString());
+
+ setFinalPage(false);
+ setCommitPage(false);
+}
+
+int RestartPage::nextId() const
+{
+ return Installer::Introduction;
}
void RestartPage::entering()
{
- emit restart();
+ if (QAbstractButton *finish = wizard()->button(QWizard::FinishButton))
+ finish->setVisible(false);
+
wizard()->restart();
- if ( wizard()->button( QWizard::FinishButton ) )
- wizard()->button( QWizard::FinishButton )->setVisible( false );
- wizard()->setOption(QWizard::NoCancelButton, false);
+ emit restart();
}
void RestartPage::leaving()
diff --git a/installerbuilder/libinstaller/qinstallergui.h b/installerbuilder/libinstaller/qinstallergui.h
index 4e602ebcc..ee9e3dfa8 100644
--- a/installerbuilder/libinstaller/qinstallergui.h
+++ b/installerbuilder/libinstaller/qinstallergui.h
@@ -26,18 +26,17 @@
#ifndef QINSTALLER_GUI_H
#define QINSTALLER_GUI_H
-#include <QtGui/QWizard>
-#include <QtCore/QMetaType>
+#include "qinstaller.h"
+#include "messageboxhandler.h"
#include <QtCore/QEvent>
-#include <QtGui/QAbstractButton>
-
-#include <KDToolsCore/pimpl_ptr>
+#include <QtCore/QMetaType>
-#include "qinstaller.h"
-#include "messageboxhandler.h"
+#include <QtGui/QAbstractButton>
+#include <QtGui/QWizard>
// FIXME: move to private classes
+QT_BEGIN_NAMESPACE
class QCheckBox;
class QLabel;
class QLineEdit;
@@ -48,31 +47,56 @@ class QRadioButton;
class QTextBrowser;
class QTreeView;
class QScriptEngine;
+QT_END_NAMESPACE
namespace QInstaller {
class Installer;
-class Page;
class IntroductionPage;
+class Page;
class PerformInstallationForm;
-class INSTALLER_EXPORT MessageBoxHandlerImpl : public MessageBoxHandler {
+
+// -- MessageBoxHandlerImpl
+
+class INSTALLER_EXPORT MessageBoxHandlerImpl : public MessageBoxHandler
+{
public:
- explicit MessageBoxHandlerImpl( QWidget* parentWidget );
- void setAutomaticAnswer( const QString& identifier, QMessageBox::StandardButton answer );
- void setDefaultAction( DefaultAction da );
-
- QMessageBox::StandardButton critical( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton information( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton question( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Yes|QMessageBox::No, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton warning( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton critical( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton information( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton question( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Yes|QMessageBox::No, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
- QMessageBox::StandardButton warning( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ explicit MessageBoxHandlerImpl(QWidget* parentWidget);
+ void setAutomaticAnswer(const QString& identifier, QMessageBox::StandardButton answer);
+ void setDefaultAction(DefaultAction da);
+
+ QMessageBox::StandardButton critical(const QString& identifier, const QString& title,
+ const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton information(const QString& identifier, const QString& title,
+ const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton question(const QString& identifier, const QString& title,
+ const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton warning(const QString& identifier, const QString& title,
+ const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton critical(QWidget* parent, const QString& identifier,
+ const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton information(QWidget* parent, const QString& identifier,
+ const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton question(QWidget* parent, const QString& identifier,
+ const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton warning(QWidget* parent, const QString& identifier,
+ const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
private:
- QMessageBox::StandardButton autoReply( QMessageBox::StandardButtons buttons ) const;
+ QMessageBox::StandardButton autoReply(QMessageBox::StandardButtons buttons) const;
private:
QList<QMessageBox::Button> m_buttonOrder;
@@ -81,6 +105,9 @@ private:
QHash<QString,QMessageBox::StandardButton> m_automaticAnswers;
};
+
+// -- Gui
+
class INSTALLER_EXPORT Gui : public QWizard
{
Q_OBJECT
@@ -89,17 +116,18 @@ public:
explicit Gui(Installer *installer, QWidget *parent = 0);
~Gui();
virtual void init() = 0;
- IntroductionPage* introductionPage() const;
- void loadControlScript( const QString& scriptPath );
- void callControlScriptMethod( const QString& methodName );
+ void loadControlScript(const QString& scriptPath);
+ void callControlScriptMethod(const QString& methodName);
void triggerControlScriptForCurrentPage();
QScriptEngine* controlScriptEngine() const;
- Q_INVOKABLE QWidget* pageWidgetByObjectName( const QString& name ) const;
+ Q_INVOKABLE Page* page(int pageId) const;
+ Q_INVOKABLE QWidget* pageWidgetByObjectName(const QString& name) const;
Q_INVOKABLE QWidget* currentPageWidget() const;
- Q_INVOKABLE void clickButton( int wizardButton, int delayInMs=0 );
+ Q_INVOKABLE QString defaultButtonText(int wizardButton) const;
+ Q_INVOKABLE void clickButton(int wizardButton, int delayInMs = 0);
Q_SIGNALS:
void interrupted();
@@ -107,37 +135,39 @@ Q_SIGNALS:
void finishButtonClicked();
void gotRestarted();
-public slots:
+public Q_SLOTS:
void cancelButtonClicked();
void reject();
void rejectWithoutPrompt();
void showFinishedPage();
- void setModified( bool value );
+ void setModified(bool value);
protected Q_SLOTS:
- void wizardPageInsertionRequested( QWidget* widget, Installer::WizardPage page );
- void wizardPageRemovalRequested( QWidget* widget );
- void wizardWidgetInsertionRequested( QWidget* widget, Installer::WizardPage page );
- void wizardWidgetRemovalRequested( QWidget* widget );
- void wizardPageVisibilityChangeRequested( bool visible, int page );
- void slotCurrentPageChanged( int id );
- void delayedControlScriptExecution( int id );
+ void wizardPageInsertionRequested(QWidget* widget, Installer::WizardPage page);
+ void wizardPageRemovalRequested(QWidget* widget);
+ void wizardWidgetInsertionRequested(QWidget* widget, Installer::WizardPage page);
+ void wizardWidgetRemovalRequested(QWidget* widget);
+ void wizardPageVisibilityChangeRequested(bool visible, int page);
+ void slotCurrentPageChanged(int id);
+ void delayedControlScriptExecution(int id);
- void setAutomatedPageSwitchEnabled( bool request );
+ void setAutomatedPageSwitchEnabled(bool request);
+
+private Q_SLOTS:
+ void onLanguageChanged();
protected:
- bool event( QEvent* event );
+ bool event(QEvent* event);
Installer *m_installer;
-
private:
class Private;
Private* const d;
- QInstaller::IntroductionPage *m_introPage;
- QMap< int, QWizardPage* > defaultPages;
};
+// -- Page
+
class INSTALLER_EXPORT Page : public QWizardPage
{
Q_OBJECT
@@ -153,13 +183,14 @@ public:
virtual bool isComplete() const;
void setComplete(bool complete);
+ Gui* gui() const { return qobject_cast<Gui*>(wizard()); }
+
protected:
Installer *installer() const;
// Inserts widget into the same layout like a sibling identified
// by its name. Default position is just behind the sibling.
- virtual void insertWidget(QWidget *widget, const QString &siblingName,
- int offset = 1);
+ virtual void insertWidget(QWidget *widget, const QString &siblingName, int offset = 1);
virtual QWidget *findWidget(const QString &objectName) const;
virtual void setVisible(bool visible); // reimp
@@ -168,8 +199,6 @@ protected:
virtual void entering() {} // called on entering
virtual void leaving() {} // called on leaving
- virtual void forward() const {} // called when going forwards
- //virtual void backward() const {} // called when going back
bool isConstructing() const { return m_fresh; }
private:
@@ -179,26 +208,33 @@ private:
};
+// -- IntroductionPage
+
class INSTALLER_EXPORT IntroductionPage : public Page
{
Q_OBJECT
+
public:
explicit IntroductionPage(Installer *installer);
void setText(const QString &text);
void setWidget(QWidget *w);
+
private:
QLabel *m_msgLabel;
QWidget *m_widget;
};
+// -- LicenseAgreementPage
+
class INSTALLER_EXPORT LicenseAgreementPage : public Page
{
Q_OBJECT
public:
explicit LicenseAgreementPage(Installer *installer);
- void initializePage();
+
+ void entering();
bool isComplete() const;
private Q_SLOTS:
@@ -217,6 +253,8 @@ private:
};
+// -- ComponentSelectionPage
+
class INSTALLER_EXPORT ComponentSelectionPage : public Page
{
Q_OBJECT
@@ -224,23 +262,29 @@ class INSTALLER_EXPORT ComponentSelectionPage : public Page
public:
explicit ComponentSelectionPage(Installer *installer);
~ComponentSelectionPage();
+
bool isComplete() const;
- Q_INVOKABLE void selectComponent( const QString& id );
- Q_INVOKABLE void deselectComponent( const QString& id );
+ Q_INVOKABLE void selectAll();
+ Q_INVOKABLE void deselectAll();
+ Q_INVOKABLE void selectDefault();
+ Q_INVOKABLE void selectComponent(const QString& id);
+ Q_INVOKABLE void deselectComponent(const QString& id);
protected:
- void showEvent( QShowEvent* event );
void entering();
+
private Q_SLOTS:
- void setModified( bool value );
- void modelWasReseted();
+ void setModified(bool modified);
private:
class Private;
- kdtools::pimpl_ptr< Private > d;
+ Private *d;
};
+
+// -- TargetDirectoryPage
+
class INSTALLER_EXPORT TargetDirectoryPage : public Page
{
Q_OBJECT
@@ -266,6 +310,8 @@ private:
};
+// -- StartMenuDirectoryPage
+
class INSTALLER_EXPORT StartMenuDirectoryPage : public Page
{
Q_OBJECT
@@ -284,26 +330,33 @@ private Q_SLOTS:
private:
QString startMenuPath;
- QLineEdit *m_lineEdit;
+ QLineEdit *m_lineEdit;
QListWidget *m_listWidget;
};
+// -- ReadyForInstallationPage
+
class INSTALLER_EXPORT ReadyForInstallationPage : public Page
{
Q_OBJECT
public:
explicit ReadyForInstallationPage(Installer *installer);
- void initializePage();
- void entering();
+
bool isComplete() const;
+protected:
+ void entering();
+ void leaving();
+
private:
QLabel* const msgLabel;
};
+// -- PerformInstallationPage
+
class INSTALLER_EXPORT PerformInstallationPage : public Page
{
Q_OBJECT
@@ -315,15 +368,15 @@ public:
protected:
void entering();
- void initializePage();
+ void leaving();
bool isInterruptible() const { return true; }
public Q_SLOTS:
- void setTitleMessage( const QString& title );
+ void setTitleMessage(const QString& title);
Q_SIGNALS:
void installationRequested();
- void setAutomatedPageSwitchEnabled( bool request );
+ void setAutomatedPageSwitchEnabled(bool request);
private Q_SLOTS:
void installationStarted();
@@ -335,6 +388,9 @@ private:
PerformInstallationForm *m_performInstallationForm;
};
+
+// -- FinishedPage
+
class INSTALLER_EXPORT FinishedPage : public Page
{
Q_OBJECT
@@ -342,14 +398,10 @@ class INSTALLER_EXPORT FinishedPage : public Page
public:
explicit FinishedPage(Installer *installer);
-Q_SIGNALS:
- void finishClicked();
-
public Q_SLOTS:
void handleFinishClicked();
protected:
- void initializePage();
void entering();
void leaving();
@@ -358,6 +410,9 @@ private:
QCheckBox *m_runItCheckBox;
};
+
+// -- RestartPage
+
class INSTALLER_EXPORT RestartPage : public Page
{
Q_OBJECT
@@ -365,9 +420,12 @@ class INSTALLER_EXPORT RestartPage : public Page
public:
explicit RestartPage(Installer *installer);
+ virtual int nextId() const;
+
protected:
void entering();
void leaving();
+
Q_SIGNALS:
void restart();
};
@@ -378,7 +436,9 @@ class ClickForwarder : public QObject
{
Q_OBJECT
public:
- explicit ClickForwarder(QAbstractButton* button) : m_abstractButton(button) {}
+ explicit ClickForwarder(QAbstractButton* button)
+ : QObject(button)
+ , m_abstractButton(button) {}
protected:
bool eventFilter(QObject *object, QEvent *event)
diff --git a/installerbuilder/libinstaller/qprocesswrapper.cpp b/installerbuilder/libinstaller/qprocesswrapper.cpp
new file mode 100644
index 000000000..70886d71b
--- /dev/null
+++ b/installerbuilder/libinstaller/qprocesswrapper.cpp
@@ -0,0 +1,424 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qprocesswrapper.h"
+
+#include "fsengineclient.h"
+#include "templates.cpp"
+
+#include <KDToolsCore/KDMetaMethodIterator>
+
+#include <QtCore/QThread>
+
+#include <QtNetwork/QTcpSocket>
+
+// -- QProcessWrapper::Private
+
+class QProcessWrapper::Private
+{
+public:
+ Private(QProcessWrapper *qq)
+ : q(qq),
+ ignoreTimer(false),
+ socket(0) { }
+
+ bool createSocket()
+ {
+ if (!FSEngineClientHandler::instance()->isActive())
+ return false;
+ if (socket != 0 && socket->state() == static_cast< int >(QAbstractSocket::ConnectedState))
+ return true;
+ if (socket != 0)
+ delete socket;
+ socket = new QTcpSocket;
+
+ if (!FSEngineClientHandler::instance()->connect(socket))
+ return false;
+ stream.setDevice(socket);
+ stream.setVersion(QDataStream::Qt_4_2);
+
+ stream << QString::fromLatin1("createQProcess");
+ socket->flush();
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+
+ q->startTimer(250);
+
+ return true;
+ }
+
+ class TimerBlocker
+ {
+ public:
+ explicit TimerBlocker(const QProcessWrapper *wrapper)
+ : w(const_cast< QProcessWrapper*> (wrapper))
+ {
+ w->d->ignoreTimer = true;
+ }
+
+ ~TimerBlocker()
+ {
+ w->d->ignoreTimer = false;
+ }
+
+ private:
+ QProcessWrapper *const w;
+ };
+
+private:
+ QProcessWrapper *const q;
+
+public:
+ bool ignoreTimer;
+
+ QProcess process;
+ mutable QTcpSocket *socket;
+ mutable QDataStream stream;
+};
+
+
+// -- QProcessWrapper
+
+QProcessWrapper::QProcessWrapper(QObject *parent)
+ : QObject(parent),
+ d(new Private(this))
+{
+ qDebug() << Q_FUNC_INFO;
+ KDMetaMethodIterator it(QProcess::staticMetaObject, KDMetaMethodIterator::Signal,
+ KDMetaMethodIterator::IgnoreQObjectMethods);
+ while (it.hasNext()) {
+ it.next();
+ connect(&d->process, it.connectableSignature(), this, it.connectableSignature());
+ }
+}
+
+QProcessWrapper::~QProcessWrapper()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->socket != 0) {
+ d->stream << QString::fromLatin1("destroyQProcess");
+ d->socket->flush();
+ quint32 result;
+ d->stream >> result;
+
+ if (QThread::currentThread() == d->socket->thread()) {
+ d->socket->close();
+ delete d->socket;
+ } else {
+ d->socket->deleteLater();
+ }
+ }
+ delete d;
+}
+
+void QProcessWrapper::timerEvent(QTimerEvent *event)
+{
+ Q_UNUSED(event)
+ qDebug() << Q_FUNC_INFO;
+
+ if (d->ignoreTimer)
+ return;
+
+ QList<QVariant> receivedSignals;
+ {
+ const Private::TimerBlocker blocker(this);
+
+ d->stream << QString::fromLatin1("getQProcessSignals");
+ d->socket->flush();
+ d->stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ d->stream >> test;
+ d->stream >> receivedSignals;
+ d->stream.device()->readAll();
+ }
+
+ while (!receivedSignals.isEmpty()) {
+ const QString name = receivedSignals.takeFirst().toString();
+ if (name == QLatin1String("started")) {
+ emit started();
+ } else if (name == QLatin1String("readyRead")) {
+ emit readyRead();
+ } else if (name == QLatin1String("stateChanged")) {
+ const QProcess::ProcessState newState =
+ static_cast<QProcess::ProcessState> (receivedSignals.takeFirst().toInt());
+ emit stateChanged(newState);
+ } else if (name == QLatin1String("finished")) {
+ const int exitCode = receivedSignals.takeFirst().toInt();
+ const QProcess::ExitStatus exitStatus =
+ static_cast<QProcess::ExitStatus> (receivedSignals.takeFirst().toInt());
+ emit finished(exitCode);
+ emit finished(exitCode, exitStatus);
+ }
+ }
+}
+
+bool startDetached(const QString &program, const QStringList &args, const QString &workingDirectory,
+ qint64 *pid);
+
+bool QProcessWrapper::startDetached(const QString &program, const QStringList &arguments,
+ const QString &workingDirectory, qint64 *pid)
+{
+ qDebug() << Q_FUNC_INFO;
+ QProcessWrapper w;
+ if (w.d->createSocket()) {
+ const QPair<bool, qint64> result = callRemoteMethod<QPair<bool, qint64> >(w.d->stream,
+ QLatin1String("QProcess::startDetached"), program, arguments, workingDirectory);
+ if (pid != 0)
+ *pid = result.second;
+ return result.first;
+ }
+ return ::startDetached(program, arguments, workingDirectory, pid);
+}
+
+bool QProcessWrapper::startDetached(const QString &program, const QStringList &arguments)
+{
+ qDebug() << Q_FUNC_INFO;
+ return startDetached(program, arguments, QDir::currentPath());
+}
+
+bool QProcessWrapper::startDetached(const QString &program)
+{
+ qDebug() << Q_FUNC_INFO;
+ return startDetached(program, QStringList());
+}
+
+void QProcessWrapper::setProcessChannelMode(QProcessWrapper::ProcessChannelMode mode)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket()) {
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::setProcessChannelMode"),
+ static_cast<QProcess::ProcessChannelMode>(mode));
+ } else {
+ d->process.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(mode));
+ }
+}
+
+/*!
+ Cancels the process. This methods tries to terminate the process
+ gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
+ */
+void QProcessWrapper::cancel()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (state() == QProcessWrapper::Running)
+ terminate();
+
+ if (!waitForFinished(10000))
+ kill();
+}
+
+void QProcessWrapper::setReadChannel(QProcessWrapper::ProcessChannel chan)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket()) {
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::setReadChannel"),
+ static_cast<QProcess::ProcessChannel>(chan));
+ } else {
+ d->process.setReadChannel(static_cast<QProcess::ProcessChannel>(chan));
+ }
+}
+
+bool QProcessWrapper::waitForFinished(int msecs)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<bool>(d->stream, QLatin1String("QProcess::waitForFinished"), msecs);
+ return d->process.waitForFinished(msecs);
+}
+
+bool QProcessWrapper::waitForStarted(int msecs)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<bool>(d->stream, QLatin1String("QProcess::waitForStarted"), msecs);
+ return d->process.waitForStarted(msecs);
+}
+
+qint64 QProcessWrapper::write(const QByteArray &data)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<qint64>(d->stream, QLatin1String("QProcess::write"), data);
+ return d->process.write(data);
+}
+
+void QProcessWrapper::closeWriteChannel()
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QProcess::closeWriteChannel"));
+ else
+ d->process.closeWriteChannel();
+};
+
+int QProcessWrapper::exitCode() const
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<int>(d->stream, QLatin1String("QProcess::exitCode"));
+ return static_cast< int>(d->process.exitCode());
+};
+
+QProcessWrapper::ExitStatus QProcessWrapper::exitStatus() const
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<QProcessWrapper::ExitStatus>(d->stream, QLatin1String("QProcess::exitStatus"));
+ return static_cast< QProcessWrapper::ExitStatus>(d->process.exitStatus());
+};
+
+void QProcessWrapper::kill()
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QProcess::kill"));
+ else
+ d->process.kill();
+}
+
+QByteArray QProcessWrapper::readAll()
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<QByteArray>(d->stream, QLatin1String("QProcess::readAll"));
+ return d->process.readAll();
+};
+
+QByteArray QProcessWrapper::readAllStandardOutput()
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<QByteArray>(d->stream, QLatin1String("QProcess::readAllStandardOutput"));
+ return d->process.readAllStandardOutput();
+};
+
+void QProcessWrapper::start(const QString& param1, const QStringList& param2, QIODevice::OpenMode param3)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::start"), param1, param2, param3);
+ else
+ d->process.start(param1, param2, param3);
+}
+
+void QProcessWrapper::start(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::start"), param1);
+ else
+ d->process.start(param1);
+}
+
+QProcessWrapper::ProcessState QProcessWrapper::state() const
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<QProcessWrapper::ProcessState>(d->stream, QLatin1String("QProcess::state"));
+ return static_cast< QProcessWrapper::ProcessState>(d->process.state());
+}
+
+void QProcessWrapper::terminate()
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QProcess::terminate"));
+ else
+ d->process.terminate();
+}
+
+QProcessWrapper::ProcessChannel QProcessWrapper::readChannel() const
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket()) {
+ return callRemoteMethod<QProcessWrapper::ProcessChannel>(d->stream,
+ QLatin1String("QProcess::readChannel"));
+ }
+ return static_cast< QProcessWrapper::ProcessChannel>(d->process.readChannel());
+}
+
+QProcessWrapper::ProcessChannelMode QProcessWrapper::processChannelMode() const
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket()) {
+ return callRemoteMethod<QProcessWrapper::ProcessChannelMode>(d->stream,
+ QLatin1String("QProcess::processChannelMode"));
+ }
+ return static_cast< QProcessWrapper::ProcessChannelMode>(d->process.processChannelMode());
+}
+
+QString QProcessWrapper::workingDirectory() const
+{
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ return callRemoteMethod<QString>(d->stream, QLatin1String("QProcess::workingDirectory"));
+ return static_cast< QString>(d->process.workingDirectory());
+}
+
+void QProcessWrapper::setEnvironment(const QStringList& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::setEnvironment"), param1);
+ else
+ d->process.setEnvironment(param1);
+}
+
+#ifdef Q_OS_WIN
+void QProcessWrapper::setNativeArguments(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::setNativeArguments"), param1);
+ else
+ d->process.setNativeArguments(param1);
+}
+#endif
+
+void QProcessWrapper::setWorkingDirectory(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ const Private::TimerBlocker blocker(this);
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QProcess::setWorkingDirectory"), param1);
+ else
+ d->process.setWorkingDirectory(param1);
+}
diff --git a/installerbuilder/libinstaller/qprocesswrapper.h b/installerbuilder/libinstaller/qprocesswrapper.h
new file mode 100644
index 000000000..bdb201922
--- /dev/null
+++ b/installerbuilder/libinstaller/qprocesswrapper.h
@@ -0,0 +1,120 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QPROCESSWRAPPER_H
+#define QPROCESSWRAPPER_H
+
+#include <installer_global.h>
+
+#include<QtCore/QIODevice>
+#include<QtCore/QObject>
+#include<QtCore/QProcess>
+
+class INSTALLER_EXPORT QProcessWrapper : public QObject
+{
+ Q_OBJECT
+public:
+ enum ProcessState {
+ NotRunning,
+ Starting,
+ Running
+ };
+
+ enum ExitStatus {
+ NormalExit,
+ CrashExit
+ };
+
+ enum ProcessChannel {
+ StandardOutput = 0,
+ StandardError = 1
+ };
+
+ enum ProcessChannelMode {
+ SeparateChannels = 0,
+ MergedChannels = 1,
+ ForwardedChannels = 2
+ };
+
+ explicit QProcessWrapper(QObject *parent = 0);
+ ~QProcessWrapper();
+
+ void closeWriteChannel();
+ int exitCode() const;
+ ExitStatus exitStatus() const;
+ void kill();
+ void terminate();
+ QByteArray readAll();
+ QByteArray readAllStandardOutput();
+ void setWorkingDirectory(const QString &dir);
+
+ void start(const QString &program);
+ void start(const QString &program, const QStringList &arguments,
+ QIODevice::OpenMode mode = QIODevice::ReadWrite);
+
+ static bool startDetached(const QString &program);
+ static bool startDetached(const QString &program, const QStringList &arguments);
+ static bool startDetached(const QString &program, const QStringList &arguments,
+ const QString &workingDirectory, qint64 *pid = 0);
+
+ ProcessState state() const;
+ bool waitForStarted(int msecs = 30000);
+ bool waitForFinished(int msecs = 30000);
+ void setEnvironment(const QStringList &environment);
+ QString workingDirectory() const;
+ qint64 write(const QByteArray &byteArray);
+ QProcessWrapper::ProcessChannel readChannel() const;
+ void setReadChannel(QProcessWrapper::ProcessChannel channel);
+ QProcessWrapper::ProcessChannelMode processChannelMode() const;
+ void setProcessChannelMode(QProcessWrapper::ProcessChannelMode channel);
+#ifdef Q_OS_WIN
+ void setNativeArguments(const QString &arguments);
+#endif
+
+Q_SIGNALS:
+ void bytesWritten(qint64);
+ void aboutToClose();
+ void readChannelFinished();
+ void error(QProcess::ProcessError);
+ void readyReadStandardOutput();
+ void readyReadStandardError();
+ void finished(int exitCode);
+ void finished(int exitCode, QProcess::ExitStatus exitStatus);
+ void readyRead();
+ void started();
+ void stateChanged(QProcess::ProcessState newState);
+
+public Q_SLOTS:
+ void cancel();
+
+protected:
+ void timerEvent(QTimerEvent *event);
+
+private:
+ class Private;
+ Private *d;
+};
+
+#endif // QPROCESSWRAPPER_H
diff --git a/installerbuilder/libinstaller/qsettingswrapper.cpp b/installerbuilder/libinstaller/qsettingswrapper.cpp
new file mode 100644
index 000000000..56f97295a
--- /dev/null
+++ b/installerbuilder/libinstaller/qsettingswrapper.cpp
@@ -0,0 +1,398 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qsettingswrapper.h"
+
+#include "fsengineclient.h"
+#include "templates.cpp"
+
+#include <QtCore/QSettings>
+#include <QtCore/QThread>
+
+#include <QtNetwork/QTcpSocket>
+
+
+// -- QSettingsWrapper::Private
+
+class QSettingsWrapper::Private
+{
+public:
+ Private(const QString &organization, const QString &application)
+ : native(true),
+ settings(organization, application),
+ socket(0)
+ {
+ }
+
+ Private(QSettings::Scope scope, const QString &organization, const QString &application)
+ : native(true),
+ settings(scope, organization, application),
+ socket(0)
+ {
+ }
+
+ Private(QSettings::Format format, QSettings::Scope scope, const QString &organization,
+ const QString &application)
+ : native(format == QSettings::NativeFormat),
+ settings(format, scope, organization, application),
+ socket(0)
+ {
+ }
+
+ Private(const QString &fileName, QSettings::Format format)
+ : native(format == QSettings::NativeFormat),
+ fileName(fileName),
+ settings(fileName, format),
+ socket(0)
+ {
+ }
+
+ Private()
+ : native(true),
+ socket(0)
+ {
+ }
+
+ bool createSocket()
+ {
+ if (!native || !FSEngineClientHandler::instance()->isActive())
+ return false;
+
+ if (socket != 0 && socket->state() == static_cast<int>(QAbstractSocket::ConnectedState))
+ return true;
+
+ if (socket != 0)
+ delete socket;
+
+ socket = new QTcpSocket;
+ if (!FSEngineClientHandler::instance()->connect(socket))
+ return false;
+
+ stream.setDevice(socket);
+ stream.setVersion(QDataStream::Qt_4_2);
+
+ stream << QString::fromLatin1("createQSettings");
+ stream << this->fileName;
+ socket->flush();
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return true;
+ }
+
+ const bool native;
+ const QString fileName;
+ QSettings settings;
+ mutable QTcpSocket* socket;
+ mutable QDataStream stream;
+};
+
+
+// -- QSettingsWrapper
+
+QSettingsWrapper::QSettingsWrapper(const QString &organization, const QString &application, QObject *parent)
+ : QObject(parent)
+ , d(new Private(organization, application))
+{
+ qDebug() << Q_FUNC_INFO;
+}
+
+QSettingsWrapper::QSettingsWrapper(QSettingsWrapper::Scope scope, const QString &organization,
+ const QString &application, QObject *parent)
+ : QObject(parent)
+ , d(new Private(static_cast<QSettings::Scope> (scope), organization, application))
+{
+ qDebug() << Q_FUNC_INFO;
+}
+
+QSettingsWrapper::QSettingsWrapper(QSettingsWrapper::Format format, QSettingsWrapper::Scope scope,
+ const QString &organization, const QString &application, QObject *parent)
+ : QObject(parent)
+ , d(new Private(static_cast<QSettings::Format> (format), static_cast<QSettings::Scope> (scope),
+ organization, application))
+{
+ qDebug() << Q_FUNC_INFO;
+}
+
+QSettingsWrapper::QSettingsWrapper(const QString &fileName, QSettingsWrapper::Format format, QObject *parent)
+ : QObject(parent)
+ , d(new Private(fileName, static_cast<QSettings::Format> (format)))
+{
+ qDebug() << Q_FUNC_INFO;
+}
+
+QSettingsWrapper::QSettingsWrapper(QObject *parent)
+ : QObject(parent)
+ , d(new Private)
+{
+ qDebug() << Q_FUNC_INFO;
+}
+
+QSettingsWrapper::~QSettingsWrapper()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->socket != 0) {
+ d->stream << QString::fromLatin1("destroyQSettings");
+ d->socket->flush();
+ quint32 result;
+ d->stream >> result;
+
+ if (QThread::currentThread() == d->socket->thread()) {
+ d->socket->close();
+ delete d->socket;
+ } else {
+ d->socket->deleteLater();
+ }
+ }
+ delete d;
+}
+
+QStringList QSettingsWrapper::allKeys() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QStringList>(d->stream, QLatin1String("QSettings::allKeys"));
+ return static_cast<QStringList>(d->settings.allKeys());
+}
+
+QString QSettingsWrapper::applicationName() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QString>(d->stream, QLatin1String("QSettings::applicationName"));
+ return static_cast<QString>(d->settings.applicationName());
+}
+
+void QSettingsWrapper::beginGroup(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::beginGroup"), param1);
+ else
+ d->settings.beginGroup(param1);
+}
+
+int QSettingsWrapper::beginReadArray(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<int>(d->stream, QLatin1String("QSettings::beginReadArray"), param1);
+ return d->settings.beginReadArray(param1);
+}
+
+void QSettingsWrapper::beginWriteArray(const QString& param1, int param2)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::beginWriteArray"), param1, param2);
+ else
+ d->settings.beginWriteArray(param1, param2);
+}
+
+QStringList QSettingsWrapper::childGroups() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QStringList>(d->stream, QLatin1String("QSettings::childGroups"));
+ return static_cast<QStringList>(d->settings.childGroups());
+}
+
+QStringList QSettingsWrapper::childKeys() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QStringList>(d->stream, QLatin1String("QSettings::childKeys"));
+ return static_cast<QStringList>(d->settings.childKeys());
+}
+
+void QSettingsWrapper::clear()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QSettings::clear"));
+ else d->settings.clear();
+}
+
+bool QSettingsWrapper::contains(const QString& param1) const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<bool>(d->stream, QLatin1String("QSettings::contains"), param1);
+ return d->settings.contains(param1);
+}
+
+void QSettingsWrapper::endArray()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QSettings::endArray"));
+ else
+ d->settings.endArray();
+}
+
+void QSettingsWrapper::endGroup()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QSettings::endGroup"));
+ else
+ d->settings.endGroup();
+}
+
+bool QSettingsWrapper::fallbacksEnabled() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<bool>(d->stream, QLatin1String("QSettings::fallbacksEnabled"));
+ return static_cast<bool>(d->settings.fallbacksEnabled());
+}
+
+QString QSettingsWrapper::fileName() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QString>(d->stream, QLatin1String("QSettings::fileName"));
+ return static_cast<QString>(d->settings.fileName());
+}
+
+QSettingsWrapper::Format QSettingsWrapper::format() const
+{
+ qDebug() << Q_FUNC_INFO;
+ return static_cast<QSettingsWrapper::Format>(d->settings.format());
+}
+
+QString QSettingsWrapper::group() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QString>(d->stream, QLatin1String("QSettings::group"));
+ return static_cast<QString>(d->settings.group());
+}
+
+QTextCodec* QSettingsWrapper::iniCodec() const
+{
+ qDebug() << Q_FUNC_INFO;
+ return d->settings.iniCodec();
+}
+
+bool QSettingsWrapper::isWritable() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<bool>(d->stream, QLatin1String("QSettings::isWritable"));
+ return static_cast<bool>(d->settings.isWritable());
+}
+
+QString QSettingsWrapper::organizationName() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QString>(d->stream, QLatin1String("QSettings::organizationName"));
+ return static_cast<QString>(d->settings.organizationName());
+}
+
+void QSettingsWrapper::remove(const QString& param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::remove"), param1);
+ else d->settings.remove(param1);
+}
+
+QSettingsWrapper::Scope QSettingsWrapper::scope() const
+{
+ qDebug() << Q_FUNC_INFO;
+ return static_cast<QSettingsWrapper::Scope>(d->settings.scope());
+}
+
+void QSettingsWrapper::setArrayIndex(int param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::setArrayIndex"), param1);
+ else d->settings.setArrayIndex(param1);
+}
+
+void QSettingsWrapper::setFallbacksEnabled(bool param1)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::setFallbacksEnabled"), param1);
+ else d->settings.setFallbacksEnabled(param1);
+}
+
+void QSettingsWrapper::setIniCodec(QTextCodec* codec)
+{
+ qDebug() << Q_FUNC_INFO;
+ d->settings.setIniCodec(codec);
+}
+
+void QSettingsWrapper::setIniCodec(const char* codecName)
+{
+ qDebug() << Q_FUNC_INFO;
+ d->settings.setIniCodec(codecName);
+}
+
+void QSettingsWrapper::setValue(const QString& param1, const QVariant& param2)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod(d->stream, QLatin1String("QSettings::setValue"), param1, param2);
+ else
+ d->settings.setValue(param1, param2);
+}
+
+QSettingsWrapper::Status QSettingsWrapper::status() const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QSettingsWrapper::Status>(d->stream, QLatin1String("QSettings::status"));
+ return static_cast<QSettingsWrapper::Status>(d->settings.status());
+};
+
+void QSettingsWrapper::sync()
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ callRemoteVoidMethod<void>(d->stream, QLatin1String("QSettings::sync"));
+ else
+ d->settings.sync();
+}
+
+QVariant QSettingsWrapper::value(const QString& param1, const QVariant& param2) const
+{
+ qDebug() << Q_FUNC_INFO;
+ if (d->createSocket())
+ return callRemoteMethod<QVariant>(d->stream, QLatin1String("QSettings::value"), param1, param2);
+ return d->settings.value(param1, param2);
+}
diff --git a/installerbuilder/libinstaller/qsettingswrapper.h b/installerbuilder/libinstaller/qsettingswrapper.h
new file mode 100644
index 000000000..c807e62c8
--- /dev/null
+++ b/installerbuilder/libinstaller/qsettingswrapper.h
@@ -0,0 +1,100 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QSETTINGSWRAPPER_H
+#define QSETTINGSWRAPPER_H
+
+#include <installer_global.h>
+
+#include<QtCore/QObject>
+#include<QtCore/QVariant>
+
+class INSTALLER_EXPORT QSettingsWrapper : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum Format {
+ NativeFormat,
+ IniFormat,
+ InvalidFormat
+ };
+
+ enum Status {
+ NoError,
+ AccessError,
+ FormatError
+ };
+
+ enum Scope {
+ UserScope,
+ SystemScope
+ };
+
+ explicit QSettingsWrapper(QObject *parent = 0);
+ explicit QSettingsWrapper(const QString &organization, const QString &application = QString(),
+ QObject *parent = 0);
+ QSettingsWrapper(const QString &fileName, QSettingsWrapper::Format format, QObject *parent = 0);
+ QSettingsWrapper(QSettingsWrapper::Scope scope, const QString &organization,
+ const QString &application = QString(), QObject *parent = 0);
+ QSettingsWrapper(QSettingsWrapper::Format format, QSettingsWrapper::Scope scope,
+ const QString &organization, const QString &application = QString(), QObject *parent = 0);
+ ~QSettingsWrapper();
+
+ QStringList allKeys() const;
+ QString applicationName() const;
+ void beginGroup(const QString &prefix);
+ int beginReadArray(const QString &prefix);
+ void beginWriteArray(const QString &prefix, int size = -1);
+ QStringList childGroups() const;
+ QStringList childKeys() const;
+ void clear();
+ bool contains(const QString &key) const;
+ void endArray();
+ void endGroup();
+ bool fallbacksEnabled() const;
+ QString fileName() const;
+ QSettingsWrapper::Format format() const;
+ QString group() const;
+ QTextCodec* iniCodec() const;
+ bool isWritable() const;
+ QString organizationName() const;
+ void remove(const QString &key);
+ QSettingsWrapper::Scope scope() const;
+ void setArrayIndex(int i);
+ void setFallbacksEnabled(bool b);
+ void setIniCodec(QTextCodec *codec);
+ void setIniCodec(const char *codecName);
+ void setValue(const QString &key, const QVariant &value);
+ QSettingsWrapper::Status status() const;
+ void sync();
+ QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
+
+private:
+ class Private;
+ Private *d;
+};
+
+#endif // QSETTINGSWRAPPER_H
diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.cpp b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
index 1e334a0ca..c240cee1d 100644
--- a/installerbuilder/libinstaller/registerdocumentationoperation.cpp
+++ b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
@@ -31,13 +31,12 @@
**
**************************************************************************/
#include "registerdocumentationoperation.h"
-#include "fsengineclient.h"
+#include <QSettings>
#include <QHelpEngine>
#include <QString>
#include <QFileInfo>
#include <QDir>
-#include <QSettings>
#include <QDebug>
using namespace QInstaller;
@@ -63,7 +62,8 @@ namespace {
// If the system settings are writable, don't touch the user settings.
// The reason is that a doc registered while running with sudo could otherwise create
// a root-owned configuration file a user directory.
- QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat, QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
+ QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat,
+ QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
// QSettings::isWritable isn't reliable enough in 4.7, determine writability experimentally
settings->setValue(QLatin1String("iswritable"), QLatin1String("accomplished"));
@@ -74,12 +74,13 @@ namespace {
settings->remove(QLatin1String("iswritable"));
} else {
// we have to use user settings
- settings.reset(new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
+ settings.reset(new QSettings(QSettings::IniFormat, QSettings::UserScope,
+ QLatin1String("Nokia"), QLatin1String("QtCreator")));
}
#else
- QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
- QLatin1String("Nokia"), QLatin1String("QtCreator")));
+ QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat,
+ QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
#endif
return settings->fileName();
}
@@ -117,7 +118,12 @@ bool RegisterDocumentationOperation::performOperation()
if (!oldData.isEmpty())
oldData.append(QLatin1String(";"));
const QString newData = oldData + QFileInfo(helpFile).absoluteFilePath();
- return help.setCustomValue(QLatin1String("AddedDocs"), newData);
+ if (!help.setCustomValue(QLatin1String("AddedDocs"), newData)) {
+ setError(UserDefinedError);
+ setErrorString(help.error());
+ return false;
+ }
+ return true;
}
bool RegisterDocumentationOperation::undoOperation()
diff --git a/installerbuilder/libinstaller/registerfiletypeoperation.cpp b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
index 21000cf9e..c6602f4f8 100644
--- a/installerbuilder/libinstaller/registerfiletypeoperation.cpp
+++ b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
@@ -32,10 +32,7 @@
**************************************************************************/
#include "registerfiletypeoperation.h"
-#include <QSettings>
-
-// this makes us use QSettingsWrapper
-#include "fsengineclient.h"
+#include "qsettingswrapper.h"
using namespace QInstaller;
@@ -73,8 +70,8 @@ bool RegisterFileTypeOperation::performOperation()
const QString className = QString::fromLatin1( "%1_auto_file" ).arg( extension );
const QString settingsPrefix = QString::fromLatin1( "Software/Classes/" );
- //QSettings settings( QLatin1String( "HKEY_CLASSES_ROOT" ), QSettings::NativeFormat );
- QSettings settings(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
+ //QSettingsWrapper settings( QLatin1String( "HKEY_CLASSES_ROOT" ), QSettingsWrapper::NativeFormat );
+ QSettingsWrapper settings(QLatin1String("HKEY_CURRENT_USER"), QSettingsWrapper::NativeFormat);
// first backup the old values
setValue(QLatin1String("oldClass"), settings.value(QString::fromLatin1("%1.%2/Default").arg(settingsPrefix, extension)));
setValue(QLatin1String("oldContentType"), settings.value(QString::fromLatin1("%1.%2/Content Type").arg(settingsPrefix, extension)));
@@ -136,7 +133,7 @@ bool RegisterFileTypeOperation::undoOperation()
const QString className = QString::fromLatin1("%1_auto_file").arg(extension);
const QString settingsPrefix = QString::fromLatin1("Software/Classes/");
- QSettings settings(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
+ QSettingsWrapper settings(QLatin1String("HKEY_CURRENT_USER"), QSettingsWrapper::NativeFormat);
const QString restoredClassName = value(QLatin1String("oldClassName")).toString();
// register the command to open the file
diff --git a/installerbuilder/libinstaller/registertoolchainoperation.cpp b/installerbuilder/libinstaller/registertoolchainoperation.cpp
index f86620222..0dbd2b75c 100644
--- a/installerbuilder/libinstaller/registertoolchainoperation.cpp
+++ b/installerbuilder/libinstaller/registertoolchainoperation.cpp
@@ -31,16 +31,17 @@
**
**************************************************************************/
#include "registertoolchainoperation.h"
+
#include "persistentsettings.h"
#include "qinstaller.h"
#include "qtcreator_constants.h"
#include "qtcreatorpersistentsettings.h"
-#include <QString>
-#include <QFileInfo>
-#include <QDir>
-#include <QSettings>
-#include <QDebug>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QSettings>
+#include <QtCore/QString>
using namespace QInstaller;
diff --git a/installerbuilder/libinstaller/files-to-patch-linux b/installerbuilder/libinstaller/resources/files-to-patch-linux
index 9c7b39f4a..9c7b39f4a 100644
--- a/installerbuilder/libinstaller/files-to-patch-linux
+++ b/installerbuilder/libinstaller/resources/files-to-patch-linux
diff --git a/installerbuilder/libinstaller/files-to-patch-macx b/installerbuilder/libinstaller/resources/files-to-patch-macx
index 7f8deda14..7f8deda14 100644
--- a/installerbuilder/libinstaller/files-to-patch-macx
+++ b/installerbuilder/libinstaller/resources/files-to-patch-macx
diff --git a/installerbuilder/libinstaller/files-to-patch-windows b/installerbuilder/libinstaller/resources/files-to-patch-windows
index 845a299ce..845a299ce 100644
--- a/installerbuilder/libinstaller/files-to-patch-windows
+++ b/installerbuilder/libinstaller/resources/files-to-patch-windows
diff --git a/installerbuilder/libinstaller/patch_file_lists.qrc b/installerbuilder/libinstaller/resources/patch_file_lists.qrc
index a51500369..a51500369 100644
--- a/installerbuilder/libinstaller/patch_file_lists.qrc
+++ b/installerbuilder/libinstaller/resources/patch_file_lists.qrc
diff --git a/installerbuilder/libinstaller/selfrestartoperation.cpp b/installerbuilder/libinstaller/selfrestartoperation.cpp
index 909d59c9c..2cadf2b7f 100644
--- a/installerbuilder/libinstaller/selfrestartoperation.cpp
+++ b/installerbuilder/libinstaller/selfrestartoperation.cpp
@@ -59,9 +59,10 @@ bool SelfRestartOperation::performOperation()
setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
return false;
}
- if (!installer->isUpdater()) {
+
+ if(!installer->isUpdater() && !installer->isPackageManager()) {
setError(UserDefinedError);
- setErrorString(tr("Self Restart: Only valid within Updater."));
+ setErrorString(tr("Self Restart: Only valid within updater or packagemanager mode."));
return false;
}
diff --git a/installerbuilder/libinstaller/templates.cpp b/installerbuilder/libinstaller/templates.cpp
new file mode 100644
index 000000000..700e0c3e3
--- /dev/null
+++ b/installerbuilder/libinstaller/templates.cpp
@@ -0,0 +1,169 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include<QtCore/QIODevice>
+
+template<typename T>
+QDataStream &operator>>(QDataStream &stream, T &state)
+{
+ int s;
+ stream >> s;
+ state = static_cast<T> (s);
+ return stream;
+}
+
+template<typename UNUSED>
+void callRemoteVoidMethod(QDataStream &stream, const QString &name)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template<typename T>
+void callRemoteVoidMethod(QDataStream & stream, const QString &name, const T &param1)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template<typename T1, typename T2>
+void callRemoteVoidMethod(QDataStream &stream, const QString &name, const T1 &param1, const T2 &param2)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template<typename T1, typename T2, typename T3>
+void callRemoteVoidMethod(QDataStream &stream, const QString &name, const T1 &param1, const T2 &param2,
+ const T3 & param3)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream << param3;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template<typename RESULT>
+RESULT callRemoteMethod(QDataStream &stream, const QString &name)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template<typename RESULT, typename T>
+RESULT callRemoteMethod(QDataStream &stream, const QString &name, const T &param1)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template<typename RESULT, typename T1, typename T2>
+RESULT callRemoteMethod(QDataStream &stream, const QString &name, const T1 & param1, const T2 &param2)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template<typename RESULT, typename T1, typename T2, typename T3>
+RESULT callRemoteMethod(QDataStream &stream, const QString &name, const T1 &param1, const T2 & param2,
+ const T3 &param3)
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream << param3;
+ stream.device()->waitForBytesWritten(-1);
+ if (!stream.device()->bytesAvailable())
+ stream.device()->waitForReadyRead(-1);
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
diff --git a/installerbuilder/libinstaller/de_de.ts b/installerbuilder/libinstaller/translations/de_de.ts
index b9a078ffd..b9a078ffd 100644
--- a/installerbuilder/libinstaller/de_de.ts
+++ b/installerbuilder/libinstaller/translations/de_de.ts
diff --git a/installerbuilder/libinstaller/sv_se.ts b/installerbuilder/libinstaller/translations/sv_se.ts
index b9a078ffd..b9a078ffd 100644
--- a/installerbuilder/libinstaller/sv_se.ts
+++ b/installerbuilder/libinstaller/translations/sv_se.ts
diff --git a/installerbuilder/libinstaller/updateagent.cpp b/installerbuilder/libinstaller/updateagent.cpp
deleted file mode 100644
index dad07373b..000000000
--- a/installerbuilder/libinstaller/updateagent.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "updateagent.h"
-
-#include "updatesettings.h"
-
-#include <memory>
-
-#include <QDateTime>
-#include <QTimer>
-
-#include <KDUpdater/Application>
-
-#include "qinstaller.h"
-#include "qinstallercomponent.h"
-
-#include "common/binaryformatenginehandler.h"
-#include "common/binaryformat.h"
-
-using namespace QInstaller;
-
-class UpdateAgent::Private
-{
-public:
- Private( UpdateAgent* qq )
- : q( qq )
- {
- connect( &checkTimer, SIGNAL( timeout() ), q, SLOT( maybeCheck() ) );
- checkTimer.start( 1000 );
- }
-
-private:
- UpdateAgent* const q;
-
-public:
- void maybeCheck()
- {
- checkTimer.stop();
-
- UpdateSettings settings;
-
- try
- {
- if( settings.updateInterval() > 0 && settings.lastCheck().secsTo( QDateTime::currentDateTime() ) >= settings.updateInterval() )
- {
- std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
- handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
-
- settings.setLastCheck( QDateTime::currentDateTime() );
-
- Installer installer;
- installer.setRemoteRepositories( settings.repositories() );
- QList< Component* > components = installer.components();
-
- // remove all unimportant updates
- if( settings.checkOnlyImportantUpdates() )
- {
- for( int i = components.count() - 1; i >= 0; --i )
- {
- const Component* const comp = components[ i ];
- if( comp->value( QLatin1String( "Important" ) ).toLower() != QLatin1String( "true" ) )
- components.removeAt( i );
- }
- }
-
- settings.setLastResult( tr( "Software Update run successfully." ) );
-
- // no updates available
- if( components.isEmpty() )
- return;
-
- emit q->updatesAvailable();
- }
- }
- catch( ... )
- {
- settings.setLastResult( tr( "Software Update failed." ) );
- }
-
- checkTimer.start();
- }
-
- QTimer checkTimer;
-};
-
-UpdateAgent::UpdateAgent( QObject* parent )
- : QObject( parent ),
- d( new Private( this ) )
-{
-}
-
-UpdateAgent::~UpdateAgent()
-{
-}
-
-#include "moc_updateagent.cpp"
diff --git a/installerbuilder/libinstaller/updater.cpp b/installerbuilder/libinstaller/updater.cpp
index b4e301391..536a1a572 100644
--- a/installerbuilder/libinstaller/updater.cpp
+++ b/installerbuilder/libinstaller/updater.cpp
@@ -31,293 +31,72 @@
**
**************************************************************************/
#include "updater.h"
-#include "messageboxhandler.h"
-
-#include <QDateTime>
-#include <QDomDocument>
-#include <QProgressDialog>
-#include <QSharedPointer>
#include "common/binaryformat.h"
-#include "common/binaryformatenginehandler.h"
-#include "common/errors.h"
#include "common/utils.h"
-
+#include "init.h"
#include "qinstaller.h"
#include "qinstallercomponent.h"
-#include "qinstallercomponentmodel.h"
-#include "updatesettings.h"
-#include "init.h"
-#include "installationprogressdialog.h"
-#include "componentselectiondialog.h"
-
-#include <KDUpdater/Application>
-#include <KDUpdater/PackagesInfo>
-
-#include <KDToolsCore/KDAutoPointer>
-
-#include <memory>
-#include <iostream>
+#include <QtXml/QDomDocument>
using namespace QInstaller;
+using namespace QInstallerCreator;
-class Updater::Private
-{
-public:
- Private() : dialog( 0 ) {
- }
-
- Installer* installer_shared;
- ComponentSelectionDialog * dialog;
- QSharedPointer< QInstallerCreator::BinaryFormatEngineHandler > handler;
- QSharedPointer< UpdateSettings > settings;
- QList< Component* > components;
-};
-
-void Updater::init()
-{
- //d->installer.setLinearComponentList( true );
- d->handler = QSharedPointer< QInstallerCreator::BinaryFormatEngineHandler > ( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
- d->settings = QSharedPointer< UpdateSettings > ( new UpdateSettings() );
- //d->dialog = QSharedPointer< ComponentSelectionDialog >( new ComponentSelectionDialog( &d->installer ) );
- //ComponentModel::setVirtualComponentsVisible( true );
-}
-
-Updater::Updater( QObject* parent )
- : QObject( parent )
-{
-}
-void Updater::setInstaller( QInstaller::Installer * installer )
+Updater::Updater()
{
- d->installer_shared = installer;
+ QInstaller::init();
}
-//QInstaller::Installer * Updater::getInstaller()
-//{
-// return &d->installer;
-//}
-
Updater::~Updater()
{
}
-ComponentSelectionDialog* Updater::updaterGui() const {
- return d->dialog;
-}
-
-void Updater::setUpdaterGui( QInstaller::ComponentSelectionDialog * gui )
+void Updater::setVerbose(bool verbose)
{
- if ( d->dialog )
- disconnect( d->dialog, SIGNAL( requestUpdate() ), this, SLOT( update() ) );
- //disconnect( d->dialog, SIGNAL( accepted() ), this, SLOT( update() ) );
- d->dialog = gui;
- //connect( gui, SIGNAL( accepted() ), this, SLOT( update() ) );
- connect( gui, SIGNAL( requestUpdate() ), this, SLOT( update() ) );
+ QInstaller::setVerbose(verbose);
}
-bool Updater::searchForUpdates()
+bool Updater::checkForUpdates()
{
- try
- {
- KDAutoPointer< QProgressDialog > progress( new QProgressDialog( d->dialog ) );
- progress->setLabelText( tr( "Checking for updates..." ) );
- progress->setRange( 0, 0 );
- connect (progress.get(), SIGNAL( canceled() ), d->dialog, SLOT( reject() ) );
- progress->show();
-
- d->settings->setLastCheck( QDateTime::currentDateTime() );
- d->installer_shared->setRemoteRepositories( d->settings->repositories() );
- d->installer_shared->setValue(QLatin1String("TargetDir"),
- QFileInfo(d->installer_shared->updaterApplication().packagesInfo()->fileName())
- .absolutePath());
- }
- catch( const Error& error )
- {
- QMessageBox::critical( d->dialog, tr( "Check for Updates" ), tr( "Error while checking for updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
- d->settings->setLastResult( tr( "Software Update failed." ) );
- return false;
- }
- catch( ... )
- {
- QMessageBox::critical( d->dialog, tr( "Check for Updates" ), tr( "Unknown error while checking for updates." ) );
- d->settings->setLastResult( tr( "Software Update failed." ) );
- return false;
- }
-
- d->components = d->installer_shared->components( true );
+ BinaryContent content = BinaryContent::readFromApplicationFile();
+ content.registerEmbeddedQResources();
- // no updates for us
- if( d->components.isEmpty() )
- {
- QMessageBox::information( d->dialog, tr( "Check for Updates" ), tr( "There are currently no updates available." ) );
+ if (content.magicmaker() == MagicInstallerMarker) {
+ verbose() << tr("Impossible to use an installer to check for updates!") << std::endl;
return false;
}
- return true;
-}
-bool Updater::update()
-{
-// if( d->dialog->exec() == QDialog::Rejected )
-// return false;
+ Installer installer(content.magicmaker(), content.performedOperations());
+ installer.setUpdater();
+ Installer::setVirtualComponentsVisible(true);
- try
- {
- InstallationProgressDialog* dialog = new InstallationProgressDialog( d->dialog );
- dialog->setAttribute( Qt::WA_DeleteOnClose, true );
- dialog->setModal( true );
- dialog->setFixedSize( 480, 360 );
- dialog->show();
- connect( dialog, SIGNAL( canceled() ), d->installer_shared, SLOT( interrupt() ) );
- connect( d->installer_shared, SIGNAL( updateFinished() ), dialog, SLOT( finished() ) );
- d->installer_shared->installSelectedComponents();
- QEventLoop loop;
- connect( dialog, SIGNAL( destroyed() ), &loop, SLOT( quit() ) );
- loop.exec();
- }
- catch( const Error& error )
- {
- //if the user clicked the confirm cancel dialog he don't want to see another messagebox
- if ( d->installer_shared->status() != Installer::InstallerCanceledByUser )
- {
- MessageBoxHandler::critical(d->dialog,
- QLatin1String("updaterCriticalInstallError"), tr( "Check for Updates" ),
- tr( "Error while installing updates:\n%1" ).arg( error.message() ) );
- }
- d->installer_shared->rollBackInstallation();
- d->settings->setLastResult( tr( "Software Update failed." ) );
- emit updateFinished( true );
- return false;
- }
- catch( ... )
- {
- MessageBoxHandler::critical(d->dialog,
- QLatin1String("updaterCriticalUnknownError"),
- tr( "Check for Updates" ),
- tr( "Unknown error while installing updates." ) );
- d->installer_shared->rollBackInstallation();
- d->settings->setLastResult( tr( "Software Update failed." ) );
- emit updateFinished( true );
- return false;
- }
- emit updateFinished( false );
- return true;
-}
-
-bool Updater::checkForUpdates( bool checkonly )
-{
KDUpdater::Application updaterapp;
- BinaryContent content = BinaryContent::readFromApplicationFile();
- Installer installer( content.magicmaker, content.performedOperations );
- QInstaller::init();
- installer.setUpdaterApplication( &updaterapp );
- installer.setPackageManager();
- installer.setLinearComponentList( true );
-
- std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
- handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
-
- UpdateSettings settings;
- KDAutoPointer< ComponentSelectionDialog > dialog( checkonly ? 0 : new ComponentSelectionDialog( &installer ) );
- if( !checkonly )
- dialog->show();
+ installer.setUpdaterApplication(&updaterapp);
- ComponentModel::setVirtualComponentsVisible( true );
+ if (installer.fetchUpdaterPackages()) {
+ const QList<QInstaller::Component*> components = installer.components(true, UpdaterMode);
- try
- {
- KDAutoPointer< QProgressDialog > progress( checkonly ? 0 : new QProgressDialog( dialog.get() ) );
- if( !checkonly )
- {
- progress->setLabelText( tr( "Checking for updates..." ) );
- progress->setRange( 0, 0 );
- progress->show();
- }
-
- settings.setLastCheck( QDateTime::currentDateTime() );
- installer.setRemoteRepositories( settings.repositories() );
- if ( installer.status() == QInstaller::Installer::InstallerFailed )
+ if (components.isEmpty()) {
+ verbose() << tr("There are currently no updates available.") << std::endl;
return false;
- installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
- }
- catch( const Error& error )
- {
- if( !checkonly )
- QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while checking for updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
- settings.setLastResult( tr( "Software Update failed." ) );
- return false;
- }
- catch( ... )
- {
- if( !checkonly )
- QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while checking for updates." ) );
- settings.setLastResult( tr( "Software Update failed." ) );
- return false;
- }
-
- const QList< Component* > components = installer.components( true, UpdaterMode );
-
- // no updates for us
- if( components.isEmpty() && !checkonly )
- {
- QMessageBox::information( dialog.get(), tr( "Check for Updates" ), tr( "There are currently no updates available." ) );
- return false;
- }
+ }
- if( checkonly )
- {
QDomDocument doc;
- QDomElement root = doc.createElement( QLatin1String( "updates" ) );
- doc.appendChild( root );
- for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
- {
- QDomElement update = doc.createElement( QLatin1String( "update" ) );
- update.setAttribute( QLatin1String( "name" ), (*it)->value( QLatin1String( "DisplayName" ) ) );
- update.setAttribute( QLatin1String( "version" ), (*it)->value( QLatin1String( "Version" ) ) );
- update.setAttribute( QLatin1String( "size" ), (*it)->value( QLatin1String( "UncompressedSize" ) ) );
- root.appendChild( update );
+ QDomElement root = doc.createElement(QLatin1String("updates"));
+ doc.appendChild(root);
+
+ QList< QInstaller::Component* >::const_iterator it;
+ for (it = components.begin(); it != components.end(); ++it) {
+ QDomElement update = doc.createElement(QLatin1String("update"));
+ update.setAttribute(QLatin1String("name"), (*it)->value(QLatin1String("DisplayName")));
+ update.setAttribute(QLatin1String("version"), (*it)->value(QLatin1String("Version")));
+ update.setAttribute(QLatin1String("size"), (*it)->value(QLatin1String("UncompressedSize")));
+ root.appendChild(update);
}
- std::cout << doc.toString( 4 ).toStdString() << std::endl;
- return true;
- }
- if( dialog->exec() == QDialog::Rejected )
- return false;
-
- try
- {
- InstallationProgressDialog* dialog = new InstallationProgressDialog();
- dialog->setModal( true );
- dialog->setAttribute( Qt::WA_DeleteOnClose, true );
- dialog->setFixedSize( 480, 360 );
- dialog->show();
- connect( dialog, SIGNAL( canceled() ), &installer, SLOT( interrupt() ) );
- connect( &installer, SIGNAL( installationProgressTextChanged( QString ) ), dialog, SLOT( changeInstallationProgressText( QString ) ) );
- connect( &installer, SIGNAL( installationProgressChanged( int ) ), dialog, SLOT( changeInstallationProgress( int ) ) );
- connect( &installer, SIGNAL( updateFinished() ), dialog, SLOT( finished() ) );
- installer.installSelectedComponents();
- QEventLoop loop;
- connect( dialog, SIGNAL( destroyed() ), &loop, SLOT( quit() ) );
- loop.exec();
- }
- catch( const Error& error )
- {
- //if the user clicked the confirm cancel dialog he don't want to see another messagebox
- if ( installer.status() != Installer::InstallerCanceledByUser )
- {
- QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
- }
- installer.rollBackInstallation();
- settings.setLastResult( tr( "Software Update failed." ) );
- return false;
- }
- catch( ... )
- {
- QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
- installer.rollBackInstallation();
- settings.setLastResult( tr( "Software Update failed." ) );
- return false;
+ verbose() << doc.toString(4) << std::endl;
}
return true;
diff --git a/installerbuilder/libinstaller/updater.h b/installerbuilder/libinstaller/updater.h
index 94076e6a0..ad1eef246 100644
--- a/installerbuilder/libinstaller/updater.h
+++ b/installerbuilder/libinstaller/updater.h
@@ -29,36 +29,22 @@
#include "installer_global.h"
#include <QtCore/QObject>
-#include <KDToolsCore/pimpl_ptr.h>
-#include <QSharedPointer>
-namespace QInstaller
-{
- class ComponentSelectionDialog;
- class Installer;
-}
+namespace QInstaller {
+class Installer;
class INSTALLER_EXPORT Updater : public QObject
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- explicit Updater( QObject* parent = 0 );
+ explicit Updater();
~Updater();
- void init();
- QInstaller::ComponentSelectionDialog* updaterGui() const;
- void setUpdaterGui( QInstaller::ComponentSelectionDialog * gui );
-// QInstaller::Installer* getInstaller();
- void setInstaller( QInstaller::Installer * installer );
- bool checkForUpdates( bool checkonly = false );
-public Q_SLOTS:
- bool searchForUpdates();
- bool update();
-Q_SIGNALS:
- void updateFinished( bool error );
-private:
- class Private;
- kdtools::pimpl_ptr< Private > d;
+ bool checkForUpdates();
+ void setVerbose(bool verbose);
};
+} // namespace QInstaller
+
#endif
diff --git a/installerbuilder/libinstaller/updatesettings.cpp b/installerbuilder/libinstaller/updatesettings.cpp
index a8045a471..8cceb0ccc 100644
--- a/installerbuilder/libinstaller/updatesettings.cpp
+++ b/installerbuilder/libinstaller/updatesettings.cpp
@@ -32,25 +32,26 @@
**************************************************************************/
#include "updatesettings.h"
-#include <QDateTime>
-#include <QSettings>
-
#include "common/errors.h"
#include "common/installersettings.h"
#include "common/repository.h"
+#include <QtCore/QDateTime>
+#include <QtCore/QSettings>
+#include <QtCore/QstringList>
+
using namespace QInstaller;
class UpdateSettings::Private
{
public:
- Private( UpdateSettings* qq )
- : q( qq )
+ Private(UpdateSettings* qq)
+ : q(qq)
{
}
private:
- UpdateSettings* const q;
+ UpdateSettings *const q;
public:
QSettings& settings()
@@ -66,16 +67,14 @@ public:
QSettings internalSettings;
static QSettings* externalSettings;
};
-
+
QSettings* UpdateSettings::Private::externalSettings = 0;
-void UpdateSettings::setSettingsSource( QSettings* settings )
-{
- Private::externalSettings = settings;
-}
+
+// -- UpdateSettings
UpdateSettings::UpdateSettings()
- : d( new Private( this ) )
+ : d(new Private(this))
{
d->settings().sync();
}
@@ -85,86 +84,84 @@ UpdateSettings::~UpdateSettings()
d->settings().sync();
}
+/* static */
+void UpdateSettings::setSettingsSource(QSettings *settings)
+{
+ Private::externalSettings = settings;
+}
+
int UpdateSettings::updateInterval() const
{
- return d->settings().value( QLatin1String( "updatesettings/interval" ), static_cast< int >( Weekly ) ).toInt();
+ return d->settings().value(QLatin1String("updatesettings/interval"), static_cast<int> (Weekly)).toInt();
}
-void UpdateSettings::setUpdateInterval( int seconds )
+void UpdateSettings::setUpdateInterval(int seconds)
{
- d->settings().setValue( QLatin1String( "updatesettings/interval" ), seconds );
+ d->settings().setValue(QLatin1String("updatesettings/interval"), seconds);
}
QString UpdateSettings::lastResult() const
{
- return d->settings().value( QLatin1String( "updatesettings/lastresult" ) ).toString();
+ return d->settings().value(QLatin1String("updatesettings/lastresult")).toString();
}
-void UpdateSettings::setLastResult( const QString& lastResult )
+void UpdateSettings::setLastResult(const QString &lastResult)
{
- d->settings().setValue( QLatin1String( "updatesettings/lastresult" ), lastResult );
+ d->settings().setValue(QLatin1String("updatesettings/lastresult"), lastResult);
}
QDateTime UpdateSettings::lastCheck() const
{
- return d->settings().value( QLatin1String( "updatesettings/lastcheck" ) ).toDateTime();
+ return d->settings().value(QLatin1String("updatesettings/lastcheck")).toDateTime();
}
-void UpdateSettings::setLastCheck( const QDateTime& lastCheck )
+void UpdateSettings::setLastCheck(const QDateTime &lastCheck)
{
- d->settings().setValue( QLatin1String( "updatesettings/lastcheck" ), lastCheck );
+ d->settings().setValue(QLatin1String("updatesettings/lastcheck"), lastCheck);
}
bool UpdateSettings::checkOnlyImportantUpdates() const
{
- return d->settings().value( QLatin1String( "updatesettings/onlyimportant" ), false ).toBool();
+ return d->settings().value(QLatin1String("updatesettings/onlyimportant"), false).toBool();
}
-void UpdateSettings::setCheckOnlyImportantUpdates( bool checkOnlyImportantUpdates )
+void UpdateSettings::setCheckOnlyImportantUpdates(bool checkOnlyImportantUpdates)
{
- d->settings().setValue( QLatin1String( "updatesettings/onlyimportant" ), checkOnlyImportantUpdates );
+ d->settings().setValue(QLatin1String("updatesettings/onlyimportant"), checkOnlyImportantUpdates);
}
-QList< Repository > UpdateSettings::repositories() const
+QList<Repository> UpdateSettings::repositories() const
{
- QList< Repository > result;
+ QSettings &settings = *(const_cast<QSettings*> (&d->settings()));
+ const int count = settings.beginReadArray(QLatin1String("updatesettings/repositories"));
- QSettings& settings = *(const_cast< QSettings* >( &d->settings() ) );
-
- const int count = settings.beginReadArray( QLatin1String( "updatesettings/repositories" ) );
- for( int i = 0; i < count; ++i )
- {
+ QList<Repository> result;
+ for (int i = 0; i < count; ++i) {
Repository rep;
- settings.setArrayIndex( i );
- rep.setUrl( d->settings().value( QLatin1String( "url" ) ).toUrl() );
- rep.setRequired( d->settings().value( QLatin1String( "required" ) ).toBool() );
- result.push_back( rep );
+ settings.setArrayIndex(i);
+ rep.setUrl(d->settings().value(QLatin1String("url")).toUrl());
+ result.append(rep);
}
settings.endArray();
- if( !result.isEmpty() )
- return result;
-
- try
- {
- return InstallerSettings::fromFileAndPrefix( QLatin1String( ":/metadata/installer-config/config.xml" ), QLatin1String( ":/metadata/installer-config/" ) ).repositories();
- }
- catch( const Error& e )
- {
- qDebug( "Could not parse config: %s", qPrintable( e.message() ) );
+ try {
+ if(result.isEmpty()) {
+ result = InstallerSettings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
+ QLatin1String(":/metadata/installer-config/")).repositories();
+ }
+ } catch (const Error &e) {
+ qDebug("Could not parse config: %s", qPrintable(e.message()));
}
return result;
}
-void UpdateSettings::setRepositories( const QList< Repository >& repositories )
+void UpdateSettings::setRepositories(const QList<Repository> &repositories)
{
- d->settings().beginWriteArray( QLatin1String( "updatesettings/repositories" ) );
- for( int i = 0; i < repositories.count(); ++i )
- {
- const Repository& rep = repositories[ i ];
- d->settings().setArrayIndex( i );
- d->settings().setValue( QLatin1String( "url" ), rep.url() );
- d->settings().setValue( QLatin1String( "required" ), rep.required() );
+ d->settings().beginWriteArray(QLatin1String("updatesettings/repositories"));
+ for (int i = 0; i < repositories.count(); ++i) {
+ const Repository &rep = repositories.at(i);
+ d->settings().setArrayIndex(i);
+ d->settings().setValue(QLatin1String("url"), rep.url());
}
d->settings().endArray();
}
diff --git a/installerbuilder/libinstaller/updatesettings.h b/installerbuilder/libinstaller/updatesettings.h
index 4ba31be7f..9031c63bb 100644
--- a/installerbuilder/libinstaller/updatesettings.h
+++ b/installerbuilder/libinstaller/updatesettings.h
@@ -30,10 +30,12 @@
#include "installer_global.h"
+QT_BEGIN_NAMESPACE
class QDateTime;
template< typename T >
class QList;
class QSettings;
+QT_END_NAMESPACE
namespace QInstaller
{
diff --git a/installerbuilder/libinstaller/updatesettingswidget.cpp b/installerbuilder/libinstaller/updatesettingswidget.cpp
deleted file mode 100644
index d28a25168..000000000
--- a/installerbuilder/libinstaller/updatesettingswidget.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt SDK**
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
-**
-** Contact: Nokia Corporation qt-info@nokia.com**
-**
-** No Commercial Usage
-**
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception version
-** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
-**
-**************************************************************************/
-#include "updatesettingswidget.h"
-#include "ui_updatesettingswidget.h"
-
-#include "common/repository.h"
-
-#include "updatesettings.h"
-
-#include <QDateTime>
-#include <QStringListModel>
-
-using namespace QInstaller;
-
-class UpdateSettingsWidget::Private
-{
-public:
- Private( UpdateSettingsWidget* qq )
- : q( qq ),
- initialized( false )
- {
- ui.setupUi( q );
- }
-
- void addUpdateSource()
- {
- const int newRow = model.rowCount();
- if( model.insertRow( newRow ) )
- ui.treeViewUpdateSources->edit( model.index( newRow, 0 ) );
- }
-
- void removeUpdateSource()
- {
- model.removeRow( ui.treeViewUpdateSources->currentIndex().row() );
- }
-
-private:
- UpdateSettingsWidget* const q;
-
-public:
- bool initialized;
- Ui::UpdateSettingsWidget ui;
- UpdateSettings settings;
- QStringListModel model;
-};
-
-UpdateSettingsWidget::UpdateSettingsWidget( QWidget* parent )
- : QWidget( parent ),
- d( new Private( this ) )
-{
-}
-
-UpdateSettingsWidget::~UpdateSettingsWidget()
-{
-}
-
-/*!
- \reimpl
-*/
-void UpdateSettingsWidget::showEvent( QShowEvent* event )
-{
- Q_UNUSED( event )
- if( d->initialized )
- return;
-
- d->ui.checkBoxCheckForUpdates->setChecked( d->settings.updateInterval() > 0 );
- d->ui.checkBoxCheckOnlyImportant->setChecked( d->settings.checkOnlyImportantUpdates() );
- switch( qAbs( d->settings.updateInterval() ) )
- {
- case UpdateSettings::Daily:
- d->ui.comboBoxFrequency->setCurrentIndex( 0 );
- break;
- case UpdateSettings::Weekly:
- d->ui.comboBoxFrequency->setCurrentIndex( 1 );
- break;
- case UpdateSettings::Monthly:
- d->ui.comboBoxFrequency->setCurrentIndex( 2 );
- break;
- }
-
- connect( d->ui.buttonAddUpdateSource, SIGNAL( clicked() ), this, SLOT( addUpdateSource() ) );
- connect( d->ui.buttonRemoveUpdateSource, SIGNAL( clicked() ), this, SLOT( removeUpdateSource() ) );
-
- connect( d->ui.buttonCheckNow, SIGNAL( clicked() ), this, SIGNAL( checkForUpdates() ) );
-
- QStringList reps;
- const QList< Repository > repositories = d->settings.repositories();
- for( QList< Repository >::const_iterator it = repositories.begin(); it != repositories.end(); ++it )
- reps.push_back( it->url().toString() );
- d->model.setStringList( reps );
- d->ui.treeViewUpdateSources->setModel( &d->model );
-
- d->ui.labelLastUpdateResult->clear();
- if( d->settings.lastResult().isEmpty() )
- d->ui.labelLastCheck->clear();
- else
- d->ui.labelLastUpdateResult->setText( d->settings.lastResult() + QLatin1Char( '\n' ) + d->settings.lastCheck().toString() );
-
- d->initialized = true;
-}
-
-void UpdateSettingsWidget::accept()
-{
- switch( d->ui.comboBoxFrequency->currentIndex() )
- {
- case 0:
- d->settings.setUpdateInterval( UpdateSettings::Daily );
- break;
- case 1:
- d->settings.setUpdateInterval( UpdateSettings::Weekly );
- break;
- case 2:
- d->settings.setUpdateInterval( UpdateSettings::Monthly );
- break;
- }
- if( !d->ui.checkBoxCheckForUpdates->isChecked() )
- d->settings.setUpdateInterval( -d->settings.updateInterval() );
- d->settings.setCheckOnlyImportantUpdates( d->ui.checkBoxCheckOnlyImportant->isChecked() );
-
- const QStringList reps = d->model.stringList();
- QList< Repository > repositories;
- Repository rep;
- for( QStringList::const_iterator it = reps.begin(); it != reps.end(); ++it )
- {
- rep.setUrl( QUrl( *it ) );
- repositories.push_back( rep );
- }
- d->settings.setRepositories( repositories );
-}
-
-#include "moc_updatesettingswidget.cpp"
diff --git a/installerbuilder/tests/tests.pro b/installerbuilder/tests/tests.pro
index 447c2d174..4cb064c52 100644
--- a/installerbuilder/tests/tests.pro
+++ b/installerbuilder/tests/tests.pro
@@ -1,10 +1,10 @@
TEMPLATE=subdirs
DESTDIR = bin
-SUBDIRS += kd7zenginetest extractarchiveoperationtest environmentvariable
+SUBDIRS += extractarchiveoperationtest environmentvariable
-unix:test.commands=./bin/kd7zenginetest && ./bin/extractarchiveoperationtest
-win32:test.commands=bin/kd7zenginetest.exe && bin/extractarchiveoperationtest.exe
+unix:test.commands=./bin/extractarchiveoperationtest
+win32:test.commands=bin\\extractarchiveoperationtest.exe
test.target=test
test.depends = $(TARGET)
diff --git a/installerfw.pro b/installerfw.pro
index 796b8a025..7009c613f 100644
--- a/installerfw.pro
+++ b/installerfw.pro
@@ -1,6 +1,6 @@
TEMPLATE=subdirs
CONFIG += ordered
-SUBDIRS += installerbuilder tools examples
+SUBDIRS += installerbuilder examples
test.target=test
diff --git a/tools/fileengineclient/fileengineclient.cpp b/tools/fileengineclient/fileengineclient.cpp
new file mode 100644
index 000000000..c8d56cc96
--- /dev/null
+++ b/tools/fileengineclient/fileengineclient.cpp
@@ -0,0 +1,183 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <fsengineclient.h>
+
+#include <QProcess>
+#include <QApplication>
+#include <QThread>
+#include <QDebug>
+
+class OutputHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ OutputHandler(QProcess* processWrapper, QObject *parent = 0)
+ : QObject (parent)
+ {
+ m_process = processWrapper;
+ QObject::connect(m_process, SIGNAL(readyRead()),
+ this, SLOT(readProcessOutput()), Qt::DirectConnection );
+ }
+ void clearSavedOutPut() { m_savedOutPut.clear(); }
+ QByteArray savedOutPut() { return m_savedOutPut; }
+
+public slots:
+ void readProcessOutput()
+ {
+ Q_ASSERT(m_process);
+ Q_ASSERT(QThread::currentThread() == m_process->thread());
+ if (QThread::currentThread() != m_process->thread()) {
+ qDebug() << Q_FUNC_INFO << QLatin1String(" can only be called from the same thread as the process is.") ;
+ }
+ const QByteArray output = m_process->readAll();
+ if( !output.isEmpty() ) {
+ m_savedOutPut.append(output);
+ qDebug() << output;
+ }
+ }
+
+private:
+ QProcess* m_process;
+ QByteArray m_savedOutPut;
+};
+
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+
+ QString fileName(QLatin1String("give_me_some_output.bat"));
+ QFile file(fileName);
+ if (file.exists() && !file.remove()) {
+ qFatal( qPrintable( QString("something is wrong, can not delete: %1").arg(file.fileName()) ) );
+ return -1;
+ }
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ qFatal( qPrintable( QString("something is wrong, can not open for writing to: %1").arg(file.fileName()) ) );
+ return -2;
+ }
+
+ QTextStream out(&file);
+ out << QLatin1String("echo mega test output");
+ if (!file.flush())
+ {
+ qFatal( qPrintable( QString("something is wrong, can not write to: %1").arg(file.fileName()) ) );
+ return -3;
+ }
+ file.close();
+
+
+//first run as a normal QProcess
+ QByteArray firstOutPut;
+ {
+ QProcess process;
+ OutputHandler outputer(&process);
+
+ process.start(fileName);
+ qDebug() << "1";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ process.waitForStarted();
+ qDebug() << "2";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ process.waitForFinished();
+ qDebug() << "3";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ firstOutPut = outputer.savedOutPut();
+ }
+//first run as a normal QProcess
+ QByteArray secondOutPut;
+ {
+ FSEngineClientHandler* engineClientHandler = new FSEngineClientHandler();
+ engineClientHandler->enableTestMode();
+ engineClientHandler->init(39999);
+ engineClientHandler->setActive(true);
+
+ QProcess process;
+ OutputHandler outputer(&process);
+
+ process.start(fileName);
+ qDebug() << "1";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ process.waitForStarted();
+ qDebug() << "2";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ process.waitForFinished();
+ qDebug() << "3";
+ {
+ const QByteArray output = process.readAll();
+ if( !output.isEmpty() ) {
+ qDebug() << output;
+ }
+ }
+ secondOutPut = outputer.savedOutPut();
+ }
+
+ if (firstOutPut != secondOutPut) {
+ qFatal( qPrintable( QString("Test failed: output is different between a normal QProcess and QProcessWrapper").arg(file.fileName()) ) );
+ return -2;
+ } else {
+ qDebug() << QLatin1String("Test OK: QProcess works as expected.");
+ }
+
+ return app.exec();
+}
+
+#include "fileengineclient.moc"
diff --git a/tools/fileengineclient/fileengineclient.pro b/tools/fileengineclient/fileengineclient.pro
new file mode 100644
index 000000000..a61aa4e91
--- /dev/null
+++ b/tools/fileengineclient/fileengineclient.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+DEPENDPATH += . .. ../../installerbuilder/common
+INCLUDEPATH += . ..
+
+DESTDIR = ../../installerbuilder/bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+include(../../installerbuilder/libinstaller/libinstaller.pri)
+
+# Input
+SOURCES += fileengineclient.cpp
+
+LIBS = -L../../installerbuilder/lib -linstaller $$LIBS
diff --git a/installerbuilder/common/kd7zenginehandler.cpp b/tools/fileengineserver/fileengineserver.cpp
index 7fbe7ed90..017952f38 100644
--- a/installerbuilder/common/kd7zenginehandler.cpp
+++ b/tools/fileengineserver/fileengineserver.cpp
@@ -30,12 +30,14 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-#include "kd7zenginehandler.h"
+#include <fsengineserver.h>
-#include "kd7zengine.h"
+#include <QApplication>
-QAbstractFileEngine* KD7zEngineHandler::create( const QString& fileName ) const
+int main(int argc, char **argv)
{
- return fileName.startsWith( QString::fromLatin1( "7z://" ), Qt::CaseInsensitive ) ? new KD7zEngine( fileName ) : 0;
+ QApplication app(argc, argv);
+ FSEngineServer server(39999);
+ server.enableTestMode();
+ return app.exec();
}
-
diff --git a/tools/fileengineserver/fileengineserver.pro b/tools/fileengineserver/fileengineserver.pro
new file mode 100644
index 000000000..89cd0ffc9
--- /dev/null
+++ b/tools/fileengineserver/fileengineserver.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+DEPENDPATH += . .. ../../installerbuilder/common
+INCLUDEPATH += . ..
+
+DESTDIR = ../../installerbuilder/bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+include(../../installerbuilder/libinstaller/libinstaller.pri)
+
+# Input
+SOURCES += fileengineserver.cpp
+
+LIBS = -L../../installerbuilder/lib -linstaller $$LIBS
diff --git a/tools/operationrunner/operationrunner.pro b/tools/operationrunner/operationrunner.pro
index 9cf0c9299..a2882cbd7 100644
--- a/tools/operationrunner/operationrunner.pro
+++ b/tools/operationrunner/operationrunner.pro
@@ -1,5 +1,4 @@
TEMPLATE = app
-TARGET = operationrunner
DEPENDPATH += . .. ../../installerbuilder/common
INCLUDEPATH += . ..
@@ -8,8 +7,6 @@ DESTDIR = ../../installerbuilder/bin
CONFIG += console
CONFIG -= app_bundle
-QT += xml
-
include(../../installerbuilder/libinstaller/libinstaller.pri)
# Input
diff --git a/installerbuilder/common/blockingbuffer.h b/tools/repocompare/main.cpp
index 2868e3650..1914cade3 100644
--- a/installerbuilder/common/blockingbuffer.h
+++ b/tools/repocompare/main.cpp
@@ -2,10 +2,17 @@
**
** This file is part of Qt SDK**
**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
**
** Contact: Nokia Corporation qt-info@nokia.com**
**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
@@ -23,25 +30,14 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-#ifndef BLOCKINGBUFFER_H
-#define BLOCKINGBUFFER_H
-
-#include <QtGlobal>
+#include <QtGui/QApplication>
+#include "mainwindow.h"
-namespace QInstaller {
- class BlockingBuffer {
- public:
- explicit BlockingBuffer( int size );
- ~BlockingBuffer();
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
- qint64 read( char* buf, qint64 max);
- qint64 write( const char* buf, qint64 max );
- void close();
-
- private:
- class Private;
- Private* const d;
- };
+ return a.exec();
}
-
-#endif // BLOCKINGBUFFER_H
diff --git a/tools/repocompare/mainwindow.cpp b/tools/repocompare/mainwindow.cpp
new file mode 100644
index 000000000..82a6ef38f
--- /dev/null
+++ b/tools/repocompare/mainwindow.cpp
@@ -0,0 +1,235 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include <QtCore/QFile>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QMapIterator>
+#include <QtCore/QTextStream>
+#include <QtCore/QUrl>
+#include <QtCore/QXmlStreamReader>
+#include <QtGui/QMessageBox>
+#include <QtGui/QFileDialog>
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ui->productionButton, SIGNAL(clicked()), this, SLOT(getProductionRepository()));
+ connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(getUpdateRepository()));
+ manager = new QNetworkAccessManager(this);
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(receiveRepository(QNetworkReply*)));
+ connect(ui->exportButton, SIGNAL(clicked()), this, SLOT(createExportFile()));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::getProductionRepository()
+{
+ QUrl url = this->ui->productionRepo->currentText();
+ if (!url.isValid()) {
+ QMessageBox::critical(this, "Error", "Specified URL is not valid");
+ return;
+ }
+
+ if (productionFile.isOpen())
+ productionFile.close();
+ if (!productionFile.open()) {
+ QMessageBox::critical(this, "Error", "Could not open File");
+ return;
+ }
+
+ QNetworkRequest request(url);
+ productionReply = manager->get(request);
+}
+
+void MainWindow::getUpdateRepository()
+{
+ QUrl url = this->ui->updateRepo->currentText();
+ if (!url.isValid()) {
+ QMessageBox::critical(this, "Error", "Specified URL is not valid");
+ return;
+ }
+
+ if (updateFile.isOpen())
+ updateFile.close();
+ if (!updateFile.open()) {
+ QMessageBox::critical(this, "Error", "Could not open File");
+ return;
+ }
+
+ QNetworkRequest request(url);
+ updateReply = manager->get(request);
+}
+
+void MainWindow::receiveRepository(QNetworkReply *reply)
+{
+ QByteArray data = reply->readAll();
+ reply->deleteLater();
+ if (reply == productionReply)
+ createRepositoryMap(data, productionMap);
+ else if (reply == updateReply)
+ createRepositoryMap(data, updateMap);
+
+ if (productionMap.size() && updateMap.size())
+ compareRepositories();
+}
+
+void MainWindow::createRepositoryMap(const QByteArray &data, QMap<QString, RepositoryDescription> &map)
+{
+ QXmlStreamReader reader(data);
+ QString currentItem;
+ RepositoryDescription currentDescription;
+ while (!reader.atEnd()) {
+ QXmlStreamReader::TokenType type = reader.readNext();
+ if (type == QXmlStreamReader::StartElement) {
+ if (reader.name() == "PackageUpdate") {
+ // new package
+ if (!currentItem.isEmpty())
+ map.insert(currentItem, currentDescription);
+ currentDescription.updateText.clear();
+ currentDescription.version.clear();
+ currentDescription.checksum.clear();
+ }
+ if (reader.name() == "SHA1")
+ currentDescription.checksum = reader.readElementText();
+ else if (reader.name() == "Version")
+ currentDescription.version = reader.readElementText();
+ else if (reader.name() == "ReleaseDate")
+ currentDescription.releaseDate = QDate::fromString(reader.readElementText(), "yyyy-MM-dd");
+ else if (reader.name() == "UpdateText")
+ currentDescription.updateText = reader.readElementText();
+ else if (reader.name() == "Name")
+ currentItem = reader.readElementText();
+ }
+ }
+ // Insert the last item
+ if (!currentItem.isEmpty())
+ map.insert(currentItem, currentDescription);
+}
+
+static qreal createVersionNumber(const QString &text)
+{
+ QStringList items = text.split(QLatin1Char('.'));
+ QString last = items.takeLast();
+ items.append(last.split(QLatin1Char('-')));
+
+ qreal value = 0;
+ if (items.count() == 4)
+ value += qreal(0.01) * items.takeLast().toInt();
+
+ int multiplier = 10000;
+ do {
+ value += multiplier * items.takeFirst().toInt();
+ multiplier /= 100;
+ } while (items.count());
+
+ return value;
+}
+
+void MainWindow::compareRepositories()
+{
+ // First we put everything into the treeview
+ for (int i = 0; i < 2; ++i) {
+ QMap<QString, RepositoryDescription>* map;
+ if (i == 0)
+ map = &productionMap;
+ else
+ map = &updateMap;
+ int indexIncrement = 4*i;
+ for (QMap<QString, RepositoryDescription>::iterator it = map->begin(); it != map->end(); ++it) {
+ QList<QTreeWidgetItem*> list = ui->treeWidget->findItems(it.key(), Qt::MatchExactly);
+ QTreeWidgetItem* item;
+ if (list.size())
+ item = list.at(0);
+ else
+ item = new QTreeWidgetItem(ui->treeWidget);
+
+ item->setText(0, it.key());
+ item->setText(indexIncrement + 3, it.value().version);
+ item->setText(indexIncrement + 4, it.value().releaseDate.toString("yyyy-MM-dd"));
+ item->setText(indexIncrement + 5, it.value().checksum);
+ item->setText(indexIncrement + 6, it.value().updateText);
+ }
+ }
+
+ // Now iterate over the items and check where an update is needed
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i);
+ if (item->text(3).isEmpty() && !item->text(7).isEmpty()) {
+ item->setText(1, "Yes");
+ item->setText(2, "New Component");
+ } else if (item->text(7).isEmpty()) {
+ item->setText(2, "Caution: component removed");
+ } else if (createVersionNumber(item->text(3)) < createVersionNumber(item->text(7))) {
+ // New Version
+ item->setText(1, "Yes");
+ // Check update date
+ QDate productionDate = QDate::fromString(item->text(4), "yyyy-MM-dd");
+ QDate updateDate = QDate::fromString(item->text(8), "yyyy-MM-dd");
+ if (updateDate <= productionDate)
+ item->setText(2, "Error: Date not correct");
+ else if (item->text(6) == item->text(10) || item->text(10).isEmpty())
+ item->setText(2, "Error: Update text wrong");
+ else
+ item->setText(2, "Ok");
+ }
+ }
+}
+
+void MainWindow::createExportFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, "Export File");
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadWrite)) {
+ QMessageBox::critical(this, "Error", "Could not open File for saving");
+ return;
+ }
+
+ QTextStream s(&file);
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i);
+ if (item->text(1) == "Yes" && item->text(2) == "Ok")
+ s << item->text(0) << "\n";
+ }
+ s.flush();
+ file.close();
+}
diff --git a/installerbuilder/installerbase/maintabwidget.cpp b/tools/repocompare/mainwindow.h
index dd3ae0815..40b03cf2d 100644
--- a/installerbuilder/installerbase/maintabwidget.cpp
+++ b/tools/repocompare/mainwindow.h
@@ -30,42 +30,55 @@
** (qt-info@nokia.com).
**
**************************************************************************/
-#include "maintabwidget.h"
-#include <QCloseEvent>
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
-class MainTabWidget::Private
-{
-public:
- bool closeAllowed;
-};
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QUrl>
+#include <QtCore/QDate>
+#include <QtCore/QString>
+#include <QtCore/QMap>
+#include <QtGui/QMainWindow>
+#include <QtNetwork/QNetworkAccessManager>
-MainTabWidget::MainTabWidget( QWidget* parent )
- : QTabWidget( parent ), d ( new Private () )
-{
- d->closeAllowed = false;
- setWindowFlags( windowFlags() | Qt::Dialog );
+namespace Ui {
+ class MainWindow;
}
-void MainTabWidget::setCloseWithoutWarning( bool value )
-{
- d->closeAllowed = value;
-}
+struct RepositoryDescription {
+ QString version;
+ QDate releaseDate;
+ QString checksum;
+ QString updateText;
+};
-MainTabWidget::~MainTabWidget()
+class MainWindow : public QMainWindow
{
-}
+ Q_OBJECT
-void MainTabWidget::closeEvent ( QCloseEvent * event )
-{
- if ( d->closeAllowed )
- {
- QTabWidget::closeEvent( event );
- //event->accept();
- }
- else
- {
- emit closeRequested();
- event->ignore();
- }
-}
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+ void compareRepositories();
+
+public slots:
+ void receiveRepository(QNetworkReply* reply);
+ void getProductionRepository();
+ void getUpdateRepository();
+ void createExportFile();
+
+private:
+ void createRepositoryMap(const QByteArray &data, QMap<QString, RepositoryDescription> &map);
+
+ Ui::MainWindow *ui;
+ QTemporaryFile productionFile;
+ QTemporaryFile updateFile;
+ QNetworkReply *productionReply;
+ QNetworkReply *updateReply;
+ QNetworkAccessManager *manager;
+ QMap<QString, RepositoryDescription> productionMap;
+ QMap<QString, RepositoryDescription> updateMap;
+};
+#endif // MAINWINDOW_H
diff --git a/tools/repocompare/mainwindow.ui b/tools/repocompare/mainwindow.ui
new file mode 100644
index 000000000..c768b840a
--- /dev/null
+++ b/tools/repocompare/mainwindow.ui
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>877</width>
+ <height>613</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>RepoCompare</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Production Repository:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="productionRepo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="productionButton">
+ <property name="text">
+ <string>Receive</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Update Repository:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="updateRepo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="updateButton">
+ <property name="text">
+ <string>Receive</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <column>
+ <property name="text">
+ <string>Component Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Update required</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Version</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Date</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Checksum</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Update Text</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Version</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Date</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Checksum</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Update Text</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="exportButton">
+ <property name="text">
+ <string>Export Update File</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>877</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionExit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <action name="actionExit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tools/repocompare/repocompare.pro b/tools/repocompare/repocompare.pro
new file mode 100644
index 000000000..349ac01e9
--- /dev/null
+++ b/tools/repocompare/repocompare.pro
@@ -0,0 +1,18 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-04-04T09:43:46
+#
+#-------------------------------------------------
+
+QT += core gui network
+
+TARGET = repocompare
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui