[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();
|
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
|
void
|
||||||
TrackingStyleConfig::setConfigurationMap( const QVariantMap& config )
|
TrackingStyleConfig::setConfigurationMap( const QVariantMap& config )
|
||||||
{
|
{
|
||||||
m_state = CalamaresUtils::getBool( config, "enabled", false ) ? DisabledByUser : DisabledByConfig;
|
m_state = CalamaresUtils::getBool( config, "enabled", false ) ? DisabledByUser : DisabledByConfig;
|
||||||
m_policy = CalamaresUtils::getString( config, "policy" );
|
m_policy = CalamaresUtils::getString( config, "policy" );
|
||||||
if ( !QUrl( m_policy ).isValid() )
|
validateUrl( m_policy );
|
||||||
{
|
|
||||||
if ( m_state != DisabledByConfig )
|
|
||||||
{
|
|
||||||
cError() << "Tracking policy URL" << m_policy << "is not valid; disabling this tracking type.";
|
|
||||||
}
|
|
||||||
m_policy = QString();
|
|
||||||
m_state = DisabledByConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit policyChanged( m_policy );
|
emit policyChanged( m_policy );
|
||||||
emit trackingChanged();
|
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 )
|
Config::Config( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_installTracking( new TrackingStyleConfig( this ) )
|
, m_installTracking( new InstallTrackingConfig( this ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +84,27 @@ signals:
|
|||||||
void trackingChanged();
|
void trackingChanged();
|
||||||
void policyChanged( QString );
|
void policyChanged( QString );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// @brief Validates the @p urlString, disables tracking if invalid
|
||||||
|
void validateUrl( QString& urlString );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TrackingState m_state = DisabledByConfig;
|
TrackingState m_state = DisabledByConfig;
|
||||||
QString m_policy; // URL
|
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
|
class Config : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -109,7 +125,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QString m_generalPolicy;
|
QString m_generalPolicy;
|
||||||
|
|
||||||
TrackingStyleConfig* m_installTracking;
|
InstallTrackingConfig* m_installTracking;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user