Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
8b4eaa54
Commit
8b4eaa54
authored
Jul 30, 2020
by
Nicolas Fella
Browse files
[plugins/screensaver] Port away from QDBusInterface
It's better overall and makes Kai happy
parent
4372678c
Pipeline
#37580
passed with stage
in 16 minutes and 35 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
plugins/screensaver-inhibit/CMakeLists.txt
View file @
8b4eaa54
...
...
@@ -10,6 +10,7 @@ else()
set
(
kdeconnect_screensaver_inhibit_SRCS
screensaverinhibitplugin.cpp
)
qt5_add_dbus_interface
(
kdeconnect_screensaver_inhibit_SRCS org.freedesktop.ScreenSaver.xml screensaverinterface
)
endif
()
set
(
debug_file_SRCS
)
...
...
plugins/screensaver-inhibit/org.freedesktop.ScreenSaver.xml
0 → 100644
View file @
8b4eaa54
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface
name=
"org.freedesktop.ScreenSaver"
>
<signal
name=
"ActiveChanged"
>
<arg
type=
"b"
/>
</signal>
<method
name=
"Lock"
/>
<method
name=
"SimulateUserActivity"
/>
<method
name=
"GetActive"
>
<arg
direction=
"out"
type=
"b"
/>
</method>
<method
name=
"GetActiveTime"
>
<arg
direction=
"out"
type=
"u"
name=
"seconds"
/>
</method>
<method
name=
"GetSessionIdleTime"
>
<arg
direction=
"out"
type=
"u"
name=
"seconds"
/>
</method>
<method
name=
"SetActive"
>
<arg
direction=
"out"
type=
"b"
/>
<arg
direction=
"in"
type=
"b"
name=
"e"
/>
</method>
<method
name=
"Inhibit"
>
<arg
direction=
"in"
type=
"s"
name=
"application_name"
/>
<arg
direction=
"in"
type=
"s"
name=
"reason_for_inhibit"
/>
<arg
direction=
"out"
type=
"u"
name=
"cookie"
/>
</method>
<method
name=
"UnInhibit"
>
<arg
direction=
"in"
type=
"u"
name=
"cookie"
/>
</method>
<method
name=
"Throttle"
>
<arg
direction=
"in"
type=
"s"
name=
"application_name"
/>
<arg
direction=
"in"
type=
"s"
name=
"reason_for_inhibit"
/>
<arg
direction=
"out"
type=
"u"
name=
"cookie"
/>
</method>
<method
name=
"UnThrottle"
>
<arg
direction=
"in"
type=
"u"
name=
"cookie"
/>
</method>
</interface>
<interface
name=
"org.kde.screensaver"
>
<method
name=
"SwitchUser"
/>
<method
name=
"configure"
/>
<signal
name=
"AboutToLock"
/>
</interface>
<interface
name=
"org.freedesktop.DBus.Properties"
>
<method
name=
"Get"
>
<arg
name=
"interface_name"
type=
"s"
direction=
"in"
/>
<arg
name=
"property_name"
type=
"s"
direction=
"in"
/>
<arg
name=
"value"
type=
"v"
direction=
"out"
/>
</method>
<method
name=
"Set"
>
<arg
name=
"interface_name"
type=
"s"
direction=
"in"
/>
<arg
name=
"property_name"
type=
"s"
direction=
"in"
/>
<arg
name=
"value"
type=
"v"
direction=
"in"
/>
</method>
<method
name=
"GetAll"
>
<arg
name=
"interface_name"
type=
"s"
direction=
"in"
/>
<arg
name=
"values"
type=
"a{sv}"
direction=
"out"
/>
<annotation
name=
"org.qtproject.QtDBus.QtTypeName.Out0"
value=
"QVariantMap"
/>
</method>
<signal
name=
"PropertiesChanged"
>
<arg
name=
"interface_name"
type=
"s"
direction=
"out"
/>
<arg
name=
"changed_properties"
type=
"a{sv}"
direction=
"out"
/>
<annotation
name=
"org.qtproject.QtDBus.QtTypeName.Out1"
value=
"QVariantMap"
/>
<arg
name=
"invalidated_properties"
type=
"as"
direction=
"out"
/>
</signal>
</interface>
<interface
name=
"org.freedesktop.DBus.Introspectable"
>
<method
name=
"Introspect"
>
<arg
name=
"xml_data"
type=
"s"
direction=
"out"
/>
</method>
</interface>
<interface
name=
"org.freedesktop.DBus.Peer"
>
<method
name=
"Ping"
/>
<method
name=
"GetMachineId"
>
<arg
name=
"machine_uuid"
type=
"s"
direction=
"out"
/>
</method>
</interface>
</node>
plugins/screensaver-inhibit/screensaverinhibitplugin.cpp
View file @
8b4eaa54
...
...
@@ -9,40 +9,28 @@
#include <KLocalizedString>
#include <KPluginFactory>
#include <QDBusConnection>
#include
<QDBusI
nterface
>
#include
"screensaveri
nterface
.h"
#include "kdeconnect_screensaverinhibit_debug.h"
K_PLUGIN_CLASS_WITH_JSON
(
ScreensaverInhibitPlugin
,
"kdeconnect_screensaver_inhibit.json"
)
#define INHIBIT_SERVICE QStringLiteral("org.freedesktop.ScreenSaver")
#define INHIBIT_INTERFACE INHIBIT_SERVICE
#define INHIBIT_PATH QStringLiteral("/ScreenSaver")
#define INHIBIT_METHOD QStringLiteral("Inhibit")
#define UNINHIBIT_METHOD QStringLiteral("UnInhibit")
#define SIMULATE_ACTIVITY_METHOD QStringLiteral("SimulateUserActivity")
ScreensaverInhibitPlugin
::
ScreensaverInhibitPlugin
(
QObject
*
parent
,
const
QVariantList
&
args
)
:
KdeConnectPlugin
(
parent
,
args
)
{
QDBus
Interface
inhibitInterface
(
INHIBIT_SERVICE
,
INHIBIT_PATH
,
INHIBIT_INTERFACE
);
OrgFreedesktopScreenSaver
Interface
inhibitInterface
(
INHIBIT_SERVICE
,
INHIBIT_PATH
,
QDBusConnection
::
sessionBus
(),
this
);
QDBusMessage
reply
=
inhibitInterface
.
call
(
INHIBIT_METHOD
,
QStringLiteral
(
"org.kde.kdeconnect.daemon"
),
i18n
(
"Phone is connected"
));
if
(
!
reply
.
errorMessage
().
isEmpty
())
{
qCDebug
(
KDECONNECT_PLUGIN_SCREENSAVERINHIBIT
)
<<
"Unable to inhibit the screensaver: "
<<
reply
.
errorMessage
();
inhibitCookie
=
0
;
}
else
{
// Store the cookie we receive, this will be sent back when sending the uninhibit call.
inhibitCookie
=
reply
.
arguments
().
at
(
0
).
toUInt
();
}
inhibitCookie
=
inhibitInterface
.
Inhibit
(
QStringLiteral
(
"org.kde.kdeconnect.daemon"
),
i18n
(
"Phone is connected"
));
}
ScreensaverInhibitPlugin
::~
ScreensaverInhibitPlugin
()
{
if
(
inhibitCookie
==
0
)
return
;
QDBus
Interface
inhibitInterface
(
INHIBIT_SERVICE
,
INHIBIT_PATH
,
INHIBIT_INTERFACE
);
inhibitInterface
.
call
(
UNINHIBIT_METHOD
,
this
->
inhibitCookie
);
OrgFreedesktopScreenSaver
Interface
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
...
...
@@ -50,7 +38,7 @@ ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
* unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
* be locked anyway.
*/
inhibitInterface
.
call
(
SIMULATE_ACTIVITY_METHOD
);
inhibitInterface
.
SimulateUserActivity
(
);
}
void
ScreensaverInhibitPlugin
::
connected
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment