コード例 #1
0
ファイル: connection.py プロジェクト: kusaku/wot_scripts
 def __doLogin(self):
     client = self.client()
     if not client.isConnecting():
         g_logOutput.warning(CLIENT_LOG_AREA.LOGIN,
                             'Client is not connecting',
                             client.getConnectionAddress(),
                             client.getConnectionState())
         yield lambda callback: callback(None)
         return
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN, 'Sends request to SPA')
     response = yield self.__tokenRequester.request()
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN,
                       'Response is received from SPA', response)
     if not response:
         g_logOutput.error(CLIENT_LOG_AREA.TOKEN,
                           'Received chat token is empty')
         return
     if response.isValid():
         if response.getDatabaseID() == getPlayerDatabaseID():
             g_logOutput.debug(CLIENT_LOG_AREA.LOGIN, 'Login to XMPP sever')
             client.login(response.getCredential())
         else:
             g_logOutput.error(CLIENT_LOG_AREA.LOGIN,
                               "Player's database ID mismatch",
                               getPlayerDatabaseID())
     else:
         g_logOutput.warning(CLIENT_LOG_AREA.TOKEN,
                             'Received chat token is not valid', response)
         self.__handleTokenError()
コード例 #2
0
 def __onSelfEnterChat(self, chatAction):
     wrapper = ChatActionWrapper(**dict(chatAction))
     channelID = wrapper.channel
     channel = self.channelsStorage.getChannel(
         entities.BWChannelLightEntity(channelID))
     isJoinAction = False
     if not channel and channelID in self.__channels:
         channel = self.__channels[channelID]
         if self.channelsStorage.addChannel(channel):
             g_messengerEvents.channels.onChannelInited(channel)
             g_messengerEvents.channels.onPlayerEnterChannelByAction(
                 channel)
             isJoinAction = True
     if not channel:
         raise ChannelNotFound(channelID)
     name = channel.getName()
     if not isJoinAction and name in self.__creationInfo and channel.getProtoData(
     ).owner == getPlayerDatabaseID():
         self.__creationInfo.pop(name)
         g_messengerEvents.channels.onPlayerEnterChannelByAction(channel)
     if not channel.isJoined():
         channel.setJoined(True)
         g_messengerEvents.channels.onConnectStateChanged(channel)
         self.requestChannelMembers(channelID)
     else:
         channel.clearHistory()
コード例 #3
0
    def __pe_onClanMembersListChanged(self):
        """Listener for event _PlayerEvents.onClanMembersListChanged.
        """
        clanMembers = getattr(BigWorld.player(), 'clanMembers', {})
        LOG_DEBUG('setClanMembersList', clanMembers)
        clanAbbrev = self.playerCtx.getClanAbbrev()
        clanDBID = self.playerCtx.getClanDbID()
        members = []
        if self.__clanChannel is not None:
            getter = self.__clanChannel.getMember
        else:

            def getter(dbID):
                return None

        playerID = getPlayerDatabaseID()
        for dbID, (name, roleFlags) in clanMembers.iteritems():
            if getter(dbID) is None:
                gos = GAME_ONLINE_STATUS.UNDEFINED
            else:
                gos = GAME_ONLINE_STATUS.ONLINE
            if playerID == dbID:
                user = XMPPUserEntity(dbID, name=name, clanInfo=ClanInfo(clanDBID, clanAbbrev, roleFlags))
            else:
                user = XMPPUserEntity(dbID, name=name, clanInfo=ClanInfo(clanDBID, clanAbbrev, roleFlags), gos=gos, tags={USER_TAG.CLAN_MEMBER})
            members.append(user)

        self.usersStorage.setClanMembersList(members)
        return
コード例 #4
0
ファイル: bwclanlistener.py プロジェクト: aevitas/wotsdk
    def __pe_onClanMembersListChanged(self):
        clanMembers = getattr(BigWorld.player(), 'clanMembers', {})
        LOG_DEBUG('setClanMembersList', clanMembers)
        if not self.__initSteps & _INIT_STEPS.MEMBERS_LIST_RECEIVED:
            self.__initSteps |= _INIT_STEPS.MEMBERS_LIST_RECEIVED
        clanAbbrev = self.playerCtx.getClanAbbrev()
        members = []
        if self.__clanChannel is not None:
            getter = self.__clanChannel.getMember
        else:
            getter = lambda dbID: None
        playerID = getPlayerDatabaseID()
        for dbID, (name, roleFlags) in clanMembers.iteritems():
            if getter(dbID) is None:
                gos = GAME_ONLINE_STATUS.UNDEFINED
            else:
                gos = GAME_ONLINE_STATUS.ONLINE
            if playerID == dbID:
                user = CurrentUserEntity(dbID, name=name, clanInfo=ClanInfo(0, clanAbbrev, roleFlags))
            else:
                user = SharedUserEntity(dbID, name=name, clanInfo=ClanInfo(0, clanAbbrev, roleFlags), gos=gos, tags={USER_TAG.CLAN_MEMBER})
            members.append(user)

        self.usersStorage.setClanMembersList(members)
        if self.__initSteps & _INIT_STEPS.LIST_INITED != 0:
            g_messengerEvents.users.onClanMembersListChanged()
        return
コード例 #5
0
ファイル: items.py プロジェクト: webiumsk/WOT-0.9.15.1
 def getMember(self, memberDbID=None):
     memberDbID = memberDbID or getPlayerDatabaseID()
     if self.hasMember(memberDbID):
         return self.__makeMemberItem(memberDbID,
                                      self._clubDescr.members[memberDbID])
     else:
         return None
コード例 #6
0
ファイル: clansstates.py プロジェクト: Difrex/wotsdk
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Clan gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request()
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the clan lib...')
             result = yield self.sendRequest(
                 contexts.LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for clan gate',
                     response)
     self.__loginState = nextLoginState
     if self.isLoggedOn():
         self._clanCtrl.onStateUpdated()
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
コード例 #7
0
ファイル: items.py プロジェクト: webiumsk/WOT0.9.10
 def getPermissions(self, memberDbID = None):
     if memberDbID is None:
         memberDbID = getPlayerDatabaseID()
     if self.hasMember(memberDbID):
         return MemberPermissions(self._clubDescr.members[memberDbID])
     else:
         return DefaultMemberPermissions()
コード例 #8
0
    def __pe_onClanMembersListChanged(self):
        clanMembers = getattr(BigWorld.player(), 'clanMembers', {})
        LOG_DEBUG('setClanMembersList', clanMembers)
        if not self.__initSteps & _INIT_STEPS.MEMBERS_LIST_RECEIVED:
            self.__initSteps |= _INIT_STEPS.MEMBERS_LIST_RECEIVED
        clanAbbrev = self.playerCtx.getClanAbbrev()
        members = []
        if self.__clanChannel is not None:
            getter = self.__clanChannel.getMember
        else:
            getter = lambda dbID: None
        playerID = getPlayerDatabaseID()
        for dbID, (name, roleFlags) in clanMembers.iteritems():
            if getter(dbID) is None:
                gos = GAME_ONLINE_STATUS.UNDEFINED
            else:
                gos = GAME_ONLINE_STATUS.ONLINE
            if playerID == dbID:
                user = CurrentUserEntity(dbID,
                                         name=name,
                                         clanInfo=ClanInfo(
                                             0, clanAbbrev, roleFlags))
            else:
                user = SharedUserEntity(dbID,
                                        name=name,
                                        clanInfo=ClanInfo(
                                            0, clanAbbrev, roleFlags),
                                        gos=gos,
                                        tags={USER_TAG.CLAN_MEMBER})
            members.append(user)

        self.usersStorage.setClanMembersList(members)
        if self.__initSteps & _INIT_STEPS.LIST_INITED != 0:
            g_messengerEvents.users.onClanMembersListChanged()
        return
コード例 #9
0
ファイル: storage__init__.py プロジェクト: aevitas/wotsdk
 def restoreFromCache(self):
     if self.__storageCache:
         return
     from gui.shared.utils import getPlayerDatabaseID, getPlayerName
     self.__storageCache = StorageLocalCache((getPlayerDatabaseID(), getPlayerName(), 'storage'))
     self.__storageCache.onRead += self.__onRead
     self.__storageCache.read()
コード例 #10
0
ファイル: states.py プロジェクト: webiumsk/WOT-0.9.14-CT
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Clan gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request()
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the clan lib...')
             result = yield self.sendRequest(contexts.LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for clan gate', response)
     self.__loginState = nextLoginState
     if self.isLoggedOn():
         self._clanCtrl.onStateUpdated()
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
コード例 #11
0
ファイル: managersvoice_chat.py プロジェクト: aevitas/wotsdk
 def __onPlayerSpeaking(self, accountDBID, isSpeak):
     """
     Raise flash event after receiving notification about player speaking.
     :param accountDBID: player db id
     :param isSpeak: is player speaking
     """
     self.as_onPlayerSpeakS(accountDBID, isSpeak, accountDBID == getPlayerDatabaseID())
コード例 #12
0
ファイル: items.py プロジェクト: webiumsk/WOT-0.9.15.1
 def getPermissions(self, memberDbID=None):
     if memberDbID is None:
         memberDbID = getPlayerDatabaseID()
     if self.hasMember(memberDbID):
         return MemberPermissions(self._clubDescr.members[memberDbID])
     else:
         return DefaultMemberPermissions()
コード例 #13
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Wgcg gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request(allowDelay=True)
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the wgcg lib...')
             responseTime = time_utils.getServerUTCTime()
             result = yield self.sendRequest(
                 LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
                 data = result.getData()
                 self.__accessTokenData = AccessTokenData(
                     data['access_token'],
                     responseTime + float(data['expires_in']))
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for wgcg gate',
                     response)
     self.__loginState = nextLoginState
     self.__clanSync = False
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
コード例 #14
0
ファイル: __init__.py プロジェクト: jamesxia4/wot_client
 def restoreFromCache(self):
     if self.__storageCache:
         return
     from gui.shared.utils import getPlayerDatabaseID, getPlayerName
     self.__storageCache = StorageLocalCache((getPlayerDatabaseID(), getPlayerName(), 'storage'))
     self.__storageCache.onRead += self.__onRead
     self.__storageCache.read()
コード例 #15
0
ファイル: voice_chat.py プロジェクト: webiumsk/WOT-0.9.17-CT
 def __onPlayerSpeaking(self, accountDBID, isSpeak):
     """
     Raise flash event after receiving notification about player speaking.
     :param accountDBID: player db id
     :param isSpeak: is player speaking
     """
     self.as_onPlayerSpeakS(accountDBID, isSpeak, accountDBID == getPlayerDatabaseID())
コード例 #16
0
 def getFullJID(self, databaseID = None):
     if databaseID is None:
         databaseID = getPlayerDatabaseID()
     raise databaseID or AssertionError("Player's databaseID can not be empty")
     jid = ContactJID()
     jid.setNode(databaseID)
     jid.setDomain(self.domain)
     jid.setResource(self.resource)
     return jid
コード例 #17
0
 def getFullJID(self, databaseID=None):
     if databaseID is None:
         databaseID = getPlayerDatabaseID()
     assert databaseID, "Player's databaseID can not be empty"
     jid = ContactJID()
     jid.setNode(databaseID)
     jid.setDomain(self.domain)
     jid.setResource(self.resource)
     return jid
コード例 #18
0
    def _updateInvites(self, invites):
        self._contactsState |= _CONTACTS_LIST.INVITES
        prevInvites = self._invites
        self._invites = {}
        for sendingTime, inviterDbID, clubDbID, status, updatingTime in invites:
            invite = ClubInvite(clubDbID, getPlayerDatabaseID(), inviterDbID, sendingTime, status, updatingTime)
            self._invites[invite.getID()] = invite

        self.__processInvitations(prevInvites)
コード例 #19
0
ファイル: clubscontroller.py プロジェクト: webiumsk/WOT0.9.10
    def _updateInvites(self, invites):
        self._contactsState |= _CONTACTS_LIST.INVITES
        prevInvites = self._invites
        self._invites = {}
        for sendingTime, inviterDbID, clubDbID, status, updatingTime in invites:
            invite = ClubInvite(clubDbID, getPlayerDatabaseID(), inviterDbID, sendingTime, status, updatingTime)
            self._invites[invite.getID()] = invite

        self.__processInvitations(prevInvites)
コード例 #20
0
ファイル: muc.py プロジェクト: webiumsk/WOT-0.9.14-CT
 def __removeMember(self, jid, dbID, nickname):
     _, found = self._searchChannel(jid.getBareJID())
     if dbID:
         leave = utils.getPlayerDatabaseID() == dbID
     else:
         leave = utils.getPlayerName() == nickname
     if leave:
         self._removeChannel(found)
     else:
         found.removeMember(jid)
コード例 #21
0
ファイル: clubscontroller.py プロジェクト: webiumsk/WOT0.9.10
    def _updateApps(self, apps):
        self._apps = {}
        for clubDbID, sendingTime, comment, status, updatingTime in apps:
            app = ClubApplication(clubDbID, getPlayerDatabaseID(), comment, sendingTime, status, updatingTime)
            self._apps[app.getID()] = app

        if not self._isSynced:
            self.__notify('onAccountClubAppsInited', self._apps.values())
        else:
            self.__notify('onAccountClubAppsChanged', self._apps.values())
コード例 #22
0
 def getFullJID(self, databaseID=None):
     if databaseID is None:
         databaseID = getPlayerDatabaseID()
     if not databaseID:
         raise SoftException("Player's databaseID can not be empty")
     jid = ContactJID()
     jid.setNode(databaseID)
     jid.setDomain(self.domain)
     jid.setResource(self.resource)
     return jid
コード例 #23
0
    def _updateApps(self, apps):
        self._apps = {}
        for clubDbID, sendingTime, comment, status, updatingTime in apps:
            app = ClubApplication(clubDbID, getPlayerDatabaseID(), comment, sendingTime, status, updatingTime)
            self._apps[app.getID()] = app

        if not self._isSynced:
            self.__notify('onAccountClubAppsInited', self._apps.values())
        else:
            self.__notify('onAccountClubAppsChanged', self._apps.values())
コード例 #24
0
 def __init__(self):
     super(ClanPersonalInvitesView, self).__init__()
     self._paginator = ClanPersonalInvitesPaginator(self.webCtrl, getPlayerDatabaseID(), [CLAN_INVITE_STATES.ACTIVE])
     self._cooldown = CooldownHelper([WebRequestDataType.ACCEPT_APPLICATION,
      WebRequestDataType.ACCEPT_INVITE,
      WebRequestDataType.DECLINE_APPLICATION,
      WebRequestDataType.DECLINE_INVITE,
      WebRequestDataType.DECLINE_INVITES,
      WebRequestDataType.CLANS_INFO,
      WebRequestDataType.CLAN_RATINGS,
      WebRequestDataType.ACCOUNT_INVITES], self._onCooldownHandle, CoolDownEvent.WGCG)
コード例 #25
0
 def __removeMember(self, jid, dbID, nickname):
     _, found = self._searchChannel(jid.getBareJID())
     if found:
         if dbID:
             leave = utils.getPlayerDatabaseID() == dbID
         else:
             leave = utils.getPlayerName() == nickname
         if leave:
             self._removeChannel(found)
         else:
             found.removeMember(jid)
コード例 #26
0
 def __init__(self):
     super(ClanPersonalInvitesView, self).__init__()
     self._paginator = ClanPersonalInvitesPaginator(g_clanCtrl, getPlayerDatabaseID(), [CLAN_INVITE_STATES.ACTIVE])
     self._cooldown = CooldownHelper([CLAN_REQUESTED_DATA_TYPE.ACCEPT_APPLICATION,
      CLAN_REQUESTED_DATA_TYPE.ACCEPT_INVITE,
      CLAN_REQUESTED_DATA_TYPE.DECLINE_APPLICATION,
      CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITE,
      CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITES,
      CLAN_REQUESTED_DATA_TYPE.CLANS_INFO,
      CLAN_REQUESTED_DATA_TYPE.CLAN_RATINGS,
      CLAN_REQUESTED_DATA_TYPE.ACCOUNT_INVITES], self._onCooldownHandle, CoolDownEvent.CLAN)
コード例 #27
0
ファイル: fallout_controller.py プロジェクト: kblw/wot_client
    def __updateVehicles(self):
        maxVehs = self._proxy.getConfig().maxVehiclesPerPlayer
        valid = [INV_ID_CLEAR_VEHICLE] * maxVehs
        slots = self.__getExtra().accountVehicles.get(getPlayerDatabaseID(), ())
        vehicles = map(lambda (vehInvID, vehIntCD): vehInvID, slots)
        vehGetter = g_itemsCache.items.getVehicle
        for idx, invID in enumerate(vehicles[:maxVehs]):
            invVehicle = vehGetter(invID)
            if invVehicle is not None:
                valid[idx] = invID

        self.__vehicles = valid
コード例 #28
0
ファイル: messages.py プロジェクト: kblw/wot_client
 def sendMessage(self, jid, body, filters):
     channel = self.channelsStorage.getChannel(entities.XMPPChatChannelEntity(jid))
     if channel:
         if self.playerCtx.isBanned(components=XMPP_BAN_COMPONENT.PRIVATE):
             error = createChatBanError(self.playerCtx.getBanInfo())
             if error:
                 g_messengerEvents.onErrorReceived(error)
                 return
         dbID = getPlayerDatabaseID()
         name = getPlayerName()
         g_messengerEvents.channels.onMessageReceived(ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()), channel)
         self.client().sendMessage(ChatMessageHolder(jid, msgBody=body))
コード例 #29
0
ファイル: messages.py プロジェクト: kblw/wot_client
 def _addChannel(self, channel, dbID, name):
     contact = self.usersStorage.getUser(dbID)
     if contact:
         if contact.isIgnored():
             return None
         isOnline = contact.isOnline()
     else:
         isOnline = False
     channel.addMembers([entities.XMPPMemberEntity(getPlayerDatabaseID(), getPlayerName(), True), entities.XMPPMemberEntity(dbID, name, isOnline)])
     if self.channelsStorage.addChannel(channel):
         channel.setStored(True)
         g_messengerEvents.channels.onChannelInited(channel)
     return channel
コード例 #30
0
    def __updateVehicles(self):
        maxVehs = self._proxy.getConfig().maxVehiclesPerPlayer
        valid = [INV_ID_CLEAR_VEHICLE] * maxVehs
        slots = self.__getExtra().accountVehicles.get(getPlayerDatabaseID(),
                                                      ())
        vehicles = map(lambda (vehInvID, vehIntCD): vehInvID, slots)
        vehGetter = g_itemsCache.items.getVehicle
        for idx, invID in enumerate(vehicles[:maxVehs]):
            invVehicle = vehGetter(invID)
            if invVehicle is not None:
                valid[idx] = invID

        self.__vehicles = valid
コード例 #31
0
 def onUnitRosterChanged(self):
     super(FortBattleRoomWindow, self).onUnitRosterChanged()
     chat = self.chat
     if chat:
         _, unit = self.unitFunctional.getUnit()
         commanderID = unit.getCommanderDBID()
         if commanderID != getPlayerDatabaseID():
             getter = storage_getter('users')
             commander = getter().getUser(commanderID)
             division = getDivisionNameByUnit(unit)
             divisionName = i18n.makeString(I18N_SYSTEM_MESSAGES.unit_notification_divisiontype(division))
             key = I18N_SYSTEM_MESSAGES.UNIT_NOTIFICATION_CHANGEDIVISION
             txt = i18n.makeString(key, name=commander.getName(), division=divisionName)
             chat.addNotification(txt)
コード例 #32
0
 def __init__(self):
     super(ClanPersonalInvitesView, self).__init__()
     self._paginator = ClanPersonalInvitesPaginator(
         self.clansCtrl, getPlayerDatabaseID(), [CLAN_INVITE_STATES.ACTIVE])
     self._cooldown = CooldownHelper([
         CLAN_REQUESTED_DATA_TYPE.ACCEPT_APPLICATION,
         CLAN_REQUESTED_DATA_TYPE.ACCEPT_INVITE,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_APPLICATION,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITE,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITES,
         CLAN_REQUESTED_DATA_TYPE.CLANS_INFO,
         CLAN_REQUESTED_DATA_TYPE.CLAN_RATINGS,
         CLAN_REQUESTED_DATA_TYPE.ACCOUNT_INVITES
     ], self._onCooldownHandle, CoolDownEvent.CLAN)
コード例 #33
0
    def getLeaderEventEnqueueData(self):
        selfDBID = getPlayerDatabaseID()
        if self.isCommander(dbID=selfDBID):
            return None
        else:
            unitId, unit = self.getUnit()
            for slot in self.getSlotsIterator(unitId, unit):
                if not slot.player:
                    continue
                dbID = slot.player.dbID
                pInfo = self.getPlayerInfo(dbID=dbID)
                if pInfo.isReady and self.isCommander(dbID=dbID):
                    return pInfo.extraData.get('eventEnqueueData', {})

            return None
コード例 #34
0
ファイル: messages.py プロジェクト: jamesxia4/wot_client
 def sendMessage(self, jid, body, filters):
     channel = self.channelsStorage.getChannel(
         entities.XMPPChatChannelEntity(jid))
     if channel:
         if self.playerCtx.isBanned(components=XMPP_BAN_COMPONENT.PRIVATE):
             error = createChatBanError(self.playerCtx.getBanInfo())
             if error:
                 g_messengerEvents.onErrorReceived(error)
                 return
         dbID = getPlayerDatabaseID()
         name = getPlayerName()
         g_messengerEvents.channels.onMessageReceived(
             ChatMessage(dbID, name, filters.chainIn(dbID, body),
                         time.time()), channel)
         self.client().sendMessage(ChatMessageHolder(jid, msgBody=body))
コード例 #35
0
ファイル: invites.py プロジェクト: kusaku/wot_scripts
    def _getOldInviteMaker(self, rosterGetter):
        receiver = getPlayerName()
        receiverDBID = getPlayerDatabaseID()
        receiverClanAbbrev = self.lobbyContext.getClanAbbrev(self.__clanInfo)

        def _inviteMaker(item):
            (prebattleID, peripheryID), data = item
            inviteID = self._makeInviteID(prebattleID, peripheryID, data['creatorDBID'], receiverDBID)
            if data is not None:
                invite = PrbInviteWrapper(clientID=inviteID, receiver=receiver, receiverDBID=receiverDBID, receiverClanAbbrev=receiverClanAbbrev, peripheryID=peripheryID, prebattleID=prebattleID, **data)
            else:
                invite = None
            return (inviteID, invite)

        return _inviteMaker
コード例 #36
0
ファイル: invites.py プロジェクト: webiumsk/WOT-0.9.15-CT
    def _getOldInviteMaker(self, rosterGetter):
        receiver = getPlayerName()
        receiverDBID = getPlayerDatabaseID()
        receiverClanAbbrev = g_lobbyContext.getClanAbbrev(self.__clanInfo)

        def _inviteMaker(item):
            (prebattleID, peripheryID), data = item
            inviteID = self._makeInviteID(prebattleID, peripheryID, data['creatorDBID'], receiverDBID)
            if data is not None:
                invite = PrbInviteWrapper(clientID=inviteID, receiver=receiver, receiverDBID=receiverDBID, receiverClanAbbrev=receiverClanAbbrev, peripheryID=peripheryID, prebattleID=prebattleID, **data)
            else:
                invite = None
            return (inviteID, invite)

        return _inviteMaker
コード例 #37
0
ファイル: messages.py プロジェクト: jamesxia4/wot_client
 def _addChannel(self, channel, dbID, name):
     contact = self.usersStorage.getUser(dbID)
     if contact:
         if contact.isIgnored():
             return None
         isOnline = contact.isOnline()
     else:
         isOnline = False
     channel.addMembers([
         entities.XMPPMemberEntity(getPlayerDatabaseID(), getPlayerName(),
                                   True),
         entities.XMPPMemberEntity(dbID, name, isOnline)
     ])
     if self.channelsStorage.addChannel(channel):
         channel.setStored(True)
         g_messengerEvents.channels.onChannelInited(channel)
     return channel
コード例 #38
0
 def onUnitRosterChanged(self):
     super(FortBattleRoomWindow, self).onUnitRosterChanged()
     chat = self.chat
     if chat:
         _, unit = self.unitFunctional.getUnit()
         commanderID = unit.getCommanderDBID()
         if commanderID != getPlayerDatabaseID():
             getter = storage_getter('users')
             commander = getter().getUser(commanderID)
             division = getDivisionNameByUnit(unit)
             divisionName = i18n.makeString(
                 I18N_SYSTEM_MESSAGES.unit_notification_divisiontype(
                     division))
             key = I18N_SYSTEM_MESSAGES.UNIT_NOTIFICATION_CHANGEDIVISION
             txt = i18n.makeString(key,
                                   name=commander.getName(),
                                   division=divisionName)
             chat.addNotification(txt)
コード例 #39
0
ファイル: clan_helpers.py プロジェクト: webiumsk/WOT-0.9.12
 def __sendRequest(self, invite, context, sucessStatus):
     self.__sentRequestCount += 1
     userDbID = getPlayerDatabaseID()
     temp = self.__accountNameMapping.get(userDbID, set())
     temp.add(invite.getDbID())
     self.__accountNameMapping[userDbID] = temp
     result = yield self._requester.sendRequest(context, allowDelay=True)
     if result.isSuccess():
         status = sucessStatus
     else:
         status = CLAN_INVITE_STATES.ERROR
     result, users = yield self._requester.requestUsers([userDbID])
     sender = users.get(userDbID, items.AccountClanRatingsData(userDbID))
     senderName = self.getUserName(userDbID)
     item = self.__updateInvite(invite, status, sender, senderName)
     self.syncUsersInfo()
     self.__sentRequestCount -= 1
     self.onListItemsUpdated(self, [item])
コード例 #40
0
ファイル: muc.py プロジェクト: webiumsk/WOT-0.9.15.1
 def setPresence(self, jid, dbID, nickname, presence, mucInfo):
     result = False
     if self._step == ENTRY_STEP.UNDEFINED:
         return result
     else:
         if jid.getBareJID() == self._room.getID():
             result = True
             if presence in PRESENCE.OFFLINE:
                 self._room.removeMember(jid)
                 if jid == self._getUserJID():
                     self._leave(mucInfo)
             else:
                 if not dbID and mucInfo is not None and MUC_STATUS.SELF_PRESENCE in mucInfo.statuses:
                     dbID = utils.getPlayerDatabaseID()
                 self._room.addMember(entities.XMPPMUCOccupant(jid, nickname, dbID, presence, mucInfo))
                 if jid == self._getUserJID():
                     self._join(mucInfo)
         return result
コード例 #41
0
 def setPresence(self, jid, dbID, nickname, presence, mucInfo):
     result = False
     if self._step == ENTRY_STEP.UNDEFINED:
         return result
     else:
         if jid.getBareJID() == self._room.getID():
             result = True
             if presence in PRESENCE.OFFLINE:
                 self._room.removeMember(jid)
                 if jid == self._getUserJID():
                     self._leave(mucInfo)
             else:
                 if not dbID and mucInfo is not None and MUC_STATUS.SELF_PRESENCE in mucInfo.statuses:
                     dbID = utils.getPlayerDatabaseID()
                 self._room.addMember(entities.XMPPMUCOccupant(jid, nickname, dbID, presence, mucInfo))
                 if jid == self._getUserJID():
                     self._join(mucInfo)
         return result
コード例 #42
0
 def __setClanInfo(self, info):
     if info:
         length = len(info)
     else:
         length = 0
     if length > 1:
         abbrev = info[1]
     else:
         abbrev = ""
     if length > 3:
         role = info[3]
     else:
         role = 0
     clanInfo = ClanInfo(abbrev=abbrev, role=role)
     self.playerCtx._setClanInfo(clanInfo)
     user = self.usersStorage.getUser(getPlayerDatabaseID())
     if user:
         user.update(clanInfo=clanInfo)
         user.addTags({USER_TAG.CLAN_MEMBER})
コード例 #43
0
 def __setClanInfo(self, info):
     if info:
         length = len(info)
     else:
         length = 0
     if length > 1:
         abbrev = info[1]
     else:
         abbrev = ''
     if length > 3:
         role = info[3]
     else:
         role = 0
     clanInfo = ClanInfo(abbrev=abbrev, role=role)
     self.playerCtx._setClanInfo(clanInfo)
     user = self.usersStorage.getUser(getPlayerDatabaseID())
     if user:
         user.update(clanInfo=clanInfo)
         user.addTags({USER_TAG.CLAN_MEMBER})
コード例 #44
0
    def handlePresence(self, jid, resource):
        result = False
        presence = resource.presence
        if not self.__isAccountInited and utils.getPlayerDatabaseID() == resource.getWgDatabaseID() and presence == PRESENCE.AVAILABLE:
            self.release(excludeLazy=True)
            self.__isAccountInited = True
        if g_settings.server.XMPP.isMucServiceAllowed(hostname=jid.getDomain()):
            mucInfo = resource.getMucInfo()
            dbID = resource.getWgDatabaseID()
            nickname = resource.getWgNickname() or jid.getResource()
            for action in self.__actions.itervalues():
                result |= action.setPresence(jid, dbID, nickname, presence, mucInfo)

            if not result:
                if presence in PRESENCE.OFFLINE:
                    self.__removeMember(jid, dbID, nickname)
                else:
                    self.__addMember(jid, dbID, nickname, presence, mucInfo)
            self.__filterActions()
        return result
コード例 #45
0
ファイル: extplayer_helpers.py プロジェクト: aevitas/wotsdk
 def __setClanInfo(self, info):
     if info:
         length = len(info)
     else:
         length = 0
     if length > _CLAN_INFO_ABBREV_INDEX:
         abbrev = info[_CLAN_INFO_ABBREV_INDEX]
     else:
         abbrev = ''
     if length > _CLAN_INFO_ROLE_INDEX:
         role = info[_CLAN_INFO_ROLE_INDEX]
     else:
         role = 0
     clanDBID = g_itemsCache.items.stats.clanDBID
     clanInfo = ClanInfo(dbID=clanDBID, abbrev=abbrev, role=role)
     self.playerCtx.setClanInfo(clanInfo)
     user = self.usersStorage.getUser(getPlayerDatabaseID())
     if user:
         user.update(clanInfo=clanInfo)
         user.addTags({USER_TAG.CLAN_MEMBER})
コード例 #46
0
 def __setClanInfo(self, info):
     if info:
         length = len(info)
     else:
         length = 0
     if length > _CLAN_INFO_ABBREV_INDEX:
         abbrev = info[_CLAN_INFO_ABBREV_INDEX]
     else:
         abbrev = ''
     if length > _CLAN_INFO_ROLE_INDEX:
         role = info[_CLAN_INFO_ROLE_INDEX]
     else:
         role = 0
     clanDBID = self.itemsCache.items.stats.clanDBID
     clanInfo = ClanInfo(dbID=clanDBID, abbrev=abbrev, role=role)
     self.playerCtx.setClanInfo(clanInfo)
     user = self.usersStorage.getUser(getPlayerDatabaseID())
     if user:
         user.update(clanInfo=clanInfo)
         user.addTags({USER_TAG.CLAN_MEMBER})
コード例 #47
0
 def __sendRequest(self, invite, context, successStatus):
     self.__sentRequestCount += 1
     userDbID = getPlayerDatabaseID()
     temp = self.__accountNameMapping.get(userDbID, set())
     temp.add(invite.getDbID())
     self.__accountNameMapping[userDbID] = temp
     result = yield self._requester.sendRequest(context, allowDelay=True)
     if result.isSuccess():
         status = (successStatus, None)
     else:
         status = (CLAN_INVITE_STATES.ERROR, result.getCode())
     result, users = yield self._requester.requestUsers([userDbID])
     sender = users.get(userDbID, items.AccountClanRatingsData(userDbID))
     senderName = self.getUserName(userDbID)
     changerName = getPlayerName()
     item = self.__updateInvite(invite, status, sender, senderName, changerName)
     self.syncUsersInfo()
     self.__sentRequestCount -= 1
     self.onListItemsUpdated(self, [item])
     return
コード例 #48
0
ファイル: xmppconnection.py プロジェクト: aevitas/wotsdk
 def __doLogin(self):
     client = self.client()
     if not client.isConnecting():
         g_logOutput.warning(CLIENT_LOG_AREA.LOGIN, 'Client is not connecting', client.getConnectionAddress(), client.getConnectionState())
         yield lambda callback: callback(None)
         return
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN, 'Sends request to SPA')
     response = yield self.__tokenRequester.request()
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN, 'Response is received from SPA', response)
     if not response:
         g_logOutput.error(CLIENT_LOG_AREA.TOKEN, 'Received chat token is empty')
         return
     if response.isValid():
         if response.getDatabaseID() == getPlayerDatabaseID():
             g_logOutput.debug(CLIENT_LOG_AREA.LOGIN, 'Login to XMPP sever')
             client.login(response.getCredential())
         else:
             g_logOutput.error(CLIENT_LOG_AREA.LOGIN, "Player's database ID mismatch", getPlayerDatabaseID())
     else:
         g_logOutput.warning(CLIENT_LOG_AREA.TOKEN, 'Received chat token is not valid', response)
         self.__handleTokenError()
コード例 #49
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     else:
         self.__accessTokenData = None
         LOG_DEBUG('Clan gate login processing...')
         self.__loginState = LOGIN_STATE.LOGGING_IN
         nextLoginState = LOGIN_STATE.LOGGED_OFF
         LOG_DEBUG('Requesting spa token...')
         response = yield self._tokenRequester.request(allowDelay=True)
         if response and response.isValid():
             pDbID = getPlayerDatabaseID()
             if response.getDatabaseID() == pDbID:
                 LOG_DEBUG('Trying to login to the clan lib...')
                 responseTime = time_utils.getCurrentTimestamp()
                 result = yield self.sendRequest(contexts.LogInCtx(pDbID, response.getToken()))
                 if result.isSuccess():
                     nextLoginState = LOGIN_STATE.LOGGED_ON
                     data = result.getData()
                     accessToken = data.get(_FIELD_ACCESS_TOKEN, None)
                     if accessToken is not None:
                         expiresIn = data.get(_FIELD_EXPIRES_IN, 0)
                         if expiresIn is None:
                             LOG_WARNING('Login success but ExpiresIn not defined! Use default value == 0!')
                         else:
                             responseTime += float(expiresIn)
                         self.__accessTokenData = AccessTokenData(accessToken, responseTime)
                     else:
                         LOG_WARNING('Login success but AccessToken not defined!')
                 else:
                     nextLoginState = LOGIN_STATE.LOGGED_OFF
         else:
             LOG_WARNING('There is error while getting spa token for clan gate', response)
         self.__loginState = nextLoginState
         self.__clanSync = False
         self.__processWaitingRequests()
         callback(self.isLoggedOn())
         return
コード例 #50
0
def _getInfo4AccountPlayer():
    return (getPlayerDatabaseID(), getPlayerName(), None)
コード例 #51
0
def isCurrentPlayer(dbID):
    return getPlayerDatabaseID() == dbID
コード例 #52
0
ファイル: bwusersmanager.py プロジェクト: aevitas/wotsdk
 def __ce_onConnectStateChanged(self, channel):
     if self.__isPrivateOpen and channel.isJoined() and channel.isPrivate() and channel.getProtoType() == PROTO_TYPE.BW and channel.getProtoData().owner == getPlayerDatabaseID():
         g_messengerEvents.channels.onPlayerEnterChannelByAction(channel)
コード例 #53
0
ファイル: invites.py プロジェクト: webiumsk/WOT-0.9.15-CT
 def canRevokeInvite(self, invite):
     result = False
     if invite.clientID in self.__invites:
         result = invite.clientID > 0 and invite.isActive() and invite.creatorDBID == getPlayerDatabaseID()
     return result
コード例 #54
0
ファイル: invites.py プロジェクト: webiumsk/WOT-0.9.15-CT
 def isIncoming(self):
     return self.ownerDBID != getPlayerDatabaseID()
コード例 #55
0
ファイル: entities.py プロジェクト: webiumsk/WOT-0.9.12
 def getName(self):
     channelName = self._data.channelName
     if getPlayerDatabaseID() != self._data.owner:
         channelName = passCensor(channelName)
     return cgi.escape(channelName)
コード例 #56
0
ファイル: items.py プロジェクト: webiumsk/WOT0.9.10
 def getMember(self, memberDbID = None):
     memberDbID = memberDbID or getPlayerDatabaseID()
     if self.hasMember(memberDbID):
         return self.__makeMemberItem(memberDbID, self._clubDescr.members[memberDbID])
     else:
         return None
コード例 #57
0
def isCurrentPlayer(dbID):
    return getPlayerDatabaseID() == dbID
コード例 #58
0
ファイル: xmppconnection.py プロジェクト: aevitas/wotsdk
 def getPlayerFullJID(self):
     return g_settings.server.XMPP.getFullJID(getPlayerDatabaseID())
コード例 #59
0
 def __init__(self):
     super(ClanPersonalInvitesView, self).__init__()
     self._paginator = ClanPersonalInvitesPaginator(g_clanCtrl, getPlayerDatabaseID(), [CLAN_INVITE_STATES.ACTIVE])
     self._cooldown = CooldownHelper(self.__coolDownRequests, self._onCooldownHandle, CoolDownEvent.CLAN)