Style: run modulesystem through the style guide

This commit is contained in:
Adriaan de Groot 2018-06-18 10:56:10 -04:00
parent 58121abf06
commit 1a097f8c49
10 changed files with 61 additions and 78 deletions

View File

@ -26,7 +26,8 @@
#include <QDir>
#include <QPluginLoader>
namespace Calamares {
namespace Calamares
{
Module::Type

View File

@ -71,8 +71,7 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
QString typeString = moduleDescriptor.value( "type" ).toString();
QString intfString = moduleDescriptor.value( "interface" ).toString();
if ( typeString.isEmpty() ||
intfString.isEmpty() )
if ( typeString.isEmpty() || intfString.isEmpty() )
{
cError() << "Bad module descriptor format" << instanceId;
return nullptr;
@ -80,9 +79,7 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
if ( ( typeString == "view" ) || ( typeString == "viewmodule" ) )
{
if ( intfString == "qtplugin" )
{
m.reset( new ViewModule() );
}
else if ( intfString == "pythonqt" )
{
#ifdef WITH_PYTHONQT
@ -97,13 +94,9 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
else if ( typeString == "job" )
{
if ( intfString == "qtplugin" )
{
m.reset( new CppJobModule() );
}
else if ( intfString == "process" )
{
m.reset( new ProcessJobModule() );
}
else if ( intfString == "python" )
{
#ifdef WITH_PYTHON
@ -168,8 +161,7 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex
{
configFilesByPriority.append(
QDir( QDir::currentPath() ).absoluteFilePath(
QString( "src/modules/%1/%2" ).arg( m_name )
.arg( configFileName ) ) );
QString( "src/modules/%1/%2" ).arg( m_name ).arg( configFileName ) ) );
}
configFilesByPriority.append(
@ -228,8 +220,7 @@ Module::instanceId() const
QString
Module::instanceKey() const
{
return QString( "%1@%2" ).arg( m_name )
.arg( m_instanceId );
return QString( "%1@%2" ).arg( m_name ).arg( m_instanceId );
}
@ -297,9 +288,7 @@ Module::initFrom( const QVariantMap& moduleDescriptor )
m_name = moduleDescriptor.value( "name" ).toString();
if ( moduleDescriptor.contains( EMERGENCY ) )
{
m_maybe_emergency = moduleDescriptor[ EMERGENCY ].toBool();
}
}
} //ns

View File

@ -147,7 +147,10 @@ public:
* @brief isLoaded reports on the loaded status of a module.
* @return true if the module's loading phase has finished, otherwise false.
*/
bool isLoaded() const { return m_loaded; }
bool isLoaded() const
{
return m_loaded;
}
/**
* @brief loadSelf initialized the module.
@ -164,7 +167,10 @@ public:
* are not run (in the common case where there is only
* one exec block, this doesn't really matter).
*/
bool isEmergency() const { return m_emergency; }
bool isEmergency() const
{
return m_emergency;
}
/**
* @brief jobs returns any jobs exposed by this module.

View File

@ -61,10 +61,8 @@ ModuleManager::~ModuleManager()
{
// The map is populated with Module::fromDescriptor(), which allocates on the heap.
for ( auto moduleptr : m_loadedModulesByInstanceKey )
{
delete moduleptr;
}
}
void
@ -124,10 +122,8 @@ ModuleManager::doInit()
}
}
else
{
cDebug() << "ModuleManager bad search path" << path;
}
}
// At this point m_availableModules is filled with whatever was found in the
// search paths.
checkDependencies();
@ -221,9 +217,7 @@ ModuleManager::loadModules()
int found = findCustomInstance( customInstances, moduleName, instanceId );
if ( found > -1 )
{
configFileName = customInstances[ found ].value( "config" );
}
else //ought to be a custom instance, but cannot find instance entry
{
cError() << "Custom instance" << moduleEntry << "not found in custom instances section.";
@ -254,9 +248,7 @@ ModuleManager::loadModules()
}
if ( thisModule && thisModule->isLoaded() )
{
cDebug() << "Module" << instanceKey << "already loaded.";
}
else
{
thisModule =

View File

@ -22,7 +22,8 @@
#include <QDir>
namespace Calamares {
namespace Calamares
{
Module::Type
@ -68,24 +69,18 @@ ProcessJobModule::initFrom( const QVariantMap& moduleDescriptor )
m_workingPath = directory.absolutePath();
if ( !moduleDescriptor.value( "command" ).toString().isEmpty() )
{
m_command = moduleDescriptor.value( "command" ).toString();
}
m_secondsTimeout = 30;
if ( moduleDescriptor.contains( "timeout" ) &&
!moduleDescriptor.value( "timeout" ).isNull() )
{
m_secondsTimeout = moduleDescriptor.value( "timeout" ).toInt();
}
m_runInChroot = false;
if ( moduleDescriptor.contains( "chroot" )&&
!moduleDescriptor.value( "chroot" ).isNull() )
{
m_runInChroot = moduleDescriptor.value( "chroot" ).toBool();
}
}
ProcessJobModule::ProcessJobModule()

View File

@ -23,7 +23,8 @@
#include <QDir>
namespace Calamares {
namespace Calamares
{
Module::Type
@ -46,9 +47,7 @@ PythonJobModule::loadSelf()
if ( m_loaded )
return;
m_job = Calamares::job_ptr( new PythonJob( m_scriptFileName,
m_workingPath,
m_configurationMap ) );
m_job = Calamares::job_ptr( new PythonJob( m_scriptFileName, m_workingPath, m_configurationMap ) );
m_loaded = true;
}
@ -68,10 +67,8 @@ PythonJobModule::initFrom( const QVariantMap& moduleDescriptor )
m_workingPath = directory.absolutePath();
if ( !moduleDescriptor.value( "script" ).toString().isEmpty() )
{
m_scriptFileName = moduleDescriptor.value( "script" ).toString();
}
}
PythonJobModule::PythonJobModule()

View File

@ -23,7 +23,8 @@
#include "UiDllMacro.h"
namespace Calamares {
namespace Calamares
{
class UIDLLEXPORT PythonJobModule : public Module
{

View File

@ -40,7 +40,8 @@
static QPointer< GlobalStorage > s_gs = nullptr;
static QPointer< Utils > s_utils = nullptr;
namespace Calamares {
namespace Calamares
{
Module::Type
PythonQtViewModule::type() const
@ -105,13 +106,14 @@ PythonQtViewModule::loadSelf()
[]( const QString& message )
{
cDebug() << "PythonQt OUT>" << message;
} );
}
);
QObject::connect( PythonQt::self(), &PythonQt::pythonStdErr,
[]( const QString& message )
{
cDebug() << "PythonQt ERR>" << message;
} );
}
);
}
QDir workingDir( m_workingPath );
@ -191,10 +193,8 @@ PythonQtViewModule::initFrom( const QVariantMap& moduleDescriptor )
m_workingPath = directory.absolutePath();
if ( !moduleDescriptor.value( "script" ).toString().isEmpty() )
{
m_scriptFileName = moduleDescriptor.value( "script" ).toString();
}
}
PythonQtViewModule::PythonQtViewModule()
: Module()

View File

@ -22,7 +22,8 @@
#include "UiDllMacro.h"
#include "Module.h"
namespace Calamares {
namespace Calamares
{
class ViewStep;

View File

@ -27,7 +27,8 @@
#include <QDir>
#include <QPluginLoader>
namespace Calamares {
namespace Calamares
{
Module::Type