mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-01-22 17:46:24 +01:00
Compare commits
26 commits
a8f16a1122
...
5e561f410a
Author | SHA1 | Date | |
---|---|---|---|
5e561f410a | |||
|
0561aaa9bc | ||
|
c696925d33 | ||
|
6c5e64b2ca | ||
|
6498ca796b | ||
|
74a7a2689e | ||
|
37a2df5486 | ||
|
75636884ad | ||
|
7e8fddcbf8 | ||
|
9c7e575e9e | ||
|
d7858d2e8f | ||
|
18647c24ca | ||
|
d67262a5e0 | ||
|
1eb5649123 | ||
|
0191ed7174 | ||
|
6e6a3ef88d | ||
|
9e5ac5a39a | ||
|
3c5fb5810e | ||
|
caa479fac4 | ||
|
3b0c2f752f | ||
|
0ee5acc494 | ||
|
8b9cd98756 | ||
|
d3de2d65b9 | ||
|
02d8f53246 | ||
|
5dd08fc215 | ||
|
072761a0ad |
133 changed files with 534 additions and 363 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -56,7 +56,7 @@ jobs:
|
|||
uses: android-actions/setup-android@v3
|
||||
- name: Install Android SDK
|
||||
run: |
|
||||
sdkmanager "platforms;android-23"
|
||||
sdkmanager "platforms;android-26"
|
||||
|
||||
# Testing
|
||||
- name: Gradle Check
|
||||
|
|
10
Makefile
10
Makefile
|
@ -1,12 +1,12 @@
|
|||
GRADLE ?= ./gradlew
|
||||
|
||||
.PHONY: all
|
||||
all: check jacocoRootReport javadocAll sinttest
|
||||
all: check codecov eclipse javadocAll sinttest
|
||||
|
||||
.PHONY: codecov
|
||||
codecov:
|
||||
$(GRADLE) smack-java11-full:testCodeCoverageReport
|
||||
echo "Report available at smack-java11-full/build/reports/jacoco/testCodeCoverageReport/html/index.html"
|
||||
echo "code coverage report available at file://$(PWD)/smack-java11-full/build/reports/jacoco/testCodeCoverageReport/html/index.html"
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
@ -20,11 +20,7 @@ eclipse:
|
|||
sinttest:
|
||||
$(GRADLE) $@
|
||||
|
||||
.PHONY: jacocoRootReport
|
||||
jacocoRootReport:
|
||||
$(GRADLE) $@
|
||||
|
||||
.PHONY: javadocAll
|
||||
javadocAll:
|
||||
$(GRADLE) $@
|
||||
echo "Smack javadoc available at build/javadoc/index.html"
|
||||
echo "javadoc available at file://$(PWD)/build/javadoc/index.html"
|
||||
|
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
id 'org.igniterealtime.smack.global-conventions'
|
||||
}
|
||||
dependencies {
|
||||
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:6.0_r3@signature"
|
||||
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:8.0.0_r2@signature"
|
||||
}
|
||||
animalsniffer {
|
||||
sourceSets = [sourceSets.main]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
javaVersion = JavaVersion.VERSION_11
|
||||
javaMajor = javaVersion.getMajorVersion()
|
||||
smackMinAndroidSdk = 23
|
||||
smackMinAndroidSdk = 26
|
||||
|
||||
androidBootClasspath = { getAndroidRuntimeJar() }
|
||||
}
|
||||
|
|
|
@ -89,28 +89,7 @@ tasks.withType(JavaCompile) {
|
|||
'-Xlint:-serial',
|
||||
'-Werror',
|
||||
]
|
||||
}
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
tasks.withType(Javadoc) {
|
||||
// The '-quiet' as second argument is actually a hack,
|
||||
// since the one parameter addStringOption doesn't seem to
|
||||
// work, we extra add '-quiet', which is added anyway by
|
||||
// gradle.
|
||||
// We disable 'missing' as we do most of javadoc checking via checkstyle.
|
||||
options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
||||
// Abort on javadoc warnings.
|
||||
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
|
||||
// for information about the -Xwerror option.
|
||||
options.addStringOption('Xwerror', '-quiet')
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs.addAll([
|
||||
'--release', javaMajor,
|
||||
])
|
||||
}
|
||||
options.release = Integer.valueOf(javaMajor)
|
||||
}
|
||||
|
||||
jacoco {
|
||||
|
@ -177,7 +156,7 @@ jar {
|
|||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = '8.27'
|
||||
toolVersion = '10.18.2'
|
||||
|
||||
if (project in gplLicensedProjects) {
|
||||
configProperties.checkstyleLicenseHeader = "${project.name}-gplv3-license-header"
|
||||
|
@ -344,17 +323,6 @@ def getGitCommit() {
|
|||
gitCommit
|
||||
}
|
||||
|
||||
def getAndroidRuntimeJar() {
|
||||
def androidHome = new File("$System.env.ANDROID_HOME")
|
||||
if (!androidHome.isDirectory()) throw new Exception("ANDROID_HOME not found or set")
|
||||
def androidJar = new File("$androidHome/platforms/android-$smackMinAndroidSdk/android.jar")
|
||||
if (androidJar.isFile()) {
|
||||
return androidJar
|
||||
} else {
|
||||
throw new Exception("Can't find android.jar for $smackMinAndroidSdk API. Please install corresponding SDK platform package")
|
||||
}
|
||||
}
|
||||
|
||||
def readVersionFile() {
|
||||
def versionFile = new File(rootDir, 'version')
|
||||
if (!versionFile.isFile()) {
|
||||
|
|
|
@ -4,25 +4,19 @@ plugins {
|
|||
id 'org.igniterealtime.smack.global-conventions'
|
||||
}
|
||||
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
tasks.withType(Javadoc) {
|
||||
// The '-quiet' as second argument is actually a hack,
|
||||
// since the one parameter addStringOption doesn't seem to
|
||||
// work, we extra add '-quiet', which is added anyway by
|
||||
// gradle.
|
||||
// We disable 'missing' as we do most of javadoc checking via checkstyle.
|
||||
options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
||||
// Abort on javadoc warnings.
|
||||
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
|
||||
// for information about the -Xwerror option.
|
||||
options.addStringOption('Xwerror', '-quiet')
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addStringOption('-release', javaMajor)
|
||||
}
|
||||
tasks.withType(Javadoc) {
|
||||
// The '-quiet' as second argument is actually a hack,
|
||||
// since the one parameter addStringOption doesn't seem to
|
||||
// work, we extra add '-quiet', which is added anyway by
|
||||
// gradle.
|
||||
// We disable 'missing' as we do most of javadoc checking via checkstyle.
|
||||
options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
||||
// Abort on javadoc warnings.
|
||||
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
|
||||
// for information about the -Xwerror option.
|
||||
options.addStringOption('Xwerror', '-quiet')
|
||||
options.addStringOption('-release', javaMajor)
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<!-- TODO stricten those checks -->
|
||||
<property name="scope" value="protected"/>
|
||||
<property name="accessModifiers" value="public,protected"/>
|
||||
</module>
|
||||
<module name="JavadocStyle">
|
||||
<property name="scope" value="public"/>
|
||||
|
@ -195,15 +195,15 @@
|
|||
, TYPE_EXTENSION_AND
|
||||
"/>
|
||||
</module>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules"
|
||||
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="^org\.jivesoftware\.smack"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
<module name="ImportOrder">
|
||||
<property name="groups" value="/^java\./,/^javax\./,/^org\.jivesoftware\.smack\./,/^org\.jivesoftware\.smackx\./,/^org\.igniterealtime\.smack\./,/^org\.igniterealtime\.smackx\./"/>
|
||||
<property name="separated" value="true"/>
|
||||
<property name="option" value="top"/>
|
||||
</module>
|
||||
<module name="MissingJavadocPackage"/>
|
||||
<!-- this seems to cause false positives with checkstyle 10.18.2
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
-->
|
||||
<module name="UnnecessarySemicolonInEnumeration"/>
|
||||
<module name="UnnecessarySemicolonInTryWithResources"/>
|
||||
</module>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#Organize Import Order
|
||||
#Wed Jun 14 16:42:40 CEST 2017
|
||||
5=
|
||||
7=
|
||||
6=org.igniterealtime.smackx
|
||||
5=org.igniterealtime.smack
|
||||
4=org.jivesoftware.smackx
|
||||
3=org.jivesoftware.smack
|
||||
2=javax
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.jivesoftware.smack.Manager;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.util.Async;
|
||||
|
||||
import org.jivesoftware.smackx.ping.PingManager;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
|
@ -173,7 +174,13 @@ public final class ServerPingWithAlarmManager extends Manager {
|
|||
*/
|
||||
public static void onCreate(Context context) {
|
||||
sContext = context;
|
||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
||||
|
||||
int receiverFlags = 0;
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
receiverFlags |= 4; // RECEIVER_NOT_EXPORTED
|
||||
}
|
||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION), receiverFlags);
|
||||
|
||||
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
int pendingIntentFlags = 0;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
|
|
|
@ -499,7 +499,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
*
|
||||
* @author Guenther Niess
|
||||
*/
|
||||
private class BOSHConnectionListener implements BOSHClientConnListener {
|
||||
private final class BOSHConnectionListener implements BOSHClientConnListener {
|
||||
|
||||
/**
|
||||
* Notify the BOSHConnection about connection state changes.
|
||||
|
@ -556,7 +556,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
*
|
||||
* @author Guenther Niess
|
||||
*/
|
||||
private class BOSHPacketReader implements BOSHClientResponseListener {
|
||||
private final class BOSHPacketReader implements BOSHClientResponseListener {
|
||||
|
||||
/**
|
||||
* Parse the received packets and notify the corresponding connection.
|
||||
|
|
|
@ -281,8 +281,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
*/
|
||||
protected Writer writer;
|
||||
|
||||
protected SmackException currentSmackException;
|
||||
protected XMPPException currentXmppException;
|
||||
private Exception currentConnectionException;
|
||||
|
||||
protected boolean tlsHandled;
|
||||
|
||||
|
@ -511,8 +510,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
public abstract boolean isUsingCompression();
|
||||
|
||||
protected void initState() {
|
||||
currentSmackException = null;
|
||||
currentXmppException = null;
|
||||
currentConnectionException = null;
|
||||
saslFeatureReceived = lastFeaturesReceived = tlsHandled = false;
|
||||
// TODO: We do not init closingStreamReceived here, as the integration tests use it to check if we waited for
|
||||
// it.
|
||||
|
@ -686,28 +684,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return streamId;
|
||||
}
|
||||
|
||||
protected final void throwCurrentConnectionException() throws SmackException, XMPPException {
|
||||
if (currentSmackException != null) {
|
||||
throw currentSmackException;
|
||||
} else if (currentXmppException != null) {
|
||||
throw currentXmppException;
|
||||
}
|
||||
|
||||
throw new AssertionError("No current connection exception set, although throwCurrentException() was called");
|
||||
}
|
||||
|
||||
protected final boolean hasCurrentConnectionException() {
|
||||
return currentSmackException != null || currentXmppException != null;
|
||||
return currentConnectionException != null;
|
||||
}
|
||||
|
||||
protected final void setCurrentConnectionExceptionAndNotify(Exception exception) {
|
||||
if (exception instanceof SmackException) {
|
||||
currentSmackException = (SmackException) exception;
|
||||
} else if (exception instanceof XMPPException) {
|
||||
currentXmppException = (XMPPException) exception;
|
||||
} else {
|
||||
currentSmackException = new SmackException.SmackWrappedException(exception);
|
||||
}
|
||||
currentConnectionException = exception;
|
||||
|
||||
notifyWaitingThreads();
|
||||
}
|
||||
|
@ -741,10 +723,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected final void waitForConditionOrThrowConnectionException(Supplier<Boolean> condition, String waitFor) throws InterruptedException, SmackException, XMPPException {
|
||||
protected final void waitForConditionOrThrowConnectionException(Supplier<Boolean> condition, String waitFor)
|
||||
throws InterruptedException, SmackException.SmackWrappedException, NoResponseException {
|
||||
boolean success = waitFor(() -> condition.get().booleanValue() || hasCurrentConnectionException());
|
||||
if (hasCurrentConnectionException()) {
|
||||
throwCurrentConnectionException();
|
||||
final Exception currentConnectionException = this.currentConnectionException;
|
||||
if (currentConnectionException != null) {
|
||||
throw new SmackException.SmackWrappedException(currentConnectionException);
|
||||
}
|
||||
|
||||
// If there was no connection exception and we still did not successfully wait for the condition to hold, then
|
||||
|
@ -1048,7 +1032,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
protected final boolean waitForClosingStreamTagFromServer() {
|
||||
try {
|
||||
waitForConditionOrThrowConnectionException(() -> closingStreamReceived, "closing stream tag from the server");
|
||||
} catch (InterruptedException | SmackException | XMPPException e) {
|
||||
} catch (InterruptedException | SmackException.SmackWrappedException | NoResponseException e) {
|
||||
LOGGER.log(Level.INFO, "Exception while waiting for closing stream element from the server " + this, e);
|
||||
return false;
|
||||
}
|
||||
|
@ -1460,7 +1444,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
int parserDepth = parser.getDepth();
|
||||
Stanza stanza = null;
|
||||
try {
|
||||
stanza = PacketParserUtils.parseStanza(parser, incomingStreamXmlEnvironment);
|
||||
try {
|
||||
stanza = PacketParserUtils.parseStanza(parser, incomingStreamXmlEnvironment);
|
||||
} catch (NullPointerException e) {
|
||||
// Those exceptions should probably be wrapped into a SmackParsingException and therefore likely constitute a missing verification in the throwing parser.
|
||||
String message = "Smack parser throw unexpected exception '" + e.getMessage() + "', please report this at " + Smack.BUG_REPORT_URL;
|
||||
LOGGER.log(Level.SEVERE, message, e);
|
||||
throw new IOException(message, e);
|
||||
}
|
||||
}
|
||||
catch (XmlPullParserException | SmackParsingException | IOException | IllegalArgumentException e) {
|
||||
CharSequence content = PacketParserUtils.parseContentDepth(parser,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020-2021 Florian Schmaus
|
||||
* Copyright 2020-2024 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,9 @@
|
|||
package org.jivesoftware.smack;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.util.FileUtils;
|
||||
|
@ -29,6 +32,16 @@ public class Smack {
|
|||
|
||||
public static final String SMACK_PACKAGE = SMACK_ORG + ".smack";
|
||||
|
||||
public static final URL BUG_REPORT_URL;
|
||||
|
||||
static {
|
||||
try {
|
||||
BUG_REPORT_URL = URI.create("https://discourse.igniterealtime.org/c/smack/smack-support/9").toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Smack version information, e.g."1.3.0".
|
||||
*
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.jivesoftware.smack;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -60,7 +61,7 @@ public final class SmackConfiguration {
|
|||
|
||||
static {
|
||||
try {
|
||||
SMACK_URL = new URL(SMACK_URL_STRING);
|
||||
SMACK_URL = URI.create(SMACK_URL_STRING).toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class SmackReactor {
|
|||
return scheduledActions.remove(scheduledAction);
|
||||
}
|
||||
|
||||
private class Reactor extends Thread {
|
||||
private final class Reactor extends Thread {
|
||||
|
||||
private volatile long shutdownRequestTimestamp = -1;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public final class HttpLookupMethod {
|
|||
*/
|
||||
public static InputStream getXrdStream(DomainBareJid xmppServiceAddress) throws IOException {
|
||||
final String metadataUrl = "https://" + xmppServiceAddress + "/.well-known/host-meta";
|
||||
final URL putUrl = new URL(metadataUrl);
|
||||
final URL putUrl = URI.create(metadataUrl).toURL();
|
||||
final URLConnection urlConnection = putUrl.openConnection();
|
||||
return urlConnection.getInputStream();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.SmackException.OutgoingQueueFullException;
|
||||
import org.jivesoftware.smack.SmackException.SmackWrappedException;
|
||||
import org.jivesoftware.smack.SmackFuture;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.FailedNonzaException;
|
||||
|
@ -259,7 +260,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
|||
|
||||
@Override
|
||||
public void waitForConditionOrThrowConnectionException(Supplier<Boolean> condition, String waitFor)
|
||||
throws InterruptedException, SmackException, XMPPException {
|
||||
throws InterruptedException, SmackWrappedException, NoResponseException {
|
||||
ModularXmppClientToServerConnection.this.waitForConditionOrThrowConnectionException(condition, waitFor);
|
||||
}
|
||||
|
||||
|
@ -596,8 +597,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
|||
case "error":
|
||||
StreamError streamError = PacketParserUtils.parseStreamError(parser, null);
|
||||
StreamErrorException streamErrorException = new StreamErrorException(streamError);
|
||||
currentXmppException = streamErrorException;
|
||||
notifyWaitingThreads();
|
||||
setCurrentConnectionExceptionAndNotify(streamErrorException);
|
||||
throw streamErrorException;
|
||||
case "features":
|
||||
parseFeatures(parser);
|
||||
|
@ -1048,8 +1048,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
|||
XmppInputOutputFilter filter = it.next();
|
||||
try {
|
||||
filter.waitUntilInputOutputClosed();
|
||||
} catch (IOException | CertificateException | InterruptedException | SmackException
|
||||
| XMPPException e) {
|
||||
} catch (IOException | CertificateException | InterruptedException | SmackException | XMPPException e) {
|
||||
LOGGER.log(Level.WARNING, "waitUntilInputOutputClosed() threw", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Queue;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.SmackException.SmackWrappedException;
|
||||
import org.jivesoftware.smack.SmackReactor;
|
||||
import org.jivesoftware.smack.SmackReactor.ChannelSelectedCallback;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
@ -127,7 +128,8 @@ public abstract class ModularXmppClientToServerConnectionInternal {
|
|||
|
||||
public abstract void asyncGo(Runnable runnable);
|
||||
|
||||
public abstract void waitForConditionOrThrowConnectionException(Supplier<Boolean> condition, String waitFor) throws InterruptedException, SmackException, XMPPException;
|
||||
public abstract void waitForConditionOrThrowConnectionException(Supplier<Boolean> condition, String waitFor)
|
||||
throws InterruptedException, SmackWrappedException, NoResponseException;
|
||||
|
||||
public abstract void notifyWaitingThreads();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019-2021 Florian Schmaus
|
||||
* Copyright 2019-2024 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,10 +20,15 @@ import java.io.IOException;
|
|||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
public class AbstractProvider<E extends Element> {
|
||||
|
@ -106,4 +111,14 @@ public class AbstractProvider<E extends Element> {
|
|||
|
||||
return e;
|
||||
}
|
||||
|
||||
public static URL toUrl(String string) throws SmackUriSyntaxParsingException, MalformedURLException {
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(string);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new SmackUriSyntaxParsingException(e);
|
||||
}
|
||||
return uri.toURL();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class EventManger<K, R, E extends Exception> {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static class Reference<V> {
|
||||
private static final class Reference<V> {
|
||||
volatile V eventResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.jivesoftware.smackx.iot.provisioning.BecameFriendListener;
|
|||
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
|
||||
|
||||
import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint;
|
||||
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2021 Florian Schmaus
|
||||
* Copyright 2021-2024 Florian Schmaus
|
||||
*
|
||||
* This file is part of smack-examples.
|
||||
*
|
||||
|
@ -25,7 +25,6 @@ import java.net.URISyntaxException;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection;
|
||||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
|
||||
import org.jivesoftware.smack.util.TLSUtils;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection;
|
|||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
|
||||
import org.jivesoftware.smack.debugger.ConsoleDebugger;
|
||||
import org.jivesoftware.smack.debugger.SmackDebuggerFactory;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
||||
import org.jivesoftware.smackx.pep.PepManager;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
||||
import org.jivesoftware.smack.util.TLSUtils;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.iqregister.AccountManager;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smack.util.EqualsUtil;
|
|||
import org.jivesoftware.smack.util.HashCode;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.hashes.HashManager;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.file_metadata.element.FileMetadataElement;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmp
|
|||
while (!done) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
|
||||
if ((eventType == XmlPullParser.Event.END_ELEMENT) && parser.getName().equals(ELEMENT_XML)) {
|
||||
if (eventType == XmlPullParser.Event.END_ELEMENT && parser.getName().equals(ELEMENT_XML)) {
|
||||
done = true;
|
||||
} else { // just write everything else as text
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017 Grigory Fedorov, 2017-2019 Florian Schmaus
|
||||
* Copyright © 2017 Grigory Fedorov, 2017-2024 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,12 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||
import org.jivesoftware.smack.provider.IqProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
@ -42,7 +44,7 @@ import org.jivesoftware.smackx.httpfileupload.element.Slot_V0_2;
|
|||
public class SlotProvider extends IqProvider<Slot> {
|
||||
|
||||
@Override
|
||||
public Slot parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
public Slot parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackUriSyntaxParsingException {
|
||||
final String namespace = parser.getNamespace();
|
||||
|
||||
final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace);
|
||||
|
@ -63,7 +65,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
switch (version) {
|
||||
case v0_2:
|
||||
String putUrlString = parser.nextText();
|
||||
putUrl = new URL(putUrlString);
|
||||
putUrl = toUrl(putUrlString);
|
||||
break;
|
||||
case v0_3:
|
||||
putElementV04Content = parsePutElement_V0_4(parser);
|
||||
|
@ -85,7 +87,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
getUrl = new URL(getUrlString);
|
||||
getUrl = toUrl(getUrlString);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -114,7 +116,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
final int initialDepth = parser.getDepth();
|
||||
|
||||
String putUrlString = parser.getAttributeValue(null, "url");
|
||||
URL putUrl = new URL(putUrlString);
|
||||
URL putUrl = URI.create(putUrlString).toURL();
|
||||
|
||||
Map<String, String> headers = null;
|
||||
outerloop: while (true) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.packet.MessageView;
|
|||
import org.jivesoftware.smack.packet.XmlElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
package org.jivesoftware.smackx.mam.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
package org.jivesoftware.smackx.mam.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
|
||||
|
||||
public class ThumbnailElementProvider extends ExtensionElementProvider<ThumbnailElement> {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Date;
|
|||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
|
||||
import org.jivesoftware.smackx.file_metadata.element.FileMetadataElement;
|
||||
import org.jivesoftware.smackx.file_metadata.provider.FileMetadataElementProvider;
|
||||
import org.jivesoftware.smackx.hashes.HashManager;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.IOException;
|
|||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
|
|
@ -461,7 +461,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* IQIBBInputStream class implements IBBInputStream to be used with IQ stanzas encapsulating the
|
||||
* data packets.
|
||||
*/
|
||||
private class IQIBBInputStream extends IBBInputStream {
|
||||
private final class IQIBBInputStream extends IBBInputStream {
|
||||
|
||||
@Override
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
|
@ -541,7 +541,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* MessageIBBInputStream class implements IBBInputStream to be used with message stanzas
|
||||
* encapsulating the data packets.
|
||||
*/
|
||||
private class MessageIBBInputStream extends IBBInputStream {
|
||||
private final class MessageIBBInputStream extends IBBInputStream {
|
||||
|
||||
@Override
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
|
@ -590,7 +590,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* containing an In-Band Bytestream data stanza extension whose session ID matches this sessions
|
||||
* ID.
|
||||
*/
|
||||
private class IBBDataPacketFilter implements StanzaFilter {
|
||||
private final class IBBDataPacketFilter implements StanzaFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
|
@ -814,7 +814,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* IQIBBOutputStream class implements IBBOutputStream to be used with IQ stanzas encapsulating
|
||||
* the data packets.
|
||||
*/
|
||||
private class IQIBBOutputStream extends IBBOutputStream {
|
||||
private final class IQIBBOutputStream extends IBBOutputStream {
|
||||
|
||||
@Override
|
||||
protected synchronized void writeToXML(DataPacketExtension data) throws IOException {
|
||||
|
@ -845,7 +845,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* MessageIBBOutputStream class implements IBBOutputStream to be used with message stanzas
|
||||
* encapsulating the data packets.
|
||||
*/
|
||||
private class MessageIBBOutputStream extends IBBOutputStream {
|
||||
private final class MessageIBBOutputStream extends IBBOutputStream {
|
||||
|
||||
@Override
|
||||
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException, InterruptedException {
|
||||
|
|
|
@ -433,7 +433,7 @@ public class Socks5Proxy {
|
|||
/**
|
||||
* Implementation of a simplified SOCKS5 proxy server.
|
||||
*/
|
||||
private class Socks5ServerProcess implements Runnable {
|
||||
private final class Socks5ServerProcess implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData.Action;
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData.AllowedAction;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||
import org.jivesoftware.smackx.xdata.form.FillableForm;
|
||||
import org.jivesoftware.smackx.xdata.form.SubmitForm;
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandDataBuilder;
|
||||
import org.jivesoftware.smackx.xdata.form.SubmitForm;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.commands;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||
import org.jivesoftware.smackx.xdata.form.FillableForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
import org.jivesoftware.smackx.muc.packet.GroupChatInvitation;
|
||||
|
||||
public interface DirectMucInvitationListener {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.muc.packet.GroupChatInvitation;
|
||||
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
@ -215,9 +216,9 @@ public class RoomInfo {
|
|||
if (urlField != null && !urlField.getValues().isEmpty()) {
|
||||
String urlString = urlField.getFirstValue();
|
||||
try {
|
||||
logs = new URL(urlString);
|
||||
} catch (MalformedURLException e) {
|
||||
LOGGER.log(Level.SEVERE, "Could not parse |