summaryrefslogtreecommitdiffstats
path: root/kdesktop/dbus/screensaver
diff options
context:
space:
mode:
authorEmanoil Kotsev <deloptes@gmail.com>2024-12-17 22:19:42 +0000
committerEmanoil Kotsev <deloptes@gmail.com>2024-12-17 22:19:42 +0000
commit790f526f18e7917e4c066112215e02e94fd628ac (patch)
treebf927caa14b7ffbdf80d78cde9963ebb21aa30bb /kdesktop/dbus/screensaver
parent1dec40d10689ff9678fb36fec0f3d87439562897 (diff)
downloadtdebase-790f526f18e7917e4c066112215e02e94fd628ac.tar.gz
tdebase-790f526f18e7917e4c066112215e02e94fd628ac.zip
Auto formatting main.cpp incl. dbus screen saver
Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
Diffstat (limited to 'kdesktop/dbus/screensaver')
-rw-r--r--kdesktop/dbus/screensaver/CMakeLists.txt44
-rw-r--r--kdesktop/dbus/screensaver/dbusscreensaverservice.cpp171
-rw-r--r--kdesktop/dbus/screensaver/dbusscreensaverservice.h126
-rw-r--r--kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml41
-rw-r--r--kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml11
-rw-r--r--kdesktop/dbus/screensaver/screensaverInterfaceImpl.cpp185
-rw-r--r--kdesktop/dbus/screensaver/screensaverInterfaceImpl.h204
7 files changed, 686 insertions, 96 deletions
diff --git a/kdesktop/dbus/screensaver/CMakeLists.txt b/kdesktop/dbus/screensaver/CMakeLists.txt
deleted file mode 100644
index 9fb887326..000000000
--- a/kdesktop/dbus/screensaver/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-#################################################
-#
-# (C) 2024 Emanoil Kotsev
-# deloptes (AT) gmail.com
-#
-# Improvements and feedback are welcome
-#
-# This file is released under GPL >= 2
-#
-#################################################
-
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${TQT_INCLUDE_DIRS}
- ${DBUS_TQT_INCLUDE_DIRS}
-)
-
-set( INTROSPECTIONPATH ${CMAKE_SOURCE_DIR}/kdesktop/dbus/screensaver )
-
-set( ScreenSaver_HDRS dbusbaseNode.h introspectableInterface.h screensaverInterface.h screensaverNode.h screensaverProxy.h)
-set( ScreenSaver_SRCS dbusbaseNode.cpp introspectableInterface.cpp screensaverInterface.cpp screensaverNode.cpp screensaverProxy.cpp )
-
-##### ScreenSaver #########################
-add_custom_command(
- OUTPUT ${ScreenSaver_HDRS} ${ScreenSaver_SRCS}
- COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.freedesktop.ScreenSaver.xml 2>/dev/null
- DEPENDS ${INTROSPECTIONPATH}/org.freedesktop.ScreenSaver.xml
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-tde_add_library( screensaverinterfaces STATIC_PIC AUTOMOC
- SOURCES ${ScreenSaver_SRCS}
- LINK ${DBUS_TQT_LIBRARIES}
-)
-
-##### install headers ###################################
-
-install(
- DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DESTINATION ${INCLUDE_INSTALL_DIR}
- USE_SOURCE_PERMISSIONS
- FILES_MATCHING PATTERN PATTERN "*.h"
- PATTERN "CMakeFiles" EXCLUDE
-)
diff --git a/kdesktop/dbus/screensaver/dbusscreensaverservice.cpp b/kdesktop/dbus/screensaver/dbusscreensaverservice.cpp
new file mode 100644
index 000000000..ba19a970a
--- /dev/null
+++ b/kdesktop/dbus/screensaver/dbusscreensaverservice.cpp
@@ -0,0 +1,171 @@
+/*
+ * dbusscreensaverservice.cpp
+ *
+ * (C) 2024 Emanoil Kotsev
+ * deloptes (AT) gmail.com
+ *
+ * tdebase Copyright (C) 2009 tdebase development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <tdelocale.h>
+#include <tqdbusobjectpath.h>
+
+#include "dbusscreensaverservice.h"
+
+RootNodeService::RootNodeService(TQT_DBusConnection &connection) :
+ DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("org");
+ registerObject(m_connection, "/");
+}
+
+RootNodeService::~RootNodeService()
+{
+}
+
+TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
+}
+
+OrgNodeService::OrgNodeService(TQT_DBusConnection &connection) :
+ DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("freedesktop");
+ registerObject(m_connection, "/org");
+}
+
+OrgNodeService::~OrgNodeService()
+{
+}
+
+TQT_DBusObjectBase* OrgNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
+}
+
+FreeDekstopNodeService::FreeDekstopNodeService(TQT_DBusConnection &connection) :
+ DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("ScreenSaver");
+ registerObject(m_connection, "/org/freedesktop");
+}
+
+FreeDekstopNodeService::~FreeDekstopNodeService()
+{
+}
+
+TQT_DBusObjectBase* FreeDekstopNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
+}
+
+ScreenSaverService::ScreenSaverService(TQT_DBusConnection &conn) :
+ org::freedesktop::screensaverNode(),
+ m_connection(conn),
+ screenSaverInterface(new ScreenSaverInterfaceImpl(conn))
+{
+ m_interfaces.insert("org.freedesktop.DBus.Introspectable", this);
+ m_interfaces.insert("org.freedesktop.ScreenSaver", screenSaverInterface);
+ registerObject(m_connection, DBUS_SCREENSAVER_SERVICE_PATH);
+}
+
+ScreenSaverService::~ScreenSaverService()
+{
+ stopService();
+ if(screenSaverInterface)
+ delete screenSaverInterface;
+}
+
+void ScreenSaverService::stopService()
+{
+ screenSaverInterface->restoreState();
+}
+
+TQT_DBusObjectBase* ScreenSaverService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
+}
+
+
+
+TDEDbusScreenSaver::TDEDbusScreenSaver()
+{
+ // open connection to DBus and configure the service
+ if (!configureService())
+ {
+ tqDebug("Failed to configure the screen saver service");
+ }
+}
+
+TDEDbusScreenSaver::~TDEDbusScreenSaver()
+{
+ // unconfigure the DBus service and close connection
+ if (!unconfigureService())
+ {
+ tqDebug("Failed to properly close the screen saver service");
+ }
+
+ delete screenSaverService;
+ delete freeDekstopNodeService;
+ delete orgService;
+ delete rootService;
+}
+
+bool TDEDbusScreenSaver::isConnectedToDBUS()
+{
+ return m_connection.isConnected();
+}
+
+bool TDEDbusScreenSaver::configureService()
+{
+ m_connection = TQT_DBusConnection::addConnection(TQT_DBusConnection::SessionBus, DBUS_SCREENSAVER_SERVICE);
+
+ if (!m_connection.isConnected())
+ {
+ tqDebug(i18n("Failed to open connection to system message bus: %1").arg(m_connection.lastError().message()));
+ return false;
+ }
+
+ // try to get a specific service name
+ if (!m_connection.requestName(DBUS_SCREENSAVER_SERVICE_NAME))
+ {
+ tqWarning(i18n("Requesting name %1 failed. "
+ "The object will only be addressable through unique name '%2'").arg(
+ DBUS_SCREENSAVER_SERVICE_NAME).arg(m_connection.uniqueName()));
+ return false;
+ }
+
+ rootService = new RootNodeService(m_connection);
+ orgService = new OrgNodeService(m_connection);
+ freeDekstopNodeService = new FreeDekstopNodeService(m_connection);
+ screenSaverService = new ScreenSaverService(m_connection);
+ return true;
+}
+
+bool TDEDbusScreenSaver::unconfigureService()
+{
+ screenSaverService->stopService(); // will restore the original state
+
+ screenSaverService=0;
+ freeDekstopNodeService=0;
+ orgService=0;
+ rootService=0;
+ // close D-Bus connection
+ m_connection.closeConnection(DBUS_SCREENSAVER_SERVICE);
+
+ return true;
+}
diff --git a/kdesktop/dbus/screensaver/dbusscreensaverservice.h b/kdesktop/dbus/screensaver/dbusscreensaverservice.h
new file mode 100644
index 000000000..d556f201d
--- /dev/null
+++ b/kdesktop/dbus/screensaver/dbusscreensaverservice.h
@@ -0,0 +1,126 @@
+/*
+ * dbusscreensaverservice.h
+ *
+ * (C) 2024 Emanoil Kotsev
+ * deloptes (AT) gmail.com
+ *
+ * tdebase Copyright (C) 2009 tdebase development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef KDESKTOP_LOCK_DBUS_SCREENSAVER_DBUSSCREENSAVERSERVICE_H_
+#define KDESKTOP_LOCK_DBUS_SCREENSAVER_DBUSSCREENSAVERSERVICE_H_
+
+#include <tqdbusconnection.h>
+#include <tqmap.h>
+
+#include "dbus/screensaver/screensaverNode.h"
+#include "dbus/screensaver/dbusbaseNode.h"
+#include "screensaverInterfaceImpl.h"
+
+class ScreenSaverService: public org::freedesktop::screensaverNode
+{
+public:
+ ScreenSaverService(TQT_DBusConnection&);
+ virtual ~ScreenSaverService();
+ void stopService();
+
+protected:
+ virtual TQT_DBusObjectBase* createInterface(const TQString&);
+
+private:
+ TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
+ TQT_DBusConnection m_connection;
+ ScreenSaverInterfaceImpl *screenSaverInterface;
+};
+
+class RootNodeService: public DBusBaseNode
+{
+public:
+ RootNodeService(TQT_DBusConnection&);
+ virtual ~RootNodeService();
+protected:
+ virtual TQT_DBusObjectBase* createInterface(const TQString&);
+private:
+ TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
+ TQT_DBusConnection m_connection;
+};
+
+class OrgNodeService: public DBusBaseNode
+{
+public:
+ OrgNodeService(TQT_DBusConnection&);
+ virtual ~OrgNodeService();
+protected:
+ virtual TQT_DBusObjectBase* createInterface(const TQString&);
+private:
+ TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
+ TQT_DBusConnection m_connection;
+};
+
+class FreeDekstopNodeService: public DBusBaseNode
+{
+public:
+ FreeDekstopNodeService(TQT_DBusConnection&);
+ virtual ~FreeDekstopNodeService();
+protected:
+ virtual TQT_DBusObjectBase* createInterface(const TQString&);
+private:
+ TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
+ TQT_DBusConnection m_connection;
+};
+
+class TDEDbusScreenSaver
+{
+
+public:
+ TDEDbusScreenSaver();
+ virtual ~TDEDbusScreenSaver();
+
+ /*!
+ * This function return information about connection status to the DBUS daemon.
+ * \return boolean with the state of the connection to D-Bus
+ * \retval true if connected
+ * \retval false if disconnected
+ */
+ bool isConnectedToDBUS();
+
+private:
+ /*!
+ * This function initialize the connection to the D-Bus daemon.
+ * \return boolean with the result of the operation
+ * \retval true if successfully configured D-Bus connection
+ * \retval false if unsuccessful
+ */
+ bool configureService();
+
+ /*!
+ * This function is to close the connection to D-Bus
+ * \return boolean with the result of the operation
+ * \retval true if successfully unset D-Bus connection
+ * \retval false if unsuccessful
+ */
+ bool unconfigureService();
+
+private:
+ TQT_DBusConnection m_connection;
+
+ RootNodeService *rootService;
+ OrgNodeService *orgService;
+ FreeDekstopNodeService *freeDekstopNodeService;
+ ScreenSaverService *screenSaverService;
+
+};
+
+#endif /* KDESKTOP_LOCK_DBUS_SCREENSAVER_DBUSSCREENSAVERSERVICE_H_ */
diff --git a/kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml b/kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml
deleted file mode 100644
index 1f7b09b28..000000000
--- a/kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/org/freedesktop/screensaver">
- <interface name="org.freedesktop.ScreenSaver">
- <signal name="ActiveChanged">
- <arg type="b"/>
- </signal>
- <method name="Lock">
- </method>
- <method name="SimulateUserActivity">
- </method>
- <method name="GetActive">
- <arg type="b" direction="out"/>
- </method>
- <method name="GetActiveTime">
- <arg name="seconds" type="u" direction="out"/>
- </method>
- <method name="GetSessionIdleTime">
- <arg name="seconds" type="u" direction="out"/>
- </method>
- <method name="SetActive">
- <arg type="b" direction="out"/>
- <arg name="e" type="b" direction="in"/>
- </method>
- <method name="Inhibit">
- <arg name="application_name" type="s" direction="in"/>
- <arg name="reason_for_inhibit" type="s" direction="in"/>
- <arg name="cookie" type="u" direction="out"/>
- </method>
- <method name="UnInhibit">
- <arg name="cookie" type="u" direction="in"/>
- </method>
- <method name="Throttle">
- <arg name="application_name" type="s" direction="in"/>
- <arg name="reason_for_inhibit" type="s" direction="in"/>
- <arg name="cookie" type="u" direction="out"/>
- </method>
- <method name="UnThrottle">
- <arg name="cookie" type="u" direction="in"/>
- </method>
- </interface>
-</node> \ No newline at end of file
diff --git a/kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml b/kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml
deleted file mode 100644
index cac5b2319..000000000
--- a/kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/org/trinitydesktop/screensaver">
- <interface name="org.trinitydesktop.screensaver">
- <!--lock the screen, and show the switch user prompt -->
- <method name="SwitchUser" />
- <!-- Re-read configuration -->
- <method name="configure" />
- <!-- Emitted just before we start the lock process. Clients should release any X grabs -->
- <signal name="AboutToLock" />
- </interface>
-</node> \ No newline at end of file
diff --git a/kdesktop/dbus/screensaver/screensaverInterfaceImpl.cpp b/kdesktop/dbus/screensaver/screensaverInterfaceImpl.cpp
new file mode 100644
index 000000000..4f05a8391
--- /dev/null
+++ b/kdesktop/dbus/screensaver/screensaverInterfaceImpl.cpp
@@ -0,0 +1,185 @@
+/*
+ * screensaverInterfaceImpl.cpp
+ *
+ *
+ * (C) 2024 Emanoil Kotsev
+ * deloptes (AT) gmail.com
+ *
+ * tdebase Copyright (C) 2009 tdebase development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "screensaverInterfaceImpl.h"
+
+ScreenSaverInterfaceImpl::ScreenSaverInterfaceImpl(TQT_DBusConnection &conn) :
+ m_connection(&conn),
+ m_ccount(1),
+ m_kdesktopdcoprefobj("kdesktop", "KScreensaverIface")
+{
+ isScreenSaverEnabled = screenSaverIsEnabled();
+ tqDebug(TQString("ScreenSaver isEnabled = %1").arg((isScreenSaverEnabled)?"yes":"no"));
+}
+
+ScreenSaverInterfaceImpl::~ScreenSaverInterfaceImpl()
+{
+}
+
+void ScreenSaverInterfaceImpl::restoreState()
+{
+ // restore the state
+ forceScreenSaver(isScreenSaverEnabled);
+}
+
+/*!
+ * Implement virtual methods
+ *
+ */
+void ScreenSaverInterfaceImpl::handleMethodReply(const TQT_DBusMessage& reply)
+{
+ m_connection->send(reply);
+}
+
+bool ScreenSaverInterfaceImpl::handleSignalSend(const TQT_DBusMessage& reply)
+{
+ return true;
+}
+
+TQString ScreenSaverInterfaceImpl::objectPath() const
+{
+ return TQString(DBUS_SCREENSAVER_SERVICE_PATH);
+}
+
+bool ScreenSaverInterfaceImpl::Lock(TQT_DBusError& dbuserror) {
+
+ DCOPReply reply = m_kdesktopdcoprefobj.call("lock");
+ if (!reply.isValid())
+ {
+ TQString e("ScreenSaverInterfaceImpl::Lock: there was some error using DCOP.");
+ tqDebug(e);
+ dbuserror = TQT_DBusError::stdFailed(e);
+ return false;
+ }
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::SimulateUserActivity(TQT_DBusError& dbuserror) {
+ tqDebug("SimulateUserActivity not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetActive(bool& arg0, TQT_DBusError& dbuserror) {
+ tqDebug("GetActive not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetActiveTime(TQ_UINT32& seconds, TQT_DBusError& dbuserror) {
+ tqDebug("GetActiveTime not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetSessionIdleTime(TQ_UINT32& seconds, TQT_DBusError& dbuserror) {
+ tqDebug("GetSessionIdleTime not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::SetActive(bool& arg0, bool e, TQT_DBusError& dbuserror) {
+ tqDebug("SetActive not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::Inhibit(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& dbuserror) {
+
+ //this is to make sure we have the actual state - it could have been changed meanwhile
+ isScreenSaverEnabled = screenSaverIsEnabled();
+ if (isScreenSaverEnabled && m_cookies.isEmpty()) // disable only once
+ {
+ if (!forceScreenSaver(false))
+ {
+ dbuserror = TQT_DBusError::stdFailed(TQString("Failed to disable the screen saver"));
+ }
+ }
+
+ cookie=m_ccount++;
+ ScreenSaverInterfaceImpl::Pair v;
+ v.name = application_name;
+ v.value = reason_for_inhibit;
+ m_cookies[cookie] = v;
+ tqDebug(TQString("Inhibit: cookie(%1), application(%2), reason(%3)")
+ .arg(cookie)
+ .arg(m_cookies[cookie].name)
+ .arg(m_cookies[cookie].value).local8Bit());
+
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::UnInhibit(TQ_UINT32 cookie, TQT_DBusError& dbuserror) {
+ tqDebug(TQString("UnInhibit: cookie(%1), application(%2), reason(%3)")
+ .arg(cookie)
+ .arg(m_cookies[cookie].name)
+ .arg(m_cookies[cookie].value).local8Bit());
+
+ m_cookies.remove(cookie);
+ if (m_cookies.isEmpty())
+ {
+ // restore states when all applications finished
+ if (!forceScreenSaver(isScreenSaverEnabled))
+ {
+ dbuserror = TQT_DBusError::stdFailed(TQString("Failed to switch ScreenSaver %1!").arg(
+ (isScreenSaverEnabled) ? "on" : "off"));
+ }
+ }
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::Throttle(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& dbuserror) {
+ tqDebug("Throttle not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::UnThrottle(TQ_UINT32 cookie, TQT_DBusError& dbuserror) {
+ tqDebug("UnThrottle not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::screenSaverIsEnabled()
+{
+ DCOPReply reply = m_kdesktopdcoprefobj.call("isEnabled");
+ bool on = false;
+ if (!reply.isValid())
+ {
+ tqDebug("ScreenSaverInterfaceImpl::screenSaverIsEnabled(): there was some error using DCOP.");
+ }
+ else
+ {
+ if (!reply.get(on))
+ {
+ tqDebug("ScreenSaverInterfaceImpl::screenSaverIsEnabled(): there was some error getting the value from DCOPReply");
+ }
+ }
+ return on;
+}
+
+bool ScreenSaverInterfaceImpl::forceScreenSaver(bool on)
+{
+ DCOPReply reply = m_kdesktopdcoprefobj.call("enable", on);
+ if (!reply.isValid())
+ {
+ tqDebug(TQString("Failed to switch ScreenSaver %1!").arg((on) ? "on" : "off"));
+ return false;
+ }
+ return true;
+}
+// End of File
diff --git a/kdesktop/dbus/screensaver/screensaverInterfaceImpl.h b/kdesktop/dbus/screensaver/screensaverInterfaceImpl.h
new file mode 100644
index 000000000..0b79f1693
--- /dev/null
+++ b/kdesktop/dbus/screensaver/screensaverInterfaceImpl.h
@@ -0,0 +1,204 @@
+/*
+ * screensaverInterfaceImpl.h
+ *
+ * (C) 2024 Emanoil Kotsev
+ * deloptes (AT) gmail.com
+ *
+ * tdebase Copyright (C) 2009 tdebase development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef KDESKTOP_SCREENSAVERINTERFACEIMPL_H_
+#define KDESKTOP_SCREENSAVERINTERFACEIMPL_H_
+
+#include <dcopref.h>
+#include <tqpair.h>
+#include <tqmap.h>
+#include <tqdbusconnection.h>
+
+#include "dbus/screensaver/screensaverInterface.h"
+
+#define DBUS_SCREENSAVER_SERVICE "TDEDbusScreenSaver"
+#define DBUS_SCREENSAVER_SERVICE_NAME "org.freedesktop.ScreenSaver"
+#define DBUS_SCREENSAVER_SERVICE_PATH "/org/freedesktop/ScreenSaver"
+
+class ScreenSaverInterfaceImpl : public org::freedesktop::ScreenSaverInterface
+{
+ /**
+ *
+ * Idle inhibition is achieved by the application calling an Inhibit method on a well-known D-Bus name.
+ *
+ * Inhibition will stop when the UnInhibit method is called, or the application disconnects from the
+ * D-Bus session bus (which usually happens upon exit).
+ * Implementations of this well-known bus name must have an object /org/freedesktop/ScreenSaver which
+ * implements the org.freedesktop.ScreenSaver interface.
+ *
+ * https://specifications.freedesktop.org/idle-inhibit-spec/latest/ch03.html
+ */
+
+public:
+ ScreenSaverInterfaceImpl(TQT_DBusConnection&);
+ virtual ~ScreenSaverInterfaceImpl();
+
+ void restoreState();
+
+protected:
+ /**
+ * void Lock()
+ * This method gets called when the service daemon
+ * locks the screen
+ */
+ virtual bool Lock(TQT_DBusError& error);
+
+ /**
+ * Name: SimulateUserActivity
+ * Args: (none)
+ * Returns: (nothing)
+ * Description: Simulate use activity to prevent screen saver being spawned
+ *
+ * Not implemented
+ */
+ virtual bool SimulateUserActivity(TQT_DBusError& error);
+
+ /**
+ * Name: GetActive
+ * Args: (none)
+ * Returns: DBUS_TYPE_BOOLEAN
+ * Descriptions: Returns the value of the current state of activity.
+ * See setActive().
+ *
+ * Not implemented
+ */
+ virtual bool GetActive(bool& arg0, TQT_DBusError& error);
+
+ /**
+ * Name: GetActiveTime
+ * Args: (none)
+ * Returns: DBUS_TYPE_UINT32
+ * Descriptions: Returns the number of seconds that the screensaver has
+ * been active. Returns zero if the screensaver is not
+ * active.
+ *
+ * Not implemented
+ */
+ virtual bool GetActiveTime(TQ_UINT32& seconds, TQT_DBusError& error);
+
+ /**
+ *
+ * Name: GetSessionIdleTime
+ * Args: (none)
+ * Returns: DBUS_TYPE_UINT32
+ * Descriptions: Returns the number of seconds that the session has
+ * been idle. Returns zero if the session is not idle.
+ *
+ * Not implemented
+ */
+ virtual bool GetSessionIdleTime(TQ_UINT32& seconds, TQT_DBusError& error);
+
+ /**
+ * Name: SetActive
+ * Args: DBUS_TYPE_BOOLEAN state
+ * state: TRUE to request activation,
+ * FALSE to request deactivation
+ * Returns: (nothing)
+ * Description: Request a change in the state of the screensaver.
+ * Set to TRUE to request that the screensaver activate.
+ * Active means that the screensaver has blanked the
+ * screen and may run a graphical theme. This does
+ * not necessary mean that the screen is locked.
+ *
+ * Not implemented
+ */
+ virtual bool SetActive(bool& arg0, bool e, TQT_DBusError& error);
+
+ /**
+ *
+ * Name: Inhibit
+ * Args: DBUS_TYPE_STRING "application-name"
+ * A unique identifier for the application, usually a reverse domain
+ * (such as 'org.freedesktop.example').
+ * DBUS_TYPE_STRING "reason for inhibit"
+ * A human-readable and possibly translated string
+ * explaining the reason why idleness is inhibited
+ * (such as 'Playing a movie').
+ * Returns: INT cookie
+ * This is a random number used to identify the request.
+ * To be passed to UnInhibit when done.
+ * Description: Request that saving the screen due to system idleness
+ * be blocked until UnInhibit is called or the
+ * calling process exits.
+ *
+ * https://specifications.freedesktop.org/idle-inhibit-spec/latest/re01.html
+ * https://lists.freedesktop.org/archives/xdg/2007-March/009187.html
+ */
+
+ virtual bool Inhibit(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& error);
+
+ /**
+ *
+ * Name: UnInhibit
+ * Args: DBUS_TYPE_UINT32 cookie
+ * A cookie representing the inhibition request,
+ * as returned by the 'Inhibit' function.
+ * Returns: (nothing)
+ * Description: Cancel a previous call to Inhibit() identified by the cookie.
+ */
+ virtual bool UnInhibit(TQ_UINT32 cookie, TQT_DBusError& error);
+
+ /**
+ *
+ * Name: Throttle
+ * Args: DBUS_TYPE_STRING "application-name"
+ * DBUS_TYPE_STRING "reason for throttle"
+ * INT cookie
+ * This is a random number used to identify the request.
+ * Description: Request that running themes while the screensaver is
+ * active be blocked until UnThrottle is called or the
+ * calling process exits.
+ *
+ * Not implemented
+ */
+ virtual bool Throttle(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& error);
+
+ /**
+ * Name: UnThrottle
+ * Args: DBUS_TYPE_UINT32 cookie
+ * Returns: (nothing)
+ * Description: Cancel a previous call to Throttle() identified by the cookie.
+ * Not implemented
+ */
+ virtual bool UnThrottle(TQ_UINT32 cookie, TQT_DBusError& error);
+
+ virtual void handleMethodReply(const TQT_DBusMessage& reply);
+ virtual bool handleSignalSend(const TQT_DBusMessage& reply);
+ virtual TQString objectPath() const;
+
+private:
+ bool screenSaverIsEnabled();
+ bool forceScreenSaver(bool);
+
+ struct Pair {
+ TQString name;
+ TQString value;
+ };
+
+ TQT_DBusConnection *m_connection;
+ TQMap<TQ_UINT32,Pair> m_cookies;
+ TQ_UINT32 m_ccount;
+
+ DCOPRef m_kdesktopdcoprefobj;
+ bool isScreenSaverEnabled;
+};
+
+#endif /* KDESKTOP_SCREENSAVERINTERFACEIMPL_H_ */