don't create uneccessary sessions (eg. for groupchat messages), bugfix for pms
This commit is contained in:
parent
59b7e83fd5
commit
88e49ffa46
6 changed files with 17 additions and 17 deletions
|
@ -1356,7 +1356,7 @@ class ChatControl(ChatControlBase):
|
||||||
name = ''
|
name = ''
|
||||||
else:
|
else:
|
||||||
# ESessions
|
# ESessions
|
||||||
if self.session.enable_encryption:
|
if self.session and self.session.enable_encryption:
|
||||||
if not self.esessioned:
|
if not self.esessioned:
|
||||||
msg = _('Encryption enabled')
|
msg = _('Encryption enabled')
|
||||||
ChatControlBase.print_conversation_line(self, msg,
|
ChatControlBase.print_conversation_line(self, msg,
|
||||||
|
|
|
@ -1429,7 +1429,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if not mtype:
|
if not mtype:
|
||||||
mtype = 'normal'
|
mtype = 'normal'
|
||||||
|
|
||||||
session = self.get_session(frm, thread_id, mtype)
|
if not mtype == 'groupchat':
|
||||||
|
session = self.get_session(frm, thread_id, mtype)
|
||||||
|
|
||||||
if thread_id and not session.received_thread_id:
|
if thread_id and not session.received_thread_id:
|
||||||
session.received_thread_id = True
|
session.received_thread_id = True
|
||||||
|
@ -1545,7 +1546,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if not self.last_history_line.has_key(jid):
|
if not self.last_history_line.has_key(jid):
|
||||||
return
|
return
|
||||||
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
||||||
if session.is_loggable() and not int(float(time.mktime(tim)))\
|
if not int(float(time.mktime(tim)))\
|
||||||
<= self.last_history_line[jid] and msgtxt:
|
<= self.last_history_line[jid] and msgtxt:
|
||||||
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
||||||
return
|
return
|
||||||
|
@ -1577,8 +1578,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
|
|
||||||
def get_session(self, jid, thread_id, type):
|
def get_session(self, jid, thread_id, type):
|
||||||
'''returns an existing session between this connection and 'jid', returns a new one if none exist.'''
|
'''returns an existing session between this connection and 'jid', returns a new one if none exist.'''
|
||||||
print repr(self.sessions)
|
|
||||||
|
|
||||||
session = self.find_session(jid, thread_id, type)
|
session = self.find_session(jid, thread_id, type)
|
||||||
|
|
||||||
if session:
|
if session:
|
||||||
|
|
|
@ -769,7 +769,6 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
|
|
||||||
k = self.sha256(k + srs + oss)
|
k = self.sha256(k + srs + oss)
|
||||||
|
|
||||||
# XXX I can skip generating ks_o here
|
|
||||||
self.kc_s, self.km_s, self.ks_s = self.generate_responder_keys(k)
|
self.kc_s, self.km_s, self.ks_s = self.generate_responder_keys(k)
|
||||||
self.kc_o, self.km_o, self.ks_o = self.generate_initiator_keys(k)
|
self.kc_o, self.km_o, self.ks_o = self.generate_initiator_keys(k)
|
||||||
|
|
||||||
|
|
|
@ -776,7 +776,7 @@ class Interface:
|
||||||
if pm:
|
if pm:
|
||||||
nickname = resource
|
nickname = resource
|
||||||
groupchat_control.on_private_message(nickname, message, array[2],
|
groupchat_control.on_private_message(nickname, message, array[2],
|
||||||
xhtml)
|
xhtml, session)
|
||||||
else:
|
else:
|
||||||
# array: (jid, msg, time, encrypted, msg_type, subject)
|
# array: (jid, msg, time, encrypted, msg_type, subject)
|
||||||
if encrypted:
|
if encrypted:
|
||||||
|
|
|
@ -97,12 +97,12 @@ def tree_cell_data_func(column, renderer, model, iter, tv=None):
|
||||||
class PrivateChatControl(ChatControl):
|
class PrivateChatControl(ChatControl):
|
||||||
TYPE_ID = message_control.TYPE_PM
|
TYPE_ID = message_control.TYPE_PM
|
||||||
|
|
||||||
def __init__(self, parent_win, gc_contact, contact, acct):
|
def __init__(self, parent_win, gc_contact, contact, acct, session):
|
||||||
room_jid = contact.jid.split('/')[0]
|
room_jid = contact.jid.split('/')[0]
|
||||||
room_ctrl = gajim.interface.msg_win_mgr.get_control(room_jid, acct)
|
room_ctrl = gajim.interface.msg_win_mgr.get_control(room_jid, acct)
|
||||||
self.room_name = room_ctrl.name
|
self.room_name = room_ctrl.name
|
||||||
self.gc_contact = gc_contact
|
self.gc_contact = gc_contact
|
||||||
ChatControl.__init__(self, parent_win, contact, acct)
|
ChatControl.__init__(self, parent_win, contact, acct, session)
|
||||||
self.TYPE_ID = 'pm'
|
self.TYPE_ID = 'pm'
|
||||||
|
|
||||||
def send_message(self, message):
|
def send_message(self, message):
|
||||||
|
@ -519,7 +519,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
self.print_conversation(msg, nick, tim, xhtml)
|
self.print_conversation(msg, nick, tim, xhtml)
|
||||||
|
|
||||||
def on_private_message(self, nick, msg, tim, xhtml):
|
def on_private_message(self, nick, msg, tim, xhtml, session):
|
||||||
# Do we have a queue?
|
# Do we have a queue?
|
||||||
fjid = self.room_jid + '/' + nick
|
fjid = self.room_jid + '/' + nick
|
||||||
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
||||||
|
@ -531,7 +531,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
event = gajim.events.create_event('pm', (msg, '', 'incoming', tim,
|
event = gajim.events.create_event('pm', (msg, '', 'incoming', tim,
|
||||||
False, '', None, xhtml))
|
False, '', None, xhtml, session))
|
||||||
gajim.events.add_event(self.account, fjid, event)
|
gajim.events.add_event(self.account, fjid, event)
|
||||||
|
|
||||||
autopopup = gajim.config.get('autopopup')
|
autopopup = gajim.config.get('autopopup')
|
||||||
|
@ -551,7 +551,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.parent_win.show_title()
|
self.parent_win.show_title()
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
else:
|
else:
|
||||||
self._start_private_message(nick)
|
self._start_private_message(nick, session)
|
||||||
# Scroll to line
|
# Scroll to line
|
||||||
self.list_treeview.expand_row(path[0:1], False)
|
self.list_treeview.expand_row(path[0:1], False)
|
||||||
self.list_treeview.scroll_to_cell(path)
|
self.list_treeview.scroll_to_cell(path)
|
||||||
|
@ -1812,7 +1812,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.popup(None, None, None, event.button, event.time)
|
menu.popup(None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def _start_private_message(self, nick):
|
def _start_private_message(self, nick, session = None):
|
||||||
gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
||||||
nick_jid = gc_c.get_full_jid()
|
nick_jid = gc_c.get_full_jid()
|
||||||
|
|
||||||
|
|
|
@ -1191,8 +1191,10 @@ class RosterWindow:
|
||||||
for jid in gajim.contacts.get_jid_list(account):
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
results = gajim.logger.get_unread_msgs_for_jid(jid)
|
results = gajim.logger.get_unread_msgs_for_jid(jid)
|
||||||
|
|
||||||
# XXX unread messages should probably have their session with them
|
# XXX unread messages should probably have their session saved with them
|
||||||
session = gajim.connections[account].make_new_session(jid)
|
if results:
|
||||||
|
session = gajim.connections[account].make_new_session(jid)
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
tim = time.localtime(float(result[2]))
|
tim = time.localtime(float(result[2]))
|
||||||
self.on_message(jid, result[1], tim, account, msg_type = 'chat',
|
self.on_message(jid, result[1], tim, account, msg_type = 'chat',
|
||||||
|
@ -3466,7 +3468,7 @@ class RosterWindow:
|
||||||
self.actions_menu_needs_rebuild = True
|
self.actions_menu_needs_rebuild = True
|
||||||
self.update_status_combobox()
|
self.update_status_combobox()
|
||||||
|
|
||||||
def new_private_chat(self, gc_contact, account):
|
def new_private_chat(self, gc_contact, account, session = None):
|
||||||
contact = gajim.contacts.contact_from_gc_contact(gc_contact)
|
contact = gajim.contacts.contact_from_gc_contact(gc_contact)
|
||||||
type_ = message_control.TYPE_PM
|
type_ = message_control.TYPE_PM
|
||||||
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
||||||
|
@ -3474,7 +3476,7 @@ class RosterWindow:
|
||||||
if not mw:
|
if not mw:
|
||||||
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
|
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
|
||||||
|
|
||||||
chat_control = PrivateChatControl(mw, gc_contact, contact, account)
|
chat_control = PrivateChatControl(mw, gc_contact, contact, account, session)
|
||||||
mw.new_tab(chat_control)
|
mw.new_tab(chat_control)
|
||||||
if len(gajim.events.get_events(account, fjid)):
|
if len(gajim.events.get_events(account, fjid)):
|
||||||
# We call this here to avoid race conditions with widget validation
|
# We call this here to avoid race conditions with widget validation
|
||||||
|
|
Loading…
Add table
Reference in a new issue