Remove deprecated methods from Stanza class

This commit is contained in:
Florian Schmaus 2019-10-05 12:16:41 +02:00
parent f0300dc906
commit 30bbdf9fdb
3 changed files with 37 additions and 82 deletions

View File

@ -31,8 +31,6 @@ import org.jivesoftware.smack.util.PacketUtil;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* Base class for XMPP Stanzas, which are called Stanza in older versions of Smack (i.e. < 4.1).
@ -47,6 +45,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
* </p>
*
* @author Matt Tucker
* @author Florian Schmaus
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#stanzas">RFC 6120 § 8. XML Stanzas</a>
*/
public abstract class Stanza implements TopLevelStreamElement {
@ -109,16 +108,6 @@ public abstract class Stanza implements TopLevelStreamElement {
return id;
}
/**
* Get the Stanza ID.
* @return the stanza id.
* @deprecated use {@link #getStanzaId()} instead.
*/
@Deprecated
public String getPacketID() {
return getStanzaId();
}
/**
* Sets the unique ID of the packet. To indicate that a stanza has no id
* pass <code>null</code> as the packet's id value.
@ -132,16 +121,6 @@ public abstract class Stanza implements TopLevelStreamElement {
this.id = id;
}
/**
* Set the stanza ID.
* @param packetID TODO javadoc me please
* @deprecated use {@link #setStanzaId(String)} instead.
*/
@Deprecated
public void setPacketID(String packetID) {
setStanzaId(packetID);
}
/**
* Check if this stanza has an ID set.
*
@ -179,26 +158,6 @@ public abstract class Stanza implements TopLevelStreamElement {
return to;
}
/**
* Sets who the stanza is being sent "to". The XMPP protocol often makes
* the "to" attribute optional, so it does not always need to be set.
*
* @param to who the stanza is being sent to.
* @throws IllegalArgumentException if to is not a valid JID String.
* @deprecated use {@link #setTo(Jid)} instead.
*/
@Deprecated
public void setTo(String to) {
Jid jid;
try {
jid = JidCreate.from(to);
}
catch (XmppStringprepException e) {
throw new IllegalArgumentException(e);
}
setTo(jid);
}
/**
* Sets who the packet is being sent "to". The XMPP protocol often makes
* the "to" attribute optional, so it does not always need to be set.
@ -221,27 +180,6 @@ public abstract class Stanza implements TopLevelStreamElement {
return from;
}
/**
* Sets who the stanza is being sent "from". The XMPP protocol often
* makes the "from" attribute optional, so it does not always need to
* be set.
*
* @param from who the stanza is being sent to.
* @throws IllegalArgumentException if from is not a valid JID String.
* @deprecated use {@link #setFrom(Jid)} instead.
*/
@Deprecated
public void setFrom(String from) {
Jid jid;
try {
jid = JidCreate.from(from);
}
catch (XmppStringprepException e) {
throw new IllegalArgumentException(e);
}
setFrom(jid);
}
/**
* Sets who the packet is being sent "from". The XMPP protocol often
* makes the "from" attribute optional, so it does not always need to
@ -263,17 +201,6 @@ public abstract class Stanza implements TopLevelStreamElement {
return error;
}
/**
* Sets the error for this packet.
*
* @param error the error to associate with this packet.
* @deprecated use {@link #setError(org.jivesoftware.smack.packet.StanzaError.Builder)} instead.
*/
@Deprecated
public void setError(StanzaError error) {
this.error = error;
}
/**
* Sets the error for this stanza.
*

View File

@ -40,6 +40,10 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* RTPBridge IQ Stanza used to request and retrieve a RTPBridge Candidates that can be used for a Jingle Media Transmission between two parties that are behind NAT.
* This Jingle Bridge has all the needed information to establish a full UDP Channel (Send and Receive) between two parties.
@ -397,7 +401,6 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("deprecation")
public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
@ -405,7 +408,13 @@ public class RTPBridge extends IQ {
}
RTPBridge rtpPacket = new RTPBridge(sessionID);
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
DomainBareJid jid;
try {
jid = JidCreate.domainBareFrom(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
} catch (XmppStringprepException e) {
throw new AssertionError(e);
}
rtpPacket.setTo(jid);
StanzaCollector collector = connection.createStanzaCollectorAndSend(rtpPacket);
@ -469,7 +478,6 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("deprecation")
public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
@ -477,7 +485,13 @@ public class RTPBridge extends IQ {
}
RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change);
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
DomainBareJid jid;
try {
jid = JidCreate.domainBareFrom(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
} catch (XmppStringprepException e) {
throw new AssertionError(e);
}
rtpPacket.setTo(jid);
rtpPacket.setType(Type.set);
rtpPacket.setPass(pass);
@ -506,7 +520,6 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("deprecation")
public static String getPublicIP(XMPPConnection xmppConnection) throws NotConnectedException, InterruptedException {
if (!xmppConnection.isConnected()) {
@ -514,7 +527,13 @@ public class RTPBridge extends IQ {
}
RTPBridge rtpPacket = new RTPBridge(RTPBridge.BridgeAction.publicip);
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getXMPPServiceDomain());
DomainBareJid jid;
try {
jid = JidCreate.domainBareFrom(RTPBridge.NAME + "." + xmppConnection.getXMPPServiceDomain());
} catch (XmppStringprepException e) {
throw new AssertionError(e);
}
rtpPacket.setTo(jid);
rtpPacket.setType(Type.set);
// LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort());

View File

@ -37,6 +37,10 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* STUN IQ Stanza used to request and retrieve a STUN server and port to make p2p connections easier. STUN is usually used by Jingle Media Transmission between two parties that are behind NAT.
*
@ -177,7 +181,6 @@ public class STUN extends SimpleIQ {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("deprecation")
public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
@ -185,7 +188,13 @@ public class STUN extends SimpleIQ {
}
STUN stunPacket = new STUN();
stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain());
DomainBareJid jid;
try {
jid = JidCreate.domainBareFrom(DOMAIN + "." + connection.getXMPPServiceDomain());
} catch (XmppStringprepException e) {
throw new AssertionError(e);
}
stunPacket.setTo(jid);
StanzaCollector collector = connection.createStanzaCollectorAndSend(stunPacket);