[tracking] Introduce configuration for install-tracking
- subclass of TrackingStyleConfig holds the URL that is pinged with information when the installation is done.
This commit is contained in:
parent
d9fb9c19a8
commit
f97a0756a9
@ -46,29 +46,50 @@ TrackingStyleConfig::setTracking( TrackingStyleConfig::TrackingState state )
|
||||
emit trackingChanged();
|
||||
}
|
||||
|
||||
void
|
||||
TrackingStyleConfig::validateUrl( QString& urlString )
|
||||
{
|
||||
if ( !QUrl( urlString ).isValid() )
|
||||
{
|
||||
if ( m_state != DisabledByConfig )
|
||||
{
|
||||
cError() << "URL" << urlString << "is not valid; disabling this tracking type.";
|
||||
m_state = DisabledByConfig;
|
||||
emit trackingChanged();
|
||||
}
|
||||
urlString = QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackingStyleConfig::setConfigurationMap( const QVariantMap& config )
|
||||
{
|
||||
m_state = CalamaresUtils::getBool( config, "enabled", false ) ? DisabledByUser : DisabledByConfig;
|
||||
m_policy = CalamaresUtils::getString( config, "policy" );
|
||||
if ( !QUrl( m_policy ).isValid() )
|
||||
{
|
||||
if ( m_state != DisabledByConfig )
|
||||
{
|
||||
cError() << "Tracking policy URL" << m_policy << "is not valid; disabling this tracking type.";
|
||||
}
|
||||
m_policy = QString();
|
||||
m_state = DisabledByConfig;
|
||||
}
|
||||
|
||||
validateUrl( m_policy );
|
||||
emit policyChanged( m_policy );
|
||||
emit trackingChanged();
|
||||
}
|
||||
|
||||
InstallTrackingConfig::InstallTrackingConfig( QObject* parent )
|
||||
: TrackingStyleConfig( parent )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InstallTrackingConfig::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
TrackingStyleConfig::setConfigurationMap( configurationMap );
|
||||
|
||||
m_installTrackingUrl = CalamaresUtils::getString( configurationMap, "url" );
|
||||
validateUrl( m_installTrackingUrl );
|
||||
}
|
||||
|
||||
|
||||
Config::Config( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_installTracking( new TrackingStyleConfig( this ) )
|
||||
, m_installTracking( new InstallTrackingConfig( this ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -84,11 +84,27 @@ signals:
|
||||
void trackingChanged();
|
||||
void policyChanged( QString );
|
||||
|
||||
protected:
|
||||
/// @brief Validates the @p urlString, disables tracking if invalid
|
||||
void validateUrl( QString& urlString );
|
||||
|
||||
private:
|
||||
TrackingState m_state = DisabledByConfig;
|
||||
QString m_policy; // URL
|
||||
};
|
||||
|
||||
class InstallTrackingConfig : public TrackingStyleConfig
|
||||
{
|
||||
public:
|
||||
InstallTrackingConfig( QObject* parent );
|
||||
void setConfigurationMap( const QVariantMap& configurationMap );
|
||||
|
||||
QString installTrackingUrl() { return m_installTrackingUrl; }
|
||||
|
||||
private:
|
||||
QString m_installTrackingUrl;
|
||||
};
|
||||
|
||||
class Config : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -109,7 +125,7 @@ signals:
|
||||
private:
|
||||
QString m_generalPolicy;
|
||||
|
||||
TrackingStyleConfig* m_installTracking;
|
||||
InstallTrackingConfig* m_installTracking;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user