Changeset 316
- Timestamp:
- 05/20/09 17:57:36 (3 years ago)
- Files:
-
- 1 modified
-
trunk/sandbox/jhb/mobile/ocwallet.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sandbox/jhb/mobile/ocwallet.py
r315 r316 39 39 self.wallet_menu.bind(EKeyRightArrow,self.displayActionMenu) 40 40 41 def feedback(self,text ):42 status(unicode(text) )41 def feedback(self,text,cb=None): 42 status(unicode(text),callback=cb) 43 43 44 44 … … 212 212 213 213 def receiveCoinsHTTP(self,transport,port): 214 import BaseHTTPServer, urllib 215 214 import BaseHTTPServer, urllib,socket 215 216 class StoppableHTTPServer(BaseHTTPServer.HTTPServer): 217 218 def server_bind(self): 219 BaseHTTPServer.HTTPServer.server_bind(self) 220 self.socket.settimeout(0.5) 221 self.run = True 222 223 def get_request(self): 224 while self.run: 225 try: 226 e32.ao_yield() 227 sock, addr = self.socket.accept() 228 sock.settimeout(None) 229 return (sock, addr) 230 except socket.timeout: 231 if not self.run: 232 self.socket.close() 233 raise socket.error 234 235 def stop(self): 236 self.run = False 237 238 def serve(self): 239 while self.run: 240 self.handle_request() 241 242 216 243 class OCHandler(BaseHTTPServer.BaseHTTPRequestHandler): 217 244 … … 239 266 #r = urllib.urlopen('http://google.com') 240 267 #ip = urllib.urlopen('http://opencoin.org/myownip').read() 241 httpd = BaseHTTPServer.HTTPServer(("",port),OCHandler) 242 self.feedback(u'Receiving coins: waiting at %s' % (self.ip)) 243 httpd.handle_request() 244 httpd.handle_request() 268 self.httpd = StoppableHTTPServer(("",port),OCHandler) 269 self.feedback(u'Receiving coins: waiting at %s' % (self.ip),self.stopReceiveCoinsHTTP) 270 if self.httpd.run: 271 self.httpd.handle_request() 272 if self.httpd.run: 273 self.httpd.handle_request() 274 self.httpd.socket.close() 245 275 self.stopInternet() 276 277 def stopReceiveCoinsHTTP(self): 278 self.httpd.stop() 279 246 280 247 281 def getBTTransport(self): … … 408 442 409 443 410 def status(text,icon=None ):444 def status(text,icon=None,callback=None): 411 445 if ':' in text: 412 446 items = [unicode(p.strip()) for p in text.split(':',1)] … … 415 449 if icon: 416 450 items.append(icon) 417 appuifw.app.body = appuifw.Listbox([tuple(items)], lambda: None)418 451 452 body = appuifw.Listbox([tuple(items)], lambda: None) 453 if callback: 454 body.bind(EKeyLeftArrow,callback) 455 appuifw.app.body=body 419 456 e32.ao_sleep(0.3) 420 457
