2013-06-06 04:57:06 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-06-06 04:57:06 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +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
|
|
|
*/
|
|
|
|
|
2013-07-24 17:42:33 +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
|
|
|
|
2013-07-26 15:21:19 +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)));
|
|
|
|
QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"),
|
|
|
|
QStringLiteral("/org/freedesktop/login1"),
|
|
|
|
QStringLiteral("org.freedesktop.login1.Manager"),
|
|
|
|
QStringLiteral("PrepareForShutdown"),
|
|
|
|
this, SLOT(suspend(bool)));
|
2013-09-09 17:35:56 +01:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|