Пример #1
0
    def handleLogOnSuccess(self, status, message):
        try:
            LOG_DEBUG('handleLogOnSuccess')
            if not len(message):
                return
            msg_dict = json.loads(message)
            if not isinstance(msg_dict, dict):
                raise Exception, ''
            else:
                self.__securityMsgType = msg_dict.get('security_msg')
                self.showSecurityMessage()
        except Exception:
            self.handleLoginCustomDefinedError(status, message)
            LOG_CURRENT_EXCEPTION()
            return

        token2 = str(msg_dict.get('token2', ''))
        user = str(msg_dict.get('name', 'UNKNOWN'))
        Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].writeString('user', user)
        Settings.g_instance.save()
        g_lobbyContext.setCredentials(user, token2)
        socialNetworkLogin.setCredentials(user, token2)
        self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength, token2)
        peripheryID, _ = g_preDefinedHosts.readPeripheryTL()
        if peripheryID != connectionManager.peripheryID:
            g_preDefinedHosts.clearPeripheryTL()
Пример #2
0
    def handleLogOnSuccess(self, status, message):
        try:
            LOG_DEBUG('handleLogOnSuccess')
            if not len(message):
                return
            msg_dict = json.loads(message)
            if not isinstance(msg_dict, dict):
                raise Exception, ''
            else:
                self.__securityMsgType = msg_dict.get('security_msg')
                self.showSecurityMessage()
        except Exception:
            self.handleLoginCustomDefinedError(status, message)
            LOG_CURRENT_EXCEPTION()
            return

        token2 = str(msg_dict.get('token2', ''))
        user = str(msg_dict.get('name', 'UNKNOWN'))
        Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].writeString(
            'user', user)
        Settings.g_instance.save()
        g_lobbyContext.setCredentials(user, token2)
        socialNetworkLogin.setCredentials(user, token2)
        self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength,
                                             token2)
        peripheryID, _ = g_preDefinedHosts.readPeripheryTL()
        if peripheryID != connectionManager.peripheryID:
            g_preDefinedHosts.clearPeripheryTL()
Пример #3
0
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = "LOGGED_ON"
        LOG_DEBUG("__handleConnectionStatus %s %s %s" % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == "DNS_LOOKUP_FAILED":
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != "LOGIN_REJECTED_LOGIN_QUEUE":
                    self.__clearAutoLoginTimer()
                if status != "LOGIN_REJECTED_RATE_LIMITED":
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                if status not in ("LOGIN_REJECTED_INVALID_PASSWORD",):
                    g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR("Handle logon status error: status = %r, message = %r" % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide("login")

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
                if connectionManager.isConnected():
                    connectionManager.disconnect()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__kickPeripheryID is not None:
                if self.__kickPeripheryID == -1:
                    msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                elif self.__kickPeripheryID == -2:
                    msg = "#menu:login/status/centerRestart"
                elif self.__kickPeripheryID == -3:
                    msg = "#menu:login/status/versionMismatch"
            elif connectionManager.isVersionsDiffered:
                msg = ""
                self.onHandleUpdateClientSoftwareNeeded()
            localizedMessage = i18n.convert(i18n.makeString(msg))
            lastLoginType = Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString("lastLoginType", "basic")
            if lastLoginType != "basic" and not Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readBool(
                "rememberPwd", False
            ):
                from gui.social_network_login import Bridge as socialNetworkLogin

                localizedMessage = socialNetworkLogin.getLogoutWarning(lastLoginType)
            self.onSetStatus(localizedMessage, self.ALL_VALID)
            connectionManager.disconnect()
        return
Пример #4
0
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = 'LOGGED_ON'
        LOG_DEBUG('__handleConnectionStatus %s %s %s' % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == 'DNS_LOOKUP_FAILED':
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != 'LOGIN_REJECTED_LOGIN_QUEUE':
                    self.__clearAutoLoginTimer()
                if status != 'LOGIN_REJECTED_RATE_LIMITED':
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                if status not in ('LOGIN_REJECTED_INVALID_PASSWORD',):
                    g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR('Handle logon status error: status = %r, message = %r' % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide('login')

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__kickPeripheryID is not None:
                if self.__kickPeripheryID == -1:
                    msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                elif self.__kickPeripheryID == -2:
                    msg = '#menu:login/status/centerRestart'
                elif self.__kickPeripheryID == -3:
                    msg = '#menu:login/status/versionMismatch'
            elif connectionManager.isVersionsDiffered:
                msg = ''
                self.onHandleUpdateClientSoftwareNeeded()
            self.onSetStatus(i18n.convert(i18n.makeString(msg)), self.ALL_VALID)
            connectionManager.disconnect()
Пример #5
0
    def __handleConnectionStatus(self, stage, status, serverMsg,
                                 isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = 'LOGGED_ON'
        LOG_DEBUG('__handleConnectionStatus %s %s %s' %
                  (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status == 'DNS_LOOKUP_FAILED':
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status != 'LOGIN_REJECTED_LOGIN_QUEUE':
                    self.__clearAutoLoginTimer()
                if status != 'LOGIN_REJECTED_RATE_LIMITED':
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR(
                    'Handle logon status error: status = %r, message = %r' %
                    (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide('login')

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__accNotReady:
                msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                self.__accNotReady = False
            self.onSetStatus(i18n.convert(i18n.makeString(msg)),
                             self.ALL_VALID)
            connectionManager.disconnect()
Пример #6
0
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = "LOGGED_ON"
        LOG_DEBUG("__handleConnectionStatus %s %s %s" % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == "DNS_LOOKUP_FAILED":
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != "LOGIN_REJECTED_LOGIN_QUEUE":
                    self.__clearAutoLoginTimer()
                if status != "LOGIN_REJECTED_RATE_LIMITED":
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR("Handle logon status error: status = %r, message = %r" % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide("login")

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__accNotReady:
                msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                self.__accNotReady = False
            self.onSetStatus(i18n.convert(i18n.makeString(msg)), self.ALL_VALID)
            connectionManager.disconnect()
Пример #7
0
    def handleLogOnSuccess(self, status, message):
        try:
            LOG_DEBUG('handleLogOnSuccess', message)
            if not len(message):
                return
            msg_dict = json.loads(message)
            if not isinstance(msg_dict, dict):
                raise Exception, ''
            else:
                self.__securityMsgType = msg_dict.get('security_msg')
                self.showSecurityMessage()
        except Exception:
            self.handleLoginCustomDefinedError(status, message)
            LOG_CURRENT_EXCEPTION()
            return

        token2 = str(msg_dict.get('token2', ''))
        g_lobbyContext.setCredentials(self.__loginDataLoader.user, token2)
        self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength, token2)
        peripheryID, _ = g_preDefinedHosts.readPeripheryTL()
        if peripheryID != connectionManager.peripheryID:
            g_preDefinedHosts.clearPeripheryTL()
Пример #8
0
    def __handleConnectionStatus(self, stage, status, serverMsg,
                                 isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = 'LOGGED_ON'
        LOG_DEBUG('__handleConnectionStatus %s %s %s' %
                  (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status == 'DNS_LOOKUP_FAILED':
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status != 'LOGIN_REJECTED_LOGIN_QUEUE':
                    self.__clearAutoLoginTimer()
                if status != 'LOGIN_REJECTED_RATE_LIMITED':
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                if status not in ('LOGIN_REJECTED_INVALID_PASSWORD', ):
                    g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR(
                    'Handle logon status error: status = %r, message = %r' %
                    (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide('login')

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
                if connectionManager.isConnected():
                    connectionManager.disconnect()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__kickPeripheryID is not None:
                if self.__kickPeripheryID == -1:
                    msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                elif self.__kickPeripheryID == -2:
                    msg = '#menu:login/status/centerRestart'
                elif self.__kickPeripheryID == -3:
                    msg = '#menu:login/status/versionMismatch'
            elif connectionManager.isVersionsDiffered:
                msg = ''
                self.onHandleUpdateClientSoftwareNeeded()
            localizedMessage = i18n.convert(i18n.makeString(msg))
            lastLoginType = Settings.g_instance.userPrefs[
                Settings.KEY_LOGIN_INFO].readString('lastLoginType', 'basic')
            if lastLoginType != 'basic' and not Settings.g_instance.userPrefs[
                    Settings.KEY_LOGIN_INFO].readBool('rememberPwd', False):
                from gui.social_network_login import Bridge as socialNetworkLogin
                localizedMessage = socialNetworkLogin.getLogoutWarning(
                    lastLoginType)
            self.onSetStatus(localizedMessage, self.ALL_VALID)
            connectionManager.disconnect()