Dateien nach „slixmpp/plugins/xep_0353“ hochladen

This commit is contained in:
apprenticius 2024-12-27 12:05:42 +00:00
parent c0881b5f36
commit 7d7fccdb65
3 changed files with 21 additions and 4 deletions

View File

@ -5,7 +5,7 @@
# See the file LICENSE for copying permission. # See the file LICENSE for copying permission.
from slixmpp.plugins.base import register_plugin from slixmpp.plugins.base import register_plugin
from slixmpp.plugins.xep_0353.stanza import Propose, Retract, Accept, Proceed, Reject from slixmpp.plugins.xep_0353.stanza import Propose, Ringing, Retract, Accept, Proceed, Reject
from slixmpp.plugins.xep_0353.jingle_message import XEP_0353 from slixmpp.plugins.xep_0353.jingle_message import XEP_0353
register_plugin(XEP_0353) register_plugin(XEP_0353)

View File

@ -12,7 +12,7 @@ from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream import register_stanza_plugin from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.plugins.xep_0353 import stanza, Propose, Retract, Accept, Proceed, Reject from slixmpp.plugins.xep_0353 import stanza, Propose, Ringing, Retract, Accept, Proceed, Reject
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -24,6 +24,7 @@ class XEP_0353(BasePlugin):
def plugin_init(self): def plugin_init(self):
register_stanza_plugin(Message, Propose) register_stanza_plugin(Message, Propose)
register_stanza_plugin(Message, Ringing)
register_stanza_plugin(Message, Retract) register_stanza_plugin(Message, Retract)
register_stanza_plugin(Message, Accept) register_stanza_plugin(Message, Accept)
register_stanza_plugin(Message, Proceed) register_stanza_plugin(Message, Proceed)
@ -33,6 +34,10 @@ class XEP_0353(BasePlugin):
Callback('Indicating Intent to Start a Session', Callback('Indicating Intent to Start a Session',
StanzaPath('message/jingle_propose'), StanzaPath('message/jingle_propose'),
self._handle_propose)) self._handle_propose))
self.xmpp.register_handler(
Callback('Ringing',
StanzaPath('message/jingle_ringing'),
self._handle_ringing))
self.xmpp.register_handler( self.xmpp.register_handler(
Callback('Disavowing Intent to Start a Session', Callback('Disavowing Intent to Start a Session',
StanzaPath('message/jingle_retract'), StanzaPath('message/jingle_retract'),
@ -51,14 +56,17 @@ class XEP_0353(BasePlugin):
self._handle_reject)) self._handle_reject))
def session_bind(self, jid): def session_bind(self, jid):
self.xmpp.plugin['xep_0030'].add_feature(stanza.JingleMessage.namespace) self.xmpp.plugin['xep_030'].add_feature(stanza.JingleMessage.namespace)
def plugin_end(self): def plugin_end(self):
self.xmpp.plugin['xep_0030'].del_feature(feature=stanza.JingleMessage.namespace) self.xmpp.plugin['xep_030'].del_feature(feature=stanza.JingleMessage.namespace)
def _handle_propose(self, message): def _handle_propose(self, message):
self.xmpp.event('jingle_message_propose', message) self.xmpp.event('jingle_message_propose', message)
def _handle_ringing(self, message):
self.xmpp.event('jingle_message_ringing', message)
def _handle_retract(self, message): def _handle_retract(self, message):
self.xmpp.event('jingle_message_retract', message) self.xmpp.event('jingle_message_retract', message)
@ -77,6 +85,11 @@ class XEP_0353(BasePlugin):
msg['jingle_propose']['descriptions'] = descriptions msg['jingle_propose']['descriptions'] = descriptions
msg.send() msg.send()
def ringing(self, mto: JID, sid: str, *, mfrom: Optional[JID] = None):
msg = self.xmpp.make_message(mto, mfrom=mfrom)
msg['jingle_ringing']['id'] = sid
msg.send()
def retract(self, mto: JID, sid: str, *, mfrom: Optional[JID] = None): def retract(self, mto: JID, sid: str, *, mfrom: Optional[JID] = None):
msg = self.xmpp.make_message(mto, mfrom=mfrom) msg = self.xmpp.make_message(mto, mfrom=mfrom)
msg['jingle_retract']['id'] = sid msg['jingle_retract']['id'] = sid

View File

@ -35,6 +35,10 @@ class Propose(JingleMessage):
for desc in self.xml.findall('{*}description'): for desc in self.xml.findall('{*}description'):
self.xml.remove(desc) self.xml.remove(desc)
class Ringing(JingleMessage):
name = 'ringing'
plugin_attrib = 'jingle_ringing'
class Retract(JingleMessage): class Retract(JingleMessage):
name = 'retract' name = 'retract'
plugin_attrib = 'jingle_retract' plugin_attrib = 'jingle_retract'