kdeconnect-kde/core/backends/linkprovider.cpp

40 lines
1.5 KiB
C++
Raw Normal View History

2013-06-06 04:57:06 +01:00
/**
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
2013-06-06 04:57:06 +01:00
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
2013-06-06 04:57:06 +01:00
*/
#include "linkprovider.h"
2020-04-06 01:38:19 +01:00
#include <QDBusConnection>
#include <core_debug.h>
2013-06-06 04:57:06 +01:00
LinkProvider::LinkProvider()
{
2020-04-06 01:38:19 +01:00
// Terminate connections when we sleep or shut down.
QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"),
QStringLiteral("/org/freedesktop/login1"),
QStringLiteral("org.freedesktop.login1.Manager"),
QStringLiteral("PrepareForSleep"),
this,
SLOT(suspend(bool)));
2020-04-06 01:38:19 +01:00
QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"),
QStringLiteral("/org/freedesktop/login1"),
QStringLiteral("org.freedesktop.login1.Manager"),
QStringLiteral("PrepareForShutdown"),
this,
SLOT(suspend(bool)));
}
2020-04-06 01:38:19 +01:00
void LinkProvider::suspend(bool suspend)
{
if (suspend) {
qCDebug(KDECONNECT_CORE) << "Stopping connection for suspension";
onStop();
} else {
qCDebug(KDECONNECT_CORE) << "Restarting connection after suspension";
onStart();
}
}
#include "moc_linkprovider.cpp"