예제 #1
0
 def addIgnored(self, dbID, name):
     error = self._checkCooldown(CLIENT_ACTION_ID.ADD_IGNORED)
     if error:
         return (False, error)
     tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if contact:
         if contact.isCurrentPlayer():
             return (False,
                     ClientActionError(CLIENT_ACTION_ID.ADD_IGNORED,
                                       CLIENT_ERROR_ID.GENERIC))
         itemType = contact.getItemType()
         if itemType in XMPP_ITEM_TYPE.BLOCK_ITEMS:
             return (False,
                     ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_EXISTS,
                                        contact.getFullName()))
     length = self.usersStorage.getCount(
         ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
     if length >= CONTACT_LIMIT.BLOCK_MAX_COUNT:
         return (False,
                 ClientIntLimitError(LIMIT_ERROR_ID.MAX_BLOCK_ITEMS,
                                     CONTACT_LIMIT.BLOCK_MAX_COUNT))
     if contact:
         jid = contact.getJID()
         if itemType in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS:
             tasks.append(sub_tasks.CancelSubscriptionTask(jid))
     else:
         jid = makeContactJID(dbID)
     tasks.append(block_tasks.AddBlockItemTask(jid, name))
     if itemType in XMPP_ITEM_TYPE.ROSTER_ITEMS:
         groups = contact.getGroups()
         if groups:
             tasks.append(roster_tasks.EmptyGroupsTask(jid, groups=groups))
     self.__cooldown.process(CLIENT_ACTION_ID.ADD_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.ADD_IGNORED, jid, *tasks)
예제 #2
0
파일: __init__.py 프로젝트: webiumsk/WoT
 def addIgnored(self, dbID, name):
     error = self.__checkCooldown(CLIENT_ACTION_ID.ADD_IGNORED)
     if error:
         return (False, error)
     tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if contact:
         if contact.isCurrentPlayer():
             return (False, ClientActionError(CLIENT_ACTION_ID.ADD_FRIEND, CLIENT_ERROR_ID.GENERIC))
         itemType = contact.getItemType()
         if itemType == XMPP_ITEM_TYPE.BLOCK_ITEM:
             return (False, ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_EXISTS, contact.getFullName()))
     length = self.usersStorage.getCount(ItemsFindCriteria(XMPP_ITEM_TYPE.BLOCKING_LIST))
     if length >= CONTACT_LIMIT.BLOCK_MAX_COUNT:
         return (False, ClientIntLimitError(LIMIT_ERROR_ID.MAX_BLOCK_ITEMS, CONTACT_LIMIT.BLOCK_MAX_COUNT))
     if contact:
         jid = contact.getJID()
         if itemType == XMPP_ITEM_TYPE.SUB_PENDING:
             tasks.append(sub_tasks.CancelSubscriptionTask(jid))
     else:
         jid = makeContactJID(dbID)
     tasks.append(block_tasks.AddBlockItemTask(jid, name))
     if itemType == XMPP_ITEM_TYPE.ROSTER_ITEM:
         groups = contact.getGroups()
         if groups:
             tasks.append(roster_tasks.EmptyGroupsTask(jid, groups=groups))
     self.__cooldown.process(CLIENT_ACTION_ID.ADD_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.ADD_IGNORED, jid, *tasks)
예제 #3
0
def createItem(databaseID, itemType = XMPP_ITEM_TYPE.EMPTY_ITEM, trusted = True):
    jid = makeContactJID(databaseID)
    if itemType in _SUPPORTED_ITEM_TYPE_TO_CLASS:
        clazz = _SUPPORTED_ITEM_TYPE_TO_CLASS[itemType]
        item = clazz(jid, trusted=trusted)
    else:
        item = ContactItem(jid)
    return item
예제 #4
0
def createItem(databaseID, itemType=XMPP_ITEM_TYPE.EMPTY_ITEM, trusted=True):
    jid = makeContactJID(databaseID)
    if itemType in _SUPPORTED_ITEM_TYPE_TO_CLASS:
        clazz = _SUPPORTED_ITEM_TYPE_TO_CLASS[itemType]
        item = clazz(jid, trusted=trusted)
    else:
        item = ContactItem(jid)
    return item
    def addFriend(self, dbID, name, group=None, shadowMode=False):
        error = self._checkCooldown(CLIENT_ACTION_ID.ADD_FRIEND)
        if error and not shadowMode:
            return (False, error)
        else:
            if group:
                if not self.usersStorage.isGroupExists(group):
                    return (False, ClientContactError(CONTACT_ERROR_ID.GROUP_NOT_FOUND, group))
                groups = {group}
            else:
                groups = None
            contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
            tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
            if contact:
                if contact.isCurrentPlayer():
                    return (False, ClientActionError(CLIENT_ACTION_ID.ADD_FRIEND, CLIENT_ERROR_ID.GENERIC))
                jid = contact.getJID()
                itemType = contact.getItemType()
                if itemType in XMPP_ITEM_TYPE.ROSTER_ITEMS:
                    return (False, ClientContactError(CONTACT_ERROR_ID.ROSTER_ITEM_EXISTS, contact.getFullName()))
                subTo = contact.getSubscription()[0]
            else:
                jid = makeContactJID(dbID)
                subTo = _SUB.OFF
            result, error = self.__subsRestrictions.canAddFriends()
            if not result:
                return (False, error)
            if itemType == XMPP_ITEM_TYPE.BLOCK_ITEM:
                tasks.append(block_tasks.RemoveBlockItemTask(jid, name))
                tasks.append(roster_tasks.AddRosterItemTask(jid, name, groups))
            elif itemType == XMPP_ITEM_TYPE.ROSTER_BLOCK_ITEM:
                tasks.append(block_tasks.RemoveBlockItemTask(jid, name))
                task, exclude = None, set()
                rosterGroups = contact.getItem().getRosterGroups()
                for rosterGroup in rosterGroups:
                    if self.usersStorage.isGroupEmpty(rosterGroup):
                        exclude.add(rosterGroup)

                if groups:
                    if groups != exclude:
                        task = roster_tasks.ChangeRosterItemGroupsTask(jid, name, groups, exclude)
                elif rosterGroups:
                    task = roster_tasks.ChangeRosterItemGroupsTask(jid, name, set(), exclude)
                if task:
                    tasks.append(task)
            elif itemType in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS:
                tasks.append(sub_tasks.ApproveSubscriptionTask(jid, name))
                if groups:
                    tasks.append(roster_tasks.ChangeRosterItemGroupsTask(jid, name, groups))
            else:
                tasks.append(roster_tasks.AddRosterItemTask(jid, name, groups))
            if subTo == _SUB.OFF:
                tasks.append(sub_tasks.AskSubscriptionTask(jid))
            if not shadowMode:
                self.__cooldown.process(CLIENT_ACTION_ID.ADD_FRIEND)
            return self.__addTasks(CLIENT_ACTION_ID.ADD_FRIEND, jid, shadowMode, *tasks)
예제 #6
0
파일: __init__.py 프로젝트: webiumsk/WoT
 def setNote(self, dbID, note):
     error = self.__checkCooldown(CLIENT_ACTION_ID.SET_NOTE)
     if error:
         return (False, error)
     contact = self.usersStorage.getUser(dbID)
     if not contact or not contact.getTags():
         return (False, ClientContactError(CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     jid = makeContactJID(dbID)
     self.__cooldown.process(CLIENT_ACTION_ID.SET_NOTE)
     return self.__addTasks(CLIENT_ACTION_ID.SET_NOTE, jid, note_tasks.SetNoteTask(jid, note))
 def __onUserStatusUpdated(self, user):
     if not user.isCurrentPlayer():
         if user.getProtoType() == PROTO_TYPE.XMPP:
             uid = user.getJID()
         else:
             uid = makeContactJID(user.getID())
         member = self._channel.getMember(uid)
         if member is not None:
             member.update(status=user.isOnline())
     return
예제 #8
0
 def setNote(self, dbID, note):
     error = self._checkCooldown(CLIENT_ACTION_ID.SET_NOTE)
     if error:
         return (False, error)
     contact = self.usersStorage.getUser(dbID)
     if not contact or not contact.getTags():
         return (False, ClientContactError(CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     jid = makeContactJID(dbID)
     self.__cooldown.process(CLIENT_ACTION_ID.SET_NOTE)
     return self.__addTasks(CLIENT_ACTION_ID.SET_NOTE, jid, note_tasks.SetNoteTask(jid, note))
예제 #9
0
파일: __init__.py 프로젝트: webiumsk/WoT
    def addFriend(self, dbID, name, group = None):
        error = self.__checkCooldown(CLIENT_ACTION_ID.ADD_FRIEND)
        if error:
            return (False, error)
        else:
            if group:
                if not self.usersStorage.isGroupExists(group):
                    return (False, ClientContactError(CONTACT_ERROR_ID.GROUP_NOT_FOUND, group))
                groups = {group}
            else:
                groups = None
            contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
            tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
            if contact:
                if contact.isCurrentPlayer():
                    return (False, ClientActionError(CLIENT_ACTION_ID.ADD_FRIEND, CLIENT_ERROR_ID.GENERIC))
                jid = contact.getJID()
                itemType = contact.getItemType()
                if itemType == XMPP_ITEM_TYPE.ROSTER_ITEM:
                    return (False, ClientContactError(CONTACT_ERROR_ID.ROSTER_ITEM_EXISTS, contact.getFullName()))
                subTo = contact.getSubscription()[0]
            else:
                jid = makeContactJID(dbID)
                subTo = _SUB.OFF
            error = self.__checkRosterSize()
            if error:
                return (False, error)
            if itemType == XMPP_ITEM_TYPE.BLOCK_ITEM:
                tasks.append(block_tasks.RemoveBlockItemTask(jid, name))
                tasks.append(roster_tasks.AddRosterItemTask(jid, name, groups))
            elif itemType == XMPP_ITEM_TYPE.ROSTER_BLOCK_ITEM:
                tasks.append(block_tasks.RemoveBlockItemTask(jid, name))
                task, exclude = None, set()
                rosterGroups = contact.getItem().getRosterGroups()
                for group in rosterGroups:
                    if self.usersStorage.isGroupEmpty(group):
                        exclude.add(group)

                if groups:
                    if groups != exclude:
                        task = roster_tasks.ChangeRosterItemGroupsTask(jid, name, groups, exclude)
                elif rosterGroups:
                    task = roster_tasks.ChangeRosterItemGroupsTask(jid, name, set(), exclude)
                if task:
                    tasks.append(task)
            elif itemType == XMPP_ITEM_TYPE.SUB_PENDING:
                tasks.append(sub_tasks.ApproveSubscriptionTask(jid, name))
                if groups:
                    tasks.append(roster_tasks.ChangeRosterItemGroupsTask(jid, name, groups))
            else:
                tasks.append(roster_tasks.AddRosterItemTask(jid, name, groups))
            if subTo == _SUB.OFF:
                tasks.append(sub_tasks.AskSubscriptionTask(jid))
            self.__cooldown.process(CLIENT_ACTION_ID.ADD_FRIEND)
            return self.__addTasks(CLIENT_ACTION_ID.ADD_FRIEND, jid, *tasks)
예제 #10
0
 def __onUserStatusUpdated(self, user):
     if not user.isCurrentPlayer():
         if user.getProtoType() == PROTO_TYPE.XMPP:
             uid = user.getJID()
         else:
             uid = makeContactJID(user.getID())
         member = self._channel.getMember(uid)
         if member is not None:
             presence = user.getItem().getPresence()
             member.update(status=presence)
     return
예제 #11
0
 def setContactPresence(self, contact):
     dbID = contact.getID()
     if contact.getProtoType() == PROTO_TYPE.XMPP:
         jid = contact.getJID()
     else:
         jid = jid_entity.makeContactJID(dbID)
     exists = self.getChannelByJID(jid)
     if exists is not None:
         member = exists.getMember(dbID)
         if member is not None:
             member.setOnline(contact.isOnline())
     return
 def setContactPresence(self, contact):
     dbID = contact.getID()
     if contact.getProtoType() == PROTO_TYPE.XMPP:
         jid = contact.getJID()
     else:
         jid = jid_entity.makeContactJID(dbID)
     exists = self.getChannelByJID(jid)
     if exists is not None:
         member = exists.getMember(dbID)
         if member is not None:
             member.setOnline(contact.isOnline())
     return
예제 #13
0
파일: messages.py 프로젝트: webiumsk/WoT
 def setContactPresence(self, contact):
     dbID = contact.getID()
     if contact.getProtoType() == PROTO_TYPE.XMPP:
         jid = contact.getJID()
     else:
         jid = makeContactJID(dbID)
     if jid not in self.__sessions:
         return
     channel = self.channelsStorage.getChannel(entities.XMPPChatChannelEntity(jid))
     if channel:
         member = channel.getMember(dbID)
         if member:
             member.setOnline(contact.isOnline())
예제 #14
0
 def approveFriendship(self, dbID):
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     result, error = self.canApproveFriendship(contact)
     if not result:
         return (result, error)
     if contact.getItemType() in XMPP_ITEM_TYPE.ROSTER_ITEMS:
         jid = contact.getJID()
         tasks = [sub_tasks.ApproveSubscriptionTask(jid)]
         if contact.getSubscription()[0] == _SUB.OFF:
             tasks.append(sub_tasks.AskSubscriptionTask(jid))
     else:
         jid = makeContactJID(dbID)
         tasks = (sub_tasks.ApproveSubscriptionTask(jid), sub_tasks.AskSubscriptionTask(jid))
     return self.__addTasks(CLIENT_ACTION_ID.APPROVE_FRIENDSHIP, jid, *tasks)
예제 #15
0
 def setContactPresence(self, contact):
     dbID = contact.getID()
     if contact.getProtoType() == PROTO_TYPE.XMPP:
         jid = contact.getJID()
     else:
         jid = makeContactJID(dbID)
     if jid not in self.__sessions:
         return
     channel = self.channelsStorage.getChannel(
         entities.XMPPChatChannelEntity(jid))
     if channel:
         member = channel.getMember(dbID)
         if member:
             member.setOnline(contact.isOnline())
예제 #16
0
파일: __init__.py 프로젝트: webiumsk/WoT
 def approveFriendship(self, dbID):
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     result, error = self.canApproveFriendship(contact)
     if not result:
         return (result, error)
     if contact.getItemType() == XMPP_ITEM_TYPE.ROSTER_ITEM:
         jid = contact.getJID()
         tasks = [sub_tasks.ApproveSubscriptionTask(jid)]
         if contact.getSubscription()[0] == _SUB.OFF:
             tasks.append(sub_tasks.AskSubscriptionTask(jid))
     else:
         jid = makeContactJID(dbID)
         tasks = (sub_tasks.ApproveSubscriptionTask(jid), sub_tasks.AskSubscriptionTask(jid))
     return self.__addTasks(CLIENT_ACTION_ID.APPROVE_FRIENDSHIP, jid, *tasks)
예제 #17
0
 def addTmpIgnored(self, dbID, name):
     error = self._checkCooldown(CLIENT_ACTION_ID.ADD_IGNORED)
     if error:
         return (False, error)
     tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if contact:
         if contact.isCurrentPlayer():
             return (False, ClientActionError(CLIENT_ACTION_ID.ADD_IGNORED, CLIENT_ERROR_ID.GENERIC))
         itemType = contact.getItemType()
         if itemType in XMPP_ITEM_TYPE.BLOCK_ITEMS:
             return (False, ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_EXISTS, contact.getFullName()))
     if contact:
         jid = contact.getJID()
     else:
         jid = makeContactJID(dbID)
     tasks.append(block_tasks.AddTmpBlockItemTask(jid, name))
     self.__cooldown.process(CLIENT_ACTION_ID.ADD_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.ADD_IGNORED, jid, *tasks)
예제 #18
0
 def addTmpIgnored(self, dbID, name):
     error = self._checkCooldown(CLIENT_ACTION_ID.ADD_IGNORED)
     if error:
         return (False, error)
     tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if contact:
         if contact.isCurrentPlayer():
             return (False, ClientActionError(CLIENT_ACTION_ID.ADD_IGNORED, CLIENT_ERROR_ID.GENERIC))
         itemType = contact.getItemType()
         if itemType in XMPP_ITEM_TYPE.BLOCK_ITEMS:
             return (False, ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_EXISTS, contact.getFullName()))
     if contact:
         jid = contact.getJID()
     else:
         jid = makeContactJID(dbID)
     tasks.append(block_tasks.AddTmpBlockItemTask(jid, name))
     self.__cooldown.process(CLIENT_ACTION_ID.ADD_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.ADD_IGNORED, jid, *tasks)
 def setUserAction(self, actionID, contact):
     if actionID in (USER_ACTION_ID.IGNORED_ADDED, USER_ACTION_ID.TMP_IGNORED_ADDED):
         self.stopSession(jid_entity.makeContactJID(contact.getID()))
예제 #20
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)
예제 #21
0
파일: messages.py 프로젝트: webiumsk/WoT
 def __me_onUserActionReceived(self, actionID, user):
     if actionID == USER_ACTION_ID.IGNORED_ADDED:
         self.__chatSessions.stopSession(makeContactJID(user.getID()))
예제 #22
0
파일: messages.py 프로젝트: webiumsk/WoT
 def startChatSession(self, dbID, name):
     self.__chatSessions.startSession(makeContactJID(dbID), name)
     return (True, None)
예제 #23
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)
예제 #24
0
 def setUserAction(self, actionID, contact):
     if actionID == USER_ACTION_ID.IGNORED_ADDED:
         self.stopSession(jid_entity.makeContactJID(contact.getID()))
    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)
예제 #26
0
 def __me_onUserActionReceived(self, actionID, user):
     if actionID == USER_ACTION_ID.IGNORED_ADDED:
         self.__chatSessions.stopSession(makeContactJID(user.getID()))
예제 #27
0
 def startChatSession(self, dbID, name):
     self.__chatSessions.startSession(jid_entity.makeContactJID(dbID), name)
     return (True, None)