Changeset 300
- Timestamp:
- 05/04/09 18:49:31 (3 years ago)
- Location:
- trunk/sandbox/jhb/mobile
- Files:
-
- 1 modified
- 1 copied
-
btsocket.py (copied) (copied from trunk/sandbox/jhb/mobile/pys60_compat_socket.py) (2 diffs)
-
ocwallet.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sandbox/jhb/mobile/btsocket.py
r292 r300 26 26 27 27 import socket 28 28 import 29 29 simulated_access_points = { 10: "life :) Internet", 15: "Vodafone Internet", 25: "WLAN" } 30 30 default_access_point = None … … 61 61 return [{'iapid': k, 'name': unicode(v)} for k,v in simulated_access_points.items()] 62 62 63 64 65 66 import bluetooth 67 AF_BT = socket.AF_BLUETOOTH 68 69 70 71 63 72 # provide access to all canonical socket module's functions, classess, etc... 64 73 def __getattr__(aAttr): -
trunk/sandbox/jhb/mobile/ocwallet.py
r299 r300 4 4 import encodings 5 5 from oc2 import storage,wallet, transports 6 import sys 6 7 7 8 class WalletClient: … … 209 210 self.displayWalletMenu() 210 211 212 def receiveCoinsBT(self,transport): 213 import btsocket 214 server_socket = btsocket.socket(btsocket.AF_BT, btsocket.SOCK_STREAM) 215 port = btsocket.bt_rfcomm_get_available_server_channel(server_socket) 216 server_socket.bind(("", port)) 217 server_socket.listen(1) 218 btsocket.bt_advertise_service( u"opencoin", server_socket, True, btsocket.RFCOMM) 219 btsocket.set_security(server_socket, btsocket.AUTH) 220 (sock,peer_addr) = server_socket.accept() 221 def receive(sock): 222 received = '' 223 try: 224 while True: 225 data = sock.recv(1024) 226 if len(data) == 0: break 227 received += data 228 except IOError: 229 pass 230 return transports.createMessage(received) 231 232 self.wallet.getApproval = self.getApproval 233 reply(self.wallet.listenSum(receive(sock)) 234 reply(self.wallet.listenSum(receive(sock)) 235 236 211 237 212 238 … … 282 308 import sys 283 309 try: 284 #sys.modules['socket'] = __import__('btsocket') 285 import btsocket as socket 310 sys.modules['socket'] = __import__('btsocket') 311 import socket 312 #import btsocket as socket 286 313 apid = socket.select_access_point() 287 314 apo = socket.access_point(apid) 288 socket.set_default_access_point(apo)315 #socket.set_default_access_point(apo) 289 316 apo.start() 290 317 self.apo = apo
