Skip to content
Snippets Groups Projects
Commit 20b33a7e authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

chore: Gateway: Add type annotations

parent f79f7c7f
No related branches found
No related tags found
No related merge requests found
......@@ -14,20 +14,26 @@
# XEP-0100: Gateway Interaction
from __future__ import annotations
from typing import Optional
import nbxmpp
from nbxmpp.protocol import Iq
from nbxmpp.namespaces import Namespace
from gajim.common import app
from gajim.common import types
from gajim.common.events import AgentRemoved
from gajim.common.events import GatewayPromptReceived
from gajim.common.modules.base import BaseModule
class Gateway(BaseModule):
def __init__(self, con):
def __init__(self, con: types.Client) -> None:
BaseModule.__init__(self, con)
def unsubscribe(self, agent):
def unsubscribe(self, agent: str) -> None:
if not app.account_is_available(self._account):
return
iq = nbxmpp.Iq('set', Namespace.REGISTER, to=agent)
......@@ -37,7 +43,10 @@ def unsubscribe(self, agent):
iq, self._on_unsubscribe_result)
self._con.get_module('Roster').delete_item(agent)
def _on_unsubscribe_result(self, _nbxmpp_client, stanza):
def _on_unsubscribe_result(self,
_nbxmpp_client: types.xmppClient,
stanza: nbxmpp.Node
) -> None:
if not nbxmpp.isResultNode(stanza):
self._log.info('Error: %s', stanza.getError())
return
......@@ -63,7 +72,10 @@ def _on_unsubscribe_result(self, _nbxmpp_client, stanza):
agent=agent,
jid_list=jid_list))
def request_gateway_prompt(self, jid, prompt=None):
def request_gateway_prompt(self,
jid: str,
prompt: Optional[str] = None
) -> None:
typ_ = 'get'
if prompt:
typ_ = 'set'
......@@ -73,7 +85,10 @@ def request_gateway_prompt(self, jid, prompt=None):
query.setTagData('prompt', prompt)
self._con.connection.SendAndCallForResponse(iq, self._on_prompt_result)
def _on_prompt_result(self, _nbxmpp_client, stanza):
def _on_prompt_result(self,
_nbxmpp_client: types.xmppClient,
stanza: Iq
) -> None:
jid = str(stanza.getFrom())
fjid = stanza.getFrom().bare
resource = stanza.getFrom().resource
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment