if peer doesn't do chat state do not keep respect that; overcome jep violations for chat state transitions
This commit is contained in:
parent
d03931eec3
commit
754999db24
|
@ -385,7 +385,7 @@ class Interface:
|
||||||
chat_win.print_conversation(jid + ' is now ' + chatstate_tag, jid, 'status', tim = array[2])
|
chat_win.print_conversation(jid + ' is now ' + chatstate_tag, jid, 'status', tim = array[2])
|
||||||
else:
|
else:
|
||||||
# got no valid jep85 answer, peer does not support it
|
# got no valid jep85 answer, peer does not support it
|
||||||
chat_win.chatstates[jid] = -1
|
chat_win.chatstates[jid] = False
|
||||||
|
|
||||||
if not array[1]: #empty message
|
if not array[1]: #empty message
|
||||||
return
|
return
|
||||||
|
|
|
@ -26,11 +26,13 @@ from common import i18n
|
||||||
|
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
|
|
||||||
|
USE_DBUS = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dbus
|
import dbus
|
||||||
_version = getattr(dbus, 'version', (0, 20, 0))
|
_version = getattr(dbus, 'version', (0, 20, 0))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
USE_DBUS = True # user can't do OpenGPG only if he removed the file!
|
||||||
|
|
||||||
if _version >= (0, 41, 0):
|
if _version >= (0, 41, 0):
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
|
|
@ -442,7 +442,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
# None, False and 'ask'
|
# None, False and 'ask'
|
||||||
# None if no info about peer
|
# None if no info about peer
|
||||||
# False if peer does not support jep85
|
# False if peer does not support jep85
|
||||||
# 'ask' if we sent 'active' chatstate and are waiting for reply
|
# 'ask' if we sent the first 'active' chatstate and are waiting for reply
|
||||||
|
|
||||||
# JEP 85 does not allow resending the same chatstate
|
# JEP 85 does not allow resending the same chatstate
|
||||||
# this function checks for that and just returns so it's safe to call it
|
# this function checks for that and just returns so it's safe to call it
|
||||||
|
@ -481,13 +481,13 @@ class TabbedChatWindow(chat.Chat):
|
||||||
|
|
||||||
# prevent going paused if we we were not composing (JEP violation)
|
# prevent going paused if we we were not composing (JEP violation)
|
||||||
if state == 'paused' and not self.chatstates[jid] == 'composing':
|
if state == 'paused' and not self.chatstates[jid] == 'composing':
|
||||||
raise RuntimeError, 'paused chatstate can only exist after composing'
|
gajim.connections[self.account].send_message(jid, None, None,
|
||||||
|
chatstate = 'active') # go active before
|
||||||
|
|
||||||
# if we're inactive prevent composing (JEP violation)
|
# if we're inactive prevent composing (JEP violation)
|
||||||
if self.chatstates[jid] == 'inactive' and state == 'composing':
|
if self.chatstates[jid] == 'inactive' and state == 'composing':
|
||||||
gajim.connections[self.account].send_message(jid, None, None,
|
gajim.connections[self.account].send_message(jid, None, None,
|
||||||
chatstate = 'active') # send active before
|
chatstate = 'active') # go active before
|
||||||
#raise RuntimeError, 'inactive chatstate can only be followed by active'
|
|
||||||
|
|
||||||
self.chatstates[jid] = state
|
self.chatstates[jid] = state
|
||||||
#print 'SENDING', state
|
#print 'SENDING', state
|
||||||
|
@ -520,8 +520,11 @@ class TabbedChatWindow(chat.Chat):
|
||||||
|
|
||||||
notif_on = gajim.config.get('send_receive_chat_state_notifications')
|
notif_on = gajim.config.get('send_receive_chat_state_notifications')
|
||||||
# chatstates - if no info about peer, start discover procedure
|
# chatstates - if no info about peer, start discover procedure
|
||||||
|
chatstate_to_send = None
|
||||||
if notif_on: # if we have them one
|
if notif_on: # if we have them one
|
||||||
|
|
||||||
|
#FIXME: move me from here to if self.chatstates[jid] is None:
|
||||||
|
#in send_chatstae
|
||||||
if self.chatstates[jid] is None:
|
if self.chatstates[jid] is None:
|
||||||
chatstate_to_send = 'active'
|
chatstate_to_send = 'active'
|
||||||
self.chatstates[jid] = 'ask'
|
self.chatstates[jid] = 'ask'
|
||||||
|
@ -530,11 +533,10 @@ class TabbedChatWindow(chat.Chat):
|
||||||
elif self.chatstates[jid] != False:
|
elif self.chatstates[jid] != False:
|
||||||
#send active chatstate on every message (as JEP says)
|
#send active chatstate on every message (as JEP says)
|
||||||
chatstate_to_send = 'active'
|
chatstate_to_send = 'active'
|
||||||
else: # just send the message
|
|
||||||
chatstate_to_send = None
|
|
||||||
|
|
||||||
gajim.connections[self.account].send_message(jid, message, keyID,
|
gajim.connections[self.account].send_message(jid, message, keyID,
|
||||||
chatstate = chatstate_to_send)
|
chatstate = chatstate_to_send)
|
||||||
|
|
||||||
message_buffer.set_text('')
|
message_buffer.set_text('')
|
||||||
self.print_conversation(message, jid, jid, encrypted = encrypted)
|
self.print_conversation(message, jid, jid, encrypted = encrypted)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue