4
0
mirror of https://github.com/QuasarApp/installer-framework.git synced 2025-05-08 19:19:33 +00:00

Add signal to inform about unstable components

Task-number: QTIFW-1197
Change-Id: If9d7941f4c7bfc478daa83dcd73dfa71c9163561
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
This commit is contained in:
Katja Marttila 2018-09-24 10:10:56 +03:00
parent 2e42e53520
commit 0e9909532f
7 changed files with 32 additions and 9 deletions

@ -7,4 +7,5 @@
<StartMenuDir>Qt IFW Examples</StartMenuDir>
<TargetDir>@HomeDir@/IfwExamples/unstablecomponent</TargetDir>
<AllowUnstableComponents>true</AllowUnstableComponents>
<ControlScript>controller.qs</ControlScript>
</Installer>

@ -0,0 +1,10 @@
function Controller() {
installer.unstableComponentFound.connect(unstableComponentFound)
}
unstableComponentFound = function(type, message, comp)
{
console.log("Unstable component, type: " + type)
console.log("Unstable component, message: " + message)
console.log("Unstable component, name: " + comp)
}

@ -524,12 +524,12 @@ void Component::loadComponentScript(const QString &fileName)
Component *dependencyComponent = packageManagerCore()->componentByName
(PackageManagerCore::checkableName(dependency));
if (dependencyComponent && dependencyComponent->isUnstable())
setUnstable();
setUnstable(PackageManagerCore::UnstableError::DepencyToUnstable, QLatin1String("Dependent on unstable component"));
}
}
} catch (const Error &error) {
if (packageManagerCore()->settings().allowUnstableComponents()) {
setUnstable();
setUnstable(PackageManagerCore::UnstableError::ScriptLoadingFailed, error.message());
qWarning() << error.message();
} else {
throw error;
@ -1380,7 +1380,7 @@ bool Component::isUnstable() const
return scTrue == d->m_vars.value(scUnstable);
}
void Component::setUnstable()
void Component::setUnstable(PackageManagerCore::UnstableError error, const QString &errorMessage)
{
QList<Component*> dependencies = d->m_core->dependees(this);
// Mark this component unstable
@ -1398,6 +1398,8 @@ void Component::setUnstable()
foreach (Component *descendant, this->descendantComponents()) {
descendant->markComponentUnstable();
}
QMetaEnum metaEnum = QMetaEnum::fromType<PackageManagerCore::UnstableError>();
emit packageManagerCore()->unstableComponentFound(QLatin1String(metaEnum.valueToKey(error)), errorMessage, this->name());
}
/*!

@ -32,6 +32,7 @@
#include "constants.h"
#include "component_p.h"
#include "qinstallerglobal.h"
#include "packagemanagercore.h"
#include <QtCore/QDir>
#include <QtCore/QMetaType>
@ -43,8 +44,6 @@ QT_FORWARD_DECLARE_CLASS(QQmlV4Function)
namespace QInstaller {
class PackageManagerCore;
class INSTALLER_EXPORT Component : public QObject, public ComponentModelHelper
{
Q_OBJECT
@ -184,7 +183,7 @@ public:
Q_INVOKABLE bool componentChangeRequested();
bool isUnstable() const;
void setUnstable();
void setUnstable(PackageManagerCore::UnstableError error, const QString &errorMessage = QString());
bool isVirtual() const;
bool isSelected() const;

@ -171,7 +171,7 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q
qWarning().noquote() << errorMessage;
m_componentsToInstallError.append(errorMessage);
if (component->packageManagerCore()->settings().allowUnstableComponents()) {
component->setUnstable();
component->setUnstable(PackageManagerCore::UnstableError::MissingDependency, errorMessage);
continue;
} else {
return false;

@ -2575,8 +2575,10 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo
// Check if there are sha checksum mismatch. Component will still show in install tree
// but is unselectable.
foreach (const QString packageName, d->m_metadataJob.shaMismatchPackages()) {
if (packageName == component->name())
component->setUnstable();
if (packageName == component->name()) {
QString errorString = QLatin1String("SHA mismatch detected for component ") + packageName;
component->setUnstable(PackageManagerCore::UnstableError::ShaMismatch, errorString);
}
}
}

@ -65,6 +65,14 @@ public:
Protocol::Mode mode = Protocol::Mode::Production);
~PackageManagerCore();
enum UnstableError {
DepencyToUnstable = 0,
ShaMismatch,
ScriptLoadingFailed,
MissingDependency
};
Q_ENUM(UnstableError)
// status
enum Status {
Success = EXIT_SUCCESS,
@ -323,6 +331,7 @@ Q_SIGNALS:
void coreNetworkSettingsChanged();
void guiObjectChanged(QObject *gui);
void unstableComponentFound(const QString &type, const QString &errorMessage, const QString &component);
private:
struct Data {