summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-04-03 16:50:35 +0200
committerTim Jenssen <tim.jenssen@digia.com>2013-04-04 10:32:35 +0200
commit546b7d16d017c9cffdff731400207177b7499488 (patch)
tree377a6c5fdee52dc32c0bf8452ec6d48359f1e626 /src
parentf6d6b61f0144c52126f0b11edf82e8660efc18c7 (diff)
parent59204c3a70b2067f8df39a57bb70a3dfb944a4b7 (diff)
Merge remote-tracking branch 'origin/1.3'
Conflicts: installerfw.pri src/libs/installer/settings.cpp tests/auto/installer/settings/tst_settings.cpp Change-Id: Idb89f22fe940a730ed03a7d10f11e1b5fa655b49
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/packagemanagercoredata.cpp2
-rw-r--r--src/libs/installer/resources/patch_file_lists.qrc2
-rw-r--r--src/libs/installer/settings.cpp78
-rw-r--r--src/libs/installer/settings.h8
-rw-r--r--src/libs/installer/updatesettings.cpp2
5 files changed, 61 insertions, 31 deletions
diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp
index f383bd62f..efc83f520 100644
--- a/src/libs/installer/packagemanagercoredata.cpp
+++ b/src/libs/installer/packagemanagercoredata.cpp
@@ -73,7 +73,7 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va
try {
m_settings = Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
- QLatin1String(":/metadata/installer-config/"));
+ QLatin1String(":/metadata/installer-config/"), Settings::RelaxedParseMode);
} catch (const Error &e) {
// TODO: try better error handling
qCritical("Could not parse Config: %s", qPrintable(e.message()));
diff --git a/src/libs/installer/resources/patch_file_lists.qrc b/src/libs/installer/resources/patch_file_lists.qrc
index 26154dec2..fe4b77046 100644
--- a/src/libs/installer/resources/patch_file_lists.qrc
+++ b/src/libs/installer/resources/patch_file_lists.qrc
@@ -6,5 +6,7 @@
<file>files-to-patch-linux-qt5</file>
<file>files-to-patch-windows-qt5</file>
<file>files-to-patch-macx-qt5</file>
+ <file>files-to-patch-linux-emb-arm</file>
+ <file>files-to-patch-windows-emb-arm</file>
</qresource>
</RCC>
diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp
index 602c6cc06..3ba85cdd6 100644
--- a/src/libs/installer/settings.cpp
+++ b/src/libs/installer/settings.cpp
@@ -41,6 +41,7 @@
#include "settings.h"
#include "errors.h"
+#include "qinstallerglobal.h"
#include "repository.h"
#include <QtCore/QFileInfo>
@@ -80,38 +81,57 @@ static QSet<T> variantListToSet(const QVariantList &list)
return set;
}
-static QSet<Repository> readRepositories(QXmlStreamReader &reader, bool isDefault)
+static void raiseError(QXmlStreamReader &reader, const QString &error, Settings::ParseMode parseMode)
+{
+ if (parseMode == Settings::StrictParseMode) {
+ reader.raiseError(error);
+ } else {
+ QFile *xmlFile = qobject_cast<QFile*>(reader.device());
+ if (xmlFile) {
+ qWarning() << QString::fromLatin1("Ignoring following settings reader error in %1, line %2, "
+ "column %3: %4").arg(xmlFile->fileName()).arg(reader.lineNumber()).arg(reader.columnNumber())
+ .arg(reader.errorString());
+ } else {
+ qWarning("Ignoring following settings reader error: %s", qPrintable(error));
+ }
+ }
+}
+
+static QSet<Repository> readRepositories(QXmlStreamReader &reader, bool isDefault, Settings::ParseMode parseMode)
{
QSet<Repository> set;
while (reader.readNextStartElement()) {
if (reader.name() == QLatin1String("Repository")) {
Repository repo(QString(), isDefault);
while (reader.readNextStartElement()) {
- if (reader.name() == QLatin1String("Url"))
+ if (reader.name() == QLatin1String("Url")) {
repo.setUrl(reader.readElementText());
- else if (reader.name() == QLatin1String("Username"))
+ } else if (reader.name() == QLatin1String("Username")) {
repo.setUsername(reader.readElementText());
- else if (reader.name() == QLatin1String("Password"))
+ } else if (reader.name() == QLatin1String("Password")) {
repo.setPassword(reader.readElementText());
- else if (reader.name() == QLatin1String("Enabled"))
+ } else if (reader.name() == QLatin1String("Enabled")) {
repo.setEnabled(bool(reader.readElementText().toInt()));
- else
- reader.raiseError(QString::fromLatin1("Unexpected element '%1'.").arg(
- reader.name().toString()));
-
- if (!reader.attributes().isEmpty())
- reader.raiseError(QString::fromLatin1("Unexpected attribute for element '%1'.").arg(
- reader.name().toString()));
+ } else {
+ raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name()
+ .toString()), parseMode);
+ }
+
+ if (!reader.attributes().isEmpty()) {
+ raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.")
+ .arg(reader.name().toString()), parseMode);
+ }
}
set.insert(repo);
} else {
- reader.raiseError(QString::fromLatin1("Unexpected element '%1'.").arg(
- reader.name().toString()));
+ raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name().toString()),
+ parseMode);
}
- if (!reader.attributes().isEmpty())
- reader.raiseError(QString::fromLatin1("Unexpected attribute for element '%1'.").arg(
- reader.name().toString()));
+ if (!reader.attributes().isEmpty()) {
+ raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.").arg(reader
+ .name().toString()), parseMode);
+ }
}
return set;
}
@@ -162,7 +182,7 @@ Settings& Settings::operator=(const Settings &other)
}
/* static */
-Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix)
+Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, ParseMode parseMode)
{
QFile file(path);
QFile overrideConfig(QLatin1String(":/overrideconfig.xml"));
@@ -175,9 +195,10 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix)
QXmlStreamReader reader(&file);
if (reader.readNextStartElement()) {
- if (reader.name() != QLatin1String("Installer"))
- reader.raiseError(QString::fromLatin1("Unexpected element '%1' as root element.").arg(
- reader.name().toString()));
+ if (reader.name() != QLatin1String("Installer")) {
+ raiseError(reader, QString::fromLatin1("Unexpected element '%1' as root element.").arg(reader
+ .name().toString()), parseMode);
+ }
}
QStringList elementList;
elementList << scName << scVersion << scTitle << scPublisher << scProductUrl
@@ -195,12 +216,13 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix)
s.d->m_data.insert(scPrefix, prefix);
while (reader.readNextStartElement()) {
const QString name = reader.name().toString();
-
if (!elementList.contains(name))
- reader.raiseError(QString::fromLatin1("Unexpected element '%1'.").arg(name));
+ raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(name), parseMode);
- if (!reader.attributes().isEmpty())
- reader.raiseError(QString::fromLatin1("Unexpected attribute for element '%1'.").arg(name));
+ if (!reader.attributes().isEmpty()) {
+ raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.").arg(name),
+ parseMode);
+ }
if (name == scIcon)
qWarning() << "Deprecated element 'Icon'.";
@@ -209,15 +231,15 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix)
reader.raiseError(QString::fromLatin1("Element '%1' has been defined before.").arg(name));
if (name == scRemoteRepositories) {
- s.addDefaultRepositories(readRepositories(reader, true));
+ s.addDefaultRepositories(readRepositories(reader, true, parseMode));
} else {
s.d->m_data.insert(name, reader.readElementText(QXmlStreamReader::SkipChildElements));
}
}
if (reader.error() != QXmlStreamReader::NoError) {
- throw Error(QString::fromLatin1("Error in %1, line %2, column %3: %4")
- .arg(path).arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
+ throw Error(QString::fromLatin1("Error in %1, line %2, column %3: %4").arg(path).arg(reader
+ .lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
}
if (s.d->m_data.value(scName).isNull())
diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h
index 79f70c3a3..277264f79 100644
--- a/src/libs/installer/settings.h
+++ b/src/libs/installer/settings.h
@@ -74,13 +74,19 @@ public:
UserDefinedProxy
};
+ enum ParseMode {
+ StrictParseMode,
+ RelaxedParseMode
+ };
+
explicit Settings();
~Settings();
Settings(const Settings &other);
Settings &operator=(const Settings &other);
- static Settings fromFileAndPrefix(const QString &path, const QString &prefix);
+ static Settings fromFileAndPrefix(const QString &path, const QString &prefix,
+ ParseMode parseMode = StrictParseMode);
QString logo() const;
QString title() const;
diff --git a/src/libs/installer/updatesettings.cpp b/src/libs/installer/updatesettings.cpp
index da6ab9319..2e876839f 100644
--- a/src/libs/installer/updatesettings.cpp
+++ b/src/libs/installer/updatesettings.cpp
@@ -153,7 +153,7 @@ QSet<Repository> UpdateSettings::repositories() const
try {
if(result.isEmpty()) {
result = Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
- QLatin1String(":/metadata/installer-config/")).userRepositories();
+ QLatin1String(":/metadata/installer-config/"), Settings::RelaxedParseMode).userRepositories();
}
} catch (const Error &error) {
qDebug("Could not parse config: %s", qPrintable(error.message()));