Dateien nach „slixmpp/plugins/xep_0353“ hochladen
This commit is contained in:
parent
c0881b5f36
commit
7d7fccdb65
@ -5,7 +5,7 @@
|
||||
# See the file LICENSE for copying permission.
|
||||
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
|
||||
|
||||
register_plugin(XEP_0353)
|
||||
|
@ -12,7 +12,7 @@ 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_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__)
|
||||
|
||||
@ -24,6 +24,7 @@ class XEP_0353(BasePlugin):
|
||||
|
||||
def plugin_init(self):
|
||||
register_stanza_plugin(Message, Propose)
|
||||
register_stanza_plugin(Message, Ringing)
|
||||
register_stanza_plugin(Message, Retract)
|
||||
register_stanza_plugin(Message, Accept)
|
||||
register_stanza_plugin(Message, Proceed)
|
||||
@ -33,6 +34,10 @@ class XEP_0353(BasePlugin):
|
||||
Callback('Indicating Intent to Start a Session',
|
||||
StanzaPath('message/jingle_propose'),
|
||||
self._handle_propose))
|
||||
self.xmpp.register_handler(
|
||||
Callback('Ringing',
|
||||
StanzaPath('message/jingle_ringing'),
|
||||
self._handle_ringing))
|
||||
self.xmpp.register_handler(
|
||||
Callback('Disavowing Intent to Start a Session',
|
||||
StanzaPath('message/jingle_retract'),
|
||||
@ -51,14 +56,17 @@ class XEP_0353(BasePlugin):
|
||||
self._handle_reject))
|
||||
|
||||
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):
|
||||
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):
|
||||
self.xmpp.event('jingle_message_propose', message)
|
||||
|
||||
def _handle_ringing(self, message):
|
||||
self.xmpp.event('jingle_message_ringing', message)
|
||||
|
||||
def _handle_retract(self, message):
|
||||
self.xmpp.event('jingle_message_retract', message)
|
||||
|
||||
@ -77,6 +85,11 @@ class XEP_0353(BasePlugin):
|
||||
msg['jingle_propose']['descriptions'] = descriptions
|
||||
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):
|
||||
msg = self.xmpp.make_message(mto, mfrom=mfrom)
|
||||
msg['jingle_retract']['id'] = sid
|
||||
|
@ -35,6 +35,10 @@ class Propose(JingleMessage):
|
||||
for desc in self.xml.findall('{*}description'):
|
||||
self.xml.remove(desc)
|
||||
|
||||
class Ringing(JingleMessage):
|
||||
name = 'ringing'
|
||||
plugin_attrib = 'jingle_ringing'
|
||||
|
||||
class Retract(JingleMessage):
|
||||
name = 'retract'
|
||||
plugin_attrib = 'jingle_retract'
|
||||
|
Loading…
x
Reference in New Issue
Block a user