diff options
author | kh1 <karsten.heimrich@nokia.com> | 2012-01-20 15:08:13 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@nokia.com> | 2012-01-20 16:39:49 +0100 |
commit | e5557f134e78cf4673b29b5ab124e3f403f0b3c7 (patch) | |
tree | 1291b7d21abf9e946abc0335e6ae8178e21253f8 /installerbuilder/libinstaller/getrepositorymetainfojob.cpp | |
parent | 6d50d407c0047d75a7c746e1147a107ee3c75bad (diff) |
Initial part to update repositories.
Change-Id: I247cca06386eee0f1af084ac4c15a813e38c3f02
Reviewed-by: Alexander Lenhardt <alexander.lenhardt@nokia.com>
Diffstat (limited to 'installerbuilder/libinstaller/getrepositorymetainfojob.cpp')
-rw-r--r-- | installerbuilder/libinstaller/getrepositorymetainfojob.cpp | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/installerbuilder/libinstaller/getrepositorymetainfojob.cpp b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp index 41171fa87..7ccf9eaf7 100644 --- a/installerbuilder/libinstaller/getrepositorymetainfojob.cpp +++ b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp @@ -151,6 +151,11 @@ void GetRepositoryMetaInfoJob::setSilentRetries(int retries) m_silentRetries = retries; } +QHash<QString, QPair<Repository, Repository> > GetRepositoryMetaInfoJob::repositoryUpdates() const +{ + return m_repositoryUpdates; +} + void GetRepositoryMetaInfoJob::doStart() { m_retriesLeft = m_silentRetries; @@ -279,6 +284,54 @@ void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished() emit infoMessage(this, tr("Parsing component meta information...")); const QDomElement root = doc.documentElement(); + + m_repositoryUpdates.clear(); + // search for additional repositories that we might need to check + const QDomNode repositoryUpdate = root.firstChildElement(QLatin1String("RepositoryUpdate")); + if (!repositoryUpdate.isNull()) { + const QDomNodeList children = repositoryUpdate.toElement().childNodes(); + for (int i = 0; i < children.count(); ++i) { + const QDomElement el = children.at(i).toElement(); + if (!el.isNull() && el.tagName() == QLatin1String("Repository")) { + const QString action = el.attribute(QLatin1String("action")); + if (action == QLatin1String("add")) { + // add a new repository to the defaults list + Repository repository(el.attribute(QLatin1String("url")), true); + repository.setUsername(el.attribute(QLatin1String("username"))); + repository.setPassword(el.attribute(QLatin1String("password"))); + m_repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); + + qDebug() << "Added new repository:" << repository.url().toString(); + } else if (action == QLatin1String("remove")) { + // remove possible default repositories using the given server url + Repository repository(el.attribute(QLatin1String("url")), true); + m_repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); + + qDebug() << "Repository to remove:" << repository.url().toString(); + } else if (action == QLatin1String("replace")) { + // replace possible default repositories using the given server url + Repository oldRepository(el.attribute(QLatin1String("oldUrl")), true); + Repository newRepository(el.attribute(QLatin1String("newUrl")), true); + newRepository.setUsername(el.attribute(QLatin1String("username"))); + newRepository.setPassword(el.attribute(QLatin1String("password"))); + + // store the new repository and the one old it replaces + m_repositoryUpdates.insertMulti(action, qMakePair(newRepository, oldRepository)); + qDebug() << "Replace repository:" << oldRepository.url().toString() << "with:" + << newRepository.url().toString(); + } else { + qDebug() << "Invalid additional repositories action set in updates.xml fetched from:" + << m_repository.url().toString() << "Line:" << el.lineNumber(); + } + } + } + + if (!m_repositoryUpdates.isEmpty()) { + finished(QInstaller::RepositoryUpdatesReceived, tr("Repository updates received.")); + return; + } + } + const QDomNodeList children = root.childNodes(); for (int i = 0; i < children.count(); ++i) { const QDomElement el = children.at(i).toElement(); @@ -293,10 +346,6 @@ void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished() m_packageVersions << c2.at(j).toElement().text(); else if (c2.at(j).toElement().tagName() == QLatin1String("SHA1")) m_packageHash << c2.at(j).toElement().text(); - } else if (el.tagName() == QLatin1String("RedirectUpdateUrl")) { // received a new URL for package download - m_repository.setUrl(QUrl(el.text())); // update the internal repo container - startUpdatesXmlDownload(); // ... and start over - return; } } |