Beispiel #1
0
 def restoreSession(self, jid, state):
     channel = entities.XMPPChatChannelEntity(jid)
     jid = ContactBareJID(jid)
     if channel.setPersistentState(state):
         channel = self._addChannel(channel, jid.getDatabaseID(), channel.getProtoData().name, self.client().isConnected())
         if channel:
             self.__sessions.add(jid)
Beispiel #2
0
    def sync(self):
        if self.__isBWRosterReceived and self.client().isConnected():
            g_logOutput.debug(CLIENT_LOG_AREA.SYNC, 'Syncing XMPP rosters from BW')
            domain = g_settings.server.XMPP.domain
            contacts = set()
            for user in self.usersStorage.getList(_BWRosterFindCriteria()):
                jid = ContactBareJID()
                jid.setNode(user.getID())
                jid.setDomain(domain)
                contacts.add(jid)
                if user.isCurrentPlayer():
                    self.xmppRoster[jid].name = user.getName()
                    continue
                groups = self.__getBWRosterGroups(user)
                if self.xmppRoster.hasItem(jid):
                    if GROUPS_SYNC_ENABLED and groups ^ self.xmppRoster[jid].groups:
                        self.__setContactToXmppRoster(jid, user.getName(), groups)
                    if self.xmppRoster[jid].subscriptionTo == SUBSCRIPTION.OFF:
                        self.__setSubscribeTo(jid)
                else:
                    self.__addContactToXmppRoster(jid, user.getName(), groups)

            toRemove = set(self.xmppRoster.keys()).difference(contacts)
            for jid in toRemove:
                contact = self.xmppRoster[jid]
                if contact.subscriptionFrom != SUBSCRIPTION.OFF:
                    if contact.subscriptionTo == SUBSCRIPTION.ON:
                        self.__removeSubscribeTo(jid)
                else:
                    self.__removeContactFromXmppRoster(jid)
Beispiel #3
0
 def __me_onRosterUpdate(self, actionIdx, user):
     groups = self.__getBWRosterGroups(user)
     databaseID = user.getID()
     g_logOutput.debug(CLIENT_LOG_AREA.SYNC, 'BW roster update', groups, user)
     jid = ContactBareJID()
     jid.setNode(databaseID)
     jid.setDomain(g_settings.server.XMPP.domain)
     hasItem = self.xmppRoster.hasItem(jid)
     if len(groups):
         if hasItem:
             if GROUPS_SYNC_ENABLED and groups ^ self.xmppRoster[jid].groups:
                 self.__setContactToXmppRoster(jid, user.getName(), groups)
             self.__setSubscribeTo(jid)
         else:
             self.__addContactToXmppRoster(jid, user.getName(), groups)
     elif hasItem:
         self.__removeSubscribeTo(jid)
     if actionIdx == USER_ROSTER_ACTION.RemoveFromFriend and g_settings.server.useToShowOnline(PROTO_TYPE.XMPP) and not self.usersStorage.isClanMember(databaseID):
         user.update(isOnline=False)
Beispiel #4
0
 def requestChatHistory(self, jid):
     self.__chatSessions.requestHistory(ContactBareJID(jid))
Beispiel #5
0
 def stopChatSession(self, jid):
     self.__chatSessions.stopSession(ContactBareJID(jid))
Beispiel #6
0
 def onRosterQuerySend(self, iqID, jid, context):
     self.__handleEvent(GLOOX_EVENT.ROSTER_QUERY, iqID, ContactBareJID(jid), context)
Beispiel #7
0
 def onRosterItemRemoved(self, jid):
     self.__handleEvent(GLOOX_EVENT.ROSTER_ITEM_REMOVED, ContactBareJID(jid))
Beispiel #8
0
 def onRosterItemSet(self, jid, name, groups, to, from_, clanInfo):
     self.__handleEvent(GLOOX_EVENT.ROSTER_ITEM_SET, ContactBareJID(jid), name, groups, (to, from_), makeClanInfo(*clanInfo))