File indexing completed on 2024-04-21 04:49:07

0001 /*
0002  * SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "lockmanager.h"
0008 #include "screensaverdbusinterface.h"
0009 
0010 #include <KLocalizedString>
0011 
0012 #include <QDBusConnection>
0013 
0014 LockManager::LockManager(QObject *parent)
0015     : QObject(parent)
0016 {
0017     m_iface = new OrgFreedesktopScreenSaverInterface(QStringLiteral("org.freedesktop.ScreenSaver"),
0018                                                      QStringLiteral("/org/freedesktop/ScreenSaver"),
0019                                                      QDBusConnection::sessionBus(),
0020                                                      this);
0021     setInhibitionOn();
0022 }
0023 
0024 void LockManager::setInhibitionOff()
0025 {
0026     m_iface->UnInhibit(m_cookie);
0027 }
0028 
0029 void LockManager::setInhibitionOn()
0030 {
0031     m_cookie = m_iface->Inhibit(QStringLiteral("org.kde.haruna"), i18nc("@info reason for blocking sleep and screen slocking", "Playing media file"));
0032 }
0033 
0034 #include "moc_lockmanager.cpp"