Changeset 293 for trunk

Show
Ignore:
Timestamp:
04/30/09 21:14:59 (3 years ago)
Author:
ocjhb
Message:

first redeem, needs error handling and coin picking

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/sandbox/jhb/mobile/ocwallet.py

    r292 r293  
    1515                      (u'Receive',u'Receive coins',self.getReceiveDetails), 
    1616                      (u'Freshen up',u'Freshen up the coins',self.getFreshenUpDetails), 
    17                       (u'Buy',u'Buy new coins',self.buyCoins), 
    18                       (u'Sell',u'Sell coins',self.getDetails), 
    19                       (u'Details',u'See what coins you hold',self.inspect),] 
     17                      (u'Buy',u'Buy new coins',self.mintCoins), 
     18                      (u'Sell',u'Sell coins',self.redeemCoins), 
     19                      (u'Details',u'See what coins you hold',self.inspectCurrency),] 
    2020 
    2121        self.methods=[(u'Internet',u'Use the internet'), 
     
    110110        return method 
    111111                               
    112     def inspect(self): 
     112    def inspectCurrency(self): 
    113113        #print 'inspect' 
    114         pass 
    115  
    116  
     114        cdd,amount = self.getCurrentCurrency() 
     115        id = cdd.currencyId 
     116        coins = self.wallet.getAllCoins(id) 
     117        coinlist = [] 
     118        for coin in coins: 
     119            coinlist.append(u'coin: %s' % coin.denomination) 
     120        self.currency_menu = appuifw.Listbox(coinlist,self.inspectCoin) 
     121        self.currency_menu.bind(EKeyRightArrow,self.inspectCoin) 
     122        self.currency_menu.bind(EKeyLeftArrow,self.displayActionMenu) 
     123        appuifw.app.body = self.currency_menu 
     124        appuifw.app.title = u'opencoin - currency\nCoins in wallet' 
     125  
     126    def inspectCoin(self): 
     127        cdd,amount = self.getCurrentCurrency() 
     128        id = cdd.currencyId 
     129        coins = self.wallet.getAllCoins(id) 
     130        coin = coins[self.currency_menu.current()] 
     131        details = [] 
     132        details.append((unicode(coin.standardId),u'Standard Id')) 
     133        details.append((unicode(coin.currencyId),u'Currency Id')) 
     134        details.append((unicode(coin.denomination),u'Denomination')) 
     135        self.coin_menu = appuifw.Listbox(details,self.inspectCurrency) 
     136        self.coin_menu.bind(EKeyLeftArrow,self.inspectCurrency) 
     137        appuifw.app.body = self.coin_menu 
     138        appuifw.app.title = u'opencoin - coin\nDetails of coin' 
     139  
    117140    def addCurrency(self): 
    118141        url = appuifw.query(u'url','text',u'http://192.168.2.101:9090') 
     
    136159        self.displayWalletMenu() 
    137160 
    138     def buyCoins(self): 
     161    def mintCoins(self): 
    139162        amount = self.getAmount() 
    140163        if not amount: 
     
    149172 
    150173        transport = transports.HTTPTransport(url) 
    151         self.wallet.buyCoins(transport,amount,target) 
    152         self.makeWalletMenu() 
    153         self.displayWalletMenu() 
     174        self.wallet.mintCoins(transport,amount,target) 
     175        self.makeWalletMenu() 
     176        self.displayWalletMenu() 
     177 
     178 
     179    def redeemCoins(self): 
     180        amount = self.getAmount() 
     181        if not amount: 
     182            return 
     183         
     184        target = self.getTarget() 
     185        if not target: 
     186            return 
     187 
     188        cdd,alreadythere = self.getCurrentCurrency() 
     189        url = cdd.issuerServiceLocation 
     190 
     191        transport = transports.HTTPTransport(url) 
     192        self.wallet.redeemCoins(transport,amount,target) 
     193        self.makeWalletMenu() 
     194        self.displayWalletMenu() 
     195 
    154196 
    155197    def execute(self): 
     
    169211                #sys.modules['socket'] = __import__('btsocket') 
    170212                import btsocket as socket 
    171                 apid = socket.select_access_point() 
    172                 apo = socket.access_point(apid) 
    173                 socket.set_default_access_point(apo) 
    174                 apo.start() 
    175                 self.apo = apo 
    176                 self.ip = apo.ip() 
     213                #apid = socket.select_access_point() 
     214                #apo = socket.access_point(apid) 
     215                #socket.set_default_access_point(apo) 
     216                #apo.start() 
     217                #self.apo = apo 
     218                #self.ip = apo.ip() 
    177219 
    178220            except ImportError: