From 1926399378cdcc469121584c2c876355ba360669 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Aug 2017 08:00:37 -0400 Subject: [PATCH 01/23] Telemetry stub. This is experimental, off-by-default, code for developing a telemetry / tracking configuration module. It is preliminary work for issue #628, but also for KDE Neon configuration. Any telemetry should conform to the KDE Telemetry Policy [1] or similar Free Software telemetry policy (e.g. the Mozilla one). [1] https://community.kde.org/Policies/Telemetry_Policy Initial idea is to distinguish three kinds of tracking: - installs. This tracks that OS has been installed somewhere. It might send some machine information to a remote server. - machines. This enables some kind of machine tracking in the installed system, for instance it could enable popcon on Debian, or periodic phone-home-pings. - users. This enables some kind of telemetry / tracking on the installed user in the system. A simple and transparent setting is to enable install-tracking and set it to opt-in, and disable machine and user tracking. Explain to the user that would like to know when is installed, and that the following information , will be sent to in accordance to the telemetry policy at . Work in this branch is subject to VDG review for the visuals, and privacy oversight by whatever group is responsible for privacy. Note that this module makes it *possible* for telemetry configuration to be visible inside the installer; what distro's do with telemetry already is entirely outside the scope of this configuration module. --- src/modules/tracking/CMakeLists.txt | 13 +++ src/modules/tracking/TrackingPage.cpp | 44 +++++++++ src/modules/tracking/TrackingPage.h | 40 ++++++++ src/modules/tracking/TrackingViewStep.cpp | 109 ++++++++++++++++++++++ src/modules/tracking/TrackingViewStep.h | 63 +++++++++++++ src/modules/tracking/page_trackingstep.ui | 106 +++++++++++++++++++++ src/modules/tracking/tracking.conf | 14 +++ 7 files changed, 389 insertions(+) create mode 100644 src/modules/tracking/CMakeLists.txt create mode 100644 src/modules/tracking/TrackingPage.cpp create mode 100644 src/modules/tracking/TrackingPage.h create mode 100644 src/modules/tracking/TrackingViewStep.cpp create mode 100644 src/modules/tracking/TrackingViewStep.h create mode 100644 src/modules/tracking/page_trackingstep.ui create mode 100644 src/modules/tracking/tracking.conf diff --git a/src/modules/tracking/CMakeLists.txt b/src/modules/tracking/CMakeLists.txt new file mode 100644 index 000000000..d99d09446 --- /dev/null +++ b/src/modules/tracking/CMakeLists.txt @@ -0,0 +1,13 @@ +calamares_add_plugin( tracking + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + TrackingViewStep.cpp + TrackingPage.cpp + UI + page_trackingstep.ui + LINK_PRIVATE_LIBRARIES + calamaresui + SHARED_LIB +) + diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp new file mode 100644 index 000000000..512b743d4 --- /dev/null +++ b/src/modules/tracking/TrackingPage.cpp @@ -0,0 +1,44 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#include "TrackingPage.h" + +#include "ui_page_trackingstep.h" + +#include "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" +#include "utils/CalamaresUtilsGui.h" +#include "utils/Retranslator.h" +#include "ViewManager.h" + +#include +#include +#include +#include +#include +#include +#include + +TrackingPage::TrackingPage(QWidget *parent) + : QWidget( parent ) + , ui( new Ui::TrackingPage ) +{ + ui->setupUi( this ); +} + diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h new file mode 100644 index 000000000..ccacb6415 --- /dev/null +++ b/src/modules/tracking/TrackingPage.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#ifndef TRACKINGPAGE_H +#define TRACKINGPAGE_H + +#include +#include + +namespace Ui +{ +class TrackingPage; +} + +class TrackingPage : public QWidget +{ + Q_OBJECT +public: + explicit TrackingPage( QWidget* parent = nullptr ); + +private: + Ui::TrackingPage* ui; +}; + +#endif //TRACKINGPAGE_H diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp new file mode 100644 index 000000000..a78b6c5b8 --- /dev/null +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -0,0 +1,109 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#include "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" + +#include "TrackingViewStep.h" +#include "TrackingPage.h" + +#include + +CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin(); ) + +TrackingViewStep::TrackingViewStep( QObject* parent ) + : Calamares::ViewStep( parent ) + , m_widget( new TrackingPage ) +{ + emit nextStatusChanged( false ); +} + + +TrackingViewStep::~TrackingViewStep() +{ + if ( m_widget && m_widget->parent() == nullptr ) + m_widget->deleteLater(); +} + + +QString +TrackingViewStep::prettyName() const +{ + return tr( "Telemetry and Tracking" ); +} + + +QWidget* +TrackingViewStep::widget() +{ + return m_widget; +} + + +void +TrackingViewStep::next() +{ + emit done(); +} + + +void +TrackingViewStep::back() +{} + + +bool +TrackingViewStep::isNextEnabled() const +{ +// return m_widget->isNextEnabled(); + return false; +} + + +bool +TrackingViewStep::isBackEnabled() const +{ + return true; +} + + +bool +TrackingViewStep::isAtBeginning() const +{ + return true; +} + + +bool +TrackingViewStep::isAtEnd() const +{ + return true; +} + + +QList< Calamares::job_ptr > +TrackingViewStep::jobs() const +{ + return QList< Calamares::job_ptr >(); +} + +void +TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ +} diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h new file mode 100644 index 000000000..8b9f97db9 --- /dev/null +++ b/src/modules/tracking/TrackingViewStep.h @@ -0,0 +1,63 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#ifndef TRACKINGVIEWSTEP_H +#define TRACKINGVIEWSTEP_H + +#include +#include +#include + +#include +#include +#include + +class TrackingPage; + +class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep +{ + Q_OBJECT + +public: + explicit TrackingViewStep( QObject* parent = nullptr ); + virtual ~TrackingViewStep(); + + QString prettyName() const override; + + QWidget* widget() override; + + void next() override; + void back() override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + QList< Calamares::job_ptr > jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + TrackingPage* m_widget; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory ) + +#endif // TRACKINGVIEWSTEP_H diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui new file mode 100644 index 000000000..f42133624 --- /dev/null +++ b/src/modules/tracking/page_trackingstep.ui @@ -0,0 +1,106 @@ + + + TrackingPage + + + + 0 + 0 + 799 + 400 + + + + Form + + + + + + + + Install Tracking + + + + + + + + Explanation of install-tracking. + + + + + + + Enable install-tracking + + + + + + + + + + + + Machine Tracking + + + + + + + + Explanation of machine-tracking. + + + + + + + Enable machine-tracking + + + + + + + + + + + + User Tracking + + + + + + + + Explanation of user-tracking. + + + + + + + Enable user-tracking + + + + + + + + + + + + + + + diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf new file mode 100644 index 000000000..ebbbc528d --- /dev/null +++ b/src/modules/tracking/tracking.conf @@ -0,0 +1,14 @@ +--- +machine: + - tracking: false + - style: neon + - path: /etc/machine-file + +user: + - tracking: false + - style: neon + +install: + - tracking: false + - style: neon + From aa26ac5dd9e5cce44a2238e7d445015699e1c449 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Sep 2017 11:07:15 +0200 Subject: [PATCH 02/23] Clang: warnings-- --- src/modules/tracking/TrackingViewStep.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index 8b9f97db9..580846ac5 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -35,7 +35,7 @@ class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep public: explicit TrackingViewStep( QObject* parent = nullptr ); - virtual ~TrackingViewStep(); + virtual ~TrackingViewStep() override; QString prettyName() const override; @@ -51,7 +51,7 @@ public: bool isAtEnd() const override; QList< Calamares::job_ptr > jobs() const override; - + void setConfigurationMap( const QVariantMap& configurationMap ) override; private: From 0d4bd5981837f75fc2c21fd2cb1483180cd35783 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Nov 2017 09:10:25 -0400 Subject: [PATCH 03/23] [tracking] Document the configuration file format - switch to 'enabled' and 'default' settings, independently. - document user-tracking as unimplemented. --- settings.conf | 1 + src/modules/tracking/tracking.conf | 73 ++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/settings.conf b/settings.conf index 9ae2e4383..b7974621c 100644 --- a/settings.conf +++ b/settings.conf @@ -66,6 +66,7 @@ sequence: - keyboard - partition - users + - tracking - summary - exec: # - dummycpp diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index ebbbc528d..d50755086 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -1,14 +1,69 @@ +# Settings for various kinds of tracking that Distributions can +# enable. Distributions looking at tracking should be aware of +# the privacy (and hence communications) impact of that tracking, +# and are advised to consult the Mozilla and KDE policies on +# privacy and user tracking. +# +# There are three areas of tracking (-configuration) supported +# by Calamares It is up to individual Distributions to create +# suitable backends / configuration scripts for each. The +# different areas are: +# +# install: This is "phone home" functionality at the end of the +# install process. When enabled, it contacts the given +# URL. The URL can contain the special token $MACHINE, +# which is replaced by the machine-id of the installed +# system (if available, blank otherwise). +# +# machine: This enables machine-level tracking on a (semi-) +# continuous basis. It is meant to keep track of installed +# systems and their continued use / updating. +# +# user: This area enables user-level tracking, along the lines +# of the KDE User Telemetry Policy. It enables specific +# collection of data at a user- and application-level, +# possibly including actions done in an application. +# For the KDE environment, this enables user tracking +# with the appropriate framework, and the KDE User Telemetry +# policy applies. +# +# Each area has a key *enabled*, and a key *default*. If the area +# is enabled, it is shown to the user with a checkbox to enable +# or disable that piece of user-tracking. The default state of that +# checkbox is set to the value of *default*. Both keys default to +# "off", disabling all tracking-configuration through Calamares. +# +# Each area may have other configuration keys, depending on the +# area and how it needs to be configured. --- -machine: - - tracking: false - - style: neon - - path: /etc/machine-file - -user: - - tracking: false - - style: neon +# The install area has one specific configuration key: +# url: this URL (remember to include the protocol, and prefer https) +# is fetched (with a GET request, and the data discarded) at +# the end of the installation process. The token $MACHINE +# in the URL is replaced by the machine-id of the installed +# system, if it is available, and otherwise blank. Typically +# you would add `?id=$MACHINE` as a GET parameter. +# +# Note that phone-home only works if the system has an internet +# connection; it is a good idea to require internet in the welcome +# module then. install: - - tracking: false + - enabled: false + - default: false + - url: + +# The machine area has one specific configuration key: +# style: This string specifies what kind of tracking configuration +# needs to be done. There is currently only one valid +# style, "neon", which edits two files in the installed +# system to enable system-tracking. +machine: + - enabled: false + - default: false - style: neon +# The user area is not yet implemented, and has no specific configuration. +user: + - enabled: false + - default: false From 806799ece4f18981c6f4661454f9eed715dbeb17 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Nov 2017 10:47:57 -0500 Subject: [PATCH 04/23] [tracking] Fix configuration file. - The sample configuration file didn't use sub-maps, but list items. --- src/modules/tracking/tracking.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index d50755086..219a853c2 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -49,9 +49,9 @@ # connection; it is a good idea to require internet in the welcome # module then. install: - - enabled: false - - default: false - - url: + enabled: false + default: false + url: # The machine area has one specific configuration key: # style: This string specifies what kind of tracking configuration @@ -59,11 +59,11 @@ install: # style, "neon", which edits two files in the installed # system to enable system-tracking. machine: - - enabled: false - - default: false - - style: neon + enabled: false + default: false + style: neon # The user area is not yet implemented, and has no specific configuration. user: - - enabled: false - - default: false + enabled: false + default: false From 20a2465cc72697f5741662bf33222ae58dc2fe4d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Nov 2017 10:12:41 -0500 Subject: [PATCH 05/23] [tracking] Polish UI a bit - add icons for graphical display of actions - extend description of tracking options - add debug logging - enable next button - show/hide tracking options based on configuration --- src/modules/tracking/CMakeLists.txt | 2 + src/modules/tracking/TrackingPage.cpp | 26 ++++ src/modules/tracking/TrackingPage.h | 9 ++ src/modules/tracking/TrackingViewStep.cpp | 34 ++++- src/modules/tracking/TrackingViewStep.h | 8 ++ src/modules/tracking/binoculars.png | Bin 0 -> 430 bytes src/modules/tracking/machine.png | Bin 0 -> 505 bytes src/modules/tracking/page_trackingstep.qrc | 8 ++ src/modules/tracking/page_trackingstep.ui | 160 ++++++++++++++++++--- src/modules/tracking/phone.png | Bin 0 -> 459 bytes 10 files changed, 228 insertions(+), 19 deletions(-) create mode 100644 src/modules/tracking/binoculars.png create mode 100644 src/modules/tracking/machine.png create mode 100644 src/modules/tracking/page_trackingstep.qrc create mode 100644 src/modules/tracking/phone.png diff --git a/src/modules/tracking/CMakeLists.txt b/src/modules/tracking/CMakeLists.txt index d99d09446..270866933 100644 --- a/src/modules/tracking/CMakeLists.txt +++ b/src/modules/tracking/CMakeLists.txt @@ -6,6 +6,8 @@ calamares_add_plugin( tracking TrackingPage.cpp UI page_trackingstep.ui + RESOURCES + page_trackingstep.qrc LINK_PRIVATE_LIBRARIES calamaresui SHARED_LIB diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 512b743d4..93c7697b4 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -42,3 +42,29 @@ TrackingPage::TrackingPage(QWidget *parent) ui->setupUi( this ); } +void TrackingPage::showTrackingOption(TrackingType t, bool show) +{ + QGroupBox *group = nullptr; + + cDebug() << "Showing tracking option" << int(t) << show; + switch ( t ) + { + case TrackingType::InstallTracking: + group = ui->installTrackingBox; + break; + case TrackingType::MachineTracking: + group = ui->machineTrackingBox; + break; + case TrackingType::UserTracking: + group = ui->UserTrackingBox; + break; + } + + if ( group != nullptr ) + if ( show ) + group->show(); + else + group->hide(); + else + cDebug() << " .. unknown option" << int(t); +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index ccacb6415..791f1039d 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -33,6 +33,15 @@ class TrackingPage : public QWidget public: explicit TrackingPage( QWidget* parent = nullptr ); + enum class TrackingType + { + InstallTracking, + MachineTracking, + UserTracking + } ; + + void showTrackingOption( TrackingType t, bool show ); + private: Ui::TrackingPage* ui; }; diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index a78b6c5b8..108b113c6 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -19,6 +19,7 @@ #include "JobQueue.h" #include "GlobalStorage.h" #include "utils/Logger.h" +#include "utils/CalamaresUtils.h" #include "TrackingViewStep.h" #include "TrackingPage.h" @@ -45,7 +46,7 @@ TrackingViewStep::~TrackingViewStep() QString TrackingViewStep::prettyName() const { - return tr( "Telemetry and Tracking" ); + return tr( "Telemetry" ); } @@ -71,8 +72,7 @@ TrackingViewStep::back() bool TrackingViewStep::isNextEnabled() const { -// return m_widget->isNextEnabled(); - return false; + return true; } @@ -100,10 +100,38 @@ TrackingViewStep::isAtEnd() const QList< Calamares::job_ptr > TrackingViewStep::jobs() const { + cDebug() << "Tracking jobs .."; return QList< Calamares::job_ptr >(); } + +static +bool getTrackingEnabled( const QVariantMap& configurationMap, const QString& key, TrackingEnabled& track ) +{ + cDebug() << "Tracking configuration" << key; + + // Switch it off by default + track.settingEnabled = false; + track.userEnabled = false; + + bool success = false; + auto config = CalamaresUtils::getSubMap( configurationMap, key, success ); + + if ( success ) + { + track.settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); + track.userEnabled = track.settingEnabled && CalamaresUtils::getBool( config, "default", false ); + } + cDebug() << " .. Install tracking: enabled=" <3#=A28n+p?*$8JE9t9%#@`UR=_(N2j~71|Ga+kelfD1twex=dk zrZgTe~ HDWM4flHaa| literal 0 HcmV?d00001 diff --git a/src/modules/tracking/machine.png b/src/modules/tracking/machine.png new file mode 100644 index 0000000000000000000000000000000000000000..bc9ab5a7270f5f5416a98b362dd471c18649caa1 GIT binary patch literal 505 zcmVA2dD$2UF6@4fiNC?5YoJtHV01d>FtPQXPq~H+2C$thw1zd^o5~qXFh=2h)t{u}4fnyt_M`P+FID!NX(;tZBATLAp%@BGH zm&!WbFN#T%(DG#rbi58=o`5YLs1dOg11xOiSidpp#<)8z4H3QBmSoj&>iidPlYrUh z`fV#OkXqIO`w9X|EVU3qfCRi2>JgBDpQj60iN^~V;s+9iJ^d}13s5xvJx7NS%oksm vm7Xx%uR1HZFTtnW=nz5(A%qY@2r2LjTpf2&y1>#(00000NkvXXu0mjfCb!d0 literal 0 HcmV?d00001 diff --git a/src/modules/tracking/page_trackingstep.qrc b/src/modules/tracking/page_trackingstep.qrc new file mode 100644 index 000000000..2d430b3ae --- /dev/null +++ b/src/modules/tracking/page_trackingstep.qrc @@ -0,0 +1,8 @@ + + + machine.png + ../../../data/images/information.svgz + binoculars.png + phone.png + + diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index f42133624..d27ff0570 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -25,11 +25,57 @@ - - - Explanation of install-tracking. - - + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/phone.png + + + + + + + <html><head/><body><p>Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent <span style=" font-weight:600;">one time only</span> to our servers. To see what will be sent, click on the help-icon.</p></body></html> + + + Qt::RichText + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + Qt::NoArrow + + + + @@ -52,11 +98,51 @@ - - - Explanation of machine-tracking. - - + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/machine.png + + + + + + + <html><head/><body><p>Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software <span style=" font-weight:600;">periodically</span> to our servers. For information about the kind of information being sent, click on the help icon.</p></body></html> + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + @@ -79,11 +165,51 @@ - - - Explanation of user-tracking. - - + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/binoculars.png + + + + + + + <html><head/><body><p>User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software <span style=" font-weight:600;">regularly</span> to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon.</p></body></html> + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + @@ -101,6 +227,8 @@ - + + + diff --git a/src/modules/tracking/phone.png b/src/modules/tracking/phone.png new file mode 100644 index 0000000000000000000000000000000000000000..91fb6228ebd084163c331d15e963f5f1590d9727 GIT binary patch literal 459 zcmV;+0W|)JP)ZMZldW1F3kR{M|y?89In z5uqrGqNtv(@87X%gKKw*kM1w259R&Gxk2jy&GRK>1+daiYH6pyaY6woTN~&AU|S_! zKnH-^E9U|_AUc3(5r9LRrRsndK-n#CPfr}sWDcT?3q}BDi5}qwL=wHxE&+(EKy(1n zvH~bm?0TXDq63H)0YnE7Edp?Ax5Oq$gbpA80x&#VeitYr@;SKn7N5sQ0Pb|esQ;E0 zz*D9D)Q4Mf&ua2x!c4(RnY>c`y)o&Yq#&-!u$kzop~fOeY_(WgO8 zVlEJnQ$TA|OG28S-`cbb zNFC4|hFsQS!^mF(h$-R(Hg&+l=>Obm4JHMEMYYberW_)Q;FEycpMRL5R)I9H)*_d| zRS2%IcD)koDclKZHbMrOc2E@oKwVQ2090=e;0w7QI%At!%!>d3002ovPDHLkV1l*T BxeWjS literal 0 HcmV?d00001 From c7120277ca81183935bdd8f67a54906cc28e2391 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 04:25:36 -0500 Subject: [PATCH 06/23] [tracking] Polish UI some more - Enable translations, substitute ShortProductName into string, - Simplify code for enabling tracking option blocks, - Set checkboxes based on configuration, - Read checkboxes when leaving page, - Don't stretch the tracking option blocks. --- src/modules/tracking/TrackingPage.cpp | 47 ++++++++++++++++++++--- src/modules/tracking/TrackingPage.h | 20 ++++++---- src/modules/tracking/TrackingType.h | 29 ++++++++++++++ src/modules/tracking/TrackingViewStep.cpp | 37 ++++++++++++------ src/modules/tracking/TrackingViewStep.h | 34 ++++++++++++---- src/modules/tracking/page_trackingstep.ui | 29 ++++++++++---- 6 files changed, 155 insertions(+), 41 deletions(-) create mode 100644 src/modules/tracking/TrackingType.h diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 93c7697b4..e6f06c3ed 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -20,6 +20,7 @@ #include "ui_page_trackingstep.h" +#include "Branding.h" #include "JobQueue.h" #include "GlobalStorage.h" #include "utils/Logger.h" @@ -39,32 +40,66 @@ TrackingPage::TrackingPage(QWidget *parent) : QWidget( parent ) , ui( new Ui::TrackingPage ) { + using StringEntry = Calamares::Branding::StringEntry; + ui->setupUi( this ); + CALAMARES_RETRANSLATE( + ui->installExplanation->setText( tr( "Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent one time only to our servers. To see what will be sent, click on the help-icon." ).arg( *StringEntry::ShortProductName ) ); + ui->machineExplanation->setText( tr( "Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software periodically to our servers. For information about the kind of information being sent, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); + ui->userExplanation->setText( tr( "User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software regularly to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); + ) } -void TrackingPage::showTrackingOption(TrackingType t, bool show) +void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) { - QGroupBox *group = nullptr; + QGroupBox* group = nullptr; + QCheckBox* check = nullptr; - cDebug() << "Showing tracking option" << int(t) << show; switch ( t ) { case TrackingType::InstallTracking: group = ui->installTrackingBox; + check = ui->installCheckBox; break; case TrackingType::MachineTracking: group = ui->machineTrackingBox; + check = ui->machineCheckBox; break; case TrackingType::UserTracking: - group = ui->UserTrackingBox; + group = ui->userTrackingBox; + check = ui->userCheckBox; break; } - if ( group != nullptr ) - if ( show ) + if ( (group != nullptr) && (check != nullptr)) + { + if ( setting ) group->show(); else group->hide(); + + check->setChecked( user ); + } else cDebug() << " .. unknown option" << int(t); } + +bool TrackingPage::getTrackingOption(TrackingType t) +{ + QCheckBox* check = nullptr; + + switch ( t ) + { + case TrackingType::InstallTracking: + check = ui->installCheckBox; + break; + case TrackingType::MachineTracking: + check = ui->machineCheckBox; + break; + case TrackingType::UserTracking: + check = ui->userCheckBox; + break; + } + + return (check != nullptr) && check->isChecked(); +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 791f1039d..86800c897 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -19,6 +19,8 @@ #ifndef TRACKINGPAGE_H #define TRACKINGPAGE_H +#include "TrackingType.h" + #include #include @@ -33,14 +35,16 @@ class TrackingPage : public QWidget public: explicit TrackingPage( QWidget* parent = nullptr ); - enum class TrackingType - { - InstallTracking, - MachineTracking, - UserTracking - } ; - - void showTrackingOption( TrackingType t, bool show ); + /** + * Enables or disables the tracking-option block for the given + * tracking option @p t, and sets the initial state of the + * checkbox to the @p user default. + */ + void setTrackingOption( TrackingType t, bool setting, bool user ); + /** + * Returns the state of the user checkbox for tracking option @p t. + */ + bool getTrackingOption( TrackingType t ); private: Ui::TrackingPage* ui; diff --git a/src/modules/tracking/TrackingType.h b/src/modules/tracking/TrackingType.h new file mode 100644 index 000000000..01997d4d5 --- /dev/null +++ b/src/modules/tracking/TrackingType.h @@ -0,0 +1,29 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#ifndef TRACKINGTYPE_H +#define TRACKINGTYPE_H + +enum class TrackingType +{ + InstallTracking, + MachineTracking, + UserTracking +} ; + +#endif //TRACKINGTYPE_H diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 108b113c6..54ecf9e6a 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -97,6 +97,17 @@ TrackingViewStep::isAtEnd() const } +void TrackingViewStep::onLeave() +{ + cDebug() << "Install tracking:" << + (tracking( TrackingType::InstallTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking )); + cDebug() << "Machine tracking:" << + (tracking( TrackingType::MachineTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking )); + cDebug() << " User tracking:" << + (tracking( TrackingType::UserTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking )); +} + + QList< Calamares::job_ptr > TrackingViewStep::jobs() const { @@ -105,33 +116,35 @@ TrackingViewStep::jobs() const } -static -bool getTrackingEnabled( const QVariantMap& configurationMap, const QString& key, TrackingEnabled& track ) +void TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) { cDebug() << "Tracking configuration" << key; - // Switch it off by default - track.settingEnabled = false; - track.userEnabled = false; + bool settingEnabled = false; + bool userEnabled = false; bool success = false; auto config = CalamaresUtils::getSubMap( configurationMap, key, success ); if ( success ) { - track.settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); - track.userEnabled = track.settingEnabled && CalamaresUtils::getBool( config, "default", false ); + settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); + userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false ); } - cDebug() << " .. Install tracking: enabled=" < #include #include @@ -29,12 +31,6 @@ class TrackingPage; -struct TrackingEnabled -{ - bool settingEnabled; // Enabled in config file - bool userEnabled; // User checked "yes" -}; - class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep { Q_OBJECT @@ -56,14 +52,38 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; + void onLeave() override; + QList< Calamares::job_ptr > jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; private: + void setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); + + struct TrackingEnabled + { + bool settingEnabled; // Enabled in config file + bool userEnabled; // User checked "yes" + + TrackingEnabled() + : settingEnabled( false ) + , userEnabled( false ) + {} + }; + TrackingEnabled m_installTracking, m_machineTracking, m_userTracking; + TrackingPage* m_widget; - TrackingEnabled m_installTracking, m_machineTracking, m_userTracking; + inline TrackingEnabled& tracking( TrackingType t ) + { + if (t == TrackingType::UserTracking) + return m_userTracking; + else if (t == TrackingType::MachineTracking) + return m_machineTracking; + else + return m_installTracking; + } }; CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory ) diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index d27ff0570..9dd5aae2b 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -15,7 +15,7 @@ - + @@ -51,7 +51,7 @@ - <html><head/><body><p>Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent <span style=" font-weight:600;">one time only</span> to our servers. To see what will be sent, click on the help-icon.</p></body></html> + Placeholder text Qt::RichText @@ -78,7 +78,7 @@ - + Enable install-tracking @@ -124,7 +124,7 @@ - <html><head/><body><p>Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software <span style=" font-weight:600;">periodically</span> to our servers. For information about the kind of information being sent, click on the help icon.</p></body></html> + Placeholder text true @@ -145,7 +145,7 @@ - + Enable machine-tracking @@ -157,7 +157,7 @@ - + User Tracking @@ -191,7 +191,7 @@ - <html><head/><body><p>User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software <span style=" font-weight:600;">regularly</span> to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon.</p></body></html> + Placeholder text true @@ -212,7 +212,7 @@ - + Enable user-tracking @@ -223,6 +223,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + From e83b4d33f8b104e30b033c6cfdb2a3b4d567cb67 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 07:40:44 -0500 Subject: [PATCH 07/23] [libcalamares] Another convenience config-extraction function --- src/libcalamares/utils/CalamaresUtils.cpp | 12 ++++++++++++ src/libcalamares/utils/CalamaresUtils.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp index ae3a14497..75f6eecf3 100644 --- a/src/libcalamares/utils/CalamaresUtils.cpp +++ b/src/libcalamares/utils/CalamaresUtils.cpp @@ -340,6 +340,18 @@ getBool( const QVariantMap& map, const QString& key, bool d ) return result; } +QString +getString(const QVariantMap& map, const QString& key) +{ + if ( map.contains( key ) ) + { + auto v = map.value( key ); + if ( v.type() == QVariant::String ) + return v.toString(); + } + return QString(); +} + QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success ) { diff --git a/src/libcalamares/utils/CalamaresUtils.h b/src/libcalamares/utils/CalamaresUtils.h index 651c6746a..1211aac54 100644 --- a/src/libcalamares/utils/CalamaresUtils.h +++ b/src/libcalamares/utils/CalamaresUtils.h @@ -104,6 +104,11 @@ namespace CalamaresUtils */ DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d ); + /** + * Get a string value from a mapping; returns empty QString if no value. + */ + DLLEXPORT QString getString( const QVariantMap& map, const QString& key ); + /** * Returns a sub-map (i.e. a nested map) from the given mapping with the * given key. @p success is set to true if the @p key exists From 7a7e2b16cb19b67c5d80dfd842f2d91d20d4e472 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 09:17:18 -0500 Subject: [PATCH 08/23] [libcalamares] Some extra system-information functions --- .../utils/CalamaresUtilsSystem.cpp | 31 ++++++++++++++++++- src/libcalamares/utils/CalamaresUtilsSystem.h | 16 +++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 656a57c10..35f394364 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -232,7 +232,7 @@ System::targetEnvOutput( const QString& command, QPair -System::getTotalMemoryB() +System::getTotalMemoryB() const { #ifdef Q_OS_LINUX struct sysinfo i; @@ -257,4 +257,33 @@ System::getTotalMemoryB() } +QString +System::getCpuDescription() const +{ + QString model; + +#ifdef Q_OS_LINUX + QFile file("/proc/cpuinfo"); + if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + if ( line.startsWith( "model name" ) && (line.indexOf( ':' ) > 0) ) + { + model = QString::fromLatin1( line.right(line.length() - line.indexOf( ':' ) ) ); + break; + } + } +#elif defined( Q_OS_FREEBSD ) + // This would use sysctl "hw.model", which has a string value +#endif + return model.simplified(); } + +quint64 +System::getTotalDiskB() const +{ + return 0; +} + +} // namespace diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.h b/src/libcalamares/utils/CalamaresUtilsSystem.h index 1ccdfb516..34ab7ecbd 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.h +++ b/src/libcalamares/utils/CalamaresUtilsSystem.h @@ -112,7 +112,21 @@ public: * * @return size, guesstimate-factor */ - DLLEXPORT QPair getTotalMemoryB(); + DLLEXPORT QPair getTotalMemoryB() const; + + /** + * @brief getCpuDescription returns a string describing the CPU. + * + * Returns the value of the "model name" line in /proc/cpuinfo. + */ + DLLEXPORT QString getCpuDescription() const; + + /** + * @brief getTotalDiskB returns the total disk attached, in bytes. + * + * If nothing can be found, returns a 0. + */ + DLLEXPORT quint64 getTotalDiskB() const; private: static System* s_instance; From a0e8f76348c6c64de60829d6836aeac93b542898 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 07:46:33 -0500 Subject: [PATCH 09/23] [tracking] Enable policy websites Each kind of tracking has an associated webpage / URL describing the policy for that tracking. The Calamares User Guide has some generic information. When the user clicks on the Help (?) button in a tracking-option block, go to that URL. --- src/modules/tracking/TrackingPage.cpp | 31 ++++++++++++++++++++++- src/modules/tracking/TrackingPage.h | 2 ++ src/modules/tracking/TrackingViewStep.cpp | 6 ++++- src/modules/tracking/TrackingViewStep.h | 2 +- src/modules/tracking/page_trackingstep.ui | 6 ++--- src/modules/tracking/tracking.conf | 9 ++++++- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index e6f06c3ed..1ad4a26db 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -44,6 +44,7 @@ TrackingPage::TrackingPage(QWidget *parent) ui->setupUi( this ); CALAMARES_RETRANSLATE( + ui->retranslateUi( this ); ui->installExplanation->setText( tr( "Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent one time only to our servers. To see what will be sent, click on the help-icon." ).arg( *StringEntry::ShortProductName ) ); ui->machineExplanation->setText( tr( "Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software periodically to our servers. For information about the kind of information being sent, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); ui->userExplanation->setText( tr( "User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software regularly to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); @@ -81,7 +82,7 @@ void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) check->setChecked( user ); } else - cDebug() << " .. unknown option" << int(t); + cDebug() << "WARNING: unknown tracking option" << int(t); } bool TrackingPage::getTrackingOption(TrackingType t) @@ -103,3 +104,31 @@ bool TrackingPage::getTrackingOption(TrackingType t) return (check != nullptr) && check->isChecked(); } + +void TrackingPage::setTrackingPolicy(TrackingType t, QString url) +{ + QToolButton *button = nullptr; + switch( t ) + { + case TrackingType::InstallTracking: + button = ui->installPolicyButton; + break; + case TrackingType::MachineTracking: + button = ui->machinePolicyButton; + break; + case TrackingType::UserTracking: + button = ui->userPolicyButton; + break; + } + + if ( button != nullptr ) + if ( url.isEmpty() ) + button->hide(); + else + { + connect( button, &QToolButton::clicked, [url]{ QDesktopServices::openUrl( url ); } ); + cDebug() << "Tracking policy" << int(t) << "set to" << url; + } + else + cDebug() << "WARNING: unknown tracking option" << int(t); +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 86800c897..8839b8598 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -46,6 +46,8 @@ public: */ bool getTrackingOption( TrackingType t ); + void setTrackingPolicy( TrackingType t, QString url ); + private: Ui::TrackingPage* ui; }; diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 54ecf9e6a..ad946a3fd 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -24,6 +24,7 @@ #include "TrackingViewStep.h" #include "TrackingPage.h" +#include #include CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin(); ) @@ -116,7 +117,7 @@ TrackingViewStep::jobs() const } -void TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) +QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) { cDebug() << "Tracking configuration" << key; @@ -138,6 +139,9 @@ void TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, co trackingConfiguration.userEnabled = userEnabled; m_widget->setTrackingOption(t, settingEnabled, userEnabled); + m_widget->setTrackingPolicy(t, CalamaresUtils::getString( config, "policy" ) ); + + return config; } diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index fdb402672..b468fc611 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -59,7 +59,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; private: - void setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); + QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); struct TrackingEnabled { diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index 9dd5aae2b..fdbbefce0 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -62,7 +62,7 @@ - + ... @@ -132,7 +132,7 @@ - + ... @@ -199,7 +199,7 @@ - + ... diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index 219a853c2..8bca218f5 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -33,6 +33,12 @@ # checkbox is set to the value of *default*. Both keys default to # "off", disabling all tracking-configuration through Calamares. # +# Each area has a key *policy*, which is a Url to be opened when +# the user clicks on the corresponding Help button for an explanation +# of the details of that particular kind of tracking. If no policy +# is set, the help button is hidden. The example policy links +# go to Calamares' generic user manual. +# # Each area may have other configuration keys, depending on the # area and how it needs to be configured. --- @@ -51,7 +57,8 @@ install: enabled: false default: false - url: + policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" + # url: "https://example.com/install.php" # The machine area has one specific configuration key: # style: This string specifies what kind of tracking configuration From 731120457246c2f2e18e196106346bad0ede4e15 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 09:35:49 -0500 Subject: [PATCH 10/23] [tracking] Step 1 of getting the install-tracking URL - document substitutions - build URL when creating jobs --- src/modules/tracking/TrackingViewStep.cpp | 25 +++++++++++++++++++++-- src/modules/tracking/TrackingViewStep.h | 7 +++++-- src/modules/tracking/tracking.conf | 12 ++++++----- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index ad946a3fd..16a0c0fb3 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -20,6 +20,7 @@ #include "GlobalStorage.h" #include "utils/Logger.h" #include "utils/CalamaresUtils.h" +#include "utils/CalamaresUtilsSystem.h" #include "TrackingViewStep.h" #include "TrackingPage.h" @@ -113,6 +114,22 @@ QList< Calamares::job_ptr > TrackingViewStep::jobs() const { cDebug() << "Tracking jobs .."; + if ( m_installTracking.enabled() ) + { + QString installUrl = m_installTrackingUrl; + const auto s = CalamaresUtils::System::instance(); + + QString memory, disk; + memory.setNum( s->getTotalMemoryB().first ); + disk.setNum( s->getTotalDiskB() ); + + installUrl + .replace( "$CPU", s->getCpuDescription() ) + .replace( "$MEMORY", memory ) + .replace( "$DISK", disk ); + + cDebug() << " .. install-tracking URL" << installUrl; + } return QList< Calamares::job_ptr >(); } @@ -132,7 +149,7 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false ); } - cDebug() << " .. Install tracking: enabled=" << settingEnabled << "default=" << userEnabled; + cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled; auto trackingConfiguration = tracking( t ); trackingConfiguration.settingEnabled = settingEnabled; @@ -148,7 +165,11 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration void TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - setTrackingOption( configurationMap, "install", TrackingType::InstallTracking ); + QVariantMap config; + + config = setTrackingOption( configurationMap, "install", TrackingType::InstallTracking ); + m_installTrackingUrl = CalamaresUtils::getString( config, "url" ); + setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking ); setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); } diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index b468fc611..30e0eaa49 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -61,6 +61,9 @@ public: private: QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); + TrackingPage* m_widget; + QString m_installTrackingUrl; + struct TrackingEnabled { bool settingEnabled; // Enabled in config file @@ -70,11 +73,11 @@ private: : settingEnabled( false ) , userEnabled( false ) {} + + bool enabled() const { return settingEnabled && userEnabled; } }; TrackingEnabled m_installTracking, m_machineTracking, m_userTracking; - TrackingPage* m_widget; - inline TrackingEnabled& tracking( TrackingType t ) { if (t == TrackingType::UserTracking) diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index 8bca218f5..aabb90177 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -46,10 +46,12 @@ # The install area has one specific configuration key: # url: this URL (remember to include the protocol, and prefer https) # is fetched (with a GET request, and the data discarded) at -# the end of the installation process. The token $MACHINE -# in the URL is replaced by the machine-id of the installed -# system, if it is available, and otherwise blank. Typically -# you would add `?id=$MACHINE` as a GET parameter. +# the end of the installation process. The following tokens +# are replaced in the url (possibly by blank strings, or by 0). +# - $CPU (cpu make and model) +# - $MEMORY (amount of main memory available) +# - $DISK (total amount of disk attached) +# Typically these are used as GET parameters, as in the example. # # Note that phone-home only works if the system has an internet # connection; it is a good idea to require internet in the welcome @@ -58,7 +60,7 @@ install: enabled: false default: false policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" - # url: "https://example.com/install.php" + # url: "https://example.com/install.php?c=$CPU&m=$MEMORY" # The machine area has one specific configuration key: # style: This string specifies what kind of tracking configuration From fbfb103b5f82ff4820cebead7e8428c0026398e6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 09:49:32 -0500 Subject: [PATCH 11/23] [tracking] Fix deduced type 'auto' doesn't pick up the reference-type returned from tracking(), and 'auto&' reads funny to me, so make the type explicit. --- src/modules/tracking/TrackingViewStep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 16a0c0fb3..73662cc3e 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -151,7 +151,7 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration } cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled; - auto trackingConfiguration = tracking( t ); + TrackingEnabled& trackingConfiguration = tracking( t ); trackingConfiguration.settingEnabled = settingEnabled; trackingConfiguration.userEnabled = userEnabled; From ff8af7d5e2f3aa2851f1ab001b527b585b10e2fe Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Nov 2017 09:59:40 -0500 Subject: [PATCH 12/23] [tracking] Switch to typedef for job list --- src/modules/tracking/TrackingViewStep.cpp | 8 +++++--- src/modules/tracking/TrackingViewStep.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 73662cc3e..ada7785ab 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -110,10 +110,12 @@ void TrackingViewStep::onLeave() } -QList< Calamares::job_ptr > +Calamares::JobList TrackingViewStep::jobs() const { - cDebug() << "Tracking jobs .."; + Calamares::JobList l; + + cDebug() << "Creating tracking jobs .."; if ( m_installTracking.enabled() ) { QString installUrl = m_installTrackingUrl; @@ -130,7 +132,7 @@ TrackingViewStep::jobs() const cDebug() << " .. install-tracking URL" << installUrl; } - return QList< Calamares::job_ptr >(); + return l; } diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index 30e0eaa49..ba0b6a6ba 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -54,7 +54,7 @@ public: void onLeave() override; - QList< Calamares::job_ptr > jobs() const override; + Calamares::JobList jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; From a0b1410a50957fb38c9d863157e07fb8c618cce3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Nov 2017 05:19:24 -0500 Subject: [PATCH 13/23] [tracking] Do the install-tracking ping with QNAM --- src/modules/tracking/TrackingJobs.cpp | 85 +++++++++++++++++++++++ src/modules/tracking/TrackingJobs.h | 50 +++++++++++++ src/modules/tracking/TrackingViewStep.cpp | 3 +- 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/modules/tracking/TrackingJobs.cpp create mode 100644 src/modules/tracking/TrackingJobs.h diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp new file mode 100644 index 000000000..8fa70f242 --- /dev/null +++ b/src/modules/tracking/TrackingJobs.cpp @@ -0,0 +1,85 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#include "TrackingJobs.h" + +#include "utils/Logger.h" + +#include +#include +#include + +TrackingInstallJob::TrackingInstallJob( const QString& url ) + : m_url( url ) + , m_networkManager( new QNetworkAccessManager( this ) ) + , m_semaphore( new QSemaphore( 1 ) ) +{ +} + +QString TrackingInstallJob::prettyName() const +{ + return tr( "Install-tracking" ); +} + +QString TrackingInstallJob::prettyDescription() const +{ + return tr( "Install-tracking" ); +} + +QString TrackingInstallJob::prettyStatusMessage() const +{ + return tr( "Sending install-tracking information." ); +} + +Calamares::JobResult TrackingInstallJob::exec() +{ + QNetworkRequest request; + request.setUrl( QUrl( m_url ) ); + // Follows all redirects except unsafe ones (https to http). + request.setAttribute( QNetworkRequest::FollowRedirectsAttribute, true ); + // Not everybody likes the default User Agent used by this class (looking at you, + // sourceforge.net), so let's set a more descriptive one. + request.setRawHeader( "User-Agent", "Mozilla/5.0 (compatible; Calamares)" ); + + connect( m_networkManager, &QNetworkAccessManager::finished, + this, &TrackingInstallJob::dataIsHere ); + + if ( !m_semaphore->tryAcquire( 1, 500 /* ms */ ) ) + { + // Something's wrong .. + cDebug() << "WARNING: could not set up semaphore for install-tracking."; + return Calamares::JobResult::error( tr( "Internal error in install-tracking." ), + tr( "Could not get semaphore for install-tracking." ) ); + } + m_networkManager->get( request ); // The semaphore is released when data is received + if ( !m_semaphore->tryAcquire( 1, 5000 /* ms */ ) ) + { + cDebug() << "WARNING: install-tracking request timed out."; + return Calamares::JobResult::error( tr( "Internal error in install-tracking." ), + tr( "HTTP request timed out." ) ); + } + + return Calamares::JobResult::ok(); +} + +void TrackingInstallJob::dataIsHere( QNetworkReply* reply ) +{ + if ( m_semaphore ) + m_semaphore->release( 1 ); + reply->deleteLater(); +} diff --git a/src/modules/tracking/TrackingJobs.h b/src/modules/tracking/TrackingJobs.h new file mode 100644 index 000000000..d81a80acb --- /dev/null +++ b/src/modules/tracking/TrackingJobs.h @@ -0,0 +1,50 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * 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 . + */ + +#ifndef TRACKINGJOBS +#define TRACKINGJOBS + +#include "Job.h" + +class QNetworkAccessManager; +class QNetworkReply; +class QSemaphore; + +class TrackingInstallJob : public Calamares::Job +{ + Q_OBJECT +public: + TrackingInstallJob( const QString& url ); + ~TrackingInstallJob(); + + QString prettyName() const override; + QString prettyDescription() const override; + QString prettyStatusMessage() const override; + Calamares::JobResult exec() override; + +public slots: + void dataIsHere( QNetworkReply* ); + +private: + const QString m_url; + + QNetworkAccessManager* m_networkManager; + QSemaphore* m_semaphore; +}; + +#endif diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index ada7785ab..8c153fa22 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -22,8 +22,9 @@ #include "utils/CalamaresUtils.h" #include "utils/CalamaresUtilsSystem.h" -#include "TrackingViewStep.h" +#include "TrackingJobs.h" #include "TrackingPage.h" +#include "TrackingViewStep.h" #include #include From 9a43b8a0e8d918a68ae574a406e6885e9e0c4970 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Nov 2017 05:45:25 -0500 Subject: [PATCH 14/23] [tracking] hook the install-tracking job into the build. (it doesn't work yet, though .. multi-threading issues). --- src/modules/tracking/CMakeLists.txt | 3 ++- src/modules/tracking/TrackingJobs.cpp | 11 ++++++++++- src/modules/tracking/TrackingViewStep.cpp | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/tracking/CMakeLists.txt b/src/modules/tracking/CMakeLists.txt index 270866933..24e020af4 100644 --- a/src/modules/tracking/CMakeLists.txt +++ b/src/modules/tracking/CMakeLists.txt @@ -2,8 +2,9 @@ calamares_add_plugin( tracking TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - TrackingViewStep.cpp + TrackingJobs.cpp TrackingPage.cpp + TrackingViewStep.cpp UI page_trackingstep.ui RESOURCES diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 8fa70f242..425f0d165 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -26,11 +26,18 @@ TrackingInstallJob::TrackingInstallJob( const QString& url ) : m_url( url ) - , m_networkManager( new QNetworkAccessManager( this ) ) + , m_networkManager( nullptr ) , m_semaphore( new QSemaphore( 1 ) ) { } +TrackingInstallJob::~TrackingInstallJob() +{ + Q_ASSERT( m_semaphore->available() == 1 ); + delete m_semaphore; + delete m_networkManager; +} + QString TrackingInstallJob::prettyName() const { return tr( "Install-tracking" ); @@ -48,6 +55,8 @@ QString TrackingInstallJob::prettyStatusMessage() const Calamares::JobResult TrackingInstallJob::exec() { + m_networkManager = new QNetworkAccessManager(); + QNetworkRequest request; request.setUrl( QUrl( m_url ) ); // Follows all redirects except unsafe ones (https to http). diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 8c153fa22..18a42f776 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -132,6 +132,8 @@ TrackingViewStep::jobs() const .replace( "$DISK", disk ); cDebug() << " .. install-tracking URL" << installUrl; + + l.append( Calamares::job_ptr( new TrackingInstallJob( installUrl ) ) ); } return l; } From f4368d05f9201dbe80e9fab9dd7cf12bee7c3185 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 13 Nov 2017 05:13:19 -0500 Subject: [PATCH 15/23] [tracking] Fix install-tracking HTTP GET --- src/modules/tracking/TrackingJobs.cpp | 31 ++++++++++++++++----------- src/modules/tracking/TrackingJobs.h | 1 - 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 425f0d165..5366f6be0 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -20,21 +20,20 @@ #include "utils/Logger.h" +#include #include #include #include +#include TrackingInstallJob::TrackingInstallJob( const QString& url ) : m_url( url ) , m_networkManager( nullptr ) - , m_semaphore( new QSemaphore( 1 ) ) { } TrackingInstallJob::~TrackingInstallJob() { - Q_ASSERT( m_semaphore->available() == 1 ); - delete m_semaphore; delete m_networkManager; } @@ -65,30 +64,36 @@ Calamares::JobResult TrackingInstallJob::exec() // sourceforge.net), so let's set a more descriptive one. request.setRawHeader( "User-Agent", "Mozilla/5.0 (compatible; Calamares)" ); + QTimer timeout; + timeout.setSingleShot(true); + + QEventLoop loop; + connect( m_networkManager, &QNetworkAccessManager::finished, this, &TrackingInstallJob::dataIsHere ); + connect( m_networkManager, &QNetworkAccessManager::finished, + &loop, &QEventLoop::quit ); + connect( &timeout, &QTimer::timeout, + &loop, &QEventLoop::quit ); - if ( !m_semaphore->tryAcquire( 1, 500 /* ms */ ) ) - { - // Something's wrong .. - cDebug() << "WARNING: could not set up semaphore for install-tracking."; - return Calamares::JobResult::error( tr( "Internal error in install-tracking." ), - tr( "Could not get semaphore for install-tracking." ) ); - } m_networkManager->get( request ); // The semaphore is released when data is received - if ( !m_semaphore->tryAcquire( 1, 5000 /* ms */ ) ) + timeout.start( 5000 /* ms */ ); + + loop.exec(); + + if ( !timeout.isActive() ) { cDebug() << "WARNING: install-tracking request timed out."; return Calamares::JobResult::error( tr( "Internal error in install-tracking." ), tr( "HTTP request timed out." ) ); } + timeout.stop(); return Calamares::JobResult::ok(); } void TrackingInstallJob::dataIsHere( QNetworkReply* reply ) { - if ( m_semaphore ) - m_semaphore->release( 1 ); + cDebug() << "Install-tracking request OK"; reply->deleteLater(); } diff --git a/src/modules/tracking/TrackingJobs.h b/src/modules/tracking/TrackingJobs.h index d81a80acb..2cf96488b 100644 --- a/src/modules/tracking/TrackingJobs.h +++ b/src/modules/tracking/TrackingJobs.h @@ -44,7 +44,6 @@ private: const QString m_url; QNetworkAccessManager* m_networkManager; - QSemaphore* m_semaphore; }; #endif From 93052311aabc15ea63abf7af7536076d56bc3272 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Nov 2017 07:51:30 -0500 Subject: [PATCH 16/23] [tracking] Switch UI to use radio buttons Following KDE Pholio M116, switch to using a radio button; instead of 4 individually toggle-able settings, use a "level" indicator to select none, install, machine, user .. each of which implies the previous levels. Each level is individually enable-able from the distro side. --- src/modules/tracking/TrackingPage.cpp | 92 ++-- src/modules/tracking/TrackingPage.h | 13 +- src/modules/tracking/TrackingViewStep.cpp | 24 +- src/modules/tracking/none.png | Bin 0 -> 538 bytes src/modules/tracking/page_trackingstep.qrc | 1 + src/modules/tracking/page_trackingstep.ui | 505 ++++++++++++--------- src/modules/tracking/tracking.conf | 26 +- 7 files changed, 385 insertions(+), 276 deletions(-) create mode 100644 src/modules/tracking/none.png diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 1ad4a26db..3f3d7c718 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -28,13 +28,9 @@ #include "utils/Retranslator.h" #include "ViewManager.h" -#include -#include +#include #include -#include #include -#include -#include TrackingPage::TrackingPage(QWidget *parent) : QWidget( parent ) @@ -45,41 +41,44 @@ TrackingPage::TrackingPage(QWidget *parent) ui->setupUi( this ); CALAMARES_RETRANSLATE( ui->retranslateUi( this ); - ui->installExplanation->setText( tr( "Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent one time only to our servers. To see what will be sent, click on the help-icon." ).arg( *StringEntry::ShortProductName ) ); - ui->machineExplanation->setText( tr( "Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software periodically to our servers. For information about the kind of information being sent, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); - ui->userExplanation->setText( tr( "User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software regularly to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); + 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 ) ); + ui->installExplanation->setText( tr( "By selecting this you will send information about your installation and hardware. This information will only be sent once after the installation finishes." ) ); + ui->machineExplanation->setText( tr( "By selecting this you will periodically send information about your installation, hardware and applications, to %1." ).arg( *StringEntry::ShortProductName ) ); + ui->userExplanation->setText( tr( "By selecting this you will regularly send information about your installation, hardware, applications and usage patterns, to %1." ).arg( *StringEntry::ShortProductName ) ); ) + + QButtonGroup *group = new QButtonGroup( this ); + group->setExclusive( true ); + group->addButton( ui->noneRadio ); + group->addButton( ui->installRadio ); + group->addButton( ui->machineRadio ); + group->addButton( ui->userRadio ); + ui->noneRadio->setChecked( true ); } -void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) +void TrackingPage::enableTrackingOption(TrackingType t, bool enabled) { - QGroupBox* group = nullptr; - QCheckBox* check = nullptr; + QWidget* group = nullptr; switch ( t ) { case TrackingType::InstallTracking: - group = ui->installTrackingBox; - check = ui->installCheckBox; + group = ui->installGroup; break; case TrackingType::MachineTracking: - group = ui->machineTrackingBox; - check = ui->machineCheckBox; + group = ui->machineGroup; break; case TrackingType::UserTracking: - group = ui->userTrackingBox; - check = ui->userCheckBox; + group = ui->userGroup; break; } - if ( (group != nullptr) && (check != nullptr)) + if ( group != nullptr ) { - if ( setting ) + if ( enabled ) group->show(); else group->hide(); - - check->setChecked( user ); } else cDebug() << "WARNING: unknown tracking option" << int(t); @@ -87,22 +86,22 @@ void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) bool TrackingPage::getTrackingOption(TrackingType t) { - QCheckBox* check = nullptr; + bool enabled = false; + // A tracking type is enabled if it is checked, or + // any higher level is checked. switch ( t ) { case TrackingType::InstallTracking: - check = ui->installCheckBox; - break; + enabled |= ui->installRadio->isChecked(); + // FALLTHRU case TrackingType::MachineTracking: - check = ui->machineCheckBox; - break; + enabled |= ui->machineRadio->isChecked(); + // FALLTHRU case TrackingType::UserTracking: - check = ui->userCheckBox; - break; + enabled |= ui->userRadio->isChecked(); } - - return (check != nullptr) && check->isChecked(); + return enabled; } void TrackingPage::setTrackingPolicy(TrackingType t, QString url) @@ -132,3 +131,36 @@ void TrackingPage::setTrackingPolicy(TrackingType t, QString url) else cDebug() << "WARNING: unknown tracking option" << int(t); } + +void TrackingPage::setGeneralPolicy( QString url ) +{ + if ( url.isEmpty() ) + ui->generalPolicyLabel->hide(); + else + { + ui->generalPolicyLabel->show(); + ui->generalPolicyLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + ui->generalPolicyLabel->show(); + connect( ui->generalPolicyLabel, &QLabel::linkActivated, [url]{ QDesktopServices::openUrl( url ); } ); + } +} + +void TrackingPage::setTrackingLevel(const QString& l) +{ + QString level = l.toLower(); + QRadioButton* button = nullptr; + + if (level.isEmpty() || level == "none") + button = ui->noneRadio; + else if (level == "install") + button = ui->installRadio; + else if (level == "machine") + button = ui->machineRadio; + else if (level == "user") + button = ui->userRadio; + + if ( button != nullptr ) + button->setChecked( true ); + else + cDebug() << "WARNING: unknown default tracking level" << l; +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 8839b8598..281102897 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -39,14 +39,23 @@ public: * Enables or disables the tracking-option block for the given * tracking option @p t, and sets the initial state of the * checkbox to the @p user default. + * + * Call this in ascending order of tracking type. */ - void setTrackingOption( TrackingType t, bool setting, bool user ); + void enableTrackingOption( TrackingType t, bool enabled ); /** - * Returns the state of the user checkbox for tracking option @p t. + * Returns whether tracking type @p is selected by the user + * (i.e. is the radio button for that level, or for a higher + * tracking level, enabled). */ bool getTrackingOption( TrackingType t ); + /* URL for given level @p t */ void setTrackingPolicy( TrackingType t, QString url ); + /* URL for the global link */ + void setGeneralPolicy( QString url ); + /* Select one of the four levels by name */ + void setTrackingLevel( const QString& level ); private: Ui::TrackingPage* ui; diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 18a42f776..79cb69903 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -102,12 +102,12 @@ TrackingViewStep::isAtEnd() const void TrackingViewStep::onLeave() { - cDebug() << "Install tracking:" << - (tracking( TrackingType::InstallTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking )); - cDebug() << "Machine tracking:" << - (tracking( TrackingType::MachineTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking )); - cDebug() << " User tracking:" << - (tracking( TrackingType::UserTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking )); + m_installTracking.userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking ); + m_machineTracking.userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking ); + m_userTracking.userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking ); + cDebug() << "Install tracking:" << m_installTracking.enabled(); + cDebug() << "Machine tracking:" << m_machineTracking.enabled(); + cDebug() << " User tracking:" << m_userTracking.enabled(); } @@ -141,10 +141,7 @@ TrackingViewStep::jobs() const QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) { - cDebug() << "Tracking configuration" << key; - bool settingEnabled = false; - bool userEnabled = false; bool success = false; auto config = CalamaresUtils::getSubMap( configurationMap, key, success ); @@ -152,15 +149,13 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration if ( success ) { settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); - userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false ); } - cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled; TrackingEnabled& trackingConfiguration = tracking( t ); trackingConfiguration.settingEnabled = settingEnabled; - trackingConfiguration.userEnabled = userEnabled; + trackingConfiguration.userEnabled = false; - m_widget->setTrackingOption(t, settingEnabled, userEnabled); + m_widget->enableTrackingOption(t, settingEnabled); m_widget->setTrackingPolicy(t, CalamaresUtils::getString( config, "policy" ) ); return config; @@ -177,4 +172,7 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking ); setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); + + m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); + m_widget->setTrackingLevel( CalamaresUtils::getString( configurationMap, "default" ) ); } diff --git a/src/modules/tracking/none.png b/src/modules/tracking/none.png new file mode 100644 index 0000000000000000000000000000000000000000..f3f2fa6bf8890666b7f529bec64606c20ca18cf9 GIT binary patch literal 538 zcmV+#0_FXQP)%?J#(-Yy9UeGOO+K$0X$ zk|bZHJnaC%cKPh_^J)XNHDdr&jyv|Fwq^@}$$97glbxT#SWD23HobN>Vy{K~&L49K z=YZv~4e&j!+164xJ5&HPXaq=Wyg|_Jt9!}ySOBcq_59{N&jV}!8USoDTSCS|y(R6b z0#&P8T0k2JNqpD^*1+zA6o3}NRy!lOC9&lav>dAWjw7N%&@(*&80kFM$5%gGRmKfM zJ!#D-CAKiO(f5lUEkIpz)Ibzr-|~B91CRqS>UP#T9lfsGC1~kK&05baBJC;E;nKS} zH7sFB71Uxogx;5+Cu_>K+l=j5P+z3XX)+s~A*KSYqA|{am}NpcLIfZ}{BBY`3eP~- zC(*+daLnqS6=w3ossQh8{EYkhhXO#AGaH01z78IRBl|dpK>^SRmrA)00}geI@A;_h zZ+PacpFD^+xrXpcup^TAd4yMj99k>uM*^H$FY8B~&aIpAD@G@^gUlM@0n`C_pYV#p z;rEm~hVf16wtZRQ6-EFjetqE;LWuaf`Wg^H-w_X>{!8qg;sI1G@Lusrk|arzBuSDa cN%B$t0aTQ2NC`tC2><{907*qoM6N<$g1epRXaE2J literal 0 HcmV?d00001 diff --git a/src/modules/tracking/page_trackingstep.qrc b/src/modules/tracking/page_trackingstep.qrc index 2d430b3ae..ead294772 100644 --- a/src/modules/tracking/page_trackingstep.qrc +++ b/src/modules/tracking/page_trackingstep.qrc @@ -1,5 +1,6 @@ + none.png machine.png ../../../data/images/information.svgz binoculars.png diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index fdbbefce0..9598d4bde 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -13,230 +13,289 @@ Form - + - - - - - Install Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/phone.png - - - - - - - Placeholder text - - - Qt::RichText - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - Qt::NoArrow - - - - - - - - - Enable install-tracking - - - - - - - - - - - - Machine Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/machine.png - - - - - - - Placeholder text - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - - - - - - - Enable machine-tracking - - - - - - - - - - - - User Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/binoculars.png - - - - - - - Placeholder text - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - - - - - - - Enable user-tracking - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + <html><head/><body><p><span style=" font-size:16pt;">Install Tracking</span></p></body></html> + + + + + + + Placeholder + + + true + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/none.png + + + + + + + + 0 + 0 + + + + <html><head/><body><p>By selecting this, you will send <span style=" font-weight:600;">no information at all</span> about your installation.</p></body></html> + + + true + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/phone.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/machine.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/binoculars.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + <html><head/><body><p><a href="placeholder"><span style=" text-decoration: underline; color:#2980b9;">Click here for more information about Install Tracking</span></a></p></body></html> + + + Qt::RichText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index aabb90177..84c3f553f 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -27,11 +27,9 @@ # with the appropriate framework, and the KDE User Telemetry # policy applies. # -# Each area has a key *enabled*, and a key *default*. If the area -# is enabled, it is shown to the user with a checkbox to enable -# or disable that piece of user-tracking. The default state of that -# checkbox is set to the value of *default*. Both keys default to -# "off", disabling all tracking-configuration through Calamares. +# Each area has a key *enabled*. If the area is enabled, it is shown to +# the user. This defaults to off, which means no tracking would be +# configured or enabled by Calamares. # # Each area has a key *policy*, which is a Url to be opened when # the user clicks on the corresponding Help button for an explanation @@ -41,7 +39,22 @@ # # Each area may have other configuration keys, depending on the # area and how it needs to be configured. +# +# Globally, there are two other keys: +# +# policy: (optional) url about tracking settings for this distro. +# default: (optional) level to enable by default +# --- +# This is the global policy; it is displayed as a link on the page. +# If blank or commented out, no link is displayed on the tracking +# page. It is recommended to either provide policy URLs for each +# area, *or* one general link, and not to mix them. +policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" + +# This is the default level to enable for tracking. If commented out, +# empty, or otherwise invalid, "none" is used, so no tracking by default. +default: user # The install area has one specific configuration key: # url: this URL (remember to include the protocol, and prefer https) @@ -58,7 +71,6 @@ # module then. install: enabled: false - default: false policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" # url: "https://example.com/install.php?c=$CPU&m=$MEMORY" @@ -69,10 +81,8 @@ install: # system to enable system-tracking. machine: enabled: false - default: false style: neon # The user area is not yet implemented, and has no specific configuration. user: enabled: false - default: false From cb8f698ce018c58ad30730671dc0559628727cfa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 13:01:41 +0100 Subject: [PATCH 17/23] [tracking] Switch to VDG icons (version 1) --- src/modules/tracking/binoculars.png | Bin 430 -> 1925 bytes src/modules/tracking/machine.png | Bin 505 -> 2003 bytes src/modules/tracking/none.png | Bin 538 -> 1681 bytes src/modules/tracking/phone.png | Bin 459 -> 1498 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/modules/tracking/binoculars.png b/src/modules/tracking/binoculars.png index 6ccd16afe5cef29018d356072a7126364128f3d0..ef43ce1f685959566e99bff8317dc9aa91f4c52f 100644 GIT binary patch delta 1890 zcmV-o2c7t?1BDNeIDZE>Nkl6~}+~u`_G09~;}X5+@CblQxYTWJNem zP(W#f>L!>1@`nhbBGe=ZD5ZixifF2$QdEIJl|Tsb2?>FVThUUr(568m5G5oPL?~2+ zsC5#O#*Zep6MJ{P-u3QWKFq#cuNyyRcNE!wX|!|a-nnzm|9_ry?m06nuHP6nEMi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0E;I;tn1@-NU(&zS-ZHPUBelM}G<_@;iab zo3%@TnxgzvBHVs2;={ay;D;*0ytv~_Jag#;zkc^0II~DkO(F?)!6S29U7?>BSU@2O zTIPSXatZSQ3)%$&Qt_R&JNQ`RI=QfljE51!R>DNuGlfNFa5Rfz#Z5pVEloqXo~Jv$OncLY zo6cFXR5&C8{HS^x+pXpNAo@?@X5sJml~TwmJG0`2tM8h=v^3k-wes}N1JqiTvzoKy zwZNzCHGEjtacJxm6Mrm>1f>)rWV_km`>enU2Kh?+XV`al$DHOYOEI)o)zH1{6LiPl zS z1W6br%oa(Sa7;)B>Jng0~_T{omx42=H3~zp+Gs-vaoJB?9~wz;7%O;I{yN cW6=}ve}A~$c0o3rb{{n-ga8P%pqplUl)Duw%C($%`-2|+}7xK z^}wr>`MgIZE`JtFUhR>4gZ=J00k7s&XJyX0bh|B^Dw}cn8|Q(BdhO)JC0%=Tx*JP= z>#`c~ay6Ja6pJ3%U&D9j(@MStycaYWZZY&SAv1jB58U2Zc2>%E@3BvZJcO@`yUM-_ zvWjJWH)o-G>zs!_#XOdroGW=O%HB|^fyM5o@v{G70SsFhrC1%L7X*SB>q`%;So$G% z*?R_7hYF||MAEM`THN%;QK3?X+y*zs3v3yCm@@vFcD(hNy^ndbYmIB-~vzPj`N1X^&*-@*DT>PgH9WaI%@huUcVS U<@M)tI0F!Py85}Sb4q9e0I=$)Z2$lO diff --git a/src/modules/tracking/machine.png b/src/modules/tracking/machine.png index bc9ab5a7270f5f5416a98b362dd471c18649caa1..64f96517061585298d43f1cacacf4317c6b61c98 100644 GIT binary patch delta 1969 zcmV;i2Tu6;1Je(XIDZF)Nkl?#-C5egJ2DQQ6= z4Q=KKEVyMLWoTZTtQE!Qzr-U{T6 zWdib6Aa5)akhcPPW0`=w704UQ1mvwi-ni}w@a8+Q`0sBbNp&f8$plgNPHG$PpZENE z6QHM0A@TI0l)9QoioFY(f8B?`bx**&L*R6YZ?%hwF0@CyGw(-sReGd{P*GBYZqlLeE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RnY>c`y)o&Yq#&-!u$kzop~fOeY_ z(WgO8VlEJnQ-45fQ%gdyDG@aVy2)SH5*L^oPyiqWZ!vkOG891(iAi4Mc@414!GG=E zCEwb#3rHQ%9EM!hV#CN^0*EQ%1U7ZR!s!3pY7Hg@fJL>=v!)y(ir|xg+n;}!qE>-4 zuht@$!Bq&Zuy(x?>nYp`X*NOznRZYW0YF_-5dc(g4;J7HxgR=Xn_A3^00000NkvXX Hu0mjfem}E+ From 9a3ba75c2cd34414a54a09ab4cae030d83b592ed Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 13:04:18 +0100 Subject: [PATCH 18/23] [tracking] Switch icons to sensible names --- .../tracking/{phone.png => level-install.png} | Bin .../tracking/{machine.png => level-machine.png} | Bin src/modules/tracking/{none.png => level-none.png} | Bin .../tracking/{binoculars.png => level-user.png} | Bin src/modules/tracking/page_trackingstep.qrc | 8 ++++---- src/modules/tracking/page_trackingstep.ui | 8 ++++---- 6 files changed, 8 insertions(+), 8 deletions(-) rename src/modules/tracking/{phone.png => level-install.png} (100%) rename src/modules/tracking/{machine.png => level-machine.png} (100%) rename src/modules/tracking/{none.png => level-none.png} (100%) rename src/modules/tracking/{binoculars.png => level-user.png} (100%) diff --git a/src/modules/tracking/phone.png b/src/modules/tracking/level-install.png similarity index 100% rename from src/modules/tracking/phone.png rename to src/modules/tracking/level-install.png diff --git a/src/modules/tracking/machine.png b/src/modules/tracking/level-machine.png similarity index 100% rename from src/modules/tracking/machine.png rename to src/modules/tracking/level-machine.png diff --git a/src/modules/tracking/none.png b/src/modules/tracking/level-none.png similarity index 100% rename from src/modules/tracking/none.png rename to src/modules/tracking/level-none.png diff --git a/src/modules/tracking/binoculars.png b/src/modules/tracking/level-user.png similarity index 100% rename from src/modules/tracking/binoculars.png rename to src/modules/tracking/level-user.png diff --git a/src/modules/tracking/page_trackingstep.qrc b/src/modules/tracking/page_trackingstep.qrc index ead294772..14a6980ce 100644 --- a/src/modules/tracking/page_trackingstep.qrc +++ b/src/modules/tracking/page_trackingstep.qrc @@ -1,9 +1,9 @@ - none.png - machine.png + level-none.png + level-install.png + level-machine.png + level-user.png ../../../data/images/information.svgz - binoculars.png - phone.png diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index 9598d4bde..a8659993a 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -59,7 +59,7 @@ - :/tracking/none.png + :/tracking/level-none.png @@ -110,7 +110,7 @@ - :/tracking/phone.png + :/tracking/level-install.png @@ -172,7 +172,7 @@ - :/tracking/machine.png + :/tracking/level-machine.png @@ -234,7 +234,7 @@ - :/tracking/binoculars.png + :/tracking/level-user.png From 4a96e832038b08617aee39f06981fb190813317e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 07:21:58 -0500 Subject: [PATCH 19/23] [tracking] Adjust wording, drop page title --- src/modules/tracking/TrackingViewStep.cpp | 2 +- src/modules/tracking/page_trackingstep.ui | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 79cb69903..9b5d3c1e5 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -49,7 +49,7 @@ TrackingViewStep::~TrackingViewStep() QString TrackingViewStep::prettyName() const { - return tr( "Telemetry" ); + return tr( "Feedback" ); } diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index a8659993a..266d786dc 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -13,16 +13,13 @@ Form - - - - - <html><head/><body><p><span style=" font-size:16pt;">Install Tracking</span></p></body></html> - - - + + + margin-bottom: 1ex; +margin-left: 2em; + Placeholder @@ -271,7 +268,7 @@ - <html><head/><body><p><a href="placeholder"><span style=" text-decoration: underline; color:#2980b9;">Click here for more information about Install Tracking</span></a></p></body></html> + <html><head/><body><p><a href="placeholder"><span style=" text-decoration: underline; color:#2980b9;">Click here for more information about user feedback</span></a></p></body></html> Qt::RichText From 22f5a121cba1c652c9f348271cf92f32a47dfb58 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 07:39:52 -0500 Subject: [PATCH 20/23] [tracking] stub implementation of neon machine feedback configuration --- src/modules/tracking/TrackingJobs.cpp | 21 +++++++++++++++++++++ src/modules/tracking/TrackingJobs.h | 11 +++++++++++ src/modules/tracking/TrackingViewStep.cpp | 23 ++++++++++++++++++++--- src/modules/tracking/TrackingViewStep.h | 1 + 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 5366f6be0..c6c6cb396 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -97,3 +97,24 @@ void TrackingInstallJob::dataIsHere( QNetworkReply* reply ) cDebug() << "Install-tracking request OK"; reply->deleteLater(); } + +QString TrackingMachineNeonJob::prettyName() const +{ + return tr( "Machine feedback" ); +} + +QString TrackingMachineNeonJob::prettyDescription() const +{ + return prettyName(); +} + +QString TrackingMachineNeonJob::prettyStatusMessage() const +{ + return tr( "Configuring machine feedback." ); +} + +Calamares::JobResult TrackingMachineNeonJob::exec() +{ + return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ), + tr( "Could not configure machine feedback correctly." ) ); +} diff --git a/src/modules/tracking/TrackingJobs.h b/src/modules/tracking/TrackingJobs.h index 2cf96488b..60c8a0f77 100644 --- a/src/modules/tracking/TrackingJobs.h +++ b/src/modules/tracking/TrackingJobs.h @@ -46,4 +46,15 @@ private: QNetworkAccessManager* m_networkManager; }; +class TrackingMachineNeonJob : public Calamares::Job +{ + Q_OBJECT +public: + QString prettyName() const override; + QString prettyDescription() const override; + QString prettyStatusMessage() const override; + Calamares::JobResult exec() override; +}; + + #endif diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 9b5d3c1e5..3d3fe4c0d 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -31,6 +31,13 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin(); ) +/** @brief Is @p s a valid machine-tracking style. */ +static bool isValidStyle( const QString& s ) +{ + static QStringList knownStyles { "neon" }; + return knownStyles.contains( s ); +} + TrackingViewStep::TrackingViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_widget( new TrackingPage ) @@ -117,7 +124,7 @@ TrackingViewStep::jobs() const Calamares::JobList l; cDebug() << "Creating tracking jobs .."; - if ( m_installTracking.enabled() ) + if ( m_installTracking.enabled() && !m_installTrackingUrl.isEmpty() ) { QString installUrl = m_installTrackingUrl; const auto s = CalamaresUtils::System::instance(); @@ -135,6 +142,13 @@ TrackingViewStep::jobs() const l.append( Calamares::job_ptr( new TrackingInstallJob( installUrl ) ) ); } + + if ( m_machineTracking.enabled() && !m_machineTrackingStyle.isEmpty() ) + { + Q_ASSERT( isValidStyle( m_machineTrackingStyle ) ); + if ( m_machineTrackingStyle == "neon" ) + l.append( Calamares::job_ptr( new TrackingMachineNeonJob() ) ); + } return l; } @@ -161,7 +175,6 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration return config; } - void TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { @@ -170,7 +183,11 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) config = setTrackingOption( configurationMap, "install", TrackingType::InstallTracking ); m_installTrackingUrl = CalamaresUtils::getString( config, "url" ); - setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking ); + config = setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking ); + auto s = CalamaresUtils::getString( config, "style" ); + if ( isValidStyle( s ) ) + m_machineTrackingStyle = s; + setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index ba0b6a6ba..5f2f58af1 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -63,6 +63,7 @@ private: TrackingPage* m_widget; QString m_installTrackingUrl; + QString m_machineTrackingStyle; struct TrackingEnabled { From 6cb88c86f11add43fba41d734e13d0f026fbfbc7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 07:49:06 -0500 Subject: [PATCH 21/23] [tracking] Improve phrasing --- src/modules/tracking/TrackingJobs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index c6c6cb396..5e8307380 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -39,17 +39,17 @@ TrackingInstallJob::~TrackingInstallJob() QString TrackingInstallJob::prettyName() const { - return tr( "Install-tracking" ); + return tr( "Installation feedback" ); } QString TrackingInstallJob::prettyDescription() const { - return tr( "Install-tracking" ); + return prettyName(); } QString TrackingInstallJob::prettyStatusMessage() const { - return tr( "Sending install-tracking information." ); + return tr( "Sending installation feedback." ); } Calamares::JobResult TrackingInstallJob::exec() @@ -94,7 +94,7 @@ Calamares::JobResult TrackingInstallJob::exec() void TrackingInstallJob::dataIsHere( QNetworkReply* reply ) { - cDebug() << "Install-tracking request OK"; + cDebug() << "Installation feedback request OK"; reply->deleteLater(); } From 8e79ad1a1479f94660218477eb95cec88eef90c7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Nov 2017 08:04:37 -0500 Subject: [PATCH 22/23] [tracking] Implement Neon machine tracking configuration --- src/modules/tracking/TrackingJobs.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 5e8307380..2863a1d94 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -18,6 +18,7 @@ #include "TrackingJobs.h" +#include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" #include @@ -115,6 +116,24 @@ QString TrackingMachineNeonJob::prettyStatusMessage() const Calamares::JobResult TrackingMachineNeonJob::exec() { - return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ), - tr( "Could not configure machine feedback correctly." ) ); + int r = CalamaresUtils::System::instance()->targetEnvCall( + "/bin/sh", + QString(), // Working dir + QString( +R"x(MACHINE_ID=`cat /etc/machine-id` +sed -i "s,URI =.*,URI = http://releases.neon.kde.org/meta-release/${MACHINE_ID}," /etc/update-manager/meta-release +sed -i "s,URI_LTS =.*,URI_LTS = http://releases.neon.kde.org/meta-release-lts/${MACHINE_ID}," /etc/update-manager/meta-release +echo "$MACHINE_ID" > /tmp/derp +true +)x"), + 1); + + if ( r == 0 ) + return Calamares::JobResult::ok(); + else if ( r > 0 ) + return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ), + tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) ); + else + return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ), + tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) ); } From 858372d93e7c28ad45437d432c3ff7d25c2a4a16 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 23 Nov 2017 17:38:06 +0100 Subject: [PATCH 23/23] [tracking] Remove derp. --- src/modules/tracking/TrackingJobs.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 2863a1d94..dc6584980 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -123,7 +123,6 @@ Calamares::JobResult TrackingMachineNeonJob::exec() R"x(MACHINE_ID=`cat /etc/machine-id` sed -i "s,URI =.*,URI = http://releases.neon.kde.org/meta-release/${MACHINE_ID}," /etc/update-manager/meta-release sed -i "s,URI_LTS =.*,URI_LTS = http://releases.neon.kde.org/meta-release-lts/${MACHINE_ID}," /etc/update-manager/meta-release -echo "$MACHINE_ID" > /tmp/derp true )x"), 1);