2018-07-09 00:21:24 +02:00
|
|
|
# This file is part of Gajim.
|
|
|
|
#
|
|
|
|
# Gajim is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published
|
|
|
|
# by the Free Software Foundation; version 3 only.
|
|
|
|
#
|
|
|
|
# Gajim is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# All XEPs that dont need their own module
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import nbxmpp
|
|
|
|
|
2018-07-19 21:26:45 +02:00
|
|
|
from gajim.common import app
|
2018-07-09 00:21:24 +02:00
|
|
|
|
|
|
|
log = logging.getLogger('gajim.c.m.misc')
|
|
|
|
|
|
|
|
|
|
|
|
# XEP-0066: Out of Band Data
|
|
|
|
|
2018-11-30 23:05:15 +01:00
|
|
|
def parse_oob(event):
|
|
|
|
oob_node = event.stanza.getTag('x', namespace=nbxmpp.NS_X_OOB)
|
2018-07-09 00:21:24 +02:00
|
|
|
if oob_node is None:
|
|
|
|
return
|
2018-11-30 23:05:15 +01:00
|
|
|
|
2018-07-09 00:21:24 +02:00
|
|
|
url = oob_node.getTagData('url')
|
|
|
|
if url is not None:
|
2018-11-30 23:05:15 +01:00
|
|
|
event.additional_data.set_value('gajim', 'oob_url', url)
|
|
|
|
|
2018-07-09 00:21:24 +02:00
|
|
|
desc = oob_node.getTagData('desc')
|
|
|
|
if desc is not None:
|
2018-11-30 23:05:15 +01:00
|
|
|
event.additional_data.set_value('gajim', 'oob_desc', desc)
|
2018-07-09 00:21:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
# XEP-0308: Last Message Correction
|
|
|
|
|
|
|
|
def parse_correction(stanza):
|
|
|
|
replace = stanza.getTag('replace', namespace=nbxmpp.NS_CORRECT)
|
|
|
|
if replace is not None:
|
|
|
|
id_ = replace.getAttr('id')
|
|
|
|
if id_ is not None:
|
|
|
|
return id_
|
2018-09-11 22:25:55 +02:00
|
|
|
log.warning('No id attr found: %s', stanza)
|
2018-07-19 21:26:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
# XEP-0224: Attention
|
|
|
|
|
|
|
|
def parse_attention(stanza):
|
|
|
|
attention = stanza.getTag('attention', namespace=nbxmpp.NS_ATTENTION)
|
|
|
|
if attention is None:
|
|
|
|
return False
|
|
|
|
delayed = stanza.getTag('x', namespace=nbxmpp.NS_DELAY2)
|
|
|
|
if delayed is not None:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
# XEP-0004: Data Forms
|
|
|
|
|
|
|
|
def parse_form(stanza):
|
|
|
|
return stanza.getTag('x', namespace=nbxmpp.NS_DATA)
|
|
|
|
|
|
|
|
|
|
|
|
# XEP-0071: XHTML-IM
|
|
|
|
|
|
|
|
def parse_xhtml(stanza):
|
|
|
|
if app.config.get('ignore_incoming_xhtml'):
|
|
|
|
return None
|
|
|
|
return stanza.getXHTML()
|