summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmanoil Kotsev <deloptes@gmail.com>2024-09-07 08:17:46 +0000
committerEmanoil Kotsev <deloptes@gmail.com>2024-09-07 08:17:46 +0000
commit1ae7c0102a3cbf83b618de367455a3b9a7a9d861 (patch)
tree61cd42e96a894c89cc64972c98feb3959c9f1090
parente6a4b278ed17b0915163a0ad31a1ccabd26b82ee (diff)
downloadtdebase-feat/dbusscreensaver.tar.gz
tdebase-feat/dbusscreensaver.zip
Add DBus screen saver interface to TDEfeat/dbusscreensaver
Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
-rw-r--r--kdesktop/CMakeLists.txt8
-rw-r--r--kdesktop/ConfigureChecks.cmake3
-rw-r--r--kdesktop/dbus/screensaver/CMakeLists.txt44
-rw-r--r--kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml41
-rw-r--r--kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml11
-rw-r--r--kdesktop/dbusscreensaverservice.cpp341
-rw-r--r--kdesktop/dbusscreensaverservice.h300
-rw-r--r--kdesktop/main.cpp10
8 files changed, 754 insertions, 4 deletions
diff --git a/kdesktop/CMakeLists.txt b/kdesktop/CMakeLists.txt
index ff0394f4b..bace17152 100644
--- a/kdesktop/CMakeLists.txt
+++ b/kdesktop/CMakeLists.txt
@@ -17,6 +17,7 @@ add_subdirectory( patterns )
add_subdirectory( programs )
add_subdirectory( init )
add_subdirectory( kwebdesktop )
+add_subdirectory( dbus/screensaver )
if( NOT BUILD_LIBKONQ )
@@ -90,16 +91,17 @@ set( ${target}_SRCS
pixmapserver.cpp kcustommenu.cpp startupid.cpp minicli_ui.ui
xautolock_diy.c xautolock_engine.c kshadowengine.cpp
kshadowsettings.cpp kdesktopshadowsettings.cpp
- tdefileividesktop.cpp kdesktopapp.cpp
+ tdefileividesktop.cpp kdesktopapp.cpp dbusscreensaverservice.cpp
)
tde_add_tdeinit_executable( ${target} AUTOMOC
SOURCES ${${target}_SRCS}
LINK
- pthread kdesktopsettings-static bgnd-static dmctl-static
+ pthread kdesktopsettings-static bgnd-static dmctl-static
+ screensaverinterfaces-static
konq-shared tdeutils-shared tdesu-shared ${TDEHW_LIBRARIES}
${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} Xext ${DL_LIBRARIES}
- ${XSS_LIBRARIES} ${DBUS_1_TQT_LIBRARIES}
+ ${XSS_LIBRARIES} ${DBUS_1_TQT_LIBRARIES}
)
diff --git a/kdesktop/ConfigureChecks.cmake b/kdesktop/ConfigureChecks.cmake
index bc53ec698..e012b1213 100644
--- a/kdesktop/ConfigureChecks.cmake
+++ b/kdesktop/ConfigureChecks.cmake
@@ -12,3 +12,6 @@
if( WITH_PAM )
set( TDESCREENSAVER_PAM_SERVICE "kde" CACHE INTERNAL "" )
endif( )
+
+# check for dbus
+tde_setup_dbus( dbus-1-tqt )
diff --git a/kdesktop/dbus/screensaver/CMakeLists.txt b/kdesktop/dbus/screensaver/CMakeLists.txt
new file mode 100644
index 000000000..9fb887326
--- /dev/null
+++ b/kdesktop/dbus/screensaver/CMakeLists.txt
@@ -0,0 +1,44 @@
+#################################################
+#
+# (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/org.freedesktop.ScreenSaver.xml b/kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml
new file mode 100644
index 000000000..1f7b09b28
--- /dev/null
+++ b/kdesktop/dbus/screensaver/org.freedesktop.ScreenSaver.xml
@@ -0,0 +1,41 @@
+<!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
new file mode 100644
index 000000000..cac5b2319
--- /dev/null
+++ b/kdesktop/dbus/screensaver/org.trinitydesktop.ScreenSaver.xml
@@ -0,0 +1,11 @@
+<!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/dbusscreensaverservice.cpp b/kdesktop/dbusscreensaverservice.cpp
new file mode 100644
index 000000000..48f143a5b
--- /dev/null
+++ b/kdesktop/dbusscreensaverservice.cpp
@@ -0,0 +1,341 @@
+/*
+ * 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"
+
+ScreenSaverInterfaceImpl::ScreenSaverInterfaceImpl(TQT_DBusConnection &conn) :
+ m_connection(&conn),
+ m_kdesktopdcoprefobj("kdesktop", "KScreensaverIface"),
+ m_cookiescounter(1),
+ isEnabled(false)
+{
+ DCOPReply reply = m_kdesktopdcoprefobj.call("isEnabled");
+ if (!reply.isValid())
+ {
+ tqDebug("ScreenSaverInterfaceImpl::SimulateUserActivity:1 there was some error using DCOP.");
+ }
+ else
+ {
+ if (!reply.get(isEnabled))
+ {
+ tqDebug("ScreenSaverInterfaceImpl::SimulateUserActivity:2 there was some error getting the value from DCOPReply");
+ }
+ else
+ {
+ tqDebug(TQString("ScreenSaver isEnabled = %1").arg((isEnabled)?"true":"false"));
+ }
+ }
+}
+
+ScreenSaverInterfaceImpl::~ScreenSaverInterfaceImpl()
+{
+}
+
+bool ScreenSaverInterfaceImpl::restoreState()
+{
+ // restore the state we obtained
+ DCOPReply reply = m_kdesktopdcoprefobj.call("enable", isEnabled);
+ if (!reply.isValid())
+ {
+ return false;
+ }
+ return true;
+}
+
+/*!
+ * Implement virtual methods
+ *
+ */
+
+void ScreenSaverInterfaceImpl::handleMethodReply(const TQT_DBusMessage& reply)
+{
+// kdDebug() << __func__ << endl;
+ m_connection->send(reply);
+}
+
+bool ScreenSaverInterfaceImpl::handleSignalSend(const TQT_DBusMessage& reply)
+{
+// kdDebug() << __func__ << endl;
+ 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("Lock: there was some error using DCOP.");
+ tqDebug(e);
+ dbuserror = TQT_DBusError::stdFailed(e);
+ return false;
+ }
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::SimulateUserActivity(TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("SimulateUserActivity not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetActive(bool& arg0, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("GetActive not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetActiveTime(TQ_UINT32& seconds, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("GetActiveTime not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::GetSessionIdleTime(TQ_UINT32& seconds, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("GetSessionIdleTime not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::SetActive(bool& arg0, bool e, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("SetActive not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::Inhibit(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& dbuserror) {
+
+ if (isEnabled)
+ {
+ DCOPReply reply = m_kdesktopdcoprefobj.call("enable", false);
+ if (!reply.isValid())
+ {
+ TQString e("Inhibit:1 there was some error using DCOP.");
+ tqDebug(e);
+ dbuserror = TQT_DBusError::stdFailed(e);
+ return false;
+ }
+ }
+
+ cookie=m_cookiescounter++;
+ ScreenSaverInterfaceImpl::Pair v;
+ v.name = application_name;
+ v.value = reason_for_inhibit;
+ m_cookies[cookie] = v;
+ tqDebug(TQString("Inhibit: application(%1) reason(%2)")
+ .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:1 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())
+ {
+ DCOPReply reply = m_kdesktopdcoprefobj.call("enable", isEnabled); // restore original state
+ if (!reply.isValid())
+ {
+ TQString e("UnInhibit:2 there was some error using DCOP.");
+ tqDebug(e);
+ dbuserror = TQT_DBusError::stdFailed(e);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::Throttle(const TQString& application_name, const TQString& reason_for_inhibit, TQ_UINT32& cookie, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("Throttle not implemented");
+ return true;
+}
+
+bool ScreenSaverInterfaceImpl::UnThrottle(TQ_UINT32 cookie, TQT_DBusError& dbuserror) {
+// kdDebug() << __func__ << endl;
+ tqDebug("UnThrottle not implemented");
+ return true;
+}
+
+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();
+ delete screenSaverInterface;
+}
+
+void ScreenSaverService::stopService()
+{
+ if(!screenSaverInterface->restoreState())
+ tqDebug("ScreenSaverService failed to restore the original state.");
+}
+
+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::SystemBus, DBUS_SCREENSAVER_SERVICE);
+ 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/dbusscreensaverservice.h b/kdesktop/dbusscreensaverservice.h
new file mode 100644
index 000000000..a4553dac5
--- /dev/null
+++ b/kdesktop/dbusscreensaverservice.h
@@ -0,0 +1,300 @@
+/*
+ * 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 <dcopref.h>
+#include <tqdbusconnection.h>
+#include <tqmap.h>
+#include <tqpair.h>
+
+#include "dbus/screensaver/screensaverInterface.h"
+#include "dbus/screensaver/screensaverNode.h"
+#include "dbus/screensaver/dbusbaseNode.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();
+ bool 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:
+
+ struct Pair {
+ TQString name;
+ TQString value;
+ };
+
+ TQT_DBusConnection *m_connection;
+ DCOPRef m_kdesktopdcoprefobj;
+ TQMap<TQ_UINT32,Pair> m_cookies;
+ TQ_UINT32 m_cookiescounter;
+ /**
+ * obtain and keep the original state if service is stopped,
+ * it is used to restored the original state
+ */
+ bool isEnabled;
+};
+
+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&);
+ ~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&);
+ ~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&);
+ ~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 initialise the connection to the D-Bus daemon.
+ * \return boolean with the result of the operation
+ * \retval true if successful initialised 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 successful initialised 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/main.cpp b/kdesktop/main.cpp
index 5a04c9bed..5c94b7e0a 100644
--- a/kdesktop/main.cpp
+++ b/kdesktop/main.cpp
@@ -37,11 +37,13 @@
#include "krootwm.h"
#include "kdesktopsettings.h"
#include "kdesktopapp.h"
+#include "dbusscreensaverservice.h"
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <iostream>
#if defined(TQ_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300
#define COMPOSITE
@@ -289,6 +291,12 @@ extern "C" TDE_EXPORT int kdemain( int argc, char **argv )
myApp->dcopClient()->setDefaultObject( "KDesktopIface" );
-
+ TDEDbusScreenSaver dbusScreenSaverInterface;
+
+ if (!dbusScreenSaverInterface.isConnectedToDBUS())
+ {
+ std::cerr << i18n("Can't connect to DBus!\nUnable to start tdedbusscreensaver.\n\n"
+ "Restart dbus and try again").local8Bit();
+ }
return myApp->exec();
}