Started working on media and fixed meta contact list contact merge and contact remove

added a method for retrieving all proto contacts that belong to a particular contact group
cusax-fix
Emil Ivov 20 years ago
parent 6557ead4ac
commit 00ccb17687

@ -114,6 +114,36 @@ public Iterator getContactsForProvider(ProtocolProviderService provider)
return providerContacts.iterator();
}
/**
* Returns contacts, encapsulated by this MetaContact and belonging to
* the specified protocol ContactGroup.
* <p>
* In order to prevent problems with concurrency, the <tt>Iterator</tt>
* returned by this method is not be over the actual list of contacts but
* over a copy of that list.
*
* @param parentProtoGroup a reference to the <tt>ContactGroup</tt>
* whose children we'd like removed..
* @return an Iterator over all <tt>Contact</tt>s encapsulated in this
* <tt>MetaContact</tt> and belonging to the specified proto ContactGroup.
*/
public Iterator getContactsForContactGroup(ContactGroup parentProtoGroup)
{
Iterator contactsIter = protoContacts.iterator();
LinkedList providerContacts = new LinkedList();
while (contactsIter.hasNext())
{
Contact contact = (Contact)contactsIter.next();
if(contact.getParentContactGroup() == parentProtoGroup)
providerContacts.add( contact );
}
return providerContacts.iterator();
}
/**
* Returns a contact encapsulated by this meta contact, having the specified
* contactAddress and coming from the indicated ownerProvider.
@ -394,6 +424,34 @@ boolean removeContactsForProvider(ProtocolProviderService provider)
return modified;
}
/**
* Removes all proto contacts that belong to the specified protocol group.
*
* @param group the group whose children we want removed.
*
* @return true if this <tt>MetaContact</tt> was modified and false
* otherwise.
*/
boolean removeContactsForGroup(ContactGroup protoGroup)
{
boolean modified = false;
Iterator contactsIter = protoContacts.iterator();
while(contactsIter.hasNext())
{
Contact contact = (Contact)contactsIter.next();
if (contact.getParentContactGroup() == protoGroup)
{
contactsIter.remove();
modified = true;
}
}
return modified;
}
/**
* Sets <tt>parentGroup</tt> as a parent of this meta contact. Do not
* call this method with a null argument even if a group is removing

Loading…
Cancel
Save