2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-05-12 14:24:33 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2020-05-12 14:24:33 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2020-05-12 14:24:33 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TRACKING_CONFIG_H
|
|
|
|
#define TRACKING_CONFIG_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariantMap>
|
|
|
|
|
2020-05-18 16:41:25 +02:00
|
|
|
/** @brief Base class for configuring a specific kind of tracking.
|
|
|
|
*
|
|
|
|
* All tracking types have a policy URL, which is used to explain what
|
|
|
|
* kind of tracking is involved, what data is sent, etc. The content
|
|
|
|
* of that URL is the responsibility of the distro.
|
|
|
|
*
|
|
|
|
* A tracking type is disabled by default: if it isn't specifically
|
|
|
|
* enabled (for configuration) in the config file, it will always be disabled.
|
|
|
|
* If it is enabled (for configuration) in the config file, it still
|
|
|
|
* defaults to disabled, but the user can choose to enable it.
|
|
|
|
*/
|
|
|
|
class TrackingStyleConfig : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( TrackingState trackingStatus READ tracking WRITE setTracking NOTIFY trackingChanged FINAL )
|
|
|
|
Q_PROPERTY( bool isEnabled READ isEnabled NOTIFY trackingChanged FINAL )
|
|
|
|
Q_PROPERTY( bool isConfigurable READ isConfigurable NOTIFY trackingChanged FINAL )
|
|
|
|
Q_PROPERTY( QString policy READ policy NOTIFY policyChanged FINAL )
|
|
|
|
|
|
|
|
public:
|
|
|
|
TrackingStyleConfig( QObject* parent );
|
2020-09-22 22:34:38 +02:00
|
|
|
~TrackingStyleConfig() override;
|
2020-05-18 16:41:25 +02:00
|
|
|
|
|
|
|
void setConfigurationMap( const QVariantMap& );
|
|
|
|
|
|
|
|
enum TrackingState
|
|
|
|
{
|
|
|
|
DisabledByConfig,
|
|
|
|
DisabledByUser,
|
|
|
|
EnabledByUser
|
|
|
|
};
|
2020-06-23 13:37:56 +02:00
|
|
|
Q_ENUM( TrackingState )
|
2020-05-18 16:41:25 +02:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
TrackingState tracking() const { return m_state; }
|
|
|
|
/// @brief Has the user specifically enabled this kind of tracking?
|
|
|
|
bool isEnabled() const { return m_state == EnabledByUser; }
|
|
|
|
/// @brief Is this tracking enabled for configuration?
|
|
|
|
bool isConfigurable() const { return m_state != DisabledByConfig; }
|
|
|
|
/** @brief Sets the tracking state
|
|
|
|
*
|
|
|
|
* Unless the tracking is enabled for configuration, it always
|
|
|
|
* remains disabled.
|
|
|
|
*/
|
|
|
|
void setTracking( TrackingState );
|
|
|
|
/** @brief Sets the tracking state
|
|
|
|
*
|
|
|
|
* Use @c true for @c EnabledByUser, @c false for DisabledByUser,
|
|
|
|
* but keep in mind that if the tracking is not enabled for
|
|
|
|
* configuration, it will always remain disabled.
|
|
|
|
*/
|
|
|
|
void setTracking( bool );
|
|
|
|
|
|
|
|
/// @brief URL for the policy explaining this tracking
|
|
|
|
QString policy() const { return m_policy; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void trackingChanged();
|
|
|
|
void policyChanged( QString );
|
|
|
|
|
2020-05-18 17:09:01 +02:00
|
|
|
protected:
|
|
|
|
/// @brief Validates the @p urlString, disables tracking if invalid
|
|
|
|
void validateUrl( QString& urlString );
|
2020-05-18 17:42:51 +02:00
|
|
|
/// @brief Validates the @p string, disables tracking if invalid
|
|
|
|
void validate( QString& s, std::function< bool( const QString& s ) >&& pred );
|
2020-05-18 17:09:01 +02:00
|
|
|
|
2020-05-18 16:41:25 +02:00
|
|
|
private:
|
|
|
|
TrackingState m_state = DisabledByConfig;
|
|
|
|
QString m_policy; // URL
|
|
|
|
};
|
|
|
|
|
2020-05-18 17:42:51 +02:00
|
|
|
/** @brief Install tracking pings a URL at the end of installation
|
|
|
|
*
|
|
|
|
* Install tracking will do a single GET on the given URL at
|
|
|
|
* the end of installation. The information included in the GET
|
|
|
|
* request depends on the URL configuration, see also the tracking
|
|
|
|
* jobs.
|
|
|
|
*/
|
2020-05-18 17:09:01 +02:00
|
|
|
class InstallTrackingConfig : public TrackingStyleConfig
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InstallTrackingConfig( QObject* parent );
|
2020-06-23 13:37:56 +02:00
|
|
|
~InstallTrackingConfig() override;
|
2020-05-18 17:09:01 +02:00
|
|
|
void setConfigurationMap( const QVariantMap& configurationMap );
|
|
|
|
|
|
|
|
QString installTrackingUrl() { return m_installTrackingUrl; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_installTrackingUrl;
|
|
|
|
};
|
|
|
|
|
2020-05-18 17:42:51 +02:00
|
|
|
/** @brief Machine tracking reports from the installed system
|
|
|
|
*
|
|
|
|
* When machine tracking is on, the installed system will report
|
|
|
|
* back ("call home") at some point. This can mean Debian pop-con,
|
2020-06-17 10:18:08 +02:00
|
|
|
* or updatemanager maching tracking, or something else. The kind
|
2020-05-18 17:42:51 +02:00
|
|
|
* of configuration depends on the style of tracking that is enabled.
|
|
|
|
*/
|
|
|
|
class MachineTrackingConfig : public TrackingStyleConfig
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MachineTrackingConfig( QObject* parent );
|
2020-06-23 13:37:56 +02:00
|
|
|
~MachineTrackingConfig() override;
|
2020-05-18 17:42:51 +02:00
|
|
|
void setConfigurationMap( const QVariantMap& configurationMap );
|
|
|
|
|
|
|
|
QString machineTrackingStyle() { return m_machineTrackingStyle; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_machineTrackingStyle;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @brief User tracking reports user actions
|
|
|
|
*
|
|
|
|
* When user tracking is on, it is enabled for the user configured
|
|
|
|
* in Calamares -- not for users created afterwards in the target
|
|
|
|
* system, unless the target system defaults to tracking them.
|
|
|
|
* The kind of user tracking depends on the target system and
|
|
|
|
* environment; KDE user tracking is one example, which can be
|
|
|
|
* configured in a fine-grained way and defaults to off.
|
|
|
|
*/
|
|
|
|
class UserTrackingConfig : public TrackingStyleConfig
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UserTrackingConfig( QObject* parent );
|
2020-06-23 13:37:56 +02:00
|
|
|
~UserTrackingConfig() override;
|
2020-05-18 17:42:51 +02:00
|
|
|
void setConfigurationMap( const QVariantMap& configurationMap );
|
|
|
|
|
|
|
|
QString userTrackingStyle() { return m_userTrackingStyle; }
|
2020-06-17 15:11:11 +02:00
|
|
|
QStringList userTrackingAreas() const { return m_userTrackingAreas; }
|
2020-05-18 17:42:51 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_userTrackingStyle;
|
2020-06-17 15:11:11 +02:00
|
|
|
QStringList m_userTrackingAreas; // fine-grained areas
|
2020-05-18 17:42:51 +02:00
|
|
|
};
|
|
|
|
|
2020-05-12 14:24:33 +02:00
|
|
|
class Config : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY( QString generalPolicy READ generalPolicy NOTIFY generalPolicyChanged FINAL )
|
2020-05-18 16:41:25 +02:00
|
|
|
Q_PROPERTY( TrackingStyleConfig* installTracking READ installTracking FINAL )
|
2020-05-18 20:18:34 +02:00
|
|
|
Q_PROPERTY( TrackingStyleConfig* machineTracking READ machineTracking FINAL )
|
|
|
|
Q_PROPERTY( TrackingStyleConfig* userTracking READ userTracking FINAL )
|
2020-05-12 14:24:33 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Config( QObject* parent = nullptr );
|
|
|
|
void setConfigurationMap( const QVariantMap& );
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
QString generalPolicy() const;
|
2020-05-18 20:18:34 +02:00
|
|
|
|
|
|
|
InstallTrackingConfig* installTracking() const { return m_installTracking; }
|
|
|
|
MachineTrackingConfig* machineTracking() const { return m_machineTracking; }
|
|
|
|
UserTrackingConfig* userTracking() const { return m_userTracking; }
|
2020-05-12 14:24:33 +02:00
|
|
|
|
2020-05-25 15:21:47 +02:00
|
|
|
/// @brief Call with @c true to turn off all the trackings
|
|
|
|
void noTracking( bool );
|
|
|
|
|
2020-05-12 14:24:33 +02:00
|
|
|
signals:
|
|
|
|
void generalPolicyChanged( QString );
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_generalPolicy;
|
2020-05-18 16:41:25 +02:00
|
|
|
|
2020-05-18 17:09:01 +02:00
|
|
|
InstallTrackingConfig* m_installTracking;
|
2020-05-18 17:48:51 +02:00
|
|
|
MachineTrackingConfig* m_machineTracking;
|
|
|
|
UserTrackingConfig* m_userTracking;
|
2020-05-12 14:24:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|