Example #1
0
    def cleanup_roster(self, client, active_jids):
        roster = client._roster
        active_stripped_jids = {}
        for jid in active_jids:
            stripped_jid = jabber_lib.strip_resource(jid)
            stripped_jid = str(stripped_jid)
            active_stripped_jids[stripped_jid] = None

        roster_jids = roster.get_subscribed_to()
        roster_jids.update(roster.get_subscribed_from())
        roster_jids.update(roster.get_subscribed_both())

        to_remove = []
        for jid in roster_jids.keys():
            stripped_jid = jabber_lib.strip_resource(jid)
            stripped_jid = str(stripped_jid)
            if not active_stripped_jids.has_key(stripped_jid):
                to_remove.append(stripped_jid)

        client.cancel_subscription(to_remove)
Example #2
0
    def fix_connection(self, client):
        # First, retrieve the roster
        client.retrieve_roster()

        # If not subscribed already, subscribe to the dispatcher
        dest = str(jabber_lib.strip_resource(self.dispatcher))
        client.subscribe_to_presence([dest])
        client._roster._subscribed_to[dest] = {
            'jid': dest,
            'subscription': "to",
        }
        client.send_presence()
Example #3
0
    def fix_connection(self, client):
        # First, retrieve the roster
        client.retrieve_roster()

        # If not subscribed already, subscribe to the dispatcher
        dest = str(jabber_lib.strip_resource(self.dispatcher))
        client.subscribe_to_presence([dest])
        client._roster._subscribed_to[dest] = {
            'jid'           : dest,
            'subscription'  : "to",
        }
        client.send_presence()
Example #4
0
    def process_once(self, client):
        ret = test_lib.SimpleRunner.process_once(self, client)
        if not self._should_exit:
            return ret

        # Wait for a presence subscription request
        djid = str(jabber_lib.strip_resource(self.dispatcher))

        if client._roster.get_subscribed_both().has_key(djid):
            client.disconnect()
            sys.exit(0)

        return ret
Example #5
0
    def process_once(self, client):
        ret = test_lib.SimpleRunner.process_once(self, client)
        if not self._should_exit:
            return ret

        # Wait for a presence subscription request
        djid = str(jabber_lib.strip_resource(self.dispatcher))

        if client._roster.get_subscribed_both().has_key(djid):
            client.disconnect()
            sys.exit(0)

        return ret