Remove some Disney shit

This commit is contained in:
Daniel 2015-03-29 14:38:52 +03:00
parent 4a787248e9
commit 9a58ff9568
11 changed files with 0 additions and 1089 deletions

View file

@ -33,7 +33,6 @@ from otp.distributed.OtpDoGlobals import *
from otp.distributed.TelemetryLimiter import TelemetryLimiter from otp.distributed.TelemetryLimiter import TelemetryLimiter
from otp.login import HTTPUtil from otp.login import HTTPUtil
from otp.login import LoginTTUAccount from otp.login import LoginTTUAccount
from otp.login.CreateAccountScreen import CreateAccountScreen
from otp.otpbase import OTPGlobals from otp.otpbase import OTPGlobals
from otp.otpbase import OTPLocalizer from otp.otpbase import OTPLocalizer
from otp.otpgui import OTPDialog from otp.otpgui import OTPDialog
@ -257,16 +256,6 @@ class OTPClientRepository(ClientRepositoryBase):
self.exitLogin, [ self.exitLogin, [
'noConnection', 'noConnection',
'waitForGameList', 'waitForGameList',
'createAccount',
'reject',
'failedToConnect',
'shutdown']),
State('createAccount',
self.enterCreateAccount,
self.exitCreateAccount, [
'noConnection',
'waitForGameList',
'login',
'reject', 'reject',
'failedToConnect', 'failedToConnect',
'shutdown']), 'shutdown']),
@ -596,9 +585,6 @@ class OTPClientRepository(ClientRepositoryBase):
self.loginFSM.request('parentPassword') self.loginFSM.request('parentPassword')
elif mode == 'freeTimeExpired': elif mode == 'freeTimeExpired':
self.loginFSM.request('freeTimeInform') self.loginFSM.request('freeTimeInform')
elif mode == 'createAccount':
self.loginFSM.request('createAccount', [{'back': 'login',
'backArgs': []}])
elif mode == 'reject': elif mode == 'reject':
self.loginFSM.request('reject') self.loginFSM.request('reject')
elif mode == 'quit': elif mode == 'quit':
@ -616,47 +602,6 @@ class OTPClientRepository(ClientRepositoryBase):
self.handler = None self.handler = None
return return
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
def enterCreateAccount(self, createAccountDoneData = {'back': 'login',
'backArgs': []}):
self.createAccountDoneData = createAccountDoneData
self.createAccountDoneEvent = 'createAccountDone'
self.createAccountScreen = None
self.createAccountScreen = CreateAccountScreen(self, self.createAccountDoneEvent)
self.accept(self.createAccountDoneEvent, self.__handleCreateAccountDone)
self.createAccountScreen.load()
self.createAccountScreen.enter()
return
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
def __handleCreateAccountDone(self, doneStatus):
mode = doneStatus['mode']
if mode == 'success':
self.setIsNotNewInstallation()
self.loginFSM.request('waitForGameList')
elif mode == 'reject':
self.loginFSM.request('reject')
elif mode == 'cancel':
self.loginFSM.request(self.createAccountDoneData['back'], self.createAccountDoneData['backArgs'])
elif mode == 'failure':
self.loginFSM.request(self.createAccountDoneData['back'], self.createAccountDoneData['backArgs'])
elif mode == 'quit':
self.loginFSM.request('shutdown')
else:
self.notify.error('Invalid doneStatus mode from CreateAccountScreen: ' + str(mode))
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
def exitCreateAccount(self):
if self.createAccountScreen:
self.createAccountScreen.exit()
self.createAccountScreen.unload()
self.createAccountScreen = None
self.renderFrame()
self.ignore(self.createAccountDoneEvent)
del self.createAccountDoneEvent
self.handler = None
return
@report(types=['args', 'deltaStamp'], dConfigParam='teleport') @report(types=['args', 'deltaStamp'], dConfigParam='teleport')
def enterFailedToConnect(self, statusCode, statusString): def enterFailedToConnect(self, statusCode, statusString):
self.handler = self.handleMessageType self.handler = self.handleMessageType

View file

@ -1,67 +0,0 @@
from pandac.PandaModules import *
from RemoteValueSet import *
from direct.directnotify import DirectNotifyGlobal
import TTAccount
import HTTPUtil
class AccountServerConstants(RemoteValueSet):
notify = DirectNotifyGlobal.directNotify.newCategory('AccountServerConstants')
def __init__(self, cr):
self.expectedConstants = ['minNameLength',
'minPwLength',
'allowNewAccounts',
'freeTrialPeriodInDays',
'priceFirstMonth',
'pricePerMonth',
'customerServicePhoneNumber',
'creditCardUpFront']
self.defaults = {'minNameLength': '1',
'minPwLength': '1',
'allowNewAccounts': '1',
'creditCardUpFront': '0',
'priceFirstMonth': '9.95',
'pricePerMonth': '9.95'}
noquery = 1
if cr.productName == 'DisneyOnline-US':
if base.config.GetBool('tt-specific-login', 0):
pass
else:
noquery = 0
if cr.accountOldAuth or base.config.GetBool('default-server-constants', noquery):
self.notify.debug('setting defaults, not using account server constants')
self.dict = {}
for constantName in self.expectedConstants:
self.dict[constantName] = 'DEFAULT'
self.dict.update(self.defaults)
return
url = URLSpec(AccountServerConstants.getServer())
url.setPath('/constants.php')
self.notify.debug('grabbing account server constants from %s' % url.cStr())
RemoteValueSet.__init__(self, url, cr.http, expectedHeader='ACCOUNT SERVER CONSTANTS', expectedFields=self.expectedConstants)
def getBool(self, name):
return self.__getConstant(name, RemoteValueSet.getBool)
def getInt(self, name):
return self.__getConstant(name, RemoteValueSet.getInt)
def getFloat(self, name):
return self.__getConstant(name, RemoteValueSet.getFloat)
def getString(self, name):
return self.__getConstant(name, RemoteValueSet.getString)
def __getConstant(self, constantName, accessor):
if constantName not in self.expectedConstants:
self.notify.warning("requested constant '%s' not in expected constant list; if it's a new constant, add it to the list" % constantName)
return accessor(self, constantName)
@staticmethod
def getServer():
return TTAccount.getAccountServer().cStr()
@staticmethod
def getServerURL():
return TTAccount.getAccountServer()

View file

@ -1,247 +0,0 @@
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from pandac.PandaModules import *
from direct.fsm import StateData
from otp.otpgui import OTPDialog
from direct.fsm import ClassicFSM
from direct.fsm import State
from direct.directnotify import DirectNotifyGlobal
from otp.otpbase import OTPLocalizer
import GuiScreen
from otp.otpbase import OTPGlobals
from direct.distributed.MsgTypes import *
class CreateAccountScreen(StateData.StateData, GuiScreen.GuiScreen):
notify = DirectNotifyGlobal.directNotify.newCategory('CreateAccountScreen')
ActiveEntryColor = Vec4(1, 1, 1, 1)
InactiveEntryColor = Vec4(0.8, 0.8, 0.8, 1)
labelFg = (1, 1, 1, 1)
labelFgActive = (1, 1, 0, 1)
def __init__(self, cr, doneEvent):
StateData.StateData.__init__(self, doneEvent)
GuiScreen.GuiScreen.__init__(self)
self.cr = cr
self.loginInterface = self.cr.loginInterface
self.fsm = ClassicFSM.ClassicFSM('CreateAccountScreen', [State.State('off', self.enterOff, self.exitOff, ['create']), State.State('create', self.enterCreate, self.exitCreate, ['waitForLoginResponse', 'create']), State.State('waitForLoginResponse', self.enterWaitForLoginResponse, self.exitWaitForLoginResponse, ['create'])], 'off', 'off')
self.fsm.enterInitialState()
def load(self):
self.notify.debug('load')
masterScale = 0.8
textScale = 0.1 * masterScale
entryScale = 0.08 * masterScale
lineHeight = 0.21 * masterScale
buttonScale = 1.3 * masterScale
buttonLineHeight = 0.16 * masterScale
self.frame = DirectFrame(parent=aspect2d, relief=None)
self.frame.hide()
linePos = 0.5
linePos -= lineHeight
self.nameLabel = DirectLabel(parent=self.frame, relief=None, pos=(-0.21, 0, linePos), text=OTPLocalizer.CreateAccountScreenUserName, text_scale=textScale, text_align=TextNode.ARight, text_fg=self.labelFg, text_shadow=(0, 0, 0, 1), text_shadowOffset=(0.08, 0.08))
self.nameEntry = DirectEntry(parent=self.frame, relief=DGG.SUNKEN, borderWidth=(0.1, 0.1), scale=entryScale, pos=(-0.125, 0.0, linePos), width=OTPGlobals.maxLoginWidth, numLines=1, focus=0, cursorKeys=1)
self.nameEntry.label = self.nameLabel
linePos -= lineHeight
self.passwordLabel = DirectLabel(parent=self.frame, relief=None, pos=(-0.21, 0, linePos), text=OTPLocalizer.CreateAccountScreenPassword, text_scale=textScale, text_align=TextNode.ARight, text_fg=self.labelFg, text_shadow=(0, 0, 0, 1), text_shadowOffset=(0.08, 0.08))
self.passwordEntry = DirectEntry(parent=self.frame, relief=DGG.SUNKEN, borderWidth=(0.1, 0.1), scale=entryScale, pos=(-0.125, 0.0, linePos), width=OTPGlobals.maxLoginWidth, numLines=1, focus=0, cursorKeys=1, obscured=1)
self.passwordEntry.label = self.passwordLabel
linePos -= lineHeight
self.passwordConfirmLabel = DirectLabel(parent=self.frame, relief=None, pos=(-0.21, 0, linePos), text=OTPLocalizer.CreateAccountScreenConfirmPassword, text_scale=textScale, text_align=TextNode.ARight, text_fg=self.labelFg, text_shadow=(0, 0, 0, 1), text_shadowOffset=(0.08, 0.08))
self.passwordConfirmEntry = DirectEntry(parent=self.frame, relief=DGG.SUNKEN, borderWidth=(0.1, 0.1), scale=entryScale, pos=(-0.125, 0.0, linePos), width=OTPGlobals.maxLoginWidth, numLines=1, focus=0, cursorKeys=1, obscured=1)
self.passwordConfirmEntry.label = self.passwordConfirmLabel
linePos -= lineHeight
linePos -= lineHeight
self.submitButton = DirectButton(parent=self.frame, relief=DGG.RAISED, borderWidth=(0.01, 0.01), pos=(0, 0, linePos), scale=buttonScale, text=OTPLocalizer.CreateAccountScreenSubmit, text_scale=0.06, text_pos=(0, -0.02), command=self.__handleSubmit)
linePos -= buttonLineHeight
self.cancelButton = DirectButton(parent=self.frame, relief=DGG.RAISED, borderWidth=(0.01, 0.01), pos=(0, 0, linePos), scale=buttonScale, text=OTPLocalizer.CreateAccountScreenCancel, text_scale=0.06, text_pos=(0, -0.02), command=self.__handleCancel)
linePos -= buttonLineHeight
self.dialogDoneEvent = 'createAccountDialogAck'
dialogClass = OTPGlobals.getGlobalDialogClass()
self.dialog = dialogClass(dialogName='createAccountDialog', doneEvent=self.dialogDoneEvent, message='', style=OTPDialog.Acknowledge, sortOrder=NO_FADE_SORT_INDEX + 100)
self.dialog.hide()
return
def unload(self):
self.notify.debug('unload')
self.dialog.cleanup()
del self.dialog
self.frame.destroy()
del self.fsm
del self.loginInterface
del self.cr
def enter(self):
self.__firstTime = 1
self.frame.show()
self.fsm.request('create')
def exit(self):
self.ignore(self.dialogDoneEvent)
self.fsm.requestFinalState()
self.frame.hide()
def enterOff(self):
pass
def exitOff(self):
pass
def enterCreate(self):
self.password = ''
self.passwordEntry.set('')
self.passwordConfirmEntry.set('')
if self.__firstTime:
self.userName = ''
self.nameEntry.set(self.userName)
self.__firstTime = 0
self.focusList = [self.nameEntry, self.passwordEntry, self.passwordConfirmEntry]
self.startFocusMgmt(overrides={}, globalFocusHandler=self.__handleFocusChange)
def exitCreate(self):
self.stopFocusMgmt()
def __handleFocusChange(self, focusItem):
for item in self.focusList:
item.label.component('text0').setFg(self.labelFg)
if focusItem is not None:
focusItem.label.component('text0').setFg(self.labelFgActive)
return
def __handleSubmit(self):
self.removeFocus()
self.userName = self.nameEntry.get()
self.password = self.passwordEntry.get()
passwordConfirm = self.passwordConfirmEntry.get()
minNameLength = self.cr.accountServerConstants.getInt('minNameLength')
minPwdLength = self.cr.accountServerConstants.getInt('minPwLength')
if self.userName == '':
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenNoAccountName)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleUsernameAck)
elif len(self.userName) < minNameLength:
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenAccountNameTooShort % minNameLength)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleUsernameAck)
elif len(self.password) < minPwdLength:
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenPasswordTooShort % minPwdLength)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handlePasswordAck)
elif self.password != passwordConfirm:
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenPasswordMismatch)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handlePasswordAck)
else:
self.fsm.request('waitForLoginResponse')
def __handleCancel(self):
messenger.send(self.doneEvent, [{'mode': 'cancel'}])
def __handleUsernameAck(self):
self.dialog.hide()
self.fsm.request('create')
self.setFocus(self.nameEntry)
def __handlePasswordAck(self):
self.dialog.hide()
self.fsm.request('create')
self.setFocus(self.passwordEntry)
def enterWaitForLoginResponse(self):
self.cr.handler = self.handleWaitForLoginResponse
self.cr.userName = self.userName
self.cr.password = self.password
data = {}
referrer = launcher.getReferrerCode()
if referrer is not None:
data['referrer'] = referrer
error = self.loginInterface.createAccount(self.userName, self.password, data)
if error:
self.notify.info(error)
self.dialog.setMessage(error)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleBadAccountAck)
else:
self.cr.logAccountInfo()
self.loginInterface.sendLoginMsg()
self.waitForDatabaseTimeout(requestName='CreateAccountWaitForLoginResponse')
return
def exitWaitForLoginResponse(self):
self.cleanupWaitingForDatabase()
self.cr.handler = None
return
def handleWaitForLoginResponse(self, msgType, di):
if msgType == CLIENT_LOGIN_2_RESP:
self.handleLoginResponseMsg2(di)
elif msgType == CLIENT_LOGIN_RESP:
self.handleLoginResponseMsg(di)
else:
self.cr.handleMessageType(msgType, di)
def handleLoginResponseMsg2(self, di):
returnCode = di.getUint8()
self.notify.info('Login response return code: ' + str(returnCode))
if returnCode == 0:
self.__handleLoginSuccess()
else:
errorString = di.getString()
self.notify.warning(errorString)
messenger.send(self.doneEvent, [{'mode': 'reject'}])
def __handleLoginSuccess(self):
self.notify.info('Logged in with username: %s' % self.userName)
launcher.setGoUserName(self.userName)
launcher.setLastLogin(self.userName)
launcher.setUserLoggedIn()
messenger.send(self.doneEvent, [{'mode': 'success'}])
def handleLoginResponseMsg(self, di):
returnCode = di.getUint8()
self.notify.info('Login response return code: ' + str(returnCode))
if returnCode == 0:
accountCode = di.getUint32()
commentString = di.getString()
sec = di.getUint32()
usec = di.getUint32()
self.__handleLoginSuccess()
elif returnCode == 12:
self.notify.info('Bad password')
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenUserNameTaken)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleBadPasswordAck)
elif returnCode == 14:
self.notify.info('Bad word in user name')
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenInvalidUserName)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleBadWordInUserName)
elif returnCode == 129:
self.notify.info('Username not found')
self.dialog.setMessage(OTPLocalizer.CreateAccountScreenUserNameNotFound)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleBadAccountAck)
else:
accountCode = di.getUint32()
errorString = di.getString()
self.notify.warning(errorString)
messenger.send(self.doneEvent, [{'mode': 'reject'}])
def __handleConnectionErrorAck(self):
self.dialog.hide()
messenger.send(self.doneEvent, [{'mode': 'failure'}])
def __handleBadPasswordAck(self):
self.dialog.hide()
self.fsm.request('create')
def __handleBadAccountAck(self):
self.dialog.hide()
self.fsm.request('create')
def __handleBadWordInUserName(self):
self.userName = ''
self.nameEntry.set('')
self.dialog.hide()
self.fsm.request('create')

View file

@ -1,276 +0,0 @@
from pandac.PandaModules import *
from otp.otpbase import OTPGlobals
from direct.gui.DirectGui import *
from otp.otpgui import OTPDialog
from direct.directnotify import DirectNotifyGlobal
from otp.otpbase import OTPLocalizer
from direct.task.Task import Task
class GuiScreen:
notify = DirectNotifyGlobal.directNotify.newCategory('GuiScreen')
DGG.ENTERPRESS_ADVANCE = 0
DGG.ENTERPRESS_ADVANCE_IFNOTEMPTY = 1
DGG.ENTERPRESS_DONT_ADVANCE = 2
DGG.ENTERPRESS_REMOVE_FOCUS = 3
ENTRY_WIDTH = 20
def __init__(self):
self.waitingForDatabase = None
self.focusIndex = None
self.suppressClickSound = 0
return
def startFocusMgmt(self, startFocus = 0, enterPressBehavior = DGG.ENTERPRESS_ADVANCE_IFNOTEMPTY, overrides = {}, globalFocusHandler = None):
GuiScreen.notify.debug('startFocusMgmt:\nstartFocus=%s,\nenterPressBehavior=%s\noverrides=%s' % (startFocus, enterPressBehavior, overrides))
self.accept('tab', self.__handleTab)
self.accept('shift-tab', self.__handleShiftTab)
self.accept('enter', self.__handleEnter)
self.__startFrameStartTask()
self.userGlobalFocusHandler = globalFocusHandler
self.focusHandlerAbsorbCounts = {}
for i in xrange(len(self.focusList)):
item = self.focusList[i]
if isinstance(item, DirectEntry):
self.focusHandlerAbsorbCounts[item] = 0
self.userFocusHandlers = {}
self.userCommandHandlers = {}
for i in xrange(len(self.focusList)):
item = self.focusList[i]
if isinstance(item, DirectEntry):
self.userFocusHandlers[item] = (item['focusInCommand'], item['focusInExtraArgs'])
item['focusInCommand'] = self.__handleFocusChangeAbsorb
item['focusInExtraArgs'] = [i]
self.userCommandHandlers[item] = (item['command'], item['extraArgs'])
item['command'] = None
item['extraArgs'] = []
elif isinstance(item, DirectScrolledList):
self.userCommandHandlers[item] = (item['command'], item['extraArgs'])
item['command'] = self.__handleDirectScrolledListCommand
item['extraArgs'] = [i]
self.enterPressHandlers = {}
for i in xrange(len(self.focusList)):
item = self.focusList[i]
behavior = enterPressBehavior
if item in overrides:
behavior = overrides[item]
if callable(behavior):
self.enterPressHandlers[item] = behavior
else:
if not isinstance(item, DirectEntry) and behavior == GuiScreen_ENTERPRESS_ADVANCE_IFNOTEMPTY:
behavior = GuiScreen_ENTERPRESS_ADVANCE
commandHandlers = (self.__alwaysAdvanceFocus,
self.__advanceFocusIfNotEmpty,
self.__neverAdvanceFocus,
self.__ignoreEnterPress)
self.enterPressHandlers[item] = commandHandlers[behavior]
self.setFocus(startFocus)
return
def focusMgmtActive(self):
return self.focusIndex != None
def stopFocusMgmt(self):
GuiScreen.notify.debug('stopFocusMgmt')
if not self.focusMgmtActive():
return
self.ignore('tab')
self.ignore('shift-tab')
self.ignore('enter')
self.__stopFrameStartTask()
self.userGlobalFocusHandler = None
self.focusIndex = None
self.focusHandlerAbsorbCounts = {}
for item in self.focusList:
if isinstance(item, DirectEntry):
userHandler, userHandlerArgs = self.userFocusHandlers[item]
item['focusInCommand'] = userHandler
item['focusInExtraArgs'] = userHandlerArgs
userHandler, userHandlerArgs = self.userCommandHandlers[item]
item['command'] = userHandler
item['extraArgs'] = userHandlerArgs
elif isinstance(item, DirectScrolledList):
userHandler, userHandlerArgs = self.userCommandHandlers[item]
item['command'] = userHandler
item['extraArgs'] = userHandlerArgs
self.userFocusHandlers = {}
self.userCommandHandlers = {}
self.enterPressHandlers = {}
return
def setFocus(self, arg, suppressSound = 1):
if type(arg) == type(0):
index = arg
else:
index = self.focusList.index(arg)
if suppressSound:
self.suppressClickSound += 1
self.__setFocusIndex(index)
def advanceFocus(self, condition = 1):
index = self.getFocusIndex()
if condition:
index += 1
self.setFocus(index, suppressSound=0)
def getFocusIndex(self):
if not self.focusMgmtActive():
return None
return self.focusIndex
def getFocusItem(self):
if not self.focusMgmtActive():
return None
return self.focusList[self.focusIndex]
def removeFocus(self):
focusItem = self.getFocusItem()
if isinstance(focusItem, DirectEntry):
focusItem['focus'] = 0
if self.userGlobalFocusHandler:
self.userGlobalFocusHandler(None)
return
def restoreFocus(self):
self.setFocus(self.getFocusItem())
def __setFocusIndex(self, index):
focusIndex = index % len(self.focusList)
focusItem = self.focusList[focusIndex]
if isinstance(focusItem, DirectEntry):
focusItem['focus'] = 1
self.focusHandlerAbsorbCounts[focusItem] += 1
self.__handleFocusChange(focusIndex)
def __chainToUserCommandHandler(self, item):
userHandler, userHandlerArgs = self.userCommandHandlers[item]
if userHandler:
if isinstance(item, DirectEntry):
enteredText = item.get()
apply(userHandler, [enteredText] + userHandlerArgs)
elif isinstance(item, DirectScrolledList):
apply(userHandler, userHandlerArgs)
def __chainToUserFocusHandler(self, item):
if isinstance(item, DirectEntry):
userHandler, userHandlerArgs = self.userFocusHandlers[item]
if userHandler:
apply(userHandler, userHandlerArgs)
def __handleTab(self):
self.tabPressed = 1
self.focusDirection = 1
self.__setFocusIndex(self.getFocusIndex() + self.focusDirection)
def __handleShiftTab(self):
self.tabPressed = 1
self.focusDirection = -1
self.__setFocusIndex(self.getFocusIndex() + self.focusDirection)
def __handleFocusChangeAbsorb(self, index):
item = self.focusList[index]
if self.focusHandlerAbsorbCounts[item] > 0:
self.focusHandlerAbsorbCounts[item] -= 1
else:
self.__handleFocusChange(index)
def playFocusChangeSound(self):
base.playSfx(DGG.getDefaultClickSound())
def __handleFocusChange(self, index):
if index != self.focusIndex:
self.removeFocus()
self.__focusChangedThisFrame = 1
if hasattr(self, 'tabPressed'):
del self.tabPressed
else:
self.focusDirection = 1
self.focusIndex = index
if self.suppressClickSound > 0:
self.suppressClickSound -= 1
else:
self.playFocusChangeSound()
focusItem = self.getFocusItem()
if self.userGlobalFocusHandler:
self.userGlobalFocusHandler(focusItem)
if self.getFocusItem() != focusItem:
GuiScreen.notify.debug('focus changed by global focus handler')
if self.focusMgmtActive():
self.__chainToUserFocusHandler(focusItem)
def __startFrameStartTask(self):
self.__focusChangedThisFrame = 0
self.frameStartTaskName = 'GuiScreenFrameStart'
taskMgr.add(self.__handleFrameStart, self.frameStartTaskName, -100)
def __stopFrameStartTask(self):
taskMgr.remove(self.frameStartTaskName)
del self.frameStartTaskName
del self.__focusChangedThisFrame
def __handleFrameStart(self, task):
self.__focusChangedThisFrame = 0
return Task.cont
def __handleDirectScrolledListCommand(self, index):
self.__chainToUserCommandHandler(self.focusList[index])
self.setFocus(index, suppressSound=self.getFocusIndex() == index)
def __handleEnter(self):
if self.__focusChangedThisFrame:
return
focusItem = self.getFocusItem()
if isinstance(focusItem, DirectEntry):
self.__chainToUserCommandHandler(focusItem)
if self.focusMgmtActive() and focusItem == self.getFocusItem():
self.enterPressHandlers[focusItem]()
def __alwaysAdvanceFocus(self):
self.advanceFocus()
def __advanceFocusIfNotEmpty(self):
focusItem = self.getFocusItem()
enteredText = focusItem.get()
if enteredText != '':
self.advanceFocus()
else:
self.setFocus(self.getFocusIndex())
def __neverAdvanceFocus(self):
self.setFocus(self.getFocusIndex())
def __ignoreEnterPress(self):
pass
def waitForDatabaseTimeout(self, requestName = 'unknown'):
GuiScreen.notify.debug('waiting for database timeout %s at %s' % (requestName, globalClock.getFrameTime()))
globalClock.tick()
taskMgr.doMethodLater(OTPGlobals.DatabaseDialogTimeout, self.__showWaitingForDatabase, 'waitingForDatabase', extraArgs=[requestName])
def __showWaitingForDatabase(self, requestName):
GuiScreen.notify.info('timed out waiting for %s at %s' % (requestName, globalClock.getFrameTime()))
dialogClass = OTPGlobals.getDialogClass()
self.waitingForDatabase = dialogClass(text=OTPLocalizer.GuiScreenToontownUnavailable, dialogName='WaitingForDatabase', buttonTextList=[OTPLocalizer.GuiScreenCancel], style=OTPDialog.Acknowledge, command=self.__handleCancelWaiting)
self.waitingForDatabase.show()
taskMgr.doMethodLater(OTPGlobals.DatabaseGiveupTimeout, self.__giveUpWaitingForDatabase, 'waitingForDatabase', extraArgs=[requestName])
return Task.done
def __giveUpWaitingForDatabase(self, requestName):
GuiScreen.notify.info('giving up waiting for %s at %s' % (requestName, globalClock.getFrameTime()))
self.cleanupWaitingForDatabase()
messenger.send(self.doneEvent, [{'mode': 'failure'}])
return Task.done
def cleanupWaitingForDatabase(self):
if self.waitingForDatabase != None:
self.waitingForDatabase.cleanup()
self.waitingForDatabase = None
taskMgr.remove('waitingForDatabase')
return
def __handleCancelWaiting(self, value):
self.cleanupWaitingForDatabase()
messenger.send(self.doneEvent, [{'mode': 'quit'}])

View file

@ -1,5 +1,4 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
import TTAccount
import HTTPUtil import HTTPUtil
class RemoteValueSet: class RemoteValueSet:

View file

@ -1,280 +0,0 @@
from pandac.PandaModules import *
from pandac.PandaModules import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import PythonUtil
from otp.otpbase import OTPLocalizer
import HTTPUtil
import RemoteValueSet
import copy
accountServer = ''
accountServer = launcher.getAccountServer()
print 'TTAccount: accountServer from launcher: ', accountServer
configAccountServer = base.config.GetString('account-server', '')
if configAccountServer:
accountServer = configAccountServer
print 'TTAccount: overriding accountServer from config: ', accountServer
if not accountServer:
accountServer = 'https://toontown.go.com'
print 'TTAccount: default accountServer: ', accountServer
accountServer = URLSpec(accountServer, 1)
def getAccountServer():
return accountServer
TTAccountException = HTTPUtil.HTTPUtilException
class TTAccount:
notify = DirectNotifyGlobal.directNotify.newCategory('TTAccount')
def __init__(self, cr):
self.cr = cr
self.response = None
return
def createAccount(self, loginName, password, data):
return self.talk('create', data=self.__makeLoginDict(loginName, password, data))
def authorize(self, loginName, password):
return self.talk('play', data=self.__makeLoginDict(loginName, password))
def createBilling(self, loginName, password, data):
return self.talk('purchase', data=self.__makeLoginDict(loginName, password, data))
def setParentPassword(self, loginName, password, parentPassword):
return self.talk('setParentPassword', data=self.__makeLoginDict(loginName, password, {'parentPassword': parentPassword}))
def supportsParentPassword(self):
return 1
def authenticateParentPassword(self, loginName, password, parentPassword):
try:
errorMsg = self.talk('authenticateParentPassword', data=self.__makeLoginDict(loginName, parentPassword))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException, e:
return (0, str(e))
return None
def supportsAuthenticateDelete(self):
return 1
def authenticateDelete(self, loginName, password):
try:
errorMsg = self.talk('authenticateDelete', data=self.__makeLoginDict(loginName, password))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException, e:
return (0, str(e))
return None
def enableSecretFriends(self, loginName, password, parentPassword, enable = 1):
try:
errorMsg = self.talk('setSecretChat', data=self.__makeLoginDict(loginName, parentPassword, {'chat': base.cr.secretChatAllowed,
'secretsNeedParentPassword': base.cr.secretChatNeedsParentPassword}))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException, e:
return (0, str(e))
return None
def changePassword(self, loginName, password, newPassword):
return self.talk('purchase', data=self.__makeLoginDict(loginName, password, {'newPassword': newPassword}))
def requestPwdReminder(self, email = None, acctName = None):
data = {}
if email is not None:
data['email'] = email
else:
data['accountName'] = acctName
return self.talk('forgotPassword', data)
def cancelAccount(self, loginName, password):
return self.talk('cancel', data=self.__makeLoginDict(loginName, password))
def getAccountData(self, loginName, password):
errorMsg = self.talk('get', data=self.__makeLoginDict(loginName, password))
if errorMsg:
self.notify.warning('getAccountData error: %s' % errorMsg)
return errorMsg
if self.response.hasKey('errorMsg'):
self.notify.warning("error field is: '%s'" % self.response.getString('errorMsg'))
self.accountData = copy.deepcopy(self.response)
fieldNameMap = {'em': 'email',
'l1': 'addr1',
'l2': 'addr2',
'l3': 'addr3'}
dict = self.accountData.dict
for fieldName in dict.keys():
if fieldName in fieldNameMap:
dict[fieldNameMap[fieldName]] = dict[fieldName]
del dict[fieldName]
return None
def getLastErrorMsg(self, forceCustServNum = 0):
errCode = self.response.getInt('errorCode')
if errCode < 100:
msg = self.response.getString('errorMsg')
if forceCustServNum:
msg += ' ' + OTPLocalizer.TTAccountCustomerServiceHelp % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
elif errCode < 200:
msg = self.response.getString('errorMsg')
msg += ' ' + OTPLocalizer.TTAccountCustomerServiceHelp % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
elif errCode >= 500:
msg = OTPLocalizer.TTAccountIntractibleError
msg += ' ' + OTPLocalizer.TTAccountCallCustomerService % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
else:
self.notify.warning('unknown error code class: %s: %s' % (self.response.getInt('errorCode'), self.response.getString('errorMsg')))
msg = self.response.getString('errorMsg')
msg += ' ' + OTPLocalizer.TTAccountCallCustomerService % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
return msg
def __makeLoginDict(self, loginName, password, data = None):
dict = {'accountName': loginName,
'password': password}
if data:
dict.update(data)
return dict
def makeLoginDict(self, loginName, password, data = None):
return self.__makeLoginDict(loginName, password, data)
def talk(self, operation, data = {}):
self.notify.debug('TTAccount.talk()')
for key in data.keys():
data[key] = str(data[key])
if operation in ('play', 'get', 'cancel', 'authenticateParentPassword', 'authenticateDelete', 'authenticateParentPasswordNewStyle', 'authenticateDeleteNewStyle'):
pass
elif operation == 'authenticateParentUsernameAndPassword':
pass
elif operation == 'forgotPassword':
pass
elif operation == 'setParentPassword':
pass
elif operation == 'setSecretChat':
pass
elif operation == 'create':
pass
elif operation == 'purchase':
if 'newPassword' in data:
pass
else:
self.notify.error("Internal TTAccount error: need to add 'required data' checking for %s operation" % operation)
op2Php = {'play': 'play',
'get': 'get',
'cancel': 'cancel',
'create': 'create',
'purchase': 'purchase',
'setParentPassword': 'setSecrets',
'authenticateParentPassword': 'authenticateChat',
'authenticateDelete': 'authDelete',
'setSecretChat': 'setChat',
'forgotPassword': 'forgotPw',
'authenticateParentPasswordNewStyle': 'api/authChat',
'authenticateParentUsernameAndPassword': 'api/authParentChat',
'authenticateDeleteNewStyle': 'api/authDelete'}
newWebOperations = ('authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle')
url = URLSpec(getAccountServer())
if operation in newWebOperations:
url.setPath('/%s' % op2Php[operation])
else:
url.setPath('/%s.php' % op2Php[operation])
body = ''
if 'accountName' in data:
if operation not in newWebOperations:
url.setQuery('n=%s' % URLSpec.quote(data['accountName']))
serverFields = {'accountName': 'n',
'password': 'p',
'parentPassword': 'sp',
'newPassword': 'np',
'chat': 'chat',
'email': 'em',
'dobYear': 'doby',
'dobMonth': 'dobm',
'dobDay': 'dobd',
'ccNumber': 'ccn',
'ccMonth': 'ccm',
'ccYear': 'ccy',
'nameOnCard': 'noc',
'addr1': 'l1',
'addr2': 'l2',
'addr3': 'l3',
'city': 'city',
'state': 'state',
'country': 'country',
'zip': 'zip',
'referrer': 'ref',
'secretsNeedParentPassword': 'secretsNeedsParentPassword',
'parentPasswordNewStyle': 'pp',
'parentUsername': 'pu',
'userid': 'userid'}
ignoredFields = ('ccType',)
outBoundFields = {}
for fieldName in data.keys():
if fieldName not in serverFields:
if fieldName not in ignoredFields:
self.notify.error('unknown data field: %s' % fieldName)
else:
outBoundFields[serverFields[fieldName]] = data[fieldName]
orderedFields = outBoundFields.keys()
orderedFields.sort()
for fieldName in orderedFields:
if len(body):
body += '&'
body += '%s=%s' % (fieldName, URLSpec.quotePlus(outBoundFields[fieldName]))
self.notify.debug('url=' + url.cStr())
self.notify.debug('body=' + body)
if operation in ('get',):
expectedHeader = 'ACCOUNT INFO'
elif operation in ('play', 'cancel', 'create', 'purchase', 'setParentPassword', 'setSecretChat', 'authenticateParentPassword', 'authenticateDelete', 'forgotPassword', 'authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle'):
expectedHeader = 'ACCOUNT SERVER RESPONSE'
else:
self.notify.error("Internal TTAccount error: need to set expected response header for '%s' operation" % operation)
self.response = RemoteValueSet.RemoteValueSet(url, self.cr.http, body=body, expectedHeader=expectedHeader)
self.notify.debug(' self.response=' + str(self.response))
if self.response.hasKey('errorCode'):
errorCode = self.response.getInt('errorCode')
self.notify.info('account server error code: %s' % errorCode)
if errorCode == 10:
self.cr.freeTimeExpiresAt = 0
if self.response.hasKey('errorMsg'):
return self.getLastErrorMsg()
if operation in ('get', 'forgotPassword', 'authenticateDelete', 'play', 'cancel', 'create', 'purchase', 'setParentPassword', 'authenticateParentPassword', 'authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle'):
pass
elif operation == 'setSecretChat':
self.playToken = self.response.getString('playToken')
self.playTokenIsEncrypted = 1
else:
self.notify.error('Internal TTAccount error: need to extract useful data for %s operation' % operation)
return None
def authenticateParentUsernameAndPassword(self, loginName, password, parentUsername, parentPassword):
try:
errorMsg = self.talk('authenticateParentUsernameAndPassword', data=self.__makeLoginDict(loginName, password, {'parentUsername': parentUsername,
'parentPasswordNewStyle': parentPassword,
'userid': loginName}))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException, e:
return (0, str(e))
return None

View file

@ -154,21 +154,6 @@ ProblemActivatingChatOK = lOK
MultiPageTextFrameNext = lNext MultiPageTextFrameNext = lNext
MultiPageTextFramePrev = 'Previous' MultiPageTextFramePrev = 'Previous'
MultiPageTextFramePage = 'Page %s/%s' MultiPageTextFramePage = 'Page %s/%s'
GuiScreenToontownUnavailable = 'The server appears to be temporarily unavailable, still trying...'
GuiScreenCancel = lCancel
CreateAccountScreenUserName = 'Account Name'
CreateAccountScreenPassword = 'Password'
CreateAccountScreenConfirmPassword = 'Confirm Password'
CreateAccountScreenCancel = lCancel
CreateAccountScreenSubmit = 'Submit'
CreateAccountScreenConnectionErrorSuffix = '.\n\nPlease try again later.'
CreateAccountScreenNoAccountName = 'Please enter an account name.'
CreateAccountScreenAccountNameTooShort = 'Your account name must be at least %s characters long. Please try again.'
CreateAccountScreenPasswordTooShort = 'Your password must be at least %s characters long. Please try again.'
CreateAccountScreenPasswordMismatch = 'The passwords you typed did not match. Please try again.'
CreateAccountScreenUserNameTaken = 'That user name is already taken. Please try again.'
CreateAccountScreenInvalidUserName = 'Invalid user name.\nPlease try again.'
CreateAccountScreenUserNameNotFound = 'User name not found.\nPlease try again or create a new account.'
CRConnecting = 'Connecting...' CRConnecting = 'Connecting...'
CRNoConnectTryAgain = 'Could not connect to %s:%s. Try again?' CRNoConnectTryAgain = 'Could not connect to %s:%s. Try again?'
CRNoConnectProxyNoPort = 'Could not connect to %s:%s.\n\nYou are communicating to the internet via a proxy, but your proxy does not permit connections on port %s.\n\nYou must open up this port, or disable your proxy, in order to play. If your proxy has been provided by your ISP, you must contact your ISP to request them to open up this port.' CRNoConnectProxyNoPort = 'Could not connect to %s:%s.\n\nYou are communicating to the internet via a proxy, but your proxy does not permit connections on port %s.\n\nYou must open up this port, or disable your proxy, in order to play. If your proxy has been provided by your ISP, you must contact your ISP to request them to open up this port.'
@ -209,7 +194,6 @@ CREnteringToontown = 'Entering...'
LoginScreenUserName = 'Account Name' LoginScreenUserName = 'Account Name'
LoginScreenPassword = 'Password' LoginScreenPassword = 'Password'
LoginScreenLogin = 'Login' LoginScreenLogin = 'Login'
LoginScreenCreateAccount = 'Create Account'
LoginScreenQuit = lQuit LoginScreenQuit = lQuit
LoginScreenLoginPrompt = 'Please enter a user name and password.' LoginScreenLoginPrompt = 'Please enter a user name and password.'
LoginScreenBadPassword = 'Bad password.\nPlease try again.' LoginScreenBadPassword = 'Bad password.\nPlease try again.'
@ -2896,9 +2880,6 @@ WhiteListMenu = [-1, 'WHITELIST']
SellbotInvasionMenuSections = [-1] SellbotInvasionMenuSections = [-1]
SellbotFieldOfficeMenuSections = [-1, 'STRATEGY'] SellbotFieldOfficeMenuSections = [-1, 'STRATEGY']
IdesOfMarchMenuSections = [-1] IdesOfMarchMenuSections = [-1]
TTAccountCallCustomerService = 'Please call Customer Service at %s.'
TTAccountCustomerServiceHelp = '\nIf you need help, please call Customer Service at %s.'
TTAccountIntractibleError = 'An error occurred.'
def timeElapsedString(timeDelta): def timeElapsedString(timeDelta):
timeDelta = abs(timeDelta) timeDelta = abs(timeDelta)

View file

@ -33,7 +33,6 @@ from toontown.distributed import DelayDelete
from toontown.friends import FriendHandle from toontown.friends import FriendHandle
from toontown.friends import FriendsListPanel from toontown.friends import FriendsListPanel
from toontown.friends import ToontownFriendSecret from toontown.friends import ToontownFriendSecret
from toontown.login import DateObject
from toontown.login import AvatarChooser from toontown.login import AvatarChooser
from toontown.makeatoon import MakeAToon from toontown.makeatoon import MakeAToon
from toontown.pets import DistributedPet, PetDetail, PetHandle from toontown.pets import DistributedPet, PetDetail, PetHandle
@ -105,7 +104,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
self.friendPendingChatSettings = {} self.friendPendingChatSettings = {}
self.elderFriendsMap = {} self.elderFriendsMap = {}
self.__queryAvatarMap = {} self.__queryAvatarMap = {}
self.dateObject = DateObject.DateObject()
self.hoodMgr = HoodMgr.HoodMgr(self) self.hoodMgr = HoodMgr.HoodMgr(self)
self.setZonesEmulated = 0 self.setZonesEmulated = 0
self.old_setzone_interest_handle = None self.old_setzone_interest_handle = None

View file

@ -1,57 +0,0 @@
from pandac.PandaModules import *
from otp.login.HTTPUtil import *
from direct.directnotify import DirectNotifyGlobal
from otp.login import TTAccount
import DateObject
import TTDateObject
import time
class AccountServerDate:
notify = DirectNotifyGlobal.directNotify.newCategory('AccountServerDate')
def __init__(self):
self.__grabbed = 0
def getServer(self):
return TTAccount.getAccountServer().cStr()
def grabDate(self, force = 0):
if self.__grabbed and not force:
self.notify.debug('using cached account server date')
return
if base.cr.accountOldAuth or base.config.GetBool('use-local-date', 0):
self.__useLocalClock()
return
url = URLSpec(self.getServer())
url.setPath('/getDate.php')
self.notify.debug('grabbing account server date from %s' % url.cStr())
response = getHTTPResponse(url, http)
if response[0] != 'ACCOUNT SERVER DATE':
self.notify.debug('invalid response header')
raise UnexpectedResponse, 'unexpected response, response=%s' % response
try:
epoch = int(response[1])
except ValueError, e:
self.notify.debug(str(e))
raise UnexpectedResponse, 'unexpected response, response=%s' % response
timeTuple = time.gmtime(epoch)
self.year = timeTuple[0]
self.month = timeTuple[1]
self.day = timeTuple[2]
base.cr.dateObject = TTDateObject.TTDateObject(self)
self.__grabbed = 1
def __useLocalClock(self):
self.month = base.cr.dateObject.getMonth()
self.year = base.cr.dateObject.getYear()
self.day = base.cr.dateObject.getDay()
def getMonth(self):
return self.month
def getYear(self):
return self.year
def getDay(self):
return self.day

View file

@ -1,64 +0,0 @@
import time
class DateObject:
def getYear(self):
return time.localtime(time.time())[0]
def getMonth(self):
return time.localtime(time.time())[1]
def getDay(self):
return time.localtime(time.time())[2]
def getDetailedAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
if curMonth is None:
curMonth = self.getMonth()
if curYear is None:
curYear = self.getYear()
if curDay is None:
curDay = self.getDay()
curMonths = curYear * 12 + (curMonth - 1)
dobMonths = dobYear * 12 + (dobMonth - 1)
if dobMonth == curMonth:
if dobDay is not None:
if dobDay > curDay:
curMonths -= 1
ageMonths = curMonths - dobMonths
return (int(ageMonths / 12), ageMonths % 12)
def getAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
return self.getDetailedAge(dobMonth, dobYear, dobDay=dobDay, curMonth=curMonth, curYear=curYear, curDay=curDay)[0]
def getNumDaysInMonth(self, month = None, year = None):
def isLeapYear(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return 1
else:
return 0
else:
return 1
else:
return 0
if month is None:
m = self.getMonth()
else:
m = month
if year is None:
y = self.getYear()
else:
y = year
if m == 2:
if isLeapYear(y):
return 29
else:
return 28
elif m in (1, 3, 5, 7, 8, 10, 12):
return 31
else:
return 30
return

View file

@ -1,21 +0,0 @@
import DateObject
class TTDateObject(DateObject.DateObject):
def __init__(self, accountServerDate):
self.accountServerDate = accountServerDate
def getYear(self):
return self.accountServerDate.getYear()
def getMonth(self):
return self.accountServerDate.getMonth()
def getDay(self):
return self.accountServerDate.getDay()
def getDetailedAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
return DateObject.DateObject.getDetailedAge(self, dobMonth, dobYear, dobDay, curMonth=self.getMonth(), curYear=self.getYear(), curDay=self.getDay())
def getAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
return TTDateObject.getDetailedAge(self, dobMonth, dobYear, dobDay=dobDay, curMonth=curMonth, curYear=curYear, curDay=curDay)[0]