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
91944ee2
Commit
91944ee2
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: UserTune: Add type annotations
parent
c09d9494
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/user_tune.py
+15
-6
15 additions, 6 deletions
gajim/common/modules/user_tune.py
with
15 additions
and
6 deletions
gajim/common/modules/user_tune.py
+
15
−
6
View file @
91944ee2
...
...
@@ -16,18 +16,23 @@
from
__future__
import
annotations
from
typing
import
Any
from
typing
import
Optional
from
nbxmpp.namespaces
import
Namespace
from
nbxmpp.protocol
import
JID
from
nbxmpp.structs
import
MessageProperties
from
nbxmpp.structs
import
TuneData
from
gajim.common
import
app
from
gajim.common
import
ged
from
gajim.common
import
types
from
gajim.common.modules.base
import
BaseModule
from
gajim.common.modules.util
import
event_node
from
gajim.common.modules.util
import
store_publish
from
gajim.common.dbus.music_track
import
MusicTrackListener
from
gajim.common.events
import
MusicTrackChanged
from
gajim.common.events
import
SignedIn
from
gajim.common.helpers
import
event_filter
...
...
@@ -38,7 +43,7 @@ class UserTune(BaseModule):
'
set_tune
'
,
]
def
__init__
(
self
,
con
)
:
def
__init__
(
self
,
con
:
types
.
Client
)
->
None
:
BaseModule
.
__init__
(
self
,
con
)
self
.
_register_pubsub_handler
(
self
.
_tune_received
)
self
.
_current_tune
:
Optional
[
TuneData
]
=
None
...
...
@@ -51,7 +56,11 @@ def get_contact_tune(self, jid: JID) -> Optional[TuneData]:
return
self
.
_contact_tunes
.
get
(
jid
)
@event_node
(
Namespace
.
TUNE
)
def
_tune_received
(
self
,
_con
,
_stanza
,
properties
):
def
_tune_received
(
self
,
_con
:
types
.
xmppClient
,
_stanza
:
Any
,
properties
:
MessageProperties
)
->
None
:
if
properties
.
pubsub_event
.
retracted
:
return
...
...
@@ -65,7 +74,7 @@ def _tune_received(self, _con, _stanza, properties):
contact
.
notify
(
'
tune-update
'
,
data
)
@store_publish
def
set_tune
(
self
,
tune
,
force
=
False
)
:
def
set_tune
(
self
,
tune
:
Optional
[
TuneData
],
force
:
bool
=
False
)
->
None
:
if
not
self
.
_con
.
get_module
(
'
PEP
'
).
supported
:
return
...
...
@@ -81,7 +90,7 @@ def set_tune(self, tune, force=False):
self
.
_log
.
info
(
'
Send %s
'
,
tune
)
self
.
_nbxmpp
(
'
Tune
'
).
set_tune
(
tune
)
def
set_enabled
(
self
,
enable
)
:
def
set_enabled
(
self
,
enable
:
bool
)
->
None
:
if
enable
:
self
.
register_events
([
(
'
music-track-changed
'
,
ged
.
CORE
,
self
.
_on_music_track_changed
),
...
...
@@ -96,10 +105,10 @@ def _publish_current_tune(self):
self
.
set_tune
(
MusicTrackListener
.
get
().
current_tune
)
@event_filter
([
'
account
'
])
def
_on_signed_in
(
self
,
_event
)
:
def
_on_signed_in
(
self
,
_event
:
SignedIn
)
->
None
:
self
.
_publish_current_tune
()
def
_on_music_track_changed
(
self
,
event
)
:
def
_on_music_track_changed
(
self
,
event
:
MusicTrackChanged
)
->
None
:
if
self
.
_current_tune
==
event
.
info
:
return
...
...
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