rosterver.py 1.11 KB
Newer Older
1 2 3 4
# Slixmpp: The Slick XMPP Library
# Copyright (C) 2012  Nathanael C. Fritz
# This file is part of Slixmpp.
# See the file LICENSE for copying permission.
5 6
import logging

louiz’'s avatar
louiz’ committed
7 8 9 10
from slixmpp.stanza import StreamFeatures
from slixmpp.features.feature_rosterver import stanza
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins.base import BasePlugin
mathieui's avatar
mathieui committed
11
from typing import ClassVar, Set
12 13 14 15 16


log = logging.getLogger(__name__)


17
class FeatureRosterVer(BasePlugin):
18

19 20
    name = 'feature_rosterver'
    description = 'RFC 6121: Stream Feature: Roster Versioning'
mathieui's avatar
mathieui committed
21
    dependences: ClassVar[Set[str]] = set()
22
    stanza = stanza
23

24
    def plugin_init(self):
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
        self.xmpp.register_feature('rosterver',
                self._handle_rosterver,
                restart=False,
                order=9000)

        register_stanza_plugin(StreamFeatures, stanza.RosterVer)

    def _handle_rosterver(self, features):
        """Enable using roster versioning.

        Arguments:
            features -- The stream features stanza.
        """
        log.debug("Enabling roster versioning.")
        self.xmpp.features.add('rosterver')