fix some archiving session negotiation bugs
print archving negotiation result in chat control
This commit is contained in:
parent
3d4688e9fa
commit
5a3ef285a5
|
@ -46,6 +46,7 @@ from common import exceptions
|
||||||
from message_control import MessageControl
|
from message_control import MessageControl
|
||||||
from conversation_textview import ConversationTextview
|
from conversation_textview import ConversationTextview
|
||||||
from message_textview import MessageTextView
|
from message_textview import MessageTextView
|
||||||
|
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||||
from common.contacts import GC_Contact
|
from common.contacts import GC_Contact
|
||||||
from common.logger import constants
|
from common.logger import constants
|
||||||
from common.pep import MOODS, ACTIVITIES
|
from common.pep import MOODS, ACTIVITIES
|
||||||
|
@ -1394,7 +1395,7 @@ class ChatControl(ChatControlBase):
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
if session.enable_encryption:
|
if session.enable_encryption:
|
||||||
self.print_esession_details()
|
self.print_session_details()
|
||||||
|
|
||||||
# Enable encryption if needed
|
# Enable encryption if needed
|
||||||
self.no_autonegotiation = False
|
self.no_autonegotiation = False
|
||||||
|
@ -2055,6 +2056,17 @@ class ChatControl(ChatControlBase):
|
||||||
msg = _('Session negotiation cancelled')
|
msg = _('Session negotiation cancelled')
|
||||||
ChatControlBase.print_conversation_line(self, msg, 'status', '', None)
|
ChatControlBase.print_conversation_line(self, msg, 'status', '', None)
|
||||||
|
|
||||||
|
def print_archiving_session_details(self):
|
||||||
|
"""
|
||||||
|
Print esession settings to textview
|
||||||
|
"""
|
||||||
|
archiving = bool(self.session) and self.session.archiving
|
||||||
|
if archiving:
|
||||||
|
msg = _('This session WILL be archived on server')
|
||||||
|
else:
|
||||||
|
msg = _('This session WILL NOT be archived on server')
|
||||||
|
ChatControlBase.print_conversation_line(self, msg, 'status', '', None)
|
||||||
|
|
||||||
def print_esession_details(self):
|
def print_esession_details(self):
|
||||||
"""
|
"""
|
||||||
Print esession settings to textview
|
Print esession settings to textview
|
||||||
|
@ -2079,6 +2091,12 @@ class ChatControl(ChatControlBase):
|
||||||
self._show_lock_image(e2e_is_active, 'E2E', e2e_is_active, self.session and \
|
self._show_lock_image(e2e_is_active, 'E2E', e2e_is_active, self.session and \
|
||||||
self.session.is_loggable(), self.session and self.session.verified_identity)
|
self.session.is_loggable(), self.session and self.session.verified_identity)
|
||||||
|
|
||||||
|
def print_session_details(self):
|
||||||
|
if isinstance(self.session, EncryptedStanzaSession):
|
||||||
|
self.print_esession_details()
|
||||||
|
elif isinstance(self.session, ArchivingStanzaSession):
|
||||||
|
self.print_archiving_session_details()
|
||||||
|
|
||||||
def print_conversation(self, text, frm='', tim=None, encrypted=False,
|
def print_conversation(self, text, frm='', tim=None, encrypted=False,
|
||||||
subject=None, xhtml=None, simple=False, xep0184_id=None):
|
subject=None, xhtml=None, simple=False, xep0184_id=None):
|
||||||
"""
|
"""
|
||||||
|
@ -2511,7 +2529,7 @@ class ChatControl(ChatControlBase):
|
||||||
if want_e2e and not self.no_autonegotiation \
|
if want_e2e and not self.no_autonegotiation \
|
||||||
and gajim.HAVE_PYCRYPTO and self.contact.supports(NS_ESESSION):
|
and gajim.HAVE_PYCRYPTO and self.contact.supports(NS_ESESSION):
|
||||||
self.begin_e2e_negotiation()
|
self.begin_e2e_negotiation()
|
||||||
elif not self.session.accepted:
|
elif not self.session or not self.session.status:
|
||||||
self.begin_archiving_negotiation()
|
self.begin_archiving_negotiation()
|
||||||
else:
|
else:
|
||||||
self.send_chatstate('active', self.contact)
|
self.send_chatstate('active', self.contact)
|
||||||
|
|
|
@ -1297,10 +1297,7 @@ class ConnectionVcard:
|
||||||
count = 0
|
count = 0
|
||||||
if count > index + nb:
|
if count > index + nb:
|
||||||
# Request the next page
|
# Request the next page
|
||||||
try:
|
after = element.getTagData('last')
|
||||||
after = int(element.getTagData('last'))
|
|
||||||
except TypeError:
|
|
||||||
after = index + nb
|
|
||||||
self.request_collection_page(with_, start_, after=after)
|
self.request_collection_page(with_, start_, after=after)
|
||||||
|
|
||||||
elif self.awaiting_answers[id_][0] == ARCHIVING_MODIFICATIONS_ARRIVED:
|
elif self.awaiting_answers[id_][0] == ARCHIVING_MODIFICATIONS_ARRIVED:
|
||||||
|
|
|
@ -177,7 +177,7 @@ class StanzaSession(object):
|
||||||
class ArchivingStanzaSession(StanzaSession):
|
class ArchivingStanzaSession(StanzaSession):
|
||||||
def __init__(self, conn, jid, thread_id, type_='chat'):
|
def __init__(self, conn, jid, thread_id, type_='chat'):
|
||||||
StanzaSession.__init__(self, conn, jid, thread_id, type_='chat')
|
StanzaSession.__init__(self, conn, jid, thread_id, type_='chat')
|
||||||
self.accepted = False
|
self.archiving = False
|
||||||
|
|
||||||
def archiving_logging_preference(self, initiator_options=None):
|
def archiving_logging_preference(self, initiator_options=None):
|
||||||
return self.conn.logging_preference(self.jid, initiator_options)
|
return self.conn.logging_preference(self.jid, initiator_options)
|
||||||
|
@ -206,7 +206,7 @@ class ArchivingStanzaSession(StanzaSession):
|
||||||
|
|
||||||
feature.addChild(node=x)
|
feature.addChild(node=x)
|
||||||
|
|
||||||
self.status = 'requested'
|
self.status = 'requested-archiving'
|
||||||
|
|
||||||
self.send(request)
|
self.send(request)
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ class ArchivingStanzaSession(StanzaSession):
|
||||||
|
|
||||||
x.addChild(node=xmpp.DataField(name='logging', value=logging))
|
x.addChild(node=xmpp.DataField(name='logging', value=logging))
|
||||||
|
|
||||||
self.status = 'responded'
|
self.status = 'responded-archiving'
|
||||||
|
|
||||||
feature.addChild(node=x)
|
feature.addChild(node=x)
|
||||||
|
|
||||||
|
@ -250,7 +250,10 @@ class ArchivingStanzaSession(StanzaSession):
|
||||||
if self.negotiated['logging'] == 'mustnot':
|
if self.negotiated['logging'] == 'mustnot':
|
||||||
self.loggable = False
|
self.loggable = False
|
||||||
print 'SESSION ACCEPTED', self.loggable
|
print 'SESSION ACCEPTED', self.loggable
|
||||||
self.accepted = True
|
self.status = 'active'
|
||||||
|
self.archiving = True
|
||||||
|
if self.control:
|
||||||
|
self.control.print_archiving_session_details()
|
||||||
|
|
||||||
def accept_archiving_alice(self, form):
|
def accept_archiving_alice(self, form):
|
||||||
negotiated = {}
|
negotiated = {}
|
||||||
|
@ -278,7 +281,10 @@ class ArchivingStanzaSession(StanzaSession):
|
||||||
if self.negotiated['logging'] == 'mustnot':
|
if self.negotiated['logging'] == 'mustnot':
|
||||||
self.loggable = False
|
self.loggable = False
|
||||||
print 'SESSION ACCEPTED', self.loggable
|
print 'SESSION ACCEPTED', self.loggable
|
||||||
self.accepted = True
|
self.status = 'active'
|
||||||
|
self.archiving = True
|
||||||
|
if self.control:
|
||||||
|
self.control.print_archiving_session_details()
|
||||||
|
|
||||||
|
|
||||||
class EncryptedStanzaSession(ArchivingStanzaSession):
|
class EncryptedStanzaSession(ArchivingStanzaSession):
|
||||||
|
@ -307,7 +313,7 @@ class EncryptedStanzaSession(ArchivingStanzaSession):
|
||||||
handle_session_negotiation method.
|
handle_session_negotiation method.
|
||||||
'''
|
'''
|
||||||
def __init__(self, conn, jid, thread_id, type_='chat'):
|
def __init__(self, conn, jid, thread_id, type_='chat'):
|
||||||
StanzaSession.__init__(self, conn, jid, thread_id, type_='chat')
|
ArchivingStanzaSession.__init__(self, conn, jid, thread_id, type_='chat')
|
||||||
|
|
||||||
self.xes = {}
|
self.xes = {}
|
||||||
self.es = {}
|
self.es = {}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import gtkgui_helpers
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
|
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||||
|
|
||||||
# Derived types MUST register their type IDs here if custom behavor is required
|
# Derived types MUST register their type IDs here if custom behavor is required
|
||||||
TYPE_CHAT = 'chat'
|
TYPE_CHAT = 'chat'
|
||||||
|
@ -163,11 +164,16 @@ class MessageControl:
|
||||||
if self.resource:
|
if self.resource:
|
||||||
jid += '/' + self.resource
|
jid += '/' + self.resource
|
||||||
|
|
||||||
crypto_changed = bool(session and session.enable_encryption) != \
|
crypto_changed = bool(session and isinstance(session,
|
||||||
|
EncryptedStanzaSession) and session.enable_encryption) != \
|
||||||
bool(oldsession and oldsession.enable_encryption)
|
bool(oldsession and oldsession.enable_encryption)
|
||||||
|
|
||||||
if crypto_changed:
|
archiving_changed = bool(session and isinstance(session,
|
||||||
self.print_esession_details()
|
ArchivingStanzaSession) and session.archiving) != \
|
||||||
|
bool(oldsession and oldsession.archiving)
|
||||||
|
|
||||||
|
if crypto_changed or archiving_changed:
|
||||||
|
self.print_session_details()
|
||||||
|
|
||||||
def send_message(self, message, keyID='', type_='chat', chatstate=None,
|
def send_message(self, message, keyID='', type_='chat', chatstate=None,
|
||||||
msg_id=None, composing_xep=None, resource=None, user_nick=None, xhtml=None,
|
msg_id=None, composing_xep=None, resource=None, user_nick=None, xhtml=None,
|
||||||
|
|
|
@ -440,7 +440,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
elif self.status == 'requested' and form.getType() == 'submit':
|
elif self.status == 'requested-archiving' and form.getType() == \
|
||||||
|
'submit':
|
||||||
try:
|
try:
|
||||||
self.accept_archiving_alice(form)
|
self.accept_archiving_alice(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError, details:
|
||||||
|
@ -481,7 +482,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
elif self.status == 'responded' and form.getType() == 'result':
|
elif self.status == 'responded-archiving' and form.getType() == \
|
||||||
|
'result':
|
||||||
try:
|
try:
|
||||||
self.accept_archiving_bob(form)
|
self.accept_archiving_bob(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError, details:
|
||||||
|
|
Loading…
Reference in New Issue