1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01:00

Use AbstractNodeInformationProvider where possible

This commit is contained in:
Florian Schmaus 2014-10-13 22:35:45 +02:00
parent b54d133b36
commit ce203e76b5
2 changed files with 8 additions and 40 deletions

View file

@ -37,12 +37,11 @@ import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache; import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
import org.jivesoftware.smackx.caps.packet.CapsExtension; import org.jivesoftware.smackx.caps.packet.CapsExtension;
import org.jivesoftware.smackx.disco.NodeInformationProvider; import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Feature; import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Feature;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity; import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.disco.packet.DiscoverItems.Item;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.util.cache.LruCache; import org.jxmpp.util.cache.LruCache;
@ -478,25 +477,17 @@ public class EntityCapsManager extends Manager {
JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion, "sha-1")); JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion, "sha-1"));
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities()); final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new NodeInformationProvider() { sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() {
List<String> features = sdm.getFeaturesList(); List<String> features = sdm.getFeaturesList();
List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList(); List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();
@Override
public List<Item> getNodeItems() {
return null;
}
@Override @Override
public List<String> getNodeFeatures() { public List<String> getNodeFeatures() {
return features; return features;
} }
@Override @Override
public List<Identity> getNodeIdentities() { public List<Identity> getNodeIdentities() {
return identities; return identities;
} }
@Override @Override
public List<PacketExtension> getNodePacketExtensions() { public List<PacketExtension> getNodePacketExtensions() {
return packetExtensions; return packetExtensions;

View file

@ -38,16 +38,14 @@ import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.commands.AdHocCommand.Action; import org.jivesoftware.smackx.commands.AdHocCommand.Action;
import org.jivesoftware.smackx.commands.AdHocCommand.Status; import org.jivesoftware.smackx.commands.AdHocCommand.Status;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData; import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
import org.jivesoftware.smackx.disco.NodeInformationProvider; import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.Form;
@ -143,7 +141,8 @@ public class AdHocCommandManager extends Manager {
// received // received
ServiceDiscoveryManager.getInstanceFor(connection) ServiceDiscoveryManager.getInstanceFor(connection)
.setNodeInformationProvider(NAMESPACE, .setNodeInformationProvider(NAMESPACE,
new NodeInformationProvider() { new AbstractNodeInformationProvider() {
@Override
public List<DiscoverItems.Item> getNodeItems() { public List<DiscoverItems.Item> getNodeItems() {
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>(); List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
@ -159,19 +158,6 @@ public class AdHocCommandManager extends Manager {
return answer; return answer;
} }
public List<String> getNodeFeatures() {
return null;
}
public List<Identity> getNodeIdentities() {
return null;
}
@Override
public List<PacketExtension> getNodePacketExtensions() {
return null;
}
}); });
// The packet listener and the filter for processing some AdHoc Commands // The packet listener and the filter for processing some AdHoc Commands
@ -232,11 +218,8 @@ public class AdHocCommandManager extends Manager {
// Set the NodeInformationProvider that will provide information about // Set the NodeInformationProvider that will provide information about
// the added command // the added command
serviceDiscoveryManager.setNodeInformationProvider(node, serviceDiscoveryManager.setNodeInformationProvider(node,
new NodeInformationProvider() { new AbstractNodeInformationProvider() {
public List<DiscoverItems.Item> getNodeItems() { @Override
return null;
}
public List<String> getNodeFeatures() { public List<String> getNodeFeatures() {
List<String> answer = new ArrayList<String>(); List<String> answer = new ArrayList<String>();
answer.add(NAMESPACE); answer.add(NAMESPACE);
@ -245,7 +228,7 @@ public class AdHocCommandManager extends Manager {
answer.add("jabber:x:data"); answer.add("jabber:x:data");
return answer; return answer;
} }
@Override
public List<DiscoverInfo.Identity> getNodeIdentities() { public List<DiscoverInfo.Identity> getNodeIdentities() {
List<DiscoverInfo.Identity> answer = new ArrayList<DiscoverInfo.Identity>(); List<DiscoverInfo.Identity> answer = new ArrayList<DiscoverInfo.Identity>();
DiscoverInfo.Identity identity = new DiscoverInfo.Identity( DiscoverInfo.Identity identity = new DiscoverInfo.Identity(
@ -253,12 +236,6 @@ public class AdHocCommandManager extends Manager {
answer.add(identity); answer.add(identity);
return answer; return answer;
} }
@Override
public List<PacketExtension> getNodePacketExtensions() {
return null;
}
}); });
} }