Show
Ignore:
Timestamp:
05/23/09 02:06:34 (3 years ago)
Author:
ocjhb
Message:

when storing: removed b64, added zlib

Files:
1 modified

Legend:

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

    r318 r319  
    4848        appuifw.app.title = u'opencoin wallet\nall currencies' 
    4949        appuifw.app.menu = [(u'add currency',self.addCurrency), 
    50                             (u'delete currency',self.delCurrency)] 
     50                            (u'delete currency',self.delCurrency), 
     51                            (u'new password',self.newPassword),] 
    5152 
    5253    def displayActionMenu(self): 
     
    426427            self.ip = s.getsockname()[0] 
    427428 
     429     
    428430 
    429431    def stopInternet(self): 
    430432        pass 
     433 
     434 
     435    def newPassword(self): 
     436        password = appuifw.query(u'new password','text') 
     437        if password != None: 
     438            self.storage.setPassword(password) 
     439            appuifw.note(u'new password set','conf') 
     440 
     441 
     442 
     443 
    431444 
    432445def filmIt(foo=None): 
     
    459472 
    460473############################### main code ############################         
     474 
     475#what port do we listen on? 
    461476walletport = 9091 
     477 
     478#setting up the environment 
    462479app_lock = e32.Ao_lock() 
    463480appuifw.app.screen='normal' 
     481 
     482#this will return normal control to the main code once the exit key is pressed 
    464483appuifw.app.exit_key_handler = app_lock.signal 
     484 
    465485import oc2 
    466486import sys 
     487 
     488#finding out where we are, in order to get the icons 
    467489oc2path = oc2.__file__ 
    468490if sys.platform == 'symbian_s60': 
     
    474496        #standalone app 
    475497        mediapath = u'%s\\private\\%s\\' % (basedrive,appuifw.app.uid()) 
     498    storagepath=u'e:\\' 
    476499else: 
    477500    mediapath = u'' 
     501    storagepath=u'' 
    478502         
    479503#only for documenting it 
     
    481505#filmIt() 
    482506 
     507#set up the icons 
    483508names = dict(coin=0,opencoin=1,coins=2,detail=3,down=4,left=5,refresh=6, 
    484509             restore=7,right=8,save=9,up=10,zoom=11) 
     
    487512startup('storage') 
    488513from oc2 import storage as oc2storage 
     514 
     515#Try to use a password on the data file. Repeat till its sucessfully loaded 
    489516password = '' 
    490517while 1: 
     
    493520    if password == None: 
    494521        sys.exit()    
    495     startup('encrypted data') 
     522    startup('data...') 
    496523    storage = oc2storage.CryptedStorage() 
    497524    storage.setPassword(password) 
    498     storage.setFilename('wallet.bin') 
     525    storage.setFilename(storagepath+'wallet.bin') 
    499526    try: 
    500527        storage.restore() 
    501528        break 
    502529    except: 
     530        appuifw.note(u'wrong password','error') 
    503531        pass 
    504532 
    505  
     533#Load the rest of the libs 
    506534startup('netlib') 
    507535import httplib, urllib 
     
    516544from oc2 import transports 
    517545startup('media') 
    518  
    519  
    520  
    521546coinsound = audio.Sound.open(mediapath+u'coinsound.wav') 
    522  
    523  
    524 #appuifw.app.screen='full' 
    525 startup('coins') 
    526547startup('done') 
     548 
     549#Ok, fire up the real wallet 
    527550w = WalletClient(storage) 
    528 import time 
     551 
     552#this makes the app running till a signal (by the exit key) is given 
    529553app_lock.wait() 
     554 
     555#Saving the data (encrypting it on the fly) 
    530556status('Shut down:saving data...',icons['save']) 
    531557storage.save() 
    532558status('Shut down:exit',icons['save']) 
     559 
     560#give a bit of time to read the last message 
     561import time 
    533562time.sleep(1)