Skip to content

Commit

Permalink
Merge pull request #5 from sailfishos-patches/dev/unapply-all
Browse files Browse the repository at this point in the history
Added unapplyall patch and dbus method to daemon
  • Loading branch information
SfietKonstantin authored Aug 13, 2016
2 parents df4c9e3 + 1517a41 commit f453867
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 10 deletions.
2 changes: 2 additions & 0 deletions rpm/patchmanager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ dbus-send --system --type=method_call \
%{_datadir}/%{name}/tools
%{_datadir}/dbus-1/
%{_sysconfdir}/dbus-1/system.d/
%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/patch.json
%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/unified_diff.patch
# >> files
# << files

Expand Down
2 changes: 2 additions & 0 deletions rpm/patchmanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Files:
- '%{_datadir}/%{name}/tools'
- '%{_datadir}/dbus-1/'
- '%{_sysconfdir}/dbus-1/system.d/'
- '%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/patch.json'
- '%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/unified_diff.patch'
SubPackages:
- Name: ui
Summary: GUI for patchmanager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="PackageBackupStatus"/>
<arg name="packageStatus" type="(basas)" direction="out" />
</method>
<method name="unapplyAllPatches" />
<method name="unapplyAllPatches">
<arg name="ok" type="b" direction="out" />
</method>
<method name="quit" />
</interface>
</node>
8 changes: 8 additions & 0 deletions src/bin/patchmanager-daemon/patch/patch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Unapply all patches on Upgrade",
"description": "Patch for unapplying all patches when upgrading SailfishOS version. Do not unapply this patch manually, unless you want to completely uninstall Patchmanager.",
"category": "settings",
"infos": {
"maintainer": "coderus"
}
}
81 changes: 81 additions & 0 deletions src/bin/patchmanager-daemon/patch/unified_diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
diff --git a/usr/share/jolla-settings/pages/sailfishos/mainpage.qml b/usr/share/jolla-settings/pages/sailfishos/mainpage.qml
index ca5c814..c330236 100644
--- a/usr/share/jolla-settings/pages/sailfishos/mainpage.qml
+++ b/usr/share/jolla-settings/pages/sailfishos/mainpage.qml
@@ -127,6 +127,25 @@ Page {
iface: "org.nemomobile.lipstick"
}

+ DBusInterface {
+ id: patchmanagerBus
+ busType: DBusInterface.SystemBus
+ destination: "org.SfietKonstantin.patchmanager"
+ path: "/org/SfietKonstantin/patchmanager"
+ iface: "org.SfietKonstantin.patchmanager"
+ }
+
+ function unapplyAllCallback(arg) {
+ if (arg) {
+ // Let the UI smoothly fade out first before doing anything scary
+ shutdownBus.call("setShutdownMode", ["upgrade"])
+ // Clear the cache and the system update notification
+ storeIf.clearOsUpdateCheckCache()
+ } else {
+ patchmanagerBus.call("applyPatch", ["sailfishos-patchmanager-unapplyall"])
+ }
+ }
+
SilicaFlickable {
anchors.fill: parent
contentHeight: content.height
@@ -250,10 +269,7 @@ Page {
}
}
} else if (storeIf.mayInstall) {
- // Let the UI smoothly fade out first before doing anything scary
- shutdownBus.call("setShutdownMode", ["upgrade"])
- // Clear the cache and the system update notification
- storeIf.clearOsUpdateCheckCache()
+ patchmanagerBus.call("unapplyAllPatches", [], unapplyAllCallback)
}
}
}
index ca5c814..4fd6f01 100644
--- a/usr/share/jolla-settings/pages/sailfishos/mainpage.qml
+++ b/usr/share/jolla-settings/pages/sailfishos/mainpage.qml
@@ -127,6 +127,23 @@ Page {
iface: "org.nemomobile.lipstick"
}

+ DBusInterface {
+ id: patchmanagerBus
+ busType: DBusInterface.SystemBus
+ destination: "org.SfietKonstantin.patchmanager"
+ path: "/org/SfietKonstantin/patchmanager"
+ iface: "org.SfietKonstantin.patchmanager"
+ }
+
+ function unapplyAllCallback(arg) {
+ if (arg) {
+ // Let the UI smoothly fade out first before doing anything scary
+ shutdownBus.call("setShutdownMode", ["upgrade"])
+ // Clear the cache and the system update notification
+ storeIf.clearOsUpdateCheckCache()
+ }
+ }
+
SilicaFlickable {
anchors.fill: parent
contentHeight: content.height
@@ -250,10 +267,7 @@ Page {
}
}
} else if (storeIf.mayInstall) {
- // Let the UI smoothly fade out first before doing anything scary
- shutdownBus.call("setShutdownMode", ["upgrade"])
- // Clear the cache and the system update notification
- storeIf.clearOsUpdateCheckCache()
+ patchmanagerBus.call("unapplyAllPatches", [], unapplyAllCallback)
}
}
}
5 changes: 5 additions & 0 deletions src/bin/patchmanager-daemon/patchmanager-daemon.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ INSTALLS += dbusConf
tools.files = check-package.sh
tools.path = /usr/share/patchmanager/tools
INSTALLS += tools

# Patch
patch.path = /usr/share/patchmanager/patches/sailfishos-patchmanager-unapplyall
patch.files = patch/patch.json patch/unified_diff.patch
INSTALLS += patch
17 changes: 9 additions & 8 deletions src/bin/patchmanager-daemon/patchmanagerobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,17 @@ bool PatchManagerObject::unapplyPatch(const QString &patch)
return ok;
}

//void PatchManagerObject::unapplyAllPatches()
//{
bool PatchManagerObject::unapplyAllPatches()
{
// checkPatches();

// QStringList appliedPatches = m_appliedPatches.toList();
// foreach (const QString &patch, appliedPatches) {
// unapplyPatch(patch);
// }
bool ok = true;
QStringList appliedPatches = m_appliedPatches.toList();
foreach (const QString &patch, appliedPatches) {
ok &= unapplyPatch(patch);
}
return ok;
// quit();
//}
}

//void PatchManagerObject::checkPatches()
//{
Expand Down
2 changes: 1 addition & 1 deletion src/bin/patchmanager-daemon/patchmanagerobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public slots:
bool isPatchApplied(const QString &patch);
bool applyPatch(const QString &patch);
bool unapplyPatch(const QString &patch);
// void unapplyAllPatches();
bool unapplyAllPatches();
PackageBackupStatus checkLipstick();
void quit();
protected:
Expand Down

0 comments on commit f453867

Please sign in to comment.