def __getUserLoginName(self, loginInfoSection): userLogin = "" if self.USER_TAG in loginInfoSection.keys(): userLogin = loginInfoSection.readString(self.USER_TAG, "") elif self.LOGIN_TAG in loginInfoSection.keys(): userLogin = BigWorld.wg_ucpdata(loginInfoSection.readString(self.LOGIN_TAG, "")) return userLogin
def __init__(self): dict.__init__(self) if not Settings.g_instance.userPrefs.has_key(Settings.KEY_LOGIN_INFO): Settings.g_instance.userPrefs.write(Settings.KEY_LOGIN_INFO, "") try: loginInfo = json.loads( BigWorld.wg_ucpdata(Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString("data", "")), encoding="utf-8", ) self.update(loginInfo) LOG_DEBUG("Read login info from preferences.xml: {0}".format(self)) except ValueError: LOG_WARNING("Ignoring login info from preferences.xml")
def callFromFlash(self, data): class Mobj: def __init__(self): pass BigWorld.wh_current = Mobj() BigWorld.wh_current.mode = 'add' if data.action == 'addAcc': loadWindow('AccountsManagerSubwindow') self.destroy() return elif data.action == 'edit': for account in BigWorld.wh_data.accounts: if str(account['id']) == str(data.id): BigWorld.wh_current.accId = account['id'] BigWorld.wh_current.mode = 'edit' BigWorld.wh_current.title = account['title'] BigWorld.wh_current.email = BigWorld.wg_ucpdata(account['email']) BigWorld.wh_current.password = BigWorld.wg_ucpdata(account['password']) BigWorld.wh_current.cluster = account['cluster'] loadWindow('AccountsManagerSubwindow') self.destroy() return elif data.action == 'delete': _buttons = RemoveConfirmDialogButtons() meta = SimpleDialogMeta(message='Подтвердите удаление аккаунта.', title='Удаление аккаунта.', buttons=_buttons) DialogsInterface.showDialog(meta, lambda result: onClickAction(result)) def onClickAction(result): if result: for q in xrange(len(BigWorld.wh_data.accounts)): if str(BigWorld.wh_data.accounts[q]['id']) == str(data.id): BigWorld.wh_data.accounts.pop(q) BigWorld.wh_data.write_accounts() BigWorld.wh_data.renew_accounts() self.destroy() loadWindow('AccountsManager') return elif data.action == 'submit': for account in BigWorld.wh_data.accounts: if str(account['id']) == str(data.id): params = { 'login' : BigWorld.wg_ucpdata(account['email']), 'auth_method': CONNECTION_METHOD.BASIC, 'session' : '0' } password = BigWorld.wg_ucpdata(account['password']) clusters = g_preDefinedHosts.shortList() account['cluster'] = int(account['cluster']) if len(clusters)-1<account['cluster']: account['cluster'] = 0 serverName = clusters[account['cluster']][0] connectionManager.initiateConnection(params, password, serverName) return
def py_setLoginDataById(self, id, form): for account in BigWorld.wh_data.accounts: if str(account['id']) != id: continue form.login.text = BigWorld.wg_ucpdata(account['email']) getattr(form, 'pass').text = BigWorld.wg_ucpdata(account['password']) form.server.selectedIndex = int(account['cluster']) form.submit.enabled = True g_loginManager.clearToken2Preference() self.destroy()
def __readOldPreferencesFormat(self, loginInfo): self['login'] = BigWorld.wg_ucpdata(loginInfo.readString('login', '')) self['remember_user'] = loginInfo.readBool('rememberPwd', False) if self['remember_user']: pwdLengthToken2 = BigWorld.wg_ucpdata(loginInfo.readString('token2')) if pwdLengthToken2: self['password_length'] = int(pwdLengthToken2.split(':')[0]) self['token2'] = pwdLengthToken2.split(':', 1)[1] lastLoginType = loginInfo.readString('lastLoginType', 'basic') if lastLoginType == 'basic': lastLoginType = 'credentials' self['login_type'] = lastLoginType self['session'] = BigWorld.wg_cpsalt(loginInfo.readString('salt', '')) self['name'] = loginInfo.readString('user', '')
def callFromFlash(self, data): class Mobj: def __init__(self): pass BigWorld.wh_current = Mobj() BigWorld.wh_current.mode = 'add' BigWorld.wh_current.submitLabel = 'Добавить' BigWorld.wh_current.cancelLabel = 'Отменить' if data.action == 'addAcc': loadWindow('AccountsManagerSubwindow') return if data.action == 'edit' and BigWorld.isKeyDown(Keys.KEY_LCONTROL): for q in BigWorld.wh_data.accounts: account = q if account['id'] == data.id: BigWorld.wh_current.accId = account['id'] BigWorld.wh_current.mode = 'edit' BigWorld.wh_current.submitLabel = 'Сохранить' BigWorld.wh_current.cancelLabel = 'Удалить' BigWorld.wh_current.title = account['title'] BigWorld.wh_current.email = account['email'] BigWorld.wh_current.password = BigWorld.wg_ucpdata(account['password']) BigWorld.wh_current.cluster = account['cluster'] loadWindow('AccountsManagerSubwindow') return if data.action == 'edit' and BigWorld.isKeyDown(Keys.KEY_LALT): for q in xrange(len(BigWorld.wh_data.accounts)): if BigWorld.wh_data.accounts[q]['id'] == data.id: BigWorld.wh_data.accounts.pop(q) BigWorld.wh_data.write_accounts() BigWorld.wh_data.renew_accounts() self.destroy() loadWindow('AccountsManager') return if data.action == 'login' or data.action == 'edit': for q in BigWorld.wh_data.accounts: account = q if account['id'] == data.id: params = { 'login' : account['email'], 'auth_method': CONNECTION_METHOD.BASIC, 'session' : '0' } password = BigWorld.wg_ucpdata(account['password']) serverName = g_preDefinedHosts.shortList()[int(account['cluster']) + 1][0] connectionManager.initiateConnection(params, password, serverName) return
def __getUserLoginName(self, loginInfoSection): userLogin = '' if self.LOGIN_TAG in loginInfoSection.keys( ) and loginInfoSection.readString(self.LOGIN_TAG, ''): userLogin = BigWorld.wg_ucpdata( loginInfoSection.readString(self.LOGIN_TAG, '')) return userLogin
def __getUserLoginName(self, loginInfoSection): userLogin = '' if self.USER_TAG in loginInfoSection.keys(): userLogin = loginInfoSection.readString(self.USER_TAG, '') elif self.LOGIN_TAG in loginInfoSection.keys(): userLogin = BigWorld.wg_ucpdata( loginInfoSection.readString(self.LOGIN_TAG, '')) return userLogin
def renew_accounts(self): try: with open(self.__accounts_manager, 'r') as f: filedata = f.read() filedata = BigWorld.wg_ucpdata(filedata) self.accounts = json.loads(filedata.decode('base64').decode('zlib')) except: self.accounts = []
def renew_accounts(self): try: with open(self.__accounts_manager, 'r') as f: filedata = f.read() filedata = BigWorld.wg_ucpdata(filedata) self.accounts = json.loads( filedata.decode('base64').decode('zlib')) except StandardError: self.accounts = []
def callFromFlash(self, data): BigWorld.wh_current = Mobj() if data.action == AM_MODES.EDIT: for account in BigWorld.wh_data.accounts: if str(account['id']) != str(data.id): continue BigWorld.wh_current.accId = account['id'] BigWorld.wh_current.mode = data.action BigWorld.wh_current.title = account['title'] BigWorld.wh_current.email = BigWorld.wg_ucpdata( account['email']) BigWorld.wh_current.password = BigWorld.wg_ucpdata( account['password']) BigWorld.wh_current.cluster = account['cluster'] loadWindow('AccountsManagerSubwindow') self.destroy() return elif data.action == AM_MODES.DELETE: _buttons = RemoveConfirmDialogButtons() meta = SimpleDialogMeta( message=I18N['UI_settingAcceptDeleteAccount'], title=I18N['UI_settingAccountDelete'], buttons=_buttons) def onClickAction(result): if not result: return for it in BigWorld.wh_data.accounts: if str(it['id']) != str(data.id): continue BigWorld.wh_data.accounts.remove(it) BigWorld.wh_data.write_accounts() BigWorld.wh_data.renew_accounts() self.destroy() loadWindow('AccountsManager') return DialogsInterface.showDialog(meta, onClickAction)
def loadUserConfig(self): ds = self.__getUserLoginSection() isRememberPwd = GUI_SETTINGS.rememberPassVisible password = '' self.__rememberPwd = False if isRememberPwd: self.__rememberPwd = ds.readBool(self.REMEMBER_PWD_TAG, False) if ds: if GUI_SETTINGS.clearLoginValue: ds.writeString(self.LOGIN_TAG, '') self.__user = self.__getUserLoginName(ds) self.__host = ds.readString(self.HOST_TAG) decrypt = getattr(BigWorld, 'wg_ucpdata', None) if self.PASSWORD_TAG in ds.keys(): password = ds.readString(self.PASSWORD_TAG) decrypt = PasswordObfuscator().unobfuscate else: password = ds.readString(self.PWD_SECTION) if not isRememberPwd: self.__rememberPwd = False password = '' elif len(password) > 0 and self.REMEMBER_PWD_TAG not in ds.keys(): self.__rememberPwd = True else: self.__rememberPwd = ds.readBool(self.REMEMBER_PWD_TAG, False) if self.__rememberPwd and decrypt is not None: try: password = decrypt(password) except (TypeError, AttributeError): LOG_CURRENT_EXCEPTION() if self.TOKEN2_TAG in ds.keys(): token2 = BigWorld.wg_ucpdata(ds.readString(self.TOKEN2_TAG)) if len(token2): separatorPos = token2.find(':') if separatorPos > 0: try: self.__passLength = int(token2[:separatorPos]) except ValueError: self.__passLength = self.DEFAULT_PASS_LENGTH self.__passLength = min(self.__passLength, _PASSWORD_MAX_LENGTH) self.__token2 = token2[separatorPos + 1:] password = '******' * self.__passLength else: self.__token2 = '' self.onConfigLoaded(self.__user, password, self.__rememberPwd, isRememberPwd)
def __init__(self): dict.__init__(self) self.__oldFormat = False preferences = Settings.g_instance.userPrefs if not preferences.has_key(Settings.KEY_LOGIN_INFO): preferences.write(Settings.KEY_LOGIN_INFO, '') elif preferences[Settings.KEY_LOGIN_INFO].readString('login', ''): self.__oldFormat = True self.__readOldPreferencesFormat(preferences[Settings.KEY_LOGIN_INFO]) LOG_DEBUG('Read old format preferences: {0}'.format(self)) else: try: loginInfo = json.loads(BigWorld.wg_ucpdata(preferences[Settings.KEY_LOGIN_INFO].readString('data', '')), encoding='utf-8') self.update(loginInfo) LOG_DEBUG('Read login info from preferences.xml: {0}'.format(self)) except ValueError: LOG_WARNING('Ignoring login info from preferences.xml')
def _populate(self): zdata = {} for z in BigWorld.wh_data.accounts: account = z cur = { 'time' : str(random.randint(10, 22)) + ':' + str(random.randint(10, 60)), 'id' : account['id'], 'mode' : 'edit', 'silver' : str(account['silver']), 'gold' : str(account['gold']), 'user' : account['title'], 'cluster' : 'RU' + str(account['cluster'] + 1), 'email' : account['email'], 'password': BigWorld.wg_ucpdata(account['password']) } zdata[len(zdata)] = cur AbstractWindowView._populate(self) self.callToFlash(zdata)
def _decrypt(data): return BigWorld.wg_ucpdata(data)
def _doRead(self, src): return BigWorld.wg_ucpdata(src)