2016-06-26 00:26:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
2016-06-28 00:00:47 +02:00
|
|
|
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
2017-01-25 09:34:18 +01:00
|
|
|
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
2020-02-18 17:40:15 +01:00
|
|
|
* Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
|
2016-06-26 00:26:08 +02:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "NetInstallViewStep.h"
|
|
|
|
|
|
|
|
#include "GlobalStorage.h"
|
2020-02-18 11:02:53 +01:00
|
|
|
#include "JobQueue.h"
|
2018-05-21 16:49:47 +02:00
|
|
|
|
2016-06-26 00:26:08 +02:00
|
|
|
#include "utils/Logger.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "utils/Variant.h"
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
#include "NetInstallPage.h"
|
|
|
|
|
2020-02-18 11:02:53 +01:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin< NetInstallViewStep >(); )
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
|
|
|
, m_widget( new NetInstallPage() )
|
2020-02-18 17:46:56 +01:00
|
|
|
, m_sidebarLabel( nullptr )
|
2020-03-27 15:51:03 +01:00
|
|
|
, m_nextEnabled( false )
|
2016-06-26 00:26:08 +02:00
|
|
|
{
|
|
|
|
emit nextStatusChanged( true );
|
2020-02-18 11:02:53 +01:00
|
|
|
connect( m_widget, &NetInstallPage::checkReady, this, &NetInstallViewStep::nextIsReady );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetInstallViewStep::~NetInstallViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2016-06-26 00:26:08 +02:00
|
|
|
m_widget->deleteLater();
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2020-02-18 17:46:56 +01:00
|
|
|
delete m_sidebarLabel;
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
NetInstallViewStep::prettyName() const
|
|
|
|
{
|
2020-02-18 17:46:56 +01:00
|
|
|
return m_sidebarLabel ? m_sidebarLabel->get() : tr( "Package selection" );
|
2020-02-19 14:37:47 +01:00
|
|
|
|
2020-03-23 14:10:48 +01:00
|
|
|
#if defined( TABLE_OF_TRANSLATIONS )
|
2020-02-19 17:21:12 +01:00
|
|
|
NOTREACHED
|
2020-02-19 14:37:47 +01:00
|
|
|
// This is a table of "standard" labels for this module. If you use them
|
|
|
|
// in the label: sidebar: section of the config file, the existing
|
|
|
|
// translations can be used.
|
|
|
|
tr( "Package selection" );
|
|
|
|
tr( "Office software" );
|
|
|
|
tr( "Office package" );
|
|
|
|
tr( "Browser software" );
|
|
|
|
tr( "Browser package" );
|
|
|
|
tr( "Web browser" );
|
2020-02-19 17:21:12 +01:00
|
|
|
tr( "Kernel" );
|
|
|
|
tr( "Services" );
|
|
|
|
tr( "Login" );
|
|
|
|
tr( "Desktop" );
|
|
|
|
tr( "Applications" );
|
|
|
|
#endif
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
NetInstallViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return m_nextEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-27 15:14:37 +01:00
|
|
|
Calamares::JobList
|
2016-06-26 00:26:08 +02:00
|
|
|
NetInstallViewStep::jobs() const
|
|
|
|
{
|
2020-03-27 15:14:37 +01:00
|
|
|
return Calamares::JobList();
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onActivate()
|
|
|
|
{
|
|
|
|
m_widget->onActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onLeave()
|
|
|
|
{
|
2020-03-27 15:51:03 +01:00
|
|
|
auto packages = m_config.model()->getPackages();
|
2020-02-18 11:28:42 +01:00
|
|
|
cDebug() << "Netinstall: Processing" << packages.length() << "packages.";
|
|
|
|
|
|
|
|
static const char PACKAGEOP[] = "packageOperations";
|
|
|
|
|
|
|
|
// Check if there's already a PACAKGEOP entry in GS, and if so we'll
|
|
|
|
// extend that one (overwriting the value in GS at the end of this method)
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList();
|
|
|
|
cDebug() << Logger::SubEntry << "Existing package operations length" << packageOperations.length();
|
|
|
|
|
2020-02-18 14:46:00 +01:00
|
|
|
// Clear out existing operations for this module, going backwards:
|
|
|
|
// Sometimes we remove an item, and we don't want the index to
|
|
|
|
// fall off the end of the list.
|
2020-02-18 17:37:58 +01:00
|
|
|
for ( int index = packageOperations.length() - 1; 0 <= index; index-- )
|
2020-02-18 14:46:00 +01:00
|
|
|
{
|
2020-02-18 17:37:58 +01:00
|
|
|
const QVariantMap op = packageOperations.at( index ).toMap();
|
2020-02-18 14:46:00 +01:00
|
|
|
if ( op.contains( "source" ) && op.value( "source" ).toString() == moduleInstanceKey().toString() )
|
|
|
|
{
|
|
|
|
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
|
|
|
|
packageOperations.removeAt( index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 11:28:42 +01:00
|
|
|
// This netinstall module may add two sub-steps to the packageOperations,
|
|
|
|
// one for installing and one for try-installing.
|
2017-01-25 09:34:18 +01:00
|
|
|
QVariantList installPackages;
|
|
|
|
QVariantList tryInstallPackages;
|
|
|
|
|
2020-02-18 11:40:43 +01:00
|
|
|
for ( const auto& package : packages )
|
2017-01-25 09:34:18 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
if ( package->isCritical() )
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
installPackages.append( package->toOperation() );
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2017-01-25 09:34:18 +01:00
|
|
|
else
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
tryInstallPackages.append( package->toOperation() );
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2017-01-25 09:34:18 +01:00
|
|
|
}
|
2016-11-12 18:57:58 +01:00
|
|
|
|
2017-01-23 13:42:40 +01:00
|
|
|
if ( !installPackages.empty() )
|
2017-10-23 17:10:18 +02:00
|
|
|
{
|
2020-02-18 14:18:48 +01:00
|
|
|
QVariantMap op;
|
2017-10-23 17:10:18 +02:00
|
|
|
op.insert( "install", QVariant( installPackages ) );
|
2020-02-18 14:18:48 +01:00
|
|
|
op.insert( "source", moduleInstanceKey().toString() );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2019-04-15 14:59:12 +02:00
|
|
|
cDebug() << Logger::SubEntry << installPackages.length() << "critical packages.";
|
2017-10-23 17:10:18 +02:00
|
|
|
}
|
2017-01-23 13:42:40 +01:00
|
|
|
if ( !tryInstallPackages.empty() )
|
2017-10-23 17:10:18 +02:00
|
|
|
{
|
2020-02-18 14:18:48 +01:00
|
|
|
QVariantMap op;
|
2017-10-23 17:10:18 +02:00
|
|
|
op.insert( "try_install", QVariant( tryInstallPackages ) );
|
2020-02-18 14:18:48 +01:00
|
|
|
op.insert( "source", moduleInstanceKey().toString() );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2019-04-15 14:59:12 +02:00
|
|
|
cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages.";
|
2017-10-23 17:10:18 +02:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
|
2017-10-23 17:10:18 +02:00
|
|
|
if ( !packageOperations.isEmpty() )
|
2017-01-23 13:42:40 +01:00
|
|
|
{
|
2020-02-18 11:28:42 +01:00
|
|
|
gs->insert( PACKAGEOP, packageOperations );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 17:59:34 +01:00
|
|
|
void
|
|
|
|
NetInstallViewStep::nextIsReady( bool b )
|
|
|
|
{
|
|
|
|
m_nextEnabled = b;
|
|
|
|
emit nextStatusChanged( b );
|
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2020-03-27 15:51:03 +01:00
|
|
|
m_config.setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) );
|
|
|
|
m_widget->setModel( m_config.model() );
|
2017-11-06 11:14:42 +01:00
|
|
|
|
2018-05-21 16:49:47 +02:00
|
|
|
QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" );
|
|
|
|
if ( !groupsUrl.isEmpty() )
|
2016-06-26 00:26:08 +02:00
|
|
|
{
|
2018-05-21 16:58:57 +02:00
|
|
|
// Keep putting groupsUrl into the global storage,
|
|
|
|
// even though it's no longer used for in-module data-passing.
|
2018-05-21 16:49:47 +02:00
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
2020-03-23 23:08:31 +01:00
|
|
|
if ( groupsUrl == QStringLiteral( "local" ) )
|
|
|
|
{
|
|
|
|
QVariantList l = configurationMap.value( "groups" ).toList();
|
2020-03-27 15:51:03 +01:00
|
|
|
m_config.loadGroupList( l );
|
2020-03-23 23:08:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-27 15:51:03 +01:00
|
|
|
m_config.loadGroupList( groupsUrl );
|
2020-03-23 23:08:31 +01:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
2017-11-06 11:14:42 +01:00
|
|
|
|
2020-02-18 17:59:34 +01:00
|
|
|
bool bogus = false;
|
|
|
|
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
|
|
|
|
|
|
|
if ( label.contains( "sidebar" ) )
|
|
|
|
{
|
2020-02-19 14:09:04 +01:00
|
|
|
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", metaObject()->className() );
|
2020-02-18 17:59:34 +01:00
|
|
|
}
|
|
|
|
if ( label.contains( "title" ) )
|
|
|
|
{
|
2020-02-19 14:37:47 +01:00
|
|
|
m_widget->setPageTitle(
|
|
|
|
new CalamaresUtils::Locale::TranslatedString( label, "title", metaObject()->className() ) );
|
2020-02-18 17:59:34 +01:00
|
|
|
}
|
2017-11-06 11:14:42 +01:00
|
|
|
}
|