mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 09:39:39 +02:00
Merge branch '4.4'
This commit is contained in:
commit
ad9867ebdf
9 changed files with 208 additions and 64 deletions
|
@ -170,16 +170,20 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
|
|||
return exception;
|
||||
}
|
||||
|
||||
private boolean callbacksInvoked;
|
||||
|
||||
protected final synchronized void maybeInvokeCallbacks() {
|
||||
if (cancelled) {
|
||||
if (cancelled || callbacksInvoked) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((result != null || exception != null) && completionCallback != null) {
|
||||
callbacksInvoked = true;
|
||||
completionCallback.accept(this);
|
||||
}
|
||||
|
||||
if (result != null && successCallback != null) {
|
||||
callbacksInvoked = true;
|
||||
AbstractXMPPConnection.asyncGo(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -188,6 +192,7 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
|
|||
});
|
||||
}
|
||||
else if (exception != null && exceptionCallback != null) {
|
||||
callbacksInvoked = true;
|
||||
AbstractXMPPConnection.asyncGo(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ExceptionThrowingCallbackWithHint extends ExceptionThrowingCallback
|
|||
|
||||
@Override
|
||||
public void handleUnparsableStanza(UnparseableStanza packetData) throws IOException {
|
||||
LOGGER.warning("Parsing exception encountered."
|
||||
LOGGER.warning("Parsing exception \"" + packetData.getParsingException().getMessage() + "\" encountered."
|
||||
+ " This exception will be re-thrown, leading to a disconnect."
|
||||
+ " You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback()."
|
||||
+ " More information an be found in AbstractXMPPConnection's javadoc.");
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* <b>Deprecation Notice:</b> This class is deprecated, use {@link IQProvider} instead.
|
||||
* <b>Deprecation Notice:</b> This class is deprecated, use {@link IqProvider} instead.
|
||||
* </p>
|
||||
* An abstract class for parsing custom IQ packets. Each IQProvider must be registered with
|
||||
* the ProviderManager class for it to be used. Every implementation of this
|
||||
|
|
|
@ -501,6 +501,23 @@ public class PacketParserUtils {
|
|||
return parseIQ(parser, null);
|
||||
}
|
||||
|
||||
public static IqData parseIqData(XmlPullParser parser) throws XmppStringprepException {
|
||||
final String id = parser.getAttributeValue("", "id");
|
||||
IqData iqData = StanzaBuilder.buildIqData(id);
|
||||
|
||||
final Jid to = ParserUtils.getJidAttribute(parser, "to");
|
||||
iqData.to(to);
|
||||
|
||||
final Jid from = ParserUtils.getJidAttribute(parser, "from");
|
||||
iqData.from(from);
|
||||
|
||||
String typeString = parser.getAttributeValue("", "type");
|
||||
final IQ.Type type = IQ.Type.fromString(typeString);
|
||||
iqData.ofType(type);
|
||||
|
||||
return iqData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an IQ packet.
|
||||
*
|
||||
|
@ -518,18 +535,7 @@ public class PacketParserUtils {
|
|||
XmlEnvironment iqXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||
IQ iqPacket = null;
|
||||
StanzaError error = null;
|
||||
|
||||
final String id = parser.getAttributeValue("", "id");
|
||||
IqData iqData = StanzaBuilder.buildIqData(id);
|
||||
|
||||
final Jid to = ParserUtils.getJidAttribute(parser, "to");
|
||||
iqData.to(to);
|
||||
|
||||
final Jid from = ParserUtils.getJidAttribute(parser, "from");
|
||||
iqData.from(from);
|
||||
|
||||
final IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type"));
|
||||
iqData.ofType(type);
|
||||
IqData iqData = parseIqData(parser);
|
||||
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
|
@ -571,7 +577,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
// Decide what to do when an IQ packet was not understood
|
||||
if (iqPacket == null) {
|
||||
switch (type) {
|
||||
switch (iqData.getType()) {
|
||||
case error:
|
||||
// If an IQ packet wasn't created above, create an empty error IQ packet.
|
||||
iqPacket = new ErrorIQ(error);
|
||||
|
@ -585,10 +591,10 @@ public class PacketParserUtils {
|
|||
}
|
||||
|
||||
// Set basic values on the iq packet.
|
||||
iqPacket.setStanzaId(id);
|
||||
iqPacket.setTo(to);
|
||||
iqPacket.setFrom(from);
|
||||
iqPacket.setType(type);
|
||||
iqPacket.setStanzaId(iqData.getStanzaId());
|
||||
iqPacket.setTo(iqData.getTo());
|
||||
iqPacket.setFrom(iqData.getFrom());
|
||||
iqPacket.setType(iqData.getType());
|
||||
iqPacket.setError(error);
|
||||
|
||||
return iqPacket;
|
||||
|
|
|
@ -288,8 +288,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
public XmlStringBuilder attribute(String name, Enum<?> value) {
|
||||
assert value != null;
|
||||
// TODO: Should use toString() instead of name().
|
||||
attribute(name, value.name());
|
||||
attribute(name, value.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue