2005-05-01 19:34:58 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
2004-07-11 03:02:14 +00:00
|
|
|
import dbus
|
2005-07-12 18:16:07 +00:00
|
|
|
import dbus.service
|
2005-07-17 21:02:56 +00:00
|
|
|
import dbus.glib
|
|
|
|
|
import gobject
|
2004-07-11 03:02:14 +00:00
|
|
|
|
2005-07-12 18:16:07 +00:00
|
|
|
class TestObject(dbus.service.Object):
|
2005-07-15 18:09:59 +00:00
|
|
|
def __init__(self, bus_name, object_path='/org/designfu/TestService/object'):
|
|
|
|
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
2004-07-11 03:02:14 +00:00
|
|
|
|
2005-07-12 18:16:07 +00:00
|
|
|
@dbus.service.signal('org.designfu.TestService')
|
2005-04-25 22:54:28 +00:00
|
|
|
def HelloSignal(self, message):
|
|
|
|
|
# The signal is emitted when this method exits
|
2005-05-24 00:21:07 +00:00
|
|
|
# You can have code here if you wish
|
2005-04-25 22:54:28 +00:00
|
|
|
pass
|
2004-07-11 03:02:14 +00:00
|
|
|
|
2005-07-12 18:16:07 +00:00
|
|
|
@dbus.service.method('org.designfu.TestService')
|
2005-04-25 22:54:28 +00:00
|
|
|
def emitHelloSignal(self):
|
|
|
|
|
#you emit signals by calling the signal's skeleton method
|
2005-07-15 18:09:59 +00:00
|
|
|
self.HelloSignal('Hello')
|
|
|
|
|
return 'Signal emitted'
|
2005-05-24 00:21:07 +00:00
|
|
|
|
2004-07-11 03:02:14 +00:00
|
|
|
session_bus = dbus.SessionBus()
|
2005-07-15 18:09:59 +00:00
|
|
|
name = dbus.service.BusName('org.designfu.TestService', bus=session_bus)
|
2005-07-12 18:16:07 +00:00
|
|
|
object = TestObject(name)
|
2004-07-11 03:02:14 +00:00
|
|
|
|
2005-07-17 21:02:56 +00:00
|
|
|
loop = gobject.MainLoop()
|
|
|
|
|
loop.run()
|