Exemplo n.º 1
0
 def onLogin(self, user, password, host, hdlr, isSocialToken2Login = False):
     self.__onLoggingTryingEndHdlr = hdlr
     self.__kickedFromServer = False
     self.__kickPeripheryID = None
     if self.__closeCallbackId:
         BigWorld.cancelCallback(self.__closeCallbackId)
         self.__closeCallbackId = None
     if not isSocialToken2Login:
         if not self.__validateCredentials(user.lower().strip(), password.strip()):
             self.__onLoggingTryingEndHdlr()
             return
     Waiting.show('login')
     self.__loginDataLoader.host = host
     self.__loginDataLoader.user = user
     self.__loginDataLoader.passLength = len(password)
     self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host)
     password = pwd_token.generate(password)
     if len(self.__loginDataLoader.token2):
         password = ''
     token2 = self.__loginDataLoader.token2
     if AUTO_LOGIN_QUERY_URL == host:
         g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd))
         return
     else:
         host = g_preDefinedHosts.byUrl(host)
         connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)
         return
Exemplo n.º 2
0
    def connect(
        self,
        url,
        login,
        password,
        publicKeyPath=None,
        nickName=None,
        token2="",
        isNeedSavingPwd=False,
        tokenLoginParams=None,
    ):
        self.disconnect()
        self.__isVersionsDiffered = False
        self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
        basicLoginParams = {"login": login, "auth_method": AUTH_METHODS.BASIC}
        loginParams = tokenLoginParams if tokenLoginParams is not None else basicLoginParams
        loginParams["session"] = md5hex(getHardwareID())
        loginParams["auth_realm"] = constants.AUTH_REALM
        loginParams["game"] = "wot"
        loginParams["temporary"] = str(int(not isNeedSavingPwd))
        if nickName is not None:
            loginParams["nickname"] = nickName
            loginParams["auto_registration"] = "true"
        if constants.IS_IGR_ENABLED:
            loginParams["is_igr"] = "1"
        if token2:
            loginParams["token2"] = token2
            loginParams["auth_method"] = AUTH_METHODS.TOKEN2
        LOG_NOTE("User authentication method: {0}".format(loginParams["auth_method"]))
        clientContext = {"lang_id": getClientLanguage()}

        class LoginInfo:
            pass

        loginInfo = LoginInfo()
        loginInfo.username = json.dumps(loginParams).encode("utf8")
        loginInfo.password = password
        loginInfo.clientContext = json.dumps(clientContext)
        loginInfo.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT
        if publicKeyPath is not None:
            loginInfo.publicKeyPath = publicKeyPath
        if login and constants.IS_DEVELOPMENT and login[0] == "@":
            try:
                loginInfo.username = login[1:]
            except IndexError:
                loginInfo.username = login

        BigWorld.connect(url, loginInfo, partial(self.connectionWatcher, nickName is not None))
        self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
        self.__loginName = login
        if g_preDefinedHosts.predefined(url) or g_preDefinedHosts.roaming(url):
            self.__host = g_preDefinedHosts.byUrl(url)
        else:
            for server in BigWorld.serverDiscovery.servers:
                if server.serverString == url:
                    self.__host = self.__host._replace(name=server.ownerName)
                    break

        return
Exemplo n.º 3
0
 def onLogin(self, user, password, host, hdlr):
     self.__onLoggingTryingEndHdlr = hdlr
     self.__kickedFromServer = False
     if self.__closeCallbackId:
         BigWorld.cancelCallback(self.__closeCallbackId)
         self.__closeCallbackId = None
     if g_steamAccount.isValid:
         user, password = g_steamAccount.getCredentials()
     else:
         user = user.lower().strip()
         if len(user) < _LOGIN_NAME_MIN_LENGTH:
             self.onSetStatus(
                 i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {"count": _LOGIN_NAME_MIN_LENGTH},
                 self.LOGIN_INVALID,
             )
             return
         if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT:
             self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID)
             return
         password = password.strip()
         if (
             not isPasswordValid(password)
             and not constants.IS_DEVELOPMENT
             and not len(self.__loginDataLoader.token2)
         ):
             self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID)
             return
     Waiting.show("login")
     self.__loginDataLoader.host = host
     self.__loginDataLoader.user = user
     self.__loginDataLoader.passLength = len(password)
     if constants.IS_VIETNAM:
         self.__pass = password
     self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host)
     password = pwd_token.generate(password)
     if len(self.__loginDataLoader.token2):
         password = ""
     if AUTO_LOGIN_QUERY_URL == host:
         g_preDefinedHosts.autoLoginQuery(
             lambda host: connectionManager.connect(
                 host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2
             )
         )
         return
     else:
         host = g_preDefinedHosts.byUrl(host)
         urls = host.urlIterator
         if urls is not None:
             if urls.end():
                 urls.cursor = 0
             host = urls.next()
             LOG_DEBUG("Gets next LoginApp url:", host)
         connectionManager.connect(
             host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2
         )
         return
Exemplo n.º 4
0
    def connect(self, url, login, password, publicKeyPath = None, nickName = None, token2 = '', isNeedSavingPwd = False):
        self.disconnect()
        LOG_DEBUG('url: %s; login: %s; pass: %s; name: %s; token: %s' % (url,
         login,
         password,
         nickName,
         token2))
        self.__isVersionsDiffered = False
        if len(login) > 0 and url is not None:
            self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
            authMethod = AUTH_METHODS.BASIC
            if constants.IS_VIETNAM:
                authMethod = AUTH_METHODS.EBANK
            dct = {'login': login,
             'auth_method': authMethod,
             'session': md5hex(getHardwareID())}
            if nickName is not None:
                dct['nickname'] = nickName
                dct['auto_registration'] = 'true'
            if constants.IS_IGR_ENABLED:
                dct['is_igr'] = '1'
            if token2:
                dct['token2'] = token2
                dct['auth_method'] = AUTH_METHODS.TOKEN2
            dct['auth_realm'] = constants.AUTH_REALM
            dct['game'] = 'wot'
            dct['temporary'] = str(int(not isNeedSavingPwd))

            class LoginInfo:
                pass

            loginInfo = LoginInfo()
            loginInfo.username = json.dumps(dct).encode('utf8')
            loginInfo.password = password
            loginInfo.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT
            if publicKeyPath is not None:
                loginInfo.publicKeyPath = publicKeyPath
            if constants.IS_DEVELOPMENT and login[0] == '@':
                try:
                    loginInfo.username = login[1:]
                except Exception:
                    loginInfo.username = login

            BigWorld.connect(url, loginInfo, partial(self.connectionWatcher, nickName is not None))
            self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
            self.__loginName = login
            if g_preDefinedHosts.predefined(url) or g_preDefinedHosts.roaming(url):
                self.__host = g_preDefinedHosts.byUrl(url)
            else:
                for server in BigWorld.serverDiscovery.servers:
                    if server.serverString == url:
                        self.__host = self.__host._replace(name=server.ownerName)
                        break
Exemplo n.º 5
0
 def onDoAutoLogin(self):
     lastLoginType = 'basic'
     if GUI_SETTINGS.socialNetworkLogin['enabled']:
         lastLoginType = self.__lastLoginType
     if lastLoginType != 'basic':
         self.__socialNetworkLogin.makeToken2LoginParams(self.__tokenLoginParams)
         if AUTO_LOGIN_QUERY_URL == self.__loginHost:
             g_preDefinedHosts.autoLoginQuery(self.__connectToHost)
         else:
             self.__connectToHost(g_preDefinedHosts.byUrl(self.__loginHost))
     else:
         LOG_DEBUG('onDoAutoLogin')
         self.as_doAutoLoginS()
Exemplo n.º 6
0
    def __connect(self):
        self.__retryConnectionCallbackID = None
        LOG_DEBUG('Calling BigWorld.connect with params: {0}, serverName: {1}, inactivityTimeout: {2}, publicKeyPath: {3}'.format(self.__connectionData.username, self.__connectionUrl, constants.CLIENT_INACTIVITY_TIMEOUT, self.__connectionData.publicKeyPath))
        nextTick(lambda : BigWorld.connect(self.__connectionUrl, self.__connectionData, self.__serverResponseHandler))()
        if g_preDefinedHosts.predefined(self.__connectionUrl) or g_preDefinedHosts.roaming(self.__connectionUrl):
            self.__hostItem = g_preDefinedHosts.byUrl(self.__connectionUrl)
        else:
            for server in BigWorld.serverDiscovery.servers:
                if server.serverString == self.__connectionUrl:
                    self.__hostItem = self.__hostItem._replace(name=server.ownerName)
                    break

        return
Exemplo n.º 7
0
    def connect(self, url, login, password, publicKeyPath = None, nickName = None, token2 = '', isNeedSavingPwd = False, tokenLoginParams = None):
        self.disconnect()
        self.__isVersionsDiffered = False
        self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
        basicLoginParams = {'login': login,
         'auth_method': AUTH_METHODS.BASIC}
        loginParams = tokenLoginParams if tokenLoginParams is not None else basicLoginParams
        loginParams['session'] = md5hex(getHardwareID())
        loginParams['auth_realm'] = constants.AUTH_REALM
        loginParams['game'] = 'wot'
        loginParams['temporary'] = str(int(not isNeedSavingPwd))
        if nickName is not None:
            loginParams['nickname'] = nickName
            loginParams['auto_registration'] = 'true'
        if constants.IS_IGR_ENABLED:
            loginParams['is_igr'] = '1'
        if token2:
            loginParams['token2'] = token2
            loginParams['auth_method'] = AUTH_METHODS.TOKEN2
        LOG_NOTE('User authentication method: {0}'.format(loginParams['auth_method']))

        class LoginInfo:
            pass

        loginInfo = LoginInfo()
        loginInfo.username = json.dumps(loginParams).encode('utf8')
        loginInfo.password = password
        loginInfo.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT
        if publicKeyPath is not None:
            loginInfo.publicKeyPath = publicKeyPath
        if login and constants.IS_DEVELOPMENT and login[0] == '@':
            try:
                loginInfo.username = login[1:]
            except IndexError:
                loginInfo.username = login

        BigWorld.connect(url, loginInfo, partial(self.connectionWatcher, nickName is not None))
        self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
        self.__loginName = login
        if g_preDefinedHosts.predefined(url) or g_preDefinedHosts.roaming(url):
            self.__host = g_preDefinedHosts.byUrl(url)
        else:
            for server in BigWorld.serverDiscovery.servers:
                if server.serverString == url:
                    self.__host = self.__host._replace(name=server.ownerName)
                    break

        return
Exemplo n.º 8
0
 def __onServerReceivedData(self, token, spaID, tokenDecrypter):
     if self.__processingLoginBySocial:
         return None
     self.__processingLoginBySocial = True
     self.__tokenLoginParams = self.__socialNetworkLogin.getLoginParams()
     self.__tokenLoginParams['token'] = tokenDecrypter(token)
     self.__tokenLoginParams['account_id'] = spaID
     connectionManager.onConnected += self.__onSocialLoginConnected
     connectionManager.onRejected += self.__onSocialLoginRejected
     connectionManager.onDisconnected += self.__onSocialLoginDisconnected
     Waiting.show('login')
     if AUTO_LOGIN_QUERY_URL == self.__loginHost:
         g_preDefinedHosts.autoLoginQuery(self.__connectToHost)
     else:
         self.__connectToHost(g_preDefinedHosts.byUrl(self.__loginHost))
     BigWorld.wg_bringWindowToForeground()
    def __connect(self):
        self.__retryConnectionCallbackID = None
        if constants.IS_DEVELOPMENT:
            LOG_DEBUG('Calling BigWorld.connect with params: {0}, serverName: {1}, inactivityTimeout: {2}, publicKeyPath: {3}'.format(self.__connectionData.username, self.__connectionUrl, constants.CLIENT_INACTIVITY_TIMEOUT, self.__connectionData.publicKeyPath))
        if self.__connectionInProgress:
            LOG_WARNING('Try to call BigWorld.connect while connection in progress')
            return
        else:
            nextTick(self.__tryConnect)()
            if g_preDefinedHosts.predefined(self.__connectionUrl) or g_preDefinedHosts.roaming(self.__connectionUrl):
                self.__hostItem = g_preDefinedHosts.byUrl(self.__connectionUrl)
            else:
                for server in BigWorld.serverDiscovery.servers:
                    if server.serverString == self.__connectionUrl:
                        self.__hostItem = self.__hostItem._replace(name=server.ownerName, shortName=server.ownerName)
                        break
                else:
                    self.__hostItem = self.__hostItem._replace(name=self.__connectionUrl, shortName=self.__connectionUrl)

            return
Exemplo n.º 10
0
 def onTryCreateAnAccount(self, nickname):
     if len(nickname) < _ACCOUNT_NAME_MIN_LENGTH_REG:
         self.onNicknameTooSmall()
         return
     if not isAccountNameValid(nickname):
         self.onAccountNameIsInvalid()
         return
     host = g_preDefinedHosts.byUrl(self.__loginDataLoader.host)
     password = pwd_token.generate(self.__pass)
     urls = host.urlIterator
     if urls is not None:
         if urls.end():
             urls.cursor = 0
         host = urls.next()
         LOG_DEBUG('Gets next LoginApp url:', host)
     LOG_DEBUG('Try create an account: url=%s; login=%s; password=%s; nickName=%s' % (host.url,
      self.__loginDataLoader.user,
      password,
      nickname))
     connectionManager.connect(host.url, self.__loginDataLoader.user, password, host.keyPath, nickName=nickname, token2='', isNeedSavingPwd=False)
Exemplo n.º 11
0
def makeContactStatusDescription(isOnline, tags, clientInfo=None):
    name, description = ('', '')
    if isOnline:
        if clientInfo:
            gameHost = clientInfo.gameHost
            arenaLabel = clientInfo.arenaLabel
        else:
            gameHost, arenaLabel = ('', '')
        if gameHost:
            item = g_preDefinedHosts.byUrl(gameHost)
            name = item.shortName or item.name
        if USER_TAG.PRESENCE_DND in tags:
            key = None
            if arenaLabel:
                key = TOOLTIPS.contact_status_inbattle(arenaLabel)
            if not key:
                key = TOOLTIPS.CONTACT_STATUS_INBATTLE_UNKNOWN
            description = i18n.makeString(key)
        else:
            description = i18n.makeString(TOOLTIPS.CONTACT_STATUS_ONLINE)
        if name:
            description = '{0}, {1}'.format(description, name)
    return description
Exemplo n.º 12
0
def makeContactStatusDescription(isOnline, tags, clientInfo = None):
    name, description = ('', '')
    if isOnline:
        if clientInfo:
            gameHost = clientInfo.gameHost
            arenaLabel = clientInfo.arenaLabel
        else:
            gameHost, arenaLabel = ('', '')
        if gameHost:
            item = g_preDefinedHosts.byUrl(gameHost)
            name = item.shortName or item.name
        if USER_TAG.PRESENCE_DND in tags:
            key = None
            if arenaLabel:
                key = TOOLTIPS.contact_status_inbattle(arenaLabel)
            if not key:
                key = TOOLTIPS.CONTACT_STATUS_INBATTLE_UNKNOWN
            description = i18n.makeString(key)
        else:
            description = i18n.makeString(TOOLTIPS.CONTACT_STATUS_ONLINE)
        if name:
            description = '{0}, {1}'.format(description, name)
    return description
Exemplo n.º 13
0
    def __connect(self):
        self.__retryConnectionCallbackID = None
        if constants.IS_DEVELOPMENT:
            LOG_DEBUG(
                'Calling BigWorld.connect with params: {0}, serverName: {1}, inactivityTimeout: {2}, publicKeyPath: {3}'
                .format(self.__connectionData.username, self.__connectionUrl,
                        constants.CLIENT_INACTIVITY_TIMEOUT,
                        self.__connectionData.publicKeyPath))
        nextTick(lambda: BigWorld.
                 connect(self.__connectionUrl, self.__connectionData, self.
                         __serverResponseHandler))()
        if g_preDefinedHosts.predefined(
                self.__connectionUrl) or g_preDefinedHosts.roaming(
                    self.__connectionUrl):
            self.__hostItem = g_preDefinedHosts.byUrl(self.__connectionUrl)
        else:
            for server in BigWorld.serverDiscovery.servers:
                if server.serverString == self.__connectionUrl:
                    self.__hostItem = self.__hostItem._replace(
                        name=server.ownerName)
                    break

        return
Exemplo n.º 14
0
 def onLogin(self, user, password, host, hdlr):
     self.__onLoggingTryingEndHdlr = hdlr
     self.__kickedFromServer = False
     self.__kickPeripheryID = None
     if self.__closeCallbackId:
         BigWorld.cancelCallback(self.__closeCallbackId)
         self.__closeCallbackId = None
     if g_steamAccount.isValid:
         user, password = g_steamAccount.getCredentials()
     else:
         user = user.lower().strip()
         if len(user) < _LOGIN_NAME_MIN_LENGTH:
             self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {'count': _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID)
             return
         if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT:
             self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID)
             return
         password = password.strip()
         if not isPasswordValid(password) and not constants.IS_DEVELOPMENT and not len(self.__loginDataLoader.token2):
             self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID)
             return
     Waiting.show('login')
     self.__loginDataLoader.host = host
     self.__loginDataLoader.user = user
     self.__loginDataLoader.passLength = len(password)
     if constants.IS_VIETNAM:
         self.__pass = password
     self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host)
     password = pwd_token.generate(password)
     if len(self.__loginDataLoader.token2):
         password = ''
     token2 = self.__loginDataLoader.token2
     if AUTO_LOGIN_QUERY_URL == host:
         g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd))
         return
     host = g_preDefinedHosts.byUrl(host)
     connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)
 def initiateConnection(self, params, password, serverName):
     self.__setConnectionData(params, password)
     if serverName == AUTO_LOGIN_QUERY_URL:
         g_preDefinedHosts.autoLoginQuery(self.__setHostDataAndConnect)
     else:
         self.__setHostDataAndConnect(g_preDefinedHosts.byUrl(serverName))
Exemplo n.º 16
0
 def initiateConnection(self, params, password, serverName):
     self.__setConnectionData(params, password)
     if serverName == AUTO_LOGIN_QUERY_URL:
         g_preDefinedHosts.autoLoginQuery(self.__setHostDataAndConnect)
     else:
         self.__setHostDataAndConnect(g_preDefinedHosts.byUrl(serverName))
Exemplo n.º 17
0
 def onLogin(self, user, password, host, hdlr):
     self.__onLoggingTryingEndHdlr = hdlr
     self.__kickedFromServer = False
     if self.__closeCallbackId:
         BigWorld.cancelCallback(self.__closeCallbackId)
         self.__closeCallbackId = None
     if g_steamAccount.isValid:
         user, password = g_steamAccount.getCredentials()
     else:
         user = user.lower().strip()
         if len(user) < _LOGIN_NAME_MIN_LENGTH:
             self.onSetStatus(
                 i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) %
                 {'count': _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID)
             return
         if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT:
             self.onSetStatus(
                 i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN),
                 self.LOGIN_INVALID)
             return
         password = password.strip()
         if not isPasswordValid(
                 password) and not constants.IS_DEVELOPMENT and not len(
                     self.__loginDataLoader.token2):
             self.onSetStatus(
                 i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD),
                 self.LOGIN_PWD_INVALID)
             return
     Waiting.show('login')
     self.__loginDataLoader.host = host
     self.__loginDataLoader.user = user
     self.__loginDataLoader.passLength = len(password)
     if constants.IS_VIETNAM:
         self.__pass = password
     self.__loginDataLoader.saveUserConfig(user,
                                           self.__loginDataLoader.host)
     password = pwd_token.generate(password)
     if len(self.__loginDataLoader.token2):
         password = ''
     if AUTO_LOGIN_QUERY_URL == host:
         g_preDefinedHosts.autoLoginQuery(
             lambda host: connectionManager.connect(
                 host.url,
                 user,
                 password,
                 host.keyPath,
                 nickName=None,
                 token2=self.__loginDataLoader.token2))
         return
     else:
         host = g_preDefinedHosts.byUrl(host)
         urls = host.urlIterator
         if urls is not None:
             if urls.end():
                 urls.cursor = 0
             host = urls.next()
             LOG_DEBUG('Gets next LoginApp url:', host)
         connectionManager.connect(host.url,
                                   user,
                                   password,
                                   host.keyPath,
                                   nickName=None,
                                   token2=self.__loginDataLoader.token2)
         return
Exemplo n.º 18
0
    def connect(self,
                url,
                login,
                password,
                publicKeyPath=None,
                areaID=None,
                nickName=None,
                token2='',
                rememberPassword=False,
                authMethod=None,
                token1='',
                spaID=None):
        self.disconnect()
        LOG_DEBUG(
            'url: %s; login: %s; pass: %s; name: %s; areaID: %s; authMethod: %s; token1: %s; token2: %s; spaID: %s'
            % (url, login, password, nickName, areaID, authMethod, token1,
               token2, spaID))
        if url is not None:

            class LoginInfo:
                pass

            loginInfo = LoginInfo()
            dct = {
                'login': '',
                'auth_method': '',
                'session': md5hex(getHardwareID())
            }
            loginInfo.inactivityTimeout = CLIENT_INACTIVITY_TIMEOUT
            if publicKeyPath is not None:
                loginInfo.publicKeyPath = publicKeyPath
            if authMethod == AUTH_METHODS.TOKEN1:
                dct['temporary'] = '0'
                dct['account_id'] = spaID
                dct['ip'] = '127.0.0.1'
                dct['game'] = 'wowp'
                dct['requested_for'] = 'wowp'
                dct['token'] = token1
                dct['auth_method'] = AUTH_METHODS.TOKEN1
                loginInfo.username = json.dumps(dct).encode('utf8')
                loginInfo.password = ''
            elif len(login) > 0 or token2:
                self.__setConnectionStatus(
                    CONNECTION_STATUS.connectionInProgress)
                if nickName is not None:
                    dct['nickname'] = nickName
                    dct['auto_registration'] = 'true'
                if token2:
                    dct['login'] = ''
                    dct['token2'] = token2
                    dct['auth_method'] = AUTH_METHODS.TOKEN2
                else:
                    dct['login'] = login
                    dct['auth_method'] = AUTH_METHODS.EBANK if config_consts.IS_VIETNAM else AUTH_METHODS.BASIC
                if config_consts.IS_IGR_ENABLED:
                    dct['is_igr'] = '1'
                dct['game'] = 'wowp'
                dct['temporary'] = str(int(not rememberPassword))
                loginInfo.username = json.dumps(dct).encode('utf8')
                if not token2:
                    loginInfo.password = password
                if len(login) > 0 and IS_DEVELOPMENT and login[0] == '@':
                    try:
                        loginInfo.username = login[1:]
                    except Exception:
                        loginInfo.username = login

            else:
                return
            BigWorld.connect(
                url, loginInfo,
                partial(self.connectionWatcher, nickName is not None))
            self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
            self.__loginName = login
            self.__areaID = areaID
            if g_preDefinedHosts.predefined(url):
                host = g_preDefinedHosts.byUrl(url)
                self.__host = host
            else:
                for server in BigWorld.serverDiscovery.servers:
                    if server.serverString == url:
                        self.__host = self.__host._replace(
                            name=server.ownerName)
                        break

        return
Exemplo n.º 19
0
    def connect(self,
                url,
                login,
                password,
                publicKeyPath=None,
                nickName=None,
                token2=''):
        self.disconnect()
        LOG_DEBUG('url: %s; login: %s; pass: %s; name: %s; token: %s' %
                  (url, login, password, nickName, token2))
        if len(login) > 0 and url is not None:
            self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
            authMethod = AUTH_METHODS.BASIC
            if constants.IS_VIETNAM:
                authMethod = AUTH_METHODS.EBANK
            dct = {
                'login': login,
                'auth_method': authMethod,
                'session': md5hex(getHardwareID())
            }
            if nickName is not None:
                dct['nickname'] = nickName
                dct['auto_registration'] = 'true'
            if constants.IS_KOREA:
                dct['is_igr'] = '1'
            if token2:
                dct['token2'] = token2
                dct['auth_method'] = AUTH_METHODS.TOKEN2
            dct['auth_realm'] = constants.AUTH_REALM
            dct['game'] = 'wot'

            class LoginInfo:
                pass

            loginInfo = LoginInfo()
            loginInfo.username = json.dumps(dct).encode('utf8')
            loginInfo.password = password
            loginInfo.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT
            if publicKeyPath is not None:
                loginInfo.publicKeyPath = publicKeyPath
            if constants.IS_DEVELOPMENT and login[0] == '@':
                try:
                    loginInfo.username = login[1:]
                except Exception:
                    loginInfo.username = login

            BigWorld.connect(
                url, loginInfo,
                partial(self.connectionWatcher, nickName is not None))
            self.__setConnectionStatus(CONNECTION_STATUS.connectionInProgress)
            self.__loginName = login
            if g_preDefinedHosts.predefined(url) or g_preDefinedHosts.roaming(
                    url):
                self.__host = g_preDefinedHosts.byUrl(url)
            else:
                for server in BigWorld.serverDiscovery.servers:
                    if server.serverString == url:
                        self.__host = self.__host._replace(
                            name=server.ownerName)
                        break

        return
Exemplo n.º 20
0
def getServerShortName(serverUrl):
    return g_preDefinedHosts.byUrl(serverUrl).shortName or i18n.makeString('#menu:login/auto')