handle correctly resources in queue of events. Fixes #1706
This commit is contained in:
parent
1ff4e4f48d
commit
1fafe3b08c
|
@ -1473,7 +1473,7 @@ class ChatControl(ChatControlBase):
|
||||||
# Redraw parent too
|
# Redraw parent too
|
||||||
gajim.interface.roster.draw_parent_contact(jid, self.account)
|
gajim.interface.roster.draw_parent_contact(jid, self.account)
|
||||||
if gajim.interface.systray_enabled:
|
if gajim.interface.systray_enabled:
|
||||||
gajim.interface.systray.remove_jid(jid, self.account, typ)
|
gajim.interface.systray.remove_jid(fjid, self.account, typ)
|
||||||
if (self.contact.show == 'offline' or self.contact.show == 'error'):
|
if (self.contact.show == 'offline' or self.contact.show == 'error'):
|
||||||
showOffline = gajim.config.get('showoffline')
|
showOffline = gajim.config.get('showoffline')
|
||||||
if not showOffline and typ == 'chat' and \
|
if not showOffline and typ == 'chat' and \
|
||||||
|
|
|
@ -506,6 +506,9 @@ def get_icon_name_to_show(contact, account = None):
|
||||||
'''Get the icon name to show in online, away, requested, ...'''
|
'''Get the icon name to show in online, away, requested, ...'''
|
||||||
if account and gajim.awaiting_events[account].has_key(contact.jid):
|
if account and gajim.awaiting_events[account].has_key(contact.jid):
|
||||||
return 'message'
|
return 'message'
|
||||||
|
if account and gajim.awaiting_events[account].has_key(
|
||||||
|
contact.get_full_jid()):
|
||||||
|
return 'message'
|
||||||
if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
||||||
return contact.show
|
return contact.show
|
||||||
if contact.sub in ('both', 'to'):
|
if contact.sub in ('both', 'to'):
|
||||||
|
|
34
src/gajim.py
34
src/gajim.py
|
@ -484,9 +484,9 @@ class Interface:
|
||||||
show_notification = True
|
show_notification = True
|
||||||
|
|
||||||
chat_control = self.msg_win_mgr.get_control(jid, account)
|
chat_control = self.msg_win_mgr.get_control(jid, account)
|
||||||
|
jid_of_control = jid
|
||||||
if chat_control and chat_control.type_id == message_control.TYPE_GC:
|
if chat_control and chat_control.type_id == message_control.TYPE_GC:
|
||||||
# it's a Private Message
|
# it's a Private Message
|
||||||
fjid = array[0]
|
|
||||||
room_jid, nick = gajim.get_room_and_nick_from_fjid(fjid)
|
room_jid, nick = gajim.get_room_and_nick_from_fjid(fjid)
|
||||||
if not self.msg_win_mgr.has_window(fjid, account) and \
|
if not self.msg_win_mgr.has_window(fjid, account) and \
|
||||||
not gajim.awaiting_events[account].has_key(fjid):
|
not gajim.awaiting_events[account].has_key(fjid):
|
||||||
|
@ -503,16 +503,20 @@ class Interface:
|
||||||
chat_control.on_private_message(nick, array[1], array[2])
|
chat_control.on_private_message(nick, array[1], array[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
# FIXME: This should happen first
|
|
||||||
if gajim.config.get('ignore_unknown_contacts') and \
|
if gajim.config.get('ignore_unknown_contacts') and \
|
||||||
not gajim.contacts.get_contact(account, jid):
|
not gajim.contacts.get_contact(account, jid):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
highest_contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
account, jid)
|
||||||
# Look for a chat control that has the given resource, or default to one
|
# Look for a chat control that has the given resource, or default to one
|
||||||
# without resource
|
# without resource
|
||||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
||||||
if ctrl:
|
if ctrl:
|
||||||
chat_control = ctrl
|
chat_control = ctrl
|
||||||
|
elif resource != highest_contact.resource:
|
||||||
|
chat_control = None
|
||||||
|
jid_of_control = fjid
|
||||||
# Handle chat states
|
# Handle chat states
|
||||||
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
||||||
if contact:
|
if contact:
|
||||||
|
@ -553,14 +557,14 @@ class Interface:
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'single_msg_recv.png')
|
'single_msg_recv.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('New Single Message'), jid, account, msg_type,
|
notify.notify(_('New Single Message'), jid_of_control,
|
||||||
path_to_image = path, text = txt)
|
account, msg_type, path_to_image = path, text = txt)
|
||||||
else: # chat message
|
else: # chat message
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'chat_msg_recv.png')
|
'chat_msg_recv.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('New Message'), jid, account, msg_type,
|
notify.notify(_('New Message'), jid_of_control, account,
|
||||||
path_to_image = path, text = txt)
|
msg_type, path_to_image = path, text = txt)
|
||||||
|
|
||||||
# array : (contact, msg, time, encrypted, msg_type, subject)
|
# array : (contact, msg, time, encrypted, msg_type, subject)
|
||||||
self.roster.on_message(jid, array[1], array[2], account, array[3],
|
self.roster.on_message(jid, array[1], array[2], account, array[3],
|
||||||
|
@ -1523,16 +1527,20 @@ class Interface:
|
||||||
|
|
||||||
def handle_event(self, account, jid, typ):
|
def handle_event(self, account, jid, typ):
|
||||||
w = None
|
w = None
|
||||||
|
fjid = jid
|
||||||
|
resource = gajim.get_resource_from_jid(jid)
|
||||||
|
jid = gajim.get_jid_without_resource(jid)
|
||||||
if typ == message_control.TYPE_GC:
|
if typ == message_control.TYPE_GC:
|
||||||
w = self.msg_win_mgr.get_window(jid, account)
|
w = self.msg_win_mgr.get_window(jid, account)
|
||||||
elif typ == message_control.TYPE_CHAT:
|
elif typ == message_control.TYPE_CHAT:
|
||||||
if self.msg_win_mgr.has_window(jid, account):
|
if self.msg_win_mgr.has_window(fjid, account):
|
||||||
w = self.msg_win_mgr.get_window(jid, account)
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
else:
|
else:
|
||||||
|
contact = gajim.contacts.get_contact(account, jid, resource)
|
||||||
|
if isinstance(contact, list):
|
||||||
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
||||||
self.roster.new_chat(contact, account)
|
self.roster.new_chat(contact, account, resource = resource)
|
||||||
w = self.msg_win_mgr.get_window(jid, account)
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
ctrl = w.get_control
|
|
||||||
gajim.last_message_time[account][jid] = 0 # long time ago
|
gajim.last_message_time[account][jid] = 0 # long time ago
|
||||||
elif typ == message_control.TYPE_PM:
|
elif typ == message_control.TYPE_PM:
|
||||||
if self.msg_win_mgr.has_window(jid, account):
|
if self.msg_win_mgr.has_window(jid, account):
|
||||||
|
@ -1569,10 +1577,10 @@ class Interface:
|
||||||
data[1])
|
data[1])
|
||||||
self.remove_first_event(account, jid, typ)
|
self.remove_first_event(account, jid, typ)
|
||||||
if w:
|
if w:
|
||||||
w.set_active_tab(jid, account)
|
w.set_active_tab(fjid, account)
|
||||||
w.window.present()
|
w.window.present()
|
||||||
w.window.window.focus()
|
w.window.window.focus()
|
||||||
ctrl = w.get_control(jid, account)
|
ctrl = w.get_control(fjid, account)
|
||||||
# Using isinstance here because we want to catch all derived types
|
# Using isinstance here because we want to catch all derived types
|
||||||
if isinstance(ctrl, ChatControlBase):
|
if isinstance(ctrl, ChatControlBase):
|
||||||
tv = ctrl.conv_textview
|
tv = ctrl.conv_textview
|
||||||
|
|
|
@ -432,6 +432,12 @@ class RosterWindow:
|
||||||
|
|
||||||
iter = iters[0] # choose the icon with the first iter
|
iter = iters[0] # choose the icon with the first iter
|
||||||
icon_name = helpers.get_icon_name_to_show(contact, account)
|
icon_name = helpers.get_icon_name_to_show(contact, account)
|
||||||
|
# look if anotherresource has awaiting events
|
||||||
|
for c in contact_instances:
|
||||||
|
c_icon_name = helpers.get_icon_name_to_show(c, account)
|
||||||
|
if c_icon_name == 'message':
|
||||||
|
icon_name = c_icon_name
|
||||||
|
break
|
||||||
path = model.get_path(iter)
|
path = model.get_path(iter)
|
||||||
if model.iter_has_child(iter):
|
if model.iter_has_child(iter):
|
||||||
if not self.tree.row_expanded(path) and icon_name != 'message':
|
if not self.tree.row_expanded(path) and icon_name != 'message':
|
||||||
|
@ -2082,7 +2088,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
# Redraw parent too
|
# Redraw parent too
|
||||||
self.draw_parent_contact(jid, account)
|
self.draw_parent_contact(jid, account)
|
||||||
if gajim.interface.systray_enabled:
|
if gajim.interface.systray_enabled:
|
||||||
gajim.interface.systray.add_jid(jid, account, kind)
|
gajim.interface.systray.add_jid(fjid, account, kind)
|
||||||
self.show_title() # we show the * or [n]
|
self.show_title() # we show the * or [n]
|
||||||
if not path:
|
if not path:
|
||||||
self.add_contact_to_roster(jid, account)
|
self.add_contact_to_roster(jid, account)
|
||||||
|
@ -2336,6 +2342,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
account = model[path][C_ACCOUNT].decode('utf-8')
|
account = model[path][C_ACCOUNT].decode('utf-8')
|
||||||
type = model[path][C_TYPE]
|
type = model[path][C_TYPE]
|
||||||
jid = model[path][C_JID].decode('utf-8')
|
jid = model[path][C_JID].decode('utf-8')
|
||||||
|
resource = None
|
||||||
iter = model.get_iter(path)
|
iter = model.get_iter(path)
|
||||||
if type in ('group', 'account'):
|
if type in ('group', 'account'):
|
||||||
if self.tree.row_expanded(path):
|
if self.tree.row_expanded(path):
|
||||||
|
@ -2344,6 +2351,14 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
self.tree.expand_row(path, False)
|
self.tree.expand_row(path, False)
|
||||||
else:
|
else:
|
||||||
first_ev = gajim.get_first_event(account, jid)
|
first_ev = gajim.get_first_event(account, jid)
|
||||||
|
if not first_ev:
|
||||||
|
# look in other resources
|
||||||
|
for c in gajim.contacts.get_contact(account, jid):
|
||||||
|
fjid = c.get_full_jid()
|
||||||
|
first_ev = gajim.get_first_event(account, fjid)
|
||||||
|
if first_ev:
|
||||||
|
resource = c.resource
|
||||||
|
break
|
||||||
if not first_ev and model.iter_has_child(iter):
|
if not first_ev and model.iter_has_child(iter):
|
||||||
child_iter = model.iter_children(iter)
|
child_iter = model.iter_children(iter)
|
||||||
while not first_ev and child_iter:
|
while not first_ev and child_iter:
|
||||||
|
@ -2354,10 +2369,13 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
else:
|
else:
|
||||||
child_iter = model.iter_next(child_iter)
|
child_iter = model.iter_next(child_iter)
|
||||||
if first_ev:
|
if first_ev:
|
||||||
if self.open_event(account, jid, first_ev):
|
fjid = jid
|
||||||
|
if resource:
|
||||||
|
fjid += '/' + resource
|
||||||
|
if self.open_event(account, fjid, first_ev):
|
||||||
return
|
return
|
||||||
c = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
c = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
self.on_open_chat_window(widget, c, account)
|
self.on_open_chat_window(widget, c, account, resource = resource)
|
||||||
|
|
||||||
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
||||||
'''When a row is expanded change the icon of the arrow'''
|
'''When a row is expanded change the icon of the arrow'''
|
||||||
|
|
Loading…
Reference in New Issue