mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Remove some duplicate IQ code
and some dead code in Socks5PacketUtils.
This commit is contained in:
parent
afd1f6bc36
commit
f05b208120
3 changed files with 4 additions and 69 deletions
|
@ -39,7 +39,6 @@ public class Socks5PacketUtils {
|
||||||
*/
|
*/
|
||||||
public static Bytestream createBytestreamInitiation(String from, String to, String sessionID) {
|
public static Bytestream createBytestreamInitiation(String from, String to, String sessionID) {
|
||||||
Bytestream bytestream = new Bytestream();
|
Bytestream bytestream = new Bytestream();
|
||||||
bytestream.getPacketID();
|
|
||||||
bytestream.setFrom(from);
|
bytestream.setFrom(from);
|
||||||
bytestream.setTo(to);
|
bytestream.setTo(to);
|
||||||
bytestream.setSessionID(sessionID);
|
bytestream.setSessionID(sessionID);
|
||||||
|
@ -57,7 +56,6 @@ public class Socks5PacketUtils {
|
||||||
*/
|
*/
|
||||||
public static Bytestream createBytestreamResponse(String from, String to) {
|
public static Bytestream createBytestreamResponse(String from, String to) {
|
||||||
Bytestream streamHostInfo = new Bytestream();
|
Bytestream streamHostInfo = new Bytestream();
|
||||||
streamHostInfo.getPacketID();
|
|
||||||
streamHostInfo.setFrom(from);
|
streamHostInfo.setFrom(from);
|
||||||
streamHostInfo.setTo(to);
|
streamHostInfo.setTo(to);
|
||||||
streamHostInfo.setType(IQ.Type.result);
|
streamHostInfo.setType(IQ.Type.result);
|
||||||
|
@ -73,7 +71,6 @@ public class Socks5PacketUtils {
|
||||||
*/
|
*/
|
||||||
public static DiscoverItems createDiscoverItems(String from, String to) {
|
public static DiscoverItems createDiscoverItems(String from, String to) {
|
||||||
DiscoverItems discoverItems = new DiscoverItems();
|
DiscoverItems discoverItems = new DiscoverItems();
|
||||||
discoverItems.getPacketID();
|
|
||||||
discoverItems.setFrom(from);
|
discoverItems.setFrom(from);
|
||||||
discoverItems.setTo(to);
|
discoverItems.setTo(to);
|
||||||
discoverItems.setType(IQ.Type.result);
|
discoverItems.setType(IQ.Type.result);
|
||||||
|
@ -89,7 +86,6 @@ public class Socks5PacketUtils {
|
||||||
*/
|
*/
|
||||||
public static DiscoverInfo createDiscoverInfo(String from, String to) {
|
public static DiscoverInfo createDiscoverInfo(String from, String to) {
|
||||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||||
discoverInfo.getPacketID();
|
|
||||||
discoverInfo.setFrom(from);
|
discoverInfo.setFrom(from);
|
||||||
discoverInfo.setTo(to);
|
discoverInfo.setTo(to);
|
||||||
discoverInfo.setType(IQ.Type.result);
|
discoverInfo.setType(IQ.Type.result);
|
||||||
|
@ -112,7 +108,6 @@ public class Socks5PacketUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
response.getPacketID();
|
|
||||||
response.setFrom(from);
|
response.setFrom(from);
|
||||||
response.setTo(to);
|
response.setTo(to);
|
||||||
response.setType(IQ.Type.result);
|
response.setType(IQ.Type.result);
|
||||||
|
|
|
@ -505,7 +505,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
||||||
if (iq != null) {
|
if (iq != null) {
|
||||||
// Don't acknowledge ACKs, errors...
|
// Don't acknowledge ACKs, errors...
|
||||||
if (iq.getType().equals(IQ.Type.set)) {
|
if (iq.getType().equals(IQ.Type.set)) {
|
||||||
IQ ack = createIQ(iq.getPacketID(), iq.getFrom(), iq.getTo(), IQ.Type.result);
|
IQ ack = IQ.createResultIQ(iq);
|
||||||
|
|
||||||
// No! Don't send it. Let it flow to the normal way IQ results get processed and sent.
|
// No! Don't send it. Let it flow to the normal way IQ results get processed and sent.
|
||||||
// getConnection().sendPacket(ack);
|
// getConnection().sendPacket(ack);
|
||||||
|
@ -1017,59 +1017,6 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
||||||
|
|
||||||
// Packet and error creation
|
// Packet and error creation
|
||||||
|
|
||||||
/**
|
|
||||||
* A convience method to create an IQ packet.
|
|
||||||
*
|
|
||||||
* @param ID
|
|
||||||
* The packet ID of the
|
|
||||||
* @param to
|
|
||||||
* To whom the packet is addressed.
|
|
||||||
* @param from
|
|
||||||
* From whom the packet is sent.
|
|
||||||
* @param type
|
|
||||||
* The iq type of the packet.
|
|
||||||
* @return The created IQ packet.
|
|
||||||
*/
|
|
||||||
public static IQ createIQ(String ID, String to, String from, IQ.Type type) {
|
|
||||||
IQ iqPacket = new IQ() {
|
|
||||||
public String getChildElementXML() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
iqPacket.setPacketID(ID);
|
|
||||||
iqPacket.setTo(to);
|
|
||||||
iqPacket.setFrom(from);
|
|
||||||
iqPacket.setType(type);
|
|
||||||
|
|
||||||
return iqPacket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A convience method to create an error packet.
|
|
||||||
*
|
|
||||||
* @param ID
|
|
||||||
* The packet ID of the
|
|
||||||
* @param to
|
|
||||||
* To whom the packet is addressed.
|
|
||||||
* @param from
|
|
||||||
* From whom the packet is sent.
|
|
||||||
* @param errCode
|
|
||||||
* The error code.
|
|
||||||
* @param error
|
|
||||||
* The XMPPError string.
|
|
||||||
* @return The created IQ packet.
|
|
||||||
*/
|
|
||||||
public static IQ createError(String ID, String to, String from, int errCode, XMPPError error) {
|
|
||||||
|
|
||||||
IQ iqError = createIQ(ID, to, from, IQ.Type.error);
|
|
||||||
iqError.setError(error);
|
|
||||||
|
|
||||||
LOGGER.fine("Created Error Packet:" + iqError.toXML());
|
|
||||||
|
|
||||||
return iqError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete and send an error. Complete all the null fields in an IQ error
|
* Complete and send an error. Complete all the null fields in an IQ error
|
||||||
* reponse, using the sesssion information we have or some info from the
|
* reponse, using the sesssion information we have or some info from the
|
||||||
|
@ -1083,12 +1030,12 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
||||||
public IQ createJingleError(IQ iq, JingleError jingleError) {
|
public IQ createJingleError(IQ iq, JingleError jingleError) {
|
||||||
IQ errorPacket = null;
|
IQ errorPacket = null;
|
||||||
if (jingleError != null) {
|
if (jingleError != null) {
|
||||||
errorPacket = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.error);
|
|
||||||
|
|
||||||
List<PacketExtension> extList = new ArrayList<PacketExtension>();
|
List<PacketExtension> extList = new ArrayList<PacketExtension>();
|
||||||
extList.add(jingleError);
|
extList.add(jingleError);
|
||||||
XMPPError error = new XMPPError(XMPPError.Type.CANCEL, jingleError.toString(), "", extList);
|
XMPPError error = new XMPPError(XMPPError.Type.CANCEL, jingleError.toString(), "", extList);
|
||||||
|
|
||||||
|
errorPacket = IQ.createErrorResponse(iq, error);
|
||||||
|
|
||||||
// Fill in the fields with the info from the Jingle packet
|
// Fill in the fields with the info from the Jingle packet
|
||||||
errorPacket.setPacketID(iq.getPacketID());
|
errorPacket.setPacketID(iq.getPacketID());
|
||||||
errorPacket.setError(error);
|
errorPacket.setError(error);
|
||||||
|
|
|
@ -667,14 +667,7 @@ public class AgentSession {
|
||||||
private void handlePacket(Packet packet) throws NotConnectedException {
|
private void handlePacket(Packet packet) throws NotConnectedException {
|
||||||
if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
|
if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
|
||||||
// Acknowledge the IQ set.
|
// Acknowledge the IQ set.
|
||||||
IQ reply = new IQ() {
|
IQ reply = IQ.createResultIQ((IQ) packet);
|
||||||
public String getChildElementXML() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reply.setPacketID(packet.getPacketID());
|
|
||||||
reply.setTo(packet.getFrom());
|
|
||||||
reply.setType(IQ.Type.result);
|
|
||||||
connection.sendPacket(reply);
|
connection.sendPacket(reply);
|
||||||
|
|
||||||
fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet);
|
fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet);
|
||||||
|
|
Loading…
Reference in a new issue