4 python example-signal-emitter.py &
5 python example-signal-recipient.py
6 python example-signal-recipient.py --exit-service
9 # Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/>
10 # Copyright (C) 2005-2007 Collabora Ltd. <http://www.collabora.co.uk/>
12 # Permission is hereby granted, free of charge, to any person
13 # obtaining a copy of this software and associated documentation
14 # files (the "Software"), to deal in the Software without
15 # restriction, including without limitation the rights to use, copy,
16 # modify, merge, publish, distribute, sublicense, and/or sell copies
17 # of the Software, and to permit persons to whom the Software is
18 # furnished to do so, subject to the following conditions:
20 # The above copyright notice and this permission notice shall be
21 # included in all copies or substantial portions of the Software.
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 # DEALINGS IN THE SOFTWARE.
36 import dbus
.mainloop
.glib
38 class TestObject(dbus
.service
.Object
):
39 def __init__(self
, conn
, object_path
='/com/example/TestService/object'):
40 dbus
.service
.Object
.__init
__(self
, conn
, object_path
)
42 @dbus.service
.signal('com.example.TestService')
43 def HelloSignal(self
, message
):
44 # The signal is emitted when this method exits
45 # You can have code here if you wish
48 @dbus.service
.method('com.example.TestService')
49 def emitHelloSignal(self
):
50 #you emit signals by calling the signal's skeleton method
51 self
.HelloSignal('Hello')
52 return 'Signal emitted'
54 @dbus.service
.method("com.example.TestService",
55 in_signature
='', out_signature
='')
59 if __name__
== '__main__':
60 dbus
.mainloop
.glib
.DBusGMainLoop(set_as_default
=True)
62 session_bus
= dbus
.SessionBus()
63 name
= dbus
.service
.BusName('com.example.TestService', session_bus
)
64 object = TestObject(session_bus
)
66 loop
= gobject
.MainLoop()
67 print "Running example signal emitter service."