1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-27 13:07:58 +01:00

Fixes a problem renaming a RosterGroup

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2176 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2003-12-02 01:53:39 +00:00 committed by gdombiak
parent b73060d000
commit b194d99054

View file

@ -92,18 +92,23 @@ public class RosterGroup {
}
/**
* Sets the name of the group.
* Sets the name of the group. Changing the group's name is like moving all the group entries
* of the group to a new group specified by the new name. Since this group won't have entries
* it will be removed from the roster. This means that all the references to this object will
* be invalid and will need to be updated to the new group specified by the new name.
*
* @param name the name of the group.
*/
public void setName(String name) {
this.name = name;
synchronized (entries) {
for (int i=0; i<entries.size(); i++) {
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.SET);
RosterEntry entry = (RosterEntry)entries.get(i);
packet.addRosterItem(RosterEntry.toRosterItem(entry));
RosterPacket.Item item = RosterEntry.toRosterItem(entry);
item.removeGroupName(this.name);
item.addGroupName(name);
packet.addRosterItem(item);
connection.sendPacket(packet);
}
}