2018-07-03 00:10:55 +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/>.
|
|
|
|
|
|
|
|
# XEP-0163: Personal Eventing Protocol
|
|
|
|
|
2018-09-13 23:56:12 +02:00
|
|
|
from typing import Any
|
|
|
|
from typing import Dict
|
|
|
|
from typing import List
|
|
|
|
from typing import Tuple
|
|
|
|
|
2018-07-03 00:10:55 +02:00
|
|
|
import nbxmpp
|
|
|
|
|
2018-09-13 23:56:12 +02:00
|
|
|
from gajim.common.types import ConnectionT
|
2019-02-17 21:21:54 +01:00
|
|
|
from gajim.common.modules.base import BaseModule
|
|
|
|
|
2018-07-03 00:10:55 +02:00
|
|
|
|
2019-02-17 21:21:54 +01:00
|
|
|
class PEP(BaseModule):
|
2018-09-13 23:56:12 +02:00
|
|
|
def __init__(self, con: ConnectionT) -> None:
|
2019-02-17 21:21:54 +01:00
|
|
|
BaseModule.__init__(self, con)
|
2018-07-03 00:10:55 +02:00
|
|
|
|
2018-07-22 12:18:24 +02:00
|
|
|
self.supported = False
|
2018-09-13 23:56:12 +02:00
|
|
|
|
|
|
|
def pass_disco(self,
|
|
|
|
from_: nbxmpp.JID,
|
|
|
|
identities: List[Dict[str, str]],
|
|
|
|
_features: List[str],
|
|
|
|
_data: List[nbxmpp.DataForm],
|
|
|
|
_node: str) -> None:
|
2018-07-22 12:18:24 +02:00
|
|
|
for identity in identities:
|
|
|
|
if identity['category'] == 'pubsub':
|
|
|
|
if identity.get('type') == 'pep':
|
2019-03-09 23:16:27 +01:00
|
|
|
self._log.info('Discovered PEP support: %s', from_)
|
2018-07-22 12:18:24 +02:00
|
|
|
self.supported = True
|
|
|
|
|
2018-07-07 13:52:44 +02:00
|
|
|
|
2018-09-13 23:56:12 +02:00
|
|
|
def get_instance(*args: Any, **kwargs: Any) -> Tuple[PEP, str]:
|
2018-07-07 13:52:44 +02:00
|
|
|
return PEP(*args, **kwargs), 'PEP'
|