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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Peter Shkenev
gajim
Commits
bc2309b6
Commit
bc2309b6
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
fixes in 30 secs timer, other chatstate logical fixes, raise exceptions on jep violations
parent
0bde1f52
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
src/tabbed_chat_window.py
+35
-38
35 additions, 38 deletions
src/tabbed_chat_window.py
with
35 additions
and
38 deletions
src/tabbed_chat_window.py
+
35
−
38
View file @
bc2309b6
...
...
@@ -228,19 +228,14 @@ def on_tabbed_chat_window_focus_in_event(self, widget, event):
self
.
send_chatstate
(
'
active
'
)
def
on_tabbed_chat_window_focus_out_event
(
self
,
widget
,
event
):
gobject
.
timeout_add
(
500
,
self
.
check_window_state
,
widget
)
def
check_window_state
(
self
,
widget
):
'''
we want:
"
minimized
"
or
"
focus-out
"
not
"
focus-out, minimized
"
or
"
focus-out
"
'''
widget
.
realize
()
new_state
=
widget
.
window
.
get_state
()
if
new_state
&
gtk
.
gdk
.
WINDOW_STATE_ICONIFIED
:
print
'
iconify
'
self
.
send_chatstate
(
'
inactive
'
)
else
:
print
'
just focus-out
'
self
.
send_chatstate
(
'
paused
'
)
'''
catch focus out and minimized and send inactive chatstate;
minimize action also focuses out first so it
'
s catched here
'''
window_state
=
widget
.
window
.
get_state
()
if
window_state
is
None
:
print
'
return NOOOOOONE
'
return
self
.
send_chatstate
(
'
inactive
'
)
def
on_chat_notebook_key_press_event
(
self
,
widget
,
event
):
chat
.
Chat
.
on_chat_notebook_key_press_event
(
self
,
widget
,
event
)
...
...
@@ -324,21 +319,22 @@ def new_user(self, contact):
def
check_for_possible_paused_chatstate
(
self
,
contact
):
'''
did we move mouse of that window or kbd activity in that window
if yes we go active
if not already
if no we go paused if
not already
'''
if yes we go active
if no we go paused if
we were previously composing
'''
current_state
=
self
.
chatstates
[
contact
.
jid
]
if
current_state
==
False
:
#
he
doesn't support chatstates
if
current_state
==
False
:
#
jid
doesn't support chatstates
return
False
# stop looping
print
'
mouse
'
,
self
.
mouse_over_in_last_5_secs
print
'
kbd
'
,
self
.
kbd_activity_in_last_5_secs
#
print 'mouse', self.mouse_over_in_last_5_secs
#
print 'kbd', self.kbd_activity_in_last_5_secs
if
self
.
mouse_over_in_last_5_secs
:
self
.
send_chatstate
(
'
active
'
)
elif
self
.
kbd_activity_in_last_5_secs
:
self
.
send_chatstate
(
'
composing
'
)
else
:
self
.
send_chatstate
(
'
paused
'
)
if
self
.
chatstates
[
contact
.
jid
]
==
'
composing
'
:
self
.
send_chatstate
(
'
paused
'
)
# pause composing
# assume no activity and let the motion-notify or key_press make them True
self
.
mouse_over_in_last_5_secs
=
False
...
...
@@ -355,14 +351,11 @@ def check_for_possible_inactive_chatstate(self, contact):
if yes we go active if not already
if no we go inactive if not already
'''
current_state
=
self
.
chatstates
[
contact
.
jid
]
if
current_state
==
False
:
#
he
doesn't support chatstates
if
current_state
==
False
:
#
jid
doesn't support chatstates
return
False
# stop looping
if
self
.
mouse_over_in_last_30_secs
:
self
.
send_chatstate
(
'
active
'
)
elif
self
.
kbd_activity_in_last_30_secs
:
self
.
send_chatstate
(
'
composing
'
)
else
:
if
not
(
self
.
mouse_over_in_last_30_secs
or
\
self
.
kbd_activity_in_last_30_secs
):
self
.
send_chatstate
(
'
inactive
'
)
# assume no activity and let the motion-notify or key_press make them True
...
...
@@ -436,12 +429,20 @@ def on_message_textview_key_press_event(self, widget, event):
def
send_chatstate
(
self
,
state
):
'''
sends our chatstate to the current tab only if new chatstate
is different for the previous one
'''
# please read jep-85
to get an idea of this
# please read jep-85
http://www.jabber.org/jeps/jep-0085.html
# we keep track of jep85 support by the peer by three extra states:
# None, False and 'ask'
# None if no info about peer
# False if peer does not support jep85
# 'ask' if we sent 'active' chatstate and are waiting for reply
# JEP 85 does not allow resending the same chatstate
# this function checks for that and just returns so it's safe to call it
# with same state.
# This functions also checks for violation in state transitions
# and raises RuntimeException with appropriate message
# more on that http://www.jabber.org/jeps/jep-0085.html#statechart
# do not send nothing if we have chat state notifications disabled
if
not
gajim
.
config
.
get
(
'
send_chat_state_notifications
'
):
...
...
@@ -449,10 +450,10 @@ def send_chatstate(self, state):
jid
=
self
.
get_active_jid
()
if
self
.
chatstates
[
jid
]
==
False
:
if
self
.
chatstates
[
jid
]
==
False
:
# jid cannot do jep85
return
# if current state equals
last
state, return
# if current state equals
previous
state, return
if
self
.
chatstates
[
jid
]
==
state
:
return
...
...
@@ -463,18 +464,14 @@ def send_chatstate(self, state):
if
self
.
chatstates
[
jid
]
==
'
ask
'
:
return
# prevent going paused if we we were not composing (JEP violation)
if
state
==
'
paused
'
and
not
self
.
chatstates
[
jid
]
==
'
composing
'
:
raise
RuntimeError
,
'
paused chatstate can only exist after composing
'
# if last state was composing, don't send active
if
self
.
chatstates
[
jid
]
==
'
composing
'
and
state
==
'
active
'
:
return
# if we're inactive prevent paused (inactive is stronger)
if
self
.
chatstates
[
jid
]
==
'
inactive
'
and
state
==
'
paused
'
:
return
# if we're inactive prevent paused (inactive is stronger)
# if we're inactive prevent composing (JEP violation)
if
self
.
chatstates
[
jid
]
==
'
inactive
'
and
state
==
'
composing
'
:
r
eturn
r
aise
RuntimeError
,
'
inactive chatstate can only be followed by active
'
self
.
chatstates
[
jid
]
=
state
gajim
.
connections
[
self
.
account
].
send_message
(
jid
,
None
,
None
,
...
...
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