source: calamares/trunk/fuentes/src/libcalamaresui/modulesystem/ProcessJobModule.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 16 months ago

sync with github

File size: 2.3 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, Teo Mrnjavac <teo@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "ProcessJobModule.h"
20
21#include "ProcessJob.h"
22
23#include <QDir>
24
25namespace Calamares {
26
27
28Module::Type
29ProcessJobModule::type() const
30{
31    return Job;
32}
33
34
35Module::Interface
36ProcessJobModule::interface() const
37{
38    return ProcessInterface;
39}
40
41
42void
43ProcessJobModule::loadSelf()
44{
45    if ( m_loaded )
46        return;
47
48    m_job = job_ptr( new ProcessJob( m_command,
49                                     m_workingPath,
50                                     m_runInChroot,
51                                     m_secondsTimeout ) );
52    m_loaded = true;
53}
54
55
56JobList
57ProcessJobModule::jobs() const
58{
59    return JobList() << m_job;
60}
61
62
63void
64ProcessJobModule::initFrom( const QVariantMap& moduleDescriptor )
65{
66    Module::initFrom( moduleDescriptor );
67    QDir directory( location() );
68    m_workingPath = directory.absolutePath();
69
70    if ( !moduleDescriptor.value( "command" ).toString().isEmpty() )
71    {
72        m_command = moduleDescriptor.value( "command" ).toString();
73    }
74
75    m_secondsTimeout = 30;
76    if ( moduleDescriptor.contains( "timeout" ) &&
77         !moduleDescriptor.value( "timeout" ).isNull() )
78    {
79        m_secondsTimeout = moduleDescriptor.value( "timeout" ).toInt();
80    }
81
82    m_runInChroot = false;
83    if ( moduleDescriptor.contains( "chroot" )&&
84         !moduleDescriptor.value( "chroot" ).isNull() )
85    {
86        m_runInChroot = moduleDescriptor.value( "chroot" ).toBool();
87    }
88}
89
90
91ProcessJobModule::ProcessJobModule()
92    : Module()
93    , m_secondsTimeout( 30 )
94    , m_runInChroot( false )
95{}
96
97
98ProcessJobModule::~ProcessJobModule()
99{}
100
101
102} // namespace Calamares
Note: See TracBrowser for help on using the repository browser.