1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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;
/**
* keep the original lock state,
* 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_ */
|