Changeset 315
- Timestamp:
- 05/20/09 16:52:51 (3 years ago)
- Files:
-
- 1 modified
-
trunk/sandbox/jhb/mobile/ocwallet.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sandbox/jhb/mobile/ocwallet.py
r314 r315 40 40 41 41 def feedback(self,text): 42 #appuifw.note(unicode(message))43 42 status(unicode(text)) 44 #i = i=appuifw.InfoPopup() 45 #i.show(unicode(message), (0, 0), timeout*1000, 0, appuifw.EHCenterVCenter) 46 47 43 48 44 49 45 def displayWalletMenu(self): … … 71 67 72 68 73 def getAmount(self): 74 amount = appuifw.query(u'Amount','number') 75 amount = int(amount) 69 def getAmount(self,min=1,max=-1): 70 ok = False 71 text = ['Amount'] 72 text.append('min %s' % min) 73 if max != -1: 74 text.append('max %s' % max) 75 text = u', '.join([unicode(t) for t in text]) 76 while not ok: 77 amount = appuifw.query(text,'number') 78 if amount: 79 amount = int(amount) 80 if amount < min: 81 appuifw.note(u'amount to small','error') 82 continue 83 if max != -1 and amount > max: 84 appuifw.note(u'amount to large','error') 85 continue 86 ok = True 87 76 88 self.todo['amount'] = amount 77 89 return amount … … 83 95 self.todo['target'] = target 84 96 return target 85 86 def getDetails(self):87 88 amount = self.getAmount()89 if not amount:90 return91 92 target = self.getTarget()93 if not target:94 return95 96 method = self.getMethod()97 if method ==1:98 url = appuifw.query(u'url','text',u'http://')99 self.todo['url'] = url100 101 self.execute()102 97 103 98 … … 170 165 171 166 def redeemCoins(self): 172 amount = self.getAmount() 167 cdd,alreadythere = self.getCurrentCurrency() 168 amount = self.getAmount(max=alreadythere) 173 169 if not amount: 174 170 return … … 178 174 return 179 175 180 cdd,alreadythere = self.getCurrentCurrency()181 176 url = cdd.issuerServiceLocation 182 177 … … 194 189 195 190 196 def execute(self):197 #print 'execute'198 print self.todo199 200 191 def receiveCoins(self): 201 192 methodlist = [u'bluetooth',u'internet'] … … 207 198 self.receiveCoinsBT(transport) 208 199 else: 209 port = int(appuifw.query(u'port','number',9091))210 200 transport = self.getHTTPTransport(cdd.issuerServiceLocation) 211 self.receiveCoinsHTTP(transport, port)201 self.receiveCoinsHTTP(transport,walletport) 212 202 213 203 coinsound.play() … … 250 240 #ip = urllib.urlopen('http://opencoin.org/myownip').read() 251 241 httpd = BaseHTTPServer.HTTPServer(("",port),OCHandler) 252 self.feedback(u'Receiving coins: waiting at %s :%s' % (self.ip,port))242 self.feedback(u'Receiving coins: waiting at %s' % (self.ip)) 253 243 httpd.handle_request() 254 244 httpd.handle_request() … … 338 328 def spendCoins(self): 339 329 340 amount = self.getAmount() 330 cdd,alreadythere = self.getCurrentCurrency() 331 332 amount = self.getAmount(max=alreadythere) 341 333 if not amount: 342 334 return … … 350 342 351 343 352 cdd,alreadythere = self.getCurrentCurrency()353 344 if method == 1: 354 url = appuifw.query(u'url','text',u'http://192.168.2.105:9091') 345 url = appuifw.query(u'address','text',u'192.168.2.105') 346 if not url: 347 return 348 else: 349 url = 'http://%s:%s' % (url,walletport) 355 350 transport = self.getHTTPTransport(url) 356 351 self.wallet.spendCoins(transport,cdd.currencyId,amount,target) … … 381 376 if not self.ip: 382 377 import sys 378 import socket 383 379 if sys.platform == 'symbian_s60': 384 380 self.feedback(u'Preparing internet access:searching access points') 385 import socket386 381 aps = [ap['name'] for ap in socket.access_points()] 387 382 aps.sort() … … 390 385 391 386 socket.set_default_access_point(aps[apid]) 392 #one time socket, for just finding out our ip 393 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 394 #anonymity issue here 395 s.connect(('www.google.com',80)) 396 self.ip = s.getsockname()[0] 397 387 398 388 else: 399 389 import socket 400 390 self.ip = 'some ip' 401 391 392 #one time socket, for just finding out our ip 393 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 394 #anonymity issue here 395 s.connect(('www.google.com',80)) 396 self.ip = s.getsockname()[0] 397 402 398 403 399 def stopInternet(self): … … 424 420 425 421 def startup(text): 426 status('opencoin: loading '+text,icons['restore']) 422 if sys.platform == 'symbian_s60': 423 status('opencoin: loading '+text,icons['restore']) 424 425 426 427 427 ############################### main code ############################ 428 walletport = 9091 428 429 app_lock = e32.Ao_lock() 429 430 appuifw.app.screen='normal'
