From 93ce2daff0929aef0f1abefcc2f72304d8fd6909 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 27 Dec 2023 00:41:03 +0100 Subject: [PATCH] [machineid] Drop namespace to avoid lupdate warnings --- src/modules/machineid/MachineIdJob.cpp | 20 ++++++++++---------- src/modules/machineid/MachineIdJob.h | 2 +- src/modules/machineid/Tests.cpp | 6 +++--- src/modules/machineid/Workers.cpp | 19 ++++++++----------- src/modules/machineid/Workers.h | 10 ++-------- 5 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/modules/machineid/MachineIdJob.cpp b/src/modules/machineid/MachineIdJob.cpp index 9bc1b3f6f..87ebb0e40 100644 --- a/src/modules/machineid/MachineIdJob.cpp +++ b/src/modules/machineid/MachineIdJob.cpp @@ -23,13 +23,13 @@ #include -const NamedEnumTable< MachineId::SystemdMachineIdStyle >& +const NamedEnumTable< SystemdMachineIdStyle >& styleNames() { - using T = MachineId::SystemdMachineIdStyle; + using T = SystemdMachineIdStyle; // *INDENT-OFF* // clang-format off - static const NamedEnumTable< MachineId::SystemdMachineIdStyle > names { + static const NamedEnumTable< SystemdMachineIdStyle > names { { QStringLiteral( "none" ), T::Blank }, { QStringLiteral( "blank" ), T::Blank }, { QStringLiteral( "uuid" ), T::Uuid }, @@ -101,8 +101,8 @@ MachineIdJob::exec() QObject::tr( "Directory not found" ), QObject::tr( "Could not create new random file
%1
." ).arg( entropy_file ) ); } - auto r = MachineId::createEntropy( m_entropy_copy ? MachineId::EntropyGeneration::CopyFromHost - : MachineId::EntropyGeneration::New, + auto r = createEntropy( m_entropy_copy ? EntropyGeneration::CopyFromHost + : EntropyGeneration::New, root, entropy_file ); if ( !r ) @@ -116,7 +116,7 @@ MachineIdJob::exec() { cWarning() << "Could not create systemd data-directory."; } - auto r = MachineId::createSystemdMachineId( m_systemd_style, root, target_systemd_machineid_file ); + auto r = createSystemdMachineId( m_systemd_style, root, target_systemd_machineid_file ); if ( !r ) { return r; @@ -130,7 +130,7 @@ MachineIdJob::exec() } if ( m_dbus_symlink && QFile::exists( root + target_systemd_machineid_file ) ) { - auto r = MachineId::createDBusLink( root, target_dbus_machineid_file, target_systemd_machineid_file ); + auto r = createDBusLink( root, target_dbus_machineid_file, target_systemd_machineid_file ); if ( !r ) { return r; @@ -138,7 +138,7 @@ MachineIdJob::exec() } else { - auto r = MachineId::createDBusMachineId( root, target_dbus_machineid_file ); + auto r = createDBusMachineId( root, target_dbus_machineid_file ); if ( !r ) { return r; @@ -157,7 +157,7 @@ MachineIdJob::setConfigurationMap( const QVariantMap& map ) const auto style = Calamares::getString( map, "systemd-style", QString() ); if ( !style.isEmpty() ) { - m_systemd_style = styleNames().find( style, MachineId::SystemdMachineIdStyle::Uuid ); + m_systemd_style = styleNames().find( style, SystemdMachineIdStyle::Uuid ); } m_dbus = Calamares::getBool( map, "dbus", false ); @@ -179,7 +179,7 @@ MachineIdJob::setConfigurationMap( const QVariantMap& map ) m_entropy_files = Calamares::getStringList( map, "entropy-files" ); if ( Calamares::getBool( map, "entropy", false ) ) { - cWarning() << "MachineId:: configuration setting *entropy* is deprecated, use *entropy-files* instead."; + cWarning() << " configuration setting *entropy* is deprecated, use *entropy-files* instead."; m_entropy_files.append( QStringLiteral( "/var/lib/urandom/random-seed" ) ); } m_entropy_files.removeDuplicates(); diff --git a/src/modules/machineid/MachineIdJob.h b/src/modules/machineid/MachineIdJob.h index b564b3708..102918228 100644 --- a/src/modules/machineid/MachineIdJob.h +++ b/src/modules/machineid/MachineIdJob.h @@ -48,7 +48,7 @@ public: private: bool m_systemd = false; ///< write systemd's files - MachineId::SystemdMachineIdStyle m_systemd_style = MachineId::SystemdMachineIdStyle::Uuid; + SystemdMachineIdStyle m_systemd_style = SystemdMachineIdStyle::Uuid; bool m_dbus = false; ///< write dbus files bool m_dbus_symlink = false; ///< .. or just symlink to systemd diff --git a/src/modules/machineid/Tests.cpp b/src/modules/machineid/Tests.cpp index 9209f7998..915812814 100644 --- a/src/modules/machineid/Tests.cpp +++ b/src/modules/machineid/Tests.cpp @@ -127,18 +127,18 @@ MachineIdTests::testCopyFile() QVERIFY( source.exists() ); // This should fail since "example" isn't standard in our test directory - auto r0 = MachineId::copyFile( tempRoot.path(), "example" ); + auto r0 = copyFile( tempRoot.path(), "example" ); QVERIFY( !r0 ); const QString sampleFile = QStringLiteral( "CMakeCache.txt" ); if ( QFile::exists( sampleFile ) ) { - auto r1 = MachineId::copyFile( tempRoot.path(), sampleFile ); + auto r1 = copyFile( tempRoot.path(), sampleFile ); // Also fail, because it's not an absolute path QVERIFY( !r1 ); QVERIFY( QFile::copy( sampleFile, tempISOdir.path() + '/' + sampleFile ) ); - auto r2 = MachineId::copyFile( tempRoot.path(), tempISOdir.path() + '/' + sampleFile ); + auto r2 = copyFile( tempRoot.path(), tempISOdir.path() + '/' + sampleFile ); QVERIFY( r2 ); } } diff --git a/src/modules/machineid/Workers.cpp b/src/modules/machineid/Workers.cpp index 1dd2321cf..fe86401d5 100644 --- a/src/modules/machineid/Workers.cpp +++ b/src/modules/machineid/Workers.cpp @@ -12,6 +12,8 @@ #include "Workers.h" +#include "MachineIdJob.h" + #include "utils/Entropy.h" #include "utils/Logger.h" #include "utils/System.h" @@ -46,9 +48,6 @@ getUrandomPoolSize() return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize; } -namespace MachineId -{ - static inline bool isAbsolutePath( const QString& fileName ) { @@ -61,19 +60,19 @@ copyFile( const QString& rootMountPoint, const QString& fileName ) if ( !isAbsolutePath( fileName ) ) { return Calamares::JobResult::internalError( - QObject::tr( "File not found" ), - QObject::tr( "Path
%1
must be an absolute path." ).arg( fileName ), + MachineIdJob::tr( "File not found" ), + MachineIdJob::tr( "Path
%1
must be an absolute path." ).arg( fileName ), 0 ); } QFile f( fileName ); if ( !f.exists() ) { - return Calamares::JobResult::error( QObject::tr( "File not found" ), fileName ); + return Calamares::JobResult::error( MachineIdJob::tr( "File not found" ), fileName ); } if ( !f.copy( rootMountPoint + fileName ) ) { - return Calamares::JobResult::error( QObject::tr( "File not found" ), rootMountPoint + fileName ); + return Calamares::JobResult::error( MachineIdJob::tr( "File not found" ), rootMountPoint + fileName ); } return Calamares::JobResult::ok(); } @@ -90,8 +89,8 @@ createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fi if ( !entropyFile.open( QIODevice::WriteOnly ) ) { return Calamares::JobResult::error( - QObject::tr( "File not found" ), - QObject::tr( "Could not create new random file
%1
." ).arg( fileName ) ); + MachineIdJob::tr( "File not found" ), + MachineIdJob::tr( "Could not create new random file
%1
." ).arg( fileName ) ); } QByteArray data; @@ -190,5 +189,3 @@ createDBusLink( const QString& rootMountPoint, const QString& fileName, const QS Q_UNUSED( rootMountPoint ) return runCmd( QStringList { QStringLiteral( "ln" ), QStringLiteral( "-sf" ), systemdFileName, fileName }, true ); } - -} // namespace MachineId diff --git a/src/modules/machineid/Workers.h b/src/modules/machineid/Workers.h index 577090a46..7665a1571 100644 --- a/src/modules/machineid/Workers.h +++ b/src/modules/machineid/Workers.h @@ -7,14 +7,11 @@ * */ -#ifndef WORKERS_H -#define WORKERS_H +#ifndef MACHINEID_WORKERS_H +#define MACHINEID_WORKERS_H #include "Job.h" -/// @brief Utility functions for doing the random-data stuff for MachineId -namespace MachineId -{ /** @brief Utility functions * * These probably belong in libcalamares, since they're general utilities @@ -70,7 +67,4 @@ enum class SystemdMachineIdStyle Calamares::JobResult createSystemdMachineId( SystemdMachineIdStyle style, const QString& rootMountPoint, const QString& fileName ); - -} // namespace MachineId - #endif // WORKERS_H