add contact to roster when he becomes observer (and was none before)

This commit is contained in:
Yann Leboulanger 2006-03-30 18:48:24 +00:00
parent 028de148d3
commit b7e4465ed5

View file

@ -915,28 +915,34 @@ class Interface:
def handle_event_roster_info(self, account, array): def handle_event_roster_info(self, account, array):
#('ROSTER_INFO', account, (jid, name, sub, ask, groups)) #('ROSTER_INFO', account, (jid, name, sub, ask, groups))
jid = array[0] jid = array[0]
if not jid in gajim.contacts.get_jid_list(account):
return
contacts = gajim.contacts.get_contacts_from_jid(account, jid)
# contact removes us.
name = array[1] name = array[1]
sub = array[2] sub = array[2]
ask = array[3] ask = array[3]
groups = array[4] groups = array[4]
contacts = gajim.contacts.get_contacts_from_jid(account, jid)
# contact removes us.
if (not sub or sub == 'none') and (not ask or ask == 'none') and \ if (not sub or sub == 'none') and (not ask or ask == 'none') and \
not name and not groups: not name and not groups:
self.roster.remove_contact(contacts[0], account) if contacts:
gajim.contacts.remove_jid(account, jid) self.roster.remove_contact(contacts[0], account)
#FIXME if it was the only one in its group, remove the group gajim.contacts.remove_jid(account, jid)
return #FIXME if it was the only one in its group, remove the group
for contact in contacts: return
if not name: elif not contacts:
name = '' # Add it to roster
contact.name = name contact = gajim.contacts.create_contact(jid = jid, name = name,
contact.sub = sub groups = groups, show = 'offline', sub = sub, ask = ask)
contact.ask = ask gajim.contacts.add_contact(account, contact)
if groups: self.roster.add_contact_to_roster(jid, account)
contact.groups = groups else:
for contact in contacts:
if not name:
name = ''
contact.name = name
contact.sub = sub
contact.ask = ask
if groups:
contact.groups = groups
self.roster.draw_contact(jid, account) self.roster.draw_contact(jid, account)
if self.remote_ctrl: if self.remote_ctrl:
self.remote_ctrl.raise_signal('RosterInfo', (account, array)) self.remote_ctrl.raise_signal('RosterInfo', (account, array))