def check_products(force=False): resp = sync.json_request_with_sid('/sale/products') if 'gold0plus' in resp: features.set_perm('gold.status', 'gold0plus') elif 'gold0' in resp: features.set_perm('gold.status', 'gold0') if 'session_warning' in resp: features.set('gold.session_warning', True) if force: ui.history = [] redisplay_menu()
def maybe_setup_launch_param(): param = features.get('app.launch_param') if param: param = binascii.a2b_base64(param) for k, v in json.loads(param).items(): features.set(k, v, require_safe=True)
def setup_game_version(): code = features.get('civsync.ua').split('/')[1] a, b, c, d = map(int, code) version = '%d.%d.%d' % (a, b, c * 10 + d) print 'Freeciv for Android', version features.set('app.version', version)
def apply_proto_change(proto): global PROTO PROTO = proto features.set_applier('civsync.host', apply_host_change, default=HOST) features.set_applier('civsync.proto', apply_proto_change, default=PROTO) def apply_user_agent_change(ua): global USER_AGENT USER_AGENT = ua # hack, hack, hack print 'changing user agent to', ua urllib.URLopener.version = ua features.set_applier('civsync.ua', apply_user_agent_change) features.set('civsync.ua', 'CivSyncAndroid/1108') features.add_feature('civsync.enable', False, type=bool) features.add_feature('civsync.sid', None) def get_sid(): sid = features.get('civsync.sid') if not sid: sid = ''.join( hex(ord(ch))[2:] for ch in os.urandom(8) ) features.set_perm('civsync.sid', sid) return sid def updates(install_time): request('/sync/updates', install_time=install_time) def get_install_time(): path = os.path.join(save.get_save_dir(), 'install_time')
def apply_host_change(host): print 'using civsync host', host civsync.HOST = host features.set_applier('civsync.host', apply_host_change, default=civsync.HOST) def apply_user_agent_change(ua): civsync.USER_AGENT = ua features.set_applier('civsync.ua', apply_user_agent_change) features.set('civsync.ua', 'CivSyncAndroid/1104') features.add_feature('civsync.enable', False, type=bool) session = None def show_load(): request(show_list, 'list') def show_list(entries): panel = ui.LinearLayoutWidget() panel.add(ui.Label('Saves from %s' % civsync.HOST)) for entry in entries: panel.add( ui.Button('%s - %dkB' % (entry.name, entry.size / 1024),
features.set_applier('civsync.host', apply_host_change, default=HOST) features.set_applier('civsync.proto', apply_proto_change, default=PROTO) def apply_user_agent_change(ua): global USER_AGENT USER_AGENT = ua # hack, hack, hack print 'changing user agent to', ua urllib.URLopener.version = ua features.set_applier('civsync.ua', apply_user_agent_change) version = 2615 if osutil.is_desktop: features.set('civsync.ua', 'CivSyncDesktop/%d' % version) else: features.set('civsync.ua', 'CivSyncAndroid/%d' % version) features.add_feature('civsync.enable', False, type=bool) features.add_feature('civsync.sid', None, safe=True) def get_sid(): sid = features.get('civsync.sid') if not sid: sid = ''.join( hex(ord(ch))[2:] for ch in os.urandom(8) ) features.set_perm('civsync.sid', sid) return sid def updates(install_time): request('/sync/updates', install_time=install_time)
def setup_game_version(): code = features.get('civsync.ua').split('/')[1] a, b, c, d = map(int, code) version = '%d.%d.%d' % (a, b, c*10 + d) print 'Freeciv for Android', version features.set('app.version', version)
features.set_applier('civsync.host', apply_host_change, default=HOST) features.set_applier('civsync.proto', apply_proto_change, default=PROTO) def apply_user_agent_change(ua): global USER_AGENT USER_AGENT = ua # hack, hack, hack print 'changing user agent to', ua urllib.URLopener.version = ua features.set_applier('civsync.ua', apply_user_agent_change) version = 1109 if osutil.is_desktop: features.set('civsync.ua', 'CivSyncDesktop/%d' % version) else: features.set('civsync.ua', 'CivSyncAndroid/%d' % version) features.add_feature('civsync.enable', False, type=bool) features.add_feature('civsync.sid', None, safe=True) def get_sid(): sid = features.get('civsync.sid') if not sid: sid = ''.join( hex(ord(ch))[2:] for ch in os.urandom(8) ) features.set_perm('civsync.sid', sid) return sid def updates(install_time): request('/sync/updates', install_time=install_time)
def setup_game_version(): code = features.get("civsync.ua").split("/")[1] a, b, c, d = map(int, code) version = "%d.%d.%d" % (a, b, c * 10 + d) print "Freeciv for Android", version features.set("app.version", version)
def apply_host_change(host): print "using civsync host", host civsync.HOST = host features.set_applier("civsync.host", apply_host_change, default=civsync.HOST) def apply_user_agent_change(ua): civsync.USER_AGENT = ua features.set_applier("civsync.ua", apply_user_agent_change) features.set("civsync.ua", "CivSyncAndroid/1003") features.add_feature("civsync.enable", False, type=bool) session = None def show_load(): request(show_list, "list") def show_list(entries): panel = ui.LinearLayoutWidget() panel.add(ui.Label("Saves from %s" % civsync.HOST)) for entry in entries: panel.add( ui.Button("%s - %dkB" % (entry.name, entry.size / 1024), functools.partial(download_sync, entry.sha1))