from gi.repository import GLib, Gio
from gi.repository import GUPnPIgd

def on_fail(igd, error, protocol, external_port, local_ip, local_port, desc, data=None):
	# FIXME: This can crash...
	# FIXME: Also error is invalid here..?
	print('failed') 
def on_success(igd, protocol, external_ip, replaces_external_ip, external_port, 
				local_ip, local_port, desc, data=None):
	print('success')


address = 'invalid-address' # '192.168.1.106'
port = 4124

igd = GUPnPIgd.SimpleIgd()
igd.connect('error-mapping-port', on_fail)
igd.connect('mapped-external-port', on_success)

def test():
	igd.add_port('TCP', 113, address, port, 180, 'Identd')
	print('added one')
	return False

GLib.timeout_add_seconds(1, test)
GLib.MainLoop().run()