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

View File

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