xep_049: implement bookmarks pinning stanzas
This commit is contained in:
parent
9266486f46
commit
c41209510a
@ -119,6 +119,7 @@ PLUGINS = [
|
||||
'xep_0444', # Message Reactions
|
||||
'xep_0447', # Stateless file sharing
|
||||
'xep_0461', # Message Replies
|
||||
'xep_0469', # Bookmarks Pinning
|
||||
# Meant to be imported by plugins
|
||||
]
|
||||
|
||||
|
8
slixmpp/plugins/xep_0469/__init__.py
Normal file
8
slixmpp/plugins/xep_0469/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
from slixmpp.plugins.base import register_plugin
|
||||
|
||||
from . import stanza
|
||||
from .pinning import XEP_0469
|
||||
|
||||
register_plugin(XEP_0469)
|
||||
|
||||
__all__ = ['stanza', 'XEP_0469']
|
17
slixmpp/plugins/xep_0469/pinning.py
Normal file
17
slixmpp/plugins/xep_0469/pinning.py
Normal file
@ -0,0 +1,17 @@
|
||||
from slixmpp.plugins import BasePlugin
|
||||
from . import stanza
|
||||
|
||||
|
||||
class XEP_0469(BasePlugin):
|
||||
|
||||
"""
|
||||
XEP-0469: Bookmark Pinning
|
||||
"""
|
||||
|
||||
name = "xep_0469"
|
||||
description = "XEP-0469: Bookmark Pinning"
|
||||
dependencies = {"xep_0402"}
|
||||
stanza = stanza
|
||||
|
||||
def plugin_init(self):
|
||||
stanza.register_plugin()
|
31
slixmpp/plugins/xep_0469/stanza.py
Normal file
31
slixmpp/plugins/xep_0469/stanza.py
Normal file
@ -0,0 +1,31 @@
|
||||
from slixmpp import register_stanza_plugin
|
||||
from slixmpp.plugins.xep_0402.stanza import Extensions
|
||||
from slixmpp.xmlstream import ElementBase
|
||||
|
||||
NS = "urn:xmpp:bookmarks-pinning:0"
|
||||
|
||||
|
||||
class Pinned(ElementBase):
|
||||
"""
|
||||
Pinned bookmark element
|
||||
|
||||
|
||||
To enable it on a Conference element, use enable() like this:
|
||||
|
||||
.. code-block::python
|
||||
|
||||
# C being a Conference element
|
||||
C['extensions'].enable('pinned')
|
||||
|
||||
Which will add the <pinned> element to the <extensions> element.
|
||||
"""
|
||||
namespace = NS
|
||||
name = "pinned"
|
||||
plugin_attrib = "pinned"
|
||||
interfaces = {"pinned"}
|
||||
bool_interfaces = {"pinned"}
|
||||
is_extension = True
|
||||
|
||||
|
||||
def register_plugin():
|
||||
register_stanza_plugin(Extensions, Pinned)
|
36
tests/test_stanza_xep_0469.py
Normal file
36
tests/test_stanza_xep_0469.py
Normal file
@ -0,0 +1,36 @@
|
||||
import unittest
|
||||
|
||||
from slixmpp.test import SlixTest
|
||||
from slixmpp.plugins.xep_0469 import stanza
|
||||
from slixmpp.plugins.xep_0402 import stanza as b_stanza
|
||||
|
||||
|
||||
class TestBookmarksPinning(SlixTest):
|
||||
def setUp(self):
|
||||
b_stanza.register_plugin()
|
||||
stanza.register_plugin()
|
||||
|
||||
def test_pinned(self):
|
||||
bookmark = b_stanza.Conference()
|
||||
bookmark["password"] = "pass"
|
||||
bookmark["nick"] = "nick"
|
||||
bookmark["autojoin"] = False
|
||||
bookmark["extensions"].enable("pinned")
|
||||
self.check(
|
||||
bookmark,
|
||||
"""
|
||||
<conference xmlns='urn:xmpp:bookmarks:1'
|
||||
autojoin='false'>
|
||||
<nick>nick</nick>
|
||||
<password>pass</password>
|
||||
<extensions>
|
||||
<pinned xmlns="urn:xmpp:bookmarks-pinning:0" />
|
||||
</extensions>
|
||||
</conference>
|
||||
""",
|
||||
use_values=False
|
||||
)
|
||||
|
||||
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestBookmarksPinning)
|
Loading…
Reference in New Issue
Block a user