users: adapt to Qt6
This commit is contained in:
parent
680d4f8dc2
commit
9d324bcccd
@ -3,7 +3,7 @@
|
||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network)
|
||||
find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core DBus Network)
|
||||
find_package(Crypt REQUIRED)
|
||||
|
||||
# Add optional libraries here
|
||||
@ -50,8 +50,8 @@ calamares_add_library(
|
||||
SOURCES
|
||||
${_users_src}
|
||||
LINK_LIBRARIES
|
||||
KF5::CoreAddons
|
||||
Qt5::DBus
|
||||
${kfname}::CoreAddons
|
||||
${qtname}::DBus
|
||||
${CRYPT_LIBRARIES}
|
||||
)
|
||||
|
||||
@ -80,8 +80,8 @@ calamares_add_test(
|
||||
TestGroupInformation.cpp
|
||||
${_users_src} # Build again with test-visibility
|
||||
LIBRARIES
|
||||
KF5::CoreAddons
|
||||
Qt5::DBus # HostName job can use DBus to systemd
|
||||
${kfname}::CoreAddons
|
||||
${qtname}::DBus # HostName job can use DBus to systemd
|
||||
${CRYPT_LIBRARIES} # SetPassword job uses crypt()
|
||||
${USER_EXTRA_LIB}
|
||||
)
|
||||
@ -90,7 +90,7 @@ calamares_add_test(
|
||||
usershostnametest
|
||||
SOURCES TestSetHostNameJob.cpp SetHostNameJob.cpp
|
||||
LIBRARIES
|
||||
Qt5::DBus # HostName job can use DBus to systemd
|
||||
${qtname}::DBus # HostName job can use DBus to systemd
|
||||
)
|
||||
|
||||
calamares_add_test(
|
||||
@ -99,8 +99,8 @@ calamares_add_test(
|
||||
Tests.cpp
|
||||
${_users_src} # Build again with test-visibility
|
||||
LIBRARIES
|
||||
KF5::CoreAddons
|
||||
Qt5::DBus # HostName job can use DBus to systemd
|
||||
${kfname}::CoreAddons
|
||||
${qtname}::DBus # HostName job can use DBus to systemd
|
||||
${CRYPT_LIBRARIES} # SetPassword job uses crypt()
|
||||
${USER_EXTRA_LIB}
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ PasswordCheck::PasswordCheck( MessageFunc m, AcceptFunc a, Weight weight )
|
||||
DEFINE_CHECK_FUNC( minLength )
|
||||
{
|
||||
int minLength = -1;
|
||||
if ( value.canConvert( QVariant::Int ) )
|
||||
if ( value.canConvert< int >() )
|
||||
{
|
||||
minLength = value.toInt();
|
||||
}
|
||||
@ -57,7 +57,7 @@ DEFINE_CHECK_FUNC( minLength )
|
||||
DEFINE_CHECK_FUNC( maxLength )
|
||||
{
|
||||
int maxLength = -1;
|
||||
if ( value.canConvert( QVariant::Int ) )
|
||||
if ( value.canConvert< int >() )
|
||||
{
|
||||
maxLength = value.toInt();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "compat/Variant.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/String.h"
|
||||
#include "utils/StringExpander.h"
|
||||
@ -24,7 +25,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QMetaProperty>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
#ifdef HAVE_ICU
|
||||
@ -41,10 +42,10 @@ static const char TRANSLITERATOR_ID[] = "Russian-Latin/BGN;"
|
||||
|
||||
#include <memory>
|
||||
|
||||
static const QRegExp USERNAME_RX( "^[a-z_][a-z0-9_-]*[$]?$" );
|
||||
static const QRegularExpression USERNAME_RX( "^[a-z_][a-z0-9_-]*[$]?$" ); // Note anchors begin and end
|
||||
static constexpr const int USERNAME_MAX_LENGTH = 31;
|
||||
|
||||
static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
|
||||
static const QRegularExpression HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); // Note anchors begin and end
|
||||
static constexpr const int HOSTNAME_MIN_LENGTH = 2;
|
||||
static constexpr const int HOSTNAME_MAX_LENGTH = 63;
|
||||
|
||||
@ -235,12 +236,12 @@ Config::loginNameStatus() const
|
||||
return tr( "Your username is too long." );
|
||||
}
|
||||
|
||||
QRegExp validateFirstLetter( "^[a-z_]" );
|
||||
if ( validateFirstLetter.indexIn( m_loginName ) != 0 )
|
||||
QRegularExpression validateFirstLetter( "^[a-z_]" );
|
||||
if ( m_loginName.indexOf( validateFirstLetter ) != 0 )
|
||||
{
|
||||
return tr( "Your username must start with a lowercase letter or underscore." );
|
||||
}
|
||||
if ( !USERNAME_RX.exactMatch( m_loginName ) )
|
||||
if ( m_loginName.indexOf( USERNAME_RX ) != 0 )
|
||||
{
|
||||
return tr( "Only lowercase letters, numbers, underscore and hyphen are allowed." );
|
||||
}
|
||||
@ -310,7 +311,7 @@ Config::hostnameStatus() const
|
||||
return tr( "'%1' is not allowed as hostname." ).arg( m_hostname );
|
||||
}
|
||||
|
||||
if ( !HOSTNAME_RX.exactMatch( m_hostname ) )
|
||||
if ( m_hostname.indexOf( HOSTNAME_RX ) != 0 )
|
||||
{
|
||||
return tr( "Only letters, numbers, underscore and hyphen are allowed." );
|
||||
}
|
||||
@ -321,7 +322,7 @@ Config::hostnameStatus() const
|
||||
static QString
|
||||
cleanupForHostname( const QString& s )
|
||||
{
|
||||
QRegExp dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", Qt::CaseInsensitive );
|
||||
QRegularExpression dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", QRegularExpression::CaseInsensitiveOption );
|
||||
return s.toLower().replace( dmirx, " " ).remove( ' ' );
|
||||
}
|
||||
|
||||
@ -412,7 +413,7 @@ makeLoginNameSuggestion( const QStringList& parts )
|
||||
}
|
||||
}
|
||||
|
||||
return USERNAME_RX.indexIn( usernameSuggestion ) != -1 ? usernameSuggestion : QString();
|
||||
return usernameSuggestion.indexOf( USERNAME_RX ) != -1 ? usernameSuggestion : QString();
|
||||
}
|
||||
|
||||
/** @brief Return an invalid string for use in a hostname, if @p s is empty
|
||||
@ -445,8 +446,8 @@ makeHostnameSuggestion( const QString& templateString, const QStringList& fullNa
|
||||
QString hostnameSuggestion = d.expand( templateString );
|
||||
|
||||
// RegExp for valid hostnames; if the suggestion produces a valid name, return it
|
||||
static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
|
||||
return HOSTNAME_RX.indexIn( hostnameSuggestion ) != -1 ? hostnameSuggestion : QString();
|
||||
static const QRegularExpression HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
|
||||
return hostnameSuggestion.indexOf( HOSTNAME_RX ) != -1 ? hostnameSuggestion : QString();
|
||||
}
|
||||
|
||||
void
|
||||
@ -483,10 +484,10 @@ Config::setFullName( const QString& name )
|
||||
emit fullNameChanged( name );
|
||||
|
||||
// Build login and hostname, if needed
|
||||
static QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive );
|
||||
static QRegularExpression rx( "[^a-zA-Z0-9 ]" );
|
||||
|
||||
const QString cleanName = Calamares::String::removeDiacritics( transliterate( name ) )
|
||||
.replace( QRegExp( "[-']" ), "" )
|
||||
.replace( QRegularExpression( "[-']" ), "" )
|
||||
.replace( rx, " " )
|
||||
.toLower()
|
||||
.simplified();
|
||||
@ -751,7 +752,7 @@ setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription >
|
||||
auto groupsFromConfig = map.value( key ).toList();
|
||||
if ( groupsFromConfig.isEmpty() )
|
||||
{
|
||||
if ( map.contains( key ) && map.value( key ).isValid() && map.value( key ).canConvert( QVariant::List ) )
|
||||
if ( map.contains( key ) && map.value( key ).isValid() && map.value( key ).canConvert< QVariantList >() )
|
||||
{
|
||||
// Explicitly set, but empty: this is valid, but unusual.
|
||||
cDebug() << key << "has explicit empty value.";
|
||||
@ -772,11 +773,11 @@ setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription >
|
||||
{
|
||||
for ( const auto& v : groupsFromConfig )
|
||||
{
|
||||
if ( v.type() == QVariant::String )
|
||||
if ( Calamares::typeOf( v ) == Calamares::StringVariantType )
|
||||
{
|
||||
defaultGroups.append( GroupDescription( v.toString() ) );
|
||||
}
|
||||
else if ( v.type() == QVariant::Map )
|
||||
else if ( Calamares::typeOf( v ) == Calamares::MapVariantType )
|
||||
{
|
||||
const auto innermap = v.toMap();
|
||||
QString name = CalamaresUtils::getString( innermap, "name" );
|
||||
|
@ -79,7 +79,7 @@ void
|
||||
GroupTests::testCreateGroup()
|
||||
{
|
||||
// BUILD_AS_TEST is the source-directory path
|
||||
QFile fi( QString( "%1/tests/5-issue-1523.conf" ).arg( BUILD_AS_TEST ) );
|
||||
QFileInfo fi( QString( "%1/tests/5-issue-1523.conf" ).arg( BUILD_AS_TEST ) );
|
||||
QVERIFY( fi.exists() );
|
||||
|
||||
bool ok = false;
|
||||
|
@ -214,7 +214,7 @@ UserTests::testDefaultGroupsYAML()
|
||||
QFETCH( QString, group );
|
||||
|
||||
// BUILD_AS_TEST is the source-directory path
|
||||
QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QVERIFY( fi.exists() );
|
||||
|
||||
bool ok = false;
|
||||
@ -450,7 +450,7 @@ UserTests::testAutoLogin()
|
||||
QFETCH( QString, autoLoginGroupName );
|
||||
|
||||
// BUILD_AS_TEST is the source-directory path
|
||||
QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QVERIFY( fi.exists() );
|
||||
|
||||
bool ok = false;
|
||||
@ -502,7 +502,7 @@ UserTests::testUserYAML()
|
||||
QFETCH( QString, shell );
|
||||
|
||||
// BUILD_AS_TEST is the source-directory path
|
||||
QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QVERIFY( fi.exists() );
|
||||
|
||||
bool ok = false;
|
||||
|
@ -8,7 +8,7 @@ if(NOT WITH_QML)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network)
|
||||
find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core DBus Network)
|
||||
find_package(Crypt REQUIRED)
|
||||
|
||||
# Add optional libraries here
|
||||
@ -46,6 +46,6 @@ calamares_add_plugin(usersq
|
||||
users_internal
|
||||
${CRYPT_LIBRARIES}
|
||||
${USER_EXTRA_LIB}
|
||||
Qt5::DBus
|
||||
${qtname}::DBus
|
||||
SHARED_LIB
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user