Do not remove resource from jid when using Actions -> Start chat. fixes #2942

This commit is contained in:
Yann Leboulanger 2007-01-27 18:43:28 +00:00
parent f450c0eb65
commit b4b2ecb41d

View file

@ -398,7 +398,7 @@ class RosterWindow:
model = self.tree.get_model() model = self.tree.get_model()
model.set_value(iter, 1 , gobject.markup_escape_text(text)) model.set_value(iter, 1 , gobject.markup_escape_text(text))
def add_to_not_in_the_roster(self, account, jid, nick = ''): def add_to_not_in_the_roster(self, account, jid, nick = '', resource = ''):
''' add jid to group "not in the roster", he MUST not be in roster yet, ''' add jid to group "not in the roster", he MUST not be in roster yet,
return contact ''' return contact '''
keyID = '' keyID = ''
@ -406,10 +406,9 @@ class RosterWindow:
'attached_gpg_keys').split() 'attached_gpg_keys').split()
if jid in attached_keys: if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1] keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid = jid, contact = gajim.contacts.create_contact(jid = jid, name = nick,
name = nick, groups = [_('Not in Roster')], groups = [_('Not in Roster')], show = 'not in roster', status = '',
show = 'not in roster', status = '', sub = 'none', sub = 'none', resource = resource, keyID = keyID)
keyID = keyID)
gajim.contacts.add_contact(account, contact) gajim.contacts.add_contact(account, contact)
self.add_contact_to_roster(contact.jid, account) self.add_contact_to_roster(contact.jid, account)
return contact return contact
@ -3052,22 +3051,27 @@ class RosterWindow:
# We call this here to avoid race conditions with widget validation # We call this here to avoid race conditions with widget validation
chat_control.read_queue() chat_control.read_queue()
def new_chat_from_jid(self, account, jid): def new_chat_from_jid(self, account, fjid):
jid = gajim.get_jid_without_resource(jid) jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) if resource:
contact = gajim.contacts.get_contact(account, jid, resource)
else:
contact = gajim.contacts.get_contact_with_highest_priority(account,
jid)
added_to_roster = False added_to_roster = False
if not contact: if not contact:
added_to_roster = True added_to_roster = True
contact = self.add_to_not_in_the_roster(account, jid) contact = self.add_to_not_in_the_roster(account, jid,
resource = resource)
if not gajim.interface.msg_win_mgr.has_window(contact.jid, account): if not gajim.interface.msg_win_mgr.has_window(fjid, account):
self.new_chat(contact, account) self.new_chat(contact, account, resource = resource)
mw = gajim.interface.msg_win_mgr.get_window(contact.jid, account) mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
mw.set_active_tab(jid, account) mw.set_active_tab(fjid, account)
mw.window.present() mw.window.present()
# For JEP-0172 # For JEP-0172
if added_to_roster: if added_to_roster:
mc = mw.get_control(jid, account) mc = mw.get_control(fjid, account)
mc.user_nick = gajim.nicks[account] mc.user_nick = gajim.nicks[account]
def new_room(self, room_jid, nick, account): def new_room(self, room_jid, nick, account):