Example of python handling of the NetworkRegistrationChanged DBus signal sent by gnome-phone-manager

Submitted by daniele on Sat, 02/20/2010 - 21:13
#!/usr/bin/env python

import gobject

import dbus
from dbus.mainloop.glib import DBusGMainLoop

def network_signal_handler(mcc, mnc, lac, cid):
    print "MCC = %s MNC = %s LAC = %s CID = %s" % (mcc, mnc, lac, cid)

def setup():
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    bus.add_signal_receiver(network_signal_handler,
                            dbus_interface = "org.gnome.phone.Manager",
                            signal_name = "NetworkRegistrationChanged")

setup()
loop = gobject.MainLoop()
loop.run()