def goToLoginByError(self, reason): """ Goes to login screen by client error. :param reason: reason describing the error that occurred. :return: True if state is changed, otherwise - False. """ LOG_DEBUG('Disconnects from server by client error') self.__ctx.dsnReason = _DSN_REASON.ERROR self.__ctx.dsnDesc = (reason, False, 0) connectionManager.disconnect() return self.showLogin()
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() 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
def goToLoginByError(self, reason): """ Goes to login screen by client error. :param reason: reason describing the error that occurred. :return: True if state is changed, otherwise - False. """ LOG_DEBUG('Disconnects from server by client error') self.__ctx.dsnReason = _DSN_REASON.ERROR self.__ctx.dsnDesc = (reason, False, 0) connectionManager.disconnect() return self.showLogin()
def goToLoginByRQ(self, forced = False): """ Goes to login screen by player request - he clicks to button or exit from login queue. :param forced: bool. :return: True if state is changed, otherwise - False. """ if self.__ctx.dsnReason != _DSN_REASON.REQUEST or forced: LOG_DEBUG('Disconnects from server by request') self.__ctx.dsnReason = _DSN_REASON.REQUEST connectionManager.disconnect() return self.showLogin()
def goToLoginByRQ(self, forced=False): """ Goes to login screen by player request - he clicks to button or exit from login queue. :param forced: bool. :return: True if state is changed, otherwise - False. """ if self.__ctx.dsnReason != _DSN_REASON.REQUEST or forced: LOG_DEBUG('Disconnects from server by request') self.__ctx.dsnReason = _DSN_REASON.REQUEST connectionManager.disconnect() return self.showLogin()
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()
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()
def __windowClosing(self): self.fireEvent(LoginEventEx(LoginEventEx.ON_LOGIN_QUEUE_CLOSED, '', '', '', '', False), EVENT_BUS_SCOPE.LOBBY) connectionManager.disconnect() self.destroy()
def onAutoLoginClick(self): self.fireEvent(LoginEventEx(LoginEventEx.SWITCH_LOGIN_QUEUE_TO_AUTO, '', '', '', '', False), EVENT_BUS_SCOPE.LOBBY) connectionManager.disconnect() self.destroy()
def goToLoginByRQ(self, forced = False): if self.__ctx.dsnReason != _DSN_REASON.REQUEST or forced: LOG_DEBUG('Disconnects from server by request') self.__ctx.dsnReason = _DSN_REASON.REQUEST connectionManager.disconnect() return self.showLogin()
def goToLoginByRQ(self, forced=False): if self.__ctx.dsnReason != _DSN_REASON.REQUEST or forced: LOG_DEBUG('Disconnects from server by request') self.__ctx.dsnReason = _DSN_REASON.REQUEST connectionManager.disconnect() return self.showLogin()
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()
def __windowClosing(self): self.fireEvent( LoginEventEx(LoginEventEx.ON_LOGIN_QUEUE_CLOSED, '', '', '', '', False), EVENT_BUS_SCOPE.LOBBY) connectionManager.disconnect() self.destroy()
def onAutoLoginClick(self): self.fireEvent( LoginEventEx(LoginEventEx.SWITCH_LOGIN_QUEUE_TO_AUTO, '', '', '', '', False), EVENT_BUS_SCOPE.LOBBY) connectionManager.disconnect() self.destroy()
def logOff(): if callback is not None: callback(True) from ConnectionManager import connectionManager connectionManager.disconnect() return