a GC_Contact can have a resource if we knoe his real JID

This commit is contained in:
Yann Leboulanger 2006-01-03 16:04:14 +00:00
parent c6978c15e0
commit 9cf05efb74
2 changed files with 16 additions and 11 deletions

View File

@ -59,7 +59,7 @@ class Contact:
class GC_Contact:
'''Information concerning each groupchat contact'''
def __init__(self, room_jid='', name='', show='', status='', role='',
affiliation='', jid = ''):
affiliation='', jid = '', resource = ''):
self.room_jid = room_jid
self.name = name
self.show = show
@ -67,6 +67,7 @@ class GC_Contact:
self.role = role
self.affiliation = affiliation
self.jid = jid
self.resource = resource
def get_full_jid(self):
return self.room_jid + '/' + self.name

View File

@ -356,14 +356,18 @@ class GroupchatWindow(chat.Chat):
if model.iter_n_children(parent_iter) == 0:
model.remove(parent_iter)
def add_contact_to_roster(self, room_jid, nick, show, role, jid, affiliation, status):
def add_contact_to_roster(self, room_jid, nick, show, role, affiliation, status, jid = ''):
model = self.list_treeview[room_jid].get_model()
role_name = helpers.get_uf_role(role, plural = True)
resource = ''
if jid:
jid = jid.split('/', 1)[0]
jids = jid.split('/', 1)
j = jids[0]
if len(jids) > 1:
resource = jids[1]
else:
jid = ''
j = ''
name = nick
@ -376,7 +380,7 @@ class GroupchatWindow(chat.Chat):
if not nick in gajim.contacts.get_nick_list(self.account, room_jid):
gc_contact = gajim.contacts.create_gc_contact(room_jid = room_jid,
name = nick, show = show, status = status, role = role,
affiliation = affiliation, jid = jid)
affiliation = affiliation, jid = j, resource = resource)
gajim.contacts.add_gc_contact(self.account, gc_contact)
self.draw_contact(room_jid, nick)
if nick == self.nicks[room_jid]: # we became online
@ -420,8 +424,8 @@ class GroupchatWindow(chat.Chat):
for nick in gajim.contacts.get_nick_list(self.account, room_jid):
gc_contact = gajim.contacts.get_gc_contact(self.account, room_jid, nick)
self.add_contact_to_roster(room_jid, nick, gc_contact.show,
gc_contact.role, gc_contact.jid, gc_contact.affiliation,
gc_contact.status)
gc_contact.role, gc_contact.affiliation, gc_contact.status,
gc_contact.jid)
def get_role(self, room_jid, nick):
gc_contact = gajim.contacts.get_gc_contact(self.account, room_jid, nick)
@ -486,14 +490,14 @@ class GroupchatWindow(chat.Chat):
else:
iter = self.get_contact_iter(room_jid, nick)
if not iter:
iter = self.add_contact_to_roster(room_jid, nick, show, role, jid,
affiliation, status)
iter = self.add_contact_to_roster(room_jid, nick, show, role,
affiliation, status, jid)
else:
actual_role = self.get_role(room_jid, nick)
if role != actual_role:
self.remove_contact(room_jid, nick)
self.add_contact_to_roster(room_jid, nick, show, role, jid,
affiliation, status)
self.add_contact_to_roster(room_jid, nick, show, role,
affiliation, status, jid)
else:
c = gajim.contacts.get_gc_contact(self.account, room_jid, nick)
if c.show == show and c.status == status and \