ScreensaverInhibitPlugin::ScreensaverInhibitPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
OrgFreedesktopScreenSaverInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, QDBusConnection::sessionBus(), this);
inhibitCookie = inhibitInterface.Inhibit(QStringLiteral("org.kde.kdeconnect.daemon"), i18n("Phone is connected"));
}
ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
{
if (inhibitCookie == 0)
return;
OrgFreedesktopScreenSaverInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, QDBusConnection::sessionBus(), this);
inhibitInterface.UnInhibit(inhibitCookie);
/*
* Simulate user activity because what ever manages the screensaver does not seem to start the timer
* automatically when all inhibitions are lifted and the user does nothing which results in an
* unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
* be locked anyway.
*/
inhibitInterface.SimulateUserActivity();
}
void ScreensaverInhibitPlugin::connected()
{
}
bool ScreensaverInhibitPlugin::receivePacket(const NetworkPacket &np)
{
Q_UNUSED(np);
return false;
}