mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Rename IQ.ELEMENT to IQ.IQ_ELEMENT
to avoid confusion between the IQ element 'iq' and the IQs child element. ELEMENT defined in an IQ sublcass should contain the *child* element. Add element to StreamInitation and fix FileTransferManager which still used a packet listener instead of an IQ request handler to handle incoming stream initiation requests.
This commit is contained in:
parent
f1a1215f35
commit
b0cecee710
6 changed files with 19 additions and 15 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue