1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 03:52:06 +01:00

Merge branch '4.4'

This commit is contained in:
Florian Schmaus 2021-04-18 17:25:14 +02:00
commit 5493a22e44
11 changed files with 70 additions and 30 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software, 2015-2016 Florian Schmaus. * Copyright 2003-2007 Jive Software, 2015-2021 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,8 @@
package org.jivesoftware.smack.packet; package org.jivesoftware.smack.packet;
import javax.xml.namespace.QName;
import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.parts.Resourcepart; import org.jxmpp.jid.parts.Resourcepart;
@ -73,6 +75,7 @@ public final class Bind extends IQ {
public static final class Feature implements ExtensionElement { public static final class Feature implements ExtensionElement {
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public static final Feature INSTANCE = new Feature(); public static final Feature INSTANCE = new Feature();
private Feature() { private Feature() {

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software, 2015-2019 Florian Schmaus * Copyright 2003-2007 Jive Software, 2015-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,6 +22,8 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
@ -74,6 +76,8 @@ public class StanzaError extends AbstractError implements ExtensionElement {
public static final String ERROR = "error"; public static final String ERROR = "error";
public static final QName QNAME = new QName(StreamOpen.CLIENT_NAMESPACE, ERROR);
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName()); private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
static final Map<Condition, Type> CONDITION_TO_TYPE = new HashMap<Condition, Type>(); static final Map<Condition, Type> CONDITION_TO_TYPE = new HashMap<Condition, Type>();
@ -199,12 +203,12 @@ public class StanzaError extends AbstractError implements ExtensionElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ERROR; return QNAME.getLocalPart();
} }
@Override @Override
public String getNamespace() { public String getNamespace() {
return StreamOpen.CLIENT_NAMESPACE; return QNAME.getNamespaceURI();
} }
@Override @Override

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2017 Paul Schaub * Copyright © 2017 Paul Schaub, 2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.hashes.element;
import static org.jivesoftware.smack.util.Objects.requireNonNull; import static org.jivesoftware.smack.util.Objects.requireNonNull;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smack.util.stringencoder.Base64;
@ -34,6 +36,8 @@ public class HashElement implements ExtensionElement {
public static final String ELEMENT = "hash"; public static final String ELEMENT = "hash";
public static final String ATTR_ALGO = "algo"; public static final String ATTR_ALGO = "algo";
public static final QName QNAME = new QName(HashManager.NAMESPACE.V2.toString(), ELEMENT);
private final HashManager.ALGORITHM algorithm; private final HashManager.ALGORITHM algorithm;
private final byte[] hash; private final byte[] hash;
private final String hashB64; private final String hashB64;
@ -89,7 +93,12 @@ public class HashElement implements ExtensionElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT; return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return QNAME.getNamespaceURI();
} }
@Override @Override
@ -102,11 +111,6 @@ public class HashElement implements ExtensionElement {
return sb; return sb;
} }
@Override
public String getNamespace() {
return HashManager.NAMESPACE.V2.toString();
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null || !(other instanceof HashElement)) { if (other == null || !(other instanceof HashElement)) {

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2014 Andriy Tsykholyas, 2015 Florian Schmaus * Copyright 2014 Andriy Tsykholyas, 2015-2021 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.hoxt.packet; package org.jivesoftware.smackx.hoxt.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
@ -36,6 +38,8 @@ public class Base64BinaryChunk implements ExtensionElement {
public static final String ATTRIBUTE_LAST = "last"; public static final String ATTRIBUTE_LAST = "last";
public static final String ATTRIBUTE_NR = "nr"; public static final String ATTRIBUTE_NR = "nr";
public static final QName QNAME = new QName(HOXTManager.NAMESPACE, ELEMENT_CHUNK);
private final String streamId; private final String streamId;
private final boolean last; private final boolean last;
private final String text; private final String text;
@ -108,12 +112,12 @@ public class Base64BinaryChunk implements ExtensionElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT_CHUNK; return QNAME.getLocalPart();
} }
@Override @Override
public String getNamespace() { public String getNamespace() {
return HOXTManager.NAMESPACE; return QNAME.getNamespaceURI();
} }
@Override @Override

View file

@ -16,9 +16,12 @@
*/ */
package org.jivesoftware.smackx.message_markup.element; package org.jivesoftware.smackx.message_markup.element;
import javax.xml.namespace.QName;
public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement { public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
public static final String ELEMENT = "bquote"; public static final String ELEMENT = "bquote";
public static final QName QNAME = new QName(MarkupElement.NAMESPACE, ELEMENT);
/** /**
* Create a new Block Quote element. * Create a new Block Quote element.
@ -32,7 +35,7 @@ public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT; return QNAME.getLocalPart();
} }
} }

View file

@ -328,6 +328,7 @@ public class MUCUser implements ExtensionElement {
*/ */
public static class Decline implements ExtensionElement { public static class Decline implements ExtensionElement {
public static final String ELEMENT = "decline"; public static final String ELEMENT = "decline";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String reason; private final String reason;
private final EntityBareJid from; private final EntityBareJid from;
@ -384,12 +385,12 @@ public class MUCUser implements ExtensionElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT; return QNAME.getLocalPart();
} }
@Override @Override
public String getNamespace() { public String getNamespace() {
return NAMESPACE; return QNAME.getNamespaceURI();
} }
} }

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.nick.packet; package org.jivesoftware.smackx.nick.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
@ -30,7 +32,16 @@ public class Nick implements ExtensionElement {
public static final String NAMESPACE = "http://jabber.org/protocol/nick"; public static final String NAMESPACE = "http://jabber.org/protocol/nick";
public static final String ELEMENT_NAME = "nick"; public static final QName QNAME = new QName(NAMESPACE, "nick");
/**
* Deprected, do not use.
*
* @deprecated use {@link #QNAME} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.6.
public static final String ELEMENT_NAME = QNAME.getLocalPart();
private final String name; private final String name;
@ -49,12 +60,12 @@ public class Nick implements ExtensionElement {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT_NAME; return QNAME.getLocalPart();
} }
@Override @Override
public String getNamespace() { public String getNamespace() {
return NAMESPACE; return QNAME.getNamespaceURI();
} }
@Override @Override

View file

@ -65,7 +65,7 @@ public final class OfflineMessageManager extends Manager {
private static final Logger LOGGER = Logger.getLogger(OfflineMessageManager.class.getName()); private static final Logger LOGGER = Logger.getLogger(OfflineMessageManager.class.getName());
private static final String namespace = "http://jabber.org/protocol/offline"; public static final String NAMESPACE = "http://jabber.org/protocol/offline";
private static final Map<XMPPConnection, OfflineMessageManager> INSTANCES = new WeakHashMap<>(); private static final Map<XMPPConnection, OfflineMessageManager> INSTANCES = new WeakHashMap<>();
@ -100,7 +100,7 @@ public final class OfflineMessageManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return serviceDiscoveryManager.serverSupportsFeature(namespace); return serviceDiscoveryManager.serverSupportsFeature(NAMESPACE);
} }
/** /**
@ -114,8 +114,8 @@ public final class OfflineMessageManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DiscoverInfo info = serviceDiscoveryManager.discoverInfo(null, namespace); DiscoverInfo info = serviceDiscoveryManager.discoverInfo(null, NAMESPACE);
DataForm dataForm = DataForm.from(info, namespace); DataForm dataForm = DataForm.from(info, NAMESPACE);
if (dataForm == null) { if (dataForm == null) {
return 0; return 0;
} }
@ -138,7 +138,7 @@ public final class OfflineMessageManager extends Manager {
*/ */
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<OfflineMessageHeader> answer = new ArrayList<>(); List<OfflineMessageHeader> answer = new ArrayList<>();
DiscoverItems items = serviceDiscoveryManager.discoverItems(null, namespace); DiscoverItems items = serviceDiscoveryManager.discoverItems(null, NAMESPACE);
for (DiscoverItems.Item item : items.getItems()) { for (DiscoverItems.Item item : items.getItems()) {
answer.add(new OfflineMessageHeader(item)); answer.add(new OfflineMessageHeader(item));
} }

View file

@ -19,11 +19,14 @@ package org.jivesoftware.smackx.offline.packet;
import java.io.IOException; import java.io.IOException;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.offline.OfflineMessageManager;
/** /**
* OfflineMessageInfo is an extension included in the retrieved offline messages requested by * OfflineMessageInfo is an extension included in the retrieved offline messages requested by
@ -35,6 +38,8 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
*/ */
public class OfflineMessageInfo implements ExtensionElement { public class OfflineMessageInfo implements ExtensionElement {
public static final QName QNAME = new QName(OfflineMessageManager.NAMESPACE, "offline");
private String node = null; private String node = null;
/** /**
@ -45,7 +50,7 @@ public class OfflineMessageInfo implements ExtensionElement {
*/ */
@Override @Override
public String getElementName() { public String getElementName() {
return "offline"; return QNAME.getLocalPart();
} }
/** /**
@ -56,7 +61,7 @@ public class OfflineMessageInfo implements ExtensionElement {
*/ */
@Override @Override
public String getNamespace() { public String getNamespace() {
return "http://jabber.org/protocol/offline"; return QNAME.getNamespaceURI();
} }
/** /**

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.offline.OfflineMessageManager;
/** /**
* Represents a request to get some or all the offline messages of a user. This class can also * Represents a request to get some or all the offline messages of a user. This class can also
@ -37,7 +38,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
public class OfflineMessageRequest extends IQ { public class OfflineMessageRequest extends IQ {
public static final String ELEMENT = "offline"; public static final String ELEMENT = "offline";
public static final String NAMESPACE = "http://jabber.org/protocol/offline"; public static final String NAMESPACE = OfflineMessageManager.NAMESPACE;
private final List<Item> items = new ArrayList<>(); private final List<Item> items = new ArrayList<>();
private boolean purge = false; private boolean purge = false;

View file

@ -24,6 +24,8 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -119,6 +121,8 @@ public final class RosterPacket extends IQ {
*/ */
public static final String ELEMENT = Stanza.ITEM; public static final String ELEMENT = Stanza.ITEM;
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public static final String GROUP = "group"; public static final String GROUP = "group";
private final BareJid jid; private final BareJid jid;
@ -160,12 +164,12 @@ public final class RosterPacket extends IQ {
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT; return QNAME.getLocalPart();
} }
@Override @Override
public String getNamespace() { public String getNamespace() {
return NAMESPACE; return QNAME.getNamespaceURI();
} }
/** /**