diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java index c4916d5fc..d938c49e4 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java @@ -543,7 +543,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection { String name = parser.getName(); switch (name) { case Message.ELEMENT: - case IQ.ELEMENT: + case IQ.IQ_ELEMENT: case Presence.ELEMENT: parseAndProcessStanza(parser); break; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java index 40529275a..3d3248ec5 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java @@ -40,7 +40,8 @@ import org.jivesoftware.smack.util.XmlStringBuilder; */ public abstract class IQ extends Packet { - public static final String ELEMENT = "iq"; + // Don't name this field 'ELEMENT'. When it comes to IQ, ELEMENT is the child element! + public static final String IQ_ELEMENT = "iq"; public static final String QUERY_ELEMENT = "query"; private final String childElementName; @@ -98,7 +99,7 @@ public abstract class IQ extends Packet { @Override public final XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); - buf.halfOpenElement(ELEMENT); + buf.halfOpenElement(IQ_ELEMENT); addCommonAttributes(buf); if (type == null) { buf.attribute("type", "get"); @@ -108,7 +109,7 @@ public abstract class IQ extends Packet { } buf.rightAngleBracket(); buf.append(getChildElementXML()); - buf.closeElement(ELEMENT); + buf.closeElement(IQ_ELEMENT); return buf; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index e9fd5fb21..fb8cc3457 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -149,7 +149,7 @@ public class PacketParserUtils { switch (name) { case Message.ELEMENT: return parseMessage(parser); - case IQ.ELEMENT: + case IQ.IQ_ELEMENT: return parseIQ(parser); case Presence.ELEMENT: return parsePresence(parser); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/packet/Bytestream.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/packet/Bytestream.java index 2b29ef024..8f76afc71 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/packet/Bytestream.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/packet/Bytestream.java @@ -30,6 +30,9 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * @author Alexander Wenckus */ public class Bytestream extends IQ { + + public static final String ELEMENT = QUERY_ELEMENT; + /** * The XMPP namespace of the SOCKS5 Bytestream */ @@ -49,7 +52,7 @@ public class Bytestream extends IQ { * The default constructor */ public Bytestream() { - super(QUERY_ELEMENT, NAMESPACE); + super(ELEMENT, NAMESPACE); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java index b0775b58b..47d80dc5a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java @@ -17,14 +17,11 @@ package org.jivesoftware.smackx.filetransfer; import org.jivesoftware.smack.Manager; -import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.filter.AndFilter; -import org.jivesoftware.smack.filter.IQTypeFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; +import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smackx.si.packet.StreamInitiation; import org.jxmpp.util.XmppStringUtils; @@ -73,15 +70,18 @@ public class FileTransferManager extends Manager { super(connection); this.fileTransferNegotiator = FileTransferNegotiator .getInstanceFor(connection); - connection.addAsyncPacketListener(new PacketListener() { - public void processPacket(Packet packet) { + connection.registerIQRequestHandler(new AbstractIqRequestHandler(StreamInitiation.ELEMENT, + StreamInitiation.NAMESPACE, IQ.Type.set, Mode.async) { + @Override + public IQ handleIQRequest(IQ packet) { StreamInitiation si = (StreamInitiation) packet; final FileTransferRequest request = new FileTransferRequest(FileTransferManager.this, si); for (final FileTransferListener listener : listeners) { listener.fileTransferRequest(request); } + return null; } - }, new AndFilter(new PacketTypeFilter(StreamInitiation.class), IQTypeFilter.SET)); + }); } /** diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 03f035fbf..a68e7e108 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -948,7 +948,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { final String name = parser.getName(); switch (name) { case Message.ELEMENT: - case IQ.ELEMENT: + case IQ.IQ_ELEMENT: case Presence.ELEMENT: try { parseAndProcessStanza(parser);