Skip to content

Commit

Permalink
Add option to load last-know-good patch list
Browse files Browse the repository at this point in the history
Contributes-To: sailfishos-patches#277
  • Loading branch information
nephros authored and nephros committed Nov 26, 2024
1 parent fa63042 commit eca3be2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
<method name="getLoaded">
<arg name="loaded" type="b" direction="out" />
</method>
<method name="revertToLastGood">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="resolveFailure">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
Expand Down
6 changes: 6 additions & 0 deletions src/bin/patchmanager-daemon/patchmanagerobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,12 @@ bool PatchManagerObject::getLoaded() const
return m_serverThread->isRunning();
}

void PatchManagerObject::revertToLastGood()
{
m_appliedPatches = getLastGoodPatches();
setAppliedPatches(m_appliedPatches);
}

/*!
Reset internal failure state and re-initialize.
Expand Down
1 change: 1 addition & 0 deletions src/bin/patchmanager-daemon/patchmanagerobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public slots:
bool getFailure() const;
bool getLoaded() const;
void resolveFailure();
void revertToLastGood();
void loadRequest(bool apply);

void lipstickChanged(const QString &state);
Expand Down
6 changes: 6 additions & 0 deletions src/qml/PatchManagerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ Page {
onClicked: pageStack.push(Qt.resolvedUrl("RestartServicesDialog.qml"))
}

MenuItem {
text: qsTranslate("", "Load Pre-Failure List")
visible: PatchManager.failure
onClicked: menuRemorse.execute( text, function() { PatchManager.call(PatchManager.revertToLastGood()) } )
}

MenuItem {
text: qsTranslate("", "Resolve failure")
visible: PatchManager.failure
Expand Down
7 changes: 7 additions & 0 deletions src/qml/patchmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,13 @@ void PatchManager::onLoadedChanged(bool loaded)
emit loadedChanged(m_loaded);
}

void PatchManager::revertToLastGood()
{
qDebug() << Q_FUNC_INFO;

m_interface->revertToLastGood();
}

/*! Calls the \e resolveFailure method on D-Bus */
void PatchManager::resolveFailure()
{
Expand Down
1 change: 1 addition & 0 deletions src/qml/patchmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public slots:
void onFailureChanged(bool failed);
void onLoadedChanged(bool loaded);

void revertToLastGood();
void resolveFailure();

signals:
Expand Down

0 comments on commit eca3be2

Please sign in to comment.