From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 6/6] test: Convert simple-player to use DBus properties interface
Date: Tue, 27 Nov 2012 14:51:25 +0200 [thread overview]
Message-ID: <1354020685-17028-6-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1354020685-17028-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
test/simple-player | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/test/simple-player b/test/simple-player
index 9e72f3e..0037f3a 100755
--- a/test/simple-player
+++ b/test/simple-player
@@ -17,14 +17,16 @@ class Player(dbus.service.Object):
bus = dbus.SystemBus()
mp = dbus.Interface(bus.get_object("org.bluez", obj),
"org.bluez.MediaPlayer")
+ prop = dbus.Interface(bus.get_object("org.bluez", obj),
+ "org.freedesktop.DBus.Properties")
- self.properties = mp.GetProperties()
+ self.properties = prop.GetAll("org.bluez.MediaPlayer")
self.metadata = mp.GetTrack()
- bus.add_signal_receiver(self.property_changed,
+ bus.add_signal_receiver(self.properties_changed,
path = obj,
- dbus_interface = "org.bluez.MediaPlayer",
- signal_name = "PropertyChanged")
+ dbus_interface = "org.freedesktop.DBus.Properties",
+ signal_name = "PropertiesChanged")
bus.add_signal_receiver(self.track_changed,
path = obj,
@@ -59,18 +61,20 @@ class Player(dbus.service.Object):
print("Release")
mainloop.quit()
- @dbus.service.method("org.bluez.MediaPlayer",
- in_signature="sv", out_signature="")
- def SetProperty(self, key, value):
- print("SetProperty (%s, %s)" % (key, value), file=sys.stderr)
+ @dbus.service.method("org.freedesktop.DBus.Properties",
+ in_signature="ssv", out_signature="")
+ def Set(self, interface, key, value):
+ print("Set (%s, %s)" % (key, value), file=sys.stderr)
return
- @dbus.service.signal("org.bluez.MediaPlayer", signature="sv")
- def PropertyChanged(self, setting, value):
- """PropertyChanged(setting, value)
+ @dbus.service.signal("org.freedesktop.DBus.Properties",
+ signature="sa{sv}as")
+ def PropertiesChanged(self, interface, properties,
+ invalidated = dbus.Array()):
+ """PropertiesChanged(interface, properties, invalidated)
- Send a PropertyChanged signal. 'setting' and 'value' are
- string parameters as specified in doc/media-api.txt.
+ Send a PropertiesChanged signal. 'properties' is a dictionary
+ containing string parameters as specified in doc/media-api.txt.
"""
pass
@@ -86,10 +90,10 @@ class Player(dbus.service.Object):
def help(self, func):
help(self.__class__.__dict__[func])
- def property_changed(self, setting, value):
- print("property_changed(%s, %s)" % (setting, value))
+ def properties_changed(self, interface, properties, invalidated):
+ print("properties_changed(%s, %s)" % (properties, invalidated))
- self.PropertyChanged(setting, value)
+ self.PropertiesChanged(interface, properties, invalidated)
def track_changed(self, metadata):
print("track_changed(%s)" % (metadata))
@@ -98,8 +102,8 @@ class Player(dbus.service.Object):
class InputHandler:
commands = { 'TrackChanged': '(metadata)',
- 'PropertyChanged': '(key, value)',
- 'help': '(cmd)' }
+ 'PropertiesChanged': '(interface, properties)',
+ 'help': '(cmd)' }
def __init__(self, player):
self.player = player
print('\n\nAvailable commands:')
--
1.7.11.7
next prev parent reply other threads:[~2012-11-27 12:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 12:51 [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 2/6] audio: Convert controller MediaPlayer interface to use D-Bus Properties Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 3/6] media: Convert target " Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 4/6] media-api: Update documentation of MediaPlayer interface Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 5/6] test: Convert mpris-player to use DBus properties interface Luiz Augusto von Dentz
2012-11-27 12:51 ` Luiz Augusto von Dentz [this message]
2012-11-29 8:52 ` [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function Luiz Augusto von Dentz
2012-11-29 13:10 ` Lucas De Marchi
2012-11-30 8:31 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354020685-17028-6-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox