1 /* === This file is part of Calamares - <https://calamares.io> ===
2  *
3  *   SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
4  *   SPDX-License-Identifier: GPL-3.0-or-later
5  *
6  *   Calamares is Free Software: see the License-Identifier above.
7  *
8  */
9 
10 #include "ProcessJobModule.h"
11 
12 #include "ProcessJob.h"
13 
14 #include <QDir>
15 
16 namespace Calamares
17 {
18 
19 
20 Module::Type
type() const21 ProcessJobModule::type() const
22 {
23     return Module::Type::Job;
24 }
25 
26 
27 Module::Interface
interface() const28 ProcessJobModule::interface() const
29 {
30     return Module::Interface::Process;
31 }
32 
33 
34 void
loadSelf()35 ProcessJobModule::loadSelf()
36 {
37     if ( m_loaded )
38     {
39         return;
40     }
41 
42     m_job = job_ptr( new ProcessJob( m_command, m_workingPath, m_runInChroot, m_secondsTimeout ) );
43     m_loaded = true;
44 }
45 
46 
47 JobList
jobs() const48 ProcessJobModule::jobs() const
49 {
50     return JobList() << m_job;
51 }
52 
53 
54 void
initFrom(const ModuleSystem::Descriptor & moduleDescriptor)55 ProcessJobModule::initFrom( const ModuleSystem::Descriptor& moduleDescriptor )
56 {
57     QDir directory( location() );
58     m_workingPath = directory.absolutePath();
59 
60     m_command = moduleDescriptor.command();
61     m_secondsTimeout = std::chrono::seconds( moduleDescriptor.timeout() );
62     m_runInChroot = moduleDescriptor.chroot();
63 }
64 
65 
ProcessJobModule()66 ProcessJobModule::ProcessJobModule()
67     : Module()
68     , m_secondsTimeout( std::chrono::seconds( 30 ) )
69     , m_runInChroot( false )
70 {
71 }
72 
73 
~ProcessJobModule()74 ProcessJobModule::~ProcessJobModule() {}
75 
76 
77 }  // namespace Calamares
78