/usr/lib/neard/tools/handover-agent is in neard-tools 0.16-0.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #!/usr/bin/python
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
from optparse import OptionParser
eir_test_data = [0x16,0x00\
,0x01,0x02,0x03,0x04,0x05,0x06\
,0x08,0x09,0x41,0x72,0x72,0x61,0x6b,0x69,0x73\
,0x04,0x0d,0x6e,0x01,0x00]
wsc_test_data = [0x10,0x4A,0x00,0x01,0x10\
,0x10,0x45,0x00,0x08\
,0x74,0x65,0x73,0x74,0x73,0x73,0x69,0x64\
,0x10,0x27,0x00,0x06\
,0x62,0x6C,0x61,0x62,0x6C,0x61]
power_state = None
def print_fields(fields):
if 'EIR' in fields:
s = ' '.join('{:#02x}'.format(i) for i in fields['EIR'])
print ' EIR: %s' % s
if 'nokia.com:bt' in fields:
s = ' '.join('{:#02x}'.format(i) for i in fields['nokia.com:bt'])
print ' nokia.com:bt: %s' % s
if 'State' in fields:
print ' State: %s' % fields['State']
if 'WSC' in fields:
s = ' '.join('{:#02x}'.format(i) for i in fields['WSC'])
print ' WSC: %s' % s
class BTHOAgent(dbus.service.Object):
@dbus.service.method('org.neard.HandoverAgent',
in_signature='',
out_signature='')
def Release(self):
print 'Release'
mainloop.quit()
@dbus.service.method('org.neard.HandoverAgent',
in_signature='a{sv}',
out_signature='')
def PushOOB(self, fields):
print 'PushOOB'
print_fields(fields)
@dbus.service.method('org.neard.HandoverAgent',
in_signature='a{sv}',
out_signature='a{sv}')
def RequestOOB(self, fields):
print 'RequestOOB'
print_fields(fields)
print ' Replying with'
s = ' '.join('{:#02x}'.format(i) for i in eir_test_data)
print ' EIR: %s' % s
if power_state != 'unknown':
print ' State: %s' % power_state
return {'EIR' : eir_test_data, 'State' : power_state}
else:
return {'EIR' : eir_test_data}
class WiFiHOAgent(dbus.service.Object):
@dbus.service.method('org.neard.HandoverAgent',
in_signature='',
out_signature='')
def Release(self):
print 'Release'
mainloop.quit()
@dbus.service.method('org.neard.HandoverAgent',
in_signature='a{sv}',
out_signature='')
def PushOOB(self, fields):
print 'PushOOB'
print_fields(fields)
@dbus.service.method('org.neard.HandoverAgent',
in_signature='a{sv}',
out_signature='a{sv}')
def RequestOOB(self, fields):
print 'RequestOOB'
print_fields(fields)
print ' Replying with'
s = ' '.join('{:#02x}'.format(i) for i in wsc_test_data)
print ' WSC: %s' % s
if power_state != 'unknown':
print ' State: %s' % power_state
return {'WSC' : wsc_test_data, 'State' : power_state}
else:
return {'WSC' : wsc_test_data}
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
parser = OptionParser()
parser.add_option("-s", "--power-state", action="store", type="string",
dest="power_state", default="active",
help="active inactive activating unknown")
(options, args) = parser.parse_args()
power_state = options.power_state
obj = bus.get_object("org.neard", "/org/neard");
manager = dbus.Interface(obj, "org.neard.AgentManager")
btpath = '/test/handover/bt/agent'
btcarrier = 'bluetooth'
btobject = BTHOAgent(bus, btpath)
wifipath = '/test/handover/wifi/agent'
wificarrier = 'wifi'
wifiobject = WiFiHOAgent(bus, wifipath)
manager.RegisterHandoverAgent(btpath, btcarrier)
manager.RegisterHandoverAgent(wifipath, wificarrier)
mainloop = gobject.MainLoop()
try:
mainloop.run()
except (KeyboardInterrupt):
manager.UnregisterHandoverAgent(btpath, btcarrier)
manager.UnregisterHandoverAgent(wifipath, wificarrier)
|