subgroups = rootGroup.subgroups();
+ while(subgroups.hasNext())
+ {
+ ContactGroup group = subgroups.next();
+ //remove the group
+ this.removeContactGroupFromMetaContactGroup(
+ (MetaContactGroupImpl) findMetaContactGroupByContactGroup(
+ group),
+ group,
+ provider);
+ }
- while(subgroups.hasNext())
- {
- ContactGroup group = subgroups.next();
- //remove the group
+ //remove the root group
this.removeContactGroupFromMetaContactGroup(
- (MetaContactGroupImpl)findMetaContactGroupByContactGroup(group),
- group,
- provider);
+ this.rootMetaGroup, rootGroup, provider);
}
- //remove the root group
- this.removeContactGroupFromMetaContactGroup(
- this.rootMetaGroup, rootGroup, provider);
+ // Check if the capabilities operation set is available for this
+ // contact and remove previously added listeners.
+ OperationSetContactCapabilities capOpSet
+ = provider.getOperationSet(OperationSetContactCapabilities.class);
+
+ if (capOpSet != null)
+ capOpSet.removeContactCapabilitiesListener(this);
}
/**
@@ -3146,4 +3167,79 @@ public synchronized void waitForEvent(long millis)
}
}
}
+
+ /**
+ * Notifies this listener that the list of the OperationSet
+ * capabilities of a Contact has changed.
+ *
+ * @param event a ContactCapabilitiesEvent with ID
+ * {@link ContactCapabilitiesEvent#SUPPORTED_OPERATION_SETS_CHANGED} which
+ * specifies the Contact whose list of OperationSet
+ * capabilities has changed
+ */
+ public void supportedOperationSetsChanged(ContactCapabilitiesEvent event)
+ {
+ // If the source contact isn't contained in this meta contact we have
+ // nothing more to do here.
+ MetaContactImpl metaContactImpl
+ = (MetaContactImpl) findMetaContactByContact(
+ event.getSourceContact());
+
+ //ignore if we have no meta contact.
+ if(metaContactImpl == null)
+ return;
+
+ fireCapabilitiesEvent(metaContactImpl,
+ MetaContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED);
+ }
+
+ /**
+ * Fires a new MetaContactCapabilitiesEvent to notify the
+ * registered MetaContactCapabilitiesListeners that this
+ * MetaContact has changed its list of OperationSet
+ * capabilities.
+ *
+ * @param metaContact the source MetaContact, which capabilities
+ * has changed
+ * @param eventID the ID of the event to be fired which indicates the
+ * specifics of the change of the list of OperationSet capabilities
+ * of the specified sourceContact and the details of the event
+ */
+ private void fireCapabilitiesEvent(MetaContact metaContact, int eventID)
+ {
+ MetaContactListListener[] listeners;
+
+ synchronized (metaContactListListeners)
+ {
+ listeners
+ = metaContactListListeners.toArray(
+ new MetaContactListListener[
+ metaContactListListeners.size()]);
+ }
+ if (listeners.length != 0)
+ {
+ MetaContactCapabilitiesEvent event
+ = new MetaContactCapabilitiesEvent(metaContact, eventID);
+
+ for (MetaContactListListener listener : listeners)
+ {
+ switch (eventID)
+ {
+ case MetaContactCapabilitiesEvent
+ .SUPPORTED_OPERATION_SETS_CHANGED:
+ listener.metaContactCapabilitiesChanged(event);
+ break;
+ default:
+ if (logger.isDebugEnabled())
+ {
+ logger.debug(
+ "Cannot fire MetaContactCapabilitiesEvent with"
+ + " unsupported eventID: "
+ + eventID);
+ }
+ throw new IllegalArgumentException("eventID");
+ }
+ }
+ }
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java
index b4ef61ecd..4b3a74e74 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java
@@ -372,6 +372,9 @@ public void metaContactRemoved(MetaContactEvent evt)
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt) {}
+ public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt)
+ {}
+
/**
* Implements MetaContactListListener.metaContactRenamed method.
* When a meta contact is renamed, updates all related labels in this
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java
index c713ad62f..774a5b82c 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java
@@ -219,6 +219,9 @@ public void metaContactMoved(MetaContactMovedEvent evt)
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt) {}
+ public void metaContactCapabilitiesChanged(
+ MetaContactCapabilitiesEvent evt) {}
+
/**
* Handles the MetaContactGroupEvent. Refreshes the list model
* when a new meta contact group has been added.
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
index d6a2db1a3..88f2bb006 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
@@ -513,7 +513,12 @@ public void protoContactRemoved(ProtoContactEvent evt)
= MetaContactListSource.getUIContact(oldParent);
if (oldUIContact != null)
- removeContact(oldUIContact);
+ {
+ ContactNode contactNode = oldUIContact.getContactNode();
+
+ if (contactNode != null)
+ treeModel.nodeChanged(contactNode);
+ }
}
/**
@@ -588,6 +593,29 @@ public void metaGroupReceived(MetaGroupQueryEvent event)
MetaContactListSource.createUIGroup(event.getMetaGroup()), true);
}
+ /**
+ * Updates the corresponding node when the list of the OperationSet
+ * capabilities of a MetaContact has changed.
+ * @param evt a ContactCapabilitiesEvent with ID
+ * {@link MetaContactCapabilitiesEvent#SUPPORTED_OPERATION_SETS_CHANGED}
+ * which specifies the Contact whose list of OperationSet
+ * capabilities has changed
+ */
+ public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt)
+ {
+ UIContact uiContact = MetaContactListSource
+ .getUIContact(evt.getSourceContact());
+
+ if (uiContact != null && evt.getEventID()
+ == MetaContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED)
+ {
+ ContactNode contactNode = uiContact.getContactNode();
+
+ if (contactNode != null)
+ treeModel.nodeChanged(contactNode);
+ }
+ }
+
/**
* Indicates that the status of a query has changed.
* @param event the ContactQueryStatusEvent that notified us
diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContact.java b/src/net/java/sip/communicator/service/contactlist/MetaContact.java
index e4ec40ca8..b999e5007 100644
--- a/src/net/java/sip/communicator/service/contactlist/MetaContact.java
+++ b/src/net/java/sip/communicator/service/contactlist/MetaContact.java
@@ -11,7 +11,7 @@
import net.java.sip.communicator.service.protocol.*;
/**
- * A MetaContact is an abstraction used for merging mutltiple Contacts (most
+ * A MetaContact is an abstraction used for merging multiple Contacts (most
* often) belonging to different ProtocolProviders.
*
* Instances of a MetaContact are read-only objects that cannot be modified
diff --git a/src/net/java/sip/communicator/service/contactlist/event/MetaContactCapabilitiesEvent.java b/src/net/java/sip/communicator/service/contactlist/event/MetaContactCapabilitiesEvent.java
new file mode 100644
index 000000000..9ae391c7b
--- /dev/null
+++ b/src/net/java/sip/communicator/service/contactlist/event/MetaContactCapabilitiesEvent.java
@@ -0,0 +1,80 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.contactlist.event;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.contactlist.*;
+
+/**
+ * Represents an event/EventObject fired by
+ * OperationSetClientCapabilities in order to notify about changes in
+ * the list of the OperationSet capabilities of a Contact.
+ *
+ * @author Yana Stamcheva
+ */
+public class MetaContactCapabilitiesEvent
+ extends EventObject
+{
+ /**ContactList.java
+ * The ID of the MetaContactCapabilitiesEvent which notifies about
+ * changes in the list of the OperationSet capabilities of a
+ * MetaContact.
+ */
+ public static final int SUPPORTED_OPERATION_SETS_CHANGED = 1;
+
+ /**
+ * The ID of this event which indicates the specifics of the change in the
+ * list of OperationSet capabilities of the associated
+ * Contact and the details this event carries.
+ */
+ private final int eventID;
+
+ /**
+ * Initializes a new ContactCapabilitiesEvent instance which is to
+ * notify about a specific change in the list of OperationSet
+ * capabilities of a specific Contact.
+ *
+ * @param sourceContact the MetaContact which is to be considered
+ * the source/cause of the new event
+ * @param eventID the ID of the new event which indicates the specifics of
+ * the change in the list of OperationSet capabilities of the
+ * specified sourceContact and the details to be carried by the new
+ * event
+ */
+ public MetaContactCapabilitiesEvent(MetaContact sourceContact, int eventID)
+ {
+ super(sourceContact);
+
+ this.eventID = eventID;
+ }
+
+ /**
+ * Gets the ID of this event which indicates the specifics of the change in
+ * the list of OperationSet capabilities of the associated
+ * sourceContact and the details it carries.
+ *
+ * @return the ID of this event which indicates the specifics of the change
+ * in the list of OperationSet capabilities of the associated
+ * sourceContact and the details it carries
+ */
+ public int getEventID()
+ {
+ return eventID;
+ }
+
+ /**
+ * Gets the MetaContact which is the source/cause of this event i.e.
+ * which has changed its list of OperationSet capabilities.
+ *
+ * @return the MetaContact which is the source/cause of this event
+ */
+ public MetaContact getSourceContact()
+ {
+ return (MetaContact) getSource();
+ }
+}
\ No newline at end of file
diff --git a/src/net/java/sip/communicator/service/contactlist/event/MetaContactListListener.java b/src/net/java/sip/communicator/service/contactlist/event/MetaContactListListener.java
index f2b760260..0ac41c3c8 100644
--- a/src/net/java/sip/communicator/service/contactlist/event/MetaContactListListener.java
+++ b/src/net/java/sip/communicator/service/contactlist/event/MetaContactListListener.java
@@ -115,7 +115,8 @@ public interface MetaContactListListener
/**
* Indicates that a MetaContact has been modified.
- * @param evt the MetaContactModifiedEvent containing the corresponding contact
+ * @param evt the MetaContactModifiedEvent containing the corresponding
+ * contact
*/
public void metaContactModified(MetaContactModifiedEvent evt);
@@ -125,4 +126,15 @@ public interface MetaContactListListener
* of this event
*/
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt);
+
+ /**
+ * Notifies this listener that the list of the OperationSet
+ * capabilities of a MetaContact has changed.
+ *
+ * @param evt a ContactCapabilitiesEvent with ID
+ * {@link MetaContactCapabilitiesEvent#SUPPORTED_OPERATION_SETS_CHANGED}
+ * which specifies the Contact whose list of OperationSet
+ * capabilities has changed
+ */
+ public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt);
}
diff --git a/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java
index 987aef801..31efffa40 100644
--- a/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java
+++ b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java
@@ -1245,5 +1245,16 @@ public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt)
{
collectedMetaContactGroupEvents.add(evt);
}
+
+ /**
+ * Indicates that a MetaContact capabilities have changed.
+ * @param evt the MetaContactCapabilitiesEvent that notified
+ * us
+ */
+ public void metaContactCapabilitiesChanged(
+ MetaContactCapabilitiesEvent evt)
+ {
+ collectedMetaContactEvents.add(evt);
+ }
}
}