1# This file is part of Gajim.
2#
3# Gajim is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published
5# by the Free Software Foundation; version 3 only.
6#
7# Gajim is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
14
15# All XEPs that don’t need their own module
16
17import logging
18
19from gajim.common.i18n import get_rfc5646_lang
20
21log = logging.getLogger('gajim.c.m.misc')
22
23
24# XEP-0066: Out of Band Data
25
26def parse_oob(properties, additional_data):
27    if not properties.is_oob:
28        return
29
30    additional_data.set_value('gajim', 'oob_url', properties.oob.url)
31    if properties.oob.desc is not None:
32        additional_data.set_value('gajim', 'oob_desc',
33                                  properties.oob.desc)
34
35
36# XEP-0308: Last Message Correction
37
38def parse_correction(properties):
39    if not properties.is_correction:
40        return None
41    return properties.correction.id
42
43
44# XEP-0071: XHTML-IM
45
46def parse_xhtml(properties, additional_data):
47    if not properties.has_xhtml:
48        return
49
50    body = properties.xhtml.get_body(get_rfc5646_lang())
51    additional_data.set_value('gajim', 'xhtml', body)
52