@ -19,30 +19,13 @@
# include "LocaleQmlViewStep.h"
# include "GlobalStorage.h"
# include "JobQueue.h"
# include "geoip/Handler.h"
# include "network/Manager.h"
# include "utils/CalamaresUtilsGui.h"
# include "utils/Logger.h"
# include "utils/Variant.h"
# include "utils/Yaml.h"
# include "Branding.h"
# include "modulesystem/ModuleManager.h"
# include <QQmlEngine>
# include <QFutureWatcher>
# include <QPixmap>
# include <QVariant>
CALAMARES_PLUGIN_FACTORY_DEFINITION ( LocaleQmlViewStepFactory , registerPlugin < LocaleQmlViewStep > ( ) ; )
LocaleQmlViewStep : : LocaleQmlViewStep ( QObject * parent )
: Calamares : : QmlViewStep ( parent )
, m_config ( new Config ( this ) )
, m_nextEnabled ( false )
, m_geoip ( nullptr )
: Calamares : : QmlViewStep ( parent )
, m_config ( std : : make_unique < Config > ( this ) )
{
emit nextStatusChanged ( m_nextEnabled ) ;
}
@ -50,43 +33,7 @@ LocaleQmlViewStep::LocaleQmlViewStep( QObject* parent )
QObject *
LocaleQmlViewStep : : getConfig ( )
{
return m_config ;
}
void
LocaleQmlViewStep : : fetchGeoIpTimezone ( )
{
if ( m_geoip & & m_geoip - > isValid ( ) )
{
m_startingTimezone = m_geoip - > get ( ) ;
if ( ! m_startingTimezone . isValid ( ) )
{
cWarning ( ) < < " GeoIP lookup at " < < m_geoip - > url ( ) < < " failed. " ;
}
}
// m_config->setLocaleInfo(m_startingTimezone.first, m_startingTimezone.second, m_localeGenPath);
}
Calamares : : RequirementsList LocaleQmlViewStep : : checkRequirements ( )
{
if ( m_geoip & & m_geoip - > isValid ( ) )
{
auto & network = CalamaresUtils : : Network : : Manager : : instance ( ) ;
if ( network . hasInternet ( ) )
{
fetchGeoIpTimezone ( ) ;
}
else
{
if ( network . synchronousPing ( m_geoip - > url ( ) ) )
{
fetchGeoIpTimezone ( ) ;
}
}
}
return Calamares : : RequirementsList ( ) ;
return m_config . get ( ) ;
}
QString
@ -98,14 +45,12 @@ LocaleQmlViewStep::prettyName() const
bool
LocaleQmlViewStep : : isNextEnabled ( ) const
{
// TODO: should return true
return true ;
}
bool
LocaleQmlViewStep : : isBackEnabled ( ) const
{
// TODO: should return true (it's weird that you are not allowed to have welcome *after* anything
return true ;
}
@ -113,7 +58,6 @@ LocaleQmlViewStep::isBackEnabled() const
bool
LocaleQmlViewStep : : isAtBeginning ( ) const
{
// TODO: adjust to "pages" in the QML
return true ;
}
@ -121,81 +65,18 @@ LocaleQmlViewStep::isAtBeginning() const
bool
LocaleQmlViewStep : : isAtEnd ( ) const
{
// TODO: adjust to "pages" in the QML
return true ;
}
Calamares : : JobList
LocaleQmlViewStep : : jobs ( ) const
{
return m_jobs ;
}
void LocaleQmlViewStep : : onActivate ( )
{
// TODO no sure if it is needed at all or for the abstract class to start something
}
void LocaleQmlViewStep : : onLeave ( )
{
#if 0
if ( true )
{
m_jobs = m_config - > createJobs ( ) ;
// m_prettyStatus = m_actualWidget->prettyStatus();
auto map = m_config - > localesMap ( ) ;
QVariantMap vm ;
for ( auto it = map . constBegin ( ) ; it ! = map . constEnd ( ) ; + + it )
{
vm . insert ( it . key ( ) , it . value ( ) ) ;
}
Calamares : : JobQueue : : instance ( ) - > globalStorage ( ) - > insert ( " localeConf " , vm ) ;
}
else
{
m_jobs . clear ( ) ;
Calamares : : JobQueue : : instance ( ) - > globalStorage ( ) - > remove ( " localeConf " ) ;
}
# endif
return m_config - > createJobs ( ) ;
}
void LocaleQmlViewStep : : setConfigurationMap ( const QVariantMap & configurationMap )
void
LocaleQmlViewStep : : setConfigurationMap ( const QVariantMap & configurationMap )
{
QString region = CalamaresUtils : : getString ( configurationMap , " region " ) ;
QString zone = CalamaresUtils : : getString ( configurationMap , " zone " ) ;
if ( ! region . isEmpty ( ) & & ! zone . isEmpty ( ) )
{
m_startingTimezone = CalamaresUtils : : GeoIP : : RegionZonePair ( region , zone ) ;
}
else
{
m_startingTimezone
= CalamaresUtils : : GeoIP : : RegionZonePair ( QStringLiteral ( " America " ) , QStringLiteral ( " New_York " ) ) ;
}
m_localeGenPath = CalamaresUtils : : getString ( configurationMap , " localeGenPath " ) ;
if ( m_localeGenPath . isEmpty ( ) )
{
m_localeGenPath = QStringLiteral ( " /etc/locale.gen " ) ;
}
bool ok = false ;
QVariantMap geoip = CalamaresUtils : : getSubMap ( configurationMap , " geoip " , ok ) ;
if ( ok )
{
QString url = CalamaresUtils : : getString ( geoip , " url " ) ;
QString style = CalamaresUtils : : getString ( geoip , " style " ) ;
QString selector = CalamaresUtils : : getString ( geoip , " selector " ) ;
m_geoip = std : : make_unique < CalamaresUtils : : GeoIP : : Handler > ( style , url , selector ) ;
if ( ! m_geoip - > isValid ( ) )
{
cWarning ( ) < < " GeoIP Style " < < style < < " is not recognized. " ;
}
}
checkRequirements ( ) ;
Calamares : : QmlViewStep : : setConfigurationMap ( configurationMap ) ; // call parent implementation last
m_config - > setConfigurationMap ( configurationMap ) ;
Calamares : : QmlViewStep : : setConfigurationMap ( configurationMap ) ; // call parent implementation last
}