Пример #1
0
 def addMessage(self, jid, message):
     if message.isHistory():
         self.__historyRQ.addHistory(message)
         return
     else:
         contactDBID = message.accountDBID or jid.getDatabaseID()
         nickname = message.accountName or jid.getNode()
         created, exists = self._searchChannel(jid, nickname)
         if exists is None and g_settings.userPrefs.chatContactsListOnly:
             contact = self.usersStorage.getUser(contactDBID)
             if not contact or not USER_TAG.filterClosedContactsTags(
                     contact.getTags()):
                 g_logOutput.debug(
                     CLIENT_LOG_AREA.MESSAGE,
                     "There is not closed contact in player's contacts list,contact's message is ignored",
                     jid, nickname)
                 return
         if exists is None:
             if self.__addSession(created, contactDBID):
                 exists = created
             else:
                 return
         if message.body:
             g_messengerEvents.channels.onMessageReceived(message, exists)
         return
Пример #2
0
 def getPersistentState(self):
     state = None
     tags = USER_TAG.filterToStoreTags(self.getTags())
     if self._databaseID and (self._item.isTrusted() or tags):
         state = (self._name, self._item.getItemType(),
                  tags if tags else None)
     return state
Пример #3
0
 def addMessage(self, jid, message):
     if message.isHistory():
         self.__historyRQ.addHistory(message)
         return
     dbID = message.accountDBID
     name = message.accountName
     if jid not in self.__sessions and g_settings.userPrefs.chatContactsListOnly:
         contact = self.usersStorage.getUser(dbID)
         if not contact or not USER_TAG.filterClosedContactsTags(contact.getTags()):
             g_logOutput.debug(
                 CLIENT_LOG_AREA.MESSAGE,
                 "There is not closed contact in player's contacts list,contact's message is ignored",
                 jid,
                 name,
             )
             return
     search = entities.XMPPChatChannelEntity(jid, name)
     channel = self.channelsStorage.getChannel(search)
     if not channel:
         channel = self._addChannel(search, dbID, name)
         if not channel:
             return
         self.__sessions.add(jid)
     if message.body:
         g_messengerEvents.channels.onMessageReceived(message, channel)
Пример #4
0
 def update(self, **kwargs):
     if 'item' in kwargs:
         self._item = self._item.replace(kwargs['item'])
     if 'gosBit' in kwargs and USER_TAG.filterSharedTags(self._tags):
         self._gos = GAME_ONLINE_STATUS.update(self._gos, kwargs['gosBit'])
     self._item.update(**kwargs)
     super(XMPPUserEntity, self).update(**kwargs)
Пример #5
0
 def update(self, **kwargs):
     if 'item' in kwargs:
         self._item = self._item.replace(kwargs['item'])
     if 'gosBit' in kwargs and USER_TAG.filterSharedTags(self._tags):
         self._gos = GAME_ONLINE_STATUS.update(self._gos, kwargs['gosBit'])
     self._item.update(**kwargs)
     super(XMPPUserEntity, self).update(**kwargs)
Пример #6
0
 def setSharedProps(self, other):
     self.update(clanInfo=other.getClanInfo(),
                 globalRating=other.getGlobalRating(),
                 note=other.getNote())
     tags = USER_TAG.filterSharedTags(other.getTags())
     if tags:
         self.addTags(tags)
     return True
Пример #7
0
 def setSharedProps(self, other):
     result = super(XMPPUserEntity, self).setSharedProps(other)
     if result and other.getProtoType() == PROTO_TYPE.XMPP:
         if USER_TAG.CACHED in self.getTags():
             self.update(name=other.getName(), item=other.getItem())
         elif USER_TAG.CACHED in other.getTags() and other.isMuted():
             self.addTags({USER_TAG.MUTED})
     if USER_TAG.filterSharedTags(self._tags):
         self._gos = other.getGOS()
     return result
Пример #8
0
 def setSharedProps(self, other):
     result = super(XMPPUserEntity, self).setSharedProps(other)
     if result and other.getProtoType() == PROTO_TYPE.XMPP:
         if USER_TAG.CACHED in self.getTags():
             self.update(name=other.getName(), item=other.getItem())
         elif USER_TAG.CACHED in other.getTags() and other.isMuted():
             self.addTags({USER_TAG.MUTED})
     if USER_TAG.filterSharedTags(self._tags):
         self._gos = other.getGOS()
     return result
    def hasUntrustedMembers(self):
        getter = self.usersStorage.getUser
        for member in self._channel.getMembers():
            user = getter(member.getID().getDatabaseID())
            if user is None:
                return True
            if user.isCurrentPlayer():
                continue
            if not USER_TAG.filterClosedContactsTags(user.getTags()):
                return True

        return False
Пример #10
0
 def onMessageReceived(self, jid, body, _, info, sentAt):
     dbID = info['dbID']
     name = info['name']
     if jid not in self.__sessions and g_settings.userPrefs.chatContactsListOnly:
         contact = self.usersStorage.getUser(dbID)
         if not contact or not USER_TAG.filterClosedContactsTags(contact.getTags()):
             g_logOutput.debug(CLIENT_LOG_AREA.MESSAGE, "There is not closed contact in player's contacts list,contact's massage is ignored", jid, name)
             return
     search = entities.XMPPChatChannelEntity(jid, name)
     channel = self.channelsStorage.getChannel(search)
     if not channel:
         channel = self._addChannel(search, dbID, name, True)
         if not channel:
             return
         self.__sessions.add(jid)
     if body:
         g_messengerEvents.channels.onMessageReceived(XMPPMessageData(dbID, name, body, sentAt), channel)
Пример #11
0
 def addMessage(self, jid, message):
     if message.isHistory():
         self.__historyRQ.addHistory(message)
         return
     else:
         contactDBID = message.accountDBID or jid.getDatabaseID()
         nickname = message.accountName or jid.getNode()
         created, exists = self._searchChannel(jid, nickname)
         if exists is None and g_settings.userPrefs.chatContactsListOnly:
             contact = self.usersStorage.getUser(contactDBID)
             if not contact or not USER_TAG.filterClosedContactsTags(contact.getTags()):
                 g_logOutput.debug(CLIENT_LOG_AREA.MESSAGE, "There is not closed contact in player's contacts list,contact's message is ignored", jid, nickname)
                 return
         if exists is None:
             if self.__addSession(created, contactDBID):
                 exists = created
             else:
                 return
         if message.body:
             g_messengerEvents.channels.onMessageReceived(message, exists)
         return
Пример #12
0
 def addMessage(self, jid, message):
     if message.isHistory():
         self.__historyRQ.addHistory(message)
         return
     dbID = message.accountDBID
     name = message.accountName
     if jid not in self.__sessions and g_settings.userPrefs.chatContactsListOnly:
         contact = self.usersStorage.getUser(dbID)
         if not contact or not USER_TAG.filterClosedContactsTags(
                 contact.getTags()):
             g_logOutput.debug(
                 CLIENT_LOG_AREA.MESSAGE,
                 "There is not closed contact in player's contacts list,contact's message is ignored",
                 jid, name)
             return
     search = entities.XMPPChatChannelEntity(jid, name)
     channel = self.channelsStorage.getChannel(search)
     if not channel:
         channel = self._addChannel(search, dbID, name)
         if not channel:
             return
         self.__sessions.add(jid)
     if message.body:
         g_messengerEvents.channels.onMessageReceived(message, channel)
Пример #13
0
def canNoteAutoDelete(contact):
    return contact.getNote() and not USER_TAG.filterSharedTags(contact.getTags())
Пример #14
0
def canNoteAutoDelete(contact):
    return contact.getNote() and not USER_TAG.filterSharedTags(contact.getTags())
 def reduce(self):
     keys = self.__contacts.keys()
     for key in keys:
         user = self.__contacts[key]
         if USER_TAG.filterToRemoveTags(user.getTags()):
             self.__contacts.pop(key)
Пример #16
0
 def setSharedProps(self, other):
     self.update(clanInfo=other.getClanInfo(), globalRating=other.getGlobalRating(), note=other.getNote())
     tags = USER_TAG.filterSharedTags(other.getTags())
     if tags:
         self.addTags(tags)
     return True
Пример #17
0
 def getPersistentState(self):
     state = None
     tags = USER_TAG.filterToStoreTags(self.getTags())
     if self._databaseID and (self._item.isTrusted() or tags):
         state = (self._name, self._item.getItemType(), tags if tags else None)
     return state
Пример #18
0
 def __me_onUsersListReceived(self, tags):
     if USER_TAG.includeToContactsList(tags):
         self._invokeListenersMethod('invalidateUsersTags')