Improvements in obtaining contact capabilities.

cusax-fix
Yana Stamcheva 15 years ago
parent 41a1a65067
commit ff5a1b7693

@ -2071,18 +2071,4 @@ public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt)
{
// TODO Store MetaContact avatar.
}
/**
* Indicates that the capabilities of a given <tt>MetaContact</tt> have
* changed.
* @param evt the <tt>MetaContactCapabilitiesEvent</tt> that notified us
*/
public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt)
{
/*
* The OperationSet capabilities of MetaContact are not pesistent so
* MclStorageManager has nothing to do in response to
* MetaContactCapabilitiesEvent.
*/
}
}

@ -36,6 +36,12 @@ public class MetaContactImpl
*/
private final List<Contact> protoContacts = new Vector<Contact>();
/**
* The list of capabilities of the meta contact.
*/
private final Map<String, List<Contact>> capabilities
= new HashMap<String, List<Contact>>();
/**
* The number of contacts online in this meta contact.
*/
@ -204,8 +210,24 @@ public List<Contact> getContactsForOperationSet(
for (Contact contact : protoContacts)
{
if(contact.getProtocolProvider()
.getOperationSet(opSetClass) != null)
ProtocolProviderService contactProvider
= contact.getProtocolProvider();
// First try to ask the capabilities operation set if such is
// available.
OperationSetContactCapabilities capOpSet = contactProvider
.getOperationSet(OperationSetContactCapabilities.class);
if (capOpSet != null)
{
List<Contact> capContacts
= capabilities.get(opSetClass.getName());
if (capContacts != null && capContacts.contains(contact))
{
opSetContacts.add( contact );
}
}
else if (contactProvider.getOperationSet(opSetClass) != null)
opSetContacts.add( contact );
}
@ -381,9 +403,13 @@ public Contact getDefaultContact(Class<? extends OperationSet> operationSet)
if (capOpSet != null)
{
if (capOpSet.getOperationSet(defaultContact, operationSet)
!= null)
List<Contact> capContacts
= capabilities.get(operationSet.getName());
if (capContacts != null && capContacts.contains(defaultContact))
{
defaultOpSetContact = defaultContact;
}
}
else if (contactProvider.getOperationSet(operationSet) != null)
defaultOpSetContact = defaultContact;
@ -407,9 +433,14 @@ else if (contactProvider.getOperationSet(operationSet) != null)
// the needed opset.
if (capOpSet != null)
{
if (capOpSet.getOperationSet(defaultContact, operationSet)
== null)
List<Contact> capContacts
= capabilities.get(operationSet.getName());
if (capContacts == null
|| !capContacts.contains(defaultContact))
{
continue;
}
}
else if (contactProvider.getOperationSet(operationSet) == null)
continue;
@ -1252,6 +1283,109 @@ else if (value == null)
data[index + 1] = value;
}
/**
* Loads the capabilities of this <tt>MetaContact</tt>.
*
* @param protocolProvider the <tt>ProtocolProviderService</tt>, for which
* we're loading the capabilities
* @param capOpSet the <tt>OperationSetContactCapabilities</tt>
* through which we obtain the capability information
*/
public void loadCapabilities(
ProtocolProviderService protocolProvider,
OperationSetContactCapabilities capOpSet)
{
Iterator<Contact> contactIter = getContactsForProvider(protocolProvider);
while (contactIter.hasNext())
{
Contact contact = contactIter.next();
addCapabilities(contact,
capOpSet.getSupportedOperationSets(contact));
}
}
/**
* Updates the capabilities for the given contact.
*
* @param contact the <tt>Contact</tt>, which capabilities have changed
* @param opSets the new updated set of operation sets
*/
public void updateCapabilities( Contact contact,
Map<String, ? extends OperationSet> opSets)
{
OperationSetContactCapabilities capOpSet
= contact.getProtocolProvider().getOperationSet(
OperationSetContactCapabilities.class);
// This should not happen, because this method is called explicitly for
// events coming from the capabilities operation set.
if (capOpSet == null)
return;
removeCapabilities(contact, opSets);
addCapabilities(contact, opSets);
}
private void removeCapabilities(Contact contact,
Map<String, ? extends OperationSet> opSets)
{
Iterator<String> caps = this.capabilities.keySet().iterator();
Set<String> contactNewCaps = opSets.keySet();
while (caps.hasNext())
{
String opSetName = caps.next();
List<Contact> contactsForCap = capabilities.get(opSetName);
if (contactsForCap.contains(contact)
&& !contactNewCaps.contains(opSetName))
{
contactsForCap.remove(contact);
if (contactsForCap.size() == 0)
capabilities.remove(opSetName);
}
}
}
/**
* Adds the capabilities of the given contact.
*
* @param contact the <tt>Contact</tt>, which capabilities we add
* @param opSets the map of operation sets supported by the contact
*/
private void addCapabilities( Contact contact,
Map<String, ? extends OperationSet> opSets)
{
Iterator<String> contactNewCaps = opSets.keySet().iterator();
while (contactNewCaps.hasNext())
{
String newCap = contactNewCaps.next();
List<Contact> capContacts = null;
if (!capabilities.containsKey(newCap))
{
capContacts = new LinkedList<Contact>();
capContacts.add(contact);
capabilities.put(newCap, capContacts);
}
else
{
capContacts = capabilities.get(newCap);
if (!capContacts.contains(contact))
{
capContacts.add(contact);
}
}
}
}
/**
* Determines the index in <code>#data</code> of a specific key.
*

@ -1542,6 +1542,51 @@ private void synchronizeOpSetWithLocalContactList(
.addServerStoredGroupChangeListener(clGroupEventHandler);
}
/**
* Goes through the <tt>MetaContact</tt>s in the given <tt>group</tt> and
* loads contact capabilities for contained protocol contacts through the
* given capabilities operation set.
*/
private class LoadCapabilitiesThread extends Thread
{
private ProtocolProviderService protocolProvider;
private OperationSetContactCapabilities capabilitiesOpSet;
public LoadCapabilitiesThread(
ProtocolProviderService protocolProvider,
OperationSetContactCapabilities capabilitiesOpSet)
{
this.protocolProvider = protocolProvider;
this.capabilitiesOpSet = capabilitiesOpSet;
}
public void run()
{
loadCapabilities(rootMetaGroup);
}
private void loadCapabilities(MetaContactGroup group)
{
Iterator<MetaContact> metaContactIter = group.getChildContacts();
while (metaContactIter.hasNext())
{
MetaContact metaContact = metaContactIter.next();
((MetaContactImpl) metaContact)
.loadCapabilities(protocolProvider, capabilitiesOpSet);
}
Iterator<MetaContactGroup> subGroupIter = group.getSubgroups();
while (subGroupIter.hasNext())
{
loadCapabilities(subGroupIter.next());
}
}
}
/**
* Creates meta contacts and meta contact groups for all children of the
* specified <tt>contactGroup</tt> and adds them to <tt>metaGroup</tt>
@ -1689,7 +1734,10 @@ private synchronized void handleProviderAdded(
= provider.getOperationSet(OperationSetContactCapabilities.class);
if (capOpSet != null)
{
new LoadCapabilitiesThread(provider, capOpSet).start();
capOpSet.addContactCapabilitiesListener(this);
}
}
/**
@ -3234,57 +3282,13 @@ public void supportedOperationSetsChanged(ContactCapabilitiesEvent event)
if(metaContactImpl == null)
return;
fireCapabilitiesEvent(metaContactImpl,
MetaContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED);
}
/**
* Fires a new <tt>MetaContactCapabilitiesEvent</tt> to notify the
* registered <tt>MetaContactCapabilitiesListener</tt>s that this
* <tt>MetaContact</tt> has changed its list of <tt>OperationSet</tt>
* capabilities.
*
* @param metaContact the source <tt>MetaContact</tt>, 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 <tt>OperationSet</tt> capabilities
* of the specified <tt>sourceContact</tt> and the details of the event
*/
private void fireCapabilitiesEvent(MetaContact metaContact, int eventID)
{
MetaContactListListener[] listeners;
Contact contact = event.getSourceContact();
synchronized (metaContactListListeners)
{
listeners
= metaContactListListeners.toArray(
new MetaContactListListener[
metaContactListListeners.size()]);
}
if (listeners.length != 0)
{
MetaContactCapabilitiesEvent event
= new MetaContactCapabilitiesEvent(metaContact, eventID);
metaContactImpl.updateCapabilities(contact, event.getOperationSets());
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");
}
}
}
fireProtoContactEvent( contact,
ProtoContactEvent.PROTO_CONTACT_MODIFIED,
metaContactImpl,
metaContactImpl);
}
}

@ -372,9 +372,6 @@ public void metaContactRemoved(MetaContactEvent evt)
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt) {}
public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt)
{}
/**
* Implements <tt>MetaContactListListener.metaContactRenamed</tt> method.
* When a meta contact is renamed, updates all related labels in this

@ -219,9 +219,6 @@ public void metaContactMoved(MetaContactMovedEvent evt)
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt) {}
public void metaContactCapabilitiesChanged(
MetaContactCapabilitiesEvent evt) {}
/**
* Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list model
* when a new meta contact group has been added.

@ -446,7 +446,25 @@ public void protoContactAdded(ProtoContactEvent evt)
}
}
public void protoContactModified(ProtoContactEvent evt) {}
/**
* Notifies the UI representation of the parent <tt>MetaContact</tt> that
* this contact has been modified.
*
* @param evt the <tt>ProtoContactEvent</tt> that notified us
*/
public void protoContactModified(ProtoContactEvent evt)
{
UIContact uiContact = MetaContactListSource
.getUIContact(evt.getNewParent());
if (uiContact != null)
{
ContactNode contactNode = uiContact.getContactNode();
if (contactNode != null)
treeModel.nodeChanged(contactNode);
}
}
/**
* Adds the new <tt>MetaContact</tt> parent and removes the old one if the
@ -596,29 +614,6 @@ public void metaGroupReceived(MetaGroupQueryEvent event)
MetaContactListSource.createUIGroup(event.getMetaGroup()), true);
}
/**
* Updates the corresponding node when the list of the <tt>OperationSet</tt>
* capabilities of a <tt>MetaContact</tt> has changed.
* @param evt a <tt>ContactCapabilitiesEvent</tt> with ID
* {@link MetaContactCapabilitiesEvent#SUPPORTED_OPERATION_SETS_CHANGED}
* which specifies the <tt>Contact</tt> whose list of <tt>OperationSet</tt>
* 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 <tt>ContactQueryStatusEvent</tt> that notified us

@ -23,10 +23,12 @@
* Jabber <tt>Contact</tt> in question.
*
* @author Lubomir Marinov
* @author Yana Stamcheva
*/
public class OperationSetContactCapabilitiesJabberImpl
extends AbstractOperationSetContactCapabilities<ProtocolProviderServiceJabberImpl>
implements UserCapsNodeListener
implements UserCapsNodeListener,
ContactPresenceStatusListener
{
/**
* The <tt>Logger</tt> used by the
@ -66,6 +68,15 @@ public class OperationSetContactCapabilitiesJabberImpl
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_AUDIO
});
OPERATION_SETS_TO_FEATURES.put(
OperationSetVideoTelephony.class,
new String[]
{
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE,
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_VIDEO
});
}
/**
@ -86,6 +97,12 @@ public OperationSetContactCapabilitiesJabberImpl(
ProtocolProviderServiceJabberImpl parentProvider)
{
super(parentProvider);
OperationSetPresence presenceOpSet
= parentProvider.getOperationSet(OperationSetPresence.class);
if (presenceOpSet != null)
presenceOpSet.addContactPresenceStatusListener(this);
}
/**
@ -120,47 +137,11 @@ protected <U extends OperationSet> U getOperationSet(
Class<U> opsetClass,
boolean online)
{
U opset = parentProvider.getOperationSet(opsetClass);
if (opset == null)
return null;
/*
* If the specified contact is offline, don't query its features (they
* should fail anyway).
*/
if (!online)
{
if (OFFLINE_OPERATION_SETS.contains(opsetClass))
return opset;
else
return null;
}
/*
* If we know the features required for the support of opsetClass, check
* whether the contact supports them. Otherwise, presume the contact
* possesses the opsetClass capability in light of the fact that we miss
* any knowledge of the opsetClass whatsoever.
*/
if (OPERATION_SETS_TO_FEATURES.containsKey(opsetClass))
{
String[] features = OPERATION_SETS_TO_FEATURES.get(opsetClass);
String jid = parentProvider.getFullJid(contact);
if (jid == null)
jid = contact.getAddress();
/*
* Either we've completely disabled the opsetClass capability by
* mapping it to the null list of features or we've mapped it to an
* actual list of features which are to be checked whether the
* contact supports them.
*/
if ((features == null)
|| ((features.length != 0)
&& !parentProvider.isFeatureListSupported(
parentProvider.getFullJid(contact),
features)))
opset = null;
}
return opset;
return getOperationSet(jid, opsetClass, online);
}
/**
@ -183,13 +164,43 @@ protected <U extends OperationSet> U getOperationSet(
* Contact)
*/
@Override
@SuppressWarnings("unchecked")
protected Map<String, OperationSet> getSupportedOperationSets(
Contact contact,
boolean online)
{
String jid = parentProvider.getFullJid(contact);
if (jid == null)
jid = contact.getAddress();
return getSupportedOperationSets(jid, online);
}
/**
* Gets the <tt>OperationSet</tt>s supported by a specific <tt>Contact</tt>.
* The returned <tt>OperationSet</tt>s are considered by the associated
* protocol provider to capabilities possessed by the specified
* <tt>contact</tt>.
*
* @param jid the <tt>Contact</tt> for which the supported
* <tt>OperationSet</tt> capabilities are to be retrieved
* @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
* <tt>false</tt>
* @return a <tt>Map</tt> listing the <tt>OperationSet</tt>s considered by
* the associated protocol provider to be supported by the specified
* <tt>contact</tt> (i.e. to be possessed as capabilities). Each supported
* <tt>OperationSet</tt> capability is represented by a <tt>Map.Entry</tt>
* with key equal to the <tt>OperationSet</tt> class name and value equal to
* the respective <tt>OperationSet</tt> instance
* @see AbstractOperationSetContactCapabilities#getSupportedOperationSets(
* Contact)
*/
@SuppressWarnings("unchecked")
private Map<String, OperationSet> getSupportedOperationSets(String jid,
boolean online)
{
Map<String, OperationSet> supportedOperationSets
= super.getSupportedOperationSets(contact, online);
= parentProvider.getSupportedOperationSets();
int supportedOperationSetCount = supportedOperationSets.size();
Map<String, OperationSet> contactSupportedOperationSets
= new HashMap<String, OperationSet>(supportedOperationSetCount);
@ -204,7 +215,6 @@ protected Map<String, OperationSet> getSupportedOperationSets(
try
{
opsetClass
= (Class<? extends OperationSet>)
Class.forName(opsetClassName);
@ -220,7 +230,7 @@ protected Map<String, OperationSet> getSupportedOperationSets(
if (opsetClass != null)
{
OperationSet opset
= getOperationSet(contact, opsetClass, online);
= getOperationSet(jid, opsetClass, online);
if (opset != null)
{
@ -234,6 +244,79 @@ protected Map<String, OperationSet> getSupportedOperationSets(
return contactSupportedOperationSets;
}
/**
* Gets the <tt>OperationSet</tt> corresponding to the specified
* <tt>Class</tt> and supported by the specified <tt>Contact</tt>. If the
* returned value is non-<tt>null</tt>, it indicates that the
* <tt>Contact</tt> is considered by the associated protocol provider to
* possess the <tt>opsetClass</tt> capability. Otherwise, the associated
* protocol provider considers <tt>contact</tt> to not have the
* <tt>opsetClass</tt> capability.
*
* @param <U> the type extending <tt>OperationSet</tt> for which the
* specified <tt>contact</tt> is to be checked whether it possesses it as a
* capability
* @param jid the Jabber id for which we're checking supported operation
* sets
* @param opsetClass the <tt>OperationSet</tt> <tt>Class</tt> for which the
* specified <tt>contact</tt> is to be checked whether it possesses it as a
* capability
* @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
* <tt>false</tt>
* @return the <tt>OperationSet</tt> corresponding to the specified
* <tt>opsetClass</tt> which is considered by the associated protocol
* provider to be possessed as a capability by the specified
* <tt>contact</tt>; otherwise, <tt>null</tt>
* @see AbstractOperationSetContactCapabilities#getOperationSet(Contact,
* Class)
*/
private <U extends OperationSet> U getOperationSet(String jid,
Class<U> opsetClass,
boolean online)
{
U opset = parentProvider.getOperationSet(opsetClass);
if (opset == null)
return null;
/*
* If the specified contact is offline, don't query its features (they
* should fail anyway).
*/
if (!online)
{
if (OFFLINE_OPERATION_SETS.contains(opsetClass))
return opset;
else
return null;
}
/*
* If we know the features required for the support of opsetClass, check
* whether the contact supports them. Otherwise, presume the contact
* possesses the opsetClass capability in light of the fact that we miss
* any knowledge of the opsetClass whatsoever.
*/
if (OPERATION_SETS_TO_FEATURES.containsKey(opsetClass))
{
String[] features = OPERATION_SETS_TO_FEATURES.get(opsetClass);
/*
* Either we've completely disabled the opsetClass capability by
* mapping it to the null list of features or we've mapped it to an
* actual list of features which are to be checked whether the
* contact supports them.
*/
if ((features == null)
|| ((features.length != 0)
&& !parentProvider.isFeatureListSupported(
jid,
features)))
opset = null;
}
return opset;
}
/**
* Sets the <tt>EntityCapsManager</tt> which is associated with the
* <tt>discoveryManager</tt> of {@link #parentProvider}.
@ -276,15 +359,16 @@ void setDiscoveryManager(ScServiceDiscoveryManager discoveryManager)
*
* @param user the user (full JID)
* @param node the entity caps node#ver
* @see UserCapsNodeListener#userCapsNodeAdded(String, String)
* @param online indicates if the user is currently online
* @see UserCapsNodeListener#userCapsNodeAdded(String, String, boolean)
*/
public void userCapsNodeAdded(String user, String node)
public void userCapsNodeAdded(String user, String node, boolean online)
{
/*
* It doesn't matter to us whether a caps node has been added or removed
* for the specified user because we report all changes.
*/
userCapsNodeRemoved(user, node);
userCapsNodeRemoved(user, node, online);
}
/**
@ -293,9 +377,10 @@ public void userCapsNodeAdded(String user, String node)
*
* @param user the user (full JID)
* @param node the entity caps node#ver
* @see UserCapsNodeListener#userCapsNodeRemoved(String, String)
* @param online indicates if the given user is online
* @see UserCapsNodeListener#userCapsNodeRemoved(String, String, boolean)
*/
public void userCapsNodeRemoved(String user, String node)
public void userCapsNodeRemoved(String user, String node, boolean online)
{
OperationSetPresence opsetPresence
= parentProvider.getOperationSet(OperationSetPresence.class);
@ -305,12 +390,30 @@ public void userCapsNodeRemoved(String user, String node)
String jid = StringUtils.parseBareAddress(user);
Contact contact = opsetPresence.findContactByID(jid);
if (contact != null)
// If the contact isn't null and is online we try to discover the
// new set of operation sets and to notify interested parties.
// Otherwise we ignore the event.
if (contact != null && online)
{
fireContactCapabilitiesEvent(
contact,
ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED);
ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED,
getSupportedOperationSets(user, online));
}
}
}
/**
* Removes the capabilities when the user goes offline.
*
* @param evt the <tt>ContactPresenceStatusChangeEvent</tt> that notified
* us
*/
public void contactPresenceStatusChanged(
ContactPresenceStatusChangeEvent evt)
{
// If the user goes offline we ensure to remove the caps node.
if (evt.getNewStatus().getStatus() < PresenceStatus.ONLINE_THRESHOLD)
capsManager.removeUserCapsNode(evt.getSourceContact().getAddress());
}
}

@ -1523,13 +1523,19 @@ public boolean isFeatureSupported(String jid, String feature)
}
/**
* Returns the full jabber id (jid) corresponding to the given contact.
* Returns the full jabber id (jid) corresponding to the given contact. If
* the provider is not connected returns null.
*
* @param contact the contact, for which we're looking for a jid
* @return the jid of the specified contact;
* @return the jid of the specified contact or null if the provider is not
* yet connected;
*/
public String getFullJid(Contact contact)
{
XMPPConnection connection = getConnection();
if (connection == null)
return null;
Roster roster = getConnection().getRoster();
Presence presence = roster.getPresence(contact.getAddress());

@ -179,10 +179,13 @@ private static String getCapsPropertyName(Caps caps)
* @param node the node (of the caps packet extension)
* @param hash the hashing algorithm used to calculate <tt>ver</tt>
* @param ver the version (of the caps packet extension)
* @param online indicates if the user is online
*/
private void addUserCapsNode(
String user,
String node, String hash, String ver)
private void addUserCapsNode( String user,
String node,
String hash,
String ver,
boolean online)
{
if ((user != null) && (node != null) && (hash != null) && (ver != null))
{
@ -194,6 +197,7 @@ private void addUserCapsNode(
|| !caps.ver.equals(ver))
{
caps = new Caps(node, hash, ver);
userCaps.put(user, caps);
}
else
@ -213,7 +217,7 @@ private void addUserCapsNode(
String nodeVer = caps.getNodeVer();
for (UserCapsNodeListener listener : listeners)
listener.userCapsNodeAdded(user, nodeVer);
listener.userCapsNodeAdded(user, nodeVer, online);
}
}
}
@ -264,7 +268,7 @@ public void removeUserCapsNode(String user)
String nodeVer = caps.getNodeVer();
for (UserCapsNodeListener listener : listeners)
listener.userCapsNodeRemoved(user, nodeVer);
listener.userCapsNodeRemoved(user, nodeVer, false);
}
}
}
@ -829,9 +833,16 @@ public void processPacket(Packet packet)
if (hash != null)
{
// Check it the packet indicates that the user is online. We
// will use this information to decide if we're going to send
// the discover info request.
boolean online = false;
if (packet instanceof Presence)
online = ((Presence) packet).isAvailable();
addUserCapsNode(
packet.getFrom(),
ext.getNode(), hash, ext.getVersion());
ext.getNode(), hash, ext.getVersion(), online);
}
}
}

@ -20,8 +20,9 @@ public interface UserCapsNodeListener
*
* @param user the user (full JID)
* @param node the entity caps node#ver
* @param online indicates if the user for which we're notified is online
*/
public void userCapsNodeAdded(String user, String node);
public void userCapsNodeAdded(String user, String node, boolean online);
/**
* Notifies this listener that an <tt>EntityCapsManager</tt> has removed a
@ -29,6 +30,7 @@ public interface UserCapsNodeListener
*
* @param user the user (full JID)
* @param node the entity caps node#ver
* @param online indicates if the user for which we're notified is online
*/
public void userCapsNodeRemoved(String user, String node);
public void userCapsNodeRemoved(String user, String node, boolean online);
}

@ -1,85 +0,0 @@
/*
* 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/<tt>EventObject</tt> fired by
* <tt>OperationSetClientCapabilities</tt> in order to notify about changes in
* the list of the <tt>OperationSet</tt> capabilities of a <tt>Contact</tt>.
*
* @author Yana Stamcheva
*/
public class MetaContactCapabilitiesEvent
extends EventObject
{
/**
* Serial version UID.
*/
private static final long serialVersionUID = 0L;
/**ContactList.java
* The ID of the <tt>MetaContactCapabilitiesEvent</tt> which notifies about
* changes in the list of the <tt>OperationSet</tt> capabilities of a
* <tt>MetaContact</tt>.
*/
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 <tt>OperationSet</tt> capabilities of the associated
* <tt>Contact</tt> and the details this event carries.
*/
private final int eventID;
/**
* Initializes a new <tt>ContactCapabilitiesEvent</tt> instance which is to
* notify about a specific change in the list of <tt>OperationSet</tt>
* capabilities of a specific <tt>Contact</tt>.
*
* @param sourceContact the <tt>MetaContact</tt> 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 <tt>OperationSet</tt> capabilities of the
* specified <tt>sourceContact</tt> 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 <tt>OperationSet</tt> capabilities of the associated
* <tt>sourceContact</tt> and the details it carries.
*
* @return the ID of this event which indicates the specifics of the change
* in the list of <tt>OperationSet</tt> capabilities of the associated
* <tt>sourceContact</tt> and the details it carries
*/
public int getEventID()
{
return eventID;
}
/**
* Gets the <tt>MetaContact</tt> which is the source/cause of this event i.e.
* which has changed its list of <tt>OperationSet</tt> capabilities.
*
* @return the <tt>MetaContact</tt> which is the source/cause of this event
*/
public MetaContact getSourceContact()
{
return (MetaContact) getSource();
}
}

@ -126,15 +126,4 @@ public interface MetaContactListListener
* of this event
*/
public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt);
/**
* Notifies this listener that the list of the <tt>OperationSet</tt>
* capabilities of a <tt>MetaContact</tt> has changed.
*
* @param evt a <tt>MetaContactCapabilitiesEvent</tt> with ID
* {@link MetaContactCapabilitiesEvent#SUPPORTED_OPERATION_SETS_CHANGED}
* which specifies the <tt>MetaContact</tt> whose list of
* <tt>OperationSet</tt> capabilities has changed
*/
public void metaContactCapabilitiesChanged(MetaContactCapabilitiesEvent evt);
}

@ -98,10 +98,12 @@ public void addContactCapabilitiesListener(
* @param eventID the ID of the event to be fired which indicates the
* specifics of the change of the list of <tt>OperationSet</tt> capabilities
* of the specified <tt>sourceContact</tt> and the details of the event
* @param opSets the new set of operation sets for the given source contact
*/
protected void fireContactCapabilitiesEvent(
Contact sourceContact,
int eventID)
int eventID,
Map<String, ? extends OperationSet> opSets)
{
ContactCapabilitiesListener[] listeners;
@ -115,7 +117,7 @@ protected void fireContactCapabilitiesEvent(
if (listeners.length != 0)
{
ContactCapabilitiesEvent event
= new ContactCapabilitiesEvent(sourceContact, eventID);
= new ContactCapabilitiesEvent(sourceContact, eventID, opSets);
for (ContactCapabilitiesListener listener : listeners)
{

@ -16,6 +16,7 @@
* the list of the <tt>OperationSet</tt> capabilities of a <tt>Contact</tt>.
*
* @author Lubomir Marinov
* @author Yana Stamcheva
*/
public class ContactCapabilitiesEvent
extends EventObject
@ -39,6 +40,11 @@ public class ContactCapabilitiesEvent
*/
private final int eventID;
/**
* The new set of supported <tt>OperationSet</tt>s.
*/
private final Map<String, ? extends OperationSet> opSets;
/**
* Initializes a new <tt>ContactCapabilitiesEvent</tt> instance which is to
* notify about a specific change in the list of <tt>OperationSet</tt>
@ -50,12 +56,17 @@ public class ContactCapabilitiesEvent
* the change in the list of <tt>OperationSet</tt> capabilities of the
* specified <tt>sourceContact</tt> and the details to be carried by the new
* event
* @param opSets the new set of operation sets this event is about
*/
public ContactCapabilitiesEvent(Contact sourceContact, int eventID)
public ContactCapabilitiesEvent(
Contact sourceContact,
int eventID,
Map<String, ? extends OperationSet> opSets)
{
super(sourceContact);
this.eventID = eventID;
this.opSets = opSets;
}
/**
@ -82,4 +93,14 @@ public Contact getSourceContact()
{
return (Contact) getSource();
}
/**
* Returns the new set of <tt>OperationSet</tt>-s this event is about
*
* @return the new set of <tt>OperationSet</tt>-s
*/
public Map<String, ? extends OperationSet> getOperationSets()
{
return opSets;
}
}

@ -1245,16 +1245,5 @@ public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt)
{
collectedMetaContactGroupEvents.add(evt);
}
/**
* Indicates that a <tt>MetaContact</tt> capabilities have changed.
* @param evt the <tt>MetaContactCapabilitiesEvent</tt> that notified
* us
*/
public void metaContactCapabilitiesChanged(
MetaContactCapabilitiesEvent evt)
{
collectedMetaContactEvents.add(evt);
}
}
}

Loading…
Cancel
Save