From ce203e76b55a703f9068956eb87ca3e3bc843eb2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 13 Oct 2014 22:35:45 +0200 Subject: [PATCH] Use AbstractNodeInformationProvider where possible --- .../smackx/caps/EntityCapsManager.java | 13 ++----- .../smackx/commands/AdHocCommandManager.java | 35 ++++--------------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index 8ac7732e5..bd546e96f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -37,12 +37,11 @@ import org.jivesoftware.smack.filter.PacketExtensionFilter; import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache; 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.packet.DiscoverInfo; import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Feature; 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.packet.DataForm; 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")); final List identities = new LinkedList(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities()); - sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new NodeInformationProvider() { + sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() { List features = sdm.getFeaturesList(); List packetExtensions = sdm.getExtendedInfoAsList(); - - @Override - public List getNodeItems() { - return null; - } - @Override public List getNodeFeatures() { return features; } - @Override public List getNodeIdentities() { return identities; } - @Override public List getNodePacketExtensions() { return packetExtensions; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java index 2bbc607ce..33820aa60 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java @@ -38,16 +38,14 @@ import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.commands.AdHocCommand.Action; import org.jivesoftware.smackx.commands.AdHocCommand.Status; 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.packet.DiscoverInfo; -import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity; import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.jivesoftware.smackx.xdata.Form; @@ -143,7 +141,8 @@ public class AdHocCommandManager extends Manager { // received ServiceDiscoveryManager.getInstanceFor(connection) .setNodeInformationProvider(NAMESPACE, - new NodeInformationProvider() { + new AbstractNodeInformationProvider() { + @Override public List getNodeItems() { List answer = new ArrayList(); @@ -159,19 +158,6 @@ public class AdHocCommandManager extends Manager { return answer; } - - public List getNodeFeatures() { - return null; - } - - public List getNodeIdentities() { - return null; - } - - @Override - public List getNodePacketExtensions() { - return null; - } }); // 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 // the added command serviceDiscoveryManager.setNodeInformationProvider(node, - new NodeInformationProvider() { - public List getNodeItems() { - return null; - } - + new AbstractNodeInformationProvider() { + @Override public List getNodeFeatures() { List answer = new ArrayList(); answer.add(NAMESPACE); @@ -245,7 +228,7 @@ public class AdHocCommandManager extends Manager { answer.add("jabber:x:data"); return answer; } - + @Override public List getNodeIdentities() { List answer = new ArrayList(); DiscoverInfo.Identity identity = new DiscoverInfo.Identity( @@ -253,12 +236,6 @@ public class AdHocCommandManager extends Manager { answer.add(identity); return answer; } - - @Override - public List getNodePacketExtensions() { - return null; - } - }); }