How to use the slixmpp.plugins.BasePlugin function in slixmpp

To help you get started, we’ve selected a few slixmpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poezio / slixmpp / slixmpp / plugins / xep_0020 / feature_negotiation.py View on Github external
import logging

from slixmpp import Iq, Message
from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin, JID
from slixmpp.plugins.xep_0020 import stanza, FeatureNegotiation
from slixmpp.plugins.xep_0004 import Form


log = logging.getLogger(__name__)


class XEP_0020(BasePlugin):

    name = 'xep_0020'
    description = 'XEP-0020: Feature Negotiation'
    dependencies = {'xep_0004', 'xep_0030'}
    stanza = stanza

    def plugin_init(self):
        self.xmpp['xep_0030'].add_feature(FeatureNegotiation.namespace)

        register_stanza_plugin(FeatureNegotiation, Form)

        register_stanza_plugin(Iq, FeatureNegotiation)
        register_stanza_plugin(Message, FeatureNegotiation)
github poezio / slixmpp / slixmpp / plugins / google / gmail / notifications.py View on Github external
"""

import logging

from slixmpp.stanza import Iq
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import MatchXPath
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.google.gmail import stanza


log = logging.getLogger(__name__)


class Gmail(BasePlugin):

    """
    Google: Gmail Notifications

    Also see .
    """

    name = 'gmail'
    description = 'Google: Gmail Notifications'
    dependencies = set()
    stanza = stanza

    def plugin_init(self):
        register_stanza_plugin(Iq, stanza.GmailQuery)
        register_stanza_plugin(Iq, stanza.MailBox)
        register_stanza_plugin(Iq, stanza.NewMail)
github poezio / slixmpp / slixmpp / features / feature_starttls / starttls.py View on Github external
"""

import logging

from slixmpp.stanza import StreamFeatures
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream.matcher import MatchXPath
from slixmpp.xmlstream.handler import CoroutineCallback
from slixmpp.features.feature_starttls import stanza


log = logging.getLogger(__name__)


class FeatureSTARTTLS(BasePlugin):

    name = 'feature_starttls'
    description = 'RFC 6120: Stream Feature: STARTTLS'
    dependencies = set()
    stanza = stanza

    def plugin_init(self):
        self.xmpp.register_handler(
                CoroutineCallback('STARTTLS Proceed',
                        MatchXPath(stanza.Proceed.tag_name()),
                        self._handle_starttls_proceed,
                        instream=True))
        self.xmpp.register_feature('starttls',
                self._handle_starttls,
                restart=True,
                order=self.config.get('order', 0))
github poezio / slixmpp / slixmpp / features / feature_bind / bind.py View on Github external
"""

import asyncio
import logging

from slixmpp.jid import JID
from slixmpp.stanza import Iq, StreamFeatures
from slixmpp.features.feature_bind import stanza
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins import BasePlugin


log = logging.getLogger(__name__)


class FeatureBind(BasePlugin):

    name = 'feature_bind'
    description = 'RFC 6120: Stream Feature: Resource Binding'
    dependencies = set()
    stanza = stanza

    def plugin_init(self):
        self.xmpp.register_feature('bind',
                self._handle_bind_resource,
                restart=False,
                order=10000)

        register_stanza_plugin(Iq, stanza.Bind)
        register_stanza_plugin(StreamFeatures, stanza.Bind)

    async def _handle_bind_resource(self, features):
github poezio / slixmpp / slixmpp / plugins / xep_0013 / offline.py View on Github external
import logging

import slixmpp
from slixmpp.stanza import Message, Iq
from slixmpp.exceptions import XMPPError
from slixmpp.xmlstream.handler import Collector
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0013 import stanza


log = logging.getLogger(__name__)


class XEP_0013(BasePlugin):

    """
    XEP-0013 Flexible Offline Message Retrieval
    """

    name = 'xep_0013'
    description = 'XEP-0013: Flexible Offline Message Retrieval'
    dependencies = {'xep_0030'}
    stanza = stanza

    def plugin_init(self):
        register_stanza_plugin(Iq, stanza.Offline)
        register_stanza_plugin(Message, stanza.Offline)

    def get_count(self, **kwargs):
        return self.xmpp['xep_0030'].get_info(
github poezio / slixmpp / slixmpp / plugins / xep_0009 / rpc.py View on Github external
import logging

from slixmpp import Iq
from slixmpp.xmlstream import ET, register_stanza_plugin
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import MatchXPath
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0009 import stanza
from slixmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, MethodResponse


log = logging.getLogger(__name__)


class XEP_0009(BasePlugin):

    name = 'xep_0009'
    description = 'XEP-0009: Jabber-RPC'
    dependencies = set(['xep_0030'])
    stanza = stanza

    def plugin_init(self):
        register_stanza_plugin(Iq, RPCQuery)
        register_stanza_plugin(RPCQuery, MethodCall)
        register_stanza_plugin(RPCQuery, MethodResponse)

        self.xmpp.register_handler(
            Callback('RPC Call', MatchXPath('{%s}iq/{%s}query/{%s}methodCall' % (self.xmpp.default_ns, RPCQuery.namespace, RPCQuery.namespace)),
            self._handle_method_call)
        )
        self.xmpp.register_handler(
github poezio / slixmpp / slixmpp / plugins / xep_0257 / client_cert_management.py View on Github external
See the file LICENSE for copying permission.
"""

import logging

from slixmpp import Iq
from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins.xep_0257 import stanza, Certs
from slixmpp.plugins.xep_0257 import AppendCert, DisableCert, RevokeCert


log = logging.getLogger(__name__)


class XEP_0257(BasePlugin):

    name = 'xep_0257'
    description = 'XEP-0257: Client Certificate Management for SASL EXTERNAL'
    dependencies = {'xep_0030'}
    stanza = stanza

    def plugin_init(self):
        register_stanza_plugin(Iq, Certs)
        register_stanza_plugin(Iq, AppendCert)
        register_stanza_plugin(Iq, DisableCert)
        register_stanza_plugin(Iq, RevokeCert)

    def get_certs(self, ifrom=None, timeout=None, callback=None,
                        timeout_callback=None):
        iq = self.xmpp.Iq()
        iq['type'] = 'get'
github poezio / slixmpp / slixmpp / plugins / xep_0092 / version.py View on Github external
import logging

import slixmpp
from slixmpp import Iq
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0092 import Version, stanza


log = logging.getLogger(__name__)


class XEP_0092(BasePlugin):

    """
    XEP-0092: Software Version
    """

    name = 'xep_0092'
    description = 'XEP-0092: Software Version'
    dependencies = {'xep_0030'}
    stanza = stanza
    default_config = {
        'software_name': 'Slixmpp',
        'version': slixmpp.__version__,
        'os': ''
    }

    def plugin_init(self):
github poezio / slixmpp / slixmpp / plugins / xep_0050 / adhoc.py View on Github external
from slixmpp import Iq
from slixmpp.exceptions import XMPPError
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin, JID
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0050 import stanza
from slixmpp.plugins.xep_0050 import Command
from slixmpp.plugins.xep_0004 import Form


log = logging.getLogger(__name__)


class XEP_0050(BasePlugin):

    """
    XEP-0050: Ad-Hoc Commands

    XMPP's Adhoc Commands provides a generic workflow mechanism for
    interacting with applications. The result is similar to menu selections
    and multi-step dialogs in normal desktop applications. Clients do not
    need to know in advance what commands are provided by any particular
    application or agent. While adhoc commands provide similar functionality
    to Jabber-RPC, adhoc commands are used primarily for human interaction.

    Also see 

    Events:
        command_execute  -- Received a command with action="execute"
        command_next     -- Received a command with action="next"
github poezio / slixmpp / slixmpp / plugins / xep_0300 / hash.py View on Github external
See the file LICENSE for copying permission.
"""

from base64 import b64encode
import hashlib
import logging

from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0300 import stanza, Hash


log = logging.getLogger(__name__)


class XEP_0300(BasePlugin):

    name = 'xep_0300'
    description = 'XEP-0300: Use of Cryptographic Hash Functions in XMPP'
    dependencies = {'xep_0030'}
    stanza = stanza
    default_config = {
        'block_size': 1024 * 1024,  # One MiB
        'preferded': 'sha-256',
        'enable_sha-1': False,
        'enable_sha-256': True,
        'enable_sha-512': True,
        'enable_sha3-256': True,
        'enable_sha3-512': True,
        'enable_BLAKE2b256': True,
        'enable_BLAKE2b512': True,
    }