summaryrefslogtreecommitdiffstats
path: root/examples/testapp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/testapp')
-rw-r--r--examples/testapp/components.xml13
-rw-r--r--examples/testapp/config.xml47
-rw-r--r--examples/testapp/config/config.xml20
-rw-r--r--examples/testapp/logo.pngbin0 -> 5437 bytes
-rw-r--r--examples/testapp/main.cpp46
-rw-r--r--examples/testapp/mainwindow.cpp182
-rw-r--r--examples/testapp/mainwindow.h48
-rw-r--r--examples/testapp/packages/com.nokia.testapp/meta/installscript.js18
-rw-r--r--examples/testapp/packages/com.nokia.testapp/meta/package.xml9
-rw-r--r--examples/testapp/testapp.pro19
-rw-r--r--examples/testapp/testapp.qrc8
11 files changed, 410 insertions, 0 deletions
diff --git a/examples/testapp/components.xml b/examples/testapp/components.xml
new file mode 100644
index 000000000..ce4e15ad5
--- /dev/null
+++ b/examples/testapp/components.xml
@@ -0,0 +1,13 @@
+<Packages>
+ <ApplicationName>Test App</ApplicationName>
+ <ApplicationVersion>1</ApplicationVersion>
+ <Package>
+ <Name>Test App</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2009-12-01</InstallDate>
+ </Package>
+</Packages>
diff --git a/examples/testapp/config.xml b/examples/testapp/config.xml
new file mode 100644
index 000000000..26b2f0980
--- /dev/null
+++ b/examples/testapp/config.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Test App</Name>
+ <Version>1</Version>
+ <Title>Test App</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzdb8ti9Ss5kmEY5rGf2HFEsj0
+ W6dXOXRIO4W3XXr37Rzc8JI4UMZd6lEcxF9mdnoqOOyhHQABI8/CB2t9HTsZPRPC
+ TCq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XXZt+M3s12sKE0B5BXuir74A==
+ -----END RSA PRIVATE KEY-----
+ </PrivateKey>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.kdab.com/~christoph/testapp</Url>
+ <Required>true</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
diff --git a/examples/testapp/config/config.xml b/examples/testapp/config/config.xml
new file mode 100644
index 000000000..f020d92e4
--- /dev/null
+++ b/examples/testapp/config/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Test App</Name>
+ <Version>1</Version>
+ <Title>Test App</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzdb8ti9Ss5kmEY5rGf2HFEsj0
+ W6dXOXRIO4W3XXr37Rzc8JI4UMZd6lEcxF9mdnoqOOyhHQABI8/CB2t9HTsZPRPC
+ TCq43QLMfVMgI6A5Cgetv6osvZFgNG3nFAlRkLHw2gLO/zxoblY0wPq5p4xmYRh4
+ f/YjsgYeA2v9V9FBAQIDAQAB
+ -----END PUBLIC KEY-----
+ </PublicKey>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+</Installer>
diff --git a/examples/testapp/logo.png b/examples/testapp/logo.png
new file mode 100644
index 000000000..3d5865a60
--- /dev/null
+++ b/examples/testapp/logo.png
Binary files differ
diff --git a/examples/testapp/main.cpp b/examples/testapp/main.cpp
new file mode 100644
index 000000000..3012c333f
--- /dev/null
+++ b/examples/testapp/main.cpp
@@ -0,0 +1,46 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QApplication>
+#include "mainwindow.h"
+#include <KDToolsCore/KDSelfRestarter>
+
+int main( int argc, char** argv ) {
+ const KDSelfRestarter restarter( argc, argv );
+ QStringList args;
+ for ( int i = 0; i < argc; ++i )
+ args << QString::fromLocal8Bit( argv[i] );
+ QApplication app( argc, argv );
+ MainWindow mw( args );
+ mw.show();
+ return app.exec();
+}
diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp
new file mode 100644
index 000000000..4a6fd1618
--- /dev/null
+++ b/examples/testapp/mainwindow.cpp
@@ -0,0 +1,182 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "mainwindow.h"
+
+#include <memory>
+
+#include <QAbstractButton>
+#include <QApplication>
+#include <QLabel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QProgressDialog>
+#include <QStringList>
+
+#include <KDToolsCore/KDAutoPointer>
+#include <KDToolsCore/KDSelfRestarter>
+
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+#include <KDUpdater/UpdateFinder>
+#include <KDUpdater/UpdateSourcesInfo>
+
+#include "common/binaryformatenginehandler.h"
+#include "common/binaryformat.h"
+#include "componentselectiondialog.h"
+#include "getrepositorymetainfojob.h"
+#include "common/errors.h"
+#include "common/fileutils.h"
+#include "init.h"
+#include "updateagent.h"
+
+#include "updatesettings.h"
+#include "updatesettingsdialog.h"
+
+using namespace QInstaller;
+
+MainWindow::MainWindow( const QStringList& args, QWidget* parent ) : QMainWindow( parent ) {
+
+ QInstaller::init();
+
+ QMenuBar* mbar = menuBar();
+ QMenu* fm = mbar->addMenu( QObject::tr("File") );
+ fm->addAction( QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()), QKeySequence( QLatin1String("Ctrl+U") ) );
+ fm->addAction( QObject::tr("Update Settings"), this, SLOT(editUpdateSettings()) );
+ fm->addAction( QObject::tr("Quit"), QApplication::instance(), SLOT(quit()), QKeySequence( QLatin1String("Ctrl+Q") ) );
+ QLabel* label = new QLabel( this );
+ label->setAlignment( Qt::AlignCenter );
+ setCentralWidget( label );
+ label->setText( QString::fromLatin1("Version: %1\n").arg( m_installer.settings().applicationVersion() ) + args.join( QLatin1String(" ") ) );
+ updaterapp.packagesInfo()->setApplicationName( m_settings.applicationName() );
+ updaterapp.packagesInfo()->setApplicationVersion( m_settings.applicationVersion() );
+
+ UpdateAgent* const agent = new UpdateAgent( this );
+ connect( agent, SIGNAL( updatesAvailable() ), this, SLOT( updatesAvailable() ) );
+}
+
+void MainWindow::editUpdateSettings()
+{
+ UpdateSettingsDialog dialog( this );
+ connect( &dialog, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) );
+ dialog.exec();
+}
+
+void MainWindow::checkForUpdates() {
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ UpdateSettings settings;
+
+ try
+ {
+ m_installer.setRemoteRepositories( settings.repositories() );
+ settings.setLastCheck( QDateTime::currentDateTime() );
+
+ // no updates for us
+ if( m_installer.components().isEmpty() )
+ {
+ QMessageBox::information( this, tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) );
+ return;
+ }
+
+ // set the target directory to the actual one
+ m_installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
+
+ // this will automatically mork components as to get installed
+ ComponentSelectionDialog componentSelection( &m_installer, this );
+ if( componentSelection.exec() == QDialog::Rejected )
+ return;
+
+ QProgressDialog dialog( this );
+ dialog.setRange( 0, 100 );
+ dialog.show();
+ connect( &dialog, SIGNAL( canceled() ), &m_installer, SLOT( interrupt() ) );
+ connect( &m_installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) );
+ connect( &m_installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) );
+ m_installer.installSelectedComponents();
+ updatesInstalled();
+ }
+ catch( const QInstaller::Error& error )
+ {
+ QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) );
+ m_installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ m_installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+}
+
+void MainWindow::updatesAvailable()
+{
+ KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
+ box->setWindowTitle( tr("Updates Available") );
+ box->setText( tr("Software updates are available for your computer. Do you want to install them?") );
+ box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr( "Continue" ) );
+ box->button( QMessageBox::No )->setText( tr( "Not Now" ) );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ checkForUpdates();
+}
+
+void MainWindow::updatesInstalled()
+{
+ // only ask that dumb question if a SelfUpdateOperation was executed
+ if( !KDSelfRestarter::restartOnQuit() )
+ {
+ QMessageBox::information( this, tr( "Updates Installed" ), tr( "Installation complete." ) );
+ return;
+ }
+
+ KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
+ box->setWindowTitle( tr("Updates Installed" ) );
+ box->setText( tr("Installation complete, you need to restart the application for the changes to take effect.") );
+ box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr("Restart Now") );
+ box->button( QMessageBox::No )->setText( tr("Restart Later") );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ QCoreApplication::quit();
+ else
+ KDSelfRestarter::setRestartOnQuit( false );
+}
+
diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h
new file mode 100644
index 000000000..c0611eaab
--- /dev/null
+++ b/examples/testapp/mainwindow.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QMainWindow>
+
+#include <KDUpdater/Application>
+
+#include "qinstaller.h"
+#include "common/installersettings.h"
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ explicit MainWindow( const QStringList& args, QWidget* parent=0 );
+
+private Q_SLOTS:
+ void editUpdateSettings();
+ void checkForUpdates();
+ void updatesInstalled();
+ void updatesAvailable();
+
+private:
+ KDUpdater::Application updaterapp;
+ QInstaller::Installer m_installer;
+ QInstaller::InstallerSettings m_settings;
+};
diff --git a/examples/testapp/packages/com.nokia.testapp/meta/installscript.js b/examples/testapp/packages/com.nokia.testapp/meta/installscript.js
new file mode 100644
index 000000000..d1dded25b
--- /dev/null
+++ b/examples/testapp/packages/com.nokia.testapp/meta/installscript.js
@@ -0,0 +1,18 @@
+function Component()
+{
+ if( installer.isUpdater() )
+ {
+ if( installer.value( "os" ) == "win" )
+ component.addDownloadableArchive( "testapp.exe" );
+ else
+ component.addDownloadableArchive( "testapp.app.7z" );
+ }
+}
+
+Component.prototype.createOperationsForArchive = function( archive )
+{
+ component.createOperationsForArchive( archive );
+
+ if( installer.isUpdater() )
+ component.addOperation( "SelfRestart" );
+}
diff --git a/examples/testapp/packages/com.nokia.testapp/meta/package.xml b/examples/testapp/packages/com.nokia.testapp/meta/package.xml
new file mode 100644
index 000000000..071a2c807
--- /dev/null
+++ b/examples/testapp/packages/com.nokia.testapp/meta/package.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<Package>
+ <DisplayName>Test App</DisplayName>
+ <Description>Installs the complete Nokia SDK.</Description>
+ <Version>1</Version>
+ <ReleaseDate>2009-12-03</ReleaseDate>
+ <Name>com.nokia.testapp</Name>
+ <Script>installscript.js</Script>
+</Package>
diff --git a/examples/testapp/testapp.pro b/examples/testapp/testapp.pro
new file mode 100644
index 000000000..f32b09f0a
--- /dev/null
+++ b/examples/testapp/testapp.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+TARGET =
+
+include( ../../installerbuilder/libinstaller/libinstaller.pri )
+LIBS = -L$$OUT_PWD/../../installerbuilder/lib -linstaller $$LIBS
+
+DESTDIR = packages/com.nokia.testapp/data
+
+QT += script network xml sql
+CONFIG += uitools help
+QTPLUGIN += qsqlite
+
+# Input
+HEADERS += mainwindow.h
+SOURCES += main.cpp mainwindow.cpp
+RESOURCES += testapp.qrc
+
+macx:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase TestAppInstaller.app com.nokia.testapp)
+win32:QMAKE_POST_LINK = ($$OUT_PWD\..\..\installerbuilder\bin\binarycreator.exe -p $$PWD\packages -c $$PWD\config -t $$OUT_PWD\..\..\installerbuilder\bin\installerbase.exe TestAppInstaller.exe com.nokia.testapp)
diff --git a/examples/testapp/testapp.qrc b/examples/testapp/testapp.qrc
new file mode 100644
index 000000000..89c08ca9e
--- /dev/null
+++ b/examples/testapp/testapp.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/metadata/installer-config">
+ <file>config.xml</file>
+ </qresource>
+ <qresource>
+ <file>logo.png</file>
+ </qresource>
+</RCC>