mirror of git://git.sysmocom.de/ofono
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
53 lines
1.3 KiB
#!/usr/bin/python3
|
|
|
|
from gi.repository import GLib
|
|
|
|
import sys
|
|
import dbus
|
|
import dbus.service
|
|
import dbus.mainloop.glib
|
|
|
|
class PushNotificationAgent(dbus.service.Object):
|
|
@dbus.service.method("org.ofono.PushNotificationAgent",
|
|
in_signature="", out_signature="")
|
|
def Release(self):
|
|
print("Release")
|
|
mainloop.quit()
|
|
|
|
@dbus.service.method("org.ofono.PushNotificationAgent",
|
|
in_signature="aya{sv}", out_signature="")
|
|
def ReceiveNotification(self, data, props):
|
|
for key in props.keys():
|
|
print("Key: %s, Value: %s" % (key, props[key]))
|
|
|
|
print("Received notification of size: %d" % len(data))
|
|
|
|
if __name__ == '__main__':
|
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
|
|
bus = dbus.SystemBus()
|
|
manager = dbus.Interface(bus.get_object("org.ofono", "/"),
|
|
"org.ofono.Manager")
|
|
|
|
modems = manager.GetModems()
|
|
|
|
for path, properties in modems:
|
|
if "org.ofono.PushNotification" not in properties["Interfaces"]:
|
|
continue
|
|
|
|
pn = dbus.Interface(bus.get_object('org.ofono', path),
|
|
'org.ofono.PushNotification')
|
|
|
|
path = "/test/agent"
|
|
agent = PushNotificationAgent(bus, path)
|
|
pn.RegisterAgent(path)
|
|
print("Agent registered")
|
|
|
|
mainloop = GLib.MainLoop()
|
|
|
|
try:
|
|
mainloop.run()
|
|
except KeyboardInterrupt:
|
|
pn.UnregisterAgent(path)
|
|
mainloop.run()
|