1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-06 05:01:12 +01:00

Change IQ.Type to enum

This commit is contained in:
Júlio Cesar Bueno Cotta 2014-06-05 21:20:45 -03:00
parent 944ac37fc3
commit 9be0c480e3
90 changed files with 284 additions and 299 deletions

View file

@ -143,7 +143,7 @@ public class JingleManagerTest extends SmackTestCase {
if (pin instanceof IQ) {
System.out.println("packet: " + pin.toXML());
IQ iq = (IQ) pin;
if (iq.getType().equals(IQ.Type.SET)) {
if (iq.getType().equals(IQ.Type.set)) {
System.out.println("packet");
if (iq instanceof Jingle) {
Jingle jin = (Jingle) pin;
@ -172,7 +172,7 @@ public class JingleManagerTest extends SmackTestCase {
iqSent.setTo(getFullJID(0));
iqSent.setFrom(getFullJID(0));
iqSent.setType(IQ.Type.SET);
iqSent.setType(IQ.Type.set);
System.out.println("Sending packet and waiting... ");
getConnection(1).sendPacket(iqSent);

View file

@ -66,7 +66,7 @@ public class JingleProviderTest extends SmackTestCase {
iqSent.setTo(getFullJID(0));
iqSent.setFrom(getFullJID(0));
iqSent.setType(IQ.Type.GET);
iqSent.setType(IQ.Type.get);
// Create a filter and a collector...
PacketFilter filter = new PacketTypeFilter(IQ.class);
@ -86,7 +86,7 @@ public class JingleProviderTest extends SmackTestCase {
if (iqReceived == null) {
fail("No response from server");
}
else if (iqReceived.getType() == IQ.Type.ERROR) {
else if (iqReceived.getType() == IQ.Type.error) {
fail("The server did reply with an error packet: " + iqReceived.getError().getCode());
}
else {

View file

@ -65,10 +65,10 @@ public class ContentNegotiator extends JingleNegotiator {
// match this media manager.
if (iq != null) {
if (iq.getType().equals(IQ.Type.ERROR)) {
if (iq.getType().equals(IQ.Type.error)) {
// Process errors
// TODO getState().eventError(iq);
} else if (iq.getType().equals(IQ.Type.RESULT)) {
} else if (iq.getType().equals(IQ.Type.result)) {
// Process ACKs
if (isExpectedId(iq.getPacketID())) {
removeExpectedId(iq.getPacketID());

View file

@ -445,7 +445,7 @@ public class JingleManager implements JingleSessionListener {
public boolean accept(Packet pin) {
if (pin instanceof IQ) {
IQ iq = (IQ) pin;
if (iq.getType().equals(IQ.Type.SET)) {
if (iq.getType().equals(IQ.Type.set)) {
if (iq instanceof Jingle) {
Jingle jin = (Jingle) pin;
if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {

View file

@ -325,7 +325,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
}
// // If the response is anything other than a RESULT then send it now.
// if ((response != null) && (!response.getType().equals(IQ.Type.RESULT))) {
// if ((response != null) && (!response.getType().equals(IQ.Type.result))) {
// getConnection().sendPacket(response);
// }
@ -351,10 +351,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
IQ response = null;
if (iq != null) {
if (iq.getType().equals(IQ.Type.ERROR)) {
if (iq.getType().equals(IQ.Type.error)) {
// Process errors
// TODO getState().eventError(iq);
} else if (iq.getType().equals(IQ.Type.RESULT)) {
} else if (iq.getType().equals(IQ.Type.result)) {
// Process ACKs
if (isExpectedId(iq.getPacketID())) {
@ -504,8 +504,8 @@ 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);
if (iq.getType().equals(IQ.Type.set)) {
IQ ack = createIQ(iq.getPacketID(), iq.getFrom(), iq.getTo(), IQ.Type.result);
// No! Don't send it. Let it flow to the normal way IQ results get processed and sent.
// getConnection().sendPacket(ack);
@ -715,10 +715,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
}
} else {
// We accept some non-Jingle IQ packets: ERRORs and ACKs
if (iq.getType().equals(IQ.Type.SET)) {
if (iq.getType().equals(IQ.Type.set)) {
LOGGER.fine("Ignored Jingle(TYPE): " + iq.toXML());
return false;
} else if (iq.getType().equals(IQ.Type.GET)) {
} else if (iq.getType().equals(IQ.Type.get)) {
LOGGER.fine("Ignored Jingle(TYPE): " + iq.toXML());
return false;
}
@ -979,7 +979,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
return;
LOGGER.fine("Terminate " + reason);
Jingle jout = new Jingle(JingleActionEnum.SESSION_TERMINATE);
jout.setType(IQ.Type.SET);
jout.setType(IQ.Type.set);
sendPacket(jout);
triggerSessionClosed(reason);
}
@ -1062,7 +1062,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
*/
public static IQ createError(String ID, String to, String from, int errCode, XMPPError error) {
IQ iqError = createIQ(ID, to, from, IQ.Type.ERROR);
IQ iqError = createIQ(ID, to, from, IQ.Type.error);
iqError.setError(error);
LOGGER.fine("Created Error Packet:" + iqError.toXML());
@ -1083,7 +1083,7 @@ 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);
errorPacket = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.error);
List<PacketExtension> extList = new ArrayList<PacketExtension>();
extList.add(jingleError);

View file

@ -108,13 +108,13 @@ public class MediaNegotiator extends JingleNegotiator {
List<IQ> responses = new ArrayList<IQ>();
IQ response = null;
if (iq.getType().equals(IQ.Type.ERROR)) {
if (iq.getType().equals(IQ.Type.error)) {
// Process errors
setNegotiatorState(JingleNegotiatorState.FAILED);
triggerMediaClosed(getBestCommonAudioPt());
// This next line seems wrong, and may subvert the normal closing process.
throw new JingleException(iq.getError().getMessage());
} else if (iq.getType().equals(IQ.Type.RESULT)) {
} else if (iq.getType().equals(IQ.Type.result)) {
// Process ACKs
if (isExpectedId(iq.getPacketID())) {
receiveResult(iq);

View file

@ -458,7 +458,7 @@ public class RTPBridge extends IQ {
RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change);
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
rtpPacket.setType(Type.SET);
rtpPacket.setType(Type.set);
rtpPacket.setPass(pass);
rtpPacket.setPortA(localCandidate.getPort());
@ -493,7 +493,7 @@ public class RTPBridge extends IQ {
RTPBridge rtpPacket = new RTPBridge(RTPBridge.BridgeAction.publicip);
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
rtpPacket.setType(Type.SET);
rtpPacket.setType(Type.set);
// LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort());

View file

@ -598,13 +598,13 @@ public abstract class TransportNegotiator extends JingleNegotiator {
IQ response = null;
if (iq != null) {
if (iq.getType().equals(IQ.Type.ERROR)) {
if (iq.getType().equals(IQ.Type.error)) {
// Process errors
setNegotiatorState(JingleNegotiatorState.FAILED);
triggerTransportClosed(null);
// This next line seems wrong, and may subvert the normal closing process.
throw new JingleException(iq.getError().getMessage());
} else if (iq.getType().equals(IQ.Type.RESULT)) {
} else if (iq.getType().equals(IQ.Type.result)) {
// Process ACKs
if (isExpectedId(iq.getPacketID())) {
response = receiveResult(iq);

View file

@ -97,7 +97,7 @@ public class Jingle extends IQ {
// Some default values for the most common situation...
action = JingleActionEnum.UNKNOWN;
this.setType(IQ.Type.SET);
this.setType(IQ.Type.set);
}
/**
@ -116,7 +116,7 @@ public class Jingle extends IQ {
// Some default values for the most common situation...
action = JingleActionEnum.UNKNOWN;
this.setType(IQ.Type.SET);
this.setType(IQ.Type.set);
}
/**
@ -129,7 +129,7 @@ public class Jingle extends IQ {
this.action = action;
// In general, a Jingle with an action is used in a SET packet...
this.setType(IQ.Type.SET);
this.setType(IQ.Type.set);
}
/**