hopefully fix the last of the get_control calls (fixes #4018)
This commit is contained in:
parent
5ddb2829f3
commit
964cb10163
|
@ -960,17 +960,22 @@ def get_chat_control(account, contact):
|
|||
account, contact.jid)
|
||||
# Look for a chat control that has the given resource, or default to
|
||||
# one without resource
|
||||
ctrl = gajim.interface.msg_win_mgr.get_control(full_jid_with_resource,
|
||||
ctrls = gajim.interface.msg_win_mgr.get_chat_controls(full_jid_with_resource,
|
||||
account)
|
||||
if ctrl:
|
||||
return ctrl
|
||||
if ctrls:
|
||||
return ctrls[0]
|
||||
elif not highest_contact or not highest_contact.resource:
|
||||
# unknow contact or offline message
|
||||
return gajim.interface.msg_win_mgr.get_control(contact.jid, account)
|
||||
pass # fall through, handle this at the end
|
||||
elif highest_contact and contact.resource != \
|
||||
highest_contact.resource:
|
||||
return None
|
||||
return gajim.interface.msg_win_mgr.get_control(contact.jid, account)
|
||||
|
||||
ctrls = gajim.interface.msg_win_mgr.get_chat_controls(contact.jid, account)
|
||||
if ctrls:
|
||||
return ctrls[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def reduce_chars_newlines(text, max_chars = 0, max_lines = 0):
|
||||
'''Cut the chars after 'max_chars' on each line
|
||||
|
|
24
src/gajim.py
24
src/gajim.py
|
@ -798,6 +798,11 @@ class Interface:
|
|||
full_jid_with_resource = array[0]
|
||||
jids = full_jid_with_resource.split('/', 1)
|
||||
jid = jids[0]
|
||||
|
||||
session = None
|
||||
if len(array) > 5:
|
||||
session = array[5]
|
||||
|
||||
gc_control = self.msg_win_mgr.get_gc_control(jid, account)
|
||||
if not gc_control and \
|
||||
jid in self.minimized_controls[account]:
|
||||
|
@ -807,8 +812,17 @@ class Interface:
|
|||
if gc_control:
|
||||
if len(jids) > 1: # it's a pm
|
||||
nick = jids[1]
|
||||
if not self.msg_win_mgr.get_control(full_jid_with_resource,
|
||||
account):
|
||||
|
||||
ctrl = None
|
||||
if session:
|
||||
ctrl = session.control
|
||||
|
||||
if not ctrl:
|
||||
ctrls = self.msg_win_mgr.get_chat_controls(full_jid_with_resource, account)
|
||||
if ctrls:
|
||||
ctrl = ctrls[0]
|
||||
|
||||
if not ctrl:
|
||||
tv = gc_control.list_treeview
|
||||
model = tv.get_model()
|
||||
iter = gc_control.get_contact_iter(nick)
|
||||
|
@ -818,8 +832,8 @@ class Interface:
|
|||
show = 'offline'
|
||||
gc_c = gajim.contacts.create_gc_contact(room_jid = jid,
|
||||
name = nick, show = show)
|
||||
self.new_private_chat(gc_c, account)
|
||||
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
|
||||
ctrl = self.new_private_chat(gc_c, account, session)
|
||||
|
||||
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
|
||||
'status')
|
||||
return
|
||||
|
@ -2673,6 +2687,8 @@ class Interface:
|
|||
# We call this here to avoid race conditions with widget validation
|
||||
session.control.read_queue()
|
||||
|
||||
return session.control
|
||||
|
||||
def new_chat(self, contact, account, resource = None, session = None):
|
||||
# Get target window, create a control, and associate it with the window
|
||||
type_ = message_control.TYPE_CHAT
|
||||
|
|
Loading…
Reference in New Issue