Commit 608607b7 authored by Philipp Hörist's avatar Philipp Hörist

Remove old PEP code

parent a7aea4ca
......@@ -33,7 +33,6 @@ from gajim.common.modules import dataforms
from gajim.common.modules.misc import parse_idle
from gajim.common.modules.misc import parse_delay
from gajim.common.const import KindConstant, SSLError
from gajim.common.pep import SUPPORTED_PERSONAL_USER_EVENTS
from gajim.common.jingle_transport import JingleTransportSocks5
from gajim.common.file_props import FilesProp
......@@ -429,30 +428,6 @@ class GPGPasswordRequiredEvent(nec.NetworkIncomingEvent):
self.keyid = app.config.get_per('accounts', self.conn.name, 'keyid')
return True
class PEPReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
name = 'pep-received'
def generate(self):
if not self.stanza.getTag('event'):
return
if self.stanza.getTag('error'):
log.debug('PEPReceivedEvent received error stanza. Ignoring')
return
try:
self.get_jid_resource()
except Exception:
return
self.event_tag = self.stanza.getTag('event')
for pep_class in SUPPORTED_PERSONAL_USER_EVENTS:
pep = pep_class.get_tag_as_PEP(self.fjid, self.conn.name,
self.event_tag)
if pep:
self.pep_type = pep.type_
return True
class PlainConnectionEvent(nec.NetworkIncomingEvent):
name = 'plain-connection'
......
......@@ -93,27 +93,23 @@ class PEP:
handlers = self._pep_handlers.get(namespace, None)
if handlers is None:
# Old Fallback
from gajim.common.connection_handlers_events import PEPReceivedEvent as OldPEPReceivedEvent
app.nec.push_incoming_event(
OldPEPReceivedEvent(None, conn=self._con, stanza=stanza))
raise nbxmpp.NodeProcessed
else:
# Check if this is a retraction
retract = items.getTag('retract')
if retract is not None:
id_ = retract.getAttr('id')
log.info('Received retract of id: %s', id_)
raise nbxmpp.NodeProcessed
# Check if we have items
items_ = items.getTags('item')
if items_ is None:
log.warning('Malformed PEP event received: %s', stanza)
raise nbxmpp.NodeProcessed
for handler in handlers:
handler(jid, items_[0])
raise nbxmpp.NodeProcessed
# Check if this is a retraction
retract = items.getTag('retract')
if retract is not None:
id_ = retract.getAttr('id')
log.info('Received retract of id: %s', id_)
raise nbxmpp.NodeProcessed
# Check if we have items
items_ = items.getTags('item')
if items_ is None:
log.warning('Malformed PEP event received: %s', stanza)
raise nbxmpp.NodeProcessed
for handler in handlers:
handler(jid, items_[0])
raise nbxmpp.NodeProcessed
def send_stored_publish(self) -> None:
for module in self._store_publish_modules:
......
# Copyright (C) 2007 Piotr Gaczkowski <doomhammerng AT gmail.com>
# Copyright (C) 2007-2014 Yann Leboulanger <asterix AT lagaule.org>
# Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
# Jean-Marie Traissard <jim AT lapin.org>
# Jonathan Schleifer <js-common.gajim AT webkeks.org>
# Stephan Erb <steve-e AT h3c.de>
#
# 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/>.
from typing import Any # pylint: disable=unused-import
from typing import List # pylint: disable=unused-import
import logging
from gajim.common import app
log = logging.getLogger('gajim.c.pep')
class AbstractPEP:
type_ = ''
namespace = ''
@classmethod
def get_tag_as_PEP(cls, jid, account, event_tag):
items = event_tag.getTag('items', {'node': cls.namespace})
if items:
log.debug('Received PEP "user %s" from %s', cls.type_, jid)
return cls(jid, account, items)
return None
def __init__(self, jid, account, items):
self.data, self._retracted = self._extract_info(items)
self._update_contacts(jid, account)
if jid == app.get_jid_from_account(account):
self._update_account(account)
self._on_receive(jid, account)
def _extract_info(self, items):
'''To be implemented by subclasses'''
raise NotImplementedError
def _update_contacts(self, jid, account):
for contact in app.contacts.get_contacts(account, jid):
if self._retracted:
if self.type_ in contact.pep:
del contact.pep[self.type_]
else:
contact.pep[self.type_] = self
def _update_account(self, account):
acc = app.connections[account]
if self._retracted:
if self.type_ in acc.pep:
del acc.pep[self.type_]
else:
acc.pep[self.type_] = self
def as_markup_text(self):
'''SHOULD be implemented by subclasses'''
return ''
def _on_receive(self, jid, account):
'''SHOULD be implemented by subclasses'''
pass
SUPPORTED_PERSONAL_USER_EVENTS = [] # type: List[Any]
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