Skip to content

Commit

Permalink
kde-plasma/bluedevil: Save bluetooth status on teardown
Browse files Browse the repository at this point in the history
Upstream commit daaa18920ae93b482585eb3df790a6d5a647b6db
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=445376
Package-Manager: Portage-3.0.29, Repoman-3.0.3
Signed-off-by: Andreas Sturmlechner <[email protected]>
  • Loading branch information
a17r committed Dec 10, 2021
1 parent 1a6f054 commit ec9c85c
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
45 changes: 45 additions & 0 deletions kde-plasma/bluedevil/bluedevil-5.23.4-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

KFMIN=5.86.0
PVCUT=$(ver_cut 1-3)
QTMIN=5.15.2
inherit ecm kde.org

DESCRIPTION="Bluetooth stack for KDE Plasma"
HOMEPAGE="https://invent.kde.org/plasma/bluedevil"

LICENSE="GPL-2" # TODO: CHECK
SLOT="5"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
IUSE=""

PATCHES=(
"${FILESDIR}"/${P}-save-bluetooth-status-on-teardown.patch # KDE-bug 445376
)

DEPEND="
>=dev-qt/qtdbus-${QTMIN}:5
>=dev-qt/qtdeclarative-${QTMIN}:5
>=dev-qt/qtgui-${QTMIN}:5
>=dev-qt/qtwidgets-${QTMIN}:5
>=kde-frameworks/bluez-qt-${KFMIN}:5
>=kde-frameworks/kconfig-${KFMIN}:5
>=kde-frameworks/kconfigwidgets-${KFMIN}:5
>=kde-frameworks/kcoreaddons-${KFMIN}:5
>=kde-frameworks/kdeclarative-${KFMIN}:5
>=kde-frameworks/kdbusaddons-${KFMIN}:5
>=kde-frameworks/ki18n-${KFMIN}:5
>=kde-frameworks/kio-${KFMIN}:5
>=kde-frameworks/knotifications-${KFMIN}:5
>=kde-frameworks/kwidgetsaddons-${KFMIN}:5
>=kde-frameworks/kwindowsystem-${KFMIN}:5
>=kde-frameworks/plasma-${KFMIN}:5
"
RDEPEND="${DEPEND}
>=dev-qt/qtquickcontrols2-${QTMIN}:5
>=kde-frameworks/kirigami-${KFMIN}:5
>=kde-plasma/kde-cli-tools-${PVCUT}:5
"
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
From daaa18920ae93b482585eb3df790a6d5a647b6db Mon Sep 17 00:00:00 2001
From: Nate Graham <[email protected]>
Date: Fri, 19 Nov 2021 19:37:58 -0700
Subject: [PATCH] Save bluetooth status on teardown

Instead of watching for the shutdown and restart signals, just save
status anytime kded quits, which automatically covers those use cases as
well as when logging out. This is what the code was already halfway
doing; let's go all the way.

BUG: 445376
FIXED-IN: 5.23.5
(cherry picked from commit e57bb7580251f38e798bea21cdad43a3f90f2568)
---
src/kded/devicemonitor.cpp | 29 +++--------------------------
src/kded/devicemonitor.h | 1 -
2 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/src/kded/devicemonitor.cpp b/src/kded/devicemonitor.cpp
index 735747ee..5090a8be 100644
--- a/src/kded/devicemonitor.cpp
+++ b/src/kded/devicemonitor.cpp
@@ -46,15 +46,6 @@ DeviceMonitor::DeviceMonitor(BlueDevilDaemon *daemon)
this,
SLOT(login1PrepareForSleep(bool)));

- // Catch shutdown events so we can save status when shutting down and
- // optionally resume when starting up
- QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"),
- QStringLiteral("/org/freedesktop/login1"),
- QStringLiteral("org.freedesktop.login1.Manager"),
- QStringLiteral("PrepareForShutdown"),
- this,
- SLOT(login1PrepareForShutdown(bool)));
-
// Set initial state
const KConfigGroup globalGroup = m_config->group("Global");
const QString launchState = globalGroup.readEntry("launchState", "remember");
@@ -75,17 +66,11 @@ DeviceMonitor::DeviceMonitor(BlueDevilDaemon *daemon)
}
}

-// Save state when tearing down to avoid getting out of sync if kded crashes
-// or is manually restarted
DeviceMonitor::~DeviceMonitor()
{
- KConfigGroup globalGroup = m_config->group("Global");
-
- if (m_manager->isBluetoothBlocked()) {
- globalGroup.writeEntry<bool>("bluetoothBlocked", true);
- } else {
- globalGroup.deleteEntry("bluetoothBlocked");
- }
+ // Save state when tearing down to avoid getting out of sync if kded crashes
+ // or is manually restarted
+ saveState();
}

KFilePlacesModel *DeviceMonitor::places()
@@ -140,14 +125,6 @@ void DeviceMonitor::login1PrepareForSleep(bool active)
}
}

-void DeviceMonitor::login1PrepareForShutdown(bool active)
-{
- if (active) {
- qCDebug(BLUEDAEMON) << "About to shut down";
- saveState();
- }
-}
-
void DeviceMonitor::saveState()
{
KConfigGroup adaptersGroup = m_config->group("Adapters");
diff --git a/src/kded/devicemonitor.h b/src/kded/devicemonitor.h
index 6a35fed4..a7b38cab 100644
--- a/src/kded/devicemonitor.h
+++ b/src/kded/devicemonitor.h
@@ -35,7 +35,6 @@ private Q_SLOTS:

void deviceConnectedChanged(bool connected);
void login1PrepareForSleep(bool active);
- void login1PrepareForShutdown(bool active);

private:
void restoreState();
--
GitLab

0 comments on commit ec9c85c

Please sign in to comment.