diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 0c0420f..b5336d0 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -12,6 +12,7 @@ set(SOURCES diskPanes/lvmdiskpane.h diskPanes/lvmdiskpane.cpp diskPanes/lvmdiskpane.ui popovers/smartpopover.cpp popovers/smartpopover.ui + popovers/pvremovepopover.h popovers/pvremovepopover.cpp popovers/pvremovepopover.ui diskpane.cpp diskpane.ui mainwindow.cpp mainwindow.ui operations/creatediskimagepopover.cpp operations/creatediskimagepopover.ui diff --git a/application/diskPanes/lvmdiskpane.cpp b/application/diskPanes/lvmdiskpane.cpp index dc0520b..8f36a56 100644 --- a/application/diskPanes/lvmdiskpane.cpp +++ b/application/diskPanes/lvmdiskpane.cpp @@ -1,6 +1,7 @@ #include "lvmdiskpane.h" #include "ui_lvmdiskpane.h" +#include "popovers/pvremovepopover.h" #include #include #include @@ -8,6 +9,7 @@ #include #include #include +#include struct LvmDiskPanePrivate { DiskObject* disk; @@ -23,8 +25,6 @@ LvmDiskPane::LvmDiskPane(DiskObject* disk, QWidget* parent) : connect(disk, &DiskObject::interfaceAdded, this, &LvmDiskPane::updateDetails); connect(disk, &DiskObject::interfaceRemoved, this, &LvmDiskPane::updateDetails); - ui->evictDataButton->setProperty("type", "destructive"); - this->updateDetails(); } @@ -50,12 +50,12 @@ void LvmDiskPane::updateDetails() { auto pv = d->disk->interface(); if (pv && pv->volumeGroup()) { ui->lvmDescription->setText(tr("This block is part of the %1 volume group.").arg(QLocale().quoteString(pv->volumeGroup()->name()))); - ui->evictDataButton->setVisible(true); + ui->pvSettingsButton->setVisible(true); ui->viewVgButton->setVisible(true); ui->attachVgButton->setVisible(false); } else { ui->lvmDescription->setText(tr("This block is not part of a volume group.")); - ui->evictDataButton->setVisible(false); + ui->pvSettingsButton->setVisible(false); ui->viewVgButton->setVisible(false); ui->attachVgButton->setVisible(true); } @@ -68,3 +68,14 @@ int LvmDiskPane::order() const { void LvmDiskPane::on_attachVgButton_clicked() { DiskOperationManager::showDiskOperationUi(this->window(), DiskOperationManager::AttachPv, d->disk); } + +void LvmDiskPane::on_pvSettingsButton_clicked() { + auto* jp = new PvRemovePopover(d->disk); + tPopover* popover = new tPopover(jp); + popover->setPopoverWidth(-200); + popover->setPopoverSide(tPopover::Bottom); + connect(jp, &PvRemovePopover::done, popover, &tPopover::dismiss); + connect(popover, &tPopover::dismissed, popover, &tPopover::deleteLater); + connect(popover, &tPopover::dismissed, jp, &PvRemovePopover::deleteLater); + popover->show(this->window()); +} diff --git a/application/diskPanes/lvmdiskpane.h b/application/diskPanes/lvmdiskpane.h index f532f98..abf6f43 100644 --- a/application/diskPanes/lvmdiskpane.h +++ b/application/diskPanes/lvmdiskpane.h @@ -27,6 +27,7 @@ class LvmDiskPane : public DiskPaneComponent { int order() const; private slots: void on_attachVgButton_clicked(); + void on_pvSettingsButton_clicked(); }; #endif // LVMDISKPANE_H diff --git a/application/diskPanes/lvmdiskpane.ui b/application/diskPanes/lvmdiskpane.ui index e6b3227..356c51c 100644 --- a/application/diskPanes/lvmdiskpane.ui +++ b/application/diskPanes/lvmdiskpane.ui @@ -6,7 +6,7 @@ 0 0 - 400 + 499 89 @@ -79,12 +79,12 @@ - + - Relocate Data + Manage Physical Volume - + .. @@ -102,7 +102,8 @@ Attach to Volume Group - + + .. diff --git a/application/lvm/lvmpage.cpp b/application/lvm/lvmpage.cpp index 7df39ef..715fc73 100644 --- a/application/lvm/lvmpage.cpp +++ b/application/lvm/lvmpage.cpp @@ -20,8 +20,13 @@ LvmPage::LvmPage(QWidget* parent) : d->vgModel->setShowAddButton(false); ui->listView->setModel(d->vgModel); + ui->noVgIcon->setPixmap(QIcon::fromTheme("drive-logical-volume").pixmap(QSize(128, 128))); + ui->stackedWidget->setCurrentAnimation(tStackedWidget::Fade); ui->stackedWidget_2->setCurrentAnimation(tStackedWidget::Lift); + + connect(d->vgModel, &VolumeGroupModel::dataChanged, this, &LvmPage::updatePage); + updatePage(); } LvmPage::~LvmPage() { @@ -46,3 +51,11 @@ void LvmPage::on_listView_clicked(const QModelIndex& index) { ui->stackedWidget_2->setCurrentWidget(vgPage); } } + +void LvmPage::updatePage() { + if (d->vgModel->rowCount() == 0) { + ui->stackedWidget->setCurrentWidget(ui->noVgsPage); + } else { + ui->stackedWidget->setCurrentWidget(ui->vgListPage); + } +} diff --git a/application/lvm/lvmpage.h b/application/lvm/lvmpage.h index 8fb5ac6..18e7e8f 100644 --- a/application/lvm/lvmpage.h +++ b/application/lvm/lvmpage.h @@ -23,6 +23,8 @@ class LvmPage : public QWidget { private: Ui::LvmPage* ui; LvmPagePrivate* d; + + void updatePage(); }; #endif // LVMPAGE_H diff --git a/application/lvm/lvmpage.ui b/application/lvm/lvmpage.ui index dd1aebc..caa1b8d 100644 --- a/application/lvm/lvmpage.ui +++ b/application/lvm/lvmpage.ui @@ -31,7 +31,10 @@ - + + 0 + + 0 @@ -87,7 +90,77 @@ - + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 20 + + + + No Volume Groups + + + Qt::AlignCenter + + + + + + + false + + + TextLabel + + + Qt::AlignCenter + + + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + + Qt::AlignCenter + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + diff --git a/application/popovers/pvremovepopover.cpp b/application/popovers/pvremovepopover.cpp new file mode 100644 index 0000000..62110da --- /dev/null +++ b/application/popovers/pvremovepopover.cpp @@ -0,0 +1,100 @@ +#include "pvremovepopover.h" +#include "ui_pvremovepopover.h" + +#include +#include +#include +#include +#include + +struct PvRemovePopoverPrivate { + DiskObject* disk; +}; + +PvRemovePopover::PvRemovePopover(DiskObject* disk, QWidget* parent) : + QWidget(parent), + ui(new Ui::PvRemovePopover) { + ui->setupUi(this); + d = new PvRemovePopoverPrivate(); + d->disk = disk; + + new tContentSizer(ui->actionsWidget); + new tContentSizer(ui->relocateDataWidget); + new tContentSizer(ui->removeWidget); + new tContentSizer(ui->doRemoveWidget); + + ui->stackedWidget->setCurrentAnimation(tStackedWidget::SlideHorizontal); + ui->removeButton->setProperty("type", "destructive"); + ui->removeButton_2->setProperty("type", "destructive"); + ui->doRemoveButton->setProperty("type", "destructive"); +} + +PvRemovePopover::~PvRemovePopover() { + delete d; + delete ui; +} + +void PvRemovePopover::on_titleLabel_backButtonClicked() { + emit done(); +} + +QCoro::Task<> PvRemovePopover::on_doRelocateButton_clicked() { + emit done(); + + auto disk = d->disk; + auto pv = disk->interface(); + auto vg = pv->volumeGroup(); + + co_await disk->lock(); + + try { + co_await vg->emptyDevice(disk, {}); + } catch (FrisbeeException ex) { + } + + disk->releaseLock(); +} + +void PvRemovePopover::on_titleLabel_2_backButtonClicked() { + ui->stackedWidget->setCurrentWidget(ui->settingsPage); +} + +void PvRemovePopover::on_relocateButton_clicked() { + ui->stackedWidget->setCurrentWidget(ui->relocatePage); +} + +void PvRemovePopover::on_titleLabel_3_backButtonClicked() { + ui->stackedWidget->setCurrentWidget(ui->settingsPage); +} + +void PvRemovePopover::on_removeButton_2_clicked() { + ui->stackedWidget->setCurrentWidget(ui->doRemovePage); +} + +void PvRemovePopover::on_titleLabel_4_backButtonClicked() { + ui->stackedWidget->setCurrentWidget(ui->removePage); +} + +QCoro::Task<> PvRemovePopover::on_doRemoveButton_clicked() { + emit done(); + + auto disk = d->disk; + auto pv = disk->interface(); + auto vg = pv->volumeGroup(); + + co_await disk->lock(); + + try { + if (pv->size() != pv->freeSize()) { + co_await vg->emptyDevice(disk, {}); + } + co_await vg->removeDevice(disk, ui->overwriteSpaceBox->isChecked(), {}); + } catch (FrisbeeException ex) { + } + + disk->releaseLock(); +} + +void PvRemovePopover::on_removeButton_clicked() { + ui->stackedWidget->setCurrentWidget(ui->removePage); +} diff --git a/application/popovers/pvremovepopover.h b/application/popovers/pvremovepopover.h new file mode 100644 index 0000000..3c1520d --- /dev/null +++ b/application/popovers/pvremovepopover.h @@ -0,0 +1,47 @@ +#ifndef PVREMOVEPOPOVER_H +#define PVREMOVEPOPOVER_H + +#include +#include + +namespace Ui { + class PvRemovePopover; +} + +class DiskObject; +struct PvRemovePopoverPrivate; +class PvRemovePopover : public QWidget { + Q_OBJECT + + public: + explicit PvRemovePopover(DiskObject* disk, QWidget* parent = nullptr); + ~PvRemovePopover(); + + signals: + void done(); + + private slots: + void on_titleLabel_backButtonClicked(); + + QCoro::Task<> on_doRelocateButton_clicked(); + + void on_titleLabel_2_backButtonClicked(); + + void on_relocateButton_clicked(); + + void on_titleLabel_3_backButtonClicked(); + + void on_removeButton_2_clicked(); + + void on_titleLabel_4_backButtonClicked(); + + QCoro::Task<> on_doRemoveButton_clicked(); + + void on_removeButton_clicked(); + + private: + Ui::PvRemovePopover* ui; + PvRemovePopoverPrivate* d; +}; + +#endif // PVREMOVEPOPOVER_H diff --git a/application/popovers/pvremovepopover.ui b/application/popovers/pvremovepopover.ui new file mode 100644 index 0000000..780b1ec --- /dev/null +++ b/application/popovers/pvremovepopover.ui @@ -0,0 +1,384 @@ + + + PvRemovePopover + + + + 0 + 0 + 763 + 511 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Manage Physical Volume + + + + + + + + + + Actions + + + + + + + 0 + + + + + Relocate Data + + + + ../../libthefrisbee/operations../../libthefrisbee/operations + + + + + + + Remove from Volume Group + + + + .. + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Relocate Data + + + + + + + + + + Relocate Data? + + + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + true + + + + + + + Once the data has been relocated, all extents on this block will be free. + + + true + + + + + + + Relocate Data + + + + ../../libthefrisbee/operations../../libthefrisbee/operations + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Remove from Volume Group + + + + + + + + + + Remove Options + + + + + + + Also overwrite space + + + + + + + Remove from Volume Group + + + + .. + + + + + + + + + + Qt::Vertical + + + + 20 + 400 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Remove from Volume Group + + + + + + + + + + This is it! + + + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + true + + + + + + + This operation can take some time. + + + true + + + + + + + Remove from Volume Group + + + + ../../libthefrisbee/operations../../libthefrisbee/operations + + + + + + + + + + Qt::Vertical + + + + 20 + 368 + + + + + + + + + + + + + tStackedWidget + QStackedWidget +
tstackedwidget.h
+ 1 + + switchingFrame(int) + +
+ + tTitleLabel + QLabel +
ttitlelabel.h
+ + backButtonClicked() + +
+ + tSubtitleLabel + QLabel +
tsubtitlelabel.h
+
+
+ + +
diff --git a/application/translations/ar_SA.ts b/application/translations/ar_SA.ts index ffead11..c40cb36 100644 --- a/application/translations/ar_SA.ts +++ b/application/translations/ar_SA.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/da.ts b/application/translations/da.ts index eb3db8d..04b0d8c 100644 --- a/application/translations/da.ts +++ b/application/translations/da.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ Ingen disk i drev + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/en_US.ts b/application/translations/en_US.ts index 357999c..b4b1bf6 100644 --- a/application/translations/en_US.ts +++ b/application/translations/en_US.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/he_IL.ts b/application/translations/he_IL.ts index 06ddee9..3dd4d28 100644 --- a/application/translations/he_IL.ts +++ b/application/translations/he_IL.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ לא הוכנס דיסק + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/ja.ts b/application/translations/ja.ts index 96a0535..207b2e7 100644 --- a/application/translations/ja.ts +++ b/application/translations/ja.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/pt_BR.ts b/application/translations/pt_BR.ts index c8551f0..c8b3b92 100644 --- a/application/translations/pt_BR.ts +++ b/application/translations/pt_BR.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/tr.ts b/application/translations/tr.ts index d44abcc..6f0ea5b 100644 --- a/application/translations/tr.ts +++ b/application/translations/tr.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ Disk Takılı Değil + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/application/translations/vi.ts b/application/translations/vi.ts index 0d707cd..c681460 100644 --- a/application/translations/vi.ts +++ b/application/translations/vi.ts @@ -129,7 +129,7 @@ - Relocate Data + Manage Physical Volume @@ -161,10 +161,20 @@ - + Volume Groups + + + No Volume Groups + + + + + Create an LVM Physical Volume and add it to a new Volume Group to start using LVM + + MainWindow @@ -352,6 +362,80 @@ Không có đĩa + + PvRemovePopover + + + Form + + + + + Manage Physical Volume + + + + + Actions + + + + + + + Relocate Data + + + + + + + + + Remove from Volume Group + + + + + Relocate Data? + + + + + Relocating data from this block will move extents from this block to other blocks in the volume group. + + + + + Once the data has been relocated, all extents on this block will be free. + + + + + Remove Options + + + + + Also overwrite space + + + + + This is it! + + + + + Removing this block from the volume group will make its space unavailable to the volume group. Used extents in this block will first be moved to free extents in other blocks in the volume group. + + + + + This operation can take some time. + + + SmartDiskPane diff --git a/libthefrisbee/DriveObjects/physicalvolumeinterface.cpp b/libthefrisbee/DriveObjects/physicalvolumeinterface.cpp index 314179f..31a1ff1 100644 --- a/libthefrisbee/DriveObjects/physicalvolumeinterface.cpp +++ b/libthefrisbee/DriveObjects/physicalvolumeinterface.cpp @@ -3,16 +3,27 @@ #include struct PhysicalVolumeInterfacePrivate { + QDBusObjectPath path; + QDBusObjectPath volumeGroup; + quint64 size; + quint64 freeSize; }; PhysicalVolumeInterface::PhysicalVolumeInterface(QDBusObjectPath path, QObject* parent) : DiskInterface{path, interfaceName(), parent} { d = new PhysicalVolumeInterfacePrivate(); + d->path = path; bindPropertyUpdater("VolumeGroup", [this](QVariant value) { d->volumeGroup = value.value(); }); + bindPropertyUpdater("Size", [this](QVariant value) { + d->size = value.toULongLong(); + }); + bindPropertyUpdater("FreeSize", [this](QVariant value) { + d->freeSize = value.toULongLong(); + }); } PhysicalVolumeInterface::~PhysicalVolumeInterface() { @@ -27,6 +38,14 @@ VolumeGroup* PhysicalVolumeInterface::volumeGroup() { return DriveObjectManager::volumeGroupForPath(d->volumeGroup); } +quint64 PhysicalVolumeInterface::size() { + return d->size; +} + +quint64 PhysicalVolumeInterface::freeSize() { + return d->freeSize; +} + DiskInterface::Interfaces PhysicalVolumeInterface::interfaceType() { return PhysicalVolume; } diff --git a/libthefrisbee/DriveObjects/physicalvolumeinterface.h b/libthefrisbee/DriveObjects/physicalvolumeinterface.h index 35dd737..57299b6 100644 --- a/libthefrisbee/DriveObjects/physicalvolumeinterface.h +++ b/libthefrisbee/DriveObjects/physicalvolumeinterface.h @@ -15,6 +15,8 @@ class PhysicalVolumeInterface : public DiskInterface { static QString interfaceName(); VolumeGroup* volumeGroup(); + quint64 size(); + quint64 freeSize(); private: PhysicalVolumeInterfacePrivate* d; diff --git a/libthefrisbee/DriveObjects/volumegroup.cpp b/libthefrisbee/DriveObjects/volumegroup.cpp index 14b70b4..fffa8f6 100644 --- a/libthefrisbee/DriveObjects/volumegroup.cpp +++ b/libthefrisbee/DriveObjects/volumegroup.cpp @@ -97,3 +97,19 @@ QCoro::Task VolumeGroup::createPlainVolume(QString name, quint64 auto lvPath = reply.arguments().first().value(); co_return DriveObjectManager::logicalVolumeForPath(lvPath); } + +QCoro::Task<> VolumeGroup::emptyDevice(DiskObject* block, QVariantMap options) { + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", d->path.path(), interfaceName(), "EmptyDevice"); + message.setArguments({block->path(), options}); + auto call = QDBusConnection::systemBus().asyncCall(message, 30000000); + auto reply = co_await call; + if (call.isError()) throw FrisbeeException(call.error().message()); +} + +QCoro::Task<> VolumeGroup::removeDevice(DiskObject* block, bool wipe, QVariantMap options) { + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", d->path.path(), interfaceName(), "RemoveDevice"); + message.setArguments({block->path(), wipe, options}); + auto call = QDBusConnection::systemBus().asyncCall(message, 30000000); + auto reply = co_await call; + if (call.isError()) throw FrisbeeException(call.error().message()); +} diff --git a/libthefrisbee/DriveObjects/volumegroup.h b/libthefrisbee/DriveObjects/volumegroup.h index a077748..1c1f9bf 100644 --- a/libthefrisbee/DriveObjects/volumegroup.h +++ b/libthefrisbee/DriveObjects/volumegroup.h @@ -25,6 +25,8 @@ class VolumeGroup : public UdisksInterface { QCoro::Task<> deleteVg(bool wipe, QVariantMap options); QCoro::Task<> addDevice(DiskObject* block, QVariantMap options); QCoro::Task createPlainVolume(QString name, quint64 size, QVariantMap options); + QCoro::Task<> emptyDevice(DiskObject* block, QVariantMap options); + QCoro::Task<> removeDevice(DiskObject* block, bool wipe, QVariantMap options); signals: void lvsChanged();