示例#1
0
 def createRoom(self,
                name,
                password='',
                initResult=ACTION_RESULT.SHOW_ROOM):
     roomJID = jid_entity.makeUserRoomJID()
     if not roomJID:
         return (False,
                 ClientActionError(CLIENT_ACTION_ID.CREATE_USER_ROOM,
                                   CLIENT_ERROR_ID.NOT_SUPPORTED))
     else:
         exists = self.getChannelByName(name)
         if exists is not None:
             return (False,
                     ClientChannelError(
                         CHANNEL_ERROR_ID.NAME_ALREADY_EXISTS, name))
         if roomJID not in self.__actions:
             from gui.shared.utils import getPlayerName
             name = '{0} ({1})'.format(name, getPlayerName())
             action = CreateAction(roomJID, name, password, initResult)
             self.__actions[roomJID] = action
             action.start()
         else:
             return (False,
                     ClientActionError(CLIENT_ACTION_ID.CREATE_USER_ROOM,
                                       CLIENT_ERROR_ID.LOCKED))
         return (True, None)
示例#2
0
 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()
 def _packBlocks(self, badgeID):
     blocks = super(BadgeTooltipData, self)._packBlocks()
     badge = self._context.buildItem(badgeID)
     paramsConfig = self._context.getParamsConfiguration(badge)
     if badge is None:
         _logger.warning(
             'Missing tooltip text for %r, please check badge.po',
             int(badgeID))
         return blocks
     else:
         tooltipData = [
             formatters.packTextBlockData(
                 text_styles.highTitle(badge.getUserName())),
             formatters.packImageBlockData(
                 badge.getHugeIcon(),
                 BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER,
                 padding=formatters.packPadding(top=-5, bottom=11))
         ]
         if g_currentVehicle.isPresent() and paramsConfig.showVehicle:
             vehicle = g_currentVehicle.item
             tooltipData.append(
                 formatters.packBadgeInfoBlockData(
                     badge.getThumbnailIcon(), vehicle.iconContour,
                     text_styles.bonusPreviewText(getPlayerName()),
                     text_styles.bonusPreviewText(vehicle.shortUserName)))
         blocks.append(formatters.packBuildUpBlockData(tooltipData))
         blocks.append(
             formatters.packTextBlockData(
                 text_styles.main(badge.getUserDescription())))
         return blocks
示例#4
0
 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()
示例#5
0
 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)
示例#6
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)
示例#7
0
 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))
 def _onLoading(self, playerPosition, rewardsData, *args, **kwargs):
     super(YearLeaderboardView, self)._onLoading(*args, **kwargs)
     defaultBG = R.images.gui.maps.icons.rankedBattles.yearLeaderboardReward.bg_default
     overrideBG = R.images.gui.maps.icons.rankedBattles.yearLeaderboardReward.dyn(
         'bg_' + CURRENT_REALM, defaultBG)
     with self.viewModel.transaction() as model:
         model.setPlayerName(getPlayerName())
         model.setPlayerClan(self.__getClanAbbrev())
         model.setPositionsTotal(self.__rankedController.getYearLBSize())
         model.setPosition(playerPosition)
         model.setRewardId(_extractReward(rewardsData))
         model.setBgImage(overrideBG())
示例#9
0
 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
示例#10
0
    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
示例#11
0
 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))
示例#12
0
    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
示例#13
0
 def createRoom(self, name, password = '', initResult = ACTION_RESULT.SHOW_ROOM):
     roomJID = jid_entity.makeUserRoomJID()
     if not roomJID:
         return (False, ClientActionError(CLIENT_ACTION_ID.CREATE_USER_ROOM, CLIENT_ERROR_ID.NOT_SUPPORTED))
     else:
         exists = self.getChannelByName(name)
         if exists is not None:
             return (False, ClientChannelError(CHANNEL_ERROR_ID.NAME_ALREADY_EXISTS, name))
         if roomJID not in self.__actions:
             from gui.shared.utils import getPlayerName
             name = '{0} ({1})'.format(name, getPlayerName())
             action = CreateAction(roomJID, name, password, initResult)
             self.__actions[roomJID] = action
             action.start()
         else:
             return (False, ClientActionError(CLIENT_ACTION_ID.CREATE_USER_ROOM, CLIENT_ERROR_ID.LOCKED))
         return (True, None)
示例#14
0
 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
示例#15
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
示例#16
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
 def _packBlocks(self, badgeID):
     blocks = super(BadgeTooltipData, self)._packBlocks()
     badge = self.__itemsCache.items.getBadges()[badgeID]
     tooltipData = [
         formatters.packTextBlockData(
             text_styles.highTitle(badge.getUserName())),
         formatters.packImageBlockData(badge.getHugeIcon(),
                                       BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER,
                                       padding=formatters.packPadding(
                                           top=-5, bottom=11))
     ]
     if g_currentVehicle.isPresent():
         vehicle = g_currentVehicle.item
         tooltipData.append(
             formatters.packBadgeInfoBlockData(
                 badge.getThumbnailIcon(), vehicle.iconContour,
                 text_styles.bonusPreviewText(getPlayerName()),
                 text_styles.bonusPreviewText(vehicle.shortUserName)))
     blocks.append(formatters.packBuildUpBlockData(tooltipData))
     blocks.append(
         formatters.packTextBlockData(
             text_styles.main(TOOLTIPS.PERSONALMISSIONS_BADGE_DESCR)))
     return blocks
示例#18
0
        g_messengerEvents.channels.onMessageReceived(
            ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()),
            channel)

    def __addSession(self, session, contactDBID=0L, byAction=False):
        jid = session.getID()
        presence = PRESENCE.UNAVAILABLE
        if contactDBID:
            contact = self.usersStorage.getUser(contactDBID)
            if contact is not None:
                if contact.isIgnored():
                    return False
                if contact.isOnline():
                    presence = PRESENCE.AVAILABLE
                else:
                    presence = PRESENCE.UNAVAILABLE
        userDBID = utils.getPlayerDatabaseID()
        session.setUser(jid_entity.makeContactJID(userDBID),
                        utils.getPlayerName())
        session.setContact(jid, presence, contactDBID)
        super(ChatSessionsProvider, self)._addChannel(session, byAction)
        return True

    def __removeSession(self, session):
        super(ChatSessionsProvider, self)._removeChannel(session)


# okay decompyling c:\Users\PC\wotmods\files\originals\res\packages\scripts\scripts\client\messenger\proto\xmpp\messages\chat_session.pyc
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2017.08.29 21:51:27 Støední Evropa (letní èas)
示例#19
0
def _getInfo4AccountPlayer():
    return (getPlayerDatabaseID(), getPlayerName(), None)
示例#20
0
        return (created, exists)

    def _repeatMessage(self, channel, body, filters):
        dbID = utils.getPlayerDatabaseID()
        name = utils.getPlayerName()
        g_messengerEvents.channels.onMessageReceived(ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()), channel)

    def __addSession(self, session, contactDBID = 0L, byAction = False):
        jid = session.getID()
        presence = PRESENCE.UNAVAILABLE
        if contactDBID:
            contact = self.usersStorage.getUser(contactDBID)
            if contact is not None:
                if contact.isIgnored():
                    return False
                if contact.isOnline():
                    presence = PRESENCE.AVAILABLE
                else:
                    presence = PRESENCE.UNAVAILABLE
        userDBID = utils.getPlayerDatabaseID()
        session.setUser(jid_entity.makeContactJID(userDBID), utils.getPlayerName())
        session.setContact(jid, presence, contactDBID)
        super(ChatSessionsProvider, self)._addChannel(session, byAction)
        return True

    def __removeSession(self, session):
        super(ChatSessionsProvider, self)._removeChannel(session)
# okay decompyling c:\Users\PC\wotsources\files\originals\res\scripts\client\messenger\proto\xmpp\messages\chat_session.pyc 
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2016.05.01 15:25:18 Støední Evropa (letní èas)
示例#21
0
 def _getUserJID(self):
     jid = jid_entity.JID(self._room.getID())
     jid.setResource(utils.getPlayerName())
     return jid
示例#22
0
 def _repeatMessage(self, channel, body, filters):
     dbID = utils.getPlayerDatabaseID()
     name = utils.getPlayerName()
     g_messengerEvents.channels.onMessageReceived(ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()), channel)
 def _repeatMessage(self, channel, body, filters):
     dbID = utils.getPlayerDatabaseID()
     name = utils.getPlayerName()
     g_messengerEvents.channels.onMessageReceived(ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()), channel)
示例#24
0
 def _getUserJID(self):
     jid = jid_entity.JID(self._room.getID())
     jid.setResource(utils.getPlayerName())
     return jid
示例#25
0
def _getInfo4AccountPlayer():
    return (getPlayerDatabaseID(), getPlayerName(), None)
    def _searchChannel(self, jid, name=''):
        created = entities.XMPPChatChannelEntity(jid, name=name)
        exists = self.channelsStorage.getChannel(created)
        return (created, exists)

    def _repeatMessage(self, channel, body, filters):
        dbID = utils.getPlayerDatabaseID()
        name = utils.getPlayerName()
        g_messengerEvents.channels.onMessageReceived(ChatMessage(dbID, name, filters.chainIn(dbID, body), time.time()), channel)

    def __addSession(self, session, contactDBID=0L, byAction=False):
        jid = session.getID()
        presence = PRESENCE.UNAVAILABLE
        if contactDBID:
            contact = self.usersStorage.getUser(contactDBID)
            if contact is not None:
                if contact.isIgnored():
                    return False
                if contact.isOnline():
                    presence = PRESENCE.AVAILABLE
                else:
                    presence = PRESENCE.UNAVAILABLE
        userDBID = utils.getPlayerDatabaseID()
        session.setUser(jid_entity.makeContactJID(userDBID), utils.getPlayerName())
        session.setContact(jid, presence, contactDBID)
        super(ChatSessionsProvider, self)._addChannel(session, byAction)
        return True

    def __removeSession(self, session):
        super(ChatSessionsProvider, self)._removeChannel(session)