Dateien nach „slixmpp/plugins/xep_0338“ hochladen
This commit is contained in:
parent
61d16b7585
commit
2b86ce9e39
11
slixmpp/plugins/xep_0338/__init__.py
Normal file
11
slixmpp/plugins/xep_0338/__init__.py
Normal 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_0338.stanza import Group, Content
|
||||
from slixmpp.plugins.xep_0338.group import XEP_0338
|
||||
|
||||
register_plugin(XEP_0338)
|
63
slixmpp/plugins/xep_0338/group.py
Normal file
63
slixmpp/plugins/xep_0338/group.py
Normal file
@ -0,0 +1,63 @@
|
||||
# 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 typing import Iterable, Tuple, Optional
|
||||
|
||||
import re
|
||||
|
||||
from slixmpp import JID, 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_0166 import Jingle
|
||||
from slixmpp.plugins.xep_0338 import stanza, Group, Content
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class XEP_0338(BasePlugin):
|
||||
|
||||
name = 'xep_0338'
|
||||
description = 'XEP-0338: Grouping Framework'
|
||||
dependencies = set(['xep_0166'])
|
||||
stanza = stanza
|
||||
|
||||
def plugin_init(self):
|
||||
register_stanza_plugin(Iq,Jingle)
|
||||
register_stanza_plugin(Jingle,Group)
|
||||
register_stanza_plugin(Group,Content,True)
|
||||
|
||||
self.xmpp.register_handler(
|
||||
Callback('Jingle Group',
|
||||
StanzaPath('iq/jingle/group'),
|
||||
self._handle_jingle_group))
|
||||
|
||||
# def session_bind(self, jid):
|
||||
# pass
|
||||
|
||||
# def plugin_end(self):
|
||||
# pass
|
||||
|
||||
|
||||
#######################################################################
|
||||
|
||||
def _handle_jingle_group(self, message):
|
||||
self.xmpp.event('jingle_group', message['jingle']['group'])
|
||||
|
||||
def make_group(self,sdp):
|
||||
m = re.search(r'^a=group:([^ ]+) +([^\r]+)\r$',sdp,re.M)
|
||||
if m:
|
||||
group = Group()
|
||||
group['semantics'] = m.group(1)
|
||||
medias = m.group(2).split(' ')
|
||||
for media in medias:
|
||||
content = Content()
|
||||
content['name'] = media
|
||||
group.append(content)
|
||||
return group
|
||||
return None
|
27
slixmpp/plugins/xep_0338/stanza.py
Normal file
27
slixmpp/plugins/xep_0338/stanza.py
Normal file
@ -0,0 +1,27 @@
|
||||
# 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 typing import Iterable, List, Tuple, Optional
|
||||
from slixmpp.xmlstream import ElementBase, ET
|
||||
|
||||
class Group(ElementBase):
|
||||
name = 'group'
|
||||
namespace = 'urn:xmpp:jingle:apps:grouping:0'
|
||||
plugin_attrib = 'group'
|
||||
interfaces = {'semantics'}
|
||||
|
||||
def getSDP(self):
|
||||
ret = "\r\na=group:"+self['semantics']
|
||||
for content in self['contents']:
|
||||
ret += " "+content['name']
|
||||
return ret
|
||||
|
||||
class Content(ElementBase):
|
||||
name = 'content'
|
||||
namespace = 'urn:xmpp:jingle:apps:grouping:0'
|
||||
plugin_attrib = 'content'
|
||||
interfaces = {'name'}
|
||||
plugin_multi_attrib = 'contents'
|
||||
|
Loading…
x
Reference in New Issue
Block a user