×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Option to "Enter Registration Code" in python?!

    I started writing some code you can use to register the app.
    If its not registred it wont start.

    If you start app it is asking for a code. If you enter it correctly it will save a reg.txt with the code in it. next time the app should start without requesting the code. create a emty reg.txt in e:\python before starting app first time.

    the register code is created out of the imei of the phone.

    Code:
    import appuifw, sysinfo, e32, appswitch
    
    def save_dict(filename, dict):
    	f = file(filename, "w")
    	for key, value in dict.items():
    		print >> f, "%s: %s" % (key, value)
    	f.close()
    
    def load_dict(filename):
    	f = file(filename, "r")
    	dict = {}
    	for line in f:
    		key, value = line.split(":")
    		dict[key.strip()] = value.strip()
    	f.close()
    	return dict
    
    reg = {"1": ""}
    
    reg_2 = {"1": ""}
    reg_2["1"] = sysinfo.imei() / 12
    
    
    def checkregister():
    	
    	register=float(appuifw.query(u"Registration Code:", "text"))
    	
    	if register == reg_2["1"]:
    
    		reg["1"] = reg_2["1"]
    		save_dict(u"e:\\python\\reg.txt", reg)
    		e32.ao_sleep(3) 
    		appuifw.note(u"App. Registred")
    		
    
    	else:
    		appuifw.note(u"code wrong")
    		appswitch.kill_app(u"Python")
    
    
    while True:
    	load_dict(u"e:\\python\\reg.txt")
    	if reg["1"] == reg_2["1"]:
    		break
    
    	else:
    		checkregister()
    
    
    
    appuifw.note(u"continue programm")
    i have two problems with the code:

    Code:
    reg_2["1"] = sysinfo.imei() / 12
    how is the correct code to get value imei/12 in the dictionary?
    i tried several combinations, but i dont get it?

    second is, that:

    Code:
    if register == reg_2["1"]:
    is not working. i always get "Code wrong".

    when i set:
    Code:
    reg_2["1"] = 1234
    i get "app registred", but next time i start app it requests the code again?!

    Could anyone please get this code to work properly??
    Whats wrong here?
    Last edited by kwik; 2008-11-06 at 11:58.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    Turkey
    Posts
    11

    Re: Working on Registration Module!! (Enter Registration Code)

    hi,
    imei not integer
    sysinfo.imei()/12 wrong code
    Code:
    >>> int(sysinfo.imei())/12
    Traceback (most recent call last):
      File "<console>", line 1, in ?
    ValueError: int() literal too large: 35666500xxxxxxx
    my register program code

    Code:
    #copyright (c) python-s60.com
    import appuifw
    from appuifw import *
    import e32
    import os
    import sysinfo
    
    pathtoapp=os.path.dirname(appuifw.app.full_name())
    
    registered=0
    
    timer = e32.Ao_timer()
    app_lock = e32.Ao_lock()
    
    a=sysinfo.imei()
    randseed = a[2]+a[0]+a[0]+a[8]
    
    
    def write_settings():
        global registered   
    
        CONFIG_DIR='c:\\system\\data\\wapstore'
        CONFIG_FILE=os.path.join(CONFIG_DIR,'reg.set')
        if not os.path.isdir(CONFIG_DIR):
            os.makedirs(CONFIG_DIR)
            CONFIG_FILE=os.path.join(CONFIG_DIR,'reg.set')      
        config={}
        config['registered']= registered
        f=open(CONFIG_FILE,'wt')
        f.write(repr(config))
        f.close()
    
    def read_settings():
        global registered   
        CONFIG_FILE='c:\\system\\data\\wapstore\\reg.set'
        try:
            f=open(CONFIG_FILE,'rt')
            try:
                content = f.read()
                config=eval(content)
                f.close()
                registered=config.get('registered','')
            except:
                appuifw.note(u"Cannot read settings file", "error")
        except:
            appuifw.note(u"Creating settings file", "info")
    def exit_key_handler():
        write_settings()
        appuifw.app.set_exit()
        
        
    def quit():
        write_settings()
        appuifw.app.set_exit()
    
    L = [u"About", u"Register", u"exit"]
    
    L1 = [u"About", u"exit"]
    
    def menu():
        global registered
        if registered == 0:
            index = appuifw.popup_menu(L)
            if index == 0:
                about()
            elif index == 1:
                register()
            elif index == 2:
                quit()
            else:
                pass
        elif registered == 1:
            index = appuifw.popup_menu(L1)
            if index == 0:
                about()
            elif index == 1:
                quit()
            else:
                pass
        else:
            pass
            
    def about():
        appuifw.note(u"register example", "info")
        menu()
    
    def donate():
        global registered
        if registered == 0:
            appuifw.note(u"not registered program", "info")
        
    def register():
        global registered
        if registered == 0:
            appuifw.note(u"buy program", "info")
            regtry = appuifw.query(u"Registration code", "text")
            if regtry == randseed:
                registered = 1 # success
                appuifw.note(u"thank you for buying!","info")
            else:
                appuifw.note(u"wrong code","error")
        else:
            appuifw.note(u"already registered!","info")
    
        menu()
        
    
    
    appuifw.app.title = u"register"
    
    appuifw.app.exit_key_handler = exit_key_handler
    appuifw.app.screen='normal'
    
    read_settings()
    donate()
    menu()
    www.python-s60.com
    Turkish python

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    37

    Re: Working on Registration Module!! (Enter Registration Code)

    Nice!

    tried your code, its exactly what i need, but
    Code:
    randseed = a[2]+a[0]+a[0]+a[8]
    how to calculate randseed?

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    Turkey
    Posts
    11

    Re: Working on Registration Module!! (Enter Registration Code)

    Thank you

    my keygen
    Code:
    import appuifw,sysinfo
    a=sysinfo.imei()
    d=a[2]+a[0]+a[0]+a[8]
    appuifw.note(u"your code \n"+d,"info")
    www.python-s60.com
    Turkish python

Similar Threads

  1. ImportError : No module named
    By mobil.prog in forum Symbian
    Replies: 3
    Last Post: 2008-11-06, 03:44
  2. Replies: 4
    Last Post: 2008-10-10, 22:56
  3. Email logs not working in logs module?
    By GonzalezM in forum Symbian
    Replies: 4
    Last Post: 2008-08-21, 19:28
  4. Replies: 2
    Last Post: 2006-03-11, 09:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×