Dateien nach „slixmpp/plugins/xep_0215“ hochladen

This commit is contained in:
apprenticius 2024-12-27 12:03:47 +00:00
parent 39c6acde17
commit 5cdd923b8c
3 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# slixmpp: The Slick XMPP Library
# Copyright (C) 2020 Emmanuel Gil Peyrot
# This file is part of slixmpp.
# See the file LICENSE for copying permission.
from slixmpp.plugins.base import register_plugin
from slixmpp.plugins.xep_0215.stanza import Services, Credentials, Service
from slixmpp.plugins.xep_0215.services import XEP_0215
register_plugin(XEP_0215)

View File

@ -0,0 +1,82 @@
# slixmpp: The Slick XMPP Library
# Copyright (C) 2020 Emmanuel Gil Peyrot
# This file is part of slixmpp.
# 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.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.plugins.xep_0215 import stanza, Services, Credentials, Service
log = logging.getLogger(__name__)
class XEP_0215(BasePlugin):
name = 'xep_0215'
description = 'XEP-0215: Services'
stanza = stanza
def plugin_init(self):
register_stanza_plugin(Iq,Services)
register_stanza_plugin(Services,Service, True)
register_stanza_plugin(Iq,Credentials)
register_stanza_plugin(Credentials,Service, True)
# self.xmpp.register_handler(
# Callback('Add Services',
# StanzaPath('iq/services@type=add'),
# self._handle_services_add))
#
# self.xmpp.register_handler(
# Callback('Delete Services',
# StanzaPath('iq/services@type=delete'),
# self._handle_services_delete))
#
# self.xmpp.register_handler(
# Callback('Modify Services',
# StanzaPath('iq/services@type=modify'),
# self._handle_services_modify))
self.xmpp.register_handler(
Callback('Services',
StanzaPath('iq/services'),
self._handle_services))
self.xmpp.register_handler(
Callback('Credentials',
StanzaPath('iq/credentials'),
self._handle_credentials))
#######################################################################
def _handle_services_add(self, message):
self.xmpp.event('services_add', message)
def _handle_services_delete(self, message):
self.xmpp.event('services_delete', message)
def _handle_services_modify(self, message):
self.xmpp.event('services_modify', message)
def _handle_services(self, message):
self.xmpp.event('services', message)
def _handle_credentials(self, message):
self.xmpp.event('credentials', message)
#######################################################################
#
# def make_services(self):
# return Services()
#
# def make_credentials(self):
# return Credentials()

View File

@ -0,0 +1,25 @@
# slixmpp: The Slick XMPP Library
# Copyright (C) 2020 Emmanuel Gil Peyrot
# This file is part of slixmpp.
# See the file LICENSE for copying permission.
from slixmpp.xmlstream import ElementBase
class Services(ElementBase):
name = 'services'
namespace = 'urn:xmpp:extdisco:2'
plugin_attrib = 'services'
interfaces = {'type'}
class Credentials(ElementBase):
name = 'credentials'
namespace = 'urn:xmpp:extdisco:2'
plugin_attrib = 'credentials'
interfaces = {}
class Service(ElementBase):
name = 'service'
namespace = 'urn:xmpp:extdisco:2'
plugin_attrib = 'service'
interfaces = {'action', 'expires', 'host', 'name', 'password', 'port', 'restricted', 'transport', 'type', 'username'}
plugin_multi_attrib = 'services'