Use generated DBus interface in mpriscontrol

This commit is contained in:
Nicolas Fella 2020-01-20 17:36:44 +01:00
parent 916ec3a405
commit f28ea834e1
6 changed files with 171 additions and 72 deletions

View file

@ -7,17 +7,17 @@ else()
mpriscontrolplugin.cpp mpriscontrolplugin.cpp
) )
qt5_add_dbus_interface( set_source_files_properties(
kdeconnect_mpriscontrol_SRCS org.freedesktop.DBus.Properties.xml
mprisdbusinterface.xml org.mpris.MediaPlayer2.Player.xml
mprisdbusinterface org.mpris.MediaPlayer2.xml
) PROPERTIES
NO_NAMESPACE ON)
qt5_add_dbus_interface(kdeconnect_mpriscontrol_SRCS org.freedesktop.DBus.Properties.xml dbusproperties)
qt5_add_dbus_interface(kdeconnect_mpriscontrol_SRCS org.mpris.MediaPlayer2.Player.xml mprisplayer)
qt5_add_dbus_interface(kdeconnect_mpriscontrol_SRCS org.mpris.MediaPlayer2.xml mprisroot)
qt5_add_dbus_interface(
kdeconnect_mpriscontrol_SRCS
propertiesInterface.xml
propertiesdbusinterface
)
endif() endif()
kdeconnect_add_plugin(kdeconnect_mpriscontrol JSON kdeconnect_mpriscontrol.json SOURCES ${kdeconnect_mpriscontrol_SRCS}) kdeconnect_add_plugin(kdeconnect_mpriscontrol JSON kdeconnect_mpriscontrol.json SOURCES ${kdeconnect_mpriscontrol_SRCS})

View file

@ -21,7 +21,6 @@
#include "mpriscontrolplugin.h" #include "mpriscontrolplugin.h"
#include <QDBusArgument> #include <QDBusArgument>
#include <QDBusInterface>
#include <qdbusconnectioninterface.h> #include <qdbusconnectioninterface.h>
#include <QDBusReply> #include <QDBusReply>
#include <QDBusMessage> #include <QDBusMessage>
@ -31,8 +30,10 @@
#include <core/device.h> #include <core/device.h>
#include <dbushelper.h> #include <dbushelper.h>
#include "mprisdbusinterface.h"
#include "propertiesdbusinterface.h" #include "dbusproperties.h"
#include "mprisplayer.h"
#include "mprisroot.h"
K_PLUGIN_CLASS_WITH_JSON(MprisControlPlugin, "kdeconnect_mpriscontrol.json") K_PLUGIN_CLASS_WITH_JSON(MprisControlPlugin, "kdeconnect_mpriscontrol.json")
@ -87,10 +88,9 @@ void MprisControlPlugin::addPlayer(const QString& service)
{ {
const QString mediaPlayerObjectPath = QStringLiteral("/org/mpris/MediaPlayer2"); const QString mediaPlayerObjectPath = QStringLiteral("/org/mpris/MediaPlayer2");
// estimate identifier string OrgMprisMediaPlayer2Interface iface(service, mediaPlayerObjectPath, DBusHelper::sessionBus());
QDBusInterface mprisInterface(service, mediaPlayerObjectPath, QStringLiteral("org.mpris.MediaPlayer2")); QString identity = iface.identity();
//FIXME: This call hangs and returns an empty string if KDED is still starting!
QString identity = mprisInterface.property("Identity").toString();
if (identity.isEmpty()) { if (identity.isEmpty()) {
identity = service.mid(sizeof("org.mpris.MediaPlayer2")); identity = service.mid(sizeof("org.mpris.MediaPlayer2"));
} }

View file

@ -1,47 +0,0 @@
<?xml version="1.0"?>
<!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.mpris.MediaPlayer2.Player">
<method name="Next"/>
<method name="Previous"/>
<method name="Pause"/>
<method name="PlayPause"/>
<method name="Stop"/>
<method name="Play"/>
<method name="Seek">
<arg direction="in" type="x" name="Offset"/>
</method>
<method name="SetPosition">
<arg direction="in" type="o" name="TrackId"/>
<arg direction="in" type="x" name="Position"/>
</method>
<method name="OpenUri">
<arg direction="in" type="s"/>
</method>
<!-- Signals -->
<signal name="Seeked">
<arg type="x" name="Position"/>
</signal>
<!-- Properties -->
<property access="read" type="s" name="PlaybackStatus"/>
<property access="readwrite" type="s" name="LoopStatus"/>
<property access="readwrite" type="d" name="Rate"/>
<property access="readwrite" type="b" name="Shuffle"/>
<property access="read" type="a{sv}" name="Metadata">
<annotation value="QVariantMap" name="com.trolltech.QtDBus.QtTypeName"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName"/>
</property>
<property access="readwrite" type="d" name="Volume"/>
<property access="read" type="x" name="Position"/>
<property access="read" type="d" name="MinimumRate"/>
<property access="read" type="d" name="MaximumRate"/>
<property access="read" type="b" name="CanGoNext"/>
<property access="read" type="b" name="CanGoPrevious"/>
<property access="read" type="b" name="CanPlay"/>
<property access="read" type="b" name="CanPause"/>
<property access="read" type="b" name="CanSeek"/>
<property access="read" type="b" name="CanControl"/>
</interface>
</node>

View file

@ -1,6 +1,4 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node> <node>
<interface name="org.freedesktop.DBus.Properties"> <interface name="org.freedesktop.DBus.Properties">
<method name="Get"> <method name="Get">
@ -19,12 +17,11 @@
<arg type="v" name="value" direction="in"/> <arg type="v" name="value" direction="in"/>
</method> </method>
<signal name="PropertiesChanged"> <signal name="PropertiesChanged">
<arg type="s" name="interface_name" direction="out"/> <arg type="s" name="interface_name"/>
<arg type="a{sv}" name="changed_properties" direction="out"/> <arg type="a{sv}" name="changed_properties"/>
<arg type="as" name="invalidated_properties" direction="out"/> <arg type="as" name="invalidated_properties"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
<!-- Aparently some old version of Qt/Dbus thinks interfaces have "input" parameters -->
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
</signal> </signal>
</interface> </interface>
</node> </node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->

View file

@ -0,0 +1,108 @@
<?xml version="1.0" ?>
<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2.Player">
<method name="Next" tp:name-for-bindings="Next">
</method>
<method name="Previous" tp:name-for-bindings="Previous">
</method>
<method name="Pause" tp:name-for-bindings="Pause">
</method>
<method name="PlayPause" tp:name-for-bindings="PlayPause">
</method>
<method name="Stop" tp:name-for-bindings="Stop">
</method>
<method name="Play" tp:name-for-bindings="Play">
</method>
<method name="Seek" tp:name-for-bindings="Seek">
<arg direction="in" type="x" name="Offset" tp:type="Time_In_Us">
</arg>
</method>
<method name="SetPosition" tp:name-for-bindings="Set_Position">
<arg direction="in" type="o" tp:type="Track_Id" name="TrackId">
</arg>
<arg direction="in" type="x" tp:type="Time_In_Us" name="Position">
</arg>
</method>
<method name="OpenUri" tp:name-for-bindings="Open_Uri">
<arg direction="in" type="s" tp:type="Uri" name="Uri">
</arg>
</method>
<property name="PlaybackStatus" tp:name-for-bindings="Playback_Status" type="s" tp:type="Playback_Status" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="LoopStatus" type="s" access="readwrite"
tp:name-for-bindings="Loop_Status" tp:type="Loop_Status">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="Rate" tp:name-for-bindings="Rate" type="d" tp:type="Playback_Rate" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="Shuffle" tp:name-for-bindings="Shuffle" type="b" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="Metadata" tp:name-for-bindings="Metadata" type="a{sv}" tp:type="Metadata_Map" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
</property>
<property name="Volume" type="d" tp:type="Volume" tp:name-for-bindings="Volume" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true" />
</property>
<property name="Position" type="x" tp:type="Time_In_Us" tp:name-for-bindings="Position" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="MinimumRate" tp:name-for-bindings="Minimum_Rate" type="d" tp:type="Playback_Rate" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="MaximumRate" tp:name-for-bindings="Maximum_Rate" type="d" tp:type="Playback_Rate" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanGoNext" tp:name-for-bindings="Can_Go_Next" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanGoPrevious" tp:name-for-bindings="Can_Go_Previous" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanPlay" tp:name-for-bindings="Can_Play" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanPause" tp:name-for-bindings="Can_Pause" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanSeek" tp:name-for-bindings="Can_Seek" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
<property name="CanControl" tp:name-for-bindings="Can_Control" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<signal name="Seeked" tp:name-for-bindings="Seeked">
<arg name="Position" type="x" tp:type="Time_In_Us">
</arg>
</signal>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->

View file

@ -0,0 +1,41 @@
<?xml version="1.0" ?>
<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<method name="Raise" tp:name-for-bindings="Raise">
</method>
<method name="Quit" tp:name-for-bindings="Quit">
</method>
<property name="CanQuit" type="b" tp:name-for-bindings="Can_Quit" access="read">
</property>
<property name="Fullscreen" type="b" tp:name-for-bindings="Fullscreen" access="readwrite">
</property>
<property name="CanSetFullscreen" type="b" tp:name-for-bindings="Can_Set_Fullscreen" access="read">
</property>
<property name="CanRaise" type="b" tp:name-for-bindings="Can_Raise" access="read">
</property>
<property name="HasTrackList" type="b" tp:name-for-bindings="Has_TrackList" access="read">
</property>
<property name="Identity" type="s" tp:name-for-bindings="Identity" access="read">
</property>
<property name="DesktopEntry" type="s" tp:name-for-bindings="Desktop_Entry" access="read">
</property>
<property name="SupportedUriSchemes" type="as" tp:name-for-bindings="Supported_Uri_Schemes" access="read">
</property>
<property name="SupportedMimeTypes" type="as" tp:name-for-bindings="Supported_Mime_Types" access="read">
</property>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->