2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2017-08-29 14:00:37 +02:00
|
|
|
*
|
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "TrackingViewStep.h"
|
|
|
|
|
2020-05-12 14:39:42 +02:00
|
|
|
#include "Config.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "TrackingJobs.h"
|
|
|
|
#include "TrackingPage.h"
|
|
|
|
|
2017-08-29 14:00:37 +02:00
|
|
|
#include "GlobalStorage.h"
|
2019-08-01 23:05:42 +02:00
|
|
|
#include "JobQueue.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
|
2017-11-08 15:35:49 +01:00
|
|
|
#include "utils/CalamaresUtilsSystem.h"
|
2019-08-01 23:05:42 +02:00
|
|
|
#include "utils/Logger.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "utils/Variant.h"
|
2017-08-29 14:00:37 +02:00
|
|
|
|
2017-11-08 13:46:33 +01:00
|
|
|
#include <QDesktopServices>
|
2017-08-29 14:00:37 +02:00
|
|
|
#include <QVariantMap>
|
|
|
|
|
2019-08-01 23:05:42 +02:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin< TrackingViewStep >(); )
|
2017-08-29 14:00:37 +02:00
|
|
|
|
2017-11-22 13:39:52 +01:00
|
|
|
/** @brief Is @p s a valid machine-tracking style. */
|
2019-08-01 23:05:42 +02:00
|
|
|
static bool
|
|
|
|
isValidStyle( const QString& s )
|
2017-11-22 13:39:52 +01:00
|
|
|
{
|
|
|
|
static QStringList knownStyles { "neon" };
|
|
|
|
return knownStyles.contains( s );
|
|
|
|
}
|
|
|
|
|
2017-08-29 14:00:37 +02:00
|
|
|
TrackingViewStep::TrackingViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
2020-05-12 14:39:42 +02:00
|
|
|
, m_config( new Config( this ) )
|
|
|
|
, m_widget( new TrackingPage( m_config ) )
|
2017-08-29 14:00:37 +02:00
|
|
|
{
|
|
|
|
emit nextStatusChanged( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TrackingViewStep::~TrackingViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
2019-08-01 23:05:42 +02:00
|
|
|
{
|
2017-08-29 14:00:37 +02:00
|
|
|
m_widget->deleteLater();
|
2019-08-01 23:05:42 +02:00
|
|
|
}
|
2017-08-29 14:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
TrackingViewStep::prettyName() const
|
|
|
|
{
|
2017-11-22 13:21:58 +01:00
|
|
|
return tr( "Feedback" );
|
2017-08-29 14:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
TrackingViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
TrackingViewStep::isNextEnabled() const
|
|
|
|
{
|
2017-11-06 16:12:41 +01:00
|
|
|
return true;
|
2017-08-29 14:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
TrackingViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
TrackingViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
TrackingViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-01 23:05:42 +02:00
|
|
|
void
|
|
|
|
TrackingViewStep::onLeave()
|
2017-11-08 10:25:36 +01:00
|
|
|
{
|
2020-05-18 20:18:34 +02:00
|
|
|
cDebug() << "Install tracking:" << m_config->installTracking()->isEnabled();
|
|
|
|
cDebug() << "Machine tracking:" << m_config->machineTracking()->isEnabled();
|
|
|
|
cDebug() << " User tracking:" << m_config->userTracking()->isEnabled();
|
2017-11-08 10:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-08 15:59:40 +01:00
|
|
|
Calamares::JobList
|
2017-08-29 14:00:37 +02:00
|
|
|
TrackingViewStep::jobs() const
|
|
|
|
{
|
2017-11-08 15:59:40 +01:00
|
|
|
Calamares::JobList l;
|
|
|
|
|
|
|
|
cDebug() << "Creating tracking jobs ..";
|
2020-05-18 20:18:34 +02:00
|
|
|
if ( m_config->installTracking()->isEnabled() )
|
2017-11-08 15:35:49 +01:00
|
|
|
{
|
2020-05-18 20:18:34 +02:00
|
|
|
QString installUrl = m_config->installTracking()->installTrackingUrl();
|
|
|
|
const auto* s = CalamaresUtils::System::instance();
|
2017-11-08 15:35:49 +01:00
|
|
|
|
|
|
|
QString memory, disk;
|
|
|
|
memory.setNum( s->getTotalMemoryB().first );
|
|
|
|
disk.setNum( s->getTotalDiskB() );
|
|
|
|
|
2019-08-01 23:05:42 +02:00
|
|
|
installUrl.replace( "$CPU", s->getCpuDescription() ).replace( "$MEMORY", memory ).replace( "$DISK", disk );
|
2017-11-08 15:35:49 +01:00
|
|
|
|
2019-04-15 14:59:12 +02:00
|
|
|
cDebug() << Logger::SubEntry << "install-tracking URL" << installUrl;
|
2017-11-09 11:45:25 +01:00
|
|
|
|
|
|
|
l.append( Calamares::job_ptr( new TrackingInstallJob( installUrl ) ) );
|
2017-11-08 15:35:49 +01:00
|
|
|
}
|
2017-11-22 13:39:52 +01:00
|
|
|
|
2020-05-18 20:18:34 +02:00
|
|
|
if ( m_config->machineTracking()->isEnabled() )
|
2017-11-22 13:39:52 +01:00
|
|
|
{
|
2020-05-18 20:18:34 +02:00
|
|
|
const auto style = m_config->machineTracking()->machineTrackingStyle();
|
|
|
|
if ( style == "neon" )
|
2019-08-01 23:05:42 +02:00
|
|
|
{
|
2017-11-22 13:39:52 +01:00
|
|
|
l.append( Calamares::job_ptr( new TrackingMachineNeonJob() ) );
|
2019-08-01 23:05:42 +02:00
|
|
|
}
|
2020-05-18 20:18:34 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
cWarning() << "Unsupported machine tracking style" << style;
|
|
|
|
}
|
2017-11-22 13:39:52 +01:00
|
|
|
}
|
2017-11-08 15:59:40 +01:00
|
|
|
return l;
|
2017-08-29 14:00:37 +02:00
|
|
|
}
|
|
|
|
|
2017-11-06 16:12:41 +01:00
|
|
|
|
2017-08-29 14:00:37 +02:00
|
|
|
void
|
|
|
|
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2020-05-12 14:39:42 +02:00
|
|
|
m_config->setConfigurationMap( configurationMap );
|
|
|
|
|
2020-05-12 11:41:02 +02:00
|
|
|
bool ok;
|
2020-05-12 14:39:42 +02:00
|
|
|
m_widget->setTrackingLevel( trackingNames().find( CalamaresUtils::getString( configurationMap, "default" ), ok ) );
|
2020-05-12 11:41:02 +02:00
|
|
|
if ( !ok )
|
|
|
|
{
|
|
|
|
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );
|
|
|
|
}
|
2017-08-29 14:00:37 +02:00
|
|
|
}
|
2020-05-12 11:22:25 +02:00
|
|
|
|
|
|
|
const NamedEnumTable< TrackingType >&
|
|
|
|
trackingNames()
|
|
|
|
{
|
|
|
|
// *INDENT-OFF*
|
|
|
|
// clang-format off
|
|
|
|
static const NamedEnumTable< TrackingType > names {
|
|
|
|
{ QStringLiteral( "none" ), TrackingType::NoTracking },
|
|
|
|
{ QStringLiteral( "install" ), TrackingType::InstallTracking },
|
|
|
|
{ QStringLiteral( "machine" ), TrackingType::MachineTracking },
|
|
|
|
{ QStringLiteral( "user" ), TrackingType::UserTracking }
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
// *INDENT-ON*
|
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|