Commit af360130 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Add OOB (XEP-0066) support

parent a15b98ae
......@@ -73,6 +73,7 @@ from nbxmpp.modules.ibb import IBB
from nbxmpp.modules.discovery import Discovery
from nbxmpp.modules.chat_markers import ChatMarkers
from nbxmpp.modules.receipts import Receipts
from nbxmpp.modules.oob import OOB
from nbxmpp.modules.misc import unwrap_carbon
from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
......@@ -213,6 +214,7 @@ class XMPPDispatcher(PlugIn):
self._modules['Discovery'] = Discovery(self._owner)
self._modules['ChatMarkers'] = ChatMarkers(self._owner)
self._modules['Receipts'] = Receipts(self._owner)
self._modules['OOB'] = OOB(self._owner)
for instance in self._modules.values():
for handler in instance.handlers:
# Copyright (C) 2018 Philipp Hörist <philipp AT>
# This file is part of nbxmpp.
# This program 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; either version 3
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <>.
import logging
from nbxmpp.protocol import NS_X_OOB
from nbxmpp.structs import StanzaHandler
from nbxmpp.structs import OOBData
log = logging.getLogger('nbxmpp.m.oob')
class OOB:
def __init__(self, client):
self._client = client
self.handlers = [
def _process_message_oob(self, _con, stanza, properties):
oob = stanza.getTag('x', namespace=NS_X_OOB)
if oob is None:
url = oob.getTagData('url')
if url is None:
log.warning('OOB data without url')
desc = oob.getTagData('desc')
properties.oob = OOBData(url, desc)
......@@ -1363,6 +1363,12 @@ class Message(Protocol):
def setReceiptReceived(self, id_):
self.setTag('received', namespace=NS_RECEIPTS, attrs={'id': id_})
def setOOB(self, url, desc=None):
oob = self.setTag('x', namespace=NS_X_OOB)
oob.setTagData('url', url)
if desc is not None:
oob.setTagData('desc', desc)
class Presence(Protocol):
......@@ -121,6 +121,8 @@ DiscoItems = namedtuple('DiscoItems', 'jid node items')
DiscoItem = namedtuple('DiscoItem', 'jid name node')
DiscoItem.__new__.__defaults__ = (None, None)
OOBData = namedtuple('OOBData', 'url desc')
class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms timestamp')):
......@@ -545,6 +547,7 @@ class MessageProperties:
self.pgp_legacy = None
self.marker = None
self.receipt = None
self.oob = None
def has_user_delay(self):
......@@ -625,6 +628,10 @@ class MessageProperties:
def is_receipt(self):
return self.receipt is not None
def is_oob(self):
return self.oob is not None
class IqProperties:
def __init__(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment