added a method that clears the contact list (by Benoit Pradelle)

cusax-fix
Emil Ivov 19 years ago
parent 7a66349697
commit a11967e5cc

@ -6,9 +6,7 @@
*/
package net.java.sip.communicator.slick.protocol.sip;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import java.util.*;
import org.osgi.framework.*;
import junit.framework.*;
@ -194,8 +192,15 @@ public static Bundle findProtocolProviderBundle(
return null;
}
/**
* Removes all contact groups and contacts currently recorded by the
* presence operation set of the sip providers we are using.
*
* @throws Exception if anything goes wrong and we fail to empty the contact
* lists.
*/
public void clearProvidersLists()
throws Exception
throws Exception
{
Map supportedOperationSets1 = provider1.getSupportedOperationSets();
@ -240,47 +245,30 @@ public void clearProvidersLists()
+ "implementation of at least the one of the Presence "
+ "Operation Sets");
ContactGroup rootGroup1 = opSetPersPresence1.getServerStoredContactListRoot();
ContactGroup rootGroup1
= opSetPersPresence1.getServerStoredContactListRoot();
// first delete the groups
Vector groupsToRemove = new Vector();
Iterator iter = rootGroup1.subgroups();
while (iter.hasNext())
{
groupsToRemove.add(iter.next());
}
iter = groupsToRemove.iterator();
while (iter.hasNext())
{
ContactGroup item = (ContactGroup) iter.next();
opSetPersPresence1.removeServerStoredContactGroup(item);
}
//then delete contacts if any in root list
Vector contactsToRemove = new Vector();
iter = rootGroup1.contacts();
while (iter.hasNext())
{
contactsToRemove.add(iter.next());
}
iter = contactsToRemove.iterator();
while (iter.hasNext())
{
opSetPersPresence1.unsubscribe((Contact)iter.next());
}
ContactGroup rootGroup2 = opSetPersPresence2.getServerStoredContactListRoot();
ContactGroup rootGroup2
= opSetPersPresence2.getServerStoredContactListRoot();
// delete groups
groupsToRemove = new Vector();
iter = rootGroup2.subgroups();
while (iter.hasNext())
{
groupsToRemove.add(iter.next());
}
iter = groupsToRemove.iterator();
iter = rootGroup2.subgroups();
while (iter.hasNext())
{
ContactGroup item = (ContactGroup) iter.next();
@ -288,14 +276,8 @@ public void clearProvidersLists()
}
//then delete contacts if any in root list
contactsToRemove = new Vector();
iter = rootGroup2.contacts();
while (iter.hasNext())
{
contactsToRemove.add(iter.next());
}
iter = contactsToRemove.iterator();
while (iter.hasNext())
{
opSetPersPresence2.unsubscribe( (Contact) iter.next());
}

Loading…
Cancel
Save