1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-09 10:19:41 +02: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

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

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.nick.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.StringUtils;
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 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;
@ -49,12 +60,12 @@ public class Nick implements ExtensionElement {
@Override
public String getElementName() {
return ELEMENT_NAME;
return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return NAMESPACE;
return QNAME.getNamespaceURI();
}
@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 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<>();
@ -100,7 +100,7 @@ public final class OfflineMessageManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted.
*/
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.
*/
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DiscoverInfo info = serviceDiscoveryManager.discoverInfo(null, namespace);
DataForm dataForm = DataForm.from(info, namespace);
DiscoverInfo info = serviceDiscoveryManager.discoverInfo(null, NAMESPACE);
DataForm dataForm = DataForm.from(info, NAMESPACE);
if (dataForm == null) {
return 0;
}
@ -138,7 +138,7 @@ public final class OfflineMessageManager extends Manager {
*/
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<OfflineMessageHeader> answer = new ArrayList<>();
DiscoverItems items = serviceDiscoveryManager.discoverItems(null, namespace);
DiscoverItems items = serviceDiscoveryManager.discoverItems(null, NAMESPACE);
for (DiscoverItems.Item item : items.getItems()) {
answer.add(new OfflineMessageHeader(item));
}

View file

@ -19,11 +19,14 @@ package org.jivesoftware.smackx.offline.packet;
import java.io.IOException;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.offline.OfflineMessageManager;
/**
* 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 static final QName QNAME = new QName(OfflineMessageManager.NAMESPACE, "offline");
private String node = null;
/**
@ -45,7 +50,7 @@ public class OfflineMessageInfo implements ExtensionElement {
*/
@Override
public String getElementName() {
return "offline";
return QNAME.getLocalPart();
}
/**
@ -56,7 +61,7 @@ public class OfflineMessageInfo implements ExtensionElement {
*/
@Override
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.xml.XmlPullParser;
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
@ -37,7 +38,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
public class OfflineMessageRequest extends IQ {
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 boolean purge = false;