├── .gitignore ├── KDUpdater.pri ├── KDUpdater.pro ├── LICENSE.GPL.txt ├── LICENSE.LGPL.txt ├── README.md ├── examples ├── common.h ├── compatexample │ ├── appdata │ │ ├── Packages.xml │ │ ├── headers.js │ │ ├── object1.txt │ │ └── object2.txt │ ├── compatexample.pro │ ├── src │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ └── mainwindow.h │ └── updateserver │ │ ├── Compat2.kvz │ │ ├── Compat2 │ │ ├── UpdateInstructions.xml │ │ ├── application.qss │ │ └── headers.js │ │ ├── Objects1.kvz │ │ ├── Objects1 │ │ ├── UpdateInstructions.xml │ │ ├── object1.txt │ │ └── object2.txt │ │ ├── Objects2.kvz │ │ ├── Objects2 │ │ ├── UpdateInstructions.xml │ │ ├── object1.txt │ │ └── object2.txt │ │ └── Updates.xml ├── examples.pro ├── firmwaredemo │ ├── appdata │ │ ├── Packages.xml │ │ ├── headers.js │ │ ├── l4rfirmware.txt │ │ └── psmfirmware.txt │ ├── firmwaredemo.pro │ ├── src │ │ ├── helpdialog.cpp │ │ ├── helpdialog.h │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ └── mainwindow.h │ └── updateserver │ │ ├── Application2.kvz │ │ ├── Application2 │ │ ├── UpdateInstructions.xml │ │ ├── application.qss │ │ └── headers.js │ │ ├── Firmware1.kvz │ │ ├── Firmware1 │ │ ├── UpdateInstructions.xml │ │ ├── l4rfirmware.txt │ │ └── psmfirmware.txt │ │ ├── Firmware2.kvz │ │ ├── Firmware2 │ │ ├── UpdateInstructions.xml │ │ ├── l4rfirmware.txt │ │ └── psmfirmware.txt │ │ └── Updates.xml ├── kdupdaterdemo │ ├── kdupdaterdemo.pro │ ├── kdupdaterdemo.qrc │ ├── kdupdaterdemo │ │ └── kdupdaterdemo.pro │ ├── kdupdaterdemov2 │ │ ├── kdupdaterdemov2.pro │ │ └── postbuild.bat │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── packages.xml │ ├── repository │ │ ├── Updates.xml │ │ ├── kdupdaterdemo_mac │ │ │ └── UpdateInstructions.xml │ │ ├── kdupdaterdemo_unix │ │ │ └── UpdateInstructions.xml │ │ └── kdupdaterdemo_win │ │ │ └── UpdateInstructions.xml │ ├── updater.cpp │ ├── updater.h │ ├── updaterdialog.cpp │ ├── updaterdialog.h │ ├── windowsrunningapplicationupdateoperation.cpp │ └── windowsrunningapplicationupdateoperation.h └── simpleexample │ ├── appdata │ └── Packages.xml │ ├── simpleexample.pro │ ├── src │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ └── mainwindow.ui │ └── updateserver │ ├── Update1.kvz │ ├── Update1 │ ├── UpdateInstructions.xml │ └── gpl-1.0.txt │ ├── Update2.kvz │ ├── Update2 │ ├── UpdateInstructions.xml │ └── gpl-2.0.txt │ ├── Update3.kvz │ ├── Update3 │ ├── UpdateInstructions.xml │ └── gpl-3.0.txt │ ├── Update4.kvz │ ├── Update4 │ ├── UpdateInstructions.xml │ └── kdtools.png │ └── Updates.xml ├── src ├── addupdatesourcedialog.ui ├── doxygen.cpp ├── kdautopointer.cpp ├── kdautopointer.h ├── kdgenericfactory.cpp ├── kdgenericfactory.h ├── kdlockedsharedmemorypointer.cpp ├── kdlockedsharedmemorypointer.h ├── kdmetamethoditerator.cpp ├── kdmetamethoditerator.h ├── kdrect.cpp ├── kdrect.h ├── kdsavefile.cpp ├── kdsavefile.h ├── kdsemaphorereleaser.cpp ├── kdsemaphorereleaser.h ├── kdsharedmemorylocker.cpp ├── kdsharedmemorylocker.h ├── kdtoolsglobal.cpp ├── kdtoolsglobal.h ├── kdupdater.dox ├── kdupdater.h ├── kdupdaterapplication.cpp ├── kdupdaterapplication.h ├── kdupdaterdemo.dox ├── kdupdaterfiledownloader.cpp ├── kdupdaterfiledownloader.h ├── kdupdaterfiledownloader_mac.cpp ├── kdupdaterfiledownloader_p.h ├── kdupdaterfiledownloaderfactory.cpp ├── kdupdaterfiledownloaderfactory.h ├── kdupdaterpackagesinfo.cpp ├── kdupdaterpackagesinfo.h ├── kdupdaterpackagesmodel.cpp ├── kdupdaterpackagesmodel.h ├── kdupdaterpackagesview.cpp ├── kdupdaterpackagesview.h ├── kdupdatertarget.cpp ├── kdupdatertarget.h ├── kdupdatertask.cpp ├── kdupdatertask.h ├── kdupdaterufcompresscommon.cpp ├── kdupdaterufcompresscommon_p.h ├── kdupdaterufuncompressor.cpp ├── kdupdaterufuncompressor_p.h ├── kdupdaterupdate.cpp ├── kdupdaterupdate.h ├── kdupdaterupdatefinder.cpp ├── kdupdaterupdatefinder.h ├── kdupdaterupdateinstaller.cpp ├── kdupdaterupdateinstaller.h ├── kdupdaterupdateoperation.cpp ├── kdupdaterupdateoperation.h ├── kdupdaterupdateoperationfactory.cpp ├── kdupdaterupdateoperationfactory.h ├── kdupdaterupdateoperations.cpp ├── kdupdaterupdateoperations_p.h ├── kdupdaterupdatesdialog.cpp ├── kdupdaterupdatesdialog.h ├── kdupdaterupdatesinfo.cpp ├── kdupdaterupdatesinfo_p.h ├── kdupdaterupdatesmodel.cpp ├── kdupdaterupdatesmodel.h ├── kdupdaterupdatesourcesinfo.cpp ├── kdupdaterupdatesourcesinfo.h ├── kdupdaterupdatesourcesmodel.cpp ├── kdupdaterupdatesourcesmodel.h ├── kdupdaterupdatesourcesview.cpp ├── kdupdaterupdatesourcesview.h ├── kdvariantconverter.cpp ├── kdvariantconverter.h ├── pimpl_ptr.cpp ├── pimpl_ptr.h ├── src.pri ├── src.pro ├── updatefileformat.dox ├── updatesdialog.ui └── xmlformats.dox └── tools ├── tools.pro ├── ufcreator ├── kdupdaterufcompressor.cpp ├── kdupdaterufcompressor.h ├── main.cpp └── ufcreator.pro └── ufextractor ├── main.cpp └── ufextractor.pro /.gitignore: -------------------------------------------------------------------------------- 1 | # common 2 | *~ 3 | *.a 4 | *.core 5 | *.moc 6 | *.o 7 | *.obj 8 | *.orig 9 | *.rej 10 | *.so 11 | *_pch.h.cpp 12 | *_resource.rc 13 | *.qm 14 | .#* 15 | *.*# 16 | tags 17 | .DS_Store 18 | *.debug 19 | Makefile* 20 | *.prl 21 | *.app 22 | moc_*.cpp 23 | ui_*.h 24 | qrc_*.cpp 25 | Thumbs.db 26 | 27 | # python temporary files 28 | *.pyc 29 | 30 | # qtcreator generated files 31 | *.pro.user* 32 | *.qmlproject.user* 33 | *.pluginspec 34 | 35 | # xemacs temporary files 36 | *.flc 37 | 38 | # Vim temporary files 39 | .*.swp 40 | 41 | # Visual Studio generated files 42 | *.ib_pdb_index 43 | *.idb 44 | *.ilk 45 | *.pdb 46 | *.sln 47 | *.suo 48 | *.vcproj 49 | *.vcxproj* 50 | *vcproj.*.*.user 51 | *vcxproj.*.*.user 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | 56 | # MinGW generated files 57 | *.Debug 58 | *.Release 59 | 60 | # Directories to ignore 61 | # --------------------- 62 | 63 | temp 64 | debug 65 | lib/* 66 | lib64/* 67 | release 68 | doc/html/* 69 | ipch/* 70 | 71 | .rcc 72 | .pch 73 | 74 | # Binaries 75 | # -------- 76 | bin/** 77 | 78 | # examples 79 | examples/kdupdater/*/application/appdir/** 80 | -------------------------------------------------------------------------------- /KDUpdater.pri: -------------------------------------------------------------------------------- 1 | ## Common file which will be included by all other .pro files. 2 | 3 | # We don't support Qt4 4 | lessThan(QT_MAJOR_VERSION, 5) { 5 | message("Cannot build KDUpdater with Qt $${QT_VERSION}.") 6 | error("Use at least Qt 5.0") 7 | } 8 | 9 | # Generate proper library name 10 | SAVED_TEMPLAET = $$TEMPLATE 11 | TEMPLATE = fake_lib 12 | LIBNAME = $$qtLibraryTarget(hkdupdater) 13 | TEMPLATE = $$SAVED_TEMPLAET 14 | 15 | KDUPDATER_SOURCE_TREE = $$PWD 16 | isEmpty(KDUPDATER_BUILD_TREE): KDUPDATER_BUILD_TREE = $$shadowed($$PWD) 17 | 18 | KDUPDATER_LIB_PATH = $$KDUPDATER_BUILD_TREE/lib 19 | KDUPDATER_BIN_PATH = $$KDUPDATER_BUILD_TREE/bin 20 | 21 | # link to the library 22 | !build_kdupdater_library { 23 | config += link_prl 24 | INCLUDEPATH += $$KDUPDATER_SOURCE_TREE/src 25 | LIBS += -L$$KDUPDATER_LIB_PATH -l$$LIBNAME 26 | unix:QMAKE_RPATHDIR += $$KDUPDATER_LIB_PATH 27 | DEFINES += KDUPDATER_SHARED 28 | } 29 | 30 | defineTest(qmakeEcho) { 31 | content = $$1 32 | operator = $$2 33 | file = $$3 34 | 35 | line = "\"$$content\"" 36 | 37 | win32 { 38 | line = $$replace(content, "<", "^<") 39 | line = $$replace(line, ">", "^>") 40 | } 41 | 42 | system("echo $$line $$operator $$file") 43 | return(true) 44 | } 45 | 46 | defineTest(qmakeCleanAndCopy) { 47 | dir = "$$1" 48 | dest = "$$2" 49 | 50 | win32 { 51 | dir = $$replace(dir, "/", "\\") 52 | dest = $$replace(dest, "/", "\\") 53 | exists($$dest) { 54 | system("del /S /Q \"$$dest\"")|error("Cannot remove $$dest") 55 | } 56 | system("xcopy /E /I /Y \"$$dir\" \"$$dest\"")|error("Cannot copy $$dir to $$dest") 57 | } else { 58 | exists($$dest) { 59 | system("rm -rf \"$$dest\"")|error("Cannot remove $$dest") 60 | } else { 61 | system("mkdir -p \"$$dest\"") 62 | } 63 | system("cp -r \"$$dir\" \"$$dest\"")|error("Cannot copy $$dir to $$dest") 64 | } 65 | return(true) 66 | } 67 | -------------------------------------------------------------------------------- /KDUpdater.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | CONFIG += ordered 4 | 5 | SUBDIRS += src 6 | SUBDIRS += tools 7 | SUBDIRS += examples 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | About KDUpdater 2 | ================ 3 | 4 | Original source file taken from KD Tools 2.3.0 5 | 6 | http://www.kdab.com/kdab-products/kd-tools/ 7 | 8 | How to build 9 | ============== 10 | 11 | This project can only be compiled using Qt5. 12 | 13 | Just open the KDUpdater.pro using Qt Creator, then build&run should work. 14 | 15 | Examples 16 | ================= 17 | 18 | how does kdupdaterdemo work 19 | ---------------------------- 20 | 21 | First, Updates.xml and UpdateInstructions.xml will be copied from 22 | `examples/data/kdupdaterdemo` to `examples/kdupdaterdemo/updateserver/` 23 | 24 | Then, generated application kdupdaterdemov2 will be copied to the 25 | `examples/kdupdaterdemo/updateserver/kdupdaterdemo_{win,unix,mac}` directory 26 | 27 | Finally, ufcreater is used to convert the kdupdaterdemo_{win, unix, mac} 28 | to a .kvz file. 29 | 30 | So, when kdupdaterdemo is running, it will get Updates.xml from the updateserver first, then download the 31 | .kvz file which contains UpdateInstructions.xml and the new kdupdaterdemo. 32 | -------------------------------------------------------------------------------- /examples/common.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef COMMON_H 24 | #define COMMON_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | 33 | static bool cleanAppDir() 34 | { 35 | // Delete application directory 36 | QDir appDir( QFile::decodeName( EXAMPLE_APP_DIR ) + QLatin1String( "_tmp" ) ); 37 | QString command; 38 | if ( appDir.exists() ) { 39 | #ifdef Q_OS_WIN32 40 | command = QString::fromLatin1( "del /S /Q %1" ).arg( appDir.path() ); 41 | #else 42 | command = QString::fromLatin1( "rm -rf %1" ).arg( appDir.path() ); 43 | #endif 44 | qDebug( "%s", command.toLatin1().constData() ); 45 | const int ret = system( command.toLatin1().constData() ); 46 | return ret == 0; 47 | } 48 | return false; 49 | } 50 | 51 | static bool restoreAppDir() { 52 | // Restore application directory 53 | cleanAppDir(); 54 | QString command; 55 | QDir appDir( QFile::decodeName( EXAMPLE_APP_DIR ) + QLatin1String( "_tmp" ) ); 56 | QDir backupDir( QFile::decodeName( EXAMPLE_APP_DIR ) ); 57 | if ( backupDir.exists() ) { 58 | #ifdef Q_OS_WIN32 59 | command = QString::fromLatin1( "xcopy /E /I /Y %1 %2" ).arg( backupDir.path(), appDir.path() ); 60 | #else 61 | command = QString::fromLatin1( "cp -r %1 %2" ).arg( backupDir.path(), appDir.path() ); 62 | #endif 63 | qDebug( "%s", command.toLatin1().constData() ); 64 | const int ret = system( command.toLatin1().constData() ); 65 | return ret == 0; 66 | } 67 | return false; 68 | } 69 | 70 | class AppDirSaver { 71 | public: 72 | AppDirSaver() { restoreAppDir(); } 73 | ~AppDirSaver() { cleanAppDir(); } 74 | }; 75 | 76 | #endif /* COMMON_H */ 77 | 78 | -------------------------------------------------------------------------------- /examples/compatexample/appdata/Packages.xml: -------------------------------------------------------------------------------- 1 | 2 | CompatExample 3 | 1.0 4 | 1 5 | 6 | Objects 7 | 8 | Objects used in the application 9 | 10 | 1.0 11 | 2008-04-09 12 | 2008-04-09 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/compatexample/appdata/headers.js: -------------------------------------------------------------------------------- 1 | 2 | function headers() 3 | { 4 | return "Id, Name, Version"; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /examples/compatexample/appdata/object1.txt: -------------------------------------------------------------------------------- 1 | Object1 2 | 1.0 3 | -------------------------------------------------------------------------------- /examples/compatexample/appdata/object2.txt: -------------------------------------------------------------------------------- 1 | Object2 2 | 1.0 3 | -------------------------------------------------------------------------------- /examples/compatexample/compatexample.pro: -------------------------------------------------------------------------------- 1 | include (../../KDUpdater.pri) 2 | TEMPLATE = app 3 | DESTDIR = $$KDUPDATER_BIN_PATH 4 | 5 | QT += widgets script 6 | TARGET = CompatExample 7 | 8 | EXAMPLE_APP_DIR="$$OUT_PWD/apptempdata" 9 | 10 | DEFINES += EXAMPLE_APP_DIR="\\\"$$EXAMPLE_APP_DIR\\\"" 11 | 12 | !build_pass:qmakeCleanAndCopy("$$PWD/appdata", "$$EXAMPLE_APP_DIR") 13 | 14 | UPDATEURL = file:///$$PWD/updateserver 15 | UPDATEURL = $$replace(UPDATEURL, file:////, file:///) 16 | 17 | qmakeEcho("", ">", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 18 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 19 | qmakeEcho(" LocalSource", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 20 | qmakeEcho(" Local Update Source", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 21 | qmakeEcho(" Update source from the local file system", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 22 | qmakeEcho(" $$UPDATEURL", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 23 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 24 | qmakeEcho("", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 25 | 26 | SOURCES += src/main.cpp src/mainwindow.cpp 27 | HEADERS += src/mainwindow.h 28 | 29 | -------------------------------------------------------------------------------- /examples/compatexample/src/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef EXAMPLE_APP_DIR 24 | #error "EXAMPLE_APP_DIR not set. It is necessary for this example application to find its application directory." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "mainwindow.h" 33 | #include "../../common.h" 34 | 35 | int main(int argc, char** argv) 36 | { 37 | QApplication a(argc, argv); 38 | 39 | const AppDirSaver saver; 40 | 41 | KDUpdater::Target target; 42 | target.setDirectory( QFile::decodeName( EXAMPLE_APP_DIR ) ); 43 | 44 | MainWindow window( &target ); 45 | window.show(); 46 | 47 | return a.exec(); 48 | } 49 | -------------------------------------------------------------------------------- /examples/compatexample/src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef MAINWINDOW_H 24 | #define MAINWINDOW_H 25 | 26 | #include 27 | #include 28 | 29 | QT_BEGIN_NAMESPACE 30 | class QTableWidget; 31 | QT_END_NAMESPACE 32 | 33 | namespace KDUpdater { 34 | class Target; 35 | } 36 | 37 | class MainWindow : public QMainWindow 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit MainWindow( KDUpdater::Target * target, QWidget * parent=0 ); 43 | ~MainWindow(); 44 | 45 | private Q_SLOTS: 46 | void onAdd1(); 47 | void onAdd2(); 48 | void onUpdateSelected(); 49 | void onUpdate(); 50 | void onUpdateCompat(); 51 | 52 | private: 53 | void loadApplicationData(); 54 | void updateObject(const QString &objectName, int object); 55 | void displayObject(int object, int row); 56 | void updatePackage( bool findCompat ); 57 | 58 | KDUpdater::Target * m_target; 59 | QTableWidget *m_table; 60 | int m_lastId; 61 | QDir m_appDir; 62 | QDir m_objectsDir; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Compat2.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/compatexample/updateserver/Compat2.kvz -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Compat2/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Application2 4 | 2.0 5 | 6 | 7 | Copy 8 | {CURPATH}/application.qss 9 | {TARGETDIR}/application.qss 10 | 11 | 12 | 13 | Copy 14 | {CURPATH}/headers.js 15 | {TARGETDIR}/headers.js 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Compat2/application.qss: -------------------------------------------------------------------------------- 1 | QToolBar { 2 | background-color: beige; 3 | } 4 | 5 | QToolBar > QWidget { 6 | background-color: beige; 7 | } 8 | 9 | QToolTip { 10 | border: 2px solid darkkhaki; 11 | padding: 5px; 12 | border-radius: 3px; 13 | background-color: beige; 14 | } 15 | 16 | QTableView { 17 | border: 0; 18 | selection-background-color: darkkhaki; 19 | background-color: beige; 20 | } 21 | 22 | QTableView > QWidget { 23 | background-color: beige; 24 | } 25 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Compat2/headers.js: -------------------------------------------------------------------------------- 1 | 2 | function headers() 3 | { 4 | return "Id, Name, Version, Features"; 5 | } 6 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects1.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/compatexample/updateserver/Objects1.kvz -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects1/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/object1.txt 6 | {APPDIR}/object1.txt 7 | 8 | 9 | 10 | Copy 11 | {CURPATH}/object2.txt 12 | {APPDIR}/object2.txt 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects1/object1.txt: -------------------------------------------------------------------------------- 1 | Object1 2 | 1.1 3 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects1/object2.txt: -------------------------------------------------------------------------------- 1 | Object2 2 | 1.1 3 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects2.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/compatexample/updateserver/Objects2.kvz -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects2/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/object1.txt 6 | {APPDIR}/object1.txt 7 | 8 | 9 | 10 | Copy 11 | {CURPATH}/object2.txt 12 | {APPDIR}/object2.txt 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects2/object1.txt: -------------------------------------------------------------------------------- 1 | Object1 2 | 2.0 3 | A, B 4 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Objects2/object2.txt: -------------------------------------------------------------------------------- 1 | Object2 2 | 2.0 3 | A, B 4 | -------------------------------------------------------------------------------- /examples/compatexample/updateserver/Updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | CompatExample 4 | 1.x 5 | 6 | 7 | Objects 8 | Objects update - version 1.1 9 | http://www.kdab.net/?page=products&sub=kdtannouncement 10 | 1.1 11 | 2009-02-01 12 | Objects1.kvz 13 | Objects1.kvz 14 | Objects1.kvz 15 | 16 | 17 | 18 | Objects 19 | Objects update - version 2.0 20 | http://www.kdab.net/?page=products&sub=kdtannouncement 21 | 2.0 22 | 2 23 | 2009-02-12 24 | Objects2.kvz 25 | Objects2.kvz 26 | Objects2.kvz 27 | 28 | 29 | 30 | Update the compat level to 2 31 | 2 32 | 2009-02-10 33 | http://www.kdab.net/?page=products&sub=kdtannouncement 34 | Compat2.kvz 35 | Compat2.kvz 36 | Compat2.kvz 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | CONFIG += ordered 4 | 5 | SUBDIRS += simpleexample kdupdaterdemo 6 | qtHaveModule(script) { 7 | SUBDIRS += compatexample 8 | SUBDIRS += firmwaredemo 9 | } 10 | 11 | -------------------------------------------------------------------------------- /examples/firmwaredemo/appdata/Packages.xml: -------------------------------------------------------------------------------- 1 | 2 | FirmwareDemo 3 | 1.0 4 | 1 5 | 6 | 7 | Firmware 8 | Firmwares used in the application (micro and mixer) 9 | 1.0 10 | 2008-04-09 11 | 2008-04-09 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/firmwaredemo/appdata/headers.js: -------------------------------------------------------------------------------- 1 | 2 | function headers() 3 | { 4 | return "Id, Type, Firmware"; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /examples/firmwaredemo/appdata/l4rfirmware.txt: -------------------------------------------------------------------------------- 1 | Line 4 Receiver 2 | 1.0 3 | -------------------------------------------------------------------------------- /examples/firmwaredemo/appdata/psmfirmware.txt: -------------------------------------------------------------------------------- 1 | Personal Sound Monitor 2 | 1.0 3 | -------------------------------------------------------------------------------- /examples/firmwaredemo/firmwaredemo.pro: -------------------------------------------------------------------------------- 1 | include (../../KDUpdater.pri) 2 | 3 | TEMPLATE = app 4 | DESTDIR = $$KDUPDATER_BIN_PATH 5 | 6 | QT += widgets script 7 | TARGET = FirmwareDemo 8 | 9 | EXAMPLE_APP_DIR="$$OUT_PWD/apptempdata" 10 | 11 | DEFINES += EXAMPLE_APP_DIR="\\\"$$EXAMPLE_APP_DIR\\\"" 12 | 13 | !build_pass:qmakeCleanAndCopy("$$PWD/appdata", "$$EXAMPLE_APP_DIR") 14 | 15 | UPDATEURL = file:///$$PWD/updateserver 16 | UPDATEURL = $$replace(UPDATEURL, file:////, file:///) 17 | 18 | qmakeEcho("", ">", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 19 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 20 | qmakeEcho(" KDABSource", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 21 | qmakeEcho(" KDAB Update Source", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 22 | qmakeEcho(" Update source from KDAB", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 23 | qmakeEcho(" $$UPDATEURL", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 24 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 25 | qmakeEcho("", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 26 | 27 | SOURCES += src/main.cpp src/mainwindow.cpp src/helpdialog.cpp 28 | HEADERS += src/mainwindow.h src/helpdialog.h 29 | -------------------------------------------------------------------------------- /examples/firmwaredemo/src/helpdialog.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "helpdialog.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | HelpDialog::HelpDialog( QWidget* parent) 30 | : QDialog( parent ) 31 | { 32 | QVBoxLayout* layout = new QVBoxLayout; 33 | setLayout( layout ); 34 | 35 | QTextBrowser* webView = new QTextBrowser( this ); 36 | layout->addWidget( webView ); 37 | 38 | const QString text = tr( 39 | "

Presentation

\ 40 | This application demonstrates some aspects of the KDAB updater component.
\ 41 | Initially you can add target items (Line 4 Receiver or PSM devices) that use some current firmware version, to the table.
\ 42 | You can see the current compatibility level and firmware version known to the application in the status bar. The source used for finding updates is available when clicking on the button Update Sources.\ 43 |

Step 1: add some items

\ 44 | Add some items to the table, using the Add Line 4 Receiver or Add PSM button. \ 45 |

Step 2: update the firmware

\ 46 | Update the firmware information by clicking on the Update button : a dialog appears that lets you download and install the version 1.1 for the package Firmware.
\ 47 | Once that is done, the status bar is updated with the new firmware version.
\ 48 | To update the devices in the table: select them all and click on the Upload Firmwares button. \ 49 |

Step 3: change the compatibility level

\ 50 | The current compatibility level is 1. To change that, click on the Update Compat button : a dialog appears that lets you change to a new compat level 2, if updates at that level are available.
\ 51 | Once it's done, the status bar is updated with the new compat level and you should see a new column in the table and the application's style changed.\ 52 |

Step 4: update the firmware (one more time)

\ 53 | Now that you changed the compatibility level, you can update the firmware one more time by clicking on the Update button: a dialog appears that lets you install the version 2.0 for the package Firmware
\ 54 | This update wasn't available the first time because it needs the compatibility level 2." ); 55 | 56 | webView->setHtml( text ); 57 | connect( webView, SIGNAL(linkClicked(QUrl)), 58 | this, SLOT(clickLink(QUrl)) ); 59 | 60 | setWindowTitle( tr("Help FirmwareDemoHttp") ); 61 | resize( 480, 480 ); 62 | } 63 | 64 | HelpDialog::~HelpDialog() 65 | { 66 | 67 | } 68 | 69 | void HelpDialog::clickLink( const QUrl &url ) 70 | { 71 | emit linkClicked( url.fragment() ); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /examples/firmwaredemo/src/helpdialog.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef HELPDIALOG_H 24 | #define HELPDIALOG_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class HelpDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | HelpDialog( QWidget* parent = 0 ); 36 | ~HelpDialog(); 37 | 38 | Q_SIGNALS: 39 | void linkClicked( const QString &name ); 40 | 41 | private Q_SLOTS: 42 | void clickLink( const QUrl & ); 43 | }; 44 | 45 | 46 | #endif /* HELPDIALOG_H */ 47 | 48 | -------------------------------------------------------------------------------- /examples/firmwaredemo/src/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef EXAMPLE_APP_DIR 24 | #error "EXAMPLE_APP_DIR not set. It is necessary for this example application to find its application directory." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "mainwindow.h" 33 | #include "../../common.h" 34 | 35 | 36 | int main(int argc, char** argv) 37 | { 38 | QApplication a(argc, argv); 39 | 40 | const AppDirSaver saver; 41 | 42 | KDUpdater::Target target; 43 | target.setDirectory( QFile::decodeName( EXAMPLE_APP_DIR ) ); 44 | 45 | MainWindow window( &target ); 46 | window.show(); 47 | 48 | return a.exec(); 49 | } 50 | -------------------------------------------------------------------------------- /examples/firmwaredemo/src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef MAINWINDOW_H 24 | #define MAINWINDOW_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | QT_BEGIN_NAMESPACE 31 | class QAction; 32 | class QTableWidget; 33 | QT_END_NAMESPACE 34 | 35 | namespace KDUpdater { 36 | class Target; 37 | } 38 | 39 | class MainWindow : public QMainWindow 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | explicit MainWindow( KDUpdater::Target * target, QWidget * parent=0 ); 45 | ~MainWindow(); 46 | 47 | public Q_SLOTS: 48 | void triggerAction( const QString& name ); 49 | 50 | private Q_SLOTS: 51 | void onAddL4R(); 52 | void onAddPSM(); 53 | void onUploadSelected(); 54 | void onUpdate(); 55 | void onUpdateCompat(); 56 | void showPackages(); 57 | void showSources(); 58 | 59 | private: 60 | void loadApplicationData(); 61 | void uploadFirmware(const QString &firmware, int device); 62 | void displayDevice(int device, int row); 63 | void updatePackage( bool findCompat ); 64 | 65 | KDUpdater::Target * m_target; 66 | QTableWidget *m_table; 67 | int m_lastId; 68 | QDir m_appDir; 69 | QDir m_devicesDir; 70 | QMap m_actionMap; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Application2.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/firmwaredemo/updateserver/Application2.kvz -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Application2/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/application.qss 6 | {TARGETDIR}/application.qss 7 | 8 | 9 | 10 | Copy 11 | {CURPATH}/headers.js 12 | {TARGETDIR}/headers.js 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Application2/application.qss: -------------------------------------------------------------------------------- 1 | QToolBar { 2 | background-color: beige; 3 | } 4 | 5 | QToolBar > QWidget { 6 | background-color: beige; 7 | } 8 | 9 | QToolTip { 10 | border: 2px solid darkkhaki; 11 | padding: 5px; 12 | border-radius: 3px; 13 | background-color: beige; 14 | } 15 | 16 | QTableView { 17 | border: 0; 18 | selection-background-color: darkkhaki; 19 | background-color: beige; 20 | } 21 | 22 | QTableView > QWidget { 23 | background-color: beige; 24 | } 25 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Application2/headers.js: -------------------------------------------------------------------------------- 1 | 2 | function headers() 3 | { 4 | return "Id, Type, Firmware, Features"; 5 | } 6 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware1.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/firmwaredemo/updateserver/Firmware1.kvz -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware1/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/psmfirmware.txt 6 | {APPDIR}/psmfirmware.txt 7 | 8 | 9 | 10 | Copy 11 | {CURPATH}/l4rfirmware.txt 12 | {APPDIR}/l4rfirmware.txt 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware1/l4rfirmware.txt: -------------------------------------------------------------------------------- 1 | Line 4 Receiver 2 | 1.1 3 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware1/psmfirmware.txt: -------------------------------------------------------------------------------- 1 | Personal Sound Monitor 2 | 1.1 3 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware2.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/firmwaredemo/updateserver/Firmware2.kvz -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware2/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/psmfirmware.txt 6 | {APPDIR}/psmfirmware.txt 7 | 8 | 9 | 10 | Copy 11 | {CURPATH}/l4rfirmware.txt 12 | {APPDIR}/l4rfirmware.txt 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware2/l4rfirmware.txt: -------------------------------------------------------------------------------- 1 | Line 4 Receiver 2 | 2.0 3 | A, B 4 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Firmware2/psmfirmware.txt: -------------------------------------------------------------------------------- 1 | Personal Sound Monitor 2 | 2.0 3 | A, B 4 | -------------------------------------------------------------------------------- /examples/firmwaredemo/updateserver/Updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FirmwareDemo 4 | 1.x 5 | 6 | 7 | Firmware 8 | Firmwares update for micro and mixer - version 1.1 9 | http://www.kdab.net/?page=products&sub=kdtannouncement 10 | 1.1 11 | 2009-02-01 12 | Firmware1.kvz 13 | Firmware1.kvz 14 | Firmware1.kvz 15 | 16 | 17 | 18 | Firmware 19 | Firmwares update for micro and mixer - version 2.0 20 | http://www.kdab.net/?page=products&sub=kdtannouncement 21 | 2.0 22 | 2 23 | 2009-02-12 24 | Firmware2.kvz 25 | Firmware2.kvz 26 | Firmware2.kvz 27 | 28 | 29 | 30 | New version of the application 31 | 2 32 | 2009-02-10 33 | http://www.kdab.net/?page=products&sub=kdtannouncement 34 | Application2.kvz 35 | Application2.kvz 36 | Application2.kvz 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/kdupdaterdemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | CONFIG += ordered 3 | #TARGET = examples 4 | SUBDIRS = kdupdaterdemo kdupdaterdemov2 5 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/kdupdaterdemo.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | packages.xml 4 | 5 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/kdupdaterdemo/kdupdaterdemo.pro: -------------------------------------------------------------------------------- 1 | include (../../../KDUpdater.pri) 2 | 3 | TEMPLATE = app 4 | DESTDIR = $$KDUPDATER_BIN_PATH 5 | QT += widgets 6 | SOURCES += ../main.cpp \ 7 | ../mainwindow.cpp \ 8 | ../updaterdialog.cpp \ 9 | ../updater.cpp 10 | HEADERS += ../mainwindow.h \ 11 | ../updaterdialog.h \ 12 | ../updater.h 13 | DEFINES += APP_VERSION="\\\"1.0\\\"" 14 | DESTREPODIR = $$KDUPDATER_BUILD_TREE/examples/kdupdaterdemo/updateserver 15 | 16 | DEFINES += REPO_DIR="\\\"$$DESTREPODIR\\\"" 17 | RESOURCES += ../kdupdaterdemo.qrc 18 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/kdupdaterdemov2/kdupdaterdemov2.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | include (../../../KDUpdater.pri) 3 | QT += widgets 4 | SOURCES += ../main.cpp \ 5 | ../mainwindow.cpp \ 6 | ../updaterdialog.cpp \ 7 | ../updater.cpp 8 | HEADERS += ../mainwindow.h \ 9 | ../updaterdialog.h \ 10 | ../updater.h 11 | DEFINES += APP_VERSION="\\\"1.1\\\"" 12 | RESOURCES += ../kdupdaterdemo.qrc 13 | 14 | SRCREPODIR = $$KDUPDATER_SOURCE_TREE/examples/kdupdaterdemo/repository 15 | DESTREPODIR = $$KDUPDATER_BUILD_TREE/examples/kdupdaterdemo/updateserver 16 | DEFINES += REPO_DIR="\\\"$$DESTREPODIRT\\\"" 17 | 18 | win32{ 19 | DESTDIR = $$OUT_PWD 20 | 21 | SOURCE_DIR = $$replace(PWD, /, \\) 22 | BUILD_DIR = $$replace(OUT_PWD, /, \\) 23 | SRCREPODIR = $$replace(SRCREPODIR, /, \\) 24 | DESTREPODIR = $$replace(DESTREPODIR, /, \\) 25 | WINDESTDIR = $$replace(KDUPDATER_BIN_PATH, /, \\) 26 | 27 | COPYSCRIPT = copy $$SOURCE_DIR\\postbuild.bat $$BUILD_DIR\\postbuild.bat 28 | QMAKE_PRE_LINK += $$COPYSCRIPT 29 | 30 | CREATEREPOTARGETPRE1.commands = postbuild.bat $$SRCREPODIR $$DESTREPODIR $$WINDESTDIR 31 | } else { 32 | macx:FOLDERSUFFIX="mac" 33 | !macx:FOLDERSUFFIX="unix" 34 | 35 | macx:SUFFIX=".app" 36 | !macx:SUFFIX="" 37 | ext = ".kvz" 38 | 39 | # copy Updates.xml and UpdateInstructions.xml to dest-dir 40 | CREATEREPOTARGET.commands = mkdir -p $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX && 41 | CREATEREPOTARGET.commands += cp $$SRCREPODIR/Updates.xml $$DESTREPODIR/Updates.xml && 42 | CREATEREPOTARGET.commands += cp $$SRCREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/UpdateInstructions.xml $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/UpdateInstructions.xml && 43 | 44 | # copy generated application to dest-dir, then create the .kvz file 45 | CREATEREPOTARGET.commands += cp -R $$OUT_PWD/kdupdaterdemov2$$SUFFIX $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/kdupdaterdemo$$SUFFIX && 46 | macx:CREATEREPOTARGET.commands += mv $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/kdupdaterdemo$$SUFFIX/Contents/MacOS/kdupdaterdemov2 $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/kdupdaterdemo$$SUFFIX/Contents/MacOS/kdupdaterdemo && 47 | CREATEREPOTARGET.commands += $$KDUPDATER_BIN_PATH/ufcreator $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/ && 48 | # CREATEREPOTARGET.commands += rm -rf $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX/kdupdaterdemo$$SUFFIX && 49 | CREATEREPOTARGET.commands += mv $$OUT_PWD/kdupdaterdemo_$$FOLDERSUFFIX$$ext $$DESTREPODIR/kdupdaterdemo_$$FOLDERSUFFIX$$ext #&& 50 | # CREATEREPOTARGET.commands += rm -rf $$OUT_PWD/kdupdaterdemov2$$SUFFIX 51 | 52 | CREATEREPOTARGETPRE1.commands = if [ -a $$DESTREPODIR ]; then rm -rf $$DESTREPODIR && 53 | CREATEREPOTARGETPRE1.commands += $$CREATEREPOTARGET.commands 54 | CREATEREPOTARGETPRE1.commands += ; else 55 | CREATEREPOTARGETPRE1.commands += $$CREATEREPOTARGET.commands 56 | CREATEREPOTARGETPRE1.commands += ; fi 57 | } 58 | #message ( $$CREATEREPOTARGETPRE1.commands ) 59 | 60 | #QMAKE_EXTRA_TARGETS += CREATEREPOTARGET 61 | QMAKE_POST_LINK = $$CREATEREPOTARGETPRE1.commands 62 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/kdupdaterdemov2/postbuild.bat: -------------------------------------------------------------------------------- 1 | rem @echo off 2 | rem parameter %1 srcrepodir, %2 destrepodir, %3 destdir 3 | 4 | if EXIST %2 ( rmdir /s /q %2 ) 5 | mkdir %2\kdupdaterdemo_win 6 | copy %1\Updates.xml %2\Updates.xml 7 | copy %1\kdupdaterdemo_win\UpdateInstructions.xml %2\kdupdaterdemo_win\UpdateInstructions.xml 8 | 9 | copy %2\..\kdupdaterdemov2\kdupdaterdemov2.exe %2\kdupdaterdemo_win\kdupdaterdemo.exe 10 | %3\ufcreator.exe %2\kdupdaterdemo_win 11 | rem del /f %2\kdupdaterdemo_win\kdupdaterdemo.exe 12 | move %2\..\kdupdaterdemov2\kdupdaterdemo_win.kvz %2\kdupdaterdemo_win.kvz 13 | rem del /f %2\kdupdaterdemov2\kdupdaterdemov2.exe 14 | echo "Script run successfull" 15 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "mainwindow.h" 24 | #include "updaterdialog.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | class MainWindow::Private : public QObject 37 | { 38 | Q_OBJECT 39 | public: 40 | explicit Private( MainWindow* parent = NULL ); 41 | ~Private(); 42 | void init(); 43 | 44 | private: 45 | void createMenus(); 46 | void createWidgets(); 47 | 48 | private: 49 | MainWindow* m_parent; 50 | QTextBrowser * m_display; 51 | 52 | private Q_SLOTS: 53 | void showUpdaterDialog(); 54 | void closeAndRestart(); 55 | }; 56 | 57 | MainWindow::Private::Private( MainWindow* parent): 58 | m_parent( parent ), 59 | m_display( NULL ) 60 | { 61 | } 62 | 63 | MainWindow::Private::~Private() 64 | { 65 | 66 | } 67 | 68 | void MainWindow::Private::createWidgets() 69 | { 70 | m_display = new QTextBrowser( m_parent ); 71 | m_parent->setCentralWidget( m_display ); 72 | const QString text = tr( "Version %1" ).arg( QLatin1String( APP_VERSION ) ); 73 | m_display->setPlainText( text ); 74 | QFont font = m_display->currentFont(); 75 | font.setPointSize( 100 ); 76 | m_display->setFont( font ); 77 | } 78 | 79 | void MainWindow::Private::init() 80 | { 81 | createWidgets(); 82 | createMenus(); 83 | 84 | } 85 | 86 | void MainWindow::Private::createMenus() 87 | { 88 | QMenu* updaterMenu = m_parent->menuBar()->addMenu( tr( "&Updater" ) ); 89 | updaterMenu->addAction( tr( "check for &updates" ), this, SLOT(showUpdaterDialog()) ); 90 | } 91 | 92 | void MainWindow::Private::closeAndRestart() 93 | { 94 | QStringList arguments; 95 | arguments.append( QString::fromLatin1( "--copy" ) ); 96 | arguments.append( qApp->applicationFilePath() ); 97 | const int extIndex = qApp->applicationFilePath().lastIndexOf( QLatin1Char( '.' ) ); 98 | const QString appFileExtension( extIndex >= 0 ? qApp->applicationFilePath().mid( extIndex ) : QString() ); 99 | const QString appName( qApp->applicationFilePath().mid( 0, extIndex ) ); 100 | const QString updatedAppFileName( appName + QString::fromLatin1( "tmp" ) + appFileExtension ); 101 | const QString startAppName( QFileInfo( updatedAppFileName ).absoluteFilePath() ); 102 | std::cout << appFileExtension.toStdString().c_str() << std::endl; 103 | std::cout << appName.toStdString().c_str()<< std::endl; 104 | std::cout << updatedAppFileName.toStdString().c_str() << std::endl; 105 | std::cout << startAppName.toStdString().c_str() << std::endl; 106 | QProcess::startDetached( startAppName, arguments, QDir::currentPath( ) ); 107 | m_parent->close(); 108 | } 109 | 110 | void MainWindow::Private::showUpdaterDialog() 111 | { 112 | UpdaterDialog d; 113 | connect( &d, SIGNAL(accepted()), this, SLOT(closeAndRestart()) ); 114 | d.exec(); 115 | } 116 | 117 | 118 | MainWindow::MainWindow( QWidget *parent ) : 119 | QMainWindow( parent ), 120 | d ( new Private( this ) ) 121 | { 122 | d->init(); 123 | } 124 | 125 | MainWindow::~MainWindow() 126 | { 127 | 128 | } 129 | #include "mainwindow.moc" 130 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef MAINWINDOW_H 24 | #define MAINWINDOW_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class MainWindow : public QMainWindow 31 | { 32 | Q_OBJECT 33 | KDAB_DISABLE_COPY( MainWindow ); 34 | public: 35 | explicit MainWindow( QWidget *parent = 0 ); 36 | ~MainWindow(); 37 | private: 38 | class Private; 39 | kdtools::pimpl_ptr< Private > d; 40 | }; 41 | 42 | #endif // MAINWINDOW_H 43 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/packages.xml: -------------------------------------------------------------------------------- 1 | 2 | kdupdaterdemo 3 | 1.0.0 4 | 5 | com.kdab.kdupdaterdemo 6 | 7 | KDUpdater Demo 8 | Installs the KDUpdater Demo. 9 | 1.0.0 10 | 11 | 2010-06-03 12 | 0 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/repository/Updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | kdupdaterdemo 4 | 1.0.0 5 | 6 | 7 | com.kdab.kdupdaterdemo 8 | Installs the KDUpdater Demo 9 | 1.1 10 | 2010-06-06 11 | kdupdaterdemo_win.kvz 12 | kdupdaterdemo_mac.kvz 13 | kdupdaterdemo_unix.kvz 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/repository/kdupdaterdemo_mac/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | kdupdaterdemo 6 | {APPDIR}/kdupdaterdemotmp 7 | Abort 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/repository/kdupdaterdemo_unix/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | kdupdaterdemo 6 | {APPDIR}/kdupdaterdemotmp 7 | Abort 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/repository/kdupdaterdemo_win/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | kdupdaterdemo.exe 6 | {APPDIR}/kdupdaterdemotmp.exe 7 | Abort 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/updater.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef UPDATER_H 24 | #define UPDATER_H 25 | 26 | #include 27 | #include 28 | 29 | QT_BEGIN_NAMESPACE 30 | class QString; 31 | QT_END_NAMESPACE 32 | 33 | class Updater : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | Updater(); 38 | ~Updater(); 39 | QString getInstalledAppVersion() const; 40 | QString getAppName() const; 41 | QString getUpdateVersion() const; 42 | bool hasUpdates() const; 43 | bool checkForUpdates(); 44 | bool installUpdates(); 45 | 46 | private: 47 | class Private; 48 | kdtools::pimpl_ptr< Private > d; 49 | }; 50 | 51 | #endif // UPDATER_H 52 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/updaterdialog.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "updaterdialog.h" 24 | #include "updater.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | 35 | class UpdaterDialog::Private : QObject 36 | { 37 | Q_OBJECT 38 | public: 39 | Private( UpdaterDialog* parent = NULL); 40 | ~Private(); 41 | void init(); 42 | 43 | private: 44 | void createWidgets(); 45 | void createConnections(); 46 | void layoutWidgets(); 47 | 48 | private: 49 | UpdaterDialog* m_parent; 50 | QDialogButtonBox* m_buttonBox; 51 | QPushButton* m_checkForUpdatesBtn; 52 | QPushButton* m_installUpdatesBtn; 53 | QLabel* m_notification; 54 | Updater m_updater; 55 | 56 | private Q_SLOTS: 57 | void checkForUpdates(); 58 | void installUpdates(); 59 | }; 60 | 61 | UpdaterDialog::Private::Private( UpdaterDialog* parent ) : 62 | m_parent( parent ), 63 | m_buttonBox( NULL ), 64 | m_checkForUpdatesBtn( NULL ), 65 | m_installUpdatesBtn( NULL ), 66 | m_notification( NULL ) 67 | { 68 | 69 | } 70 | 71 | void UpdaterDialog::Private::createWidgets() 72 | { 73 | m_buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, m_parent ); 74 | 75 | m_checkForUpdatesBtn = new QPushButton( tr( "Search updates" ), m_buttonBox); 76 | 77 | m_buttonBox->addButton( m_checkForUpdatesBtn, QDialogButtonBox::ActionRole ); 78 | 79 | m_installUpdatesBtn = new QPushButton( tr( "Install updates" ), m_buttonBox); 80 | m_installUpdatesBtn->setEnabled( false ); 81 | m_buttonBox->addButton( m_installUpdatesBtn, QDialogButtonBox::AcceptRole ); 82 | 83 | 84 | m_notification = new QLabel( m_parent); 85 | const QString textDisplay = tr( "Currently version %1 of %2 is installed" ).arg( m_updater.getInstalledAppVersion() , m_updater.getAppName() ); 86 | m_notification->setText( textDisplay ); 87 | } 88 | 89 | void UpdaterDialog::Private::createConnections() 90 | { 91 | connect( m_buttonBox, SIGNAL(rejected()), m_parent, SLOT(reject()) ); 92 | connect( m_checkForUpdatesBtn, SIGNAL(clicked()), this, SLOT(checkForUpdates()) ); 93 | connect( m_installUpdatesBtn, SIGNAL(clicked()), this, SLOT(installUpdates()) ); 94 | } 95 | 96 | void UpdaterDialog::Private::layoutWidgets() 97 | { 98 | QVBoxLayout* layout = new QVBoxLayout( m_parent ); 99 | layout->addWidget( m_notification, 1); 100 | layout->addWidget( m_buttonBox, 0); 101 | } 102 | 103 | void UpdaterDialog::Private::checkForUpdates() 104 | { 105 | m_checkForUpdatesBtn->setEnabled( false ); 106 | QProgressDialog dialog; 107 | dialog.setLabelText( tr( "searching updates" ) ); 108 | const bool success = m_updater.checkForUpdates(); 109 | const QString updateFoundText = tr( "\nFound update to version: "); 110 | if ( success ) 111 | { 112 | m_notification->setText( m_notification->text() + updateFoundText + m_updater.getUpdateVersion() ); 113 | m_installUpdatesBtn->setEnabled( true ); 114 | } 115 | else 116 | { 117 | m_installUpdatesBtn->setEnabled( false ); 118 | } 119 | m_checkForUpdatesBtn->setEnabled( true ); 120 | } 121 | 122 | void UpdaterDialog::Private::installUpdates() 123 | { 124 | const bool success = m_updater.installUpdates(); 125 | if ( success ) 126 | { 127 | m_parent->accept(); 128 | } 129 | } 130 | 131 | void UpdaterDialog::Private::init() 132 | { 133 | createWidgets(); 134 | createConnections(); 135 | layoutWidgets(); 136 | } 137 | 138 | UpdaterDialog::Private::~Private() 139 | { 140 | 141 | } 142 | 143 | 144 | UpdaterDialog::UpdaterDialog( QWidget *parent ) : 145 | QDialog( parent ), 146 | d( new Private( this ) ) 147 | { 148 | d->init(); 149 | } 150 | 151 | UpdaterDialog::~UpdaterDialog() 152 | { 153 | 154 | } 155 | 156 | #include "updaterdialog.moc" 157 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/updaterdialog.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef UPDATERDIALOG_H 24 | #define UPDATERDIALOG_H 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | class UpdaterDialog : public QDialog 32 | { 33 | Q_OBJECT 34 | KDAB_DISABLE_COPY( UpdaterDialog ); 35 | public: 36 | explicit UpdaterDialog( QWidget *parent = 0 ); 37 | ~UpdaterDialog(); 38 | 39 | private: 40 | class Private; 41 | kdtools::pimpl_ptr< Private > d; 42 | 43 | }; 44 | 45 | #endif // UPDATERDIALOG_H 46 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/windowsrunningapplicationupdateoperation.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "windowsrunningapplicationupdateoperation.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | WindowsRunningApplicationUpdateOperation::WindowsRunningApplicationUpdateOperation() 30 | { 31 | } 32 | 33 | WindowsRunningApplicationUpdateOperation::~WindowsRunningApplicationUpdateOperation() 34 | { 35 | } 36 | 37 | 38 | void WindowsRunningApplicationUpdateOperation::backup() 39 | { 40 | } 41 | 42 | bool WindowsRunningApplicationUpdateOperation::performOperation() 43 | { 44 | QStringList processArgs; 45 | Q_FOREACH( const QString & arg, arguments() ) 46 | { 47 | QFileInfo fi( arg ); 48 | processArgs.append( fi.absoluteFilePath() ); 49 | processArgs.append( fi.fileName() ); 50 | } 51 | processArgs.append( QString::number( QCoreApplication::applicationPid() ) ); 52 | 53 | QProcess::startDetached( QLatin1String( "UpdateHelper"), processArgs, qApp->applicationDirPath() ); 54 | return true; 55 | } 56 | 57 | bool WindowsRunningApplicationUpdateOperation::undoOperation() 58 | { 59 | return true; 60 | } 61 | bool WindowsRunningApplicationUpdateOperation::testOperation() 62 | { 63 | return true; 64 | } 65 | 66 | KDUpdater::UpdateOperation* WindowsRunningApplicationUpdateOperation::clone() const 67 | { 68 | return new WindowsRunningApplicationUpdateOperation(); 69 | } 70 | -------------------------------------------------------------------------------- /examples/kdupdaterdemo/windowsrunningapplicationupdateoperation.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef WINDOWSRUNNINGAPPLICATIONUPDATEOPERATION_H 24 | #define WINDOWSRUNNINGAPPLICATIONUPDATEOPERATION_H 25 | 26 | #include 27 | 28 | class WindowsRunningApplicationUpdateOperation : public KDUpdater::UpdateOperation 29 | { 30 | public: 31 | WindowsRunningApplicationUpdateOperation(); 32 | ~WindowsRunningApplicationUpdateOperation(); 33 | /*reimpl*/ void backup(); 34 | /*reimpl*/ bool performOperation(); 35 | /*reimpl*/ bool undoOperation(); 36 | /*reimpl*/ bool testOperation(); 37 | /*reimpl*/ UpdateOperation* clone() const; 38 | 39 | 40 | }; 41 | 42 | #endif // WINDOWSRUNNINGAPPLICATIONUPDATEOPERATION_H 43 | -------------------------------------------------------------------------------- /examples/simpleexample/appdata/Packages.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimpleExample 4 | 1.0 5 | 6 | 7 | MainWindow 8 | The main window of the application 9 | 0.0 10 | 2008-04-09 11 | 2008-04-09 12 | 13 | 14 | 15 | LicenseText 16 | Set of related text files 17 | 0.0 18 | This package contains license text for the application. 19 | 2008-04-09 20 | 2008-04-09 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/simpleexample/simpleexample.pro: -------------------------------------------------------------------------------- 1 | include (../../KDUpdater.pri) 2 | 3 | TEMPLATE = app 4 | DESTDIR = $$KDUPDATER_BIN_PATH 5 | 6 | DEFINES -= QT_NO_KEYWORDS QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII 7 | 8 | QT += widgets 9 | 10 | TARGET = SimpleExample 11 | 12 | EXAMPLE_APP_DIR="$$OUT_PWD/apptempdata" 13 | 14 | DEFINES += EXAMPLE_APP_DIR="\\\"$$EXAMPLE_APP_DIR\\\"" 15 | 16 | !build_pass:qmakeCleanAndCopy("$$PWD/appdata", "$$EXAMPLE_APP_DIR") 17 | 18 | UPDATEURL = file:///$$PWD/updateserver 19 | UPDATEURL = $$replace(UPDATEURL, file:////, file:///) 20 | 21 | qmakeEcho("", ">", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 22 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 23 | qmakeEcho(" LocalSource", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 24 | qmakeEcho(" Local Update Source", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 25 | qmakeEcho(" Update source from the local file system", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 26 | qmakeEcho(" $$UPDATEURL", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 27 | qmakeEcho(" ", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 28 | qmakeEcho("", ">>", "$$EXAMPLE_APP_DIR/UpdateSources.xml") 29 | 30 | SOURCES += src/main.cpp src/mainwindow.cpp 31 | HEADERS += src/mainwindow.h 32 | FORMS += src/mainwindow.ui 33 | 34 | -------------------------------------------------------------------------------- /examples/simpleexample/src/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef EXAMPLE_APP_DIR 24 | #error "EXAMPLE_APP_DIR not set. It is necessary for this example application to find its application directory." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "mainwindow.h" 33 | #include "../../common.h" 34 | 35 | 36 | int main(int argc, char** argv) 37 | { 38 | QApplication a(argc, argv); 39 | 40 | const AppDirSaver saver; 41 | 42 | KDUpdater::Target target; 43 | target.setDirectory( QFile::decodeName( EXAMPLE_APP_DIR ) ); 44 | 45 | MainWindow window( &target ); 46 | window.show(); 47 | 48 | return a.exec(); 49 | } 50 | -------------------------------------------------------------------------------- /examples/simpleexample/src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef MAIN_WINDOW_H 24 | #define MAIN_WINDOW_H 25 | 26 | #include 27 | 28 | namespace KDUpdater { 29 | class Target; 30 | } 31 | 32 | QT_BEGIN_NAMESPACE 33 | namespace Ui { 34 | class MainWindow; 35 | } 36 | QT_END_NAMESPACE 37 | 38 | class MainWindow : public QMainWindow 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | explicit MainWindow( KDUpdater::Target * target, QWidget * parent=0 ); 44 | ~MainWindow(); 45 | 46 | private: 47 | void init(); 48 | 49 | private Q_SLOTS: 50 | void updatePackages(); 51 | void showPackages(); 52 | void showSources(); 53 | 54 | private: 55 | Ui::MainWindow* ui; 56 | KDUpdater::Target * m_target; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /examples/simpleexample/src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindow 3 | 4 | 5 | 6 | 0 7 | 0 8 | 800 9 | 600 10 | 11 | 12 | 13 | MainWindow 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Qt::Vertical 30 | 31 | 32 | 33 | 20 34 | 40 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 0 48 | 0 49 | 50 | 51 | 52 | License: 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 6 61 | 0 62 | 63 | 64 | 65 | true 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 0 77 | 0 78 | 800 79 | 30 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update1.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/simpleexample/updateserver/Update1.kvz -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update1/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/gpl-1.0.txt 6 | {APPDIR}/license.txt 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update2.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/simpleexample/updateserver/Update2.kvz -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update2/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/gpl-2.0.txt 6 | {APPDIR}/license.txt 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update3.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/simpleexample/updateserver/Update3.kvz -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update3/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/gpl-3.0.txt 6 | {APPDIR}/license.txt 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update4.kvz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/simpleexample/updateserver/Update4.kvz -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update4/UpdateInstructions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copy 5 | {CURPATH}/kdtools.png 6 | {APPDIR}/icon.png 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Update4/kdtools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbzhang800/KDUpdater/aa9b903d42757d55d7c2b1cc55bfb06660be8d31/examples/simpleexample/updateserver/Update4/kdtools.png -------------------------------------------------------------------------------- /examples/simpleexample/updateserver/Updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimpleExample 4 | 1.x 5 | 6 | 7 | LicenseText 8 | License Text Update - GPL Version 1 9 | 1.0 10 | 2008-04-10 11 | Update1.kvz 12 | Update1.kvz 13 | Update1.kvz 14 | 15 | 16 | 17 | LicenseText 18 | License Text Update - GPL Version 2 19 | 2.0 20 | 2008-04-11 21 | Update2.kvz 22 | Update2.kvz 23 | Update2.kvz 24 | 25 | 26 | LicenseText 27 | License Text Update - GPL Version 3 28 | http://www.kdab.net/ 29 | 3.0 30 | 2008-04-12 31 | Update3.kvz 32 | Update3.kvz 33 | Update3.kvz 34 | 35 | 36 | 37 | MainWindow 38 | Some icons 39 | 1.0 40 | 2009-02-25 41 | Update4.kvz 42 | Update4.kvz 43 | Update4.kvz 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/addupdatesourcedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | AddUpdateSourceDialog 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 239 10 | 11 | 12 | 13 | Add Update Source 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | &Name 22 | 23 | 24 | txtName 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 10 33 | 75 34 | true 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | &Title 43 | 44 | 45 | txtTitle 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 9 54 | false 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | &Description 63 | 64 | 65 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 66 | 67 | 68 | txtDescription 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | &URL 79 | 80 | 81 | txtUrl 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 0 94 | 45 95 | 195 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 0 105 | 45 106 | 195 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 106 116 | 104 117 | 100 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | true 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | Qt::Vertical 137 | 138 | 139 | 140 | 20 141 | 40 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | Qt::Horizontal 150 | 151 | 152 | QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | buttonBox 162 | accepted() 163 | AddUpdateSourceDialog 164 | accept() 165 | 166 | 167 | 257 168 | 229 169 | 170 | 171 | 157 172 | 274 173 | 174 | 175 | 176 | 177 | buttonBox 178 | rejected() 179 | AddUpdateSourceDialog 180 | reject() 181 | 182 | 183 | 325 184 | 229 185 | 186 | 187 | 286 188 | 274 189 | 190 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /src/kdgenericfactory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLSCORE__KDGENERICFACTORY_H__ 24 | #define __KDTOOLSCORE__KDGENERICFACTORY_H__ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifndef DOXYGEN_RUN 34 | 35 | template< typename T_Identifier, template< typename U, typename V > class T_Map > 36 | class KDGenericFactoryBase 37 | { 38 | protected: 39 | ~KDGenericFactoryBase() {} 40 | 41 | typedef void* (*FactoryFunction)(); 42 | 43 | void unregisterProduct( const T_Identifier& name ) 44 | { 45 | map.remove( name ); 46 | } 47 | 48 | unsigned int productCount() const 49 | { 50 | return map.size(); 51 | } 52 | 53 | QList< T_Identifier > availableProducts() const 54 | { 55 | return map.keys(); 56 | } 57 | 58 | void * create( const T_Identifier & name ) const 59 | { 60 | const typename T_Map< T_Identifier, FactoryFunction >::const_iterator it = map.find( name ); 61 | if( it == map.end() ) 62 | return 0; 63 | return (*it)(); 64 | } 65 | 66 | protected: 67 | void registerProductionFunction( const T_Identifier& name, FactoryFunction createfun ) 68 | { 69 | map.insert( name, createfun ); 70 | } 71 | 72 | private: 73 | T_Map< T_Identifier, FactoryFunction > map; 74 | }; 75 | 76 | #if defined (KDAB_HAVE_CPP11_EXTERN_TEMPLATES) && !defined(KDGENERICFACTORYBASE_INSTANTIATION) 77 | extern template class KDGenericFactoryBase; 78 | extern template class KDGenericFactoryBase; 79 | extern template class KDGenericFactoryBase; 80 | extern template class KDGenericFactoryBase; 81 | #endif 82 | 83 | #endif // DOXYGEN_RUN 84 | 85 | template< typename T_Product, typename T_Identifier = QString, template< typename U, typename V > class T_Map = QHash > 86 | class MAKEINCLUDES_EXPORT KDGenericFactory 87 | #ifndef DOXYGEN_RUN 88 | : KDGenericFactoryBase 89 | #endif 90 | { 91 | typedef KDGenericFactoryBase base; 92 | public: 93 | virtual ~KDGenericFactory() 94 | { 95 | } 96 | 97 | typedef T_Product* (*FactoryFunction)(); 98 | 99 | template< typename T > 100 | void registerProduct( const T_Identifier& name ) 101 | { 102 | FactoryFunction function = &KDGenericFactory::template create; // disambiguate 103 | registerProductionFunction( name, function ); 104 | } 105 | 106 | #ifdef DOXYGEN_RUN 107 | void unregisterProduct( const T_Identifier& name ); 108 | unsigned int productCount() const; 109 | QList< T_Identifier > availableProducts() const; 110 | #else 111 | using base::unregisterProduct; 112 | using base::productCount; 113 | using base::availableProducts; 114 | #endif 115 | 116 | T_Product* create( const T_Identifier& name ) const 117 | { 118 | return static_cast( base::create( name ) ); 119 | } 120 | 121 | protected: 122 | void registerProductionFunction( const T_Identifier& name, FactoryFunction createfun ) 123 | { 124 | typename base::FactoryFunction fun = reinterpret_cast( createfun ); 125 | base::registerProductionFunction( name, fun ); 126 | } 127 | 128 | private: 129 | template< typename T > 130 | static T_Product * create() 131 | { 132 | return new T; 133 | } 134 | 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /src/kdlockedsharedmemorypointer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS__CORE__KDLOCKEDSHAREDMEMORYPOINTER_H__ 24 | #define __KDTOOLS__CORE__KDLOCKEDSHAREDMEMORYPOINTER_H__ 25 | 26 | #include 27 | 28 | #if QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) 29 | #ifndef QT_NO_SHAREDMEMORY 30 | 31 | #include "kdsharedmemorylocker.h" 32 | #include 33 | 34 | #include 35 | 36 | #ifndef DOXYGEN_RUN 37 | namespace kdtools { 38 | #endif 39 | 40 | class KDLockedSharedMemoryPointerBase { 41 | protected: 42 | explicit KDLockedSharedMemoryPointerBase( QSharedMemory * mem ); 43 | explicit KDLockedSharedMemoryPointerBase( QSharedMemory & mem ); 44 | ~KDLockedSharedMemoryPointerBase(); 45 | 46 | // PENDING(marc) do we really want const propagation here? I 47 | // usually declare all my RAII objects const... 48 | void * get(); 49 | const void * get() const; 50 | 51 | KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR_BASE( get() ) 52 | 53 | size_t byteSize() const; 54 | 55 | private: 56 | KDSharedMemoryLocker locker; 57 | QSharedMemory * const mem; 58 | }; 59 | 60 | template< typename T> 61 | class MAKEINCLUDES_EXPORT KDLockedSharedMemoryPointer KDAB_FINAL_CLASS : KDLockedSharedMemoryPointerBase { 62 | KDAB_DISABLE_COPY( KDLockedSharedMemoryPointer ); 63 | public: 64 | explicit KDLockedSharedMemoryPointer( QSharedMemory * m ) 65 | : KDLockedSharedMemoryPointerBase( m ) {} 66 | explicit KDLockedSharedMemoryPointer( QSharedMemory & m ) 67 | : KDLockedSharedMemoryPointerBase( m ) {} 68 | 69 | T * get() { return static_cast( KDLockedSharedMemoryPointerBase::get() ); } 70 | const T * get() const { return static_cast( KDLockedSharedMemoryPointerBase::get() ); } 71 | 72 | T * data() { return static_cast( get() ); } 73 | const T * data() const { return static_cast( get() ); } 74 | 75 | T & operator*() { assert( get() ); return *get(); } 76 | const T & operator*() const { assert( get() ); return *get(); } 77 | 78 | T * operator->() { return get(); } 79 | const T * operator->() const { return get(); } 80 | 81 | KDAB_USING_SAFE_BOOL_OPERATOR( KDLockedSharedMemoryPointerBase ) 82 | }; 83 | 84 | template 85 | class MAKEINCLUDES_EXPORT KDLockedSharedMemoryArray KDAB_FINAL_CLASS : KDLockedSharedMemoryPointerBase { 86 | KDAB_DISABLE_COPY( KDLockedSharedMemoryArray ); 87 | public: 88 | explicit KDLockedSharedMemoryArray( QSharedMemory * m ) 89 | : KDLockedSharedMemoryPointerBase( m ) {} 90 | explicit KDLockedSharedMemoryArray( QSharedMemory & m ) 91 | : KDLockedSharedMemoryPointerBase( m ) {} 92 | 93 | typedef std::size_t size_type; 94 | typedef std::ptrdiff_t difference_type; 95 | typedef T* iterator; 96 | typedef const T* const_iterator; 97 | typedef std::reverse_iterator< const_iterator > const_reverse_iterator; 98 | typedef std::reverse_iterator< iterator > reverse_iterator; 99 | 100 | iterator begin() { return get(); } 101 | const_iterator begin() const { return get(); } 102 | 103 | iterator end() { return begin() + size(); } 104 | const_iterator end() const { return begin() + size(); } 105 | 106 | reverse_iterator rbegin() { return reverse_iterator( end() ); } 107 | const_reverse_iterator rbegin() const { return reverse_iterator( end() ); } 108 | 109 | reverse_iterator rend() { return reverse_iterator( begin() ); } 110 | const_reverse_iterator rend() const { return const_reverse_iterator( begin() ); } 111 | 112 | size_type size() const { return byteSize() / sizeof( T ); } 113 | 114 | T * get() { return static_cast( KDLockedSharedMemoryPointerBase::get() ); } 115 | const T * get() const { return static_cast( KDLockedSharedMemoryPointerBase::get() ); } 116 | 117 | T & operator[]( difference_type n ) { assert( get() ); return *(get()+n); } 118 | const T & operator[]( difference_type n ) const { assert( get() ); return *(get()+n); } 119 | 120 | T & front() { assert( get() ); return *get(); } 121 | const T & front() const { assert( get() ); return *get(); } 122 | 123 | T & back() { assert( get() ); return *( get() + size() - 1 ); } 124 | const T & back() const { assert( get() ); return *( get() + size() - 1 ); } 125 | 126 | KDAB_USING_SAFE_BOOL_OPERATOR( KDLockedSharedMemoryPointerBase ) 127 | }; 128 | 129 | #ifndef DOXYGEN_RUN 130 | } 131 | #endif 132 | 133 | #endif /* QT_NO_SHAREDMEMORY */ 134 | 135 | #endif /* QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) */ 136 | 137 | #endif /* __KDTOOLS__CORE__KDLOCKEDSHAREDMEMORYPOINTER_H__ */ 138 | -------------------------------------------------------------------------------- /src/kdmetamethoditerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLSCORE_KDMETAMETHODITERATOR_H__ 24 | #define __KDTOOLSCORE_KDMETAMETHODITERATOR_H__ 25 | 26 | #include 27 | 28 | #include 29 | 30 | class KDUPDATER_EXPORT KDMetaMethodIterator KDAB_FINAL_CLASS 31 | { 32 | public: 33 | enum AccessType 34 | { 35 | Private = 1 << QMetaMethod::Private, 36 | Protected = 1 << QMetaMethod::Protected, 37 | Public = 1 << QMetaMethod::Public, 38 | AllAccessTypes = Private | Protected | Public 39 | }; 40 | Q_DECLARE_FLAGS( AccessTypes, AccessType ) 41 | 42 | enum MethodType 43 | { 44 | Method = 0x1, 45 | Signal = 0x2, 46 | Slot = 0x4, 47 | Constructor = 0x8, 48 | AllMethodTypes = Method | Signal | Slot | Constructor 49 | }; 50 | Q_DECLARE_FLAGS( MethodTypes, MethodType ) 51 | 52 | enum IteratorFlag 53 | { 54 | NoFlags = 0x00, 55 | IgnoreQObjectMethods = 0x01, 56 | IgnoreSuperClassMethods = 0x02 57 | }; 58 | Q_DECLARE_FLAGS( IteratorFlags, IteratorFlag ) 59 | 60 | explicit KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags ); 61 | KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags ); 62 | KDMetaMethodIterator( const QMetaObject& metaObject, AccessType access, IteratorFlags flags = NoFlags ); 63 | 64 | explicit KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags ); 65 | KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags ); 66 | KDMetaMethodIterator( const QMetaObject* metaObject, AccessType access, IteratorFlags flags = NoFlags ); 67 | 68 | explicit KDMetaMethodIterator( const QObject* object, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags ); 69 | KDMetaMethodIterator( const QObject* object, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags ); 70 | KDMetaMethodIterator( const QObject* object, AccessType access, IteratorFlags flags = NoFlags ); 71 | 72 | ~KDMetaMethodIterator(); 73 | 74 | bool hasNext() const; 75 | QMetaMethod next(); 76 | 77 | const char* connectableSignature() const; 78 | 79 | private: 80 | class Priv; 81 | kdtools::pimpl_ptr< Priv > d; 82 | }; 83 | 84 | 85 | #endif // __KDTOOLSCORE_KDMETAMETHODITERATOR_H__ 86 | -------------------------------------------------------------------------------- /src/kdsavefile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLSCORE_KDSAVEFILE_H__ 24 | #define __KDTOOLSCORE_KDSAVEFILE_H__ 25 | 26 | #include 27 | 28 | #include 29 | 30 | class KDUPDATER_EXPORT KDSaveFile : public QIODevice 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit KDSaveFile( QObject* parent = 0 ); 35 | explicit KDSaveFile( const QString& filename, QObject* parent = 0 ); 36 | ~KDSaveFile(); 37 | 38 | enum CommitMode { 39 | BackupExistingFile=0x1, 40 | OverwriteExistingFile=0x2 41 | }; 42 | 43 | bool commit( CommitMode=BackupExistingFile ); 44 | 45 | QFile::FileError error() const; 46 | void unsetError(); 47 | 48 | QString fileName() const; 49 | void setFileName( const QString& filename ); 50 | 51 | QFile::Permissions permissions() const; 52 | bool setPermissions( QFile::Permissions ); 53 | 54 | QString backupExtension() const; 55 | void setBackupExtension( const QString& extension ); 56 | 57 | bool flush(); 58 | bool resize( qint64 sz ); 59 | int handle() const; 60 | 61 | qint64 bytesAvailable() const; 62 | qint64 bytesToWrite() const; 63 | bool canReadLine() const; 64 | void close(); 65 | bool isSequential() const; 66 | bool open( OpenMode mode=QIODevice::ReadWrite ); //only valid: WriteOnly, ReadWrite 67 | bool seek( qint64 pos ); 68 | qint64 size() const; 69 | bool waitForBytesWritten( int msecs ); 70 | bool waitForReadyRead( int msecs ); 71 | 72 | protected: 73 | qint64 readData( char* data, qint64 maxSize ); 74 | qint64 readLineData( char* data, qint64 maxSize ); 75 | qint64 writeData( const char* data, qint64 maxSize ); 76 | 77 | private: 78 | class Private; 79 | kdtools::pimpl_ptr d; 80 | }; 81 | 82 | #endif // __KDTOOLSCORE_KDSAVEFILE_H__ 83 | -------------------------------------------------------------------------------- /src/kdsemaphorereleaser.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdsemaphorereleaser.h" 24 | 25 | #include 26 | 27 | /*! 28 | \class KDSemaphoreReleaser 29 | \ingroup raii core 30 | \brief Exception-safe and convenient wrapper around QSemaphore::release() 31 | 32 | All methods in this class are nothrow. 33 | 34 | Semaphores differ from mutexes in that semaphore acquirers and 35 | releasers usually live on separate threads. So an RAII class a la 36 | QMutexLocker doesn't make much sense for semaphores. 37 | 38 | It is occasionally important to ensure that the release 39 | operation is called reliably, even in the face of early returns or 40 | exceptions. 41 | 42 | This is where KDSemaphoreReleaser comes in. It stores the 43 | constructor arguments, thereby deferring the QSemaphore::release() 44 | call until the current scope's exit. 45 | 46 | There is no KDSemaphoreAcquirer, since the acquire operation is 47 | usually done before other, in particular, exception-throwing code is 48 | executed, so a RAII approach makes little sense for the acquire 49 | operation. 50 | 51 | Example (using QSemaphore as a multi-thread join): 52 | 53 | Manager Thread: 54 | \code 55 | QSemaphore sem; 56 | const int numWorkItems = ...; 57 | for ( int i = 0 ; i < numWorkItems ; ++it ) 58 | startWorkItem( i, sem ); 59 | sem.aquire( numWorkItems ); // join work items 60 | \endcode 61 | 62 | Work Item: 63 | \code 64 | void doWork( int i, QSemaphore & sem ) { 65 | const KDSemaphoreReleaser releaser( sem ); 66 | // do work, might throw execeptions 67 | if ( early return ) 68 | return; 69 | } // reliably calls sem.release() when exiting this scope 70 | \endcode 71 | 72 | \since_c 2.3. 73 | */ 74 | 75 | 76 | /*! 77 | Constructor. Schedules a \a sem->release( \a count ) call at scope exit. 78 | */ 79 | KDSemaphoreReleaser::KDSemaphoreReleaser( QSemaphore * sem, int count ) 80 | : sem( sem ), count( count ) 81 | { 82 | 83 | } 84 | 85 | /*! 86 | \overload 87 | */ 88 | KDSemaphoreReleaser::KDSemaphoreReleaser( QSemaphore & sem, int count ) 89 | : sem( &sem ), count( count ) 90 | { 91 | 92 | } 93 | 94 | /*! 95 | Destructor. Calls QSemaphore::release() with the arguments passed 96 | earlier to the constructor. 97 | */ 98 | KDSemaphoreReleaser::~KDSemaphoreReleaser() { 99 | if ( sem ) sem->release( count ); 100 | } 101 | -------------------------------------------------------------------------------- /src/kdsemaphorereleaser.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS__CORE__KDSEMAPHORERELEASER_H__ 24 | #define __KDTOOLS__CORE__KDSEMAPHORERELEASER_H__ 25 | 26 | #include 27 | 28 | QT_BEGIN_NAMESPACE 29 | class QSemaphore; 30 | QT_END_NAMESPACE 31 | 32 | class KDUPDATER_EXPORT KDSemaphoreReleaser KDAB_FINAL_CLASS { 33 | Q_DISABLE_COPY( KDSemaphoreReleaser ) 34 | public: 35 | explicit KDSemaphoreReleaser( QSemaphore * sem, int count=1 ); 36 | explicit KDSemaphoreReleaser( QSemaphore & sem, int count=1 ); 37 | ~KDSemaphoreReleaser(); 38 | private: 39 | QSemaphore * const sem; 40 | const int count; 41 | }; 42 | 43 | #endif /* __KDTOOLS__CORE__KDSEMAPHORERELEASER_H__ */ 44 | 45 | -------------------------------------------------------------------------------- /src/kdsharedmemorylocker.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdsharedmemorylocker.h" 24 | 25 | #if QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) 26 | 27 | #ifndef QT_NO_SHAREDMEMORY 28 | 29 | #include 30 | 31 | using namespace kdtools; 32 | 33 | /*! 34 | \class KDSharedMemoryLocker 35 | \ingroup raii core 36 | \brief Exception-safe and convenient wrapper around QSharedMemory::lock() 37 | */ 38 | 39 | /*! 40 | Constructor. Locks the shared memory segment \a m. 41 | If another process has locking the segment, this constructor blocks 42 | until the lock is released. The memory segments needs to be properly created or attached. 43 | */ 44 | KDSharedMemoryLocker::KDSharedMemoryLocker( QSharedMemory * m ) 45 | : mem( m ) 46 | { 47 | if ( mem ) 48 | mem->lock(); 49 | } 50 | 51 | /*! 52 | Constructor. 53 | \overload 54 | */ 55 | KDSharedMemoryLocker::KDSharedMemoryLocker( QSharedMemory & m ) 56 | : mem( &m ) 57 | { 58 | if ( mem ) 59 | mem->lock(); 60 | } 61 | 62 | /*! 63 | Destructor. Unlocks the shared memory segment associated with this 64 | KDSharedMemoryLocker. 65 | */ 66 | KDSharedMemoryLocker::~KDSharedMemoryLocker() { 67 | if ( mem ) 68 | mem->unlock(); 69 | } 70 | 71 | #endif /* QT_NO_SHAREDMEMORY */ 72 | 73 | #endif /* QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) */ 74 | -------------------------------------------------------------------------------- /src/kdsharedmemorylocker.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS__CORE__KDSHAREDMEMORYLOCKER_H 24 | #define __KDTOOLS__CORE__KDSHAREDMEMORYLOCKER_H 25 | 26 | #include 27 | 28 | #if QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) 29 | #ifndef QT_NO_SHAREDMEMORY 30 | 31 | QT_BEGIN_NAMESPACE 32 | class QSharedMemory; 33 | QT_END_NAMESPACE 34 | 35 | #ifndef DOXYGEN_RUN 36 | namespace kdtools { 37 | #endif 38 | 39 | class KDUPDATER_EXPORT KDSharedMemoryLocker KDAB_FINAL_CLASS { 40 | Q_DISABLE_COPY( KDSharedMemoryLocker ) 41 | public: 42 | explicit KDSharedMemoryLocker( QSharedMemory * mem ); 43 | explicit KDSharedMemoryLocker( QSharedMemory & mem ); 44 | ~KDSharedMemoryLocker(); 45 | 46 | private: 47 | QSharedMemory * const mem; 48 | }; 49 | 50 | #ifndef DOXYGEN_RUN 51 | } 52 | #endif 53 | 54 | #endif /* QT_NO_SHAREDMEMORY */ 55 | 56 | #endif /* QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN ) */ 57 | 58 | #endif /* __KDTOOLS__CORE__KDSHAREDMEMORYLOCKER_H */ 59 | -------------------------------------------------------------------------------- /src/kdupdater.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATER_H__ 24 | #define __KDTOOLS_KDUPDATER_H__ 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace KDUpdater 31 | { 32 | enum Error 33 | { 34 | ENoError = 0, 35 | ECannotStartTask, 36 | ECannotPauseTask, 37 | ECannotResumeTask, 38 | ECannotStopTask, 39 | EUnknown 40 | }; 41 | 42 | enum UpdateType { 43 | PackageUpdate = 0x1, 44 | CompatUpdate = 0x2, 45 | NewPackage = 0x4, 46 | AllUpdate = PackageUpdate | CompatUpdate 47 | }; 48 | Q_DECLARE_FLAGS( UpdateTypes, UpdateType ) 49 | Q_DECLARE_OPERATORS_FOR_FLAGS( UpdateTypes ) 50 | 51 | KDUPDATER_EXPORT int compareVersion(const QString& v1, const QString& v2); 52 | KDUPDATER_EXPORT bool versionLessThan(const QString& v1, const QString& v2); 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/kdupdaterapplication.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterapplication.h" 24 | 25 | #ifndef KDUPDATER_NO_COMPAT 26 | 27 | using namespace KDUpdater; 28 | 29 | Application::Application() 30 | { 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/kdupdaterapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERAPPLICATION_H__ 24 | #define __KDTOOLS_KDUPDATERAPPLICATION_H__ 25 | 26 | #ifndef KDUPDATER_NO_COMPAT 27 | 28 | #include "kdupdatertarget.h" 29 | 30 | #include 31 | 32 | namespace KDUpdater { 33 | 34 | class KDUPDATER_EXPORT Application : public Target 35 | { 36 | public: 37 | Application(); 38 | 39 | void setApplicationDirectory( const QString & dir ) { setDirectory( dir ); } 40 | QString applicationDirectory() const { return directory(); } 41 | 42 | QString applicationName() const { return name(); } 43 | QString applicationVersion() const { return version(); } 44 | }; 45 | 46 | } 47 | #endif // KDUPDATER_NO_COMPAT 48 | 49 | #endif /* __KDTOOLS_KDUPDATERAPPLICATION_H__ */ 50 | -------------------------------------------------------------------------------- /src/kdupdaterfiledownloader.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef KDUPDATER_KDUPDATERFILEDOWNLOADER_H 24 | #define KDUPDATER_KDUPDATERFILEDOWNLOADER_H 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace KDUpdater 34 | { 35 | KDUPDATER_EXPORT QByteArray calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo ); 36 | KDUPDATER_EXPORT QByteArray calculateHash( const QString& path, QCryptographicHash::Algorithm algo ); 37 | 38 | class HashVerificationJob; 39 | 40 | class KDUPDATER_EXPORT FileDownloader : public QObject 41 | { 42 | Q_OBJECT 43 | Q_PROPERTY( bool autoRemoveDownloadedFile READ isAutoRemoveDownloadedFile WRITE setAutoRemoveDownloadedFile ) 44 | Q_PROPERTY( QUrl url READ url WRITE setUrl ) 45 | Q_PROPERTY( QString scheme READ scheme ) 46 | 47 | public: 48 | explicit FileDownloader(const QString& scheme, QObject* parent=0); 49 | ~FileDownloader(); 50 | 51 | void setUrl(const QUrl& url); 52 | QUrl url() const; 53 | 54 | void setSha1Sum( const QByteArray& sha1 ); 55 | QByteArray sha1Sum() const; 56 | 57 | QString errorString() const; 58 | QString scheme() const; 59 | 60 | virtual bool canDownload() const = 0; 61 | virtual bool isDownloaded() const = 0; 62 | virtual QString downloadedFileName() const = 0; 63 | virtual FileDownloader* clone( QObject* parent=0 ) const = 0; 64 | 65 | void download(); 66 | 67 | void setAutoRemoveDownloadedFile(bool val); 68 | bool isAutoRemoveDownloadedFile() const; 69 | 70 | void setFollowRedirects( bool val ); 71 | bool followRedirects() const; 72 | 73 | public Q_SLOTS: 74 | virtual void cancelDownload(); 75 | void sha1SumVerified( KDUpdater::HashVerificationJob* job ); 76 | 77 | protected: 78 | virtual void onError() = 0; 79 | virtual void onSuccess() = 0; 80 | 81 | Q_SIGNALS: 82 | void downloadProgress(int); 83 | void downloadStarted(); 84 | void downloadCanceled(); 85 | 86 | #ifndef Q_MOC_RUN 87 | private: 88 | #endif 89 | void downloadCompleted(); 90 | void downloadAborted(const QString& errorMessage); 91 | 92 | protected: 93 | void setDownloadCompleted( const QString& filepath ); 94 | void setDownloadAborted( const QString& error ); 95 | 96 | private Q_SLOTS: 97 | virtual void doDownload() = 0; 98 | 99 | private: 100 | struct FileDownloaderData; 101 | kdtools::pimpl_ptr d; 102 | }; 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/kdupdaterfiledownloader_mac.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include 24 | 25 | #ifdef QT_MAC_USE_COCOA 26 | 27 | /*! 28 | This encourages Qt to start a NSApp if there's none running yet. This makes sure 29 | that Qt is handling meta call events properly. Background: downloader calls doDownload as 30 | queued connection, this gets not called for the first time if there's no QCoreApplication 31 | being exec()'d yet. This is only required if Qt is using Cocoa. 32 | \internal 33 | */ 34 | void kdupdaterEncourageQtToStartNSApp() 35 | { 36 | static bool didEncourage = false; 37 | if( !didEncourage ) 38 | { 39 | QEventLoop loop; 40 | QMetaObject::invokeMethod(&loop, "quit", Qt::QueuedConnection); 41 | loop.exec(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeUserInputEvents); 42 | didEncourage = true; 43 | } 44 | } 45 | 46 | #endif // QT_MAC_USE_COCOA 47 | -------------------------------------------------------------------------------- /src/kdupdaterfiledownloaderfactory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterfiledownloaderfactory.h" 24 | #include "kdupdaterfiledownloader_p.h" 25 | 26 | #include 27 | 28 | /*! 29 | \internal 30 | \ingroup kdupdater 31 | \class KDUpdater::FileDownloaderFactory kdupdaterfiledownloaderfactory.h 32 | \brief Factory for \ref KDUpdater::FileDownloader 33 | 34 | This class acts as a factory for \ref KDUpdater::FileDownloader. You can register 35 | one or more file downloaders with this factory and query them based on their scheme. 36 | 37 | This class follows the singleton design pattern. Only one instance of this class can 38 | be created and its reference can be fetched from the \ref instance() method. 39 | */ 40 | 41 | using namespace KDUpdater; 42 | 43 | struct FileDownloaderFactory::FileDownloaderFactoryData 44 | { 45 | bool m_followRedirects; 46 | }; 47 | 48 | FileDownloaderFactory& FileDownloaderFactory::instance() 49 | { 50 | static KDUpdater::FileDownloaderFactory theFactory; 51 | return theFactory; 52 | } 53 | 54 | /*! 55 | Constructor 56 | */ 57 | FileDownloaderFactory::FileDownloaderFactory() 58 | : d ( new FileDownloaderFactoryData ) 59 | { 60 | // Register the default file downloader set 61 | registerFileDownloader< LocalFileDownloader >( QLatin1String( "file" ) ); 62 | #if 0 63 | registerFileDownloader< FtpDownloader >( QLatin1String( "ftp" ) ); 64 | #endif 65 | registerFileDownloader< HttpDownloader >( QLatin1String( "http" ) ); 66 | registerFileDownloader< ResourceFileDownloader >( QLatin1String( "resource" ) ); 67 | d->m_followRedirects = false; 68 | } 69 | /*! 70 | Configures the factory to handle redirects if the protocol of the download supports it 71 | */ 72 | void FileDownloaderFactory::setFollowRedirects( bool val ) 73 | { 74 | FileDownloaderFactory::instance().d->m_followRedirects = val; 75 | } 76 | 77 | /*! 78 | Checks if the factory creates downloader that follow redirects 79 | */ 80 | bool FileDownloaderFactory::followRedirects() 81 | { 82 | return FileDownloaderFactory::instance().d->m_followRedirects; 83 | } 84 | 85 | /*! 86 | Destructor 87 | */ 88 | FileDownloaderFactory::~FileDownloaderFactory() 89 | { 90 | } 91 | 92 | /*! 93 | Returns a new instance to the \ref KDUpdater::FileDownloader based whose scheme is equal to the string 94 | passed as parameter to this function. 95 | \note Ownership of this object remains to the programmer. 96 | */ 97 | FileDownloader* FileDownloaderFactory::create( const QString& scheme, QObject* parent ) const 98 | { 99 | FileDownloader* const downloader = KDGenericFactory< FileDownloader >::create( scheme ); 100 | if( downloader != 0 ) { 101 | downloader->setFollowRedirects( d->m_followRedirects ); 102 | downloader->setParent( parent ); 103 | } 104 | return downloader; 105 | } 106 | 107 | /*! 108 | KDUpdater::FileDownloaderFactory::registerFileDownlooader 109 | Registers a new file downloader with the factory. If there is already a downloader with the same scheme, 110 | the downloader is replaced. The ownership of the downloader is transfered to the factory. 111 | */ 112 | 113 | /*! 114 | Returns the number of file downloaders in the factory. 115 | */ 116 | int FileDownloaderFactory::fileDownloaderCount() const 117 | { 118 | return productCount(); 119 | } 120 | 121 | /*! 122 | Returns a list of schemes supported by this factory, i.e. for which a 123 | FileDownloader was registered. 124 | */ 125 | QStringList FileDownloaderFactory::supportedSchemes() const 126 | { 127 | return availableProducts(); 128 | } 129 | -------------------------------------------------------------------------------- /src/kdupdaterfiledownloaderfactory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef KDUPDATER_KDUPDATERFILEDOWNLOADERFACTORY_H 24 | #define KDUPDATER_KDUPDATERFILEDOWNLOADERFACTORY_H 25 | 26 | #include "kdupdater.h" 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | QT_BEGIN_NAMESPACE 34 | class QObject; 35 | QT_END_NAMESPACE 36 | 37 | namespace KDUpdater 38 | { 39 | class FileDownloader; 40 | 41 | class KDUPDATER_EXPORT FileDownloaderFactory : public KDGenericFactory< FileDownloader > 42 | { 43 | KDAB_DISABLE_COPY( FileDownloaderFactory ); 44 | public: 45 | static FileDownloaderFactory& instance(); 46 | ~FileDownloaderFactory(); 47 | 48 | template< typename T > 49 | void registerFileDownloader( const QString& scheme ) 50 | { 51 | registerProduct< T >( scheme ); 52 | } 53 | QStringList supportedSchemes() const; 54 | 55 | int fileDownloaderCount() const; 56 | FileDownloader* create( const QString& scheme, QObject* parent = 0 ) const; 57 | static void setFollowRedirects( bool val ); 58 | static bool followRedirects(); 59 | 60 | private: 61 | FileDownloaderFactory(); 62 | 63 | private: 64 | struct FileDownloaderFactoryData; 65 | kdtools::pimpl_ptr d; 66 | }; 67 | } 68 | 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/kdupdaterpackagesinfo.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERPACKAGESINFO_H__ 24 | #define __KDTOOLS_KDUPDATERPACKAGESINFO_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #ifndef KDUPDATER_NO_COMPAT 35 | # include "kdupdaterapplication.h" 36 | #endif 37 | 38 | namespace KDUpdater 39 | { 40 | class Target; 41 | class UpdateInstaller; 42 | 43 | struct KDUPDATER_EXPORT PackageInfo 44 | { 45 | QString name; 46 | QString pixmap; 47 | QString title; 48 | QString description; 49 | QString version; 50 | QStringList dependencies; 51 | QDate lastUpdateDate; 52 | QDate installDate; 53 | quint64 uncompressedSize; 54 | }; 55 | 56 | class KDUPDATER_EXPORT PackagesInfo : public QObject 57 | { 58 | Q_OBJECT 59 | Q_PROPERTY( QString targetName READ targetName WRITE setTargetName ) 60 | Q_PROPERTY( QString targetVersion READ targetVersion WRITE setTargetVersion ) 61 | #ifndef KDUPDATER_NO_COMPAT 62 | Q_PROPERTY( QString applicationName READ applicationName WRITE setApplicationName ) 63 | Q_PROPERTY( QString applicationVersion READ applicationVersion WRITE setApplicationVersion ) 64 | #endif 65 | Q_PROPERTY( int compatLevel READ compatLevel WRITE setCompatLevel ) 66 | Q_PROPERTY( QString errorString READ errorString ) 67 | Q_PROPERTY( QString fileName READ fileName WRITE setFileName ) 68 | 69 | public: 70 | enum Error 71 | { 72 | NoError=0, 73 | NotYetReadError, 74 | CouldNotReadPackageFileError, 75 | InvalidXmlError, 76 | InvalidContentError 77 | }; 78 | 79 | Target * target() const; 80 | 81 | bool isValid() const; 82 | QString errorString() const; 83 | Error error() const; 84 | 85 | void setFileName( const QString& fileName ); 86 | QString fileName() const; 87 | 88 | void setTargetName( const QString & name ); 89 | QString targetName() const; 90 | 91 | void setTargetVersion( const QString & version ); 92 | QString targetVersion() const; 93 | 94 | int packageInfoCount() const; 95 | PackageInfo packageInfo( int index ) const; 96 | int findPackageInfo( const QString& pkgName ) const; 97 | QVector packageInfos() const; 98 | 99 | int compatLevel() const; 100 | void setCompatLevel( int level ); 101 | 102 | bool installPackage( const QString& pkgName, const QString& version, const QString& title = QString(), const QString& description = QString() 103 | , const QStringList& dependencies = QStringList(), quint64 uncompressedSize = 0 ); 104 | bool updatePackage( const QString &pkgName, const QString &version, const QDate &date ); 105 | bool removePackage( const QString& pkgName ); 106 | 107 | #ifndef KDUPDATER_NO_COMPAT 108 | Application * application() const { return dynamic_cast( target() ); } 109 | void setApplicationName( const QString & n ) { setTargetName( n ); } 110 | QString applicationName() const { return targetName(); } 111 | void setApplicationVersion( const QString & v ) { setTargetVersion( v ); } 112 | QString applicationVersion() const { return targetVersion(); } 113 | #endif 114 | 115 | public Q_SLOTS: 116 | void refresh(); 117 | 118 | Q_SIGNALS: 119 | void reset(); 120 | 121 | protected: 122 | explicit PackagesInfo( Target * target=0 ); 123 | ~PackagesInfo(); 124 | 125 | void writeToDisk(); 126 | 127 | private: 128 | friend class Target; 129 | friend class UpdateInstaller; 130 | class Private; 131 | kdtools::pimpl_ptr< Private > d; 132 | }; 133 | 134 | } 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /src/kdupdaterpackagesmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERPACKAGESMODEL_H__ 24 | #define __KDTOOLS_KDUPDATERPACKAGESMODEL_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | class PackagesInfo; 34 | 35 | class KDUPDATER_EXPORT PackagesModel : public QAbstractTableModel 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | enum Column 41 | { 42 | Name, 43 | Title, 44 | Description, 45 | Version, 46 | LastUpdate 47 | }; 48 | 49 | explicit PackagesModel( QObject* parent =0 ); 50 | ~PackagesModel(); 51 | 52 | void setPackageInfo( const PackagesInfo* packageInfo ); 53 | const PackagesInfo* packagesInfo() const; 54 | 55 | int rowCount( const QModelIndex& parent = QModelIndex() ) const; 56 | int columnCount( const QModelIndex& parent = QModelIndex() ) const; 57 | 58 | QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 59 | QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 60 | 61 | private: 62 | Q_PRIVATE_SLOT( d, void refresh() ) 63 | 64 | class Private; 65 | kdtools::pimpl_ptr< Private > d; 66 | }; 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/kdupdaterpackagesview.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterpackagesview.h" 24 | #include "kdupdaterpackagesmodel.h" 25 | 26 | /*! 27 | \ingroup kdupdater 28 | \class KDUpdater::PackagesView kdupdaterpackagesview.h KDUpdaterPackagesView 29 | \brief A widget that can show packages contained in \ref KDUpdater::PackagesInfo 30 | 31 | \ref KDUpdater::PackagesInfo, associated with \ref KDUpdater::Target, contains 32 | information about all the packages installed in the target. This widget helps view the packages 33 | in a list. 34 | 35 | \image html packagesview.jpg 36 | 37 | To use this widget, just create an instance and pass to \ref setPackageInfo() a pointer to 38 | \ref KDUpdater::PackagesInfo whose information you want this widget to show. 39 | */ 40 | 41 | using namespace KDUpdater; 42 | 43 | class PackagesView::Private 44 | { 45 | public: 46 | Private( PackagesView* qq ) 47 | : q( qq ) 48 | { 49 | } 50 | 51 | private: 52 | PackagesView* const q; 53 | 54 | public: 55 | PackagesModel model; 56 | }; 57 | 58 | /*! 59 | Constructor. 60 | */ 61 | PackagesView::PackagesView(QWidget* parent) 62 | : QTreeView( parent ), 63 | d ( new Private( this ) ) 64 | { 65 | setModel( &d->model ); 66 | setRootIsDecorated( false ); 67 | } 68 | 69 | /*! 70 | Destructor 71 | */ 72 | PackagesView::~PackagesView() 73 | { 74 | } 75 | 76 | /*! 77 | Sets the package info whose information this widget should show. 78 | 79 | \code 80 | KDUpdater::Target target; 81 | 82 | KDUpdater::PackagesView packageView; 83 | packageView.setPackageInfo( target.packagesInfo() ); 84 | packageView.show(); 85 | \endcode 86 | 87 | */ 88 | void PackagesView::setPackageInfo( const PackagesInfo* packagesInfo ) 89 | { 90 | d->model.setPackageInfo( packagesInfo ); 91 | } 92 | 93 | /*! 94 | Returns a pointer to the package info whose information this widget is showing. 95 | */ 96 | const PackagesInfo* PackagesView::packagesInfo() const 97 | { 98 | return d->model.packagesInfo(); 99 | } 100 | -------------------------------------------------------------------------------- /src/kdupdaterpackagesview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERPACKAGESVIEW_H__ 24 | #define __KDTOOLS_KDUPDATERPACKAGESVIEW_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | class PackagesInfo; 34 | 35 | class KDUPDATER_EXPORT PackagesView : public QTreeView 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit PackagesView(QWidget* parent=0); 41 | ~PackagesView(); 42 | 43 | void setPackageInfo( const PackagesInfo* packageInfo ); 44 | const PackagesInfo* packagesInfo() const; 45 | 46 | private: 47 | class Private; 48 | kdtools::pimpl_ptr< Private > d; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/kdupdatertarget.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERTARGET_H__ 24 | #define __KDTOOLS_KDUPDATERTARGET_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | QT_BEGIN_NAMESPACE 30 | class QUrl; 31 | QT_END_NAMESPACE 32 | 33 | namespace KDUpdater 34 | { 35 | class PackagesInfo; 36 | class UpdateSourcesInfo; 37 | class Task; 38 | 39 | class KDUPDATER_EXPORT Target { 40 | DOXYGEN_PROPERTY( QString directory READ directory WRITE setDirectory ) 41 | DOXYGEN_PROPERTY( QString name READ name ) 42 | DOXYGEN_PROPERTY( QString version READ version ) 43 | DOXYGEN_PROPERTY( int compatLevel READ compatLevel ) 44 | DOXYGEN_PROPERTY( QString packagesXMLFileName READ packagesXMLFileName WRITE setPackagesXMLFileName ) 45 | DOXYGEN_PROPERTY( QString updateSourcesXMLFileName READ updateSourcesXMLFileName WRITE setUpdateSourcesXMLFileName ) 46 | public: 47 | Target(); 48 | explicit Target( const QString& name ); 49 | virtual ~Target(); 50 | 51 | void setDirectory(const QString& dir); 52 | QString directory() const; 53 | 54 | QString name() const; 55 | QString version() const; 56 | int compatLevel() const; 57 | 58 | void setPackagesXMLFileName(const QString& fileName); 59 | QString packagesXMLFileName() const; 60 | PackagesInfo* packagesInfo() const; 61 | 62 | void addUpdateSource( const QString& name, const QString& title, 63 | const QString& description, const QUrl& url, int priority = -1 ); 64 | 65 | void setUpdateSourcesXMLFileName(const QString& fileName); 66 | QString updateSourcesXMLFileName() const; 67 | UpdateSourcesInfo* updateSourcesInfo() const; 68 | 69 | private: 70 | friend class ::KDUpdater::Task; 71 | void addTask( Task * task ); 72 | 73 | private: 74 | class Private; 75 | kdtools::pimpl_ptr< Private > d; 76 | }; 77 | 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/kdupdatertask.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERTASK_H__ 24 | #define __KDTOOLS_KDUPDATERTASK_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | 34 | class Target; 35 | 36 | class KDUPDATER_EXPORT Task : public QObject 37 | { 38 | Q_OBJECT 39 | Q_PROPERTY( int capabilities READ capabilities ) 40 | Q_PROPERTY( int error READ error ) 41 | Q_PROPERTY( QString errorString READ errorString ) 42 | Q_PROPERTY( QString name READ name ) 43 | Q_PROPERTY( int progressPercent READ progressPercent ) 44 | Q_PROPERTY( QString progressText READ progressText ) 45 | 46 | public: 47 | enum Capability 48 | { 49 | NoCapability = 0, 50 | Pausable = 1, 51 | Stoppable = 2 52 | }; 53 | 54 | virtual ~Task(); 55 | 56 | QString name() const; 57 | int capabilities() const; 58 | 59 | int error() const; 60 | QString errorString() const; 61 | 62 | bool isRunning() const; 63 | bool isFinished() const; 64 | bool isPaused() const; 65 | bool isStopped() const; 66 | 67 | int progressPercent() const; 68 | QString progressText() const; 69 | 70 | public Q_SLOTS: 71 | void run(); 72 | void stop(); 73 | void pause(); 74 | void resume(); 75 | 76 | Q_SIGNALS: 77 | void error(int code, const QString& errorText); 78 | void progressValue(int percent); 79 | void progressText(const QString& progressText); 80 | void started(); 81 | void paused(); 82 | void resumed(); 83 | void stopped(); 84 | void finished(); 85 | 86 | protected: 87 | explicit Task( const QString & name, int caps=NoCapability, Target * target=0 ); 88 | void reportProgress(int percent, const QString& progressText); 89 | void reportError(int errorCode, const QString& errorText); 90 | void reportDone(); 91 | 92 | void reportError(const QString& errorText) 93 | { 94 | reportError(EUnknown, errorText); 95 | } 96 | 97 | protected: 98 | // Task interface 99 | virtual void doRun() = 0; 100 | virtual bool doStop() = 0; 101 | virtual bool doPause() = 0; 102 | virtual bool doResume() = 0; 103 | 104 | private: 105 | class Private; 106 | kdtools::pimpl_ptr< Private > d; 107 | }; 108 | } 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /src/kdupdaterufcompresscommon.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterufcompresscommon_p.h" 24 | 25 | #include 26 | #include 27 | 28 | using namespace KDUpdater; 29 | 30 | bool UFHeader::isValid() const 31 | { 32 | return magic == QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) && 33 | fileList.count() == permList.count() && 34 | fileList.count() == isDirList.count(); 35 | } 36 | 37 | void UFHeader::addToHash(QCryptographicHash& hash) const 38 | { 39 | QByteArray data; 40 | QDataStream stream( &data, QIODevice::WriteOnly ); 41 | stream << *this; 42 | hash.addData(data); 43 | } 44 | 45 | UFEntry::UFEntry() 46 | : permissions( 0 ) 47 | { 48 | } 49 | 50 | bool UFEntry::isValid() const 51 | { 52 | return !fileName.isEmpty(); 53 | } 54 | 55 | void UFEntry::addToHash(QCryptographicHash& hash) const 56 | { 57 | QByteArray data; 58 | QDataStream stream( &data, QIODevice::WriteOnly ); 59 | stream.setVersion( QDataStream::Qt_5_0 ); 60 | stream << *this; 61 | hash.addData(data); 62 | } 63 | 64 | namespace KDUpdater 65 | { 66 | 67 | QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr ) 68 | { 69 | stream << hdr.magic; 70 | stream << hdr.fileList; 71 | stream << hdr.permList; 72 | stream << hdr.isDirList; 73 | return stream; 74 | } 75 | 76 | QDataStream& operator>>( QDataStream& stream, UFHeader& hdr ) 77 | { 78 | const QDataStream::Status oldStatus = stream.status(); 79 | stream >> hdr.magic; 80 | if( stream.status() == QDataStream::Ok && hdr.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) ) 81 | stream.setStatus( QDataStream::ReadCorruptData ); 82 | 83 | if( stream.status() == QDataStream::Ok ) 84 | stream >> hdr.fileList; 85 | 86 | if( stream.status() == QDataStream::Ok ) 87 | stream >> hdr.permList; 88 | 89 | if( stream.status() == QDataStream::Ok ) 90 | stream >> hdr.isDirList; 91 | 92 | if( stream.status() == QDataStream::Ok && ( hdr.fileList.count() != hdr.permList.count() || hdr.permList.count() != hdr.isDirList.count() ) ) 93 | stream.setStatus( QDataStream::ReadCorruptData ); 94 | 95 | if( stream.status() != QDataStream::Ok ) 96 | hdr = UFHeader(); 97 | 98 | if( oldStatus != QDataStream::Ok ) 99 | stream.setStatus( oldStatus ); 100 | 101 | return stream; 102 | } 103 | 104 | QDataStream& operator<<( QDataStream& stream, const UFEntry& entry ) 105 | { 106 | stream << entry.fileName; 107 | stream << entry.permissions; 108 | stream << entry.fileData; 109 | return stream; 110 | } 111 | 112 | QDataStream& operator>>( QDataStream& stream, UFEntry& entry ) 113 | { 114 | const QDataStream::Status oldStatus = stream.status(); 115 | if( stream.status() == QDataStream::Ok ) 116 | stream >> entry.fileName; 117 | if( stream.status() == QDataStream::Ok ) 118 | stream >> entry.permissions; 119 | if( stream.status() == QDataStream::Ok ) 120 | stream >> entry.fileData; 121 | 122 | if( stream.status() != QDataStream::Ok ) 123 | entry = UFEntry(); 124 | 125 | if( oldStatus != QDataStream::Ok ) 126 | stream.setStatus( oldStatus ); 127 | 128 | return stream; 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/kdupdaterufcompresscommon_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUFCOMPRESSCOMMON_P_H__ 24 | #define __KDTOOLS_KDUPDATERUFCOMPRESSCOMMON_P_H__ 25 | 26 | #define KD_UPDATER_UF_HEADER_MAGIC "KDVCLZ" 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | QT_BEGIN_NAMESPACE 35 | class QCryptographicHash; 36 | class QDataStream; 37 | QT_END_NAMESPACE 38 | 39 | namespace KDUpdater 40 | { 41 | struct KDUPDATER_EXPORT UFHeader 42 | { 43 | QString magic; 44 | QStringList fileList; 45 | QVector permList; 46 | QVector isDirList; 47 | 48 | bool isValid() const; 49 | 50 | void addToHash( QCryptographicHash& hash ) const; 51 | }; 52 | 53 | struct KDUPDATER_EXPORT UFEntry 54 | { 55 | QString fileName; 56 | quint64 permissions; 57 | QByteArray fileData; 58 | 59 | UFEntry(); 60 | 61 | bool isValid() const; 62 | 63 | void addToHash(QCryptographicHash& hash) const; 64 | }; 65 | 66 | KDUPDATER_EXPORT QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr ); 67 | KDUPDATER_EXPORT QDataStream& operator>>( QDataStream& stream, UFHeader& hdr ); 68 | 69 | KDUPDATER_EXPORT QDataStream& operator<<( QDataStream& stream, const UFEntry& entry ); 70 | KDUPDATER_EXPORT QDataStream& operator>>( QDataStream& stream, UFEntry& entry ); 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/kdupdaterufuncompressor_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H__ 24 | #define __KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H__ 25 | 26 | #include 27 | 28 | #include 29 | 30 | QT_BEGIN_NAMESPACE 31 | class QString; 32 | QT_END_NAMESPACE 33 | 34 | namespace KDUpdater 35 | { 36 | class KDUPDATER_EXPORT UFUncompressor 37 | { 38 | Q_DECLARE_TR_FUNCTIONS(KDUpdater::UFUncompressor) 39 | 40 | public: 41 | UFUncompressor(); 42 | ~UFUncompressor(); 43 | 44 | QString errorString() const; 45 | 46 | void setFileName(const QString& fileName); 47 | QString fileName() const; 48 | 49 | void setDestination(const QString& dest); 50 | QString destination() const; 51 | 52 | bool uncompress(); 53 | 54 | private: 55 | class Private; 56 | kdtools::pimpl_ptr< Private > d; 57 | }; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/kdupdaterupdate.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATE_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATE_H__ 25 | 26 | #include "kdupdater.h" 27 | #include "kdupdatertask.h" 28 | #include 29 | 30 | #ifndef KDUPDATER_NO_COMPAT 31 | # include "kdupdaterapplication.h" 32 | #endif 33 | 34 | QT_BEGIN_NAMESPACE 35 | template< typename K, typename V > 36 | class QMap; 37 | 38 | template< typename T > 39 | class QList; 40 | 41 | class QDate; 42 | class QUrl; 43 | QT_END_NAMESPACE 44 | 45 | namespace KDUpdater 46 | { 47 | class Target; 48 | struct UpdateSourceInfo; 49 | class UpdateFinder; 50 | class UpdateOperation; 51 | 52 | class KDUPDATER_EXPORT Update : public Task 53 | { 54 | Q_OBJECT 55 | Q_PROPERTY( bool canDownload READ canDownload ) 56 | Q_PROPERTY( quint64 compressedSize READ compressedSize ) 57 | Q_PROPERTY( bool downloaded READ isDownloaded ) 58 | Q_PROPERTY( QString downloadedFileName READ downloadedFileName ) 59 | Q_PROPERTY( QDate releaseDate READ releaseDate ) 60 | Q_PROPERTY( UpdateType type READ type ) 61 | Q_PROPERTY( quint64 uncompressedSize READ uncompressedSize ) 62 | Q_PROPERTY( QUrl updateUrl READ updateUrl ) 63 | 64 | public: 65 | ~Update(); 66 | 67 | Target * target() const; 68 | 69 | UpdateType type() const; 70 | QUrl updateUrl() const; 71 | QDate releaseDate() const; 72 | QVariant data( const QString& name ) const; 73 | UpdateSourceInfo sourceInfo() const; 74 | 75 | bool canDownload() const; 76 | bool isDownloaded() const; 77 | void download() { run(); } 78 | QString downloadedFileName() const; 79 | 80 | QList operations() const; 81 | 82 | quint64 compressedSize() const; 83 | quint64 uncompressedSize() const; 84 | 85 | #ifndef KDUPDATER_NO_COMPAT 86 | Application * application() const { return dynamic_cast( target() ); } 87 | #endif // KDUPDATER_NO_COMPAT 88 | 89 | private: 90 | Q_PRIVATE_SLOT( d, void downloadProgress( int ) ) 91 | Q_PRIVATE_SLOT( d, void downloadAborted( const QString& msg ) ) 92 | Q_PRIVATE_SLOT( d, void downloadCompleted() ) 93 | 94 | friend class UpdateFinder; 95 | class Private; 96 | kdtools::pimpl_ptr< Private > d; 97 | 98 | void doRun(); 99 | bool doStop(); 100 | bool doPause(); 101 | bool doResume(); 102 | 103 | Update( Target* target, const UpdateSourceInfo& sourceInfo, 104 | UpdateType type, const QUrl& updateUrl, const QMap& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum ); 105 | }; 106 | } 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/kdupdaterupdatefinder.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATE_FINDER_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATE_FINDER_H__ 25 | 26 | #include "kdupdater.h" 27 | #include "kdupdatertask.h" 28 | #include 29 | 30 | #ifndef KDUPDATER_NO_COMPAT 31 | # include "kdupdaterapplication.h" 32 | #endif // KDUPDATER_NO_COMPAT 33 | 34 | QT_BEGIN_NAMESPACE 35 | class QUrl; 36 | 37 | template< typename K, typename V > 38 | class QMap; 39 | QT_END_NAMESPACE 40 | 41 | namespace KDUpdater 42 | { 43 | class Target; 44 | class Update; 45 | struct UpdateSourceInfo; 46 | 47 | class KDUPDATER_EXPORT UpdateFinder : public Task 48 | { 49 | Q_OBJECT 50 | Q_PROPERTY( UpdateTypes updateType READ updateType WRITE setUpdateType ) 51 | Q_PROPERTY( QString platformIdentifier READ platformIdentifier WRITE setPlatformIdentifier ) 52 | 53 | public: 54 | explicit UpdateFinder( Target * target ); 55 | ~UpdateFinder(); 56 | 57 | Target * target() const; 58 | QList updates() const; 59 | 60 | void setUpdateType( UpdateTypes type ); 61 | UpdateTypes updateType() const; 62 | 63 | void setPlatformIdentifier( const QString & platformIdentifier ); 64 | QString platformIdentifier() const; 65 | 66 | #ifndef KDUPDATER_NO_COMPAT 67 | Application * application() const { return dynamic_cast( target() ); } 68 | #endif // KDUPDATER_NO_COMPAT 69 | 70 | private: 71 | void doRun(); 72 | bool doStop(); 73 | bool doPause(); 74 | bool doResume(); 75 | 76 | Update* constructUpdate( Target * target, const UpdateSourceInfo & sourceInfo, 77 | UpdateType type, const QUrl& updateUrl, const QMap< QString, QVariant >& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum ); 78 | 79 | 80 | private: 81 | Q_PRIVATE_SLOT( d, void slotDownloadDone() ) 82 | 83 | class Private; 84 | kdtools::pimpl_ptr< Private > d; 85 | }; 86 | 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/kdupdaterupdateinstaller.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATEINSTALLER_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATEINSTALLER_H__ 25 | 26 | #include "kdupdater.h" 27 | #include "kdupdatertask.h" 28 | #include 29 | 30 | #ifndef KDUPDATER_NO_COMPAT 31 | # include "kdupdaterapplication.h" 32 | #endif // KDUPDATER_NO_COMPAT 33 | 34 | QT_BEGIN_NAMESPACE 35 | template< typename T > 36 | class QList; 37 | QT_END_NAMESPACE 38 | 39 | namespace KDUpdater 40 | { 41 | class Target; 42 | class Update; 43 | 44 | class KDUPDATER_EXPORT UpdateInstaller : public Task 45 | { 46 | Q_OBJECT 47 | 48 | public: 49 | explicit UpdateInstaller( Target * target ); 50 | ~UpdateInstaller(); 51 | 52 | Target * target() const; 53 | 54 | void setUpdatesToInstall(const QList& updates); 55 | QList updatesToInstall() const; 56 | 57 | #ifndef KDUPDATER_NO_COMPAT 58 | Application * application() const { return dynamic_cast( target() ); } 59 | #endif // KDUPDATER_NO_COMPAT 60 | 61 | private: 62 | void doRun(); 63 | bool doStop(); 64 | bool doPause(); 65 | bool doResume(); 66 | 67 | bool installUpdate(Update* update, int minPc, int maxPc); 68 | 69 | class Private; 70 | kdtools::pimpl_ptr d; 71 | 72 | Q_PRIVATE_SLOT( d, void slotUpdateDownloadProgress() ) 73 | Q_PRIVATE_SLOT( d, void slotUpdateDownloadDone() ) 74 | Q_PRIVATE_SLOT( d, void slotUpdateDownloadFailed() ) 75 | }; 76 | 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/kdupdaterupdateoperation.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATEOPERATION_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATEOPERATION_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include "kdupdaterupdateoperationfactory.h" 30 | 31 | #ifndef KDUPDATER_NO_COMPAT 32 | # include "kdupdaterapplication.h" 33 | #endif // KDUPDATER_NO_COMPAT 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | QT_BEGIN_NAMESPACE 40 | class QDomDocument; 41 | QT_END_NAMESPACE 42 | 43 | namespace KDUpdater 44 | { 45 | class Target; 46 | 47 | class KDUPDATER_EXPORT UpdateOperation 48 | { 49 | Q_DECLARE_TR_FUNCTIONS(UpdateOperation) 50 | 51 | friend class KDUpdater::UpdateOperationFactory; 52 | 53 | public: 54 | enum Error { 55 | NoError=0, 56 | InvalidArguments=1, 57 | UserDefinedError=128 58 | }; 59 | 60 | UpdateOperation(); 61 | virtual ~UpdateOperation(); 62 | 63 | QString name() const; 64 | QString operationCommand() const; 65 | 66 | QStringList arguments() const; 67 | QString errorString() const; 68 | int error() const; 69 | 70 | virtual void backup() = 0; 71 | virtual bool performOperation() = 0; 72 | virtual bool undoOperation() = 0; 73 | virtual bool testOperation() = 0; 74 | virtual UpdateOperation* clone() const = 0; 75 | 76 | QString lastError() const; 77 | 78 | virtual QDomDocument toXml() const; 79 | bool fromXml( const QString &xml ); 80 | virtual bool fromXml( const QDomDocument &doc ); 81 | 82 | protected: 83 | template< class T > 84 | T* clone() const 85 | { 86 | T* const cloned = new T; 87 | cloned->setValues( values() ); 88 | cloned->setArguments( arguments() ); 89 | return cloned; 90 | } 91 | 92 | bool hasValue( const QString& name ) const; 93 | void clearValue( const QString& name ); 94 | QVariant value( const QString& name ) const; 95 | void setValue( const QString& name, const QVariant &value ); 96 | 97 | void setArguments(const QStringList& args); 98 | void setTarget( Target * target ); 99 | 100 | void setName(const QString& name); 101 | Target * target() const; 102 | void setErrorString( const QString& errorString ); 103 | void setError( int error ); 104 | void setError( int error, const QString& errorString ); 105 | 106 | #ifndef KDUPDATER_NO_COMPAT 107 | void setApplication( Application * a ) { setTarget( a ); } 108 | Application * application() const { return dynamic_cast( target() ); } 109 | #endif // KDUPDATER_NO_COMPAT 110 | 111 | private: 112 | QVariantMap values() const; 113 | void setValues( const QVariantMap& values ); 114 | 115 | class Private; 116 | kdtools::pimpl_ptr< Private > d; 117 | }; 118 | 119 | } 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /src/kdupdaterupdateoperationfactory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterupdateoperationfactory.h" 24 | #include "kdupdaterupdateoperations_p.h" 25 | 26 | #include 27 | #include 28 | 29 | /*! 30 | \ingroup kdupdater 31 | \class KDUpdater::UpdateOperationFactory kdupdaterupdateoperationfactory.h KDUpdaterUpdateOperationFactory 32 | \brief Factory for \ref KDUpdater::UpdateOperation 33 | 34 | This class acts as a factory for \ref KDUpdater::UpdateOperation. You can register 35 | one or more update operations with this factory and query operations based on their name. 36 | 37 | This class follows the singleton design pattern. Only one instance of this class can 38 | be created and its reference can be fetched from the \ref instance() method. 39 | */ 40 | 41 | /*! 42 | \fn KDUpdater::UpdateOperationFactory::registerUpdateOperation( const QString& name ) 43 | 44 | Registers T as new UpdateOperation with \a name. When create() is called with that \a name, 45 | T is constructed using its default constructor. 46 | */ 47 | 48 | using namespace KDUpdater; 49 | 50 | class UpdateOperationFactory::Private 51 | { 52 | }; 53 | 54 | /*! 55 | Returns the UpdateOperationFactory instance. The instance is created if needed. 56 | */ 57 | UpdateOperationFactory& UpdateOperationFactory::instance() 58 | { 59 | static UpdateOperationFactory theFactory; 60 | return theFactory; 61 | } 62 | 63 | /*! 64 | Constructor 65 | */ 66 | UpdateOperationFactory::UpdateOperationFactory() 67 | { 68 | // Register the default update operation set 69 | registerUpdateOperation< CopyOperation >( QLatin1String( "Copy" ) ); 70 | registerUpdateOperation< MoveOperation >( QLatin1String( "Move" ) ); 71 | registerUpdateOperation< DeleteOperation >( QLatin1String( "Delete" ) ); 72 | registerUpdateOperation< MkdirOperation >( QLatin1String( "Mkdir" ) ); 73 | registerUpdateOperation< RmdirOperation >( QLatin1String( "Rmdir" ) ); 74 | registerUpdateOperation< AppendFileOperation >( QLatin1String( "AppendFile" ) ); 75 | registerUpdateOperation< PrependFileOperation >( QLatin1String( "PrependFile" ) ); 76 | registerUpdateOperation< ExecuteOperation >( QLatin1String( "Execute" ) ); 77 | registerUpdateOperation< UpdatePackageOperation >( QLatin1String( "UpdatePackage" ) ); 78 | registerUpdateOperation< UpdateCompatOperation >( QLatin1String( "UpdateCompat" ) ); 79 | } 80 | 81 | /*! 82 | Destructor 83 | */ 84 | UpdateOperationFactory::~UpdateOperationFactory() 85 | { 86 | } 87 | 88 | /*! 89 | Creates an UpdateOperation from \a name for \a app. 90 | The resulting operation gets \a arguments and \a app assigned. 91 | */ 92 | UpdateOperation * UpdateOperationFactory::create( const QString & name, const QStringList & arguments, Target * target ) const 93 | { 94 | UpdateOperation* const op = KDGenericFactory< UpdateOperation >::create( name ); 95 | if( op != 0 ) 96 | { 97 | op->setArguments( arguments ); 98 | op->setTarget( target ); 99 | } 100 | return op; 101 | } 102 | 103 | /*! 104 | Returns the number of update operations in the factory. 105 | */ 106 | int UpdateOperationFactory::updateOperationCount() const 107 | { 108 | return productCount(); 109 | } 110 | 111 | /*! 112 | Returns a list containing the names of all available UpdateOperations. 113 | */ 114 | QStringList UpdateOperationFactory::availableUpdateOperations() const 115 | { 116 | return availableProducts(); 117 | } 118 | 119 | /* 120 | Unregisters the update operation previously registered with \a name. 121 | */ 122 | void UpdateOperationFactory::unregisterUpdateOperation( const QString& name ) 123 | { 124 | unregisterProduct( name ); 125 | } 126 | 127 | /*! 128 | Registers \a create to be a factory function to create an UpdateOperation with \a name. 129 | \sa registerUpdateOperation 130 | */ 131 | void UpdateOperationFactory::registerUpdateOperationFactory( const QString& name, UpdateOperationFactoryFunction create ) 132 | { 133 | registerProductionFunction( name, create ); 134 | } 135 | -------------------------------------------------------------------------------- /src/kdupdaterupdateoperationfactory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATEOPERATIONFACTORY_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATEOPERATIONFACTORY_H__ 25 | 26 | #include 27 | 28 | #include "kdupdater.h" 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | class Target; 34 | class UpdateOperation; 35 | 36 | typedef KDGenericFactory< UpdateOperation >::FactoryFunction UpdateOperationFactoryFunction; 37 | 38 | class KDUPDATER_EXPORT UpdateOperationFactory : public KDGenericFactory< UpdateOperation > 39 | { 40 | KDAB_DISABLE_COPY( UpdateOperationFactory ); 41 | public: 42 | static UpdateOperationFactory& instance(); 43 | ~UpdateOperationFactory(); 44 | 45 | UpdateOperation * create( const QString & name, const QStringList & arguments, Target * target ) const; 46 | 47 | template< class T > 48 | void registerUpdateOperation( const QString& name ) 49 | { 50 | registerProduct< T >( name ); 51 | } 52 | void registerUpdateOperationFactory( const QString& name, UpdateOperationFactoryFunction create ); 53 | 54 | void unregisterUpdateOperation( const QString& name ); 55 | 56 | int updateOperationCount() const; 57 | QStringList availableUpdateOperations() const; 58 | 59 | protected: 60 | UpdateOperationFactory(); 61 | 62 | private: 63 | class Private; 64 | kdtools::pimpl_ptr< Private > d; 65 | }; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/kdupdaterupdateoperations_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATEOPERATIONS_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATEOPERATIONS_H__ 25 | 26 | #include "kdupdaterupdateoperation.h" 27 | 28 | #include // for Q_DECLARE_TR_FUNCTIONS 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | 34 | class CopyOperation : public UpdateOperation 35 | { 36 | Q_DECLARE_TR_FUNCTIONS( CopyOperation ) 37 | public: 38 | CopyOperation(); 39 | ~CopyOperation(); 40 | 41 | void backup(); 42 | bool performOperation(); 43 | bool undoOperation(); 44 | bool testOperation(); 45 | CopyOperation* clone() const; 46 | }; 47 | 48 | class MoveOperation : public UpdateOperation 49 | { 50 | Q_DECLARE_TR_FUNCTIONS( MoveOperation ) 51 | public: 52 | MoveOperation(); 53 | ~MoveOperation(); 54 | 55 | void backup(); 56 | bool performOperation(); 57 | bool undoOperation(); 58 | bool testOperation(); 59 | MoveOperation* clone() const; 60 | }; 61 | 62 | class DeleteOperation : public UpdateOperation 63 | { 64 | Q_DECLARE_TR_FUNCTIONS( DeleteOperation ) 65 | public: 66 | DeleteOperation(); 67 | ~DeleteOperation(); 68 | 69 | void backup(); 70 | bool performOperation(); 71 | bool undoOperation(); 72 | bool testOperation(); 73 | DeleteOperation* clone() const; 74 | }; 75 | 76 | class MkdirOperation : public UpdateOperation 77 | { 78 | Q_DECLARE_TR_FUNCTIONS( MkdirOperation ) 79 | public: 80 | MkdirOperation(); 81 | ~MkdirOperation(); 82 | 83 | void backup(); 84 | bool performOperation(); 85 | bool undoOperation(); 86 | bool testOperation(); 87 | MkdirOperation* clone() const; 88 | }; 89 | 90 | class RmdirOperation : public UpdateOperation 91 | { 92 | Q_DECLARE_TR_FUNCTIONS( RmdirOperation ) 93 | public: 94 | RmdirOperation(); 95 | ~RmdirOperation(); 96 | 97 | void backup(); 98 | bool performOperation(); 99 | bool undoOperation(); 100 | bool testOperation(); 101 | RmdirOperation* clone() const; 102 | }; 103 | 104 | class AppendFileOperation : public UpdateOperation 105 | { 106 | Q_DECLARE_TR_FUNCTIONS( AppendFileOperation ) 107 | public: 108 | AppendFileOperation(); 109 | ~AppendFileOperation(); 110 | 111 | void backup(); 112 | bool performOperation(); 113 | bool undoOperation(); 114 | bool testOperation(); 115 | AppendFileOperation* clone() const; 116 | }; 117 | 118 | class PrependFileOperation : public UpdateOperation 119 | { 120 | Q_DECLARE_TR_FUNCTIONS( PrependFileOperation ) 121 | public: 122 | PrependFileOperation(); 123 | ~PrependFileOperation(); 124 | 125 | void backup(); 126 | bool performOperation(); 127 | bool undoOperation(); 128 | bool testOperation(); 129 | PrependFileOperation* clone() const; 130 | }; 131 | 132 | class ExecuteOperation : public QObject, public UpdateOperation 133 | { 134 | Q_OBJECT 135 | public: 136 | ExecuteOperation(); 137 | ~ExecuteOperation(); 138 | 139 | void backup(); 140 | bool performOperation(); 141 | bool undoOperation(); 142 | bool testOperation(); 143 | ExecuteOperation* clone() const; 144 | 145 | public Q_SLOTS: 146 | void cancelOperation(); 147 | 148 | private Q_SLOTS: 149 | void readProcessOutput(); 150 | 151 | Q_SIGNALS: 152 | void outputChanged(const QString &text); 153 | 154 | private: 155 | QProcess process; 156 | }; 157 | 158 | class UpdatePackageOperation : public UpdateOperation 159 | { 160 | Q_DECLARE_TR_FUNCTIONS( UpdatePackageOperation ) 161 | public: 162 | UpdatePackageOperation(); 163 | ~UpdatePackageOperation(); 164 | 165 | void backup(); 166 | bool performOperation(); 167 | bool undoOperation(); 168 | bool testOperation(); 169 | UpdatePackageOperation* clone() const; 170 | }; 171 | 172 | class UpdateCompatOperation : public UpdateOperation 173 | { 174 | Q_DECLARE_TR_FUNCTIONS( UpdateCompatOperation ) 175 | public: 176 | UpdateCompatOperation(); 177 | ~UpdateCompatOperation(); 178 | 179 | void backup(); 180 | bool performOperation(); 181 | bool undoOperation(); 182 | bool testOperation(); 183 | UpdateCompatOperation* clone() const; 184 | }; 185 | 186 | } 187 | 188 | #endif 189 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesdialog.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESDIALOG_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESDIALOG_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | 31 | QT_BEGIN_NAMESPACE 32 | template< typename T > 33 | class QList; 34 | QT_END_NAMESPACE 35 | 36 | namespace KDUpdater 37 | { 38 | class Update; 39 | 40 | class KDUPDATER_EXPORT UpdatesDialog : public QDialog 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit UpdatesDialog(QWidget *parent = 0); 46 | ~UpdatesDialog(); 47 | 48 | void setUpdates(const QList &updates); 49 | QList updates() const; 50 | 51 | bool isUpdateAllowed( const Update * update ) const; 52 | 53 | private: 54 | Q_PRIVATE_SLOT( d, void slotStateChanged() ) 55 | Q_PRIVATE_SLOT( d, void slotPreviousClicked() ) 56 | Q_PRIVATE_SLOT( d, void slotNextClicked() ) 57 | 58 | class Private; 59 | kdtools::pimpl_ptr< Private > d; 60 | }; 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesinfo_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESINFO_P_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESINFO_P_H__ 25 | 26 | #include "kdupdater.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | // Classes and structures in this header file are for internal use only. 35 | // They are not a part of the public API 36 | 37 | namespace KDUpdater 38 | { 39 | struct UpdateFileInfo 40 | { 41 | UpdateFileInfo() 42 | : compressedSize( 0 ), 43 | uncompressedSize( 0 ) 44 | { 45 | } 46 | QString arch; 47 | QString platformRegEx; 48 | QString fileName; 49 | QByteArray sha1sum; 50 | quint64 compressedSize; 51 | quint64 uncompressedSize; 52 | }; 53 | 54 | struct UpdateInfo 55 | { 56 | UpdateInfo() 57 | : type( 0 ) 58 | { 59 | } 60 | int type; 61 | QMap data; 62 | QVector updateFiles; 63 | }; 64 | 65 | class UpdatesInfo 66 | { 67 | public: 68 | enum Error 69 | { 70 | NoError=0, 71 | NotYetReadError, 72 | CouldNotReadUpdateInfoFileError, 73 | InvalidXmlError, 74 | InvalidContentError 75 | }; 76 | 77 | UpdatesInfo(); 78 | ~UpdatesInfo(); 79 | 80 | bool isValid() const; 81 | QString errorString() const; 82 | Error error() const; 83 | 84 | void setFileName(const QString& updateXmlFile); 85 | QString fileName() const; 86 | 87 | QString targetName() const; 88 | QString targetVersion() const; 89 | int compatLevel() const; 90 | 91 | int updateInfoCount( int type=AllUpdate ) const; 92 | UpdateInfo updateInfo(int index) const; 93 | QVector updatesInfo( int type=AllUpdate, int compatLevel=-1 ) const; 94 | 95 | private: 96 | class Private; 97 | QSharedDataPointer< Private > d; 98 | }; 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESMODEL_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESMODEL_H__ 25 | 26 | #include "kdupdater.h" 27 | #include "kdupdaterupdate.h" 28 | #include 29 | 30 | #include 31 | 32 | namespace KDUpdater 33 | { 34 | 35 | class KDUPDATER_EXPORT UpdatesModel : public QAbstractTableModel 36 | { 37 | Q_OBJECT 38 | public: 39 | explicit UpdatesModel( QObject* parent = 0 ); 40 | ~UpdatesModel(); 41 | 42 | void setUpdates( const QList< Update* >& updates ); 43 | QList< Update* > updates() const; 44 | 45 | QList< Update* > selectedUpdates() const; 46 | 47 | Qt::ItemFlags flags( const QModelIndex& index ) const; 48 | QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 49 | QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 50 | bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ); 51 | 52 | int columnCount( const QModelIndex& parent = QModelIndex() ) const; 53 | int rowCount( const QModelIndex& parent = QModelIndex() ) const; 54 | 55 | private: 56 | class Private; 57 | kdtools::pimpl_ptr< Private > d; 58 | }; 59 | } 60 | 61 | Q_DECLARE_METATYPE( KDUpdater::Update* ) 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesourcesinfo.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESOURCESINFO_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESOURCESINFO_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #ifndef KDUPDATER_NO_COMPAT 34 | # include "kdupdaterapplication.h" 35 | #endif // KDUPDATER_NO_COMPAT 36 | 37 | namespace KDUpdater 38 | { 39 | class Target; 40 | 41 | struct KDUPDATER_EXPORT UpdateSourceInfo 42 | { 43 | UpdateSourceInfo(); 44 | 45 | QString name; 46 | QString title; 47 | QString description; 48 | QUrl url; 49 | int priority; 50 | }; 51 | 52 | KDUPDATER_EXPORT bool operator==( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs ); 53 | KDUPDATER_EXPORT bool operator<( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs ); 54 | KDUPDATER_MAKE_RELATION_OPERATORS( UpdateSourceInfo, inline ) 55 | 56 | class KDUPDATER_EXPORT UpdateSourcesInfo : public QObject 57 | { 58 | Q_OBJECT 59 | Q_PROPERTY( Error error READ error ) 60 | Q_PROPERTY( QString errorString READ errorString ) 61 | Q_PROPERTY( QString fileName READ fileName WRITE setFileName ) 62 | 63 | public: 64 | enum Error 65 | { 66 | NoError=0, 67 | NotYetReadError, 68 | CouldNotReadSourceFileError, 69 | InvalidXmlError, 70 | InvalidContentError, 71 | CouldNotSaveChangesError 72 | }; 73 | 74 | Target * target() const; 75 | 76 | bool isValid() const; 77 | QString errorString() const; 78 | Error error() const; 79 | 80 | bool isModified() const; 81 | void setModified(bool modified); 82 | 83 | void setFileName(const QString& fileName); 84 | QString fileName() const; 85 | 86 | int updateSourceInfoCount() const; 87 | UpdateSourceInfo updateSourceInfo(int index) const; 88 | 89 | void addUpdateSourceInfo(const UpdateSourceInfo& info); 90 | void removeUpdateSourceInfo(const UpdateSourceInfo& info); 91 | void removeUpdateSourceInfoAt(int index); 92 | void setUpdateSourceInfoAt(int index, const UpdateSourceInfo& info); 93 | 94 | #ifndef KDUPDATER_NO_COMPAT 95 | Application * application() const { return dynamic_cast( target() ); } 96 | #endif // KDUPDATER_NO_COMPAT 97 | 98 | protected: 99 | explicit UpdateSourcesInfo( Target * target ); 100 | ~UpdateSourcesInfo(); 101 | 102 | public Q_SLOTS: 103 | void refresh(); 104 | 105 | Q_SIGNALS: 106 | void reset(); 107 | void aboutToAddUpdateSourceInfo( int index, const UpdateSourceInfo& info ); 108 | void updateSourceInfoAdded( const UpdateSourceInfo& info ); 109 | 110 | void updateSourceInfoRemoved( const UpdateSourceInfo& info ); 111 | void aboutToRemoveUpdateSourceInfo( const UpdateSourceInfo& info ); 112 | 113 | void updateSourceInfoChanged( const UpdateSourceInfo& newInfo, const UpdateSourceInfo& oldInfo ); 114 | 115 | private: 116 | friend class Target; 117 | class Private; 118 | kdtools::pimpl_ptr< Private > d; 119 | }; 120 | } 121 | 122 | Q_DECLARE_METATYPE(KDUpdater::UpdateSourceInfo) 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesourcesmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESOURCESMODEL_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESOURCESMODEL_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | 31 | namespace KDUpdater 32 | { 33 | class UpdateSourcesInfo; 34 | 35 | class KDUPDATER_EXPORT UpdateSourcesModel : public QAbstractTableModel 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | enum Column 41 | { 42 | Name, 43 | Title, 44 | Url 45 | }; 46 | 47 | explicit UpdateSourcesModel( QObject* parent = 0 ); 48 | ~UpdateSourcesModel(); 49 | 50 | void setUpdateSourcesInfo( UpdateSourcesInfo* info ); 51 | UpdateSourcesInfo* updateSourcesInfo() const; 52 | 53 | int rowCount( const QModelIndex& parent = QModelIndex() ) const; 54 | int columnCount( const QModelIndex& parent = QModelIndex() ) const; 55 | 56 | bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ); 57 | 58 | bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ); 59 | QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 60 | QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 61 | 62 | private: 63 | Q_PRIVATE_SLOT( d, void refresh() ) 64 | 65 | Q_PRIVATE_SLOT( d, void slotAboutToAddUpdateSourceInfo( int index ) ) 66 | Q_PRIVATE_SLOT( d, void slotUpdateSourceInfoAdded() ) 67 | 68 | Q_PRIVATE_SLOT( d, void slotAboutToRemoveUpdateSourceInfo( const UpdateSourceInfo& info ) ) 69 | Q_PRIVATE_SLOT( d, void slotUpdateSourceInfoRemoved() ) 70 | 71 | Q_PRIVATE_SLOT( d, void slotUpdateSourceInfoChanged( const UpdateSourceInfo& newInfo ) ) 72 | 73 | class Private; 74 | kdtools::pimpl_ptr< Private > d; 75 | }; 76 | 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/kdupdaterupdatesourcesview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLS_KDUPDATERUPDATESOURCESVIEW_H__ 24 | #define __KDTOOLS_KDUPDATERUPDATESOURCESVIEW_H__ 25 | 26 | #include "kdupdater.h" 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace KDUpdater 33 | { 34 | struct UpdateSourceInfo; 35 | class UpdateSourcesInfo; 36 | 37 | class KDUPDATER_EXPORT EditUpdateSourceDialog : public QDialog 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit EditUpdateSourceDialog( QWidget* parent = 0 ); 42 | ~EditUpdateSourceDialog(); 43 | 44 | void setInfo( const UpdateSourceInfo& info ); 45 | UpdateSourceInfo info() const; 46 | 47 | public Q_SLOTS: 48 | void accept(); 49 | 50 | private: 51 | class Private; 52 | kdtools::pimpl_ptr< Private > d; 53 | }; 54 | 55 | class KDUPDATER_EXPORT UpdateSourcesView : public QTreeView 56 | { 57 | Q_OBJECT 58 | 59 | public: 60 | explicit UpdateSourcesView( QWidget* parent = 0 ); 61 | ~UpdateSourcesView(); 62 | 63 | void setUpdateSourcesInfo(UpdateSourcesInfo* info); 64 | UpdateSourcesInfo* updateSourcesInfo() const; 65 | 66 | int currentUpdateSourceInfoIndex() const; 67 | 68 | public Q_SLOTS: 69 | void addNewSource(); 70 | void removeCurrentSource(); 71 | void editCurrentSource(); 72 | 73 | protected: 74 | #ifndef QT_NO_CONTEXTMENU 75 | void contextMenuEvent( QContextMenuEvent* e ); 76 | #endif 77 | 78 | private: 79 | class Private; 80 | kdtools::pimpl_ptr< Private > d; 81 | }; 82 | 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/pimpl_ptr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef __KDTOOLSCORE__PIMPL_PTR_H__ 24 | #define __KDTOOLSCORE__PIMPL_PTR_H__ 25 | 26 | #include 27 | 28 | #ifndef DOXYGEN_RUN 29 | namespace kdtools { 30 | #endif 31 | 32 | template 33 | class MAKEINCLUDES_EXPORT pimpl_ptr KDAB_FINAL_CLASS { 34 | KDAB_DISABLE_COPY( pimpl_ptr ); 35 | T * d; 36 | public: 37 | pimpl_ptr() : d( new T ) {} 38 | explicit pimpl_ptr( T * t ) : d( t ) {} 39 | ~pimpl_ptr() { delete d; d = 0; } 40 | 41 | void swap( pimpl_ptr & other ) { 42 | T * const tmp = d; 43 | d = other.d; 44 | other.d = tmp; 45 | } 46 | 47 | T * get() { return d; } 48 | const T * get() const { return d; } 49 | 50 | T * operator->() { return get(); } 51 | const T * operator->() const { return get(); } 52 | 53 | T & operator*() { return *get(); } 54 | const T & operator*() const { return *get(); } 55 | 56 | KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( get() ) 57 | }; 58 | 59 | template 60 | inline void swap( pimpl_ptr & lhs, pimpl_ptr & rhs ) { 61 | lhs.swap( rhs ); 62 | } 63 | 64 | // these are not implemented, so's we can catch their use at 65 | // link-time. Leaving them undeclared would open up a comparison 66 | // via operator unspecified-bool-type(). 67 | template 68 | void operator==( const pimpl_ptr &, const pimpl_ptr & ); 69 | template 70 | void operator!=( const pimpl_ptr &, const pimpl_ptr & ); 71 | 72 | #ifndef DOXYGEN_RUN 73 | } // namespace kdtools 74 | #endif 75 | 76 | #endif /* __KDTOOLSCORE__PIMPL_PTR_H__ */ 77 | 78 | -------------------------------------------------------------------------------- /src/src.pri: -------------------------------------------------------------------------------- 1 | win32 { 2 | DEFINES += _CRT_SECURE_NO_DEPRECATE 3 | } 4 | 5 | # Input 6 | INSTALLHEADERS = \ 7 | $$PWD/kdupdater.h \ 8 | $$PWD/kdupdaterpackagesinfo.h \ 9 | $$PWD/kdupdaterapplication.h \ 10 | $$PWD/kdupdatertarget.h \ 11 | $$PWD/kdupdaterupdatesourcesinfo.h \ 12 | $$PWD/kdupdaterupdate.h \ 13 | $$PWD/kdupdaterupdateoperation.h \ 14 | $$PWD/kdupdaterupdateoperationfactory.h \ 15 | $$PWD/kdupdaterupdatefinder.h \ 16 | $$PWD/kdupdaterupdateinstaller.h \ 17 | $$PWD/kdupdatertask.h \ 18 | $$PWD/kdupdaterfiledownloader.h \ 19 | $$PWD/kdupdaterfiledownloaderfactory.h \ 20 | $$PWD/kdupdaterpackagesmodel.h \ 21 | $$PWD/kdupdaterupdatesourcesmodel.h \ 22 | $$PWD/kdupdaterupdatesmodel.h \ 23 | $$PWD/kdtoolsglobal.h \ 24 | $$PWD/kdsemaphorereleaser.h \ 25 | $$PWD/kdrect.h \ 26 | $$PWD/kdsavefile.h \ 27 | $$PWD/kdautopointer.h \ 28 | $$PWD/kdsharedmemorylocker.h \ 29 | $$PWD/kdlockedsharedmemorypointer.h \ 30 | $$PWD/kdgenericfactory.h \ 31 | # $$PWD/kdvariantconverter.h \ 32 | $$PWD/kdmetamethoditerator.h 33 | 34 | PRIVATEHEADERS = $$PWD/kdupdaterfiledownloader_p.h \ 35 | $$PWD/kdupdaterupdateoperations_p.h \ 36 | $$PWD/kdupdaterupdatesinfo_p.h \ 37 | 38 | SOURCES += $$PWD/kdupdaterpackagesinfo.cpp \ 39 | $$PWD/kdupdaterapplication.cpp \ 40 | $$PWD/kdupdatertarget.cpp \ 41 | $$PWD/kdupdaterupdatesourcesinfo.cpp \ 42 | $$PWD/kdupdaterupdate.cpp \ 43 | $$PWD/kdupdaterfiledownloader.cpp \ 44 | $$PWD/kdupdaterfiledownloader_mac.cpp \ 45 | $$PWD/kdupdaterfiledownloaderfactory.cpp \ 46 | $$PWD/kdupdaterupdateoperation.cpp \ 47 | $$PWD/kdupdaterupdateoperations.cpp \ 48 | $$PWD/kdupdaterupdateoperationfactory.cpp \ 49 | $$PWD/kdupdaterupdatesinfo.cpp \ 50 | $$PWD/kdupdaterupdatefinder.cpp \ 51 | $$PWD/kdupdaterupdateinstaller.cpp \ 52 | $$PWD/kdupdatertask.cpp \ 53 | $$PWD/kdupdaterpackagesmodel.cpp \ 54 | $$PWD/kdupdaterupdatesourcesmodel.cpp \ 55 | $$PWD/kdupdaterufcompresscommon.cpp \ 56 | $$PWD/kdupdaterupdatesmodel.cpp \ 57 | $$PWD/kdtoolsglobal.cpp \ 58 | $$PWD/kdsemaphorereleaser.cpp \ 59 | $$PWD/kdrect.cpp \ 60 | $$PWD/kdsavefile.cpp \ 61 | $$PWD/kdautopointer.cpp \ 62 | $$PWD/pimpl_ptr.cpp \ 63 | $$PWD/kdsharedmemorylocker.cpp \ 64 | $$PWD/kdlockedsharedmemorypointer.cpp \ 65 | $$PWD/kdgenericfactory.cpp \ 66 | # $$PWD/kdvariantconverter.cpp \ 67 | $$PWD/kdmetamethoditerator.cpp 68 | 69 | PRIVATEHEADERS += $$PWD/kdupdaterufcompresscommon_p.h \ 70 | $$PWD/kdupdaterufuncompressor_p.h 71 | 72 | SOURCES += $$PWD/kdupdaterufuncompressor.cpp 73 | 74 | kdupdatergui { 75 | SOURCES += $$PWD/kdupdaterupdatesdialog.cpp \ 76 | $$PWD/kdupdaterpackagesview.cpp \ 77 | $$PWD/kdupdaterupdatesourcesview.cpp 78 | 79 | INSTALLHEADERS += $$PWD/kdupdaterupdatesdialog.h \ 80 | $$PWD/kdupdaterpackagesview.h \ 81 | $$PWD/kdupdaterupdatesourcesview.h 82 | 83 | FORMS += $$PWD/addupdatesourcedialog.ui \ 84 | $$PWD/updatesdialog.ui 85 | 86 | QT += gui widgets 87 | } 88 | 89 | HEADERS += $$INSTALLHEADERS $$PRIVATEHEADERS 90 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | CONFIG += build_kdupdater_library 2 | include (../KDUpdater.pri) 3 | 4 | TEMPLATE = lib 5 | TARGET = $$LIBNAME 6 | VERSION = 2.3.0 7 | DESTDIR = $$KDUPDATER_LIB_PATH 8 | INCLUDEPATH += . 9 | 10 | win32{ 11 | DLLDESTDIR = $$KDUPDATER_BIN_PATH 12 | QMAKE_DISTCLEAN += $$KDUPDATER_BIN_PATH/$${TARGET}.dll 13 | } 14 | 15 | macx { 16 | CONFIG += absolute_library_soname 17 | QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$KDUPDATER_LIB_PATH/ 18 | } 19 | 20 | QT += xml network 21 | CONFIG += create_prl 22 | DEFINES += emit="" 23 | DEFINES += QT_NO_KEYWORDS QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII QT_NO_CAST_FROM_BYTEARRAY 24 | 25 | DEFINES += BUILD_KDUPDATER 26 | 27 | CONFIG += kdupdatergui 28 | 29 | include (src.pri) 30 | -------------------------------------------------------------------------------- /src/updatefileformat.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \page kdupdater_updatefileformat KDUpdater - UpdateFile Format 3 | 4 | \section kdupdater_updatefileformat_intro Introduction 5 | 6 | A typical update consists of one or more files that should be copied into the 7 | application directory(ies) and/or system directory(ies) during the installation 8 | of the update. All of these files have to be compressed into a single file and 9 | served as such; this single file is called UpdateFile. 10 | 11 | 12 | \htmlonly 13 |
14 | 15 |
Definition:
16 | An UpdateFile is a compressed file that contains all the files and 17 | directories required for installing the update on the client. Each UpdateFile 18 | contains the file(s) required for installing that update. Update dependencies 19 | can be used to provide dependent files if needed. 20 |
21 | \endhtmlonly 22 | 23 | \section kdupdater_updatefileformat_structure Structure of the UpdateFile 24 | 25 | The UpdateFile basically contains two types blocks of data 26 | 27 | \li One UpdateFileHeader structure represented by the KDUpdater::UFHeader struct 28 | \li Followed by a series of UpdateFileEntry structures represented by KDUpdater::UFEntry struct 29 | 30 | The image below gives a visual representation of an UpdateFile 31 | 32 | \image html kdupdater_updatefileillustration2.png 33 | 34 | \note The files are written and read via a QDataStream using big endian byte order in version 8. See the QDataStream documentation for details. 35 | 36 | The following subsections explain UFHeader and UFEntry structures in more detail 37 | 38 | \subsection kdupdater_updatefileheader_ufheader UFHeader 39 | 40 | The update file header describes the contents of the update file interms of file 41 | names, their permissions and directory entry flags. The update header consists 42 | of the following fields. 43 | 44 | \htmlonly 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 83 | 84 | 85 | 86 | 87 | 88 | 91 | 92 | 93 | 94 | 95 | 96 | 98 | 99 | 100 |
Field NameField Data TypeDescription
MagicQStringA magic string that is used to identify the file type. Has to be "KDVCLZ"
FileListQStringListA list of file names of files and directories contained in the 63 | UpdateFile. It should be noted here that, in this list, directory names 64 | must appear before the names of files contained in them. 65 | 66 | For example consider the directory structure shown in the screenshot 67 | below. 68 | \endhtmlonly 69 | 70 | \image html kdupdater_updatefileillustration1.png 71 | 72 | \htmlonly 73 | The FileList for the above directory would contain the following strings 74 |
    75 |
  • admin
  • 76 |
  • internal
  • 77 |
  • internal/KD_Updater_SDS.odt
  • 78 |
  • internal/KD_Updater_SRD.pdf
  • 79 |
  • internal/KD_Updater_SRS.odt
  • 80 |
  • kdupdater
  • 81 |
82 |
PermListQList<quint64>Contains an associative (with respect to FileList) list of integers 89 | describing the access permissions for different files/directories in the 90 | update file.
IsDirListQList<bool>Contains an associative (with respect to FileList) list of boolean 97 | values flagging names in FileList as directory names or file names.
101 | \endhtmlonly 102 | 103 | \subsection kdupdater_updatefilecontents_ufentry UFEntry 104 | 105 | After the header, the contents of the UpdateFile is stored. The content can be 106 | thought of as an array of UFEntry structures. Each UFEntry structure contains data 107 | of a single file in terms of the following fields. 108 | 109 | \htmlonly 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 |
Field NameField Data TypeDescription
FileNameQStringName of the file described in this entry. This 122 | string name should be one of the names contained in 123 | the UpdateFileHeader.FileList.
Permissionsquint64Permissions of the file stored as a bit-field value.
FileDataQByteArrayContents of the file compressed using ZLib compression.
139 | \endhtmlonly 140 | 141 | \note It must be noted at this point that an UFEntry can only contain information 142 | about a file and not a directory. 143 | 144 | */ 145 | -------------------------------------------------------------------------------- /tools/tools.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | CONFIG += ordered 3 | SUBDIRS += ufcreator ufextractor 4 | 5 | -------------------------------------------------------------------------------- /tools/ufcreator/kdupdaterufcompressor.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #ifndef KD_UPDATER_UF_COMPRESSOR_H 24 | #define KD_UPDATER_UF_COMPRESSOR_H 25 | 26 | #include 27 | 28 | QT_BEGIN_NAMESPACE 29 | class QString; 30 | QT_END_NAMESPACE 31 | 32 | namespace KDUpdater 33 | { 34 | class UFCompressor 35 | { 36 | Q_DECLARE_TR_FUNCTIONS(KDUpdater::UFCompressor) 37 | 38 | public: 39 | UFCompressor(); 40 | ~UFCompressor(); 41 | 42 | QString errorString() const; 43 | 44 | void setFileName(const QString& fileName); 45 | QString fileName() const; 46 | 47 | void setSource(const QString& source); 48 | QString source() const; 49 | 50 | bool compress(); 51 | 52 | private: 53 | struct UFCompressorData; 54 | UFCompressorData* d; 55 | }; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tools/ufcreator/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterufcompressor.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int main(int argc, char** argv) 31 | { 32 | if( argc != 2 ) 33 | { 34 | std::cerr << "Usage: " << argv[0] << 35 | " \n Generates " 36 | "SourceDir.kvz file\n"; 37 | return EXIT_FAILURE; 38 | } 39 | 40 | const QString srcDir = QFile::decodeName( argv[1] ); 41 | 42 | if( !QDir(srcDir).exists() ) 43 | { 44 | std::cerr << argv[1] << " - Directory does not exist\n"; 45 | return EXIT_FAILURE; 46 | } 47 | 48 | QString fileName = QDir(srcDir).dirName(); 49 | if(fileName.isEmpty()) 50 | fileName = QLatin1String( "CompressedUpdateFile" ); 51 | 52 | const QString zipFile = QString::fromLatin1("%1.kvz").arg(fileName); 53 | 54 | qDebug("Source Directory = %s", qPrintable(srcDir)); 55 | qDebug("Compressed file = %s", qPrintable(zipFile)); 56 | 57 | KDUpdater::UFCompressor compressor; 58 | compressor.setFileName( zipFile ); 59 | compressor.setSource( srcDir ); 60 | if ( !compressor.compress() ) { 61 | std::cerr << "Creating " << argv[1] << " failed: " 62 | << qPrintable( compressor.errorString() ) << std::endl; 63 | return EXIT_FAILURE; 64 | } 65 | 66 | std::cerr << "Created " << argv[1] << std::endl; 67 | return EXIT_SUCCESS; 68 | } 69 | -------------------------------------------------------------------------------- /tools/ufcreator/ufcreator.pro: -------------------------------------------------------------------------------- 1 | include (../../KDUpdater.pri) 2 | 3 | TEMPLATE = app 4 | TARGET = ufcreator 5 | DEPENDPATH += . ../../src 6 | INCLUDEPATH +=. ../../src 7 | QT -= gui 8 | CONFIG += console 9 | macx: CONFIG -= app_bundle 10 | 11 | DESTDIR = $$KDUPDATER_BIN_PATH 12 | 13 | SOURCES += main.cpp \ 14 | kdupdaterufcompressor.cpp 15 | 16 | 17 | -------------------------------------------------------------------------------- /tools/ufextractor/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 3 | ** 4 | ** This file is part of the KD Tools library. 5 | ** 6 | ** Licensees holding valid commercial KD Tools licenses may use this file in 7 | ** accordance with the KD Tools Commercial License Agreement provided with 8 | ** the Software. 9 | ** 10 | ** 11 | ** This file may be distributed and/or modified under the terms of the GNU 12 | ** Lesser General Public License version 2 and version 3 as published by the 13 | ** Free Software Foundation and appearing in the file LICENSE.LGPL included. 14 | ** 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | ** 18 | ** Contact info@kdab.net if any conditions of this licensing are not 19 | ** clear to you. 20 | ** 21 | **********************************************************************/ 22 | 23 | #include "kdupdaterufuncompressor_p.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | int main(int argc, char** argv) 30 | { 31 | if( argc != 2 ) 32 | { 33 | std::cerr << "Usage: " << argv[0] << 34 | " \n " 35 | "Extracts the compressed file into " 36 | "the current working directory" << std::endl; 37 | return EXIT_FAILURE; 38 | } 39 | 40 | const QFileInfo fileInfo(QFile::decodeName(argv[1])); 41 | 42 | qDebug("Compressed file = %s", argv[1]); 43 | 44 | KDUpdater::UFUncompressor uncompressor; 45 | uncompressor.setFileName( fileInfo.absoluteFilePath() ); 46 | uncompressor.setDestination( QLatin1String( "." ) ); 47 | if ( !uncompressor.uncompress() ) { 48 | std::cerr << "Extracting " << argv[1] << " failed: " 49 | << qPrintable(uncompressor.errorString()) << std::endl; 50 | return EXIT_FAILURE; 51 | } 52 | 53 | std::cerr << "Extracted " << argv[1] << std::endl; 54 | return EXIT_SUCCESS; 55 | } 56 | -------------------------------------------------------------------------------- /tools/ufextractor/ufextractor.pro: -------------------------------------------------------------------------------- 1 | include (../../KDUpdater.pri) 2 | 3 | TEMPLATE = app 4 | TARGET = ufextractor 5 | DEPENDPATH += . ../../src 6 | INCLUDEPATH +=. ../../src 7 | QT -= gui 8 | CONFIG += console 9 | macx:CONFIG -= app_bundle 10 | 11 | DESTDIR = $$KDUPDATER_BIN_PATH 12 | 13 | SOURCES += main.cpp 14 | --------------------------------------------------------------------------------