From f3deefc372fc7e92aa2006b40b3a4184a7955225 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 30 Dec 2005 14:04:01 +0000 Subject: [PATCH] support of contacts in no group --- src/dialogs.py | 5 ----- src/gajim.py | 4 +--- src/roster_window.py | 30 ++++++++++++++---------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/dialogs.py b/src/dialogs.py index 19d49a42f..c60b2393b 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -106,11 +106,6 @@ class EditGroupsDialog: def group_toggled_cb(self, cell, path): self.changes_made = True 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] if model[path][1]: self.user.groups.append(model[path][0].decode('utf-8')) diff --git a/src/gajim.py b/src/gajim.py index 94d5ddea0..5fa182312 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -528,8 +528,6 @@ class Interface: self.roster.remove_contact(c, account) if _('not in the roster') in c.groups: c.groups.remove(_('not in the roster')) - if len(c.groups) == 0: - c.groups = [_('General')] self.roster.add_contact_to_roster(c.jid, account) gajim.connections[account].update_contact(c.jid, c.name, c.groups) else: @@ -541,7 +539,7 @@ class Interface: name = jid.split('@', 1)[0] name = name.split('%', 1)[0] 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) gajim.contacts.add_contact(account, contact1) self.roster.add_contact_to_roster(jid, account) diff --git a/src/roster_window.py b/src/roster_window.py index 731a82af1..de4aef38f 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -149,17 +149,13 @@ class RosterWindow: if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent contact.groups = [_('Transports')] - elif contact.groups == []: - contact.groups.append(_('General')) hide = True if contact.sub in ('both', 'to'): hide = False elif contact.ask == 'subscribe': hide = False - # FIXME: uncomment when we support contacts in no group -# elif contact.name or len(contact.groups): - elif contact.name: + elif contact.name or len(contact.groups): hide = False # JEP-0162 @@ -172,7 +168,10 @@ class RosterWindow: return 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) if not iterG: IterAcct = self.get_account_iter(account) @@ -1244,8 +1243,8 @@ class RosterWindow: if not pseudo: pseudo = jid gajim.connections[account].request_subscription(jid, txt) - if not group: - group = _('General') + if group: + group = [group] contact = gajim.contacts.get_contact_with_highest_priority(account, jid) if not contact: keyID = '' @@ -1254,18 +1253,17 @@ class RosterWindow: if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] 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) - gajim.contacts.add_contact(account, c) + gajim.contacts.add_contact(account, contact) else: - c = gajim.contacts.get_contact_with_highest_priority(account, jid) - if not _('not in the roster') in c.groups: + if not _('not in the roster') in contact.groups: 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 - c.groups = [group] - c.name = pseudo - self.remove_contact(c, account) + contact.groups = group + contact.name = pseudo + self.remove_contact(contact, account) self.add_contact_to_roster(jid, account) def revoke_auth(self, widget, jid, account):