6 import dbus.mainloop.glib
26 if t is dbus.Dictionary:
27 return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
28 if t is dbus.Array and d.signature == "y":
29 return "".join([chr(b) for b in d])
30 if t is dbus.Array or t is list:
31 return [dbus2py(v) for v in d]
32 if t is dbus.Struct or t is tuple:
33 return tuple([dbus2py(v) for v in d])
40 if t in (dict, tuple, list) and len(d) > 0:
42 d = ", ".join(["%s = %s" % (k, pretty(v))
43 for k, v in d.items()])
46 d = " ".join([pretty(e) for e in d])
53 def property_changed(name, value, path, interface):
54 iface = interface[interface.rfind(".") + 1:]
55 print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value))
57 def added(name, value, member, path, interface):
58 iface = interface[interface.rfind(".") + 1:]
59 print "{%s} [%s] %s %s" % (iface, member, name, pretty(value))
61 def removed(name, member, path, interface):
62 iface = interface[interface.rfind(".") + 1:]
63 print "{%s} [%s] %s" % (iface, name, member)
65 def event(member, path, interface):
66 iface = interface[interface.rfind(".") + 1:]
67 print "{%s} [%s] %s" % (iface, path, member)
69 def message(msg, args, member, path, interface):
70 iface = interface[interface.rfind(".") + 1:]
71 print "{%s} [%s] %s %s (%s)" % (iface, path, member,
74 def ussd(msg, member, path, interface):
75 iface = interface[interface.rfind(".") + 1:]
76 print "{%s} [%s] %s %s" % (iface, path, member, msg)
78 def value(value, member, path, interface):
79 iface = interface[interface.rfind(".") + 1:]
80 print "{%s} [%s] %s %s" % (iface, path, member, str(value))
82 if __name__ == '__main__':
83 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
85 bus = dbus.SystemBus()
87 bus.add_signal_receiver(property_changed,
89 signal_name = "PropertyChanged",
91 interface_keyword="interface")
93 for member in ["IncomingBarringInEffect",
94 "OutgoingBarringInEffect",
95 "NearMaximumWarning"]:
96 bus.add_signal_receiver(event,
99 member_keyword="member",
101 interface_keyword="interface")
103 for member in ["ModemAdded",
107 bus.add_signal_receiver(added,
108 bus_name="org.ofono",
109 signal_name = member,
110 member_keyword="member",
112 interface_keyword="interface")
114 for member in ["ModemRemoved",
118 bus.add_signal_receiver(removed,
119 bus_name="org.ofono",
120 signal_name = member,
121 member_keyword="member",
123 interface_keyword="interface")
125 for member in ["DisconnectReason", "Forwarded", "BarringActive"]:
126 bus.add_signal_receiver(value,
127 bus_name="org.ofono",
128 signal_name = member,
129 member_keyword="member",
131 interface_keyword="interface")
133 for member in ["IncomingBroadcast", "EmergencyBroadcast",
134 "IncomingMessage", "ImmediateMessage"]:
135 bus.add_signal_receiver(message,
136 bus_name="org.ofono",
137 signal_name = member,
138 member_keyword="member",
140 interface_keyword="interface")
142 for member in ["NotificationReceived", "RequestReceived"]:
143 bus.add_signal_receiver(ussd,
144 bus_name="org.ofono",
145 signal_name = member,
146 member_keyword="member",
148 interface_keyword="interface")
150 mainloop = gobject.MainLoop()