[users] Move job-creation to Config
- this makes Config entirely stand-alone: it has all the business logic and can be hooked up to alternate UIs or used from other view steps or jobs
This commit is contained in:
parent
abae942e55
commit
2c72524f29
@ -20,6 +20,10 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "CreateUserJob.h"
|
||||
#include "SetHostNameJob.h"
|
||||
#include "SetPasswordJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "utils/Logger.h"
|
||||
@ -705,3 +709,31 @@ Config::finalizeGlobalStorage() const
|
||||
}
|
||||
gs->insert( "password", CalamaresUtils::obscure( userPassword() ) );
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
Config::createJobs() const
|
||||
{
|
||||
Calamares::JobList jobs;
|
||||
|
||||
if ( !isReady() )
|
||||
{
|
||||
return jobs;
|
||||
}
|
||||
|
||||
Calamares::Job* j;
|
||||
|
||||
j = new CreateUserJob(
|
||||
loginName(), fullName().isEmpty() ? loginName() : fullName(), doAutoLogin(), defaultGroups() );
|
||||
jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
j = new SetPasswordJob( loginName(), userPassword() );
|
||||
jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
j = new SetPasswordJob( "root", rootPassword() );
|
||||
jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
j = new SetHostNameJob( hostName(), hostNameActions() );
|
||||
jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "CheckPWQuality.h"
|
||||
|
||||
#include "Job.h"
|
||||
#include "utils/NamedEnum.h"
|
||||
|
||||
#include <QObject>
|
||||
@ -125,6 +126,12 @@ public:
|
||||
*/
|
||||
void finalizeGlobalStorage() const;
|
||||
|
||||
/** @brief Jobs for creating user, setting passwords
|
||||
*
|
||||
* If the Config object isn't ready yet, returns an empty list.
|
||||
*/
|
||||
Calamares::JobList createJobs() const;
|
||||
|
||||
/** @brief Full path to the user's shell executable
|
||||
*
|
||||
* Typically this will be /bin/bash, but it can be set from
|
||||
|
@ -21,9 +21,6 @@
|
||||
#include "UsersViewStep.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "CreateUserJob.h"
|
||||
#include "SetHostNameJob.h"
|
||||
#include "SetPasswordJob.h"
|
||||
#include "UsersPage.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
@ -120,30 +117,7 @@ UsersViewStep::onActivate()
|
||||
void
|
||||
UsersViewStep::onLeave()
|
||||
{
|
||||
m_jobs.clear();
|
||||
if ( !m_widget || !m_config->isReady() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Calamares::Job* j;
|
||||
// TODO: Config object should create jobs, like this one, that depend only on config values
|
||||
j = new CreateUserJob( m_config->loginName(),
|
||||
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
|
||||
m_config->doAutoLogin(),
|
||||
m_config->defaultGroups() );
|
||||
m_jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
j = new SetPasswordJob( m_config->loginName(), m_config->userPassword() );
|
||||
m_jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
j = new SetPasswordJob( "root", m_config->rootPassword() );
|
||||
m_jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
// TODO: Config object should create jobs
|
||||
j = new SetHostNameJob( m_config->hostName(), m_config->hostNameActions() );
|
||||
m_jobs.append( Calamares::job_ptr( j ) );
|
||||
|
||||
m_jobs = m_config->createJobs();
|
||||
m_config->finalizeGlobalStorage();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
UsersPage* m_widget;
|
||||
QList< Calamares::job_ptr > m_jobs;
|
||||
Calamares::JobList m_jobs;
|
||||
|
||||
Config* m_config;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user