hopefully fix the last of the get_control calls (fixes #4018)

This commit is contained in:
Brendan Taylor 2008-06-14 08:43:20 +00:00
parent 5ddb2829f3
commit 964cb10163
2 changed files with 30 additions and 9 deletions

View File

@ -960,17 +960,22 @@ def get_chat_control(account, contact):
account, contact.jid) account, contact.jid)
# Look for a chat control that has the given resource, or default to # Look for a chat control that has the given resource, or default to
# one without resource # 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) account)
if ctrl: if ctrls:
return ctrl return ctrls[0]
elif not highest_contact or not highest_contact.resource: elif not highest_contact or not highest_contact.resource:
# unknow contact or offline message # 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 != \ elif highest_contact and contact.resource != \
highest_contact.resource: highest_contact.resource:
return None 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): def reduce_chars_newlines(text, max_chars = 0, max_lines = 0):
'''Cut the chars after 'max_chars' on each line '''Cut the chars after 'max_chars' on each line

View File

@ -798,6 +798,11 @@ class Interface:
full_jid_with_resource = array[0] full_jid_with_resource = array[0]
jids = full_jid_with_resource.split('/', 1) jids = full_jid_with_resource.split('/', 1)
jid = jids[0] jid = jids[0]
session = None
if len(array) > 5:
session = array[5]
gc_control = self.msg_win_mgr.get_gc_control(jid, account) gc_control = self.msg_win_mgr.get_gc_control(jid, account)
if not gc_control and \ if not gc_control and \
jid in self.minimized_controls[account]: jid in self.minimized_controls[account]:
@ -807,8 +812,17 @@ class Interface:
if gc_control: if gc_control:
if len(jids) > 1: # it's a pm if len(jids) > 1: # it's a pm
nick = jids[1] 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 tv = gc_control.list_treeview
model = tv.get_model() model = tv.get_model()
iter = gc_control.get_contact_iter(nick) iter = gc_control.get_contact_iter(nick)
@ -818,8 +832,8 @@ class Interface:
show = 'offline' show = 'offline'
gc_c = gajim.contacts.create_gc_contact(room_jid = jid, gc_c = gajim.contacts.create_gc_contact(room_jid = jid,
name = nick, show = show) name = nick, show = show)
self.new_private_chat(gc_c, account) ctrl = self.new_private_chat(gc_c, account, session)
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]), ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
'status') 'status')
return return
@ -2673,6 +2687,8 @@ class Interface:
# We call this here to avoid race conditions with widget validation # We call this here to avoid race conditions with widget validation
session.control.read_queue() session.control.read_queue()
return session.control
def new_chat(self, contact, account, resource = None, session = None): def new_chat(self, contact, account, resource = None, session = None):
# Get target window, create a control, and associate it with the window # Get target window, create a control, and associate it with the window
type_ = message_control.TYPE_CHAT type_ = message_control.TYPE_CHAT