hopefully fix some has_window bugs
This commit is contained in:
parent
8b4627049b
commit
d6be46be84
29
src/gajim.py
29
src/gajim.py
|
@ -1025,23 +1025,22 @@ class Interface:
|
||||||
if vcard.has_key('resource'):
|
if vcard.has_key('resource'):
|
||||||
resource = vcard['resource']
|
resource = vcard['resource']
|
||||||
|
|
||||||
|
fjid = jid + '/' + str(resource)
|
||||||
|
|
||||||
# vcard window
|
# vcard window
|
||||||
win = None
|
win = None
|
||||||
if self.instances[account]['infos'].has_key(jid):
|
if self.instances[account]['infos'].has_key(jid):
|
||||||
win = self.instances[account]['infos'][jid]
|
win = self.instances[account]['infos'][jid]
|
||||||
elif resource and self.instances[account]['infos'].has_key(
|
elif resource and self.instances[account]['infos'].has_key(fjid):
|
||||||
jid + '/' + resource):
|
win = self.instances[account]['infos'][fjid]
|
||||||
win = self.instances[account]['infos'][jid + '/' + resource]
|
|
||||||
if win:
|
if win:
|
||||||
win.set_values(vcard)
|
win.set_values(vcard)
|
||||||
|
|
||||||
# show avatar in chat
|
# show avatar in chat
|
||||||
ctrls = []
|
ctrls = []
|
||||||
if resource and self.msg_win_mgr.has_window(
|
if resource and self.msg_win_mgr.has_window(fjid, account):
|
||||||
jid + '/' + resource, account):
|
win = self.msg_win_mgr.get_window(fjid, account)
|
||||||
win = self.msg_win_mgr.get_window(jid + '/' + resource,
|
ctrls = win.get_controls(fjid, account)
|
||||||
account)
|
|
||||||
ctrls = win.get_controls(jid + '/' + resource, account)
|
|
||||||
elif self.msg_win_mgr.has_window(jid, account):
|
elif self.msg_win_mgr.has_window(jid, account):
|
||||||
win = self.msg_win_mgr.get_window(jid, account)
|
win = self.msg_win_mgr.get_window(jid, account)
|
||||||
ctrls = win.get_controls(jid, account)
|
ctrls = win.get_controls(jid, account)
|
||||||
|
@ -2126,10 +2125,13 @@ class Interface:
|
||||||
elif type_ == 'chat':
|
elif type_ == 'chat':
|
||||||
session = event.parameters[8]
|
session = event.parameters[8]
|
||||||
ctrl = session.control
|
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):
|
if ctrls:
|
||||||
ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0]
|
ctrl = ctrls[0]
|
||||||
elif not ctrl:
|
|
||||||
|
if not ctrl:
|
||||||
highest_contact = gajim.contacts.get_contact_with_highest_priority(
|
highest_contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
account, jid)
|
account, jid)
|
||||||
# jid can have a window if this resource was lower when he sent
|
# 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,
|
contact = self.roster.add_to_not_in_the_roster(account, jid,
|
||||||
resource=resource)
|
resource=resource)
|
||||||
|
|
||||||
if self.msg_win_mgr.has_window(fjid, account):
|
ctrls = self.msg_win_mgr.get_chat_controls(fjid, account)
|
||||||
ctrl = self.msg_win_mgr.get_chat_controls(fjid, account)[0]
|
if ctrls:
|
||||||
|
ctrl = ctrls[0]
|
||||||
else:
|
else:
|
||||||
ctrl = self.new_chat(contact, account,
|
ctrl = self.new_chat(contact, account,
|
||||||
resource=resource)
|
resource=resource)
|
||||||
|
|
|
@ -621,6 +621,12 @@ class MessageWindow(object):
|
||||||
nth_child = notebook.get_nth_page(page_num)
|
nth_child = notebook.get_nth_page(page_num)
|
||||||
return self._widget_to_control(nth_child)
|
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):
|
def get_gc_control(self, jid, acct):
|
||||||
return self.get_control(jid, acct, 'gc')
|
return self.get_control(jid, acct, 'gc')
|
||||||
|
|
||||||
|
@ -924,8 +930,7 @@ class MessageWindowMgr(gobject.GObject):
|
||||||
|
|
||||||
def get_window(self, jid, acct):
|
def get_window(self, jid, acct):
|
||||||
for win in self.windows():
|
for win in self.windows():
|
||||||
if (acct in win._controls and jid in win._controls[acct]) or \
|
if win.has_control(jid, acct):
|
||||||
(acct in win.sessionless_ctrls and jid in win.sessionless_ctrls[acct]):
|
|
||||||
return win
|
return win
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue