mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-20 09:37:58 +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) {
|
||||
Bytestream bytestream = new Bytestream();
|
||||
bytestream.getPacketID();
|
||||
bytestream.setFrom(from);
|
||||
bytestream.setTo(to);
|
||||
bytestream.setSessionID(sessionID);
|
||||
|
@ -57,7 +56,6 @@ public class Socks5PacketUtils {
|
|||
*/
|
||||
public static Bytestream createBytestreamResponse(String from, String to) {
|
||||
Bytestream streamHostInfo = new Bytestream();
|
||||
streamHostInfo.getPacketID();
|
||||
streamHostInfo.setFrom(from);
|
||||
streamHostInfo.setTo(to);
|
||||
streamHostInfo.setType(IQ.Type.result);
|
||||
|
@ -73,7 +71,6 @@ public class Socks5PacketUtils {
|
|||
*/
|
||||
public static DiscoverItems createDiscoverItems(String from, String to) {
|
||||
DiscoverItems discoverItems = new DiscoverItems();
|
||||
discoverItems.getPacketID();
|
||||
discoverItems.setFrom(from);
|
||||
discoverItems.setTo(to);
|
||||
discoverItems.setType(IQ.Type.result);
|
||||
|
@ -89,7 +86,6 @@ public class Socks5PacketUtils {
|
|||
*/
|
||||
public static DiscoverInfo createDiscoverInfo(String from, String to) {
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
discoverInfo.getPacketID();
|
||||
discoverInfo.setFrom(from);
|
||||
discoverInfo.setTo(to);
|
||||
discoverInfo.setType(IQ.Type.result);
|
||||
|
@ -112,7 +108,6 @@ public class Socks5PacketUtils {
|
|||
}
|
||||
|
||||
};
|
||||
response.getPacketID();
|
||||
response.setFrom(from);
|
||||
response.setTo(to);
|
||||
response.setType(IQ.Type.result);
|
||||
|
|
|
@ -505,7 +505,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
if (iq != null) {
|
||||
// Don't acknowledge ACKs, errors...
|
||||
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.
|
||||
// getConnection().sendPacket(ack);
|
||||
|
@ -1017,59 +1017,6 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
// 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
|
||||
* 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) {
|
||||
IQ errorPacket = null;
|
||||
if (jingleError != null) {
|
||||
errorPacket = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.error);
|
||||
|
||||
List<PacketExtension> extList = new ArrayList<PacketExtension>();
|
||||
extList.add(jingleError);
|
||||
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
|
||||
errorPacket.setPacketID(iq.getPacketID());
|
||||
errorPacket.setError(error);
|
||||
|
|
|
@ -667,14 +667,7 @@ public class AgentSession {
|
|||
private void handlePacket(Packet packet) throws NotConnectedException {
|
||||
if (packet instanceof OfferRequestProvider.OfferRequestPacket) {
|
||||
// Acknowledge the IQ set.
|
||||
IQ reply = new IQ() {
|
||||
public String getChildElementXML() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
reply.setPacketID(packet.getPacketID());
|
||||
reply.setTo(packet.getFrom());
|
||||
reply.setType(IQ.Type.result);
|
||||
IQ reply = IQ.createResultIQ((IQ) packet);
|
||||
connection.sendPacket(reply);
|
||||
|
||||
fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet);
|
||||
|
|
Loading…
Reference in a new issue