1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-14 06:51:08 +01:00

Rename PacketFilter (and implementing classes) and PacketExtension

to StanzaFilter and ExtensionElement.
This commit is contained in:
Florian Schmaus 2015-02-26 18:41:17 +01:00
parent 2250ac20ed
commit d4a6d8e653
233 changed files with 1175 additions and 895 deletions

View file

@ -36,7 +36,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
@ -51,8 +51,8 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
private final StreamNegotiator primaryNegotiator;
private final StreamNegotiator secondaryNegotiator;
private final XMPPConnection connection;
private PacketFilter primaryFilter;
private PacketFilter secondaryFilter;
private StanzaFilter primaryFilter;
private StanzaFilter secondaryFilter;
public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary,
StreamNegotiator secondary) {
@ -61,7 +61,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
this.connection = connection;
}
public PacketFilter getInitiationPacketFilter(String from, String streamID) {
public StanzaFilter getInitiationPacketFilter(String from, String streamID) {
if (primaryFilter == null || secondaryFilter == null) {
primaryFilter = primaryNegotiator.getInitiationPacketFilter(from, streamID);
secondaryFilter = secondaryNegotiator.getInitiationPacketFilter(from, streamID);

View file

@ -24,11 +24,12 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
@ -81,7 +82,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
return negotiateIncomingStream(streamInitiation);
}
public PacketFilter getInitiationPacketFilter(String from, String streamID) {
public StanzaFilter getInitiationPacketFilter(String from, String streamID) {
/*
* this method is always called prior to #negotiateIncomingStream() so
* the In-Band Bytestream initiation listener must ignore the next
@ -111,27 +112,19 @@ public class IBBTransferNegotiator extends StreamNegotiator {
* This PacketFilter accepts an incoming In-Band Bytestream open request
* with a specified session ID.
*/
private static class IBBOpenSidFilter extends PacketTypeFilter {
private static class IBBOpenSidFilter extends FlexibleStanzaTypeFilter<Open> {
private String sessionID;
private final String sessionID;
public IBBOpenSidFilter(String sessionID) {
super(Open.class);
if (sessionID == null) {
throw new IllegalArgumentException("StreamID cannot be null");
}
this.sessionID = sessionID;
this.sessionID = Objects.requireNonNull(sessionID, "sessionID must not be null");
}
public boolean accept(Stanza packet) {
if (super.accept(packet)) {
Open bytestream = (Open) packet;
// packet must by of type SET and contains the given session ID
return this.sessionID.equals(bytestream.getSessionID())
&& IQ.Type.set.equals(bytestream.getType());
}
return false;
@Override
protected boolean acceptSpecific(Open bytestream) {
// packet must by of type SET and contains the given session ID
return this.sessionID.equals(bytestream.getSessionID())
&& IQ.Type.set.equals(bytestream.getType());
}
}

View file

@ -27,9 +27,9 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
@ -85,7 +85,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
}
@Override
public PacketFilter getInitiationPacketFilter(final String from, String streamID) {
public StanzaFilter getInitiationPacketFilter(final String from, String streamID) {
/*
* this method is always called prior to #negotiateIncomingStream() so the SOCKS5
* InitiationListener must ignore the next SOCKS5 Bytestream request with the given session
@ -126,27 +126,20 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
/**
* This PacketFilter accepts an incoming SOCKS5 Bytestream request with a specified session ID.
*/
private static class BytestreamSIDFilter extends PacketTypeFilter {
private static class BytestreamSIDFilter extends FlexibleStanzaTypeFilter<Bytestream> {
private final String sessionID;
public BytestreamSIDFilter(String sessionID) {
super(Bytestream.class);
this.sessionID = Objects.requireNonNull(sessionID, "SessionID cannot be null");
}
@Override
public boolean accept(Stanza packet) {
if (super.accept(packet)) {
Bytestream bytestream = (Bytestream) packet;
// packet must by of type SET and contains the given session ID
return this.sessionID.equals(bytestream.getSessionID())
&& IQ.Type.set.equals(bytestream.getType());
}
return false;
protected boolean acceptSpecific(Bytestream bytestream) {
// packet must by of type SET and contains the given session ID
return this.sessionID.equals(bytestream.getSessionID())
&& IQ.Type.set.equals(bytestream.getType());
}
}
/**

View file

@ -23,7 +23,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
@ -94,7 +94,7 @@ public abstract class StreamNegotiator {
* @return The <b><i>PacketFilter</b></i> that will return the packet relatable to the stream
* initiation.
*/
public abstract PacketFilter getInitiationPacketFilter(String from, String streamID);
public abstract StanzaFilter getInitiationPacketFilter(String from, String streamID);
abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException,