Commit faf67470 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

fwupd: remove unneeded complexity

It doesn't make sense, conceptually, to uninstall a firmware.
parent 7ccd0c47
......@@ -659,17 +659,19 @@ AbstractReviewsBackend* FwupdBackend::reviewsBackend() const
Transaction* FwupdBackend::installApplication(AbstractResource* app, const AddonList& addons)
{
return new FwupdTransaction(qobject_cast<FwupdResource*>(app), this, addons, Transaction::InstallRole);
Q_ASSERT(addons.isEmpty());
return installApplication(app);
}
Transaction* FwupdBackend::installApplication(AbstractResource* app)
{
return new FwupdTransaction(qobject_cast<FwupdResource*>(app), this, Transaction::InstallRole);
return new FwupdTransaction(qobject_cast<FwupdResource*>(app), this);
}
Transaction* FwupdBackend::removeApplication(AbstractResource* app)
{
return new FwupdTransaction(qobject_cast<FwupdResource*>(app), this, Transaction::RemoveRole);
qWarning() << "should not have reached here, it's not possible to uninstall a firmware";
return nullptr;
}
void FwupdBackend::checkForUpdates()
......
......@@ -23,27 +23,15 @@
#include <QTimer>
FwupdTransaction::FwupdTransaction(FwupdResource* app, FwupdBackend* backend, Role role)
: FwupdTransaction(app, backend,{}, role)
{
}
FwupdTransaction::FwupdTransaction(FwupdResource* app, FwupdBackend* backend, const AddonList& addons, Transaction::Role role)
: Transaction(app->backend(), app, role, addons)
FwupdTransaction::FwupdTransaction(FwupdResource* app, FwupdBackend* backend)
: Transaction(backend, app, Transaction::InstallRole, {})
, m_app(app)
, m_backend(backend)
{
setCancellable(true);
setStatus(QueuedStatus);
if(role == InstallRole)
{
QTimer::singleShot(0, this, &FwupdTransaction::install);
}
else if(role == RemoveRole)
{
QTimer::singleShot(0, this, &FwupdTransaction::remove);
}
QTimer::singleShot(0, this, &FwupdTransaction::install);
}
FwupdTransaction::~FwupdTransaction() = default;
......@@ -123,13 +111,6 @@ void FwupdTransaction::fwupdInstall()
finishTransaction();
}
void FwupdTransaction::remove()
{
qWarning() << "something horrible has happened";
m_app->setState(AbstractResource::State::None);
setStatus(DoneWithErrorStatus);
}
void FwupdTransaction::updateProgress()
{
setProgress(fwupd_client_get_percentage(m_backend->client));
......
......@@ -32,8 +32,8 @@ class FwupdTransaction : public Transaction
{
Q_OBJECT
public:
FwupdTransaction(FwupdResource* app, FwupdBackend* backend, Role role);
FwupdTransaction(FwupdResource* app, FwupdBackend* backend, const AddonList& list, Role role);
FwupdTransaction(FwupdResource* app, FwupdBackend* backend);
FwupdTransaction(FwupdResource* app, FwupdBackend* backend, const AddonList& list);
~FwupdTransaction();
void cancel() override;
void proceed() override;
......@@ -45,7 +45,6 @@ class FwupdTransaction : public Transaction
private:
void install();
void remove();
FwupdResource* const m_app;
FwupdBackend* const m_backend;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment