hopefully fix some has_window bugs

This commit is contained in:
Brendan Taylor 2008-06-21 19:12:58 +00:00
parent 8b4627049b
commit d6be46be84
2 changed files with 25 additions and 17 deletions

View File

@ -1025,23 +1025,22 @@ class Interface:
if vcard.has_key('resource'):
resource = vcard['resource']
fjid = jid + '/' + str(resource)
# vcard window
win = None
if self.instances[account]['infos'].has_key(jid):
win = self.instances[account]['infos'][jid]
elif resource and self.instances[account]['infos'].has_key(
jid + '/' + resource):
win = self.instances[account]['infos'][jid + '/' + resource]
elif resource and self.instances[account]['infos'].has_key(fjid):
win = self.instances[account]['infos'][fjid]
if win:
win.set_values(vcard)
# show avatar in chat
ctrls = []
if resource and self.msg_win_mgr.has_window(
jid + '/' + resource, account):
win = self.msg_win_mgr.get_window(jid + '/' + resource,
account)
ctrls = win.get_controls(jid + '/' + resource, account)
if resource and self.msg_win_mgr.has_window(fjid, account):
win = self.msg_win_mgr.get_window(fjid, account)
ctrls = win.get_controls(fjid, account)
elif self.msg_win_mgr.has_window(jid, account):
win = self.msg_win_mgr.get_window(jid, account)
ctrls = win.get_controls(jid, account)
@ -2126,10 +2125,13 @@ class Interface:
elif type_ == 'chat':
session = event.parameters[8]
ctrl = session.control
elif type_ == '':
ctrls = self.msg_win_mgr.get_chat_controls(fjid, account)
if type_ == '' and self.msg_win_mgr.has_window(fjid, account):
ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0]
elif not ctrl:
if ctrls:
ctrl = ctrls[0]
if not ctrl:
highest_contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
# jid can have a window if this resource was lower when he sent
@ -2574,8 +2576,9 @@ class Interface:
contact = self.roster.add_to_not_in_the_roster(account, jid,
resource=resource)
if self.msg_win_mgr.has_window(fjid, account):
ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0]
ctrls = self.msg_win_mgr.get_chat_controls(fjid, account)
if ctrls:
ctrl = ctrls[0]
else:
ctrl = self.new_chat(contact, account,
resource=resource)

View File

@ -621,6 +621,12 @@ class MessageWindow(object):
nth_child = notebook.get_nth_page(page_num)
return self._widget_to_control(nth_child)
def has_control(self, jid, acct):
sessioned = (acct in self._controls and jid in self._controls[acct] \
and self._controls[acct][jid])
return sessioned or self.sessionless_controls(acct, jid)
def get_gc_control(self, jid, acct):
return self.get_control(jid, acct, 'gc')
@ -924,9 +930,8 @@ class MessageWindowMgr(gobject.GObject):
def get_window(self, jid, acct):
for win in self.windows():
if (acct in win._controls and jid in win._controls[acct]) or \
(acct in win.sessionless_ctrls and jid in win.sessionless_ctrls[acct]):
return win
if win.has_control(jid, acct):
return win
return None