support of contacts in no group

This commit is contained in:
Yann Leboulanger 2005-12-30 14:04:01 +00:00
parent 96419ac1d8
commit f3deefc372
3 changed files with 15 additions and 24 deletions

View file

@ -106,11 +106,6 @@ class EditGroupsDialog:
def group_toggled_cb(self, cell, path): def group_toggled_cb(self, cell, path):
self.changes_made = True self.changes_made = True
model = self.list.get_model() model = self.list.get_model()
if model[path][1] and len(self.user.groups) == 1: # we try to remove
# the last group
ErrorDialog(_('Cannot remove last group'),
_('At least one contact group must be present.')).get_response()
return
model[path][1] = not model[path][1] model[path][1] = not model[path][1]
if model[path][1]: if model[path][1]:
self.user.groups.append(model[path][0].decode('utf-8')) self.user.groups.append(model[path][0].decode('utf-8'))

View file

@ -528,8 +528,6 @@ class Interface:
self.roster.remove_contact(c, account) self.roster.remove_contact(c, account)
if _('not in the roster') in c.groups: if _('not in the roster') in c.groups:
c.groups.remove(_('not in the roster')) c.groups.remove(_('not in the roster'))
if len(c.groups) == 0:
c.groups = [_('General')]
self.roster.add_contact_to_roster(c.jid, account) self.roster.add_contact_to_roster(c.jid, account)
gajim.connections[account].update_contact(c.jid, c.name, c.groups) gajim.connections[account].update_contact(c.jid, c.name, c.groups)
else: else:
@ -541,7 +539,7 @@ class Interface:
name = jid.split('@', 1)[0] name = jid.split('@', 1)[0]
name = name.split('%', 1)[0] name = name.split('%', 1)[0]
contact1 = gajim.contacts.create_contact(jid = jid, name = name, contact1 = gajim.contacts.create_contact(jid = jid, name = name,
groups = [_('General')], show = 'online', status = 'online', groups = None, show = 'online', status = 'online',
ask = 'to', resource = array[1], keyID = keyID) ask = 'to', resource = array[1], keyID = keyID)
gajim.contacts.add_contact(account, contact1) gajim.contacts.add_contact(account, contact1)
self.roster.add_contact_to_roster(jid, account) self.roster.add_contact_to_roster(jid, account)

View file

@ -149,17 +149,13 @@ class RosterWindow:
if contact.jid.find('@') <= 0: if contact.jid.find('@') <= 0:
# if not '@' or '@' starts the jid ==> agent # if not '@' or '@' starts the jid ==> agent
contact.groups = [_('Transports')] contact.groups = [_('Transports')]
elif contact.groups == []:
contact.groups.append(_('General'))
hide = True hide = True
if contact.sub in ('both', 'to'): if contact.sub in ('both', 'to'):
hide = False hide = False
elif contact.ask == 'subscribe': elif contact.ask == 'subscribe':
hide = False hide = False
# FIXME: uncomment when we support contacts in no group elif contact.name or len(contact.groups):
# elif contact.name or len(contact.groups):
elif contact.name:
hide = False hide = False
# JEP-0162 # JEP-0162
@ -172,7 +168,10 @@ class RosterWindow:
return return
model = self.tree.get_model() model = self.tree.get_model()
for g in contact.groups: groups = contact.groups
if not groups:
groups = [_('General')]
for g in groups:
iterG = self.get_group_iter(g, account) iterG = self.get_group_iter(g, account)
if not iterG: if not iterG:
IterAcct = self.get_account_iter(account) IterAcct = self.get_account_iter(account)
@ -1244,8 +1243,8 @@ class RosterWindow:
if not pseudo: if not pseudo:
pseudo = jid pseudo = jid
gajim.connections[account].request_subscription(jid, txt) gajim.connections[account].request_subscription(jid, txt)
if not group: if group:
group = _('General') group = [group]
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
if not contact: if not contact:
keyID = '' keyID = ''
@ -1254,18 +1253,17 @@ class RosterWindow:
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, name = pseudo, contact = gajim.contacts.create_contact(jid = jid, name = pseudo,
groups = [group], show = 'requested', status = '', ask = 'none', groups = group, show = 'requested', status = '', ask = 'none',
sub = 'subscribe', keyID = keyID) sub = 'subscribe', keyID = keyID)
gajim.contacts.add_contact(account, c) gajim.contacts.add_contact(account, contact)
else: else:
c = gajim.contacts.get_contact_with_highest_priority(account, jid) if not _('not in the roster') in contact.groups:
if not _('not in the roster') in c.groups:
dialogs.InformationDialog(_('Subscription request has been sent'), dialogs.InformationDialog(_('Subscription request has been sent'),
_('If "%s" accepts this request you will know his or her status.') %jid) _('If "%s" accepts this request you will know his or her status.') % jid)
return return
c.groups = [group] contact.groups = group
c.name = pseudo contact.name = pseudo
self.remove_contact(c, account) self.remove_contact(contact, account)
self.add_contact_to_roster(jid, account) self.add_contact_to_roster(jid, account)
def revoke_auth(self, widget, jid, account): def revoke_auth(self, widget, jid, account):