login: even more cleanup
This commit is contained in:
parent
058f66948d
commit
b0acb2701d
1 changed files with 14 additions and 92 deletions
|
@ -242,11 +242,13 @@ class GetAvatarsOperation(AvatarOperation):
|
||||||
self.pendingAvatars = None
|
self.pendingAvatars = None
|
||||||
self.avatarFields = None
|
self.avatarFields = None
|
||||||
|
|
||||||
def start(self):
|
def start(self, setCallback=True):
|
||||||
self.setCallback(self.__handleQueryAvatars)
|
if setCallback:
|
||||||
|
self.setCallback(self._handleQueryAvatars)
|
||||||
|
|
||||||
AvatarOperation.start(self)
|
AvatarOperation.start(self)
|
||||||
|
|
||||||
def __handleQueryAvatars(self):
|
def _handleQueryAvatars(self):
|
||||||
self.pendingAvatars = set()
|
self.pendingAvatars = set()
|
||||||
self.avatarFields = {}
|
self.avatarFields = {}
|
||||||
for avId in self.avList:
|
for avId in self.avList:
|
||||||
|
@ -535,32 +537,16 @@ class AcknowledgeNameOperation(AvatarOperation):
|
||||||
del self.loginManager.account2operation[self.sender]
|
del self.loginManager.account2operation[self.sender]
|
||||||
|
|
||||||
|
|
||||||
class RemoveAvatarOperation:
|
class RemoveAvatarOperation(GetAvatarsOperation):
|
||||||
|
|
||||||
def __init__(self, loginManager, sender):
|
def __init__(self, loginManager, sender):
|
||||||
self.loginManager = loginManager
|
GetAvatarsOperation.__init__(self, loginManager, sender)
|
||||||
self.sender = sender
|
|
||||||
self.account = None
|
|
||||||
self.avList = []
|
|
||||||
self.pendingAvatars = None
|
|
||||||
self.avatarFields = None
|
|
||||||
self.avId = None
|
self.avId = None
|
||||||
|
|
||||||
def start(self, avId):
|
def start(self, avId):
|
||||||
self.avId = avId
|
self.avId = avId
|
||||||
self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender,
|
self.setCallback(self.__handleRemoveAvatar)
|
||||||
self.__handleAccountRetrieved)
|
GetAvatarsOperation.start(self, False)
|
||||||
|
|
||||||
def __handleAccountRetrieved(self, dclass, fields):
|
|
||||||
if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']:
|
|
||||||
# TODO: Kill the connection
|
|
||||||
return
|
|
||||||
|
|
||||||
self.account = fields
|
|
||||||
self.avList = self.account['ACCOUNT_AV_SET']
|
|
||||||
self.avList = self.avList[:6]
|
|
||||||
self.avList += [0] * (6 - len(self.avList))
|
|
||||||
self.__handleRemoveAvatar()
|
|
||||||
|
|
||||||
def __handleRemoveAvatar(self):
|
def __handleRemoveAvatar(self):
|
||||||
if self.avId not in self.avList:
|
if self.avId not in self.avList:
|
||||||
|
@ -591,83 +577,19 @@ class RemoveAvatarOperation:
|
||||||
# TODO: Kill the connection
|
# TODO: Kill the connection
|
||||||
return
|
return
|
||||||
|
|
||||||
self.__handleQueryAvatars()
|
self._handleQueryAvatars()
|
||||||
|
|
||||||
def __handleQueryAvatars(self):
|
|
||||||
self.pendingAvatars = set()
|
|
||||||
self.avatarFields = {}
|
|
||||||
for avId in self.avList:
|
|
||||||
if avId:
|
|
||||||
self.pendingAvatars.add(avId)
|
|
||||||
|
|
||||||
def response(dclass, fields, avId=avId):
|
|
||||||
if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']:
|
|
||||||
# TODO: Kill the connection
|
|
||||||
return
|
|
||||||
|
|
||||||
self.avatarFields[avId] = fields
|
|
||||||
self.pendingAvatars.remove(avId)
|
|
||||||
if not self.pendingAvatars:
|
|
||||||
self.__handleSendAvatars()
|
|
||||||
|
|
||||||
self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, avId, response)
|
|
||||||
|
|
||||||
if not self.pendingAvatars:
|
|
||||||
self.__handleSendAvatars()
|
|
||||||
|
|
||||||
def __handleSendAvatars(self):
|
|
||||||
potentialAvatars = []
|
|
||||||
for avId, fields in self.avatarFields.items():
|
|
||||||
index = self.avList.index(avId)
|
|
||||||
wishNameState = fields.get('WishNameState', [''])[0]
|
|
||||||
name = fields['setName'][0]
|
|
||||||
nameState = 0
|
|
||||||
if wishNameState == 'OPEN':
|
|
||||||
nameState = 1
|
|
||||||
elif wishNameState == 'PENDING':
|
|
||||||
nameState = 2
|
|
||||||
elif wishNameState == 'APPROVED':
|
|
||||||
nameState = 3
|
|
||||||
name = fields['WishName'][0]
|
|
||||||
elif wishNameState == 'REJECTED':
|
|
||||||
nameState = 4
|
|
||||||
elif wishNameState == 'LOCKED':
|
|
||||||
nameState = 0
|
|
||||||
else:
|
|
||||||
# unknown name state.
|
|
||||||
nameState = 0
|
|
||||||
|
|
||||||
potentialAvatars.append([avId, name, fields['setDNAString'][0], index, nameState])
|
|
||||||
|
|
||||||
self.loginManager.sendUpdateToAccountId(self.sender, 'avatarListResponse', [potentialAvatars])
|
|
||||||
del self.loginManager.account2operation[self.sender]
|
|
||||||
|
|
||||||
|
|
||||||
class LoadAvatarOperation:
|
class LoadAvatarOperation(AvatarOperation):
|
||||||
|
|
||||||
def __init__(self, loginManager, sender):
|
def __init__(self, loginManager, sender):
|
||||||
self.loginManager = loginManager
|
AvatarOperation.__init__(self, loginManager, sender)
|
||||||
self.sender = sender
|
|
||||||
self.avId = None
|
self.avId = None
|
||||||
|
|
||||||
def start(self, avId):
|
def start(self, avId):
|
||||||
self.avId = avId
|
self.avId = avId
|
||||||
self.__handleRetrieveAccount()
|
self.setCallback(self.__handleGetTargetAvatar)
|
||||||
|
AvatarOperation.start(self)
|
||||||
def __handleRetrieveAccount(self):
|
|
||||||
self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender,
|
|
||||||
self.__handleAccountRetrieved)
|
|
||||||
|
|
||||||
def __handleAccountRetrieved(self, dclass, fields):
|
|
||||||
if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']:
|
|
||||||
# TODO: Kill the connection
|
|
||||||
return
|
|
||||||
|
|
||||||
self.account = fields
|
|
||||||
self.avList = self.account['ACCOUNT_AV_SET']
|
|
||||||
self.avList = self.avList[:6]
|
|
||||||
self.avList += [0] * (6 - len(self.avList))
|
|
||||||
self.__handleGetTargetAvatar()
|
|
||||||
|
|
||||||
def __handleGetTargetAvatar(self):
|
def __handleGetTargetAvatar(self):
|
||||||
if self.avId not in self.avList:
|
if self.avId not in self.avList:
|
||||||
|
|
Loading…
Reference in a new issue