@ -8,6 +8,7 @@
# include "Descriptor.h"
# include "utils/Logger.h"
# include "utils/Variant.h"
namespace Calamares
{
@ -57,9 +58,21 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
{
bool typeOk = false ;
Type t = typeNames ( ) . find ( moduleDesc . value ( " type " ) . toString ( ) , typeOk ) ;
QString typeValue = moduleDesc . value ( " type " ) . toString ( ) ;
Type t = typeNames ( ) . find ( typeValue , typeOk ) ;
if ( ! typeOk )
{
cWarning ( ) < < " Module descriptor contains invalid *type* " < < typeValue ;
}
bool interfaceOk = false ;
Interface i = interfaceNames ( ) . find ( moduleDesc . value ( " interface " ) . toString ( ) , interfaceOk ) ;
QString interfaceValue = moduleDesc . value ( " interface " ) . toString ( ) ;
Interface i = interfaceNames ( ) . find ( interfaceValue , interfaceOk ) ;
if ( ! interfaceOk )
{
cWarning ( ) < < " Module descriptor contains invalid *interface* " < < interfaceValue ;
}
d . m_name = moduleDesc . value ( " name " ) . toString ( ) ;
if ( typeOk & & interfaceOk & & ! d . m_name . isEmpty ( ) )
{
@ -73,6 +86,26 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
return d ;
}
d . m_isEmergeny = CalamaresUtils : : getBool ( moduleDesc , " emergency " , false ) ;
d . m_hasConfig = ! CalamaresUtils : : getBool ( moduleDesc , " noconfig " , false ) ; // Inverted logic during load
d . m_requiredModules = CalamaresUtils : : getStringList ( moduleDesc , " requiredModules " ) ;
QStringList consumedKeys { " type " , " interface " , " name " , " emergency " , " noconfig " , " requiredModules " } ;
QStringList superfluousKeys ;
for ( auto kv = moduleDesc . keyBegin ( ) ; kv ! = moduleDesc . keyEnd ( ) ; + + kv )
{
if ( ! consumedKeys . contains ( * kv ) )
{
superfluousKeys < < * kv ;
}
}
if ( ! superfluousKeys . isEmpty ( ) )
{
cWarning ( ) < < " Module descriptor contains extra keys: " < < Logger : : DebugList ( superfluousKeys ) ;
d . m_isValid = false ;
}
return d ;
}