Make the headset button work again
[panucci.git] / src / panucci / dbusinterface.py
bloba511277f4547f10805885aa5754abb3b9369c6fe
1 #!/usr/bin/env python
3 import logging
4 import dbus
5 import dbus.service
7 import util
9 class panucciInterface(dbus.service.Object):
10 """ Panucci's d-bus interface """
12 def __init__(self, bus_name, path='/panucciInterface'):
13 self.__log = logging.getLogger('panucci.dbusinterface.panucciInterface')
14 dbus.service.Object.__init__(self, object_path=path, bus_name=bus_name)
16 self.player = None
17 self.gui = None
18 self.headset_device = None
20 if util.platform == util.MAEMO:
21 headset_button = dbus.SystemBus().get_object(
22 'org.freedesktop.Hal', '/org/freedesktop/Hal/devices/'
23 'platform_retu_headset_logicaldev_input' )
24 self.headset_device = dbus.Interface(
25 headset_button, 'org.freedesktop.Hal.Device')
27 def register_player(self, player):
28 self.__log.debug('Registered player.')
29 self.player = player
31 def register_gui(self, gui):
32 self.__log.debug('Registered GUI.')
33 self.gui = gui
35 @dbus.service.method('org.panucci.panucciInterface')
36 def play(self):
37 if self.player is not None: self.player.play()
39 @dbus.service.method('org.panucci.panucciInterface')
40 def pause(self):
41 if self.player is not None: self.player.pause()
43 @dbus.service.method('org.panucci.panucciInterface')
44 def stop(self):
45 if self.player is not None: self.player.stop()
47 @dbus.service.method('org.panucci.panucciInterface')
48 def playPause(self):
49 if self.player is not None: self.player.play_pause_toggle()
51 @dbus.service.method('org.panucci.panucciInterface', in_signature='s')
52 def play_file(self, filepath):
53 if self.player is not None: self.player.play_file(filepath)
55 @dbus.service.method('org.panucci.panucciInterface', in_signature='s')
56 def queue_file(self, filepath):
57 if self.player is not None: self.player.playlist.append(filepath)
59 @dbus.service.method('org.panucci.panucciInterface', in_signature='su')
60 def insert_file(self, pos, filepath):
61 if self.player is not None: self.player.playlist.insert(pos, filepath)
63 @dbus.service.method('org.panucci.panucciInterface')
64 def show_main_window(self):
65 if self.gui is not None: self.gui.show_main_window()
67 interface = panucciInterface(
68 dbus.service.BusName('org.panucci.panucciInterface', dbus.SessionBus()) )