Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
20b33a7e
Commit
20b33a7e
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: Gateway: Add type annotations
parent
f79f7c7f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/common/modules/gateway.py
+20
-5
20 additions, 5 deletions
gajim/common/modules/gateway.py
with
20 additions
and
5 deletions
gajim/common/modules/gateway.py
+
20
−
5
View file @
20b33a7e
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment