summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0332/stanza/data.py
blob: a19c94f5975c01c33589437e138a7c2015e1477a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
    Slixmpp: The Slick XMPP Library
    Implementation of HTTP over XMPP transport
    http://xmpp.org/extensions/xep-0332.html
    Copyright (C) 2015 Riptide IO, sangeeth@riptideio.com
    This file is part of slixmpp.

    See the file LICENSE for copying permission.
"""

from slixmpp.xmlstream import ElementBase


class HTTPData(ElementBase):
    """
    The data element.
    """
    name = 'data'
    namespace = 'urn:xmpp:http'
    interfaces = set(['data'])
    plugin_attrib = 'data'
    is_extension = True

    def get_data(self, encoding='text'):
        data = self._get_sub_text(encoding, None)
        return str(data) if data is not None else data

    def set_data(self, data, encoding='text'):
        self._set_sub_text(encoding, text=data)