summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'dbus')
-rw-r--r--dbus/examples/.cvsignore2
-rw-r--r--dbus/examples/example-client.py51
-rw-r--r--dbus/examples/example-service.py50
-rw-r--r--dbus/examples/example-signal-emitter.py46
-rw-r--r--dbus/examples/example-signal-recipient.py77
-rw-r--r--dbus/examples/gconf-proxy-client.py15
-rw-r--r--dbus/examples/gconf-proxy-service2.py40
-rw-r--r--dbus/examples/list-system-services.py41
8 files changed, 0 insertions, 322 deletions
diff --git a/dbus/examples/.cvsignore b/dbus/examples/.cvsignore
deleted file mode 100644
index 282522d..0000000
--- a/dbus/examples/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/dbus/examples/example-client.py b/dbus/examples/example-client.py
deleted file mode 100644
index aae4c3f..0000000
--- a/dbus/examples/example-client.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-
-usage = """Usage:
-python example-service.py &
-python example-client.py
-python example-client.py --exit-service
-"""
-
-import sys
-from traceback import print_exc
-
-import dbus
-import dbus.mainloop.glib
-
-def main():
- bus = dbus.SessionBus()
-
- try:
- remote_object = bus.get_object("com.example.SampleService",
- "/SomeObject")
-
- # you can either specify the dbus_interface in each call...
- hello_reply_list = remote_object.HelloWorld("Hello from example-client.py!",
- dbus_interface = "com.example.SampleInterface")
- except dbus.DBusException:
- print_exc()
- print usage
- sys.exit(1)
-
- print (hello_reply_list)
-
- # ... or create an Interface wrapper for the remote object
- iface = dbus.Interface(remote_object, "com.example.SampleInterface")
-
- hello_reply_tuple = iface.GetTuple()
-
- print hello_reply_tuple
-
- hello_reply_dict = iface.GetDict()
-
- print hello_reply_dict
-
- # introspection is automatically supported
- print remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable")
-
- if sys.argv[1:] == ['--exit-service']:
- iface.Exit()
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- main()
diff --git a/dbus/examples/example-service.py b/dbus/examples/example-service.py
deleted file mode 100644
index fc3ded5..0000000
--- a/dbus/examples/example-service.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-usage = """Usage:
-python example-service.py &
-python example-client.py
-python example-client.py --exit-service
-"""
-
-import gobject
-
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-
-class SomeObject(dbus.service.Object):
-
- @dbus.service.method("com.example.SampleInterface",
- in_signature='s', out_signature='as')
- def HelloWorld(self, hello_message):
- print (str(hello_message))
- return ["Hello", " from example-service.py", "with unique name",
- session_bus.get_unique_name()]
-
- @dbus.service.method("com.example.SampleInterface",
- in_signature='', out_signature='(ss)')
- def GetTuple(self):
- return ("Hello Tuple", " from example-service.py")
-
- @dbus.service.method("com.example.SampleInterface",
- in_signature='', out_signature='a{ss}')
- def GetDict(self):
- return {"first": "Hello Dict", "second": " from example-service.py"}
-
- @dbus.service.method("com.example.SampleInterface",
- in_signature='', out_signature='')
- def Exit(self):
- mainloop.quit()
-
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- session_bus = dbus.SessionBus()
- name = dbus.service.BusName("com.example.SampleService", session_bus)
- object = SomeObject(session_bus, '/SomeObject')
-
- mainloop = gobject.MainLoop()
- print "Running example service."
- print usage
- mainloop.run()
diff --git a/dbus/examples/example-signal-emitter.py b/dbus/examples/example-signal-emitter.py
deleted file mode 100644
index 24384c1..0000000
--- a/dbus/examples/example-signal-emitter.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env python
-
-usage = """Usage:
-python example-signal-emitter.py &
-python example-signal-recipient.py
-python example-signal-recipient.py --exit-service
-"""
-
-import gobject
-
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-
-class TestObject(dbus.service.Object):
- def __init__(self, conn, object_path='/com/example/TestService/object'):
- dbus.service.Object.__init__(self, conn, object_path)
-
- @dbus.service.signal('com.example.TestService')
- def HelloSignal(self, message):
- # The signal is emitted when this method exits
- # You can have code here if you wish
- pass
-
- @dbus.service.method('com.example.TestService')
- def emitHelloSignal(self):
- #you emit signals by calling the signal's skeleton method
- self.HelloSignal('Hello')
- return 'Signal emitted'
-
- @dbus.service.method("com.example.TestService",
- in_signature='', out_signature='')
- def Exit(self):
- loop.quit()
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- session_bus = dbus.SessionBus()
- name = dbus.service.BusName('com.example.TestService', session_bus)
- object = TestObject(session_bus)
-
- loop = gobject.MainLoop()
- print "Running example signal emitter service."
- print usage
- loop.run()
diff --git a/dbus/examples/example-signal-recipient.py b/dbus/examples/example-signal-recipient.py
deleted file mode 100644
index 3d8a190..0000000
--- a/dbus/examples/example-signal-recipient.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env python
-
-usage = """Usage:
-python example-signal-emitter.py &
-python example-signal-recipient.py
-python example-signal-recipient.py --exit-service
-"""
-
-import sys
-import traceback
-
-import gobject
-
-import dbus
-import dbus.decorators
-import dbus.mainloop.glib
-
-def handle_reply(msg):
- print msg
-
-def handle_error(e):
- print str(e)
-
-def emit_signal():
- #call the emitHelloSignal method
- object.emitHelloSignal(dbus_interface="com.example.TestService")
- #reply_handler = handle_reply, error_handler = handle_error)
- # exit after waiting a short time for the signal
- gobject.timeout_add(2000, loop.quit)
-
- if sys.argv[1:] == ['--exit-service']:
- object.Exit(dbus_interface='com.example.TestService')
-
- return False
-
-def hello_signal_handler(hello_string):
- print ("Received signal (by connecting using remote object) and it says: "
- + hello_string)
-
-def catchall_signal_handler(*args, **kwargs):
- print ("Caught signal (in catchall handler) "
- + kwargs['dbus_interface'] + "." + kwargs['member'])
- for arg in args:
- print " " + str(arg)
-
-def catchall_hello_signals_handler(hello_string):
- print "Received a hello signal and it says " + hello_string
-
-def catchall_testservice_interface_handler(hello_string, dbus_message):
- print "com.example.TestService interface says " + hello_string + " when it sent signal " + dbus_message.get_member()
-
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SessionBus()
- try:
- object = bus.get_object("com.example.TestService","/com/example/TestService/object")
-
- object.connect_to_signal("HelloSignal", hello_signal_handler, dbus_interface="com.example.TestService", arg0="Hello")
- except dbus.DBusException:
- traceback.print_exc()
- print usage
- sys.exit(1)
-
- #lets make a catchall
- bus.add_signal_receiver(catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member')
-
- bus.add_signal_receiver(catchall_hello_signals_handler, dbus_interface = "com.example.TestService", signal_name = "HelloSignal")
-
- bus.add_signal_receiver(catchall_testservice_interface_handler, dbus_interface = "com.example.TestService", message_keyword='dbus_message')
-
- # Tell the remote object to emit the signal after a short delay
- gobject.timeout_add(2000, emit_signal)
-
- loop = gobject.MainLoop()
- loop.run()
diff --git a/dbus/examples/gconf-proxy-client.py b/dbus/examples/gconf-proxy-client.py
deleted file mode 100644
index 222c96e..0000000
--- a/dbus/examples/gconf-proxy-client.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-
-print "WARNING: this hasn't been updated to current API yet, and might not work"
-
-import dbus
-
-gconf_key = "/desktop/gnome/file_views/icon_theme"
-
-bus = dbus.SessionBus()
-gconf_service = bus.get_service("org.gnome.GConf")
-gconf_key_object = gconf_service.get_object("/org/gnome/GConf" + gconf_key, "org.gnome.GConf")
-
-value = gconf_key_object.getString()
-
-print ("Value of GConf key %s is %s" % (gconf_key, value))
diff --git a/dbus/examples/gconf-proxy-service2.py b/dbus/examples/gconf-proxy-service2.py
deleted file mode 100644
index 36a323a..0000000
--- a/dbus/examples/gconf-proxy-service2.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-print "WARNING: this hasn't been updated to current API yet, and might not work"
-#FIXME: doesn't work with the new bindings
-import dbus
-
-import gobject
-import gconf
-
-class GConfService(dbus.Service):
-
- def __init__(self):
- dbus.Service.__init__(self, "org.gnome.GConf", dbus.SessionBus())
-
- gconf_object_tree = self.GConfObjectTree(self)
-
- class GConfObjectTree(dbus.ObjectTree):
- def __init__(self, service):
- dbus.ObjectTree.__init__(self, "/org/gnome/GConf", service)
-
- self.client = gconf.client_get_default()
-
- def object_method_called(self, message, object_path, method_name, argument_list):
- print ("Method %s called on GConf key %s" % (method_name, object_path))
-
- if "getString" == method_name:
- return self.client.get_string(object_path)
- elif "setString" == method_name:
- self.client.set_int(object_path, argument_list[0])
- elif "getInt" == method_name:
- return self.client.get_int(object_path)
- elif "setInt" == method_name:
- self.client.set_int(object_path, argument_list[0])
-
-gconf_service = GConfService()
-
-print ("GConf Proxy service started.")
-print ("Run 'gconf-proxy-client.py' to fetch a GConf key through the proxy...")
-
-mainloop = gobject.MainLoop()
-mainloop.run()
diff --git a/dbus/examples/list-system-services.py b/dbus/examples/list-system-services.py
deleted file mode 100644
index da4111b..0000000
--- a/dbus/examples/list-system-services.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-
-"""Usage: python list-system-services.py [--session|--system]
-List services on the system bus (default) or the session bus."""
-
-import sys
-
-import dbus
-
-def main(argv):
- factory = dbus.SystemBus
-
- if len(argv) > 2:
- sys.exit(__doc__)
- elif len(argv) == 2:
- if argv[1] == '--session':
- factory = dbus.SessionBus
- elif argv[1] != 'system':
- sys.exit(__doc__)
-
- # Get a connection to the system or session bus as appropriate
- bus = factory()
-
- # Get a reference to the desktop bus' standard object, denoted
- # by the path /org/freedesktop/DBus.
- dbus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
-
- # The object /org/freedesktop/DBus
- # implements the 'org.freedesktop.DBus' interface
- dbus_iface = dbus.Interface(dbus_object, 'org.freedesktop.DBus')
-
- # One of the member functions in the org.freedesktop.DBus interface
- # is ListServices(), which provides a list of all the other services
- # registered on this bus. Call it, and print the list.
- services = dbus_object.ListNames()
- services.sort()
- for service in services:
- print service
-
-if __name__ == '__main__':
- main(sys.argv)