Add wrapper for DBusServer.
[dbus-python-phuang.git] / examples / gconf-proxy-service2.py
blobf805b77b90b28de5c4eac19cf9d6647627c71fc7
1 #!/usr/bin/env python
2 print "WARNING: this hasn't been updated to current API yet, and might not work"
3 #FIXME: doesn't work with the new bindings
5 # Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/>
6 # Copyright (C) 2005-2007 Collabora Ltd. <http://www.collabora.co.uk/>
8 # Permission is hereby granted, free of charge, to any person
9 # obtaining a copy of this software and associated documentation
10 # files (the "Software"), to deal in the Software without
11 # restriction, including without limitation the rights to use, copy,
12 # modify, merge, publish, distribute, sublicense, and/or sell copies
13 # of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
16 # The above copyright notice and this permission notice shall be
17 # included in all copies or substantial portions of the Software.
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 # DEALINGS IN THE SOFTWARE.
28 import dbus
30 import gobject
31 import gconf
33 class GConfService(dbus.Service):
35 def __init__(self):
36 dbus.Service.__init__(self, "org.gnome.GConf", dbus.SessionBus())
38 gconf_object_tree = self.GConfObjectTree(self)
40 class GConfObjectTree(dbus.ObjectTree):
41 def __init__(self, service):
42 dbus.ObjectTree.__init__(self, "/org/gnome/GConf", service)
44 self.client = gconf.client_get_default()
46 def object_method_called(self, message, object_path, method_name, argument_list):
47 print ("Method %s called on GConf key %s" % (method_name, object_path))
49 if "getString" == method_name:
50 return self.client.get_string(object_path)
51 elif "setString" == method_name:
52 self.client.set_int(object_path, argument_list[0])
53 elif "getInt" == method_name:
54 return self.client.get_int(object_path)
55 elif "setInt" == method_name:
56 self.client.set_int(object_path, argument_list[0])
58 gconf_service = GConfService()
60 print ("GConf Proxy service started.")
61 print ("Run 'gconf-proxy-client.py' to fetch a GConf key through the proxy...")
63 mainloop = gobject.MainLoop()
64 mainloop.run()