summaryrefslogtreecommitdiffstats
path: root/src/libs/kdtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r--src/libs/kdtools/environment.cpp41
-rw-r--r--src/libs/kdtools/environment.h41
-rw-r--r--src/libs/kdtools/kdgenericfactory.cpp158
-rw-r--r--src/libs/kdtools/kdgenericfactory.h45
-rw-r--r--src/libs/kdtools/kdjob.cpp45
-rw-r--r--src/libs/kdtools/kdjob.h45
-rw-r--r--src/libs/kdtools/kdlockfile.cpp79
-rw-r--r--src/libs/kdtools/kdlockfile.h45
-rw-r--r--src/libs/kdtools/kdlockfile_p.h45
-rw-r--r--src/libs/kdtools/kdlockfile_unix.cpp45
-rw-r--r--src/libs/kdtools/kdlockfile_win.cpp47
-rw-r--r--src/libs/kdtools/kdrunoncechecker.cpp45
-rw-r--r--src/libs/kdtools/kdrunoncechecker.h45
-rw-r--r--src/libs/kdtools/kdsavefile.cpp115
-rw-r--r--src/libs/kdtools/kdsavefile.h45
-rw-r--r--src/libs/kdtools/kdselfrestarter.cpp51
-rw-r--r--src/libs/kdtools/kdselfrestarter.h47
-rw-r--r--src/libs/kdtools/kdsysinfo.cpp45
-rw-r--r--src/libs/kdtools/kdsysinfo.h45
-rw-r--r--src/libs/kdtools/kdsysinfo_mac.cpp45
-rw-r--r--src/libs/kdtools/kdsysinfo_win.cpp222
-rw-r--r--src/libs/kdtools/kdsysinfo_x11.cpp47
-rw-r--r--src/libs/kdtools/kdtools.pri3
-rw-r--r--src/libs/kdtools/kdtoolsglobal.h45
-rw-r--r--src/libs/kdtools/kdupdater.h57
-rw-r--r--src/libs/kdtools/kdupdaterapplication.cpp92
-rw-r--r--src/libs/kdtools/kdupdaterapplication.h72
-rw-r--r--src/libs/kdtools/kdupdaterfiledownloader.cpp107
-rw-r--r--src/libs/kdtools/kdupdaterfiledownloader.h50
-rw-r--r--src/libs/kdtools/kdupdaterfiledownloader_p.h45
-rw-r--r--src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp59
-rw-r--r--src/libs/kdtools/kdupdaterfiledownloaderfactory.h48
-rw-r--r--src/libs/kdtools/kdupdaterpackagesinfo.cpp98
-rw-r--r--src/libs/kdtools/kdupdaterpackagesinfo.h58
-rw-r--r--src/libs/kdtools/kdupdatersignatureverificationrunnable.cpp137
-rw-r--r--src/libs/kdtools/kdupdatersignatureverificationrunnable.h92
-rw-r--r--src/libs/kdtools/kdupdatertask.cpp45
-rw-r--r--src/libs/kdtools/kdupdatertask.h45
-rw-r--r--src/libs/kdtools/kdupdaterupdate.cpp310
-rw-r--r--src/libs/kdtools/kdupdaterupdate.h102
-rw-r--r--src/libs/kdtools/kdupdaterupdatefinder.cpp399
-rw-r--r--src/libs/kdtools/kdupdaterupdatefinder.h64
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperation.cpp71
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperation.h50
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperationfactory.cpp48
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperationfactory.h45
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperations.cpp584
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperations.h102
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfo.cpp237
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfo_p.h85
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfodata_p.h76
-rw-r--r--src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp198
-rw-r--r--src/libs/kdtools/kdupdaterupdatesourcesinfo.h61
53 files changed, 2119 insertions, 2754 deletions
diff --git a/src/libs/kdtools/environment.cpp b/src/libs/kdtools/environment.cpp
index 4b031ecc4..5c3eb8bc1 100644
--- a/src/libs/kdtools/environment.cpp
+++ b/src/libs/kdtools/environment.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "environment.h"
#include <QHash>
diff --git a/src/libs/kdtools/environment.h b/src/libs/kdtools/environment.h
index 917da4f45..94e13e9d8 100644
--- a/src/libs/kdtools/environment.h
+++ b/src/libs/kdtools/environment.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef LIBINSTALLER_ENVIRONMENT_H
#define LIBINSTALLER_ENVIRONMENT_H
diff --git a/src/libs/kdtools/kdgenericfactory.cpp b/src/libs/kdtools/kdgenericfactory.cpp
index 9352f83cd..a45d1089c 100644
--- a/src/libs/kdtools/kdgenericfactory.cpp
+++ b/src/libs/kdtools/kdgenericfactory.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdgenericfactory.h"
@@ -31,7 +50,7 @@
(The exception safety of this class has not been evaluated yet.)
KDGenericFactory is an implemention of of the factory pattern. It can be used to
- "produce" instances of different classes having a common superclass
+ "produce" instances of different classes having a common superclass
T_Product. The user of the
factory registers those producable classes in the factory by using an identifier
(T_Identifier, defaulting to QString). That identifer can then be used to
@@ -44,10 +63,10 @@
\li\link QHash::const_iterator a nested %const_iterator \endlink typedef for an iterator type that when dereferenced has type ((const) reference to) FactoryFunction (Qt convention),
\li\link QHash::insert %insert( T_Identifier, FactoryFunction ) \endlink, which must overwrite any existing entries with the same identifier.
- \li\link QHash::find %find( T_Identifier ) \endlink,
+ \li\link QHash::find %find( T_Identifier ) \endlink,
\li\link QHash::end %end() \endlink,
- \li\link QHash::size %size() \endlink,
- \li\link QHash::remove %remove( T_Identifier ) \endlink, and
+ \li\link QHash::size %size() \endlink,
+ \li\link QHash::remove %remove( T_Identifier ) \endlink, and
\li\link QHash::keys %keys ) \endlink, returning a QList<T_Identifier>.
The only two class templates that currently match this concept are
@@ -59,7 +78,7 @@
instead of just FactoryFunction.
\section general-use General Use
-
+
The following example shows how the general use case of KDGenericFactory looks like:
\code
@@ -87,10 +106,10 @@
// lets create some stuff - here comes our tasty apple:
Fruit* myApple = fruitPlantation.create( "Apple" );
-
+
// and a pear, please:
Fruit* myPear = fruitPlantation.create( "Pear" );
-
+
// ohh - that doesn't work, returns a null pointer:
Fruit* myCherry = fruitPlantation.create( "Cherry" );
}
@@ -106,7 +125,7 @@
/*!
\typedef KDGenericFactory::FactoryFunction
-
+
This typedef defines a factory function producing an object of type T_Product.
*/
@@ -116,7 +135,7 @@
Registers a product of type T, identified by \a name in the factory.
Any type with the same name gets unregistered.
- If a product was registered via this method, it will be created using its
+ If a product was registered via this method, it will be created using its
default constructor.
*/
@@ -153,98 +172,3 @@
type T, identified by \a name. When a product is registered via this method, it will be created
by calling create().
*/
-
-#ifdef KDTOOLSCORE_UNITTESTS
-
-#include <KDUnitTest/test.h>
-
-#include <QStringList>
-#include <QMap>
-
-class Fruit
-{
-public:
- virtual ~Fruit() {}
-};
-
-class Apple : public Fruit
-{
-};
-
-class Pear : public Fruit
-{
-};
-
-std::ostream& operator<<( std::ostream& stream, const QStringList& list )
-{
- stream << "QStringList(";
- for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it )
- {
- stream << " " << it->toLocal8Bit().data();
- if( it + 1 != list.end() )
- stream << ",";
- }
- stream << " )";
- return stream;
-}
-
-class KDGenericFactoryTest : public KDUnitTest::Test {
-public:
- KDGenericFactoryTest() : Test( "KDGenericFactory" ) {}
- void run() {
- doRun<QHash>();
- doRun<QMap>();
- }
-
- template <template <typename U, typename V> class T_Map>
- void doRun();
-};
-
-KDAB_EXPORT_UNITTEST( KDGenericFactoryTest, "kdcoretools" )
-
-template <template <typename U, typename V> class T_Map>
-void KDGenericFactoryTest::doRun() {
-
- {
- KDGenericFactory< Fruit, QString, T_Map > fruitPlantation;
- assertEqual( fruitPlantation.productCount(), 0U );
- assertEqual( fruitPlantation.availableProducts(), QStringList() );
-
- fruitPlantation.template registerProduct< Apple >( QLatin1String( "Apple" ) );
- assertEqual( fruitPlantation.productCount(), 1U );
- assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Apple" ) ) );
-
- fruitPlantation.template registerProduct< Pear >( QLatin1String( "Pear" ) );
- assertEqual( fruitPlantation.productCount(), 2U );
-
- Fruit* fruit = 0;
- fruit = fruitPlantation.create( QLatin1String( "Apple" ) );
- assertNotNull( fruit );
- assertNotNull( dynamic_cast< Apple* >( fruit ) );
-
- fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
- assertNotNull( fruit );
- assertNotNull( dynamic_cast< Pear* >( fruit ) );
-
- fruit = fruitPlantation.create( QLatin1String( "Cherry" ) );
- assertNull( fruit );
-
- fruitPlantation.unregisterProduct( QLatin1String( "Apple" ) );
- assertEqual( fruitPlantation.productCount(), 1U );
- assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Pear" ) ) );
- fruit = fruitPlantation.create( QLatin1String( "Apple" ) );
- assertNull( fruit );
-
- fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
- assertNotNull( fruit );
- assertNotNull( dynamic_cast< Pear* >( fruit ) );
-
-
- fruitPlantation.unregisterProduct( QLatin1String( "Pear" ) );
- assertEqual( fruitPlantation.productCount(), 0U );
- fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
- assertNull( fruit );
- }
-
-}
-#endif // KDTOOLSCORE_UNITTESTS
diff --git a/src/libs/kdtools/kdgenericfactory.h b/src/libs/kdtools/kdgenericfactory.h
index d12c35785..349c5ee92 100644
--- a/src/libs/kdtools/kdgenericfactory.h
+++ b/src/libs/kdtools/kdgenericfactory.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS__KDGENERICFACTORY_H
#define KDTOOLS__KDGENERICFACTORY_H
diff --git a/src/libs/kdtools/kdjob.cpp b/src/libs/kdtools/kdjob.cpp
index 47a30a836..484cd6dc4 100644
--- a/src/libs/kdtools/kdjob.cpp
+++ b/src/libs/kdtools/kdjob.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdjob.h"
diff --git a/src/libs/kdtools/kdjob.h b/src/libs/kdtools/kdjob.h
index 37f441526..33b0f556d 100644
--- a/src/libs/kdtools/kdjob.h
+++ b/src/libs/kdtools/kdjob.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_KDJOB_H
#define KDTOOLS_KDJOB_H
diff --git a/src/libs/kdtools/kdlockfile.cpp b/src/libs/kdtools/kdlockfile.cpp
index 3a440b6b0..a647f4eb8 100644
--- a/src/libs/kdtools/kdlockfile.cpp
+++ b/src/libs/kdtools/kdlockfile.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdlockfile.h"
@@ -55,37 +74,3 @@ bool KDLockFile::unlock()
{
return d->unlock();
}
-
-
-#ifdef KDTOOLSCORE_UNITTESTS
-
-#include <KDUnitTest/Test>
-#include <QDebug>
-#include <QDir>
-
-KDAB_UNITTEST_SIMPLE( KDLockFile, "kdcoretools" ) {
- {
- KDLockFile f( QLatin1String("/jlksdfdsfjkldsf-doesnotexist/file") );
- const bool locked = f.lock();
- assertFalse( locked );
- qDebug() << f.errorString();
- assertTrue( !f.errorString().isEmpty() );
- if ( !locked )
- assertTrue( f.unlock() );
- }
- {
- KDLockFile f( QDir::currentPath() + QLatin1String("/kdlockfile-test") );
- const bool locked = f.lock();
- assertTrue( locked );
- if ( !locked )
- qDebug() << f.errorString();
- assertEqual( locked, f.errorString().isEmpty() );
- const bool unlocked = f.unlock();
- assertTrue( unlocked );
- if ( !unlocked )
- qDebug() << f.errorString();
- assertEqual( unlocked, f.errorString().isEmpty() );
- }
-}
-
-#endif // KDTOOLSCORE_UNITTESTS
diff --git a/src/libs/kdtools/kdlockfile.h b/src/libs/kdtools/kdlockfile.h
index 1674070bf..dfa389595 100644
--- a/src/libs/kdtools/kdlockfile.h
+++ b/src/libs/kdtools/kdlockfile.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_KDLOCKFILE_H
#define KDTOOLS_KDLOCKFILE_H
diff --git a/src/libs/kdtools/kdlockfile_p.h b/src/libs/kdtools/kdlockfile_p.h
index da4c4dc4c..091819997 100644
--- a/src/libs/kdtools/kdlockfile_p.h
+++ b/src/libs/kdtools/kdlockfile_p.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef __KDTOOLSCORE_KDLOCKFILE_P_H__
#define __KDTOOLSCORE_KDLOCKFILE_P_H__
diff --git a/src/libs/kdtools/kdlockfile_unix.cpp b/src/libs/kdtools/kdlockfile_unix.cpp
index 6f362b974..3e0a450b7 100644
--- a/src/libs/kdtools/kdlockfile_unix.cpp
+++ b/src/libs/kdtools/kdlockfile_unix.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdlockfile_p.h"
diff --git a/src/libs/kdtools/kdlockfile_win.cpp b/src/libs/kdtools/kdlockfile_win.cpp
index f139bd0d4..b5c756a8e 100644
--- a/src/libs/kdtools/kdlockfile_win.cpp
+++ b/src/libs/kdtools/kdlockfile_win.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdlockfile.h"
#include "kdlockfile_p.h"
@@ -28,7 +47,7 @@
KDLockFile::Private::~Private()
{
- unlock();
+ unlock();
}
bool KDLockFile::Private::lock()
diff --git a/src/libs/kdtools/kdrunoncechecker.cpp b/src/libs/kdtools/kdrunoncechecker.cpp
index 702016d71..b814ae6f3 100644
--- a/src/libs/kdtools/kdrunoncechecker.cpp
+++ b/src/libs/kdtools/kdrunoncechecker.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdrunoncechecker.h"
#include "kdlockfile.h"
diff --git a/src/libs/kdtools/kdrunoncechecker.h b/src/libs/kdtools/kdrunoncechecker.h
index 127102274..d9d69fc1d 100644
--- a/src/libs/kdtools/kdrunoncechecker.h
+++ b/src/libs/kdtools/kdrunoncechecker.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_RUNONCECHECKER_H
#define KDTOOLS_RUNONCECHECKER_H
diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp
index 849eef393..483f1b338 100644
--- a/src/libs/kdtools/kdsavefile.cpp
+++ b/src/libs/kdtools/kdsavefile.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdsavefile.h"
@@ -458,73 +477,3 @@ QString KDSaveFile::backupExtension() const
{
return d->backupExtension;
}
-
-/**
- * TODO
- *
- *
- */
-
-#ifdef KDTOOLSCORE_UNITTESTS
-
-#include <KDUnitTest/Test>
-
-KDAB_UNITTEST_SIMPLE( KDSaveFile, "kdcoretools" ) {
- //TODO test contents (needs blocking and checked write() )
- {
- const QString testfile1 = QLatin1String("kdsavefile-test1");
- QByteArray testData("lalalala");
- KDSaveFile saveFile( testfile1 );
- assertTrue( saveFile.open( QIODevice::WriteOnly ) );
- saveFile.write( testData.constData(), testData.size() );
- assertTrue( saveFile.commit() );
- assertTrue( QFile::exists( testfile1 ) );
- assertTrue( QFile::remove( testfile1 ) );
- }
- {
- const QString testfile1 = QLatin1String("kdsavefile-test1");
- QByteArray testData("lalalala");
- KDSaveFile saveFile( testfile1 );
- assertTrue( saveFile.open( QIODevice::WriteOnly ) );
- saveFile.write( testData.constData(), testData.size() );
- saveFile.close();
- assertFalse( QFile::exists( testfile1 ) );
- }
- {
- const QString testfile1 = QLatin1String("kdsavefile-test1");
- QByteArray testData("lalalala");
- KDSaveFile saveFile( testfile1 );
- assertTrue( saveFile.open( QIODevice::WriteOnly ) );
- saveFile.write( testData.constData(), testData.size() );
- assertTrue( saveFile.commit() );
- assertTrue( QFile::exists( testfile1 ) );
-
- KDSaveFile sf2( testfile1 );
- sf2.setBackupExtension( QLatin1String(".bak") );
- assertTrue( sf2.open( QIODevice::WriteOnly ) );
- sf2.write( testData.constData(), testData.size() );
- sf2.commit(); //commit in backup mode (default)
- const QString backup = testfile1 + sf2.backupExtension();
- assertTrue( QFile::exists( backup ) );
- assertTrue( QFile::remove( backup ) );
-
- KDSaveFile sf3( testfile1 );
- sf3.setBackupExtension( QLatin1String(".bak") );
- assertTrue( sf3.open( QIODevice::WriteOnly ) );
- sf3.write( testData.constData(), testData.size() );
- sf3.commit( KDSaveFile::OverwriteExistingFile );
- const QString backup2 = testfile1 + sf3.backupExtension();
- assertFalse( QFile::exists( backup2 ) );
-
- assertTrue( QFile::remove( testfile1 ) );
- }
- {
- const QString testfile1 = QLatin1String("kdsavefile-test1");
- KDSaveFile sf( testfile1 );
- assertFalse( sf.open( QIODevice::ReadOnly ) );
- assertFalse( sf.open( QIODevice::WriteOnly|QIODevice::Append ) );
- assertTrue( sf.open( QIODevice::ReadWrite ) );
- }
-}
-
-#endif // KDTOOLSCORE_UNITTESTS
diff --git a/src/libs/kdtools/kdsavefile.h b/src/libs/kdtools/kdsavefile.h
index 8147459a8..24eee9870 100644
--- a/src/libs/kdtools/kdsavefile.h
+++ b/src/libs/kdtools/kdsavefile.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_KDSAVEFILE_H
#define KDTOOLS_KDSAVEFILE_H
diff --git a/src/libs/kdtools/kdselfrestarter.cpp b/src/libs/kdtools/kdselfrestarter.cpp
index 22457bd92..e8ffad4ee 100644
--- a/src/libs/kdtools/kdselfrestarter.cpp
+++ b/src/libs/kdtools/kdselfrestarter.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdselfrestarter.h"
@@ -33,11 +52,11 @@ public:
: restartOnQuit(false)
{
executable = QString::fromLocal8Bit(argv[0]);
- workingPath = QDir::currentPath();
+ workingPath = QDir::currentPath();
for (int i = 1; i < argc; ++i)
args << QString::fromLocal8Bit(argv[i]);
}
-
+
Private()
{
executable = qApp->applicationFilePath();
@@ -50,7 +69,7 @@ public:
if (restartOnQuit)
QProcess::startDetached(executable, args, workingPath);
}
-
+
QString executable;
QStringList args;
bool restartOnQuit;
diff --git a/src/libs/kdtools/kdselfrestarter.h b/src/libs/kdtools/kdselfrestarter.h
index bbf46a2b9..34918d644 100644
--- a/src/libs/kdtools/kdselfrestarter.h
+++ b/src/libs/kdtools/kdselfrestarter.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_KDSELFRESTARTER_H
#define KDTOOLS_KDSELFRESTARTER_H
@@ -33,7 +52,7 @@ public:
static bool restartOnQuit();
static void setRestartOnQuit(bool restart);
-
+
private:
Q_DISABLE_COPY(KDSelfRestarter)
class Private;
diff --git a/src/libs/kdtools/kdsysinfo.cpp b/src/libs/kdtools/kdsysinfo.cpp
index 194e5c5b5..98a0d951e 100644
--- a/src/libs/kdtools/kdsysinfo.cpp
+++ b/src/libs/kdtools/kdsysinfo.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdsysinfo.h"
diff --git a/src/libs/kdtools/kdsysinfo.h b/src/libs/kdtools/kdsysinfo.h
index bab32979a..ccbd4b4b1 100644
--- a/src/libs/kdtools/kdsysinfo.h
+++ b/src/libs/kdtools/kdsysinfo.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDSYSINFO_H
#define KDSYSINFO_H
diff --git a/src/libs/kdtools/kdsysinfo_mac.cpp b/src/libs/kdtools/kdsysinfo_mac.cpp
index e81b88495..9ca7150b6 100644
--- a/src/libs/kdtools/kdsysinfo_mac.cpp
+++ b/src/libs/kdtools/kdsysinfo_mac.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdsysinfo.h"
diff --git a/src/libs/kdtools/kdsysinfo_win.cpp b/src/libs/kdtools/kdsysinfo_win.cpp
index 10666c8e0..edeeb6879 100644
--- a/src/libs/kdtools/kdsysinfo_win.cpp
+++ b/src/libs/kdtools/kdsysinfo_win.cpp
@@ -1,28 +1,48 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdsysinfo.h"
-#include "link.h"
+#include <QLibrary>
+#include <QStringList>
#ifdef Q_CC_MINGW
# ifndef _WIN32_WINNT
@@ -34,16 +54,6 @@
#include <psapi.h>
#include <tlhelp32.h>
-#include <winnetwk.h>
-
-#ifndef Q_CC_MINGW
-#pragma comment(lib, "mpr.lib")
-#endif
-
-#include <QDebug>
-#include <QDir>
-#include <QLibrary>
-
const int KDSYSINFO_PROCESS_QUERY_LIMITED_INFORMATION = 0x1000;
namespace KDUpdater {
@@ -56,100 +66,6 @@ quint64 installedMemory()
return quint64(status.ullTotalPhys);
}
-VolumeInfo updateVolumeSizeInformation(const VolumeInfo &info)
-{
- ULARGE_INTEGER bytesTotal;
- ULARGE_INTEGER freeBytesPerUser;
-
- VolumeInfo update = info;
- if (GetDiskFreeSpaceExA(qPrintable(info.volumeDescriptor()), &freeBytesPerUser, &bytesTotal, NULL)) {
- update.setSize(bytesTotal.QuadPart);
- update.setAvailableSize(freeBytesPerUser.QuadPart);
- }
- return update;
-}
-
-/*!
- Returns a list of volume info objects that are mounted as network drive shares.
-*/
-QList<VolumeInfo> networkVolumeInfosFromMountPoints()
-{
- QList<VolumeInfo> volumes;
- QFileInfoList drives = QDir::drives();
- foreach (const QFileInfo &drive, drives) {
- const QString driveLetter = QDir::toNativeSeparators(drive.canonicalPath());
- const uint driveType = GetDriveTypeA(qPrintable(driveLetter));
- switch (driveType) {
- case DRIVE_REMOTE: {
- char buffer[1024] = "";
- DWORD bufferLength = 1024;
- UNIVERSAL_NAME_INFOA *universalNameInfo = (UNIVERSAL_NAME_INFOA*) &buffer;
- if (WNetGetUniversalNameA(qPrintable(driveLetter), UNIVERSAL_NAME_INFO_LEVEL,
- LPVOID(universalNameInfo), &bufferLength) == NO_ERROR) {
- VolumeInfo info;
- info.setMountPath(driveLetter);
- info.setVolumeDescriptor(QLatin1String(universalNameInfo->lpUniversalName));
- volumes.append(info);
- }
- } break;
-
- default:
- break;
- }
- }
- return volumes;
-}
-
-/*!
- Returns a list of volume info objects based on the given \a volumeGUID. The function also solves mounted
- volume folder paths. It does not return any network drive shares.
-*/
-QList<VolumeInfo> localVolumeInfosFromMountPoints(PTCHAR volumeGUID)
-{
- QList<VolumeInfo> volumes;
- DWORD bufferSize;
- TCHAR volumeNames[MAX_PATH + 1] = { 0 };
- if (GetVolumePathNamesForVolumeName(volumeGUID, volumeNames, MAX_PATH, &bufferSize)) {
- QStringList mountedPaths =
-#ifdef UNICODE
- QString::fromWCharArray(volumeNames, bufferSize).split(QLatin1Char(char(0)), QString::SkipEmptyParts);
-#else
- QString::fromLatin1(volumeNames, bufferSize).split(QLatin1Char(char(0)), QString::SkipEmptyParts);
-#endif
- foreach (const QString &mountedPath, mountedPaths) {
- VolumeInfo info;
- info.setMountPath(mountedPath);
-#ifdef UNICODE
- info.setVolumeDescriptor(QString::fromWCharArray(volumeGUID));
-#else
- info.setVolumeDescriptor(QString::fromLatin1(volumeGUID));
-#endif
- volumes.append(info);
- }
- }
- return volumes;
-}
-
-QList<VolumeInfo> mountedVolumes()
-{
- QList<VolumeInfo> tmp;
- TCHAR volumeGUID[MAX_PATH + 1] = { 0 };
- HANDLE handle = FindFirstVolume(volumeGUID, MAX_PATH);
- if (handle != INVALID_HANDLE_VALUE) {
- tmp += localVolumeInfosFromMountPoints(volumeGUID);
- while (FindNextVolume(handle, volumeGUID, MAX_PATH)) {
- tmp += localVolumeInfosFromMountPoints(volumeGUID);
- }
- FindVolumeClose(handle);
- }
- tmp += networkVolumeInfosFromMountPoints();
-
- QList<VolumeInfo> volumes;
- while (!tmp.isEmpty()) // update volume size information
- volumes.append(updateVolumeSizeInformation(tmp.takeFirst()));
- return volumes;
-}
-
struct EnumWindowsProcParam
{
QList<ProcessInfo> processes;
@@ -228,74 +144,4 @@ QList<ProcessInfo> runningProcesses()
return param.processes;
}
-bool CALLBACK TerminateAppEnum(HWND hwnd, LPARAM lParam)
-{
- DWORD dwID;
- GetWindowThreadProcessId(hwnd, &dwID);
-
- if (dwID == (DWORD)lParam)
- PostMessage(hwnd, WM_CLOSE, 0, 0);
-
- return true;
-}
-
-bool killProcess(const ProcessInfo &process, int msecs)
-{
- DWORD dwTimeout = msecs;
- if (msecs == -1)
- dwTimeout = INFINITE;
-
- // If we can't open the process with PROCESS_TERMINATE rights,
- // then we give up immediately.
- HANDLE hProc = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, FALSE, process.id);
-
- if (hProc == 0)
- return false;
-
- // TerminateAppEnum() posts WM_CLOSE to all windows whose PID
- // matches your process's.
- EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM)process.id);
-
- // Wait on the handle. If it signals, great. If it times out,
- // then you kill it.
- bool returnValue = false;
- if (WaitForSingleObject(hProc, dwTimeout) != WAIT_OBJECT_0)
- returnValue = TerminateProcess(hProc, 0);
-
- CloseHandle(hProc) ;
-
- return returnValue;
-}
-
-bool pathIsOnLocalDevice(const QString &path)
-{
- if (!QFileInfo(path).exists())
- return false;
-
- if (path.startsWith(QLatin1String("\\\\")))
- return false;
-
- QDir dir(path);
- do {
- if (QFileInfo(dir, QString()).isSymLink()) {
- QString currentPath = QFileInfo(dir, QString()).absoluteFilePath();
- return pathIsOnLocalDevice(Link(currentPath).targetPath());
- }
- } while (dir.cdUp());
-
- const UINT DRIVE_REMOTE_TYPE = 4;
- if (path.contains(QLatin1Char(':'))) {
- const QLatin1Char nullTermination('\0');
- // for example "c:\"
- const QString driveSearchString = path.left(3) + nullTermination;
- WCHAR wCharDriveSearchArray[4];
- driveSearchString.toWCharArray(wCharDriveSearchArray);
- UINT type = GetDriveType(wCharDriveSearchArray);
- if (type == DRIVE_REMOTE_TYPE)
- return false;
- }
-
- return true;
-}
-
} // namespace KDUpdater
diff --git a/src/libs/kdtools/kdsysinfo_x11.cpp b/src/libs/kdtools/kdsysinfo_x11.cpp
index 391fb5280..d9a51185c 100644
--- a/src/libs/kdtools/kdsysinfo_x11.cpp
+++ b/src/libs/kdtools/kdsysinfo_x11.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdsysinfo.h"
@@ -67,7 +86,7 @@ QList<VolumeInfo> mountedVolumes()
qCritical("%s: Could not open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString()));
return result; //better error-handling?
}
-
+
QTextStream stream(&f);
while (true) {
const QString s = stream.readLine();
diff --git a/src/libs/kdtools/kdtools.pri b/src/libs/kdtools/kdtools.pri
index cc9fd52fb..2b98089b9 100644
--- a/src/libs/kdtools/kdtools.pri
+++ b/src/libs/kdtools/kdtools.pri
@@ -36,7 +36,8 @@ HEADERS += $$PWD/kdupdater.h \
$$PWD/kdupdatertask.h \
$$PWD/kdupdaterupdatefinder.h \
$$PWD/kdupdaterupdatesinfo_p.h \
- $$PWD/environment.h
+ $$PWD/environment.h \
+ $$PWD/kdupdaterupdatesinfodata_p.h
SOURCES += $$PWD/kdupdaterapplication.cpp \
$$PWD/kdupdaterfiledownloader.cpp \
diff --git a/src/libs/kdtools/kdtoolsglobal.h b/src/libs/kdtools/kdtoolsglobal.h
index 8ce4d5224..628972fee 100644
--- a/src/libs/kdtools/kdtoolsglobal.h
+++ b/src/libs/kdtools/kdtoolsglobal.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KDTOOLS_KDTOOLSGLOBAL_H
#define KDTOOLS_KDTOOLSGLOBAL_H
diff --git a/src/libs/kdtools/kdupdater.h b/src/libs/kdtools/kdupdater.h
index f28461d9b..4ea6ba842 100644
--- a/src/libs/kdtools/kdupdater.h
+++ b/src/libs/kdtools/kdupdater.h
@@ -1,29 +1,48 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_H
#define KD_UPDATER_H
-#include <kdtoolsglobal.h>
+#include "kdtoolsglobal.h"
namespace KDUpdater
{
@@ -36,16 +55,6 @@ namespace KDUpdater
ECannotStopTask,
EUnknown
};
-
- enum UpdateType {
- PackageUpdate = 0x1,
- CompatUpdate = 0x2,
- NewPackage = 0x4,
- AllUpdate = PackageUpdate | CompatUpdate
- };
- Q_DECLARE_FLAGS( UpdateTypes, UpdateType )
- Q_DECLARE_OPERATORS_FOR_FLAGS( UpdateTypes )
-
KDTOOLS_EXPORT int compareVersion(const QString &v1, const QString &v2);
}
diff --git a/src/libs/kdtools/kdupdaterapplication.cpp b/src/libs/kdtools/kdupdaterapplication.cpp
index 352c33ca8..76290348c 100644
--- a/src/libs/kdtools/kdupdaterapplication.cpp
+++ b/src/libs/kdtools/kdupdaterapplication.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterapplication.h"
#include "kdupdaterpackagesinfo.h"
@@ -27,7 +46,6 @@
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
-#include <QSettings>
using namespace KDUpdater;
@@ -55,32 +73,6 @@ medium-to-large scale software systems.
\namespace KDUpdater
*/
-ConfigurationInterface::~ConfigurationInterface()
-{
-}
-
-namespace {
-
-class DefaultConfigImpl : public ConfigurationInterface
-{
-public:
- QVariant value(const QString &key) const
- {
- QSettings settings;
- settings.beginGroup(QLatin1String("KDUpdater"));
- return settings.value(key);
- }
-
- void setValue(const QString &key, const QVariant &value)
- {
- QSettings settings;
- settings.beginGroup(QLatin1String("KDUpdater"));
- settings.setValue(key, value);
- }
-};
-
-} // namespace anon
-
/*!
\class KDUpdater::Application kdupdaterapplication.h KDUpdaterApplication
\ingroup kdupdater
@@ -95,7 +87,6 @@ public:
User can also retrieve some information from this class:
\li application name
\li application version
- \li compat level
*/
struct Application::ApplicationData
@@ -103,7 +94,7 @@ struct Application::ApplicationData
explicit ApplicationData(ConfigurationInterface *config) :
packagesInfo(0),
updateSourcesInfo(0),
- configurationInterface(config ? config : new DefaultConfigImpl)
+ configurationInterface(config ? config : new ConfigurationInterface)
{
const QStringList oldFiles = configurationInterface->value(QLatin1String("FilesForDelayedDeletion")).toStringList();
Q_FOREACH(const QString &i, oldFiles) { //TODO this should happen asnyc and report errors, I guess
@@ -122,7 +113,7 @@ struct Application::ApplicationData
delete updateSourcesInfo;
delete configurationInterface;
}
-
+
static Application *instance;
QString applicationDirectory;
@@ -161,7 +152,7 @@ Application::~Application()
}
/*!
- Returns a previousle created Application instance.
+ Returns a previously created Application instance.
*/
Application *Application::instance()
{
@@ -215,17 +206,6 @@ QString Application::applicationVersion() const
return QString();
}
-/*!
- Returns the compat level that this application is in.
-*/
-int Application::compatLevel() const
-{
- if (d->packagesInfo->isValid())
- return d->packagesInfo->compatLevel();
-
- return -1;
-}
-
void Application::addUpdateSource(const QString &name, const QString &title,
const QString &description, const QUrl &url, int priority)
{
@@ -292,7 +272,7 @@ UpdateSourcesInfo* Application::updateSourcesInfo() const
{
return d->updateSourcesInfo;
}
-
+
void Application::printError(int errorCode, const QString &error)
{
qDebug() << errorCode << error;
diff --git a/src/libs/kdtools/kdupdaterapplication.h b/src/libs/kdtools/kdupdaterapplication.h
index b2079fe7c..b9250fdee 100644
--- a/src/libs/kdtools/kdupdaterapplication.h
+++ b/src/libs/kdtools/kdupdaterapplication.h
@@ -1,48 +1,73 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_APPLICATION_H
#define KD_UPDATER_APPLICATION_H
-#include "kdupdater.h"
-#include <QObject>
-#include <QRegExp>
+#include "kdtoolsglobal.h"
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
+#include <QSettings>
namespace KDUpdater {
class PackagesInfo;
class UpdateSourcesInfo;
-static QRegExp scCommaRegExp(QLatin1String("\\b(,|, )\\b"));
class ConfigurationInterface
{
public:
- virtual ~ConfigurationInterface();
- virtual QVariant value(const QString &key ) const = 0;
- virtual void setValue(const QString &key, const QVariant &value) = 0;
+ virtual ~ConfigurationInterface() {}
+ virtual QVariant value(const QString &key) const
+ {
+ QSettings settings;
+ settings.beginGroup(QLatin1String("KDUpdater"));
+ return settings.value(key);
+ }
+
+ virtual void setValue(const QString &key, const QVariant &value)
+ {
+ QSettings settings;
+ settings.beginGroup(QLatin1String("KDUpdater"));
+ settings.setValue(key, value);
+ }
};
class KDTOOLS_EXPORT Application : public QObject
@@ -60,7 +85,6 @@ public:
QString applicationName() const;
QString applicationVersion() const;
- int compatLevel() const;
void setPackagesXMLFileName(const QString &fileName);
QString packagesXMLFileName() const;
diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp
index 9ad3861dd..a7fbfe85b 100644
--- a/src/libs/kdtools/kdupdaterfiledownloader.cpp
+++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterfiledownloader_p.h"
#include "kdupdaterfiledownloaderfactory.h"
@@ -93,6 +112,7 @@ struct KDUpdater::FileDownloader::Private
, m_sampleIndex(0)
, m_downloadSpeed(0)
, m_factory(0)
+ , m_ignoreSslErrors(false)
{
memset(m_samples, 0, sizeof(m_samples));
}
@@ -125,6 +145,7 @@ struct KDUpdater::FileDownloader::Private
QAuthenticator m_authenticator;
FileDownloaderProxyFactory *m_factory;
+ bool m_ignoreSslErrors;
};
KDUpdater::FileDownloader::FileDownloader(const QString &scheme, QObject *parent)
@@ -363,6 +384,12 @@ void KDUpdater::FileDownloader::addCheckSumData(const char *data, int length)
d->m_hash.addData(data, length);
}
+void KDUpdater::FileDownloader::resetCheckSumData()
+{
+ d->m_hash.reset();
+}
+
+
/*!
Returns a copy of the proxy factory that this FileDownloader object is using to determine the proxies to
be used for requests.
@@ -407,6 +434,16 @@ void KDUpdater::FileDownloader::setAuthenticator(const QAuthenticator &authentic
}
}
+bool KDUpdater::FileDownloader::ignoreSslErrors()
+{
+ return d->m_ignoreSslErrors;
+}
+
+void KDUpdater::FileDownloader::setIgnoreSslErrors(bool ignore)
+{
+ d->m_ignoreSslErrors = ignore;
+}
+
// -- KDUpdater::LocalFileDownloader
/*
@@ -778,6 +815,7 @@ struct KDUpdater::HttpDownloader::Private
destination->close();
destination->deleteLater();
destination = 0;
+ q->resetCheckSumData();
}
};
@@ -941,6 +979,12 @@ void KDUpdater::HttpDownloader::httpReqFinished()
void KDUpdater::HttpDownloader::httpReadProgress(qint64 done, qint64 total)
{
+ if (d->http) {
+ const QUrl redirectUrl = d->http->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
+ if (followRedirects() && redirectUrl.isValid())
+ return; // if we are a redirection, do not emit the progress
+ }
+
setProgress(done, total);
emit downloadProgress(calcProgress(done, total));
}
@@ -1024,11 +1068,13 @@ void KDUpdater::HttpDownloader::onAuthenticationRequired(QNetworkReply *reply, Q
}
#ifndef QT_NO_OPENSSL
+
+#include "messageboxhandler.h"
+
// TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL
void KDUpdater::HttpDownloader::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors)
{
Q_UNUSED(reply)
-
QString errorString;
foreach (const QSslError &error, errors) {
if (!errorString.isEmpty())
@@ -1037,7 +1083,36 @@ void KDUpdater::HttpDownloader::onSslErrors(QNetworkReply* reply, const QList<QS
}
qDebug() << errorString;
- if (!d->aborted)
- httpDone(true);
+ const QStringList arguments = QCoreApplication::arguments();
+ if (arguments.contains(QLatin1String("--script")) || arguments.contains(QLatin1String("Script"))
+ || ignoreSslErrors()) {
+ reply->ignoreSslErrors();
+ return;
+ }
+ // TODO: Remove above code once we have a proper implementation for message box handler supporting
+ // methods used in the following code, right now we return here cause the message box is not scriptable.
+
+ QMessageBox msgBox(MessageBoxHandler::currentBestSuitParent());
+ msgBox.setDetailedText(errorString);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowModality(Qt::WindowModal);
+ msgBox.setWindowTitle(tr("Secure Connection Failed"));
+ msgBox.setText(tr("There was an error during connection to: %1.").arg(url().toString()));
+ msgBox.setInformativeText(QString::fromLatin1("<ul><li>%1</li><li>%2</li></ul>").arg(tr("This could be "
+ "a problem with the server's configuration, or it could be someone trying to impersonate the "
+ "server."), tr("If you have connected to this server successfully in the past or trust this server, "
+ "the error may be temporary and you can try again.")));
+
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
+ msgBox.setButtonText(QMessageBox::Yes, tr("Try again"));
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+
+ if (msgBox.exec() == QMessageBox::Cancel) {
+ if (!d->aborted)
+ httpDone(true);
+ } else {
+ reply->ignoreSslErrors();
+ KDUpdater::FileDownloaderFactory::instance().setIgnoreSslErrors(true);
+ }
}
#endif
diff --git a/src/libs/kdtools/kdupdaterfiledownloader.h b/src/libs/kdtools/kdupdaterfiledownloader.h
index 5c5fab459..9e5929050 100644
--- a/src/libs/kdtools/kdupdaterfiledownloader.h
+++ b/src/libs/kdtools/kdupdaterfiledownloader.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_FILE_DOWNLOADER_H
#define KD_UPDATER_FILE_DOWNLOADER_H
@@ -32,7 +51,6 @@
namespace KDUpdater {
-class HashVerificationJob;
class FileDownloaderProxyFactory;
class KDTOOLS_EXPORT FileDownloader : public QObject
@@ -79,6 +97,9 @@ public:
QAuthenticator authenticator() const;
void setAuthenticator(const QAuthenticator &authenticator);
+ bool ignoreSslErrors();
+ void setIgnoreSslErrors(bool ignore);
+
public Q_SLOTS:
virtual void cancelDownload();
@@ -122,6 +143,7 @@ protected:
void addCheckSumData(const QByteArray &data);
void addCheckSumData(const char *data, int length);
+ void resetCheckSumData();
private Q_SLOTS:
virtual void doDownload() = 0;
diff --git a/src/libs/kdtools/kdupdaterfiledownloader_p.h b/src/libs/kdtools/kdupdaterfiledownloader_p.h
index 8c540d6af..c5019cae6 100644
--- a/src/libs/kdtools/kdupdaterfiledownloader_p.h
+++ b/src/libs/kdtools/kdupdaterfiledownloader_p.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_FILE_DOWNLOADER_P_H
#define KD_UPDATER_FILE_DOWNLOADER_P_H
diff --git a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp
index 14f9ecee1..7f6e72efb 100644
--- a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp
+++ b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterfiledownloaderfactory.h"
#include "kdupdaterfiledownloader_p.h"
@@ -46,6 +65,7 @@ struct FileDownloaderFactory::FileDownloaderFactoryData
~FileDownloaderFactoryData() { delete m_factory; }
bool m_followRedirects;
+ bool m_ignoreSslErrors;
FileDownloaderProxyFactory *m_factory;
};
@@ -71,6 +91,8 @@ FileDownloaderFactory::FileDownloaderFactory()
// TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL
if (QSslSocket::supportsSsl())
registerFileDownloader<HttpDownloader>(QLatin1String("https"));
+ else
+ qWarning() << "Could not register file downloader for https protocol: QSslSocket::supportsSsl() returns false";
#endif
d->m_followRedirects = false;
@@ -92,6 +114,16 @@ void FileDownloaderFactory::setProxyFactory(FileDownloaderProxyFactory *factory)
FileDownloaderFactory::instance().d->m_factory = factory;
}
+bool FileDownloaderFactory::ignoreSslErrors()
+{
+ return FileDownloaderFactory::instance().d->m_ignoreSslErrors;
+}
+
+void FileDownloaderFactory::setIgnoreSslErrors(bool ignore)
+{
+ FileDownloaderFactory::instance().d->m_ignoreSslErrors = ignore;
+}
+
FileDownloaderFactory::~FileDownloaderFactory()
{
delete d;
@@ -109,6 +141,7 @@ FileDownloader *FileDownloaderFactory::create(const QString &scheme, QObject *pa
downloader->setParent(parent);
downloader->setScheme(scheme);
downloader->setFollowRedirects(d->m_followRedirects);
+ downloader->setIgnoreSslErrors(d->m_ignoreSslErrors);
if (d->m_factory)
downloader->setProxyFactory(d->m_factory->clone());
}
diff --git a/src/libs/kdtools/kdupdaterfiledownloaderfactory.h b/src/libs/kdtools/kdupdaterfiledownloaderfactory.h
index e27cb6f7e..a4338e3ce 100644
--- a/src/libs/kdtools/kdupdaterfiledownloaderfactory.h
+++ b/src/libs/kdtools/kdupdaterfiledownloaderfactory.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_FILE_DOWNLOADER_FACTORY_H
#define KD_UPDATER_FILE_DOWNLOADER_FACTORY_H
@@ -66,6 +85,9 @@ public:
static void setProxyFactory(FileDownloaderProxyFactory *factory);
+ static bool ignoreSslErrors();
+ static void setIgnoreSslErrors(bool ignore);
+
private:
FileDownloaderFactory();
diff --git a/src/libs/kdtools/kdupdaterpackagesinfo.cpp b/src/libs/kdtools/kdupdaterpackagesinfo.cpp
index 9ac2b8eac..80c96dc5a 100644
--- a/src/libs/kdtools/kdupdaterpackagesinfo.cpp
+++ b/src/libs/kdtools/kdupdaterpackagesinfo.cpp
@@ -1,26 +1,46 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "kdupdaterpackagesinfo.h"
-#include "kdupdaterapplication.h"
+#include "globals.h"
#include <QFileInfo>
#include <QtXml/QDomDocument>
@@ -65,7 +85,7 @@ using namespace KDUpdater;
*/
/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::InvalidXmlError
- * The source file contains invalid XML.
+ * The source file contains invalid XML.
*/
/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::InvalidContentError
@@ -75,18 +95,14 @@ using namespace KDUpdater;
struct PackagesInfo::PackagesInfoData
{
PackagesInfoData() :
- application(0),
error(PackagesInfo::NotYetReadError),
- compatLevel(-1),
modified(false)
{}
- Application *application;
QString errorMessage;
PackagesInfo::Error error;
QString fileName;
QString applicationName;
QString applicationVersion;
- int compatLevel;
bool modified;
QVector<PackageInfo> packageInfoList;
@@ -104,11 +120,10 @@ void PackagesInfo::PackagesInfoData::setInvalidContentError(const QString &detai
/*!
\internal
*/
-PackagesInfo::PackagesInfo(Application *application)
- : QObject(application),
+PackagesInfo::PackagesInfo(QObject *parent)
+ : QObject(parent),
d(new PackagesInfoData())
{
- d->application = application;
}
/*!
@@ -121,15 +136,6 @@ PackagesInfo::~PackagesInfo()
}
/*!
- Returns a pointer to the application, whose package information this class provides
- access to.
-*/
-Application *PackagesInfo::application() const
-{
- return d->application;
-}
-
-/*!
Returns true if the PackagesInfo are valid else false is returned in which case
the \a errorString() method can be used to receive a describing error message.
*/
@@ -233,14 +239,6 @@ PackageInfo PackagesInfo::packageInfo(int index) const
}
/*!
- Returns the compat level of the application.
-*/
-int PackagesInfo::compatLevel() const
-{
- return d->compatLevel;
-}
-
-/*!
This function returns the index of the package whose name is \c pkgName. If no such
package was found, this function returns -1.
*/
@@ -276,7 +274,7 @@ void PackagesInfo::refresh()
d->modified = false;
QFile file(d->fileName);
-
+
// if the file does not exist then we just skip the reading
if (!file.exists()) {
d->error = NotYetReadError;
@@ -331,8 +329,6 @@ void PackagesInfo::refresh()
d->applicationVersion = childNodeE.text();
else if (childNodeE.tagName() == QLatin1String("Package"))
d->addPackageFrom(childNodeE);
- else if (childNodeE.tagName() == QLatin1String("CompatLevel"))
- d->compatLevel = childNodeE.text().toInt();
}
d->error = NoError;
@@ -341,15 +337,6 @@ void PackagesInfo::refresh()
}
/*!
- Sets the application compat level.
-*/
-void PackagesInfo::setCompatLevel(int level)
-{
- d->compatLevel = level;
- d->modified = true;
-}
-
-/*!
Marks the package with \a name as installed in \a version.
*/
bool PackagesInfo::installPackage(const QString &name, const QString &version,
@@ -433,8 +420,6 @@ void PackagesInfo::writeToDisk()
addTextChildHelper(&root, QLatin1String("ApplicationName"), d->applicationName);
addTextChildHelper(&root, QLatin1String("ApplicationVersion"), d->applicationVersion);
- if (d->compatLevel != -1)
- addTextChildHelper(&root, QLatin1String( "CompatLevel" ), QString::number(d->compatLevel));
Q_FOREACH (const PackageInfo &info, d->packageInfoList) {
QDomElement package = doc.createElement(QLatin1String("Package"));
@@ -511,9 +496,10 @@ void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement &packageE)
info.virtualComp = childNodeE.text().toLower() == QLatin1String("true") ? true : false;
else if (childNodeE.tagName() == QLatin1String("Size"))
info.uncompressedSize = childNodeE.text().toULongLong();
- else if (childNodeE.tagName() == QLatin1String("Dependencies"))
- info.dependencies = childNodeE.text().split(scCommaRegExp, QString::SkipEmptyParts);
- else if (childNodeE.tagName() == QLatin1String("ForcedInstallation"))
+ else if (childNodeE.tagName() == QLatin1String("Dependencies")) {
+ info.dependencies = childNodeE.text().split(QInstaller::commaRegExp(),
+ QString::SkipEmptyParts);
+ } else if (childNodeE.tagName() == QLatin1String("ForcedInstallation"))
info.forcedInstallation = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
else if (childNodeE.tagName() == QLatin1String("LastUpdateDate"))
info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
diff --git a/src/libs/kdtools/kdupdaterpackagesinfo.h b/src/libs/kdtools/kdupdaterpackagesinfo.h
index a70a70568..1fe19aa18 100644
--- a/src/libs/kdtools/kdupdaterpackagesinfo.h
+++ b/src/libs/kdtools/kdupdaterpackagesinfo.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_PACKAGES_INFO_H
#define KD_UPDATER_PACKAGES_INFO_H
@@ -33,9 +52,6 @@
namespace KDUpdater {
-class Application;
-class UpdateInstaller;
-
struct KDTOOLS_EXPORT PackageInfo
{
QString name;
@@ -69,8 +85,6 @@ public:
InvalidContentError
};
- Application *application() const;
-
bool isValid() const;
QString errorString() const;
Error error() const;
@@ -91,9 +105,6 @@ public:
QVector<KDUpdater::PackageInfo> packageInfos() const;
void writeToDisk();
- int compatLevel() const;
- void setCompatLevel(int level);
-
bool installPackage(const QString &pkgName, const QString &version, const QString &title = QString(),
const QString &description = QString(), const QStringList &dependencies = QStringList(),
bool forcedInstallation = false, bool virtualComp = false, quint64 uncompressedSize = 0,
@@ -109,11 +120,10 @@ Q_SIGNALS:
void reset();
protected:
- explicit PackagesInfo(Application *application = 0);
+ friend class Application;
+ explicit PackagesInfo(QObject *parent = 0);
private:
- friend class Application;
- friend class UpdateInstaller;
struct PackagesInfoData;
PackagesInfoData *d;
};
diff --git a/src/libs/kdtools/kdupdatersignatureverificationrunnable.cpp b/src/libs/kdtools/kdupdatersignatureverificationrunnable.cpp
deleted file mode 100644
index 1e00ca43f..000000000
--- a/src/libs/kdtools/kdupdatersignatureverificationrunnable.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#include "kdupdatersignatureverificationrunnable.h"
-#include "kdupdatersignatureverifier.h"
-#include "kdupdatersignatureverificationresult.h"
-
-#include <QByteArray>
-#include <QIODevice>
-#include <QMetaObject>
-#include <QObject>
-#include <QPointer>
-#include <QThreadPool>
-#include <QVariant>
-#include <QVector>
-
-#include <cassert>
-
-using namespace KDUpdater;
-
-class Runnable::Private {
-public:
- QVector<QObject*> receivers;
- QVector<QByteArray> methods;
-};
-
-Runnable::Runnable() : QRunnable(), d( new Private ) {
-}
-
-Runnable::~Runnable() {
- delete d;
-}
-
-
-void Runnable::addResultListener( QObject* receiver, const char* method ) {
- d->receivers.push_back( receiver );
- d->methods.push_back( QByteArray( method ) );
-}
-
-void Runnable::emitResult( const QGenericArgument& arg0,
- const QGenericArgument& arg1,
- const QGenericArgument& arg2,
- const QGenericArgument& arg3,
- const QGenericArgument& arg4,
- const QGenericArgument& arg5,
- const QGenericArgument& arg6,
- const QGenericArgument& arg7,
- const QGenericArgument& arg8,
- const QGenericArgument& arg9 ) {
- assert( d->receivers.size() == d->methods.size() );
- for ( int i = 0; i < d->receivers.size(); ++i ) {
- QMetaObject::invokeMethod( d->receivers[i],
- d->methods[i].constData(),
- Qt::QueuedConnection,
- arg0,
- arg1,
- arg2,
- arg3,
- arg4,
- arg5,
- arg6,
- arg7,
- arg8,
- arg9 );
- }
-}
-
-class SignatureVerificationRunnable::Private {
-public:
- Private() : verifier( 0 ) {}
- const SignatureVerifier* verifier;
- QPointer<QIODevice> device;
- QByteArray signature;
-};
-
-SignatureVerificationRunnable::SignatureVerificationRunnable() : Runnable(), d( new Private ) {
-}
-
-SignatureVerificationRunnable::~SignatureVerificationRunnable() {
- delete d;
-}
-
-const SignatureVerifier* SignatureVerificationRunnable::verifier() const {
- return d->verifier;
-}
-
-void SignatureVerificationRunnable::setVerifier( const SignatureVerifier* verifier ) {
- delete d->verifier;
- d->verifier = verifier ? verifier->clone() : 0;
-}
-
-QByteArray SignatureVerificationRunnable::signature() const {
- return d->signature;
-}
-
-void SignatureVerificationRunnable::setSignature( const QByteArray& sig ) {
- d->signature = sig;
-}
-
-QIODevice* SignatureVerificationRunnable::data() const {
- return d->device;
-}
-
-void SignatureVerificationRunnable::setData( QIODevice* device ) {
- d->device = device;
-}
-
-
-void SignatureVerificationRunnable::run() {
- QThreadPool::globalInstance()->releaseThread();
- const SignatureVerificationResult result = d->verifier->verify( d->device->readAll(), d->signature );
- QThreadPool::globalInstance()->reserveThread();
- delete d->verifier;
- delete d->device;
- emitResult( Q_ARG( KDUpdater::SignatureVerificationResult, result ) );
-}
-
-
diff --git a/src/libs/kdtools/kdupdatersignatureverificationrunnable.h b/src/libs/kdtools/kdupdatersignatureverificationrunnable.h
deleted file mode 100644
index 901689253..000000000
--- a/src/libs/kdtools/kdupdatersignatureverificationrunnable.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#ifndef KDUPDATERSIGNATUREVERIFICATIONJOB_H
-#define KDUPDATERSIGNATUREVERIFICATIONJOB_H
-
-#include <kdtoolsglobal.h>
-
-#include <QtCore/QGenericArgument>
-#include <QtCore/QRunnable>
-
-QT_BEGIN_NAMESPACE
-class QByteArray;
-class QIODevice;
-class QObject;
-template <typename T> class QVector;
-QT_END_NAMESPACE
-
-namespace KDUpdater {
-
-class SignatureVerifier;
-class SignatureVerificationResult;
-
-class Runnable : public QRunnable
-{
-public:
- Runnable();
- ~Runnable();
-
- void addResultListener(QObject *receiver, const char *method);
-
-protected:
- void emitResult(const QGenericArgument &arg0 = QGenericArgument(0),
- const QGenericArgument &arg1 = QGenericArgument(),
- const QGenericArgument &arg2 = QGenericArgument(),
- const QGenericArgument &arg3 = QGenericArgument(),
- const QGenericArgument &arg4 = QGenericArgument(),
- const QGenericArgument &arg5 = QGenericArgument(),
- const QGenericArgument &arg6 = QGenericArgument(),
- const QGenericArgument &arg7 = QGenericArgument(),
- const QGenericArgument &arg8 = QGenericArgument(),
- const QGenericArgument &arg9 = QGenericArgument());
-
-private:
- class Private;
- Private *d;
-};
-
-class SignatureVerificationRunnable : public Runnable
-{
-public:
- explicit SignatureVerificationRunnable();
- ~SignatureVerificationRunnable();
-
- const SignatureVerifier *verifier() const;
- void setVerifier(const SignatureVerifier *verifier);
-
- QByteArray signature() const;
- void setSignature(const QByteArray &sig);
-
- QIODevice *data() const;
- void setData(QIODevice *device);
-
- void run();
-
-private:
- class Private;
- Private *d;
-};
-
-} // namespace KDUpdater
-
-#endif // KDUPDATERSIGNATUREVERIFICATIONJOB_H
diff --git a/src/libs/kdtools/kdupdatertask.cpp b/src/libs/kdtools/kdupdatertask.cpp
index fb8118fbd..187bcdae7 100644
--- a/src/libs/kdtools/kdupdatertask.cpp
+++ b/src/libs/kdtools/kdupdatertask.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdatertask.h"
diff --git a/src/libs/kdtools/kdupdatertask.h b/src/libs/kdtools/kdupdatertask.h
index 4b2b2e4f5..3b1f86129 100644
--- a/src/libs/kdtools/kdupdatertask.h
+++ b/src/libs/kdtools/kdupdatertask.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_TASK_H
#define KD_UPDATER_TASK_H
diff --git a/src/libs/kdtools/kdupdaterupdate.cpp b/src/libs/kdtools/kdupdaterupdate.cpp
index 0ae2ebfaf..c6b0775e8 100644
--- a/src/libs/kdtools/kdupdaterupdate.cpp
+++ b/src/libs/kdtools/kdupdaterupdate.cpp
@@ -1,34 +1,45 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdate.h"
-#include "kdupdaterapplication.h"
-#include "kdupdaterupdatesourcesinfo.h"
-#include "kdupdaterfiledownloader_p.h"
-#include "kdupdaterfiledownloaderfactory.h"
-#include "kdupdaterupdateoperations.h"
-#include "kdupdaterupdateoperationfactory.h"
-
-#include <QFile>
using namespace KDUpdater;
@@ -37,124 +48,22 @@ using namespace KDUpdater;
\class KDUpdater::Update kdupdaterupdate.h KDUpdaterUpdate
\brief Represents a single update
- The KDUpdater::Update class contains information and mechanisms to download one update. It is
- created by KDUpdater::UpdateFinder and is used by KDUpdater::UpdateInstaller to download the UpdateFile
+ The KDUpdater::Update class contains information about an update. It is created by KDUpdater::UpdateFinder
corresponding to the update.
- The class makes use of appropriate network protocols (HTTP, HTTPS, FTP, or Local File Copy) to
- download the UpdateFile.
-
The constructor of the KDUpdater::Update class is made protected, because it can be instantiated only by
KDUpdater::UpdateFinder (which is a friend class). The destructor however is public.
*/
-struct Update::UpdateData
-{
- UpdateData(Update *qq) :
- q(qq),
- application(0),
- compressedSize(0),
- uncompressedSize(0)
- {}
-
- Update *q;
- Application *application;
- UpdateSourceInfo sourceInfo;
- QHash<QString, QVariant> data;
- QUrl updateUrl;
- UpdateType type;
- QList<UpdateOperation *> operations;
- QByteArray sha1sum;
-
- quint64 compressedSize;
- quint64 uncompressedSize;
-
- FileDownloader *fileDownloader;
-};
-
/*!
\internal
*/
-Update::Update(Application *application, const UpdateSourceInfo &sourceInfo,
- UpdateType type, const QUrl &updateUrl, const QHash<QString, QVariant> &data,
- quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum)
- : Task(QLatin1String("Update"), Stoppable, application),
- d(new UpdateData(this))
-{
- d->application = application;
- d->sourceInfo = sourceInfo;
- d->data = data;
- d->updateUrl = updateUrl;
- d->type = type;
-
- d->compressedSize = compressedSize;
- d->uncompressedSize = uncompressedSize;
- d->sha1sum = sha1sum;
-
- d->fileDownloader = FileDownloaderFactory::instance().create(updateUrl.scheme(), this);
- if (d->fileDownloader) {
- d->fileDownloader->setUrl(d->updateUrl);
- d->fileDownloader->setAssumedSha1Sum(d->sha1sum);
- connect(d->fileDownloader, SIGNAL(downloadProgress(double)), this, SLOT(downloadProgress(double)));
- connect(d->fileDownloader, SIGNAL(downloadCanceled()), this, SIGNAL(stopped()));
- connect(d->fileDownloader, SIGNAL(downloadCompleted()), this, SIGNAL(finished()));
- }
-
- switch (type) {
- case NewPackage:
- case PackageUpdate: {
- UpdateOperation *packageOperation = UpdateOperationFactory::instance().create(QLatin1String("UpdatePackage"));
- QStringList args;
- args << data.value(QLatin1String("Name")).toString()
- << data.value(QLatin1String("Version")).toString()
- << data.value(QLatin1String("ReleaseDate")).toString();
- packageOperation->setArguments(args);
- packageOperation->setApplication(application);
- d->operations.append(packageOperation);
- break;
- }
- case CompatUpdate: {
- UpdateOperation *compatOperation = UpdateOperationFactory::instance().create(QLatin1String("UpdateCompatLevel"));
- QStringList args;
- args << data.value(QLatin1String("CompatLevel")).toString();
- compatOperation->setArguments(args);
- compatOperation->setApplication(application);
- d->operations.append(compatOperation);
- break;
- }
- default:
- break;
- }
-}
-
-/*!
- Destructor
-*/
-Update::~Update()
-{
- const QString fileName = this->downloadedFileName();
- if (!fileName.isEmpty())
- QFile::remove(fileName);
- qDeleteAll(d->operations);
- d->operations.clear();
- delete d;
-}
-
-/*!
- Returns the application for which this class is downloading the UpdateFile
-*/
-Application *Update::application() const
-{
- return d->application;
-}
-
-/*!
- Returns the release date of the update downloaded by this class
-*/
-QDate Update::releaseDate() const
+Update::Update(int priority, const QUrl &sourceInfoUrl, const QHash<QString, QVariant> &data)
+ : m_priority(priority)
+ , m_sourceInfoUrl(sourceInfoUrl)
+ , m_data(data)
{
- return d->data.value(QLatin1String("ReleaseDate")).toDate();
}
/*!
@@ -162,150 +71,15 @@ QDate Update::releaseDate() const
*/
QVariant Update::data(const QString &name, const QVariant &defaultValue) const
{
- if (d->data.contains(name))
- return d->data.value(name);
- return defaultValue;
-}
-
-/*!
- Returns the complete URL of the UpdateFile downloaded by this class.
-*/
-QUrl Update::updateUrl() const
-{
- return d->updateUrl;
-}
-
-/*!
- Returns the update source info on which this update was created.
-*/
-UpdateSourceInfo Update::sourceInfo() const
-{
- return d->sourceInfo;
-}
-
-/*!
- * Returns the type of update
- */
-UpdateType Update::type() const
-{
- return d->type;
-}
-
-/*!
- Returns true of the update can be downloaded, false otherwise. The function
- returns false if the URL scheme is not supported by this class.
-*/
-bool Update::canDownload() const
-{
- return d->fileDownloader && d->fileDownloader->canDownload();
-}
-
-/*!
- Returns true of the update has been downloaded. If this function returns true
- the you can use the \ref downloadedFileName() method to get the complete name
- of the downloaded UpdateFile.
-
- \note: The downloaded UpdateFile will be deleted when this class is destroyed
-*/
-bool Update::isDownloaded() const
-{
- return d->fileDownloader && d->fileDownloader->isDownloaded();
-}
-
-/*!
- Returns the name of the downloaded UpdateFile after the download is complete, ie
- when \ref isDownloaded() returns true.
-*/
-QString Update::downloadedFileName() const
-{
- if (d->fileDownloader)
- return d->fileDownloader->downloadedFileName();
-
- return QString();
-}
-
-/*!
- \internal
-*/
-void Update::downloadProgress(double value)
-{
- Q_ASSERT(value <= 1);
- reportProgress(value * 100, tr("Downloading update..."));
+ return m_data.value(name, defaultValue);
}
-/*!
- \internal
-*/
-void Update::downloadCompleted()
+int Update::priority() const
{
- reportProgress(100, tr("Update downloaded"));
- reportDone();
+ return m_priority;
}
-/*!
- \internal
-*/
-void Update::downloadAborted(const QString &msg)
-{
- reportError(msg);
-}
-
-/*!
- \internal
-*/
-void Update::doRun()
-{
- if (d->fileDownloader)
- d->fileDownloader->download();
-}
-
-/*!
- \internal
-*/
-bool Update::doStop()
-{
- if (d->fileDownloader)
- d->fileDownloader->cancelDownload();
- return true;
-}
-
-/*!
- \internal
-*/
-bool Update::doPause()
-{
- return false;
-}
-
-/*!
- \internal
-*/
-bool Update::doResume()
-{
- return false;
-}
-
-/*!
- Returns a list of operations needed by this update. For example, package update needs to change
- the package version, compat update needs to change the compat level...
- */
-QList<UpdateOperation *> Update::operations() const
-{
- return d->operations;
-}
-
-/*!
- * Returns the compressed size of this update's data file.
- */
-quint64 Update::compressedSize() const
-{
- return d->compressedSize;
-}
-
-/*!
- * Returns the uncompressed size of this update's data file.
- */
-quint64 Update::uncompressedSize() const
+QUrl Update::sourceInfoUrl() const
{
- return d->uncompressedSize;
+ return m_sourceInfoUrl;
}
diff --git a/src/libs/kdtools/kdupdaterupdate.h b/src/libs/kdtools/kdupdaterupdate.h
index 17250a71e..ec9c56d24 100644
--- a/src/libs/kdtools/kdupdaterupdate.h
+++ b/src/libs/kdtools/kdupdaterupdate.h
@@ -1,87 +1,69 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_H
#define KD_UPDATER_UPDATE_H
-#include "kdupdater.h"
-#include "kdupdatertask.h"
-
-#include <QUrl>
-#include <QDate>
#include <QHash>
+#include <QUrl>
#include <QVariant>
-#include <QList>
namespace KDUpdater {
-class Application;
-struct UpdateSourceInfo;
-class UpdateFinder;
-class UpdateOperation;
-
-class KDTOOLS_EXPORT Update : public Task
+class Update
{
- Q_OBJECT
-
public:
- ~Update();
+ QVariant data(const QString &name, const QVariant &defaultValue = QVariant()) const;
- Application *application() const;
-
- UpdateType type() const;
- QUrl updateUrl() const;
- QDate releaseDate() const;
- QVariant data(const QString &m_name, const QVariant &defaultValue = QVariant()) const;
- UpdateSourceInfo sourceInfo() const;
-
- bool canDownload() const;
- bool isDownloaded() const;
- void download() { run(); }
- QString downloadedFileName() const;
-
- QList<UpdateOperation *> operations() const;
-
- quint64 compressedSize() const;
- quint64 uncompressedSize() const;
-
-private Q_SLOTS:
- void downloadProgress(double);
- void downloadAborted(const QString &msg);
- void downloadCompleted();
+ int priority() const;
+ QUrl sourceInfoUrl() const;
private:
friend class UpdateFinder;
- struct UpdateData;
- UpdateData *d;
-
- void doRun();
- bool doStop();
- bool doPause();
- bool doResume();
+ Update(int p, const QUrl &sourceInfoUrl, const QHash<QString, QVariant> &data);
- Update(Application *application, const UpdateSourceInfo &sourceInfo,
- UpdateType type, const QUrl &updateUrl, const QHash<QString, QVariant> &data,
- quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum);
+private:
+ int m_priority;
+ QUrl m_sourceInfoUrl;
+ QHash<QString, QVariant> m_data;
};
} // namespace KDUpdater
diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp
index caa66982e..f37fa9244 100644
--- a/src/libs/kdtools/kdupdaterupdatefinder.cpp
+++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp
@@ -1,36 +1,56 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdatefinder.h"
#include "kdupdaterapplication.h"
#include "kdupdaterupdatesourcesinfo.h"
#include "kdupdaterpackagesinfo.h"
#include "kdupdaterupdate.h"
-#include "kdupdaterfiledownloader_p.h"
+#include "kdupdaterfiledownloader.h"
#include "kdupdaterfiledownloaderfactory.h"
#include "kdupdaterupdatesinfo_p.h"
+#include "globals.h"
+
#include <QCoreApplication>
-#include <QDebug>
using namespace KDUpdater;
@@ -80,11 +100,8 @@ using namespace KDUpdater;
class UpdateFinder::Private
{
public:
- Private(UpdateFinder *qq) :
- q(qq),
- application(0),
- updateType(PackageUpdate)
- {}
+ Private(UpdateFinder *qq)
+ : q(qq), application(0) {}
~Private()
{
@@ -92,11 +109,10 @@ public:
qDeleteAll(updatesInfoList);
qDeleteAll(updateXmlFDList);
}
-
+
UpdateFinder *q;
Application *application;
QList<Update *> updates;
- UpdateTypes updateType;
// Temporary structure that notes down information about updates.
bool cancel;
@@ -111,12 +127,9 @@ public:
bool downloadUpdateXMLFiles();
bool computeApplicableUpdates();
- QList<UpdateInfo> applicableUpdates(UpdatesInfo *updatesInfo,
- bool addNewPackages = false);
- void createUpdateObjects(const UpdateSourceInfo &sourceInfo,
- const QList<UpdateInfo> &updateInfoList);
- bool checkForUpdatePriority(const UpdateSourceInfo &sourceInfo,
- const UpdateInfo &updateInfo);
+ QList<UpdateInfo> applicableUpdates(UpdatesInfo *updatesInfo);
+ void createUpdateObjects(const UpdateSourceInfo &sourceInfo, const QList<UpdateInfo> &updateInfoList);
+ bool checkForUpdatePriority(const UpdateSourceInfo &sourceInfo, const UpdateInfo &updateInfo);
void slotDownloadDone();
};
@@ -174,8 +187,8 @@ void UpdateFinder::Private::computeUpdates()
// 1. Downloading Update XML files from all the update sources
// 2. Matching updates with Package XML and figuring out available updates
- cancel = false;
clear();
+ cancel = false;
// First do some quick sanity checks on the packages info
PackagesInfo *packages = application->packagesInfo();
@@ -257,8 +270,8 @@ bool UpdateFinder::Private::downloadUpdateXMLFiles()
// Create FileDownloader and UpdatesInfo for each update
for (int i = 0; i < updateSources->updateSourceInfoCount(); i++) {
- UpdateSourceInfo info = updateSources->updateSourceInfo(i);
- QUrl updateXmlUrl = QString::fromLatin1("%1/Updates.xml").arg(info.url.toString());
+ const UpdateSourceInfo info = updateSources->updateSourceInfo(i);
+ const QUrl updateXmlUrl = QString::fromLatin1("%1/Updates.xml").arg(info.url.toString());
FileDownloader *downloader = FileDownloaderFactory::instance().create(updateXmlUrl.scheme(), q);
if (!downloader)
@@ -267,82 +280,49 @@ bool UpdateFinder::Private::downloadUpdateXMLFiles()
downloader->setUrl(updateXmlUrl);
downloader->setAutoRemoveDownloadedFile(true);
- UpdatesInfo *updatesInfo = new UpdatesInfo;
updateSourceInfoList.append(info);
updateXmlFDList.append(downloader);
- updatesInfoList.append(updatesInfo);
-
- connect(downloader, SIGNAL(downloadCompleted()),
- q, SLOT(slotDownloadDone()));
- connect(downloader, SIGNAL(downloadCanceled()),
- q, SLOT(slotDownloadDone()));
- connect(downloader, SIGNAL(downloadAborted(QString)),
- q, SLOT(slotDownloadDone()));
+ updatesInfoList.append(new UpdatesInfo);
+
+ connect(downloader, SIGNAL(downloadCompleted()), q, SLOT(slotDownloadDone()));
+ connect(downloader, SIGNAL(downloadCanceled()), q, SLOT(slotDownloadDone()));
+ connect(downloader, SIGNAL(downloadAborted(QString)), q, SLOT(slotDownloadDone()));
}
// Trigger download of Updates.xml file
downloadCompleteCount = 0;
- for (int i = 0; i < updateXmlFDList.count(); i++) {
- FileDownloader *downloader = updateXmlFDList.at(i);
+ foreach (FileDownloader *const downloader, updateXmlFDList)
downloader->download();
- }
// Wait until all downloaders have completed their downloads.
while (true) {
QCoreApplication::processEvents();
if (cancel)
return false;
+
if (downloadCompleteCount == updateXmlFDList.count())
break;
- int pc = computePercent(downloadCompleteCount, updateXmlFDList.count());
- q->reportProgress(pc, tr("Downloading Updates.xml from update sources."));
+ q->reportProgress(computePercent(downloadCompleteCount, updateXmlFDList.count()),
+ tr("Downloading Updates.xml from update sources."));
}
- // All the downloaders have now either downloaded or aborted the
- // download of update XML files.
-
- // Let's now get rid of update sources whose Updates.xml could not be downloaded
- for (int i = 0; i < updateXmlFDList.count(); i++) {
- FileDownloader *downloader = updateXmlFDList.at(i);
- if (downloader->isDownloaded())
- continue;
-
- UpdateSourceInfo info = updateSourceInfoList.at(i);
- QString msg = tr("Could not download updates from %1 ('%2')").arg(info.name, info.url.toString());
- q->reportError(msg);
-
- delete updatesInfoList[i];
- delete downloader;
- updateXmlFDList.removeAt(i);
- updatesInfoList.removeAt(i);
- updateSourceInfoList.removeAt(i);
- --i;
- }
-
- if (updatesInfoList.isEmpty())
- return false;
-
- // Lets parse the downloaded update XML files and get rid of the downloaders.
- for (int i = 0; i < updateXmlFDList.count(); i++) {
- FileDownloader *downloader = updateXmlFDList.at(i);
- UpdatesInfo *updatesInfo = updatesInfoList.at(i);
-
- updatesInfo->setFileName(downloader->downloadedFileName());
-
- if (!updatesInfo->isValid()) {
- QString msg = updatesInfo->errorString();
- q->reportError(msg);
-
- delete updatesInfoList[i];
- delete downloader;
- updateXmlFDList.removeAt(i);
- updatesInfoList.removeAt(i);
- --i;
+ for (int i = updateXmlFDList.count() - 1; i >= 0; --i) {
+ UpdatesInfo *const updatesInfo = updatesInfoList.at(i);
+ FileDownloader *const downloader = updateXmlFDList.takeAt(i);
+ if (downloader->isDownloaded()) {
+ updatesInfo->setFileName(downloader->downloadedFileName());
+ if (!updatesInfo->isValid()) {
+ q->reportError(updatesInfo->errorString());
+ delete updatesInfoList.takeAt(i); // updates info
+ }
+ } else {
+ delete updatesInfoList.takeAt(i); // updates info
+ const UpdateSourceInfo info = updateSourceInfoList.takeAt(i);
+ q->reportError(tr("Could not download updates from %1 ('%2')").arg(info.name, info.url.toString()));
}
+ delete downloader;
}
- qDeleteAll(updateXmlFDList);
- updateXmlFDList.clear();
if (updatesInfoList.isEmpty())
return false;
@@ -361,109 +341,43 @@ bool UpdateFinder::Private::downloadUpdateXMLFiles()
*/
bool UpdateFinder::Private::computeApplicableUpdates()
{
- if (updateType & CompatUpdate) {
- UpdateInfo compatUpdateInfo;
- UpdateSourceInfo compatUpdateSourceInfo;
-
- // Required compat level
- int reqCompatLevel = application->compatLevel() + 1;
-
- q->reportProgress(60, tr("Looking for compatibility update..."));
-
- // We are only interested in compat updates.
- for (int i = 0; i < updatesInfoList.count(); i++) {
- UpdatesInfo *info = updatesInfoList.at(i);
- UpdateSourceInfo updateSource = updateSourceInfoList.at(i);
-
- // If we already have a compat update, just check if the source currently being
- // considered has a higher priority or not.
- if (compatUpdateInfo.data.contains(QLatin1String("CompatLevel")) && updateSource.priority < compatUpdateSourceInfo.priority)
- continue;
-
- // Let's look for compat updates that provide compat level one-higher than
- // the application's current compat level.
- QList<UpdateInfo> updatesInfo = info->updatesInfo(CompatUpdate, reqCompatLevel);
-
- if (updatesInfo.count() == 0)
- continue;
-
- compatUpdateInfo = updatesInfo.at(0);
- compatUpdateSourceInfo = updateSource;
- }
-
- bool found = compatUpdateInfo.data.contains(QLatin1String("CompatLevel"));
- if (found) {
- q->reportProgress(80, tr("Found compatibility update."));
-
- if (compatUpdateInfo.updateFiles.isEmpty()) {
- q->reportError(tr("Update not found."));
- q->reportProgress(100, tr("Update not found."));
- return false;
- }
-
- UpdateFileInfo fileInfo = compatUpdateInfo.updateFiles.at(0);
-
- // Create an update for this entry
- QUrl url = QString::fromLatin1("%1/%2").arg( compatUpdateSourceInfo.url.toString(), fileInfo.fileName);
- Update *update = q->constructUpdate(application, compatUpdateSourceInfo, CompatUpdate,
- url, compatUpdateInfo.data, fileInfo.compressedSize,
- fileInfo.uncompressedSize, fileInfo.sha1sum);
-
- // Register the update
- updates.append(update);
+ for (int i = 0; i < updatesInfoList.count(); i++) {
+ // Fetch updates applicable to this application.
+ QList<UpdateInfo> updates = applicableUpdates(updatesInfoList.at(i));
+ if (!updates.count())
+ continue;
- // Done
- q->reportProgress(100, tr("Compatibility update found."));
- } else {
- q->reportProgress(100, tr("No compatibility updates found."));
- }
- }
- if (updateType & PackageUpdate) {
- // We are looking for normal updates, not compat ones.
- for (int i = 0; i < updatesInfoList.count(); i++) {
- // Fetch updates applicable to this application.
- UpdatesInfo *info = updatesInfoList.at(i);
- QList<UpdateInfo> updates = applicableUpdates(info , updateType & NewPackage);
- if (!updates.count())
- continue;
-
- if (cancel)
- return false;
- UpdateSourceInfo updateSource = updateSourceInfoList.at(i);
+ if (cancel)
+ return false;
+ const UpdateSourceInfo updateSource = updateSourceInfoList.at(i);
- // Create Update objects for updates that have a valid
- // UpdateFile
- createUpdateObjects(updateSource, updates);
- if (cancel)
- return false;
+ // Create Update objects for updates that have a valid
+ // UpdateFile
+ createUpdateObjects(updateSource, updates);
+ if (cancel)
+ return false;
- // Report progress
- int pc = computePercent(i, updatesInfoList.count());
- pc = computeProgressPercentage(51, 100, pc);
- q->reportProgress(pc, tr("Computing applicable updates."));
- }
+ // Report progress
+ q->reportProgress(computeProgressPercentage(51, 100, computePercent(i, updatesInfoList.count())),
+ tr("Computing applicable updates."));
}
q->reportProgress(99, tr("Application updates computed."));
return true;
}
-QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesInfo, bool addNewPackages)
+QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesInfo)
{
- QList<UpdateInfo> retList;
-
- if (!updatesInfo || updatesInfo->updateInfoCount( PackageUpdate ) == 0)
- return retList;
+ const QList<UpdateInfo> dummy;
+ if (!updatesInfo || updatesInfo->updateInfoCount() == 0)
+ return dummy;
PackagesInfo *packages = this->application->packagesInfo();
if (!packages)
- return retList;
+ return dummy;
// Check to see if the updates info contains updates for any application
- bool anyApp = updatesInfo->applicationName() == QLatin1String("{AnyApplication}");
- int appNameIndex = -1;
-
- if (!anyApp) {
+ if (updatesInfo->applicationName() != QLatin1String("{AnyApplication}")) {
// updatesInfo->applicationName() describes one application or a series of
// application names separated by commas.
QString appName = updatesInfo->applicationName();
@@ -471,90 +385,28 @@ QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesI
appName = appName.replace(QLatin1String( " ," ), QLatin1String( "," ));
// Catch hold of app names contained updatesInfo->applicationName()
- QStringList apps = appName.split(scCommaRegExp, QString::SkipEmptyParts);
- appNameIndex = apps.indexOf(this->application->applicationName());
-
- // If the application appName isn't one of the app names, then
- // the updates are not applicable.
- if (appNameIndex < 0)
- return retList;
+ // If the application appName isn't one of the app names, then the updates are not applicable.
+ const QStringList apps = appName.split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
+ if (apps.indexOf(this->application->applicationName()) < 0)
+ return dummy;
}
-
- // Check to see if version numbers match. This means that the version
- // number of the update should be greater than the version number of
- // the package that is currently installed.
- QList<UpdateInfo> updateList = updatesInfo->updatesInfo(PackageUpdate);
- for (int i = 0; i < updatesInfo->updateInfoCount(PackageUpdate); i++) {
- UpdateInfo updateInfo = updateList.at(i);
- if (!addNewPackages) {
- int pkgInfoIdx = packages->findPackageInfo( updateInfo.data.value(QLatin1String("Name")).toString());
- if (pkgInfoIdx < 0)
- continue;
-
- PackageInfo pkgInfo = packages->packageInfo(pkgInfoIdx);
-
- // First check to see if the update version is higher than package version
- QString updateVersion = updateInfo.data.value(QLatin1String("Version")).toString();
- QString pkgVersion = pkgInfo.version;
- if (KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0)
- continue;
-
- // It is quite possible that we may have already installed the update.
- // Lets check the last update date of the package and the release date
- // of the update. This way we can compare and figure out if the update
- // has been installed or not.
- QDate pkgDate = pkgInfo.lastUpdateDate;
- QDate updateDate = updateInfo.data.value(QLatin1String("ReleaseDate")).toDate();
- if (pkgDate > updateDate)
- continue;
- }
-
- // Bingo, we found an update :-)
- retList.append(updateInfo);
- }
-
- return retList;
+ return updatesInfo->updatesInfo();
}
-void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceInfo, const QList<UpdateInfo> &updateInfoList)
+void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceInfo,
+ const QList<UpdateInfo> &updateInfoList)
{
- for (int i = 0; i < updateInfoList.count(); i++) {
- UpdateInfo info = updateInfoList.at(i);
- // Compat level checks
- if (info.data.contains(QLatin1String("RequiredCompatLevel")) &&
- info.data.value(QLatin1String("RequiredCompatLevel")).toInt() != application->compatLevel())
- {
- qDebug().nospace() << "Update \"" << info.data.value( QLatin1String( "Name" ) ).toString()
- << "\" at \"" << sourceInfo.name << "\"(\"" << sourceInfo.url.toString()
- << "\") requires a different compat level";
- continue; // Compatibility level mismatch
- }
-
- // If another update of the same name exists, then use the update coming from
- // a higher priority.
+ foreach (const UpdateInfo &info, updateInfoList) {
+ // If another update of the same name exists, then use the update coming from a higher priority.
if (!checkForUpdatePriority(sourceInfo, info)) {
- qDebug().nospace() << "Skipping Update \""
- << info.data.value(QLatin1String("Name")).toString()
- << "\" from \""
- << sourceInfo.name
- << "\"(\""
- << sourceInfo.url.toString()
- << "\") because an update with the same name was found from a higher priority location";
-
+ qDebug().nospace() << "Skipping Update \"" << info.data.value(QLatin1String("Name")).toString()
+ << "\" from \"" << sourceInfo.name << "\"(\"" << sourceInfo.url.toString()
+ << "\") because an update with the same name was found from a higher priority location";
continue;
}
- if (info.updateFiles.isEmpty())
- continue;
-
- UpdateFileInfo fileInfo = info.updateFiles.at(0);
-
- // Create an update for this entry
- QUrl url(QString::fromLatin1("%1/%2").arg( sourceInfo.url.toString(), fileInfo.fileName));
- Update *update = q->constructUpdate(application, sourceInfo, PackageUpdate, url, info.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum);
-
- // Register the update
- this->updates.append(update);
+ // Create and register the update
+ this->updates.append(new Update(sourceInfo.priority, sourceInfo.url, info.data));
}
}
@@ -568,14 +420,14 @@ bool UpdateFinder::Private::checkForUpdatePriority(const UpdateSourceInfo &sourc
// Bingo, update was previously found elsewhere.
// If the existing update comes from a higher priority server, then cool :)
- if (update->sourceInfo().priority > sourceInfo.priority)
+ if (update->priority() > sourceInfo.priority)
return false;
// If the existing update has a higher version number, keep it
- if (KDUpdater::compareVersion(update->data(QLatin1String("Version")).toString(),
- updateInfo.data.value(QLatin1String("Version")).toString()) > 0)
- return false;
-
+ if (KDUpdater::compareVersion(update->data(QLatin1String("Version")).toString(), updateInfo.data
+ .value(QLatin1String("Version")).toString()) > 0) {
+ return false;
+ }
// Otherwise the old update must be deleted.
this->updates.removeAll(update);
delete update;
@@ -610,15 +462,6 @@ UpdateFinder::~UpdateFinder()
}
/*!
- Returns a pointer to the update application for which this function computes all
- the updates.
-*/
-Application *UpdateFinder::application() const
-{
- return d->application;
-}
-
-/*!
Returns a list of KDUpdater::Update objects. The update objects returned in this list
are made children of the \ref KDUpdater::Application object associated with this class.
*/
@@ -628,22 +471,6 @@ QList<Update *> UpdateFinder::updates() const
}
/*!
- Looks only for a certain type of update. By default, only package update
-*/
-void UpdateFinder::setUpdateType(UpdateTypes type)
-{
- d->updateType = type;
-}
-
-/*!
- Returns the type of updates searched
-*/
-UpdateTypes UpdateFinder::updateType() const
-{
- return d->updateType;
-}
-
-/*!
\internal
Implemented from \ref KDUpdater::Task::doStart().
@@ -702,16 +529,6 @@ void UpdateFinder::Private::slotDownloadDone()
q->reportProgress( pc, tr("Downloading Updates.xml from update sources.") );
}
-/*!
- \internal
- */
-Update *UpdateFinder::constructUpdate(Application *application, const UpdateSourceInfo &sourceInfo,
- UpdateType type, const QUrl &updateUrl, const QHash<QString, QVariant> &data,
- quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum )
-{
- return new Update(application, sourceInfo, type, updateUrl, data, compressedSize, uncompressedSize, sha1sum);
-}
-
/*!
\ingroup kdupdater
diff --git a/src/libs/kdtools/kdupdaterupdatefinder.h b/src/libs/kdtools/kdupdaterupdatefinder.h
index 7f5ec1bfb..fc7eaf926 100644
--- a/src/libs/kdtools/kdupdaterupdatefinder.h
+++ b/src/libs/kdtools/kdupdaterupdatefinder.h
@@ -1,70 +1,78 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_FINDER_H
#define KD_UPDATER_UPDATE_FINDER_H
-#include "kdupdater.h"
#include "kdupdatertask.h"
-#include <QList>
#include <QHash>
-
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
+#include <QUrl>
namespace KDUpdater {
class Application;
class Update;
-struct UpdateSourceInfo;
class KDTOOLS_EXPORT UpdateFinder : public Task
{
Q_OBJECT
+ class Private;
public:
explicit UpdateFinder(Application *application);
~UpdateFinder();
- Application *application() const;
QList<Update *> updates() const;
- void setUpdateType(UpdateTypes type);
- UpdateTypes updateType() const;
-
private:
void doRun();
bool doStop();
bool doPause();
bool doResume();
- Update *constructUpdate(Application *application, const UpdateSourceInfo &sourceInfo,
- UpdateType type, const QUrl &updateUrl, const QHash<QString, QVariant> &data,
- quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum);
+ Update *constructUpdate(int priority, const QUrl &sourceInfoUrl, const QHash<QString, QVariant> &data,
+ quint64 compressedSize, quint64 uncompressedSize) const;
private:
- class Private;
Private *d;
Q_PRIVATE_SLOT(d, void slotDownloadDone())
};
diff --git a/src/libs/kdtools/kdupdaterupdateoperation.cpp b/src/libs/kdtools/kdupdaterupdateoperation.cpp
index 40d2e5ada..c1591f467 100644
--- a/src/libs/kdtools/kdupdaterupdateoperation.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperation.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdateoperation.h"
@@ -38,7 +57,7 @@
update operations. Concrete implementations of this class must perform a single update
operation like copy, move, delete etc.
- \note Two seperate threads cannot be using a single instance of KDUpdater::UpdateOperation
+ \note Two separate threads cannot be using a single instance of KDUpdater::UpdateOperation
at the same time.
*/
@@ -63,7 +82,7 @@ using namespace KDUpdater;
Constructor
*/
UpdateOperation::UpdateOperation()
- : m_error(0), m_application(0)
+ : m_error(0)
{}
/*!
@@ -150,15 +169,6 @@ void UpdateOperation::setArguments(const QStringList &args)
}
/*!
- Sets the Application for this operation.
- This may be used by some operations
-*/
-void UpdateOperation::setApplication(Application *application)
-{
- m_application = application;
-}
-
-/*!
Returns the last set function arguments.
*/
QStringList UpdateOperation::arguments() const
@@ -207,7 +217,6 @@ void UpdateOperation::setError(int error, const QString &errorString)
void UpdateOperation::clear()
{
m_arguments.clear();
- m_application = 0;
}
QStringList UpdateOperation::filesForDelayedDeletion() const
@@ -224,7 +233,7 @@ void UpdateOperation::registerForDelayedDeletion(const QStringList &files)
{
m_delayedDeletionFiles << files;
}
-
+
/*!
Tries to delete \a file. If \a file can't be deleted, it gets registered for delayed deletion.
*/
@@ -235,7 +244,7 @@ bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorSt
if (!QFile::exists(file))
return true;
-
+
const QString backup = backupFileName(file);
QFile f(file);
if (!f.rename(backup)) {
@@ -248,14 +257,6 @@ bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorSt
}
/*!
- Returns a pointer to the current Application
-*/
-Application *UpdateOperation::application() const
-{
- return m_application;
-}
-
-/*!
\fn virtual void KDUpdater::UpdateOperation::backup() = 0;
Subclasses must implement this function to backup any data before performing the action.
diff --git a/src/libs/kdtools/kdupdaterupdateoperation.h b/src/libs/kdtools/kdupdaterupdateoperation.h
index 04f1c4858..cac68d2f1 100644
--- a/src/libs/kdtools/kdupdaterupdateoperation.h
+++ b/src/libs/kdtools/kdupdaterupdateoperation.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_OPERATION_H
#define KD_UPDATER_UPDATE_OPERATION_H
@@ -32,8 +51,6 @@
namespace KDUpdater {
-class Application;
-
class KDTOOLS_EXPORT UpdateOperation
{
Q_DECLARE_TR_FUNCTIONS(UpdateOperation)
@@ -57,7 +74,6 @@ public:
void setValue(const QString &name, const QVariant &value);
void setArguments(const QStringList &args);
- void setApplication(Application *application);
QStringList arguments() const;
void clear();
QString errorString() const;
@@ -76,7 +92,6 @@ public:
protected:
void setName(const QString &name);
- Application *application() const;
void setErrorString(const QString &errorString);
void setError(int error, const QString &errorString = QString());
void registerForDelayedDeletion(const QStringList &files);
@@ -87,7 +102,6 @@ private:
QStringList m_arguments;
QString m_errorString;
int m_error;
- Application *m_application;
QVariantMap m_values;
QStringList m_delayedDeletionFiles;
};
diff --git a/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp b/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
index aab8f6c2d..ed5c67a8b 100644
--- a/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdateoperationfactory.h"
#include "kdupdaterupdateoperations.h"
@@ -68,7 +87,4 @@ UpdateOperationFactory::UpdateOperationFactory()
registerUpdateOperation<RmdirOperation>(QLatin1String("Rmdir"));
registerUpdateOperation<AppendFileOperation>(QLatin1String("AppendFile"));
registerUpdateOperation<PrependFileOperation>(QLatin1String("PrependFile"));
- registerUpdateOperation<ExecuteOperation>(QLatin1String("Execute"));
- registerUpdateOperation<UpdatePackageOperation>(QLatin1String("UpdatePackage"));
- registerUpdateOperation<UpdateCompatOperation>(QLatin1String("UpdateCompat"));
}
diff --git a/src/libs/kdtools/kdupdaterupdateoperationfactory.h b/src/libs/kdtools/kdupdaterupdateoperationfactory.h
index c21727f78..b6e433c80 100644
--- a/src/libs/kdtools/kdupdaterupdateoperationfactory.h
+++ b/src/libs/kdtools/kdupdaterupdateoperationfactory.h
@@ -1,24 +1,43 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_OPERATION_FACTORY_H
#define KD_UPDATER_UPDATE_OPERATION_FACTORY_H
diff --git a/src/libs/kdtools/kdupdaterupdateoperations.cpp b/src/libs/kdtools/kdupdaterupdateoperations.cpp
index 835697040..be123fe61 100644
--- a/src/libs/kdtools/kdupdaterupdateoperations.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperations.cpp
@@ -1,49 +1,56 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdateoperations.h"
-#include "kdupdaterapplication.h"
-#include "kdupdaterpackagesinfo.h"
-#include "environment.h"
+#include "errors.h"
+#include "fileutils.h"
-#include <QFile>
#include <QDir>
-#include <QDirIterator>
-#include <QProcess>
+#include <QFile>
#include <QTextStream>
-#include <QDebug>
#include <QTemporaryFile>
-
+#include <QFileInfo>
#include <cerrno>
-#define SUPPORT_DETACHED_PROCESS_EXECUTION
-
-#ifdef SUPPORT_DETACHED_PROCESS_EXECUTION
-#ifdef Q_OS_WIN
-#include <windows.h>
-#endif
-#endif
-
using namespace KDUpdater;
static QString errnoToQString(int error)
@@ -58,33 +65,29 @@ static QString errnoToQString(int error)
#endif
}
-static bool removeDirectory(const QString &path, QString *errorString, bool force = true)
+static bool removeDirectory(const QString &path, QString *errorString, bool force)
{
Q_ASSERT(errorString);
- const QFileInfoList entries = QDir(path).entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden);
- for (QFileInfoList::const_iterator it = entries.constBegin(); it != entries.constEnd(); ++it) {
- if (it->isDir() && !it->isSymLink()) {
- removeDirectory(it->filePath(), errorString, force);
- } else if (force) {
- QFile f(it->filePath());
- if (!f.remove())
- return false;
- }
+
+ QDir dir = path;
+ const QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden);
+ foreach (const QFileInfo &entry, entries) {
+ if (entry.isDir() && (!entry.isSymLink()))
+ removeDirectory(entry.filePath(), errorString, force);
+ else if (force && (!QFile(entry.filePath()).remove()))
+ return false;
}
// even remove some hidden, OS-created files in there
-#if defined Q_OS_MAC
- QFile::remove(path + QLatin1String("/.DS_Store"));
-#elif defined Q_OS_WIN
- QFile::remove(path + QLatin1String("/Thumbs.db"));
-#endif
+ QInstaller::removeSystemGeneratedFiles(path);
errno = 0;
- const bool success = QDir().rmdir(path);
+ const bool success = dir.rmdir(path);
if (errno)
*errorString = errnoToQString(errno);
return success;
}
+
/*
* \internal
* Returns a filename for a temporary file based on \a templateName
@@ -113,67 +116,90 @@ CopyOperation::~CopyOperation()
deleteFileNowOrLater(value(QLatin1String("backupOfExistingDestination")).toString());
}
+QString CopyOperation::sourcePath()
+{
+ return arguments().first();
+}
+
+QString CopyOperation::destinationPath()
+{
+ QString destination = arguments().last();
+
+ // if the target is a directory use the source filename to complete the destination path
+ if (QFileInfo(destination).isDir())
+ destination = QDir(destination).filePath(QFileInfo(sourcePath()).fileName());
+ return destination;
+}
+
+
void CopyOperation::backup()
{
- const QString dest = arguments().last();
- if (!QFile::exists(dest)) {
+ QString destination = destinationPath();
+
+ if (!QFile::exists(destination)) {
clearValue(QLatin1String("backupOfExistingDestination"));
return;
}
- setValue(QLatin1String("backupOfExistingDestination"), backupFileName(dest));
+ setValue(QLatin1String("backupOfExistingDestination"), backupFileName(destination));
- // race condition: The backup file could get created
- // by another process right now. But this is the same
+ // race condition: The backup file could get created by another process right now. But this is the same
// in QFile::copy...
- const bool success = QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString());
- if (!success)
- setError(UserDefinedError, tr("Could not backup file %1.").arg(dest));
+ if (!QFile::rename(destination, value(QLatin1String("backupOfExistingDestination")).toString()))
+ setError(UserDefinedError, tr("Could not backup file %1.").arg(destination));
}
bool CopyOperation::performOperation()
{
- // We need two args to complete the copy operation.
- // First arg provides the complete file name of source
+ // We need two args to complete the copy operation. First arg provides the complete file name of source
// Second arg provides the complete file name of dest
- QStringList args = this->arguments();
- if (args.count() != 2) {
+ if (arguments().count() != 2) {
setError(InvalidArguments);
- setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(arguments().count()));
return false;
}
- QString source = args.first();
- QString dest = args.last();
- // If destination file exists, then we cannot use QFile::copy()
- // because it does not overwrite an existing file. So we remove
- // the destination file.
- if (QFile::exists(dest)) {
- QFile file(dest);
- if (!file.remove()) {
+ QString source = sourcePath();
+ QString destination = destinationPath();
+
+ QFile sourceFile(source);
+ if (!sourceFile.exists()) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not copy a non-existent file: %1").arg(source));
+ return false;
+ }
+ // If destination file exists, we cannot use QFile::copy() because it does not overwrite an existing
+ // file. So we remove the destination file.
+ QFile destinationFile(destination);
+ if (destinationFile.exists()) {
+ if (!destinationFile.remove()) {
setError(UserDefinedError);
- setErrorString(tr("Could not remove destination file %1: %2").arg(dest, file.errorString()));
+ setErrorString(tr("Could not remove destination file %1: %2").arg(destination, destinationFile.errorString()));
return false;
}
}
- QFile file(source);
- const bool copied = file.copy(dest);
+ const bool copied = sourceFile.copy(destination);
if (!copied) {
setError(UserDefinedError);
- setErrorString(tr("Could not copy %1 to %2: %3").arg(source, dest, file.errorString()));
+ setErrorString(tr("Could not copy %1 to %2: %3").arg(source, destination, sourceFile.errorString()));
}
return copied;
}
bool CopyOperation::undoOperation()
{
- const QString dest = arguments().last();
+ QString source = sourcePath();
+ QString destination = destinationPath();
- QFile destF(dest);
+ // if the target is a directory use the source filename to complete the destination path
+ if (QFileInfo(destination).isDir())
+ destination = destination + QDir::separator() + QFileInfo(source).fileName();
+
+ QFile destFile(destination);
// first remove the dest
- if (destF.exists() && !destF.remove()) {
- setError(UserDefinedError, tr("Could not delete file %1: %2").arg(dest, destF.errorString()));
+ if (destFile.exists() && !destFile.remove()) {
+ setError(UserDefinedError, tr("Could not delete file %1: %2").arg(destination, destFile.errorString()));
return false;
}
@@ -182,11 +208,11 @@ bool CopyOperation::undoOperation()
if (!hasValue(QLatin1String("backupOfExistingDestination")))
return true;
- QFile backupF(value(QLatin1String("backupOfExistingDestination")).toString());
+ QFile backupFile(value(QLatin1String("backupOfExistingDestination")).toString());
// otherwise we have to copy the backup back:
- const bool success = backupF.rename(dest);
+ const bool success = backupFile.rename(destination);
if (!success)
- setError(UserDefinedError, tr("Could not restore backup file into %1: %2").arg(dest, backupF.errorString()));
+ setError(UserDefinedError, tr("Could not restore backup file into %1: %2").arg(destination, backupFile.errorString()));
return success;
}
@@ -198,9 +224,9 @@ QDomDocument CopyOperation::toXml() const
// we don't want to save the backupOfExistingDestination
if (!hasValue(QLatin1String("backupOfExistingDestination")))
return UpdateOperation::toXml();
-
+
CopyOperation *const me = const_cast<CopyOperation *>(this);
-
+
const QVariant v = value(QLatin1String("backupOfExistingDestination"));
me->clearValue(QLatin1String("backupOfExistingDestination"));
const QDomDocument xml = UpdateOperation::toXml();
@@ -244,32 +270,26 @@ void MoveOperation::backup()
setValue(QLatin1String("backupOfExistingDestination"), backupFileName(dest));
- // race condition: The backup file could get created
- // by another process right now. But this is the same
+ // race condition: The backup file could get created by another process right now. But this is the same
// in QFile::copy...
- const bool success = QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString());
- if (!success)
+ if (!QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString()))
setError(UserDefinedError, tr("Could not backup file %1.").arg(dest));
}
bool MoveOperation::performOperation()
{
- // We need two args to complete the copy operation.
- // First arg provides the complete file name of source
- // Second arg provides the complete file name of dest
- QStringList args = this->arguments();
+ // We need two args to complete the copy operation. // First arg provides the complete file name of
+ // source, second arg provides the complete file name of dest
+ const QStringList args = this->arguments();
if (args.count() != 2) {
setError(InvalidArguments);
setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
- QString source = args.first();
- QString dest = args.last();
-
- // If destination file exists, then we cannot use QFile::copy()
- // because it does not overwrite an existing file. So we remove
- // the destination file.
+ const QString dest = args.last();
+ // If destination file exists, then we cannot use QFile::copy() because it does not overwrite an existing
+ // file. So we remove the destination file.
if (QFile::exists(dest)) {
QFile file(dest);
if (!file.remove(dest)) {
@@ -280,27 +300,23 @@ bool MoveOperation::performOperation()
}
// Copy source to destination.
- QFile file(source);
- const bool copied = file.copy(source, dest);
- if (!copied) {
+ QFile file(args.first());
+ if (!file.copy(dest)) {
setError(UserDefinedError);
- setErrorString(tr("Could not copy %1 to %2: %3").arg(source, dest, file.errorString()));
+ setErrorString(tr("Could not copy %1 to %2: %3").arg(file.fileName(), dest, file.errorString()));
return false;
}
-
- return deleteFileNowOrLater(source);
+ return deleteFileNowOrLater(file.fileName());
}
bool MoveOperation::undoOperation()
{
const QStringList args = arguments();
- const QString& source = args.first();
- const QString& dest = args.last();
-
+ const QString dest = args.last();
// first: copy back the destination to source
QFile destF(dest);
- if (!destF.copy(source)) {
- setError(UserDefinedError, tr("Cannot copy %1 to %2: %3").arg(dest, source, destF.errorString()));
+ if (!destF.copy(args.first())) {
+ setError(UserDefinedError, tr("Cannot copy %1 to %2: %3").arg(dest, args.first(), destF.errorString()));
return false;
}
@@ -317,7 +333,7 @@ bool MoveOperation::undoOperation()
// otherwise we have to copy the backup back:
QFile backupF(value(QLatin1String("backupOfExistingDestination")).toString());
- const bool success = backupF.rename(dest);
+ const bool success = backupF.rename(dest);
if (!success)
setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(dest, backupF.errorString()));
@@ -354,25 +370,22 @@ void DeleteOperation::backup()
{
const QString fileName = arguments().first();
setValue(QLatin1String("backupOfExistingFile"), backupFileName(fileName));
+
QFile file(fileName);
- const bool success = file.copy(value(QLatin1String("backupOfExistingFile")).toString());
- if (!success)
+ if (!file.copy(value(QLatin1String("backupOfExistingFile")).toString()))
setError(UserDefinedError, tr("Cannot create backup of %1: %2").arg(fileName, file.errorString()));
}
bool DeleteOperation::performOperation()
{
- // Requires only one parameter. That is the name of
- // the file to remove.
- QStringList args = this->arguments();
+ // Requires only one parameter. That is the name of the file to remove.
+ const QStringList args = this->arguments();
if (args.count() != 1) {
setError(InvalidArguments);
setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
-
- const QString fName = args.first();
- return deleteFileNowOrLater(fName);
+ return deleteFileNowOrLater(args.first());
}
bool DeleteOperation::undoOperation()
@@ -385,7 +398,6 @@ bool DeleteOperation::undoOperation()
const bool success = backupF.copy(fileName) && deleteFileNowOrLater(backupF.fileName());
if (!success)
setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(fileName, backupF.errorString()));
-
return success;
}
@@ -408,9 +420,9 @@ QDomDocument DeleteOperation::toXml() const
// we don't want to save the backupOfExistingFile
if (!hasValue(QLatin1String("backupOfExistingFile")))
return UpdateOperation::toXml();
-
+
DeleteOperation *const me = const_cast<DeleteOperation *>(this);
-
+
const QVariant v = value(QLatin1String("backupOfExistingFile"));
me->clearValue(QLatin1String("backupOfExistingFile"));
const QDomDocument xml = UpdateOperation::toXml();
@@ -460,7 +472,8 @@ bool MkdirOperation::performOperation()
setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
- QString dirName = args.first();
+
+ const QString dirName = args.first();
const bool created = QDir::root().mkpath(dirName);
if (!created) {
setError(UserDefinedError);
@@ -520,8 +533,8 @@ MkdirOperation *MkdirOperation::clone() const
RmdirOperation::RmdirOperation()
{
- setValue(QLatin1String("removed"), false);
setName(QLatin1String("Rmdir"));
+ setValue(QLatin1String("removed"), false);
}
void RmdirOperation::backup()
@@ -531,29 +544,27 @@ void RmdirOperation::backup()
bool RmdirOperation::performOperation()
{
- // Requires only one parameter. That is the name of
- // the file to remove.
- QStringList args = this->arguments();
+ // Requires only one parameter. That is the name of the file to remove.
+ const QStringList args = this->arguments();
if (args.count() != 1) {
setError(InvalidArguments);
setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
- QString dirName = args.first();
- QDir dir(dirName);
+ QDir dir(args.first());
if (!dir.exists()) {
setError(UserDefinedError);
- setErrorString(tr("Could not remove folder %1: The folder does not exist.").arg(dirName));
+ setErrorString(tr("Could not remove folder %1: The folder does not exist.").arg(args.first()));
return false;
}
errno = 0;
- const bool removed = dir.rmdir(dirName);
+ const bool removed = dir.rmdir(args.first());
setValue(QLatin1String("removed"), removed);
if (!removed) {
setError(UserDefinedError);
- setErrorString(tr("Could not remove folder %1: %2").arg(dirName, errnoToQString(errno)));
+ setErrorString(tr("Could not remove folder %1: %2").arg(args.first(), errnoToQString(errno)));
}
return removed;
}
@@ -563,8 +574,8 @@ bool RmdirOperation::undoOperation()
if (!value(QLatin1String("removed")).toBool())
return true;
- const QFileInfo fi(arguments().first());
errno = 0;
+ const QFileInfo fi(arguments().first());
const bool success = fi.dir().mkdir(fi.fileName());
if( !success)
setError(UserDefinedError, tr("Cannot recreate directory %1: %2").arg(fi.fileName(), errnoToQString(errno)));
@@ -610,34 +621,46 @@ void AppendFileOperation::backup()
bool AppendFileOperation::performOperation()
{
- // This operation takes two arguments. First argument is the name
- // of the file into which a text has to be appended. Second argument
- // is the text to append.
- QStringList args = this->arguments();
+ // This operation takes two arguments. First argument is the name of the file into which a text has to be
+ // appended. Second argument is the text to append.
+ const QStringList args = this->arguments();
if (args.count() != 2) {
setError(InvalidArguments);
- setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.")
+ .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String("")));
return false;
}
- QString fName = args.first();
- QString text = args.last();
-
+ const QString fName = args.first();
QFile file(fName);
if (!file.open(QFile::Append)) {
// first we rename the file, then we copy it to the real target and open the copy - the renamed original is then marked for deletion
+ bool error = false;
const QString newName = backupFileName(fName);
- if (!QFile::rename(fName, newName) && QFile::copy(newName, fName) && file.open(QFile::Append)) {
+
+ if (!QFile::rename(fName, newName))
+ error = true;
+
+ if (!error && !QFile::copy(newName, fName)) {
+ error = true;
QFile::rename(newName, fName);
+ }
+
+ if (!error && !file.open(QFile::Append)) {
+ error = true;
+ deleteFileNowOrLater(newName);
+ }
+
+ if (error) {
setError(UserDefinedError);
- setErrorString(tr("Could not open file %1 for writing: %2").arg(file.fileName(), file.errorString()));
+ setErrorString(tr("Could not open file '%1' for writing: %2").arg(file.fileName(), file.errorString()));
return false;
}
deleteFileNowOrLater(newName);
}
QTextStream ts(&file);
- ts << text;
+ ts << args.last();
file.close();
return true;
@@ -711,16 +734,14 @@ bool PrependFileOperation::performOperation()
// This operation takes two arguments. First argument is the name
// of the file into which a text has to be appended. Second argument
// is the text to append.
- QStringList args = this->arguments();
+ const QStringList args = this->arguments();
if (args.count() != 2) {
setError(InvalidArguments);
setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
- QString fName = args.first();
- QString text = args.last();
-
+ const QString fName = args.first();
// Load the file first.
QFile file(fName);
if (!file.open(QFile::ReadOnly)) {
@@ -728,11 +749,13 @@ bool PrependFileOperation::performOperation()
setErrorString(tr("Could not open file %1 for reading: %2").arg(file.fileName(), file.errorString()));
return false;
}
+
+ // TODO: fix this, use a text stream
QString fContents(QLatin1String(file.readAll()));
file.close();
// Prepend text to the file text
- fContents = text + fContents;
+ fContents = args.last() + fContents;
// Now re-open the file in write only mode.
if (!file.open(QFile::WriteOnly)) {
@@ -790,278 +813,3 @@ PrependFileOperation *PrependFileOperation::clone() const
{
return new PrependFileOperation;
}
-
-
-////////////////////////////////////////////////////////////////////////////
-// KDUpdater::ExecuteOperation
-////////////////////////////////////////////////////////////////////////////
-
-ExecuteOperation::ExecuteOperation()
- : QObject()
-{
- setName(QLatin1String("Execute"));
-}
-
-void ExecuteOperation::backup()
-{
- // this is not possible, since the process can do whatever...
-}
-
-#if defined(SUPPORT_DETACHED_PROCESS_EXECUTION) && defined(Q_OS_WIN)
-// stolen from qprocess_win.cpp
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
-
- for (int i = 0; i < arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace(QLatin1String("\\\""), QLatin1String("\\\\\""));
- // escape a single " because the arguments will be parsed
- tmp.replace(QLatin1Char('\"'), QLatin1String("\\\""));
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- QString endQuote(QLatin1Char('\"'));
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) {
- --i;
- endQuote += QLatin1Char('\\');
- }
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
- } else {
- args += QLatin1Char(' ') + tmp;
- }
- }
- return args;
-}
-#endif
-
-bool ExecuteOperation::performOperation()
-{
- // This operation receives only one argument. It is the complete
- // command line of the external program to execute.
- QStringList args = this->arguments();
- if (args.isEmpty()) {
- setError(InvalidArguments);
- setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
- return false;
- }
-
- QList<int> allowedExitCodes;
-
- QRegExp re(QLatin1String("^\\{((-?\\d+,)*-?\\d+)\\}$"));
- if (re.exactMatch(args.first())) {
- const QStringList numbers = re.cap(1).split(QLatin1Char(','));
- for (QStringList::const_iterator it = numbers.begin(); it != numbers.end(); ++it)
- allowedExitCodes.push_back(it->toInt());
- args.pop_front();
- } else {
- allowedExitCodes.push_back(0);
- }
-
- bool success = false;
-#ifdef SUPPORT_DETACHED_PROCESS_EXECUTION
- // unix style: when there's an ampersand after the command, it's started detached
- if (args.count() >= 2 && args.last() == QLatin1String("&")) {
- args.pop_back();
-#ifdef Q_OS_WIN
- QString arguments = qt_create_commandline(args.front(), args.mid(1));
-
- PROCESS_INFORMATION pinfo;
-
- STARTUPINFOW startupInfo = { sizeof(STARTUPINFO), 0, 0, 0,
- static_cast< ulong >(CW_USEDEFAULT), static_cast< ulong >(CW_USEDEFAULT),
- static_cast< ulong >(CW_USEDEFAULT), static_cast< ulong >(CW_USEDEFAULT),
- 0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
- };
- success = CreateProcess(0, (wchar_t*)arguments.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
- 0,
- &startupInfo, &pinfo);
-
-#else
- success = QProcess::startDetached(args.front(), args.mid(1));
-#endif
- }
- else
-#endif
- {
- Environment::instance().applyTo(&process); //apply non-persistent variables
- process.start(args.front(), args.mid(1));
-
- QEventLoop loop;
- QObject::connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
- QObject::connect(&process, SIGNAL(readyRead()), this, SLOT(readProcessOutput()));
- success = process.waitForStarted(-1);
- if (success) {
- loop.exec();
- setValue(QLatin1String("ExitCode"), process.exitCode());
- success = allowedExitCodes.contains(process.exitCode());
- }
- }
- if (!success) {
- setError(UserDefinedError);
- setErrorString(tr("Execution failed: %1").arg(args.join(QLatin1String(" "))));
- }
-
- return success;
-}
-
-/*!
- Cancels the ExecuteOperation. This methods tries to terminate the process
- gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
- */
-void ExecuteOperation::cancelOperation()
-{
- if (process.state() == QProcess::Running)
- process.terminate();
- if (!process.waitForFinished(10000))
- process.kill();
-}
-
-void ExecuteOperation::readProcessOutput()
-{
- QByteArray output = process.readAll();
- if (!output.isEmpty())
- emit outputTextChanged(QString::fromLocal8Bit(output));
-}
-
-bool ExecuteOperation::undoOperation()
-{
- // this is not possible, since the process can do whatever...
- return false;
-}
-
-bool ExecuteOperation::testOperation()
-{
- // TODO
- return true;
-}
-
-ExecuteOperation *ExecuteOperation::clone() const
-{
- return new ExecuteOperation;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-// KDUpdater::UpdatePackageOperation
-////////////////////////////////////////////////////////////////////////////
-
-UpdatePackageOperation::UpdatePackageOperation()
-{
- setName(QLatin1String("UpdatePackage"));
-}
-
-void UpdatePackageOperation::backup()
-{
- const PackageInfo info = application()->packagesInfo()->packageInfo(application()->packagesInfo()->findPackageInfo(arguments().first()));
- setValue(QLatin1String("oldVersion"), info.version);
- setValue(QLatin1String("oldDate"), info.lastUpdateDate);
-}
-
-bool UpdatePackageOperation::performOperation()
-{
- // This operation receives three arguments : the name of the package
- // the new version and the release date
- const QStringList args = this->arguments();
- if (args.count() != 3) {
- setError(InvalidArguments, tr("Invalid arguments: %1 arguments given, 3 expected.").arg(args.count()));
- return false;
- }
-
- const QString &packageName = args.at(0);
- const QString &version = args.at(1);
- const QDate date = QDate::fromString(args.at(2));
- const bool success = application()->packagesInfo()->updatePackage(packageName, version, date);
- if (!success)
- setError(UserDefinedError, tr("Cannot update %1-%2").arg(packageName, version));
-
- return success;
-}
-
-bool UpdatePackageOperation::undoOperation()
-{
- const QString packageName = arguments().first();
- const QString version = arguments().at(1);
- const QString oldVersion = value(QLatin1String("oldVersion")).toString();
- const QDate oldDate = value(QLatin1String("oldDate")).toDate();
- const bool success = application()->packagesInfo()->updatePackage(packageName, oldVersion, oldDate);
- if (!success)
- setError(UserDefinedError, tr("Cannot restore %1-%2").arg(packageName, version));
-
- return success;
-}
-
-bool UpdatePackageOperation::testOperation()
-{
- // TODO
- return true;
-}
-
-UpdatePackageOperation *UpdatePackageOperation::clone() const
-{
- return new UpdatePackageOperation;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-// KDUpdater::UpdateCompatOperation
-////////////////////////////////////////////////////////////////////////////
-
-UpdateCompatOperation::UpdateCompatOperation()
-{
- setName(QLatin1String("UpdateCompatLevel"));
-}
-
-void UpdateCompatOperation::backup()
-{
- setValue(QLatin1String("oldCompatLevel"), application()->packagesInfo()->compatLevel());
-}
-
-bool UpdateCompatOperation::performOperation()
-{
- // This operation receives one argument : the new compat level
- const QStringList args = this->arguments();
- if (args.count() != 1) {
- setError(InvalidArguments, tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
- return false;
- }
-
- const int level = args.first().toInt();
- application()->packagesInfo()->setCompatLevel(level);
- return true;
-}
-
-bool UpdateCompatOperation::undoOperation()
-{
- if (!hasValue(QLatin1String("oldCompatLevel"))) {
- setError(UserDefinedError, tr("Cannot restore previous compat-level"));
- return false;
- }
-
- application()->packagesInfo()->setCompatLevel(value(QLatin1String("oldCompatLevel")).toInt());
- return true;
-}
-
-bool UpdateCompatOperation::testOperation()
-{
- // TODO
- return true;
-}
-
-UpdateCompatOperation *UpdateCompatOperation::clone() const
-{
- return new UpdateCompatOperation;
-}
diff --git a/src/libs/kdtools/kdupdaterupdateoperations.h b/src/libs/kdtools/kdupdaterupdateoperations.h
index 40480d1e1..43a0ff9d2 100644
--- a/src/libs/kdtools/kdupdaterupdateoperations.h
+++ b/src/libs/kdtools/kdupdaterupdateoperations.h
@@ -1,34 +1,49 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_OPERATIONS_H
#define KD_UPDATER_UPDATE_OPERATIONS_H
#include "kdupdaterupdateoperation.h"
-#include <QDir>
-#include <QObject>
-#include <QProcess>
-
namespace KDUpdater {
class KDTOOLS_EXPORT CopyOperation : public UpdateOperation
@@ -44,6 +59,9 @@ public:
CopyOperation *clone() const;
QDomDocument toXml() const;
+private:
+ QString sourcePath();
+ QString destinationPath();
};
class KDTOOLS_EXPORT MoveOperation : public UpdateOperation
@@ -122,56 +140,6 @@ public:
PrependFileOperation *clone() const;
};
-class KDTOOLS_EXPORT ExecuteOperation : public QObject, public UpdateOperation
-{
- Q_OBJECT
-
-public:
- ExecuteOperation();
-
- void backup();
- bool performOperation();
- bool undoOperation();
- bool testOperation();
- ExecuteOperation *clone() const;
-
-public Q_SLOTS:
- void cancelOperation();
-
-private Q_SLOTS:
- void readProcessOutput();
-
-Q_SIGNALS:
- void outputTextChanged(const QString &text);
-
-private:
- QProcess process;
-};
-
-class KDTOOLS_EXPORT UpdatePackageOperation : public UpdateOperation
-{
-public:
- UpdatePackageOperation();
-
- void backup();
- bool performOperation();
- bool undoOperation();
- bool testOperation();
- UpdatePackageOperation *clone() const;
-};
-
-class KDTOOLS_EXPORT UpdateCompatOperation : public UpdateOperation
-{
-public:
- UpdateCompatOperation();
-
- void backup();
- bool performOperation();
- bool undoOperation();
- bool testOperation();
- UpdateCompatOperation *clone() const;
-};
-
} // namespace KDUpdater
#endif // KD_UPDATER_UPDATE_OPERATIONS_H
diff --git a/src/libs/kdtools/kdupdaterupdatesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesinfo.cpp
index b0cc8608b..27c21fb19 100644
--- a/src/libs/kdtools/kdupdaterupdatesinfo.cpp
+++ b/src/libs/kdtools/kdupdaterupdatesinfo.cpp
@@ -1,68 +1,68 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdatesinfo_p.h"
-#include <QCoreApplication>
-#include <QtXml/QDomDocument>
-#include <QtXml/QDomElement>
#include <QFile>
-#include <QSharedData>
#include <QLocale>
+#include <QUrl>
using namespace KDUpdater;
-//
-// UpdatesInfo::UpdatesInfoData
-//
-struct UpdatesInfo::UpdatesInfoData : public QSharedData
+UpdatesInfoData::UpdatesInfoData()
+ : error(UpdatesInfo::NotYetReadError)
{
- Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
-
-public:
- UpdatesInfoData() : error(UpdatesInfo::NotYetReadError), compatLevel(-1) { }
-
- QString errorMessage;
- UpdatesInfo::Error error;
- QString updateXmlFile;
- QString applicationName;
- QString applicationVersion;
- int compatLevel;
- QList<UpdateInfo> updateInfoList;
-
- void parseFile(const QString &updateXmlFile);
- bool parsePackageUpdateElement(const QDomElement &updateE);
- bool parseCompatUpdateElement(const QDomElement &updateE);
+}
- void setInvalidContentError(const QString &detail);
-};
+UpdatesInfoData::~UpdatesInfoData()
+{
+}
-void UpdatesInfo::UpdatesInfoData::setInvalidContentError(const QString &detail)
+void UpdatesInfoData::setInvalidContentError(const QString &detail)
{
error = UpdatesInfo::InvalidContentError;
errorMessage = tr("Updates.xml contains invalid content: %1").arg(detail);
}
-void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
+void UpdatesInfoData::parseFile(const QString &updateXmlFile)
{
QFile file(updateXmlFile);
if (!file.open(QFile::ReadOnly)) {
@@ -73,15 +73,11 @@ void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
QDomDocument doc;
QString parseErrorMessage;
- int parseErrorLine;
- int parseErrorColumn;
+ int parseErrorLine, parseErrorColumn;
if (!doc.setContent(&file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn)) {
error = UpdatesInfo::InvalidXmlError;
- errorMessage = tr("Parse error in %1 at %2, %3: %4")
- .arg(updateXmlFile,
- QString::number(parseErrorLine),
- QString::number(parseErrorColumn),
- parseErrorMessage);
+ errorMessage = tr("Parse error in %1 at %2, %3: %4").arg(updateXmlFile,
+ QString::number(parseErrorLine), QString::number(parseErrorColumn), parseErrorMessage);
return;
}
@@ -93,8 +89,7 @@ void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
QDomNodeList childNodes = rootE.childNodes();
for(int i = 0; i < childNodes.count(); i++) {
- QDomNode childNode = childNodes.at(i);
- QDomElement childE = childNode.toElement();
+ const QDomElement childE = childNodes.at(i).toElement();
if (childE.isNull())
continue;
@@ -102,20 +97,9 @@ void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
applicationName = childE.text();
else if (childE.tagName() == QLatin1String("ApplicationVersion"))
applicationVersion = childE.text();
- else if (childE.tagName() == QLatin1String("RequiredCompatLevel"))
- compatLevel = childE.text().toInt();
else if (childE.tagName() == QLatin1String("PackageUpdate")) {
- const bool res = parsePackageUpdateElement(childE);
- if (!res) {
- //error handled in subroutine
- return;
- }
- } else if (childE.tagName() == QLatin1String("CompatUpdate")) {
- const bool res = parseCompatUpdateElement(childE);
- if (!res) {
- //error handled in subroutine
- return;
- }
+ if (!parsePackageUpdateElement(childE))
+ return; //error handled in subroutine
}
}
@@ -123,40 +107,29 @@ void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
setInvalidContentError(tr("ApplicationName element is missing."));
return;
}
-
+
if (applicationVersion.isEmpty()) {
setInvalidContentError(tr("ApplicationVersion element is missing."));
return;
}
-
- error = UpdatesInfo::NoError;
+
errorMessage.clear();
+ error = UpdatesInfo::NoError;
}
-bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
+bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
{
if (updateE.isNull())
return false;
UpdateInfo info;
- info.type = PackageUpdate;
-
- QDomNodeList childNodes = updateE.childNodes();
- for (int i = 0; i < childNodes.count(); i++) {
- QDomNode childNode = childNodes.at(i);
- QDomElement childE = childNode.toElement();
+ for (int i = 0; i < updateE.childNodes().count(); i++) {
+ QDomElement childE = updateE.childNodes().at(i).toElement();
if (childE.isNull())
continue;
if (childE.tagName() == QLatin1String("ReleaseNotes")) {
info.data[childE.tagName()] = QUrl(childE.text());
- } else if (childE.tagName() == QLatin1String("UpdateFile")) {
- UpdateFileInfo ufInfo;
- ufInfo.compressedSize = childE.attribute(QLatin1String("CompressedSize")).toLongLong();
- ufInfo.uncompressedSize = childE.attribute(QLatin1String("UncompressedSize")).toLongLong();
- ufInfo.sha1sum = QByteArray::fromHex(childE.attribute(QLatin1String("sha1sum")).toLatin1());
- ufInfo.fileName = childE.text();
- info.updateFiles.append(ufInfo);
} else if (childE.tagName() == QLatin1String("Licenses")) {
QHash<QString, QVariant> licenseHash;
const QDomNodeList licenseNodes = childE.childNodes();
@@ -171,19 +144,20 @@ bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &
if (!licenseHash.isEmpty())
info.data.insert(QLatin1String("Licenses"), licenseHash);
} else if (childE.tagName() == QLatin1String("Version")) {
- info.data.insert(QLatin1String("inheritVersionFrom"), childE.attribute(QLatin1String("inheritVersionFrom")));
+ info.data.insert(QLatin1String("inheritVersionFrom"),
+ childE.attribute(QLatin1String("inheritVersionFrom")));
info.data[childE.tagName()] = childE.text();
} else if (childE.tagName() == QLatin1String("Description")) {
-
QString languageAttribute = childE.attribute(QLatin1String("xml:lang")).toLower();
-
if (!info.data.contains(QLatin1String("Description")) && (languageAttribute.isEmpty()))
info.data[childE.tagName()] = childE.text();
// overwrite default if we have a language specific description
if (languageAttribute == QLocale().name().toLower())
info.data[childE.tagName()] = childE.text();
-
+ } else if (childE.tagName() == QLatin1String("UpdateFile")) {
+ info.data[QLatin1String("CompressedSize")] = childE.attribute(QLatin1String("CompressedSize"));
+ info.data[QLatin1String("UncompressedSize")] = childE.attribute(QLatin1String("UncompressedSize"));
} else {
info.data[childE.tagName()] = childE.text();
}
@@ -201,55 +175,6 @@ bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &
setInvalidContentError(tr("PackageUpdate element without ReleaseDate"));
return false;
}
- if (info.updateFiles.isEmpty()) {
- setInvalidContentError(tr("PackageUpdate element without UpdateFile"));
- return false;
- }
-
- updateInfoList.append(info);
- return true;
-}
-
-bool UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement &updateE)
-{
- if (updateE.isNull())
- return false;
-
- UpdateInfo info;
- info.type = CompatUpdate;
-
- QDomNodeList childNodes = updateE.childNodes();
- for (int i = 0; i < childNodes.count(); i++) {
- QDomNode childNode = childNodes.at(i);
- QDomElement childE = childNode.toElement();
- if (childE.isNull())
- continue;
-
- if (childE.tagName() == QLatin1String("ReleaseNotes")) {
- info.data[childE.tagName()] = QUrl(childE.text());
- } else if (childE.tagName() == QLatin1String("UpdateFile")) {
- UpdateFileInfo ufInfo;
- ufInfo.fileName = childE.text();
- info.updateFiles.append(ufInfo);
- } else {
- info.data[childE.tagName()] = childE.text();
- }
- }
-
- if (!info.data.contains(QLatin1String("CompatLevel"))) {
- setInvalidContentError(tr("CompatUpdate element without CompatLevel"));
- return false;
- }
-
- if (!info.data.contains(QLatin1String("ReleaseDate"))) {
- setInvalidContentError(tr("CompatUpdate element without ReleaseDate"));
- return false;
- }
-
- if (info.updateFiles.isEmpty()) {
- setInvalidContentError(tr("CompatUpdate element without UpdateFile"));
- return false;
- }
updateInfoList.append(info);
return true;
@@ -260,7 +185,7 @@ bool UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement &u
// UpdatesInfo
//
UpdatesInfo::UpdatesInfo()
- : d(new UpdatesInfo::UpdatesInfoData)
+ : d(new UpdatesInfoData)
{
}
@@ -306,55 +231,19 @@ QString UpdatesInfo::applicationVersion() const
return d->applicationVersion;
}
-int UpdatesInfo::compatLevel() const
-{
- return d->compatLevel;
-}
-
-int UpdatesInfo::updateInfoCount(int type) const
+int UpdatesInfo::updateInfoCount() const
{
- if (type == AllUpdate)
- return d->updateInfoList.count();
-
- int count = 0;
- for (int i = 0; i < d->updateInfoList.count(); ++i) {
- if (d->updateInfoList.at(i).type == type)
- ++count;
- }
- return count;
+ return d->updateInfoList.count();
}
UpdateInfo UpdatesInfo::updateInfo(int index) const
{
if (index < 0 || index >= d->updateInfoList.count())
return UpdateInfo();
-
return d->updateInfoList.at(index);
}
-QList<UpdateInfo> UpdatesInfo::updatesInfo(int type, int compatLevel) const
+QList<UpdateInfo> UpdatesInfo::updatesInfo() const
{
- QList<UpdateInfo> list;
- if (compatLevel == -1) {
- if (type == AllUpdate)
- return d->updateInfoList;
- for (int i = 0; i < d->updateInfoList.count(); ++i) {
- if (d->updateInfoList.at(i).type == type)
- list.append(d->updateInfoList.at(i));
- }
- } else {
- for (int i = 0; i < d->updateInfoList.count(); ++i) {
- UpdateInfo updateInfo = d->updateInfoList.at(i);
- if (updateInfo.type == type) {
- if (updateInfo.type == CompatUpdate) {
- if (updateInfo.data.value(QLatin1String("CompatLevel")) == compatLevel)
- list.append(updateInfo);
- } else {
- if (updateInfo.data.value(QLatin1String("RequiredCompatLevel")) == compatLevel)
- list.append(updateInfo);
- }
- }
- }
- }
- return list;
+ return d->updateInfoList;
}
diff --git a/src/libs/kdtools/kdupdaterupdatesinfo_p.h b/src/libs/kdtools/kdupdaterupdatesinfo_p.h
index 926133eb1..449c851e3 100644
--- a/src/libs/kdtools/kdupdaterupdatesinfo_p.h
+++ b/src/libs/kdtools/kdupdaterupdatesinfo_p.h
@@ -1,65 +1,65 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_INFO_H
#define KD_UPDATER_UPDATE_INFO_H
#include "kdupdater.h"
+#include "kdupdaterupdatesinfodata_p.h"
-#include <QSharedDataPointer>
-#include <QString>
-#include <QDate>
-#include <QList>
-#include <QStringList>
-#include <QUrl>
#include <QHash>
+#include <QSharedData>
#include <QVariant>
-// Classes and structures in this header file are for internal use only.
// They are not a part of the public API
+// Classes and structures in this header file are for internal use only but still exported for auto tests.
namespace KDUpdater {
-struct UpdateFileInfo
-{
- UpdateFileInfo()
- : compressedSize(0),
- uncompressedSize(0)
- {}
-
- QString fileName;
- QByteArray sha1sum;
- quint64 compressedSize;
- quint64 uncompressedSize;
-};
-
-struct UpdateInfo
+struct KDTOOLS_EXPORT UpdateInfo
{
- int type;
QHash<QString, QVariant> data;
- QList<UpdateFileInfo> updateFiles;
};
-class UpdatesInfo
+class KDTOOLS_EXPORT UpdatesInfo
{
public:
enum Error
@@ -75,22 +75,21 @@ public:
~UpdatesInfo();
bool isValid() const;
- QString errorString() const;
+
Error error() const;
+ QString errorString() const;
- void setFileName(const QString &updateXmlFile);
QString fileName() const;
+ void setFileName(const QString &updateXmlFile);
QString applicationName() const;
QString applicationVersion() const;
- int compatLevel() const;
- int updateInfoCount(int type = AllUpdate) const;
+ int updateInfoCount() const;
UpdateInfo updateInfo(int index) const;
- QList<UpdateInfo> updatesInfo(int type = AllUpdate, int compatLevel = -1) const;
+ QList<UpdateInfo> updatesInfo() const;
private:
- struct UpdatesInfoData;
QSharedDataPointer<UpdatesInfoData> d;
};
diff --git a/src/libs/kdtools/kdupdaterupdatesinfodata_p.h b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h
new file mode 100644
index 000000000..c02629aa5
--- /dev/null
+++ b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_INFO_DATA_H
+#define KD_UPDATER_UPDATE_INFO_DATA_H
+
+#include <QCoreApplication>
+#include <QDomElement>
+#include <QSharedData>
+
+namespace KDUpdater {
+
+struct UpdateInfo;
+
+struct UpdatesInfoData : public QSharedData
+{
+ Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
+
+public:
+ UpdatesInfoData();
+ ~UpdatesInfoData();
+
+ int error;
+ QString errorMessage;
+ QString updateXmlFile;
+ QString applicationName;
+ QString applicationVersion;
+ QList<UpdateInfo> updateInfoList;
+
+ void parseFile(const QString &updateXmlFile);
+ bool parsePackageUpdateElement(const QDomElement &updateE);
+
+ void setInvalidContentError(const QString &detail);
+};
+
+} // namespace KDUpdater
+
+#endif // KD_UPDATER_UPDATE_INFO_DATA_H
diff --git a/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp
index 01f3a96f4..9acd09682 100644
--- a/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp
+++ b/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp
@@ -1,27 +1,45 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#include "kdupdaterupdatesourcesinfo.h"
-#include "kdupdaterapplication.h"
#include <QtXml/QDomElement>
#include <QtXml/QDomDocument>
@@ -73,7 +91,7 @@
*/
/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::InvalidXmlError
- * The source file contains invalid XML.
+ * The source file contains invalid XML.
*/
/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::InvalidContentError
@@ -97,24 +115,21 @@ struct UpdateSourceInfoPriorityHigherThan
struct UpdateSourcesInfo::UpdateSourcesInfoData
{
- UpdateSourcesInfoData(UpdateSourcesInfo *qq) :
- q(qq),
- error(UpdateSourcesInfo::NotYetReadError),
- application(0),
- modified(false)
+ UpdateSourcesInfoData()
+ : modified(false)
+ , error(UpdateSourcesInfo::NotYetReadError)
{}
- UpdateSourcesInfo *q;
-
- QString errorMessage;
- UpdateSourcesInfo::Error error;
- Application *application;
bool modified;
+ UpdateSourcesInfo::Error error;
+
QString fileName;
+ QString errorMessage;
QList<UpdateSourceInfo> updateSourceInfoList;
void addUpdateSourceFrom(const QDomElement &element);
- void addChildElement(QDomDocument &doc, QDomElement &parentE, const QString &tagName, const QString &text, bool htmlText = false);
+ void addChildElement(QDomDocument &doc, QDomElement &parentE, const QString &tagName,
+ const QString &text, bool htmlText = false);
void setInvalidContentError(const QString &detail);
void clearError();
void saveChanges();
@@ -135,11 +150,10 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::clearError()
/*!
\internal
*/
-UpdateSourcesInfo::UpdateSourcesInfo(Application *application)
- : QObject(application),
- d(new UpdateSourcesInfo::UpdateSourcesInfoData(this))
+UpdateSourcesInfo::UpdateSourcesInfo(QObject *parent)
+ : QObject(parent)
+ , d(new UpdateSourcesInfo::UpdateSourcesInfoData)
{
- d->application = application;
}
/*!
@@ -148,15 +162,6 @@ UpdateSourcesInfo::UpdateSourcesInfo(Application *application)
UpdateSourcesInfo::~UpdateSourcesInfo()
{
d->saveChanges();
- delete d;
-}
-
-/*!
- Returns a pointer to the update application for which this class manages update sources.
-*/
-Application *UpdateSourcesInfo::application() const
-{
- return d->application;
}
/*!
@@ -264,47 +269,6 @@ void UpdateSourcesInfo::removeUpdateSourceInfo(const UpdateSourceInfo &info)
}
/*!
- Removes an update source info at \index in this class. Upon successful removal, the class emits a
- \ref updateSourceInfoRemoved() signal.
-*/
-void UpdateSourcesInfo::removeUpdateSourceInfoAt(int index)
-{
- if (index < 0 || index >= d->updateSourceInfoList.count())
- return;
- UpdateSourceInfo info = d->updateSourceInfoList[index];
- d->updateSourceInfoList.removeAt(index);
- emit updateSourceInfoRemoved(info);
- d->modified = true;
-}
-
-/*!
- Changes the update source info at \c index to \c info. If \c index is equal to the number of
- source info structures in this class (\ref updateSourceInfoCount()) then \c info is appended;
- otherwise the existing info at \c index will be changed.
-
- Depending on what the function does \ref updateSourceInfoAdded() or \ref updateSourceInfoChanged()
- signal is emitted.
-*/
-void UpdateSourcesInfo::setUpdateSourceInfoAt(int index, const UpdateSourceInfo &info)
-{
- if (index < 0 || index > d->updateSourceInfoList.count())
- return;
-
- if (index == d->updateSourceInfoList.count()) {
- d->updateSourceInfoList.append(info);
- emit updateSourceInfoAdded(info);
- } else {
- UpdateSourceInfo oldInfo = d->updateSourceInfoList[index];
- if (info == oldInfo)
- return;
-
- d->updateSourceInfoList[index] = info;
- emit updateSourceInfoChanged(info, oldInfo);
- }
- d->modified = true;
-}
-
-/*!
This slot reloads the update source information from UpdateSources.xml.
*/
void UpdateSourcesInfo::refresh()
@@ -313,14 +277,14 @@ void UpdateSourcesInfo::refresh()
d->updateSourceInfoList.clear();
QFile file(d->fileName);
-
+
// if the file does not exist then we just skip the reading
if (!file.exists()) {
d->clearError();
emit reset();
return;
}
-
+
// Open the XML file
if (!file.open(QFile::ReadOnly)) {
d->errorMessage = tr("Could not read \"%1\"").arg(d->fileName);
@@ -331,35 +295,27 @@ void UpdateSourcesInfo::refresh()
QDomDocument doc;
QString parseErrorMessage;
- int parseErrorLine;
- int parseErrorColumn;
+ int parseErrorLine, parseErrorColumn;
if (!doc.setContent(&file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn)) {
d->error = InvalidXmlError;
- d->errorMessage = tr("XML Parse error in %1 at %2, %3: %4")
- .arg(d->fileName,
- QString::number(parseErrorLine),
- QString::number(parseErrorColumn),
- parseErrorMessage);
+ d->errorMessage = tr("XML Parse error in %1 at %2, %3: %4").arg(d->fileName,
+ QString::number(parseErrorLine), QString::number(parseErrorColumn), parseErrorMessage);
emit reset();
return;
}
// Now parse the XML file.
- QDomElement rootE = doc.documentElement();
+ const QDomElement rootE = doc.documentElement();
if (rootE.tagName() != QLatin1String("UpdateSources")) {
d->setInvalidContentError(tr("Root element %1 unexpected, should be \"UpdateSources\"").arg(rootE.tagName()));
emit reset();
return;
}
- QDomNodeList childNodes = rootE.childNodes();
+ const QDomNodeList childNodes = rootE.childNodes();
for (int i = 0; i < childNodes.count(); i++) {
- QDomNode childNode = childNodes.item(i);
- QDomElement childNodeE = childNode.toElement();
- if (childNodeE.isNull())
- continue;
-
- if (childNodeE.tagName() == QLatin1String("UpdateSource"))
+ QDomElement childNodeE = childNodes.item(i).toElement();
+ if ((!childNodeE.isNull()) && (childNodeE.tagName() == QLatin1String("UpdateSource")))
d->addUpdateSourceFrom(childNodeE);
}
@@ -372,23 +328,20 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
if (!modified || fileName.isEmpty())
return;
- const bool hadSaveError = error == UpdateSourcesInfo::CouldNotSaveChangesError;
-
- QDomDocument doc;
+ const bool hadSaveError = (error == UpdateSourcesInfo::CouldNotSaveChangesError);
+ QDomDocument doc;
QDomElement rootE = doc.createElement(QLatin1String("UpdateSources"));
doc.appendChild(rootE);
- for (int i = 0; i < updateSourceInfoList.count(); i++) {
- UpdateSourceInfo info = updateSourceInfoList.at(i);
-
+ foreach (const UpdateSourceInfo &info, updateSourceInfoList) {
QDomElement infoE = doc.createElement(QLatin1String("UpdateSource"));
rootE.appendChild(infoE);
addChildElement(doc, infoE, QLatin1String("Name"), info.name);
addChildElement(doc, infoE, QLatin1String("Title"), info.title);
- addChildElement(doc, infoE, QLatin1String("Description"), info.description,
- (info.description.length() && info.description.at(0) == QLatin1Char('<')));
- addChildElement(doc, infoE, QLatin1String("Url"), info.url.toString());
+ addChildElement(doc, infoE, QLatin1String("Description"), info.description,
+ (info.description.length() && info.description.at(0) == QLatin1Char('<')));
+ addChildElement(doc, infoE, QLatin1String("Url"), info.url.toString());
}
QFile file(fileName);
@@ -397,7 +350,7 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
return;
}
-
+
QTextStream stream(&file);
doc.save(stream, 2);
stream.flush();
@@ -408,11 +361,11 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
return;
}
-
+
//if there was a write error before, clear the error, as the write was successful now
if (hadSaveError)
clearError();
-
+
modified = false;
}
@@ -421,15 +374,13 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::addUpdateSourceFrom(const QDomEle
if (element.tagName() != QLatin1String("UpdateSource"))
return;
- QDomNodeList childNodes = element.childNodes();
+ const QDomNodeList childNodes = element.childNodes();
if (!childNodes.count())
return;
UpdateSourceInfo info;
-
- for (int i = 0; i<childNodes.count(); i++) {
- QDomNode childNode = childNodes.item(i);
- QDomElement childNodeE = childNode.toElement();
+ for (int i = 0; i < childNodes.count(); ++i) {
+ const QDomElement childNodeE = childNodes.item(i).toElement();
if (childNodeE.isNull())
continue;
@@ -442,22 +393,15 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::addUpdateSourceFrom(const QDomEle
else if (childNodeE.tagName() == QLatin1String("Url"))
info.url = childNodeE.text();
}
-
this->updateSourceInfoList.append(info);
}
-void UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement(QDomDocument &doc, QDomElement &parentE, const QString &tagName, const QString &text, bool htmlText)
+void UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement(QDomDocument &doc, QDomElement &parentE,
+ const QString &tagName, const QString &text, bool htmlText)
{
QDomElement childE = doc.createElement(tagName);
parentE.appendChild(childE);
-
- if (htmlText) {
- QDomCDATASection textE = doc.createCDATASection(text);
- childE.appendChild(textE);
- } else {
- QDomText textE = doc.createTextNode(text);
- childE.appendChild(textE);
- }
+ childE.appendChild(htmlText ? doc.createCDATASection(text) : doc.createTextNode(text));
}
/*!
@@ -491,10 +435,10 @@ void UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement(QDomDocument &doc
namespace KDUpdater {
-bool operator==(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs)
+bool operator== (const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs)
{
- return lhs.name == rhs.name && lhs.title == rhs.title
- && lhs.description == rhs.description && lhs.url == rhs.url;
+ return lhs.name == rhs.name && lhs.title == rhs.title && lhs.description == rhs.description
+ && lhs.url == rhs.url;
}
} // namespace KDUpdater
diff --git a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h b/src/libs/kdtools/kdupdaterupdatesourcesinfo.h
index 2afeda966..23ffaf6a8 100644
--- a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h
+++ b/src/libs/kdtools/kdupdaterupdatesourcesinfo.h
@@ -1,29 +1,48 @@
/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
**
-** This file is part of the KD Tools library.
+** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: http://www.qt-project.org/legal
**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
+** This file is part of the Qt Installer Framework.
**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-**********************************************************************/
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
#ifndef KD_UPDATER_UPDATE_SOURCES_INFO_H
#define KD_UPDATER_UPDATE_SOURCES_INFO_H
-#include "kdupdater.h"
+#include "kdtoolsglobal.h"
#include <QObject>
#include <QVariant>
@@ -31,8 +50,6 @@
namespace KDUpdater {
-class Application;
-
struct KDTOOLS_EXPORT UpdateSourceInfo
{
UpdateSourceInfo() : priority(-1) { }
@@ -68,8 +85,6 @@ public:
CouldNotSaveChangesError
};
- Application *application() const;
-
bool isValid() const;
QString errorString() const;
Error error() const;
@@ -85,11 +100,10 @@ public:
void addUpdateSourceInfo(const UpdateSourceInfo &info);
void removeUpdateSourceInfo(const UpdateSourceInfo &info);
- void removeUpdateSourceInfoAt(int index);
- void setUpdateSourceInfoAt(int index, const UpdateSourceInfo &info);
protected:
- explicit UpdateSourcesInfo(Application *application);
+ friend class Application;
+ explicit UpdateSourcesInfo(QObject *parent = 0);
public Q_SLOTS:
void refresh();
@@ -98,13 +112,10 @@ Q_SIGNALS:
void reset();
void updateSourceInfoAdded(const UpdateSourceInfo &info);
void updateSourceInfoRemoved(const UpdateSourceInfo &info);
- void updateSourceInfoChanged(const UpdateSourceInfo &newInfo,
- const UpdateSourceInfo &oldInfo);
private:
- friend class Application;
struct UpdateSourcesInfoData;
- UpdateSourcesInfoData *d;
+ QScopedPointer<UpdateSourcesInfoData> d;
};
} // namespace KDUpdater