[users] Settle on 'hostname' as a single word for camel-casing
This commit is contained in:
parent
92b1341730
commit
1a8fc1feec
@ -77,7 +77,7 @@ updateGSAutoLogin( bool doAutoLogin, const QString& login )
|
||||
}
|
||||
|
||||
const NamedEnumTable< HostNameAction >&
|
||||
hostNameActionNames()
|
||||
hostnameActionNames()
|
||||
{
|
||||
// *INDENT-OFF*
|
||||
// clang-format off
|
||||
@ -100,7 +100,7 @@ Config::Config( QObject* parent )
|
||||
emit readyChanged( m_isReady ); // false
|
||||
|
||||
// Gang together all the changes of status to one readyChanged() signal
|
||||
connect( this, &Config::hostNameStatusChanged, this, &Config::checkReady );
|
||||
connect( this, &Config::hostnameStatusChanged, this, &Config::checkReady );
|
||||
connect( this, &Config::loginNameStatusChanged, this, &Config::checkReady );
|
||||
connect( this, &Config::fullNameChanged, this, &Config::checkReady );
|
||||
connect( this, &Config::userPasswordStatusChanged, this, &Config::checkReady );
|
||||
@ -242,15 +242,15 @@ Config::loginNameStatus() const
|
||||
void
|
||||
Config::setHostName( const QString& host )
|
||||
{
|
||||
if ( hostNameAction() != HostNameAction::EtcHostname && hostNameAction() != HostNameAction::SystemdHostname )
|
||||
if ( hostnameAction() != HostNameAction::EtcHostname && hostnameAction() != HostNameAction::SystemdHostname )
|
||||
{
|
||||
cDebug() << "Ignoring hostname" << host << "No hostname will be set.";
|
||||
return;
|
||||
}
|
||||
if ( host != m_hostName )
|
||||
if ( host != m_hostname )
|
||||
{
|
||||
m_customHostName = !host.isEmpty();
|
||||
m_hostName = host;
|
||||
m_hostname = host;
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
if ( host.isEmpty() )
|
||||
{
|
||||
@ -260,8 +260,8 @@ Config::setHostName( const QString& host )
|
||||
{
|
||||
gs->insert( "hostname", host );
|
||||
}
|
||||
emit hostNameChanged( host );
|
||||
emit hostNameStatusChanged( hostNameStatus() );
|
||||
emit hostnameChanged( host );
|
||||
emit hostnameStatusChanged( hostnameStatus() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,31 +273,31 @@ Config::forbiddenHostNames()
|
||||
}
|
||||
|
||||
QString
|
||||
Config::hostNameStatus() const
|
||||
Config::hostnameStatus() const
|
||||
{
|
||||
// An empty hostname is "ok", even if it isn't really
|
||||
if ( m_hostName.isEmpty() )
|
||||
if ( m_hostname.isEmpty() )
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
if ( m_hostName.length() < HOSTNAME_MIN_LENGTH )
|
||||
if ( m_hostname.length() < HOSTNAME_MIN_LENGTH )
|
||||
{
|
||||
return tr( "Your hostname is too short." );
|
||||
}
|
||||
if ( m_hostName.length() > HOSTNAME_MAX_LENGTH )
|
||||
if ( m_hostname.length() > HOSTNAME_MAX_LENGTH )
|
||||
{
|
||||
return tr( "Your hostname is too long." );
|
||||
}
|
||||
for ( const QString& badName : forbiddenHostNames() )
|
||||
{
|
||||
if ( 0 == QString::compare( badName, m_hostName, Qt::CaseSensitive ) )
|
||||
if ( 0 == QString::compare( badName, m_hostname, Qt::CaseSensitive ) )
|
||||
{
|
||||
return tr( "'%1' is not allowed as hostname." ).arg( badName );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !HOSTNAME_RX.exactMatch( m_hostName ) )
|
||||
if ( !HOSTNAME_RX.exactMatch( m_hostname ) )
|
||||
{
|
||||
return tr( "Only letters, numbers, underscore and hyphen are allowed." );
|
||||
}
|
||||
@ -449,7 +449,7 @@ Config::setFullName( const QString& name )
|
||||
if ( !m_customHostName )
|
||||
{
|
||||
QString hostname = makeHostnameSuggestion( cleanParts );
|
||||
if ( !hostname.isEmpty() && hostname != m_hostName )
|
||||
if ( !hostname.isEmpty() && hostname != m_hostname )
|
||||
{
|
||||
setHostName( hostname );
|
||||
// Still not custom
|
||||
@ -660,7 +660,7 @@ bool
|
||||
Config::isReady() const
|
||||
{
|
||||
bool readyFullName = !fullName().isEmpty(); // Needs some text
|
||||
bool readyHostname = hostNameStatus().isEmpty(); // .. no warning message
|
||||
bool readyHostname = hostnameStatus().isEmpty(); // .. no warning message
|
||||
bool readyUsername = !loginName().isEmpty() && loginNameStatus().isEmpty(); // .. no warning message
|
||||
bool readyUserPassword = userPasswordValidity() != Config::PasswordValidity::Invalid;
|
||||
bool readyRootPassword = rootPasswordValidity() != Config::PasswordValidity::Invalid;
|
||||
@ -749,7 +749,7 @@ getHostNameAction( const QVariantMap& configurationMap )
|
||||
if ( !hostnameActionString.isEmpty() )
|
||||
{
|
||||
bool ok = false;
|
||||
setHostName = hostNameActionNames().find( hostnameActionString, ok );
|
||||
setHostName = hostnameActionNames().find( hostnameActionString, ok );
|
||||
if ( !ok )
|
||||
{
|
||||
setHostName = HostNameAction::EtcHostname; // Rather than none
|
||||
@ -875,7 +875,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
// TODO:3.3: Remove calls to copyLegacy
|
||||
copyLegacy( configurationMap, "setHostname", hostnameSettings, "location" );
|
||||
copyLegacy( configurationMap, "writeHostsFile", hostnameSettings, "writeHostsFile" );
|
||||
m_hostNameAction = getHostNameAction( hostnameSettings );
|
||||
m_hostnameAction = getHostNameAction( hostnameSettings );
|
||||
m_writeEtcHosts = CalamaresUtils::getBool( hostnameSettings, "writeHostsFile", true );
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ enum class HostNameAction
|
||||
Transient, // Force target system transient, remove /etc/hostname
|
||||
};
|
||||
|
||||
const NamedEnumTable< HostNameAction >& hostNameActionNames();
|
||||
const NamedEnumTable< HostNameAction >& hostnameActionNames();
|
||||
|
||||
/** @brief Settings for a single group
|
||||
*
|
||||
@ -99,9 +99,9 @@ class PLUGINDLLEXPORT Config : public Calamares::ModuleSystem::Config
|
||||
Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged )
|
||||
Q_PROPERTY( QString loginNameStatus READ loginNameStatus NOTIFY loginNameStatusChanged )
|
||||
|
||||
Q_PROPERTY( QString hostName READ hostName WRITE setHostName NOTIFY hostNameChanged )
|
||||
Q_PROPERTY( QString hostNameStatus READ hostNameStatus NOTIFY hostNameStatusChanged )
|
||||
Q_PROPERTY( HostNameAction hostNameAction READ hostNameAction CONSTANT )
|
||||
Q_PROPERTY( QString hostname READ hostname WRITE setHostName NOTIFY hostnameChanged )
|
||||
Q_PROPERTY( QString hostnameStatus READ hostnameStatus NOTIFY hostnameStatusChanged )
|
||||
Q_PROPERTY( HostNameAction hostnameAction READ hostnameAction CONSTANT )
|
||||
|
||||
Q_PROPERTY( QString userPassword READ userPassword WRITE setUserPassword NOTIFY userPasswordChanged )
|
||||
Q_PROPERTY( QString userPasswordSecondary READ userPasswordSecondary WRITE setUserPasswordSecondary NOTIFY
|
||||
@ -202,17 +202,17 @@ public:
|
||||
QString loginNameStatus() const;
|
||||
|
||||
/// The host name (name for the system)
|
||||
QString hostName() const
|
||||
QString hostname() const
|
||||
{
|
||||
return ( ( hostNameAction() == HostNameAction::EtcHostname )
|
||||
|| ( hostNameAction() == HostNameAction::SystemdHostname ) )
|
||||
? m_hostName
|
||||
return ( ( hostnameAction() == HostNameAction::EtcHostname )
|
||||
|| ( hostnameAction() == HostNameAction::SystemdHostname ) )
|
||||
? m_hostname
|
||||
: QString();
|
||||
}
|
||||
/// Status message about hostname -- empty for "ok"
|
||||
QString hostNameStatus() const;
|
||||
QString hostnameStatus() const;
|
||||
/// How to write the hostname
|
||||
HostNameAction hostNameAction() const { return m_hostNameAction; }
|
||||
HostNameAction hostnameAction() const { return m_hostnameAction; }
|
||||
/// Write /etc/hosts ?
|
||||
bool writeEtcHosts() const { return m_writeEtcHosts; }
|
||||
|
||||
@ -299,8 +299,8 @@ signals:
|
||||
void fullNameChanged( const QString& );
|
||||
void loginNameChanged( const QString& );
|
||||
void loginNameStatusChanged( const QString& );
|
||||
void hostNameChanged( const QString& );
|
||||
void hostNameStatusChanged( const QString& );
|
||||
void hostnameChanged( const QString& );
|
||||
void hostnameStatusChanged( const QString& );
|
||||
void autoLoginChanged( bool );
|
||||
void reuseUserPasswordForRootChanged( bool );
|
||||
void requireStrongPasswordsChanged( bool );
|
||||
@ -323,7 +323,7 @@ private:
|
||||
SudoStyle m_sudoStyle = SudoStyle::UserOnly;
|
||||
QString m_fullName;
|
||||
QString m_loginName;
|
||||
QString m_hostName;
|
||||
QString m_hostname;
|
||||
|
||||
QString m_userPassword;
|
||||
QString m_userPasswordSecondary; // enter again to be sure
|
||||
@ -343,7 +343,7 @@ private:
|
||||
|
||||
bool m_isReady = false; ///< Used to reduce readyChanged signals
|
||||
|
||||
HostNameAction m_hostNameAction = HostNameAction::EtcHostname;
|
||||
HostNameAction m_hostnameAction = HostNameAction::EtcHostname;
|
||||
bool m_writeEtcHosts = false;
|
||||
PasswordCheckList m_passwordChecks;
|
||||
};
|
||||
|
@ -33,21 +33,21 @@ SetHostNameJob::SetHostNameJob( const Config* c )
|
||||
QString
|
||||
SetHostNameJob::prettyName() const
|
||||
{
|
||||
return tr( "Set hostname %1" ).arg( m_config->hostName() );
|
||||
return tr( "Set hostname %1" ).arg( m_config->hostname() );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SetHostNameJob::prettyDescription() const
|
||||
{
|
||||
return tr( "Set hostname <strong>%1</strong>." ).arg( m_config->hostName() );
|
||||
return tr( "Set hostname <strong>%1</strong>." ).arg( m_config->hostname() );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SetHostNameJob::prettyStatusMessage() const
|
||||
{
|
||||
return tr( "Setting hostname %1." ).arg( m_config->hostName() );
|
||||
return tr( "Setting hostname %1." ).arg( m_config->hostname() );
|
||||
}
|
||||
|
||||
STATICTEST bool
|
||||
@ -131,12 +131,12 @@ SetHostNameJob::exec()
|
||||
return Calamares::JobResult::error( tr( "Internal Error" ) );
|
||||
}
|
||||
|
||||
switch ( m_config->hostNameAction() )
|
||||
switch ( m_config->hostnameAction() )
|
||||
{
|
||||
case HostNameAction::None:
|
||||
break;
|
||||
case HostNameAction::EtcHostname:
|
||||
if ( !setFileHostname( m_config->hostName() ) )
|
||||
if ( !setFileHostname( m_config->hostname() ) )
|
||||
{
|
||||
cError() << "Can't write to hostname file";
|
||||
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
||||
@ -144,7 +144,7 @@ SetHostNameJob::exec()
|
||||
break;
|
||||
case HostNameAction::SystemdHostname:
|
||||
// Does its own logging
|
||||
setSystemdHostname( m_config->hostName() );
|
||||
setSystemdHostname( m_config->hostname() );
|
||||
break;
|
||||
case HostNameAction::Transient:
|
||||
CalamaresUtils::System::instance()->removeTargetFile( QStringLiteral( "/etc/hostname" ) );
|
||||
@ -153,7 +153,7 @@ SetHostNameJob::exec()
|
||||
|
||||
if ( m_config->writeEtcHosts() )
|
||||
{
|
||||
if ( !writeFileEtcHosts( m_config->hostName() ) )
|
||||
if ( !writeFileEtcHosts( m_config->hostname() ) )
|
||||
{
|
||||
cError() << "Can't write to hosts file";
|
||||
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
||||
|
@ -268,13 +268,13 @@ UserTests::testHostActions2()
|
||||
|
||||
// Test defaults
|
||||
c.setConfigurationMap( legacy );
|
||||
QCOMPARE( c.hostNameAction(), HostNameAction::EtcHostname );
|
||||
QCOMPARE( c.hostnameAction(), HostNameAction::EtcHostname );
|
||||
QCOMPARE( c.writeEtcHosts(), true );
|
||||
|
||||
legacy.insert( "writeHostsFile", false );
|
||||
legacy.insert( "setHostname", "Hostnamed" );
|
||||
c.setConfigurationMap( legacy );
|
||||
QCOMPARE( c.hostNameAction(), HostNameAction::SystemdHostname );
|
||||
QCOMPARE( c.hostnameAction(), HostNameAction::SystemdHostname );
|
||||
QCOMPARE( c.writeEtcHosts(), false );
|
||||
}
|
||||
|
||||
|
@ -106,13 +106,13 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
||||
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
|
||||
|
||||
// If the hostname is going to be written out, then show the field
|
||||
if ( ( m_config->hostNameAction() == HostNameAction::EtcHostname )
|
||||
|| ( m_config->hostNameAction() == HostNameAction::SystemdHostname ) )
|
||||
if ( ( m_config->hostnameAction() == HostNameAction::EtcHostname )
|
||||
|| ( m_config->hostnameAction() == HostNameAction::SystemdHostname ) )
|
||||
{
|
||||
ui->textBoxHostname->setText( config->hostName() );
|
||||
ui->textBoxHostname->setText( config->hostname() );
|
||||
connect( ui->textBoxHostname, &QLineEdit::textEdited, config, &Config::setHostName );
|
||||
connect( config,
|
||||
&Config::hostNameChanged,
|
||||
&Config::hostnameChanged,
|
||||
[ this ]( const QString& name )
|
||||
{
|
||||
if ( !ui->textBoxHostname->hasFocus() )
|
||||
@ -120,7 +120,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
||||
ui->textBoxHostname->setText( name );
|
||||
}
|
||||
} );
|
||||
connect( config, &Config::hostNameStatusChanged, this, &UsersPage::reportHostNameStatus );
|
||||
connect( config, &Config::hostnameStatusChanged, this, &UsersPage::reportHostNameStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -168,7 +168,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
||||
onReuseUserPasswordChanged( m_config->reuseUserPasswordForRoot() );
|
||||
onFullNameTextEdited( m_config->fullName() );
|
||||
reportLoginNameStatus( m_config->loginNameStatus() );
|
||||
reportHostNameStatus( m_config->hostNameStatus() );
|
||||
reportHostNameStatus( m_config->hostnameStatus() );
|
||||
|
||||
ui->textBoxLoginName->setEnabled( m_config->isEditable( "loginName" ) );
|
||||
ui->textBoxFullName->setEnabled( m_config->isEditable( "fullName" ) );
|
||||
@ -231,7 +231,7 @@ UsersPage::reportLoginNameStatus( const QString& status )
|
||||
void
|
||||
UsersPage::reportHostNameStatus( const QString& status )
|
||||
{
|
||||
labelStatus( ui->labelHostname, ui->labelHostnameError, m_config->hostName(), status );
|
||||
labelStatus( ui->labelHostname, ui->labelHostnameError, m_config->hostname(), status );
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -149,7 +149,7 @@ Kirigami.ScrollablePage {
|
||||
id: _hostName
|
||||
width: parent.width
|
||||
placeholderText: qsTr("Computer Name")
|
||||
text: config.hostName
|
||||
text: config.hostname
|
||||
validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ }
|
||||
|
||||
onTextChanged: acceptableInput
|
||||
|
Loading…
Reference in New Issue
Block a user