mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Add (partial) support for IoT XEPs
That is XEP-0323, -0324, -0325, and -0347. SMACK-727.
This commit is contained in:
parent
d1fe5c2933
commit
b91978dcc4
110 changed files with 5395 additions and 40 deletions
|
@ -238,7 +238,11 @@ public final class ReconnectionManager {
|
|||
// Makes a reconnection attempt
|
||||
try {
|
||||
if (isReconnectionPossible(connection)) {
|
||||
connection.connect();
|
||||
try {
|
||||
connection.connect();
|
||||
} catch (SmackException.AlreadyConnectedException e) {
|
||||
LOGGER.log(Level.FINER, "Connection was already connected on reconnection attempt", e);
|
||||
}
|
||||
}
|
||||
// TODO Starting with Smack 4.2, connect() will no
|
||||
// longer login automatically. So change this and the
|
||||
|
|
|
@ -25,13 +25,7 @@ public class EmptyResultIQ extends IQ {
|
|||
|
||||
public EmptyResultIQ(IQ request) {
|
||||
this();
|
||||
if (!(request.getType() == Type.get || request.getType() == Type.set)) {
|
||||
throw new IllegalArgumentException(
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
|
||||
}
|
||||
setStanzaId(request.getStanzaId());
|
||||
setFrom(request.getTo());
|
||||
setTo(request.getFrom());
|
||||
initialzeAsResultFor(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -215,6 +215,17 @@ public abstract class IQ extends Stanza {
|
|||
*/
|
||||
protected abstract IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml);
|
||||
|
||||
protected final void initialzeAsResultFor(IQ request) {
|
||||
if (!(request.getType() == Type.get || request.getType() == Type.set)) {
|
||||
throw new IllegalArgumentException(
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
|
||||
}
|
||||
setStanzaId(request.getStanzaId());
|
||||
setFrom(request.getTo());
|
||||
setTo(request.getFrom());
|
||||
setType(Type.result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to create a new empty {@link Type#result IQ.Type.result}
|
||||
* IQ based on a {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set}
|
||||
|
@ -289,9 +300,7 @@ public abstract class IQ extends Stanza {
|
|||
* @throws IllegalArgumentException if the IQ stanza(/packet) does not have a type of
|
||||
* {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set}.
|
||||
* @return a new {@link Type#error IQ.Type.error} IQ based on the originating IQ.
|
||||
* @deprecated use {@link #createErrorResponse(IQ, org.jivesoftware.smack.packet.XMPPError.Builder)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final XMPPError error) {
|
||||
return createErrorResponse(request, XMPPError.getBuilder(error));
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
* @param type the type.
|
||||
*/
|
||||
public Presence(Type type) {
|
||||
// Ensure that the stanza ID is set by calling super().
|
||||
super();
|
||||
setType(type);
|
||||
}
|
||||
|
||||
|
@ -85,6 +87,8 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
* @param mode the mode type for this presence update.
|
||||
*/
|
||||
public Presence(Type type, String status, int priority, Mode mode) {
|
||||
// Ensure that the stanza ID is set by calling super().
|
||||
super();
|
||||
setType(type);
|
||||
setStatus(status);
|
||||
setPriority(priority);
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.text.ParseException;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
@ -122,6 +123,14 @@ public class ParserUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage) throws SmackException {
|
||||
Integer res = getIntegerAttribute(parser, name);
|
||||
if (res == null) {
|
||||
throw new SmackException(throwMessage);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static Integer getIntegerAttribute(XmlPullParser parser, String name) {
|
||||
String valueString = parser.getAttributeValue("", name);
|
||||
if (valueString == null)
|
||||
|
|
|
@ -238,6 +238,10 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
|||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder attribute(String name, boolean bool) {
|
||||
return attribute(name, Boolean.toString(bool));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new attribute to this builder, with the {@link java.util.Date} instance as its value,
|
||||
* which will get formated with {@link XmppDateTime#formatXEP0082Date(Date)}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue