[partition] Add a job to handle automount behavior
- while here, nudge CalamaresUtils automount API a little, since it doesn't really need an rvalue-ref.
This commit is contained in:
parent
f3752e200a
commit
1704ad5977
@ -79,7 +79,7 @@ automountDisable( bool disable )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
automountRestore( std::shared_ptr< AutoMountInfo >&& t )
|
automountRestore( const std::shared_ptr< AutoMountInfo >& t )
|
||||||
{
|
{
|
||||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||||
enableSolidAutoMount( dbus, t->wasSolidModuleAutoLoaded );
|
enableSolidAutoMount( dbus, t->wasSolidModuleAutoLoaded );
|
||||||
|
@ -43,7 +43,7 @@ DLLEXPORT std::shared_ptr< AutoMountInfo > automountDisable( bool disable = true
|
|||||||
* Pass the value returned from automountDisable() to restore the
|
* Pass the value returned from automountDisable() to restore the
|
||||||
* previous settings.
|
* previous settings.
|
||||||
*/
|
*/
|
||||||
DLLEXPORT void automountRestore( std::shared_ptr< AutoMountInfo >&& t );
|
DLLEXPORT void automountRestore( const std::shared_ptr< AutoMountInfo >& t );
|
||||||
|
|
||||||
} // namespace Partition
|
} // namespace Partition
|
||||||
} // namespace CalamaresUtils
|
} // namespace CalamaresUtils
|
||||||
|
@ -79,6 +79,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
|
|||||||
gui/ScanningDialog.cpp
|
gui/ScanningDialog.cpp
|
||||||
gui/ReplaceWidget.cpp
|
gui/ReplaceWidget.cpp
|
||||||
gui/VolumeGroupBaseDialog.cpp
|
gui/VolumeGroupBaseDialog.cpp
|
||||||
|
jobs/AutoMountManagementJob.cpp
|
||||||
jobs/ClearMountsJob.cpp
|
jobs/ClearMountsJob.cpp
|
||||||
jobs/ClearTempMountsJob.cpp
|
jobs/ClearTempMountsJob.cpp
|
||||||
jobs/CreatePartitionJob.cpp
|
jobs/CreatePartitionJob.cpp
|
||||||
|
39
src/modules/partition/jobs/AutoMountManagementJob.cpp
Normal file
39
src/modules/partition/jobs/AutoMountManagementJob.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Calamares is Free Software: see the License-Identifier above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AutoMountManagementJob.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
AutoMountManagementJob::AutoMountManagementJob( bool disable )
|
||||||
|
: m_disable( disable )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
AutoMountManagementJob::prettyName() const
|
||||||
|
{
|
||||||
|
return tr( "Manage auto-mount settings" );
|
||||||
|
}
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
AutoMountManagementJob::exec()
|
||||||
|
{
|
||||||
|
cDebug() << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored.get() );
|
||||||
|
if ( m_stored )
|
||||||
|
{
|
||||||
|
CalamaresUtils::Partition::automountRestore( m_stored );
|
||||||
|
m_stored.reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_stored = CalamaresUtils::Partition::automountDisable( m_disable );
|
||||||
|
}
|
||||||
|
return Calamares::JobResult::ok();
|
||||||
|
}
|
42
src/modules/partition/jobs/AutoMountManagementJob.h
Normal file
42
src/modules/partition/jobs/AutoMountManagementJob.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Calamares is Free Software: see the License-Identifier above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PARTITION_AUTOMOUNTMANAGEMENTJOB_H
|
||||||
|
#define PARTITION_AUTOMOUNTMANAGEMENTJOB_H
|
||||||
|
|
||||||
|
#include "Job.h"
|
||||||
|
|
||||||
|
#include "partition/AutoMount.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This job sets automounting to a specific value, and when run a
|
||||||
|
* second time, **re**sets to the original value. See the documentation
|
||||||
|
* for CalamaresUtils::Partition::automountDisable() for details.
|
||||||
|
* Use @c true to **disable** automounting.
|
||||||
|
*
|
||||||
|
* Effectively: queue the **same** job twice; the first time it runs
|
||||||
|
* it will set the automount behavior, and the second time it
|
||||||
|
* restores the original.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class AutoMountManagementJob : public Calamares::Job
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AutoMountManagementJob( bool disable = true );
|
||||||
|
|
||||||
|
QString prettyName() const override;
|
||||||
|
Calamares::JobResult exec() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_disable;
|
||||||
|
decltype( CalamaresUtils::Partition::automountDisable( true ) ) m_stored;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PARTITION_AUTOMOUNTMANAGEMENTJOB_H */
|
Loading…
Reference in New Issue
Block a user