[tracking] Apply current coding style
This commit is contained in:
parent
e3ecb083a0
commit
5183200515
@ -38,22 +38,26 @@ TrackingInstallJob::~TrackingInstallJob()
|
|||||||
delete m_networkManager;
|
delete m_networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingInstallJob::prettyName() const
|
QString
|
||||||
|
TrackingInstallJob::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Installation feedback" );
|
return tr( "Installation feedback" );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingInstallJob::prettyDescription() const
|
QString
|
||||||
|
TrackingInstallJob::prettyDescription() const
|
||||||
{
|
{
|
||||||
return prettyName();
|
return prettyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingInstallJob::prettyStatusMessage() const
|
QString
|
||||||
|
TrackingInstallJob::prettyStatusMessage() const
|
||||||
{
|
{
|
||||||
return tr( "Sending installation feedback." );
|
return tr( "Sending installation feedback." );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult TrackingInstallJob::exec()
|
Calamares::JobResult
|
||||||
|
TrackingInstallJob::exec()
|
||||||
{
|
{
|
||||||
m_networkManager = new QNetworkAccessManager();
|
m_networkManager = new QNetworkAccessManager();
|
||||||
|
|
||||||
@ -70,12 +74,9 @@ Calamares::JobResult TrackingInstallJob::exec()
|
|||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
|
|
||||||
connect( m_networkManager, &QNetworkAccessManager::finished,
|
connect( m_networkManager, &QNetworkAccessManager::finished, this, &TrackingInstallJob::dataIsHere );
|
||||||
this, &TrackingInstallJob::dataIsHere );
|
connect( m_networkManager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit );
|
||||||
connect( m_networkManager, &QNetworkAccessManager::finished,
|
connect( &timeout, &QTimer::timeout, &loop, &QEventLoop::quit );
|
||||||
&loop, &QEventLoop::quit );
|
|
||||||
connect( &timeout, &QTimer::timeout,
|
|
||||||
&loop, &QEventLoop::quit );
|
|
||||||
|
|
||||||
m_networkManager->get( request ); // The semaphore is released when data is received
|
m_networkManager->get( request ); // The semaphore is released when data is received
|
||||||
timeout.start( 5000 /* ms */ );
|
timeout.start( 5000 /* ms */ );
|
||||||
@ -93,31 +94,35 @@ Calamares::JobResult TrackingInstallJob::exec()
|
|||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackingInstallJob::dataIsHere( QNetworkReply* reply )
|
void
|
||||||
|
TrackingInstallJob::dataIsHere( QNetworkReply* reply )
|
||||||
{
|
{
|
||||||
cDebug() << "Installation feedback request OK";
|
cDebug() << "Installation feedback request OK";
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingMachineNeonJob::prettyName() const
|
QString
|
||||||
|
TrackingMachineNeonJob::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Machine feedback" );
|
return tr( "Machine feedback" );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingMachineNeonJob::prettyDescription() const
|
QString
|
||||||
|
TrackingMachineNeonJob::prettyDescription() const
|
||||||
{
|
{
|
||||||
return prettyName();
|
return prettyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TrackingMachineNeonJob::prettyStatusMessage() const
|
QString
|
||||||
|
TrackingMachineNeonJob::prettyStatusMessage() const
|
||||||
{
|
{
|
||||||
return tr( "Configuring machine feedback." );
|
return tr( "Configuring machine feedback." );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult TrackingMachineNeonJob::exec()
|
Calamares::JobResult
|
||||||
|
TrackingMachineNeonJob::exec()
|
||||||
{
|
{
|
||||||
int r = CalamaresUtils::System::instance()->targetEnvCall(
|
int r = CalamaresUtils::System::instance()->targetEnvCall( "/bin/sh",
|
||||||
"/bin/sh",
|
|
||||||
QString(), // Working dir
|
QString(), // Working dir
|
||||||
QString(
|
QString(
|
||||||
R"x(MACHINE_ID=`cat /etc/machine-id`
|
R"x(MACHINE_ID=`cat /etc/machine-id`
|
||||||
@ -130,9 +135,11 @@ true
|
|||||||
if ( r == 0 )
|
if ( r == 0 )
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
else if ( r > 0 )
|
else if ( r > 0 )
|
||||||
return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ),
|
return Calamares::JobResult::error(
|
||||||
|
tr( "Error in machine feedback configuration." ),
|
||||||
tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) );
|
tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) );
|
||||||
else
|
else
|
||||||
return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ),
|
return Calamares::JobResult::error(
|
||||||
|
tr( "Error in machine feedback configuration." ),
|
||||||
tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) );
|
tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) );
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
#include "ui_page_trackingstep.h"
|
#include "ui_page_trackingstep.h"
|
||||||
|
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
|
||||||
#include "utils/Retranslator.h"
|
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@ -40,12 +40,20 @@ TrackingPage::TrackingPage(QWidget *parent)
|
|||||||
|
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE(
|
||||||
ui->retranslateUi( this );
|
ui->retranslateUi( this ); ui->generalExplanation->setText(
|
||||||
ui->generalExplanation->setText( tr( "Install tracking helps %1 to see how many users they have, what hardware they install %1 to and (with the last two options below), get continuous information about preferred applications. To see what will be sent, please click the help icon next to each area." ).arg( *StringEntry::ShortProductName ) );
|
tr( "Install tracking helps %1 to see how many users they have, what hardware they install %1 to and (with "
|
||||||
ui->installExplanation->setText( tr( "By selecting this you will send information about your installation and hardware. This information will <b>only be sent once</b> after the installation finishes." ) );
|
"the last two options below), get continuous information about preferred applications. To see what "
|
||||||
ui->machineExplanation->setText( tr( "By selecting this you will <b>periodically</b> send information about your installation, hardware and applications, to %1." ).arg( *StringEntry::ShortProductName ) );
|
"will be sent, please click the help icon next to each area." )
|
||||||
ui->userExplanation->setText( tr( "By selecting this you will <b>regularly</b> send information about your installation, hardware, applications and usage patterns, to %1." ).arg( *StringEntry::ShortProductName ) );
|
.arg( *StringEntry::ShortProductName ) );
|
||||||
)
|
ui->installExplanation->setText(
|
||||||
|
tr( "By selecting this you will send information about your installation and hardware. This information "
|
||||||
|
"will <b>only be sent once</b> after the installation finishes." ) );
|
||||||
|
ui->machineExplanation->setText( tr( "By selecting this you will <b>periodically</b> send information about "
|
||||||
|
"your installation, hardware and applications, to %1." )
|
||||||
|
.arg( *StringEntry::ShortProductName ) );
|
||||||
|
ui->userExplanation->setText( tr( "By selecting this you will <b>regularly</b> send information about your "
|
||||||
|
"installation, hardware, applications and usage patterns, to %1." )
|
||||||
|
.arg( *StringEntry::ShortProductName ) ); )
|
||||||
|
|
||||||
QButtonGroup* group = new QButtonGroup( this );
|
QButtonGroup* group = new QButtonGroup( this );
|
||||||
group->setExclusive( true );
|
group->setExclusive( true );
|
||||||
@ -56,7 +64,8 @@ TrackingPage::TrackingPage(QWidget *parent)
|
|||||||
ui->noneRadio->setChecked( true );
|
ui->noneRadio->setChecked( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackingPage::enableTrackingOption(TrackingType t, bool enabled)
|
void
|
||||||
|
TrackingPage::enableTrackingOption( TrackingType t, bool enabled )
|
||||||
{
|
{
|
||||||
QWidget* group = nullptr;
|
QWidget* group = nullptr;
|
||||||
|
|
||||||
@ -76,15 +85,22 @@ void TrackingPage::enableTrackingOption(TrackingType t, bool enabled)
|
|||||||
if ( group != nullptr )
|
if ( group != nullptr )
|
||||||
{
|
{
|
||||||
if ( enabled )
|
if ( enabled )
|
||||||
|
{
|
||||||
group->show();
|
group->show();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
group->hide();
|
group->hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cWarning() << "unknown tracking option" << int( t );
|
cWarning() << "unknown tracking option" << int( t );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TrackingPage::getTrackingOption(TrackingType t)
|
bool
|
||||||
|
TrackingPage::getTrackingOption( TrackingType t )
|
||||||
{
|
{
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
|
||||||
@ -107,7 +123,8 @@ bool TrackingPage::getTrackingOption(TrackingType t)
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackingPage::setTrackingPolicy(TrackingType t, QString url)
|
void
|
||||||
|
TrackingPage::setTrackingPolicy( TrackingType t, QString url )
|
||||||
{
|
{
|
||||||
QToolButton* button = nullptr;
|
QToolButton* button = nullptr;
|
||||||
switch ( t )
|
switch ( t )
|
||||||
@ -125,20 +142,27 @@ void TrackingPage::setTrackingPolicy(TrackingType t, QString url)
|
|||||||
|
|
||||||
if ( button != nullptr )
|
if ( button != nullptr )
|
||||||
if ( url.isEmpty() )
|
if ( url.isEmpty() )
|
||||||
|
{
|
||||||
button->hide();
|
button->hide();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
connect( button, &QToolButton::clicked, [url] { QDesktopServices::openUrl( url ); } );
|
connect( button, &QToolButton::clicked, [url] { QDesktopServices::openUrl( url ); } );
|
||||||
cDebug() << "Tracking policy" << int( t ) << "set to" << url;
|
cDebug() << "Tracking policy" << int( t ) << "set to" << url;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cWarning() << "unknown tracking option" << int( t );
|
cWarning() << "unknown tracking option" << int( t );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrackingPage::setGeneralPolicy( QString url )
|
void
|
||||||
|
TrackingPage::setGeneralPolicy( QString url )
|
||||||
{
|
{
|
||||||
if ( url.isEmpty() )
|
if ( url.isEmpty() )
|
||||||
|
{
|
||||||
ui->generalPolicyLabel->hide();
|
ui->generalPolicyLabel->hide();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->generalPolicyLabel->show();
|
ui->generalPolicyLabel->show();
|
||||||
@ -148,22 +172,35 @@ void TrackingPage::setGeneralPolicy( QString url )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackingPage::setTrackingLevel(const QString& l)
|
void
|
||||||
|
TrackingPage::setTrackingLevel( const QString& l )
|
||||||
{
|
{
|
||||||
QString level = l.toLower();
|
QString level = l.toLower();
|
||||||
QRadioButton* button = nullptr;
|
QRadioButton* button = nullptr;
|
||||||
|
|
||||||
if ( level.isEmpty() || level == "none" )
|
if ( level.isEmpty() || level == "none" )
|
||||||
|
{
|
||||||
button = ui->noneRadio;
|
button = ui->noneRadio;
|
||||||
|
}
|
||||||
else if ( level == "install" )
|
else if ( level == "install" )
|
||||||
|
{
|
||||||
button = ui->installRadio;
|
button = ui->installRadio;
|
||||||
|
}
|
||||||
else if ( level == "machine" )
|
else if ( level == "machine" )
|
||||||
|
{
|
||||||
button = ui->machineRadio;
|
button = ui->machineRadio;
|
||||||
|
}
|
||||||
else if ( level == "user" )
|
else if ( level == "user" )
|
||||||
|
{
|
||||||
button = ui->userRadio;
|
button = ui->userRadio;
|
||||||
|
}
|
||||||
|
|
||||||
if ( button != nullptr )
|
if ( button != nullptr )
|
||||||
|
{
|
||||||
button->setChecked( true );
|
button->setChecked( true );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cWarning() << "unknown default tracking level" << l;
|
cWarning() << "unknown default tracking level" << l;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
#include "TrackingType.h"
|
#include "TrackingType.h"
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
#include "TrackingJobs.h"
|
#include "TrackingJobs.h"
|
||||||
#include "TrackingPage.h"
|
#include "TrackingPage.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@ -34,7 +34,8 @@
|
|||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin< TrackingViewStep >(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin< TrackingViewStep >(); )
|
||||||
|
|
||||||
/** @brief Is @p s a valid machine-tracking style. */
|
/** @brief Is @p s a valid machine-tracking style. */
|
||||||
static bool isValidStyle( const QString& s )
|
static bool
|
||||||
|
isValidStyle( const QString& s )
|
||||||
{
|
{
|
||||||
static QStringList knownStyles { "neon" };
|
static QStringList knownStyles { "neon" };
|
||||||
return knownStyles.contains( s );
|
return knownStyles.contains( s );
|
||||||
@ -51,8 +52,10 @@ TrackingViewStep::TrackingViewStep( QObject* parent )
|
|||||||
TrackingViewStep::~TrackingViewStep()
|
TrackingViewStep::~TrackingViewStep()
|
||||||
{
|
{
|
||||||
if ( m_widget && m_widget->parent() == nullptr )
|
if ( m_widget && m_widget->parent() == nullptr )
|
||||||
|
{
|
||||||
m_widget->deleteLater();
|
m_widget->deleteLater();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -97,7 +100,8 @@ TrackingViewStep::isAtEnd() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackingViewStep::onLeave()
|
void
|
||||||
|
TrackingViewStep::onLeave()
|
||||||
{
|
{
|
||||||
m_installTracking.userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking );
|
m_installTracking.userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking );
|
||||||
m_machineTracking.userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking );
|
m_machineTracking.userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking );
|
||||||
@ -123,10 +127,7 @@ TrackingViewStep::jobs() const
|
|||||||
memory.setNum( s->getTotalMemoryB().first );
|
memory.setNum( s->getTotalMemoryB().first );
|
||||||
disk.setNum( s->getTotalDiskB() );
|
disk.setNum( s->getTotalDiskB() );
|
||||||
|
|
||||||
installUrl
|
installUrl.replace( "$CPU", s->getCpuDescription() ).replace( "$MEMORY", memory ).replace( "$DISK", disk );
|
||||||
.replace( "$CPU", s->getCpuDescription() )
|
|
||||||
.replace( "$MEMORY", memory )
|
|
||||||
.replace( "$DISK", disk );
|
|
||||||
|
|
||||||
cDebug() << Logger::SubEntry << "install-tracking URL" << installUrl;
|
cDebug() << Logger::SubEntry << "install-tracking URL" << installUrl;
|
||||||
|
|
||||||
@ -137,13 +138,16 @@ TrackingViewStep::jobs() const
|
|||||||
{
|
{
|
||||||
Q_ASSERT( isValidStyle( m_machineTrackingStyle ) );
|
Q_ASSERT( isValidStyle( m_machineTrackingStyle ) );
|
||||||
if ( m_machineTrackingStyle == "neon" )
|
if ( m_machineTrackingStyle == "neon" )
|
||||||
|
{
|
||||||
l.append( Calamares::job_ptr( new TrackingMachineNeonJob() ) );
|
l.append( Calamares::job_ptr( new TrackingMachineNeonJob() ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t)
|
QVariantMap
|
||||||
|
TrackingViewStep::setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t )
|
||||||
{
|
{
|
||||||
bool settingEnabled = false;
|
bool settingEnabled = false;
|
||||||
|
|
||||||
@ -176,7 +180,9 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
config = setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
config = setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
||||||
auto s = CalamaresUtils::getString( config, "style" );
|
auto s = CalamaresUtils::getString( config, "style" );
|
||||||
if ( isValidStyle( s ) )
|
if ( isValidStyle( s ) )
|
||||||
|
{
|
||||||
m_machineTrackingStyle = s;
|
m_machineTrackingStyle = s;
|
||||||
|
}
|
||||||
|
|
||||||
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
#include "TrackingType.h"
|
#include "TrackingType.h"
|
||||||
|
|
||||||
|
#include <PluginDllMacro.h>
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
#include <PluginDllMacro.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@ -70,7 +70,8 @@ private:
|
|||||||
TrackingEnabled()
|
TrackingEnabled()
|
||||||
: settingEnabled( false )
|
: settingEnabled( false )
|
||||||
, userEnabled( false )
|
, userEnabled( false )
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool enabled() const { return settingEnabled && userEnabled; }
|
bool enabled() const { return settingEnabled && userEnabled; }
|
||||||
};
|
};
|
||||||
@ -79,12 +80,18 @@ private:
|
|||||||
inline TrackingEnabled& tracking( TrackingType t )
|
inline TrackingEnabled& tracking( TrackingType t )
|
||||||
{
|
{
|
||||||
if ( t == TrackingType::UserTracking )
|
if ( t == TrackingType::UserTracking )
|
||||||
|
{
|
||||||
return m_userTracking;
|
return m_userTracking;
|
||||||
|
}
|
||||||
else if ( t == TrackingType::MachineTracking )
|
else if ( t == TrackingType::MachineTracking )
|
||||||
|
{
|
||||||
return m_machineTracking;
|
return m_machineTracking;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return m_installTracking;
|
return m_installTracking;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )
|
||||||
|
Loading…
Reference in New Issue
Block a user