summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2012-03-15 14:53:47 +0100
committerKarsten Heimrich <karsten.heimrich@nokia.com>2012-03-19 16:14:04 +0100
commitbe3b47d0d504a3409ce66bd77bb8c0acff87c4f5 (patch)
tree09dfb02d484a4f395991972b828da71400fb761a /examples
parent9fd62353cf7f973d78cd2093328ac15b5c4980b6 (diff)
Reorganize the tree, have better ifw.pri. Shadow build support.
Change-Id: I01fb12537f863ed0744979973c7e4153889cc5cb Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/downloadspeed/downloadspeed.pro14
-rw-r--r--examples/downloadspeed/main.cpp203
-rw-r--r--examples/examples.pro4
-rw-r--r--examples/testapp/testapp.pro49
4 files changed, 29 insertions, 241 deletions
diff --git a/examples/downloadspeed/downloadspeed.pro b/examples/downloadspeed/downloadspeed.pro
deleted file mode 100644
index 820753e79..000000000
--- a/examples/downloadspeed/downloadspeed.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-include(../../installerbuilder/libinstaller/libinstaller.pri)
-DEPENDPATH += . .. ../../installerbuilder/libinstaller
-INCLUDEPATH += . .. ../../installerbuilder/libinstaller
-
-TEMPLATE = app
-CONFIG += console
-CONFIG -= app_bundle
-TARGET = downloadspeed
-
-QT -= gui
-QT += core network
-LIBS = -L$$OUT_PWD/../../installerbuilder/lib -linstaller $$LIBS
-
-SOURCES += main.cpp
diff --git a/examples/downloadspeed/main.cpp b/examples/downloadspeed/main.cpp
deleted file mode 100644
index 56d6f44f4..000000000
--- a/examples/downloadspeed/main.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Installer Framework
-**
-** Copyright (c) 2011-2012 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.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**************************************************************************/
-
-#include <kdupdaterfiledownloader.h>
-#include <kdupdaterfiledownloaderfactory.h>
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDebug>
-#include <QtCore/QObject>
-#include <QtCore/QUrl>
-
-#include <QtNetwork/QNetworkProxy>
-
-static QString humanReadableSize(quint64 intSize)
-{
- QString unit;
- double size;
-
- if (intSize < 1024 * 1024) {
- size = 1. + intSize / 1024.;
- unit = QObject::tr("kB");
- } else if (intSize < 1024 * 1024 * 1024) {
- size = 1. + intSize / 1024. / 1024.;
- unit = QObject::tr("MB");
- } else {
- size = 1. + intSize / 1024. / 1024. / 1024.;
- unit = QObject::tr("GB");
- }
-
- size = qRound(size * 10) / 10.0;
- return QString::fromLatin1("%L1 %2").arg(size, 0, 'g', 4).arg(unit);
-}
-
-// -- Receiver
-
-class Receiver : public QObject
-{
- Q_OBJECT
-
-public:
- Receiver() : QObject(), m_downloadFinished(false) {}
- ~Receiver() {}
-
- inline bool downloaded() { return m_downloadFinished; }
-
-public slots:
- void downloadStarted()
- {
- m_downloadFinished = false;
- }
-
- void downloadFinished()
- {
- m_downloadFinished = true;
- }
-
- void downloadAborted(const QString &error)
- {
- m_downloadFinished = true;
- qDebug() << "Error:" << error;
- }
-
- void downloadSpeed(qint64 speed)
- {
- qDebug() << "Download speed:" << humanReadableSize(speed) + "/sec";
- }
-
- void downloadProgress(double progress)
- {
- qDebug() << "Progress:" << progress;
- }
-
- void estimatedDownloadTime(int time)
- {
- if (time <= 0) {
- qDebug() << "Unknown time remaining.";
- return;
- }
-
- const int d = time / 86400;
- const int h = (time / 3600) - (d * 24);
- const int m = (time / 60) - (d * 1440) - (h * 60);
- const int s = time % 60;
-
- QString days;
- if (d > 0)
- days = QString::number(d) + (d < 2 ? " day" : " days") + QLatin1String(", ");
-
- QString hours;
- if (h > 0)
- hours = QString::number(h) + (h < 2 ? " hour" : " hours") + QLatin1String(", ");
-
- QString minutes;
- if (m > 0)
- minutes = QString::number(m) + (m < 2 ? " minute" : " minutes");
-
- QString seconds;
- if (s >= 0 && minutes.isEmpty())
- seconds = QString::number(s) + (s < 2 ? " second" : " seconds");
-
- qDebug() << days + hours + minutes + seconds + tr("remaining.");
- }
-
- void downloadStatus(const QString &status)
- {
- qDebug() << status;
- }
-
- void downloadProgress(qint64 bytesReceived, qint64 bytesToReceive)
- {
- qDebug() << "Bytes received:" << bytesReceived << ", Bytes to receive:" << bytesToReceive;
- }
-
-private:
- volatile bool m_downloadFinished;
-};
-
-
-// http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.4.dmg
-// ftp://ftp.trolltech.com/qt/source/qt-mac-opensource-4.7.4.dmg
-
-class ProxyFactory : public KDUpdater::FileDownloaderProxyFactory
-{
-public:
- ProxyFactory() {}
-
- ProxyFactory *clone() const
- {
- return new ProxyFactory();
- }
-
- QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery())
- {
- return QNetworkProxyFactory::systemProxyForQuery(query);
- }
-};
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
-
- if (a.arguments().count() < 2)
- return EXIT_FAILURE;
-
- const QUrl url(a.arguments().value(1));
- qDebug() << url.toString();
- KDUpdater::FileDownloader *loader = KDUpdater::FileDownloaderFactory::instance().create(url.scheme(), 0);
- if (loader) {
- loader->setUrl(url);
- loader->setProxyFactory(new ProxyFactory());
-
- Receiver r;
- r.connect(loader, SIGNAL(downloadStarted()), &r, SLOT(downloadStarted()));
- r.connect(loader, SIGNAL(downloadCanceled()), &r, SLOT(downloadFinished()));
- r.connect(loader, SIGNAL(downloadCompleted()), &r, SLOT(downloadFinished()));
- r.connect(loader, SIGNAL(downloadAborted(QString)), &r, SLOT(downloadAborted(QString)));
-
- r.connect(loader, SIGNAL(downloadSpeed(qint64)), &r, SLOT(downloadSpeed(qint64)));
- r.connect(loader, SIGNAL(downloadStatus(QString)), &r, SLOT(downloadStatus(QString)));
- r.connect(loader, SIGNAL(downloadProgress(double)), &r, SLOT(downloadProgress(double)));
- r.connect(loader, SIGNAL(estimatedDownloadTime(int)), &r, SLOT(estimatedDownloadTime(int)));
- r.connect(loader, SIGNAL(downloadProgress(qint64, qint64)), &r, SLOT(downloadProgress(qint64, qint64)));
-
- loader->download();
- while (!r.downloaded())
- QCoreApplication::processEvents();
-
- delete loader;
- }
-
- return EXIT_SUCCESS;
-}
-
-#include "main.moc"
diff --git a/examples/examples.pro b/examples/examples.pro
index 7a2731edb..e86e611da 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
-TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS += testapp downloadspeed
+TEMPLATE = subdirs
+SUBDIRS += testapp
diff --git a/examples/testapp/testapp.pro b/examples/testapp/testapp.pro
index 48ac2b0b2..888e45803 100644
--- a/examples/testapp/testapp.pro
+++ b/examples/testapp/testapp.pro
@@ -1,33 +1,38 @@
TEMPLATE = app
-TARGET =
+DEPENDPATH += . ..
+INCLUDEPATH += . ..
+TARGET = testapp
-include( ../../installerbuilder/libinstaller/libinstaller.pri )
-LIBS = -L$$OUT_PWD/../../installerbuilder/lib -linstaller $$LIBS
+include(../../installerfw.pri)
+!static {
+ warning("You can use this example only with a static build of Qt and IFW!")
+}
+
+LIBS += -linstaller
DESTDIR = packages/com.nokia.testapp/data
-QT += script network xml sql
-CONFIG += uitools help
-contains(CONFIG, static): {
- QTPLUGIN += qsqlite
- DEFINES += USE_STATIC_SQLITE_PLUGIN
-}
+FORMS += \
+ componentselectiondialog.ui \
+ updatesettingsdialog.ui \
+ updatesettingswidget.ui
-# Input
-FORMS += componentselectiondialog.ui updatesettingsdialog.ui updatesettingswidget.ui
HEADERS += mainwindow.h \
- componentselectiondialog.h \
- updatesettingsdialog.h \
- updateagent.h \
- updatesettingswidget.h
+ componentselectiondialog.h \
+ updatesettingsdialog.h \
+ updateagent.h \
+ updatesettingswidget.h
-SOURCES += main.cpp mainwindow.cpp \
- componentselectiondialog.cpp \
- updatesettingsdialog.cpp \
- updateagent.cpp \
- updatesettingswidget.cpp
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ componentselectiondialog.cpp \
+ updatesettingsdialog.cpp \
+ updateagent.cpp \
+ updatesettingswidget.cpp
RESOURCES += testapp.qrc
-macx:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase TestAppInstaller.app com.nokia.testapp)
-win32:QMAKE_POST_LINK = ($$OUT_PWD\\..\\..\\installerbuilder\\bin\\binarycreator.exe -p $$PWD\\packages -c $$PWD\\config -t $$OUT_PWD\\..\\..\\installerbuilder\\bin\\installerbase.exe TestAppInstaller.exe com.nokia.testapp)
+isEqual(IFW_SOURCE_TREE, $$IFW_BUILD_TREE) {
+ macx:QMAKE_POST_LINK = ($$IFW_APP_PATH/binarycreator -p $$PWD/packages -c $$PWD/config -t $$IFW_APP_PATH/installerbase TestAppInstaller.app com.nokia.testapp)
+ win32:QMAKE_POST_LINK = ($$IFW_APP_PATH/binarycreator.exe -p $$PWD/packages -c $$PWD/config -t $$IFW_APP_PATH/installerbase.exe TestAppInstaller.exe com.nokia.testapp)
+}