mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 13:32:07 +01:00
Compare commits
No commits in common. "de564689c6822cd2152ab77a7cb12c9de1726a18" and "b5180f819f422d3d6d3d6ff277f7fb8eee2ccbcc" have entirely different histories.
de564689c6
...
b5180f819f
447 changed files with 4111 additions and 5602 deletions
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
|
@ -6,14 +6,13 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Smack
|
name: Build Smack
|
||||||
|
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java:
|
java:
|
||||||
- 17
|
- 11
|
||||||
- 21
|
|
||||||
env:
|
env:
|
||||||
PRIMARY_JAVA_VERSION: 21
|
PRIMARY_JAVA_VERSION: 11
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -53,10 +52,10 @@ jobs:
|
||||||
- name: Install GraphViz
|
- name: Install GraphViz
|
||||||
run: sudo apt update && sudo apt install graphviz
|
run: sudo apt update && sudo apt install graphviz
|
||||||
- name: Install Android SDK Manager
|
- name: Install Android SDK Manager
|
||||||
uses: android-actions/setup-android@v3
|
uses: android-actions/setup-android@v2
|
||||||
- name: Install Android SDK
|
- name: Install Android SDK
|
||||||
run: |
|
run: |
|
||||||
sdkmanager "platforms;android-23"
|
sdkmanager "platforms;android-19"
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
- name: Gradle Check
|
- name: Gradle Check
|
||||||
|
@ -72,22 +71,15 @@ jobs:
|
||||||
run: ./gradlew javadocAll --stacktrace
|
run: ./gradlew javadocAll --stacktrace
|
||||||
|
|
||||||
# Test Coverage Report
|
# Test Coverage Report
|
||||||
- name: Aggregated Jacoco Test Coverage Report
|
- name: Jacoco Test Coverage
|
||||||
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
||||||
run: |
|
run: ./gradlew jacocoRootReport coveralls
|
||||||
./gradlew smack-java11-full:testCodeCoverageReport
|
env:
|
||||||
|
COVERALLS_REPO_TOKEN: S2ecSJja2cKJa9yv45C8ZFPohXuRrTXKd
|
||||||
# Coveralls
|
|
||||||
- name: Report coverage stats to Coveralls
|
|
||||||
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
|
||||||
uses: coverallsapp/github-action@v2
|
|
||||||
with:
|
|
||||||
format: jacoco
|
|
||||||
file: smack-java11-full/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
|
|
||||||
|
|
||||||
# Upload build artifacts
|
# Upload build artifacts
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: smack-java-${{ matrix.java }}
|
name: smack-java-${{ matrix.java }}
|
||||||
path: |
|
path: |
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,6 +12,7 @@
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
.gradle
|
.gradle
|
||||||
|
gradle.properties
|
||||||
|
|
||||||
build/
|
build/
|
||||||
core/build/
|
core/build/
|
||||||
|
|
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,17 +1,5 @@
|
||||||
# Smack Changelog
|
# Smack Changelog
|
||||||
|
|
||||||
# 4.4.8 -- 2024-04-02
|
|
||||||
|
|
||||||
### Improvement
|
|
||||||
|
|
||||||
[SMACK-941](https://igniterealtime.atlassian.net/browse/SMACK-941) Suppress "roster not loaded while processing presence" warning if its caused by the reflected self-presence
|
|
||||||
|
|
||||||
### Bug
|
|
||||||
|
|
||||||
[SMACK-938](https://igniterealtime.atlassian.net/browse/SMACK-938) Busy loop in SmackReactor
|
|
||||||
|
|
||||||
[SMACK-940](https://igniterealtime.atlassian.net/browse/SMACK-940) Ignore IPv6 Zone IDs in incoming streamhost candidates
|
|
||||||
|
|
||||||
# 4.4.7 -- 2023-11-25
|
# 4.4.7 -- 2023-11-25
|
||||||
|
|
||||||
### Improvement
|
### Improvement
|
||||||
|
|
30
Makefile
30
Makefile
|
@ -1,30 +0,0 @@
|
||||||
GRADLE ?= ./gradlew
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: check jacocoRootReport javadocAll sinttest
|
|
||||||
|
|
||||||
.PHONY: codecov
|
|
||||||
codecov:
|
|
||||||
$(GRADLE) smack-java11-full:testCodeCoverageReport
|
|
||||||
echo "Report available at smack-java11-full/build/reports/jacoco/testCodeCoverageReport/html/index.html"
|
|
||||||
|
|
||||||
.PHONY: check
|
|
||||||
check:
|
|
||||||
$(GRADLE) $@
|
|
||||||
|
|
||||||
.PHONY: eclipse
|
|
||||||
eclipse:
|
|
||||||
$(GRADLE) $@
|
|
||||||
|
|
||||||
.PHONY: sinttest
|
|
||||||
sinttest:
|
|
||||||
$(GRADLE) $@
|
|
||||||
|
|
||||||
.PHONY: jacocoRootReport
|
|
||||||
jacocoRootReport:
|
|
||||||
$(GRADLE) $@
|
|
||||||
|
|
||||||
.PHONY: javadocAll
|
|
||||||
javadocAll:
|
|
||||||
$(GRADLE) $@
|
|
||||||
echo "Smack javadoc available at build/javadoc/index.html"
|
|
|
@ -1,14 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'groovy-gradle-plugin'
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0"
|
|
||||||
implementation "me.champeau.jmh:jmh-gradle-plugin:0.7.2"
|
|
||||||
implementation "net.ltgt.gradle:gradle-errorprone-plugin:4.0.1"
|
|
||||||
implementation "ru.vyarus:gradle-animalsniffer-plugin:1.7.1"
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
rootProject.name = 'smack-build-logic'
|
|
|
@ -1,6 +0,0 @@
|
||||||
compileJava {
|
|
||||||
options.bootstrapClasspath = files(androidBootClasspath)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
classpath += files(androidBootClasspath)
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'ru.vyarus.animalsniffer'
|
|
||||||
id 'org.igniterealtime.smack.global-conventions'
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:6.0_r3@signature"
|
|
||||||
}
|
|
||||||
animalsniffer {
|
|
||||||
sourceSets = [sourceSets.main]
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'application'
|
|
||||||
}
|
|
||||||
|
|
||||||
application {
|
|
||||||
applicationDefaultJvmArgs = ["-enableassertions"]
|
|
||||||
}
|
|
||||||
|
|
||||||
run {
|
|
||||||
// Pass all system properties down to the "application" run
|
|
||||||
systemProperties System.getProperties()
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
ext {
|
|
||||||
javaVersion = JavaVersion.VERSION_11
|
|
||||||
javaMajor = javaVersion.getMajorVersion()
|
|
||||||
smackMinAndroidSdk = 23
|
|
||||||
|
|
||||||
androidBootClasspath = { getAndroidRuntimeJar() }
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAndroidRuntimeJar() {
|
|
||||||
def androidApiLevel = ext.smackMinAndroidSdk
|
|
||||||
def androidHome = getAndroidHome()
|
|
||||||
def androidJar = new File("$androidHome/platforms/android-${androidApiLevel}/android.jar")
|
|
||||||
if (androidJar.isFile()) {
|
|
||||||
return androidJar
|
|
||||||
} else {
|
|
||||||
throw new Exception("Can't find android.jar for API level ${androidApiLevel}. Please install corresponding SDK platform package")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def getAndroidJavadocOffline() {
|
|
||||||
def androidHome = getAndroidHome()
|
|
||||||
return androidHome.toString() + "/docs/reference"
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAndroidHome() {
|
|
||||||
def androidHomeEnv = System.getenv("ANDROID_HOME")
|
|
||||||
if (androidHomeEnv == null) {
|
|
||||||
throw new Exception("ANDROID_HOME environment variable is not set")
|
|
||||||
}
|
|
||||||
def androidHome = new File(androidHomeEnv)
|
|
||||||
if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
|
|
||||||
return androidHome
|
|
||||||
}
|
|
|
@ -1,367 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'biz.aQute.bnd.builder'
|
|
||||||
id 'checkstyle'
|
|
||||||
id 'eclipse'
|
|
||||||
id 'idea'
|
|
||||||
id 'jacoco'
|
|
||||||
id 'java'
|
|
||||||
id 'java-library'
|
|
||||||
id 'java-test-fixtures'
|
|
||||||
id 'maven-publish'
|
|
||||||
id 'net.ltgt.errorprone'
|
|
||||||
id 'signing'
|
|
||||||
|
|
||||||
id 'jacoco-report-aggregation'
|
|
||||||
id 'test-report-aggregation'
|
|
||||||
|
|
||||||
id 'org.igniterealtime.smack.global-conventions'
|
|
||||||
id 'org.igniterealtime.smack.javadoc-conventions'
|
|
||||||
}
|
|
||||||
|
|
||||||
version readVersionFile()
|
|
||||||
|
|
||||||
ext {
|
|
||||||
isSnapshot = version.endsWith('-SNAPSHOT')
|
|
||||||
gitCommit = getGitCommit()
|
|
||||||
rootConfigDir = new File(rootDir, 'config')
|
|
||||||
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
|
|
||||||
isReleaseVersion = !isSnapshot
|
|
||||||
isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
|
|
||||||
signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
|
|
||||||
sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
|
|
||||||
sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
|
||||||
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
|
|
||||||
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
|
|
||||||
|
|
||||||
jxmppVersion = '[1.1.0-beta1, 1.1.999]'
|
|
||||||
miniDnsVersion = '[1.1.0-alpha3, 1.1.999]'
|
|
||||||
junitVersion = '5.9.2'
|
|
||||||
commonsIoVersion = '2.6'
|
|
||||||
bouncyCastleVersion = '1.73'
|
|
||||||
guavaVersion = '30.1-jre'
|
|
||||||
mockitoVersion = '5.13.0'
|
|
||||||
orgReflectionsVersion = '0.9.11'
|
|
||||||
|
|
||||||
if (project.hasProperty("useSonatype")) {
|
|
||||||
useSonatype = project.getProperty("useSonatype").toBoolean()
|
|
||||||
} else {
|
|
||||||
// Default to true
|
|
||||||
useSonatype = true
|
|
||||||
}
|
|
||||||
|
|
||||||
gplLicensedProjects = [
|
|
||||||
':smack-examples',
|
|
||||||
':smack-omemo-signal',
|
|
||||||
':smack-omemo-signal-integration-test',
|
|
||||||
':smack-repl'
|
|
||||||
].collect{ project(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
group = 'org.igniterealtime.smack'
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = javaVersion
|
|
||||||
targetCompatibility = sourceCompatibility
|
|
||||||
}
|
|
||||||
|
|
||||||
eclipse {
|
|
||||||
classpath {
|
|
||||||
downloadJavadoc = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make all project's 'test' target depend on javadoc, so that
|
|
||||||
// javadoc is also linted.
|
|
||||||
test.dependsOn javadoc
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
// Some systems may not have set their platform default
|
|
||||||
// converter to 'utf8', but we use unicode in our source
|
|
||||||
// files. Therefore ensure that javac uses unicode
|
|
||||||
options.encoding = "utf8"
|
|
||||||
options.compilerArgs = [
|
|
||||||
'-Xlint:all',
|
|
||||||
// Set '-options' because a non-java7 javac will emit a
|
|
||||||
// warning if source/target is set to 1.7 and
|
|
||||||
// bootclasspath is *not* set.
|
|
||||||
'-Xlint:-options',
|
|
||||||
// TODO: Enable xlint serial
|
|
||||||
'-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,
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = "0.8.12"
|
|
||||||
}
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
dependsOn test
|
|
||||||
reports {
|
|
||||||
xml.required = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
|
||||||
|
|
||||||
testFixturesApi "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
|
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
|
||||||
// https://stackoverflow.com/a/77274251/194894
|
|
||||||
testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.11.0"
|
|
||||||
|
|
||||||
// The smack-extensions subproject uses mockito in its fest
|
|
||||||
// fixtures, and we want to have mockito also available in
|
|
||||||
// test, so we use API here.
|
|
||||||
testFixturesApi "org.mockito:mockito-core:${mockitoVersion}"
|
|
||||||
|
|
||||||
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
|
|
||||||
|
|
||||||
errorprone 'com.google.errorprone:error_prone_core:2.32.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
|
|
||||||
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
|
||||||
|
|
||||||
// Enable full stacktraces of failed tests. Especially handy
|
|
||||||
// for CI environments.
|
|
||||||
testLogging {
|
|
||||||
events "failed"
|
|
||||||
exceptionFormat "full"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Implementation-Version': version,
|
|
||||||
'Implementation-GitRevision': gitCommit,
|
|
||||||
'Built-JDK': System.getProperty('java.version'),
|
|
||||||
'Built-Gradle': gradle.gradleVersion,
|
|
||||||
'Built-By': System.getProperty('user.name')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle {
|
|
||||||
bnd(
|
|
||||||
'-removeheaders': 'Tool, Bnd-*',
|
|
||||||
'-exportcontents': '*',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkstyle {
|
|
||||||
toolVersion = '8.27'
|
|
||||||
|
|
||||||
if (project in gplLicensedProjects) {
|
|
||||||
configProperties.checkstyleLicenseHeader = "${project.name}-gplv3-license-header"
|
|
||||||
} else {
|
|
||||||
configProperties.checkstyleLicenseHeader = "header"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
archiveClassifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
archiveClassifier = 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
task testsJar(type: Jar) {
|
|
||||||
archiveClassifier = 'tests'
|
|
||||||
from sourceSets.test.output
|
|
||||||
}
|
|
||||||
configurations {
|
|
||||||
testRuntime
|
|
||||||
}
|
|
||||||
artifacts {
|
|
||||||
// Add a 'testRuntime' configuration including the tests so that
|
|
||||||
// it can be consumed by other projects (smack-omemo-signal for
|
|
||||||
// example). See http://stackoverflow.com/a/21946676/194894
|
|
||||||
testRuntime testsJar
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocJar
|
|
||||||
artifact testsJar
|
|
||||||
pom {
|
|
||||||
name = 'Smack'
|
|
||||||
packaging = 'jar'
|
|
||||||
inceptionYear = '2003'
|
|
||||||
url = 'http://www.igniterealtime.org/projects/jxmpp/'
|
|
||||||
afterEvaluate {
|
|
||||||
description = project.description
|
|
||||||
}
|
|
||||||
|
|
||||||
issueManagement {
|
|
||||||
system = 'JIRA'
|
|
||||||
url = 'http://issues.igniterealtime.org/browse/SMACK'
|
|
||||||
}
|
|
||||||
|
|
||||||
scm {
|
|
||||||
url = 'https://github.com/igniterealtime/Smack'
|
|
||||||
connection = 'scm:git:https://github.com/igniterealtime/Smack.git'
|
|
||||||
developerConnection = 'scm:git:https://github.com/igniterealtime/Smack.git'
|
|
||||||
}
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
if (project in gplLicensedProjects) {
|
|
||||||
license {
|
|
||||||
name = 'GNU General Public License, version 3 or any later version'
|
|
||||||
url = 'https://www.gnu.org/licenses/gpl.txt'
|
|
||||||
distribution = 'repo'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
license {
|
|
||||||
name = 'The Apache Software License, Version 2.0'
|
|
||||||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
||||||
distribution = 'repo'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = 'flow'
|
|
||||||
name = 'Florian Schmaus'
|
|
||||||
email = 'flow@igniterealtime.org'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
if (sonatypeCredentialsAvailable && useSonatype) {
|
|
||||||
maven {
|
|
||||||
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
|
|
||||||
credentials {
|
|
||||||
username = sonatypeUsername
|
|
||||||
password = sonatypePassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Use
|
|
||||||
// gradle publish -P customRepoUrl=https://www.igniterealtime.org/archiva/repository/maven -P customRepoUsername=bamboo -P customRepoPassword=hidden -P useSonatype=false
|
|
||||||
// to deploy to this repo.
|
|
||||||
if (project.hasProperty("customRepoUrl")) {
|
|
||||||
maven {
|
|
||||||
name 'customRepo'
|
|
||||||
url customRepoUrl
|
|
||||||
if (project.hasProperty("customRepoUsername")) {
|
|
||||||
credentials {
|
|
||||||
username customRepoUsername
|
|
||||||
password customRepoPassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Workaround for gpg signatory not supporting the 'required' option
|
|
||||||
// See https://github.com/gradle/gradle/issues/5064#issuecomment-381924984
|
|
||||||
// Note what we use 'signing.gnupg.keyName' instead of 'signing.keyId'.
|
|
||||||
tasks.withType(Sign) {
|
|
||||||
onlyIf {
|
|
||||||
project.hasProperty('signing.gnupg.keyName')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
signing {
|
|
||||||
required { signingRequired }
|
|
||||||
useGpgCmd()
|
|
||||||
sign publishing.publications.mavenJava
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.errorprone {
|
|
||||||
disableWarningsInGeneratedCode = true
|
|
||||||
excludedPaths = ".*/jmh_generated/.*"
|
|
||||||
error(
|
|
||||||
"UnusedVariable",
|
|
||||||
"UnusedMethod",
|
|
||||||
"MethodCanBeStatic",
|
|
||||||
)
|
|
||||||
errorproneArgs = [
|
|
||||||
// Disable MissingCasesInEnumSwitch error prone check
|
|
||||||
// because this check is already done by javac as incomplete-switch.
|
|
||||||
'-Xep:MissingCasesInEnumSwitch:OFF',
|
|
||||||
'-Xep:StringSplitter:OFF',
|
|
||||||
'-Xep:JavaTimeDefaultTimeZone:OFF',
|
|
||||||
'-Xep:InlineMeSuggester:OFF',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work around https://github.com/gradle/gradle/issues/4046
|
|
||||||
task copyJavadocDocFiles(type: Copy) {
|
|
||||||
from('src/javadoc')
|
|
||||||
into 'build/docs/javadoc'
|
|
||||||
include '**/doc-files/*.*'
|
|
||||||
}
|
|
||||||
javadoc.dependsOn copyJavadocDocFiles
|
|
||||||
|
|
||||||
def getGitCommit() {
|
|
||||||
def projectDirFile = new File("$projectDir")
|
|
||||||
|
|
||||||
def cmd = 'git describe --always --tags --dirty=+'
|
|
||||||
def proc = cmd.execute(null, projectDirFile)
|
|
||||||
|
|
||||||
def exitStatus = proc.waitFor()
|
|
||||||
if (exitStatus != 0) return "non-git build"
|
|
||||||
|
|
||||||
def gitCommit = proc.text.trim()
|
|
||||||
assert !gitCommit.isEmpty()
|
|
||||||
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()) {
|
|
||||||
throw new Exception("Could not find version file")
|
|
||||||
}
|
|
||||||
if (versionFile.text.isEmpty()) {
|
|
||||||
throw new Exception("Version file does not contain a version")
|
|
||||||
}
|
|
||||||
versionFile.text.trim()
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
plugins {
|
|
||||||
// Javadoc linking requires repositories to bet configured. And
|
|
||||||
// those are declared in global-conventions, hence we add it here.
|
|
||||||
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) {
|
|
||||||
options.charSet = "UTF-8"
|
|
||||||
}
|
|
724
build.gradle
724
build.gradle
|
@ -1,20 +1,349 @@
|
||||||
plugins {
|
buildscript {
|
||||||
// The scalastyle plugin of smack-repl wants the root project to
|
repositories {
|
||||||
// have a ideaProject task, so let's add one.
|
jcenter()
|
||||||
id 'idea'
|
maven { url 'https://plugins.gradle.org/m2/' }
|
||||||
|
maven { url 'https://dl.bintray.com/content/aalmiray/kordamp' }
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
|
||||||
|
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id 'org.igniterealtime.smack.javadoc-conventions'
|
plugins {
|
||||||
|
id 'ru.vyarus.animalsniffer' version '1.5.0'
|
||||||
|
id 'net.ltgt.errorprone' version '1.3.0'
|
||||||
|
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
|
||||||
|
id 'com.dorongold.task-tree' version '1.5'
|
||||||
|
id 'com.github.kt3k.coveralls' version '2.10.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
javadocAllDir = new File(buildDir, 'javadoc')
|
java11Projects = [
|
||||||
integrationTestProjects = [
|
':smack-examples',
|
||||||
':smack-integration-test',
|
':smack-integration-test',
|
||||||
':smack-omemo-signal-integration-test',
|
':smack-omemo-signal-integration-test',
|
||||||
].collect{ project(it) }
|
':smack-repl',
|
||||||
javadocAllProjects = subprojects - integrationTestProjects
|
':smack-websocket-java11',
|
||||||
|
].collect { project(it) }
|
||||||
|
java11Projects += getRootProject()
|
||||||
|
java8Projects = allprojects - java11Projects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configure (java8Projects) {
|
||||||
|
ext {
|
||||||
|
javaCompatilibity = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configure (java11Projects) {
|
||||||
|
ext {
|
||||||
|
javaCompatilibity = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'java-test-fixtures'
|
||||||
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'net.ltgt.errorprone'
|
||||||
|
|
||||||
|
version readVersionFile()
|
||||||
|
|
||||||
|
ext {
|
||||||
|
isSnapshot = version.endsWith('-SNAPSHOT')
|
||||||
|
gitCommit = getGitCommit()
|
||||||
|
javadocAllDir = new File(buildDir, 'javadoc')
|
||||||
|
documentationDir = new File(projectDir, 'documentation')
|
||||||
|
releasedocsDir = new File(buildDir, 'releasedocs')
|
||||||
|
rootConfigDir = new File(rootDir, 'config')
|
||||||
|
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
|
||||||
|
isReleaseVersion = !isSnapshot
|
||||||
|
isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
|
||||||
|
signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
|
||||||
|
sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||||
|
sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
||||||
|
// Returns only the date in yyyy-MM-dd format, as otherwise, with
|
||||||
|
// hh:mm:ss information, the manifest files would change with every
|
||||||
|
// build, causing unnecessary rebuilds.
|
||||||
|
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
|
||||||
|
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
|
||||||
|
integrationTestProjects = [
|
||||||
|
':smack-integration-test',
|
||||||
|
':smack-omemo-signal-integration-test',
|
||||||
|
].collect{ project(it) }
|
||||||
|
javadocAllProjects = subprojects - integrationTestProjects
|
||||||
|
// A dirty hack used for Gradle's jacoco plugin, since is not
|
||||||
|
// hable to handle the case when a (sub)project has no unit
|
||||||
|
// tests. :-(
|
||||||
|
projectsWithoutUnitTests = [
|
||||||
|
':smack-android',
|
||||||
|
':smack-android-extensions',
|
||||||
|
':smack-bosh',
|
||||||
|
':smack-debug',
|
||||||
|
':smack-debug-slf4j',
|
||||||
|
':smack-java8',
|
||||||
|
':smack-jingle-old',
|
||||||
|
':smack-resolver-dnsjava',
|
||||||
|
':smack-resolver-javax',
|
||||||
|
':smack-resolver-minidns',
|
||||||
|
':smack-omemo-signal-integration-test',
|
||||||
|
].collect{ project(it) }
|
||||||
|
projectsWithUnitTests = subprojects - projectsWithoutUnitTests
|
||||||
|
androidProjects = [
|
||||||
|
':smack-tcp',
|
||||||
|
':smack-bosh',
|
||||||
|
':smack-core',
|
||||||
|
':smack-im',
|
||||||
|
':smack-resolver-minidns',
|
||||||
|
':smack-sasl-provided',
|
||||||
|
':smack-extensions',
|
||||||
|
':smack-experimental',
|
||||||
|
':smack-omemo',
|
||||||
|
':smack-omemo-signal',
|
||||||
|
':smack-openpgp',
|
||||||
|
':smack-xmlparser',
|
||||||
|
':smack-xmlparser-xpp3',
|
||||||
|
].collect{ project(it) }
|
||||||
|
androidBootClasspathProjects = [
|
||||||
|
':smack-android',
|
||||||
|
':smack-android-extensions',
|
||||||
|
].collect{ project(it) }
|
||||||
|
androidOptionalProjects = [
|
||||||
|
':smack-tcp',
|
||||||
|
':smack-extensions',
|
||||||
|
':smack-experimental',
|
||||||
|
':smack-bosh',
|
||||||
|
':smack-omemo',
|
||||||
|
':smack-omemo-signal',
|
||||||
|
].collect{ project(it) }
|
||||||
|
gplLicensedProjects = [
|
||||||
|
':smack-examples',
|
||||||
|
':smack-omemo-signal',
|
||||||
|
':smack-omemo-signal-integration-test',
|
||||||
|
':smack-repl'
|
||||||
|
].collect{ project(it) }
|
||||||
|
// Lazily evaluate the Android bootClasspath and offline
|
||||||
|
// Javadoc using a closure, so that targets which do not
|
||||||
|
// require it are still able to succeed without an Android
|
||||||
|
// SDK.
|
||||||
|
androidBootClasspath = { getAndroidRuntimeJar() }
|
||||||
|
androidJavadocOffline = { getAndroidJavadocOffline() }
|
||||||
|
junit4Projects = [
|
||||||
|
':smack-core',
|
||||||
|
':smack-im',
|
||||||
|
':smack-omemo',
|
||||||
|
':smack-omemo-signal',
|
||||||
|
':smack-openpgp',
|
||||||
|
].collect { project(it) }
|
||||||
|
|
||||||
|
// When using dynamic versions for those, do *not* use [1.0,
|
||||||
|
// 2.0), since this will also pull in 2.0-alpha1. Instead use
|
||||||
|
// [1.0, 1.0.99].
|
||||||
|
// See also:
|
||||||
|
// - https://issues.apache.org/jira/browse/MNG-6232
|
||||||
|
// - https://issues.igniterealtime.org/browse/SMACK-858
|
||||||
|
jxmppVersion = '[1.0.0, 1.0.999]'
|
||||||
|
miniDnsVersion = '[1.0.0, 1.0.999]'
|
||||||
|
smackMinAndroidSdk = 19
|
||||||
|
junitVersion = '5.7.1'
|
||||||
|
commonsIoVersion = '2.6'
|
||||||
|
bouncyCastleVersion = '1.73'
|
||||||
|
guavaVersion = '30.1-jre'
|
||||||
|
mockitoVersion = '3.7.7'
|
||||||
|
orgReflectionsVersion = '0.9.11'
|
||||||
|
|
||||||
|
if (project.hasProperty("useSonatype")) {
|
||||||
|
useSonatype = project.getProperty("useSonatype").toBoolean()
|
||||||
|
} else {
|
||||||
|
// Default to true
|
||||||
|
useSonatype = true
|
||||||
|
}
|
||||||
|
javaMajor = javaCompatilibity.getMajorVersion()
|
||||||
|
}
|
||||||
|
group = 'org.igniterealtime.smack'
|
||||||
|
sourceCompatibility = javaCompatilibity
|
||||||
|
targetCompatibility = sourceCompatibility
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
||||||
|
|
||||||
|
// Enable full stacktraces of failed tests. Especially handy
|
||||||
|
// for environments like Travis.
|
||||||
|
testLogging {
|
||||||
|
events "failed"
|
||||||
|
exceptionFormat "full"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.sharedManifest = manifest {
|
||||||
|
attributes('Implementation-Version': version,
|
||||||
|
'Implementation-GitRevision': ext.gitCommit,
|
||||||
|
'Built-Date': ext.builtDate,
|
||||||
|
'Built-JDK': System.getProperty('java.version'),
|
||||||
|
'Built-Gradle': gradle.gradleVersion,
|
||||||
|
'Built-By': System.getProperty('user.name')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
eclipse {
|
||||||
|
classpath {
|
||||||
|
downloadJavadoc = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
// Some systems may not have set their platform default
|
||||||
|
// converter to 'utf8', but we use unicode in our source
|
||||||
|
// files. Therefore ensure that javac uses unicode
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
options.compilerArgs = [
|
||||||
|
'-Xlint:all',
|
||||||
|
// Set '-options' because a non-java7 javac will emit a
|
||||||
|
// warning if source/traget is set to 1.7 and
|
||||||
|
// bootclasspath is *not* set.
|
||||||
|
// TODO implement a sound heuristic to determine a java7
|
||||||
|
// rt.jar on the build host. And if none is found,
|
||||||
|
// fallback to using a environment variable,
|
||||||
|
// e.g. JAVA7_HOME. See SMACK-651.
|
||||||
|
'-Xlint:-options',
|
||||||
|
'-Werror',
|
||||||
|
]
|
||||||
|
options.errorprone {
|
||||||
|
error(
|
||||||
|
"UnusedVariable",
|
||||||
|
"UnusedMethod",
|
||||||
|
"MethodCanBeStatic",
|
||||||
|
)
|
||||||
|
errorproneArgs = [
|
||||||
|
// Disable errorprone checks
|
||||||
|
'-Xep:TypeParameterUnusedInFormals:OFF',
|
||||||
|
// Disable errorpone StringSplitter check, as it
|
||||||
|
// recommends using Splitter from Guava, which we don't
|
||||||
|
// have (nor want to use in Smack).
|
||||||
|
'-Xep:StringSplitter:OFF',
|
||||||
|
'-Xep:JdkObsolete:OFF',
|
||||||
|
// Disabled because sinttest re-uses BeforeClass from junit.
|
||||||
|
// TODO: change sinttest so that it has it's own
|
||||||
|
// BeforeClass and re-enable this check.
|
||||||
|
'-Xep:JUnit4ClassAnnotationNonStatic:OFF',
|
||||||
|
// Disabled but should be re-enabled at some point
|
||||||
|
//'-Xep:InconsistentCapitalization:OFF',
|
||||||
|
'-Xep:MixedMutabilityReturnType:OFF',
|
||||||
|
// TODO: Re-enable once Smack's minimum Android SDK level is 26 or higher.
|
||||||
|
'-Xep:JavaUtilDate:OFF',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(ScalaCompile) {
|
||||||
|
scalaCompileOptions.additionalParameters = [
|
||||||
|
'-Xfatal-warnings',
|
||||||
|
'-feature',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.6"
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn test
|
||||||
|
getSourceDirectories().setFrom(project.files(sourceSets.main.allSource.srcDirs))
|
||||||
|
getClassDirectories().setFrom(project.files(sourceSets.main.output))
|
||||||
|
reports {
|
||||||
|
xml.enabled true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JavaVersion.current().isJava8Compatible()) {
|
||||||
|
tasks.withType(Javadoc) {
|
||||||
|
// The '-quiet' as second argument is actually a hack,
|
||||||
|
// since the one paramater addStringOption doesn't seem to
|
||||||
|
// work, we extra add '-quiet', which is added anyway by
|
||||||
|
// gradle.
|
||||||
|
// TODO: This enables all doclint check but
|
||||||
|
// 'missing'. Re-enable 'missing' once every public API in
|
||||||
|
// Smack has a javadoc comment.
|
||||||
|
options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet')
|
||||||
|
|
||||||
|
// Treat warnings as errors.
|
||||||
|
// See also https://bugs.openjdk.java.net/browse/JDK-8200363
|
||||||
|
options.addStringOption('Xwerror', '-quiet')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JavaVersion.current().isJava9Compatible()) {
|
||||||
|
tasks.withType(Javadoc) {
|
||||||
|
options.addStringOption('-release', javaMajor)
|
||||||
|
|
||||||
|
// The -no-modules-directories javadoc option was removed in Java 13
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8215582
|
||||||
|
if (JavaVersion.current() < JavaVersion.VERSION_13) {
|
||||||
|
// Fix for javadoc search. If not set, the search result would direct to
|
||||||
|
// javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html
|
||||||
|
// instead of
|
||||||
|
// javadoc/org/jivesoftware/smack/altconnections/HttpLookupMethod.html
|
||||||
|
// https://stackoverflow.com/a/53732633/194894
|
||||||
|
options.addBooleanOption("-no-module-directories", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs.addAll([
|
||||||
|
'--release', javaMajor,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(Javadoc) {
|
||||||
|
options.charSet = "UTF-8"
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testFixturesApi "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||||
|
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
|
||||||
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
||||||
|
|
||||||
|
// The smack-extensions subproject uses mockito in its fest
|
||||||
|
// fixtures, and we want to have mockito also available in
|
||||||
|
// test, so we use API here.
|
||||||
|
testFixturesApi "org.mockito:mockito-core:${mockitoVersion}"
|
||||||
|
|
||||||
|
// To mock final classes
|
||||||
|
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
|
||||||
|
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
|
||||||
|
|
||||||
|
errorprone 'com.google.errorprone:error_prone_core:2.5.1'
|
||||||
|
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make all project's 'test' target depend on javadoc, so that
|
||||||
|
// javadoc is also linted.
|
||||||
|
test { dependsOn javadoc }
|
||||||
|
}
|
||||||
|
|
||||||
|
configure (junit4Projects) {
|
||||||
|
dependencies {
|
||||||
|
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to evaluate the child projects first because
|
||||||
|
// - javadocAll needs the smack-core child to have already resolved
|
||||||
|
// the jXMPP/MiniDNS dependencies, so that we can the resovled
|
||||||
|
// version to link to those project's javadoc.
|
||||||
|
// - We use the child's project description as description for the
|
||||||
|
// Maven POM.
|
||||||
evaluationDependsOnChildren()
|
evaluationDependsOnChildren()
|
||||||
task javadocAll(type: Javadoc) {
|
task javadocAll(type: Javadoc) {
|
||||||
source javadocAllProjects.collect {project ->
|
source javadocAllProjects.collect {project ->
|
||||||
|
@ -63,6 +392,315 @@ task javadocAll(type: Javadoc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
|
task prepareReleasedocs(type: Copy) {
|
||||||
|
from 'resources/releasedocs'
|
||||||
|
into releasedocsDir
|
||||||
|
filter(ReplaceTokens, tokens: [version: version, releasedate: builtDate, targetCompatibility: targetCompatibility.toString()])
|
||||||
|
}
|
||||||
|
|
||||||
|
task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs]) {
|
||||||
|
classifier builtDate
|
||||||
|
into ('javadoc') {
|
||||||
|
from(javadocAllDir)
|
||||||
|
}
|
||||||
|
into ('releasedocs') {
|
||||||
|
from(releasedocsDir)
|
||||||
|
}
|
||||||
|
into ('releasedocs/documentation') {
|
||||||
|
from(documentationDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task maybeCheckForSnapshotDependencies {
|
||||||
|
// Don't check for Snapshot dependencies if this is a snapshot.
|
||||||
|
onlyIf { isReleaseVersion }
|
||||||
|
// Run in the execution phase, not in configuration phase, as the
|
||||||
|
// 'each' forces the runtime configuration to be resovled, which
|
||||||
|
// causes "Cannot change dependencies of configuration after it
|
||||||
|
// has been included in dependency resolution." errors.
|
||||||
|
// See https://discuss.gradle.org/t/23153
|
||||||
|
doLast {
|
||||||
|
allprojects { project ->
|
||||||
|
project.configurations.runtime.each {
|
||||||
|
if (it.toString().contains("-SNAPSHOT"))
|
||||||
|
throw new Exception("Release build contains snapshot dependencies: " + it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test { dependsOn maybeCheckForSnapshotDependencies }
|
||||||
|
|
||||||
|
jar {
|
||||||
|
// Root project should not create empty jar artifact
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable upload archives for the root project
|
||||||
|
uploadArchives.enabled = false
|
||||||
|
|
||||||
|
description = """\
|
||||||
|
Smack ${version}
|
||||||
|
${oneLineDesc}."""
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'signing'
|
||||||
|
apply plugin: 'checkstyle'
|
||||||
|
apply plugin: 'org.kordamp.gradle.clirr'
|
||||||
|
apply plugin: 'biz.aQute.bnd.builder'
|
||||||
|
|
||||||
|
checkstyle {
|
||||||
|
toolVersion = '8.27'
|
||||||
|
}
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
classifier = 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
from javadoc.destinationDir
|
||||||
|
}
|
||||||
|
task testsJar(type: Jar, dependsOn: testClasses) {
|
||||||
|
classifier = 'tests'
|
||||||
|
from sourceSets.test.output
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
// See http://stackoverflow.com/a/21946676/194894
|
||||||
|
testRuntime testsJar
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
artifact sourcesJar
|
||||||
|
artifact javadocJar
|
||||||
|
artifact testsJar
|
||||||
|
pom {
|
||||||
|
name = 'Smack'
|
||||||
|
packaging = 'jar'
|
||||||
|
inceptionYear = '2003'
|
||||||
|
url = 'http://www.igniterealtime.org/projects/smack/'
|
||||||
|
description = project.description
|
||||||
|
|
||||||
|
issueManagement {
|
||||||
|
system = 'JIRA'
|
||||||
|
url = 'https://igniterealtime.org/issues/browse/SMACK'
|
||||||
|
}
|
||||||
|
|
||||||
|
scm {
|
||||||
|
url = 'https://github.com/igniterealtime/Smack'
|
||||||
|
connection = 'scm:git:https://github.com/igniterealtime/Smack.git'
|
||||||
|
developerConnection = 'scm:git:https://github.com/igniterealtime/Smack.git'
|
||||||
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = 'flow'
|
||||||
|
name = 'Florian Schmaus'
|
||||||
|
email = 'flow@igniterealtime.org'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
if (sonatypeCredentialsAvailable && useSonatype) {
|
||||||
|
maven {
|
||||||
|
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
|
||||||
|
credentials {
|
||||||
|
username = sonatypeUsername
|
||||||
|
password = sonatypePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use
|
||||||
|
// gradle publish -P customRepoUrl=https://www.igniterealtime.org/archiva/repository/maven -P customRepoUsername=bamboo -P customRepoPassword=hidden -P useSonatype=false
|
||||||
|
// to deploy to this repo.
|
||||||
|
if (project.hasProperty("customRepoUrl")) {
|
||||||
|
maven {
|
||||||
|
name 'customRepo'
|
||||||
|
url customRepoUrl
|
||||||
|
if (project.hasProperty("customRepoUsername")) {
|
||||||
|
credentials {
|
||||||
|
username customRepoUsername
|
||||||
|
password customRepoPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.distributionZip {
|
||||||
|
dependsOn build
|
||||||
|
from(buildDir) {
|
||||||
|
include "$libsDirName/*${version}.jar"
|
||||||
|
include "$libsDirName/*${version}-javadoc.jar"
|
||||||
|
include "$libsDirName/*${version}-sources.jar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for gpg signatory not supporting the 'required' option
|
||||||
|
// See https://github.com/gradle/gradle/issues/5064#issuecomment-381924984
|
||||||
|
// Note what we use 'signing.gnupg.keyName' instead of 'signing.keyId'.
|
||||||
|
tasks.withType(Sign) {
|
||||||
|
onlyIf {
|
||||||
|
project.hasProperty('signing.gnupg.keyName')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
signing {
|
||||||
|
useGpgCmd()
|
||||||
|
required { signingRequired }
|
||||||
|
sign publishing.publications.mavenJava
|
||||||
|
}
|
||||||
|
|
||||||
|
clirr {
|
||||||
|
// 2018-08-14: Disabled Clirr because
|
||||||
|
// - It reports an breaking change in android.jar (seems right, but there is nothing we can do about it)
|
||||||
|
// - Only the first smack-* projects are correctly checked,
|
||||||
|
// the other ones have the output of a clirr report from a previous project
|
||||||
|
// (Look at the clirr reports).
|
||||||
|
enabled false
|
||||||
|
semver false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around https://github.com/gradle/gradle/issues/4046
|
||||||
|
task copyJavadocDocFiles(type: Copy) {
|
||||||
|
from('src/javadoc')
|
||||||
|
into 'build/docs/javadoc'
|
||||||
|
include '**/doc-files/*.*'
|
||||||
|
}
|
||||||
|
javadoc.dependsOn copyJavadocDocFiles
|
||||||
|
|
||||||
|
// Make sure root projects 'javadocAll' depends on the
|
||||||
|
// subproject's javadoc, to ensure that all all doc-files/ are
|
||||||
|
// generated and up-to-date. Obviously this means that the
|
||||||
|
// javadocAll task will also create the individual javadoc's of the
|
||||||
|
// subprojects.
|
||||||
|
javadocAll.dependsOn javadoc
|
||||||
|
}
|
||||||
|
|
||||||
|
// The smack-java8-full project generates the dot and png files of the
|
||||||
|
// current state graph. Ensure they are generated before copied.
|
||||||
|
configure (project(':smack-java8-full')) {
|
||||||
|
copyJavadocDocFiles.dependsOn convertModularXmppClientToServerConnectionStateGraphDotToPng
|
||||||
|
}
|
||||||
|
|
||||||
|
configure (androidProjects + androidBootClasspathProjects) {
|
||||||
|
apply plugin: 'ru.vyarus.animalsniffer'
|
||||||
|
dependencies {
|
||||||
|
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:4.4.2_r4@signature"
|
||||||
|
}
|
||||||
|
animalsniffer {
|
||||||
|
sourceSets = [sourceSets.main]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is no need to ever clirr integration test projects and the
|
||||||
|
// smack-repl project.
|
||||||
|
configure(integrationTestProjects + project(':smack-repl')) {
|
||||||
|
clirr {
|
||||||
|
enabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable clirr on omemo modules
|
||||||
|
project(':smack-omemo').clirr.enabled = false
|
||||||
|
project(':smack-omemo-signal').clirr.enabled = false
|
||||||
|
|
||||||
|
subprojects*.jar {
|
||||||
|
manifest {
|
||||||
|
from sharedManifest
|
||||||
|
}
|
||||||
|
bundle {
|
||||||
|
bnd(
|
||||||
|
'-removeheaders': 'Tool, Bnd-*',
|
||||||
|
'-exportcontents': '*',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(subprojects - gplLicensedProjects) {
|
||||||
|
checkstyle {
|
||||||
|
configProperties.checkstyleLicenseHeader = "header"
|
||||||
|
}
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
pom {
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = 'The Apache Software License, Version 2.0'
|
||||||
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
distribution = 'repo'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(gplLicensedProjects) {
|
||||||
|
checkstyle {
|
||||||
|
configProperties.checkstyleLicenseHeader = "${project.name}-gplv3-license-header"
|
||||||
|
}
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
pom {
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = 'GNU General Public License, version 3 or any later version'
|
||||||
|
url = 'https://www.gnu.org/licenses/gpl.txt'
|
||||||
|
distribution = 'repo'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(androidBootClasspathProjects) {
|
||||||
|
compileJava {
|
||||||
|
options.bootstrapClasspath = files(androidBootClasspath)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
classpath += files(androidBootClasspath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: "com.github.kt3k.coveralls"
|
||||||
|
coveralls {
|
||||||
|
sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
|
||||||
|
dependsOn = projectsWithUnitTests.jacocoTestReport
|
||||||
|
getSourceDirectories().setFrom(files(projectsWithUnitTests.sourceSets.main.allSource.srcDirs))
|
||||||
|
getClassDirectories().setFrom(files(projectsWithUnitTests.sourceSets.main.output))
|
||||||
|
getExecutionData().setFrom(files(projectsWithUnitTests.jacocoTestReport.executionData))
|
||||||
|
reports {
|
||||||
|
xml.enabled true
|
||||||
|
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
|
||||||
|
}
|
||||||
|
// We could remove the following setOnlyIf line, but then
|
||||||
|
// jacocoRootReport would silently be SKIPPED if something with
|
||||||
|
// the projectsWithUnitTests is wrong (e.g. a project is missing
|
||||||
|
// in there).
|
||||||
|
setOnlyIf { true }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Important to specify this task after the subprojects block
|
||||||
|
task clirrRootReport(type: org.kordamp.gradle.clirr.ClirrReportTask) {
|
||||||
|
dependsOn = subprojects.tasks.clirr
|
||||||
|
reports = files((subprojects.findAll { it.clirr.enabled == true }).tasks.clirr.xmlReport)
|
||||||
|
}
|
||||||
|
|
||||||
task integrationTest {
|
task integrationTest {
|
||||||
description 'Verify correct functionality of Smack by running some integration tests.'
|
description 'Verify correct functionality of Smack by running some integration tests.'
|
||||||
dependsOn project(':smack-integration-test').tasks.run
|
dependsOn project(':smack-integration-test').tasks.run
|
||||||
|
@ -70,7 +708,7 @@ task integrationTest {
|
||||||
|
|
||||||
task omemoSignalIntTest {
|
task omemoSignalIntTest {
|
||||||
description 'Run integration tests of the smack-omemo module in combination with smack-omemo-signal.'
|
description 'Run integration tests of the smack-omemo module in combination with smack-omemo-signal.'
|
||||||
dependsOn 'smack-omemo-signal-integration-test:run'
|
dependsOn project(':smack-omemo-signal-integration-test').tasks.run
|
||||||
}
|
}
|
||||||
|
|
||||||
task sinttestAll {
|
task sinttestAll {
|
||||||
|
@ -81,6 +719,70 @@ task sinttestAll {
|
||||||
]}
|
]}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getGitCommit() {
|
||||||
|
def projectDirFile = new File("$projectDir")
|
||||||
|
def dotGit = new File(projectDirFile, ".git")
|
||||||
|
if (!dotGit.isDirectory()) return 'non-git build'
|
||||||
|
|
||||||
|
def cmd = 'git describe --always --tags --dirty=+'
|
||||||
|
def proc = cmd.execute(null, projectDirFile)
|
||||||
|
proc.waitForOrKill(10 * 1000)
|
||||||
|
|
||||||
|
def gitCommit = proc.text.trim()
|
||||||
|
assert !gitCommit.isEmpty()
|
||||||
|
|
||||||
|
def srCmd = 'git symbolic-ref --short HEAD'
|
||||||
|
def srProc = srCmd.execute(null, projectDirFile)
|
||||||
|
srProc.waitForOrKill(10 * 1000)
|
||||||
|
if (srProc.exitValue() == 0) {
|
||||||
|
// Only add the information if the git command was
|
||||||
|
// successful. There may be no symbolic reference for HEAD if
|
||||||
|
// e.g. in detached mode.
|
||||||
|
def symbolicReference = srProc.text.trim()
|
||||||
|
assert !symbolicReference.isEmpty()
|
||||||
|
gitCommit += "-$symbolicReference"
|
||||||
|
}
|
||||||
|
|
||||||
|
gitCommit
|
||||||
|
}
|
||||||
|
|
||||||
|
def getAndroidRuntimeJar() {
|
||||||
|
def androidApiLevel = ext.smackMinAndroidSdk
|
||||||
|
def androidHome = getAndroidHome()
|
||||||
|
def androidJar = new File("$androidHome/platforms/android-${androidApiLevel}/android.jar")
|
||||||
|
if (androidJar.isFile()) {
|
||||||
|
return androidJar
|
||||||
|
} else {
|
||||||
|
throw new Exception("Can't find android.jar for API level ${androidApiLevel}. Please install corresponding SDK platform package")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getAndroidJavadocOffline() {
|
||||||
|
def androidHome = getAndroidHome()
|
||||||
|
return androidHome.toString() + "/docs/reference"
|
||||||
|
}
|
||||||
|
|
||||||
|
def getAndroidHome() {
|
||||||
|
def androidHomeEnv = System.getenv("ANDROID_HOME")
|
||||||
|
if (androidHomeEnv == null) {
|
||||||
|
throw new Exception("ANDROID_HOME environment variable is not set")
|
||||||
|
}
|
||||||
|
def androidHome = new File(androidHomeEnv)
|
||||||
|
if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
|
||||||
|
return androidHome
|
||||||
|
}
|
||||||
|
|
||||||
|
def readVersionFile() {
|
||||||
|
def versionFile = new File(rootDir, 'version')
|
||||||
|
if (!versionFile.isFile()) {
|
||||||
|
throw new Exception("Could not find version file")
|
||||||
|
}
|
||||||
|
if (versionFile.text.isEmpty()) {
|
||||||
|
throw new Exception("Version file does not contain a version")
|
||||||
|
}
|
||||||
|
versionFile.text.trim()
|
||||||
|
}
|
||||||
|
|
||||||
def getResolvedVersion(queriedProject = 'smack-core', component) {
|
def getResolvedVersion(queriedProject = 'smack-core', component) {
|
||||||
def configuration = project(queriedProject)
|
def configuration = project(queriedProject)
|
||||||
.configurations
|
.configurations
|
||||||
|
@ -91,7 +793,7 @@ def getResolvedVersion(queriedProject = 'smack-core', component) {
|
||||||
.resolvedArtifacts
|
.resolvedArtifacts
|
||||||
.findAll {
|
.findAll {
|
||||||
// 'it' is of type ResolvedArtifact, 'id' of
|
// 'it' is of type ResolvedArtifact, 'id' of
|
||||||
// Component*Artifact*Identifier, and we check the
|
// Component*Artifcat*Identifier, and we check the
|
||||||
// ComponentIdentifier.
|
// ComponentIdentifier.
|
||||||
it.id.getComponentIdentifier() instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier
|
it.id.getComponentIdentifier() instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# Workaround for https://github.com/CycloneDX/cyclonedx-gradle-plugin/issues/349
|
|
||||||
# suggested at https://docs.gradle.org/current/userguide/upgrading_version_8.html#xml_parsing_now_requires_recent_parsers
|
|
||||||
systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
|
|
||||||
systemProp.javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
|
|
||||||
systemProp.javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||||
networkTimeout=10000
|
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
285
gradlew
vendored
285
gradlew
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
@ -15,104 +15,69 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
# This is normally unused
|
APP_NAME="Gradle"
|
||||||
# shellcheck disable=SC2034
|
APP_BASE_NAME=`basename "$0"`
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
@ -122,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
@ -133,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
if ! command -v java >/dev/null 2>&1
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
# shellcheck disable=SC2039,SC3045
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
fi
|
||||||
warn "Could not query maximum file descriptor limit"
|
ulimit -n $MAX_FD
|
||||||
esac
|
if [ $? -ne 0 ] ; then
|
||||||
case $MAX_FD in #(
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
'' | soft) :;; #(
|
fi
|
||||||
*)
|
else
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
# shellcheck disable=SC2039,SC3045
|
fi
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
for arg do
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
if
|
SEP=""
|
||||||
case $arg in #(
|
for dir in $ROOTDIRSRAW ; do
|
||||||
-*) false ;; # don't mess with options #(
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
SEP="|"
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
||||||
# and any embedded shellness will be escaped.
|
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
37
gradlew.bat
vendored
37
gradlew.bat
vendored
|
@ -13,10 +13,8 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -27,8 +25,7 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -59,11 +56,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -78,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
11
repl
11
repl
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -e
|
||||||
|
set -u
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
JDWP=false
|
JDWP=false
|
||||||
JDWP_PORT=8000
|
JDWP_PORT=8000
|
||||||
|
@ -35,13 +37,12 @@ echo "Compiling and computing classpath (May take a while)"
|
||||||
# /smack/smack-repl/build/classes/main:/smack/smack-repl/build/
|
# /smack/smack-repl/build/classes/main:/smack/smack-repl/build/
|
||||||
# resources/main:/smack/smack-tcp/build/libs/smack-tcp-4.2.0-alpha4-SNAPSHOT.jar
|
# resources/main:/smack/smack-tcp/build/libs/smack-tcp-4.2.0-alpha4-SNAPSHOT.jar
|
||||||
# So perform a "tail -n1" on the output of gradle
|
# So perform a "tail -n1" on the output of gradle
|
||||||
GRADLE_CLASSPATH="$(${GRADLE_BIN:-./gradlew} :smack-repl:printClasspath --quiet |\
|
GRADLE_CLASSPATH="$(gradle :smack-repl:printClasspath --quiet |\
|
||||||
tail -n1)"
|
tail -n1)"
|
||||||
echo "Finished, starting REPL"
|
echo "Finished, starting REPL"
|
||||||
|
|
||||||
exec java \
|
java "${EXTRA_JAVA_ARGS[@]}" \
|
||||||
"${EXTRA_JAVA_ARGS[@]}" \
|
|
||||||
-Dscala.usejavacp=true \
|
-Dscala.usejavacp=true \
|
||||||
-classpath "${GRADLE_CLASSPATH}" \
|
-classpath "${GRADLE_CLASSPATH}" \
|
||||||
ammonite.Main \
|
ammonite.Main \
|
||||||
--predef smack-repl/scala.repl
|
--predef "smack-repl/scala.repl"
|
||||||
|
|
|
@ -29,7 +29,7 @@ SMACK_EXCEPTIONS[SmackException]="if Smack detected an exceptional situation."
|
||||||
SMACK_EXCEPTIONS[XMPPException]="if an XMPP protocol error was received."
|
SMACK_EXCEPTIONS[XMPPException]="if an XMPP protocol error was received."
|
||||||
SMACK_EXCEPTIONS[SmackSaslException]="if a SASL specific error occurred."
|
SMACK_EXCEPTIONS[SmackSaslException]="if a SASL specific error occurred."
|
||||||
SMACK_EXCEPTIONS[SASLErrorException]="if a SASL protocol error was returned."
|
SMACK_EXCEPTIONS[SASLErrorException]="if a SASL protocol error was returned."
|
||||||
SMACK_EXCEPTIONS[NotAMucServiceException]="if the entity is not a MUC service."
|
SMACK_EXCEPTIONS[NotAMucServiceException]="if the entity is not a MUC serivce."
|
||||||
SMACK_EXCEPTIONS[NoSuchAlgorithmException]="if no such algorithm is available."
|
SMACK_EXCEPTIONS[NoSuchAlgorithmException]="if no such algorithm is available."
|
||||||
SMACK_EXCEPTIONS[KeyManagementException]="if there was a key mangement error."
|
SMACK_EXCEPTIONS[KeyManagementException]="if there was a key mangement error."
|
||||||
SMACK_EXCEPTIONS[XmppStringprepException]="if the provided string is invalid."
|
SMACK_EXCEPTIONS[XmppStringprepException]="if the provided string is invalid."
|
||||||
|
@ -53,7 +53,7 @@ SMACK_EXCEPTIONS[Exception]="if an exception occurred."
|
||||||
SMACK_EXCEPTIONS[TestNotPossibleException]="if the test is not possible."
|
SMACK_EXCEPTIONS[TestNotPossibleException]="if the test is not possible."
|
||||||
SMACK_EXCEPTIONS[TimeoutException]="if there was a timeout."
|
SMACK_EXCEPTIONS[TimeoutException]="if there was a timeout."
|
||||||
SMACK_EXCEPTIONS[IllegalStateException]="if an illegal state was encountered"
|
SMACK_EXCEPTIONS[IllegalStateException]="if an illegal state was encountered"
|
||||||
SMACK_EXCEPTIONS[NoSuchPaddingException]="if the requested padding mechanism is not available."
|
SMACK_EXCEPTIONS[NoSuchPaddingException]="if the requested padding mechanism is not availble."
|
||||||
SMACK_EXCEPTIONS[BadPaddingException]="if the input data is not padded properly."
|
SMACK_EXCEPTIONS[BadPaddingException]="if the input data is not padded properly."
|
||||||
SMACK_EXCEPTIONS[InvalidKeyException]="if the key is invalid."
|
SMACK_EXCEPTIONS[InvalidKeyException]="if the key is invalid."
|
||||||
SMACK_EXCEPTIONS[IllegalBlockSizeException]="if the input data length is incorrect."
|
SMACK_EXCEPTIONS[IllegalBlockSizeException]="if the input data length is incorrect."
|
||||||
|
|
|
@ -15,7 +15,7 @@ for p in $SUBPROJECTS; do
|
||||||
sort | \
|
sort | \
|
||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
uniq | \
|
uniq | \
|
||||||
# Split multi Copyright statements, e.g. "2001-2013 FooBar, 2014 Baz"
|
# Split multi Copyright statemtents, e.g. "2001-2013 FooBar, 2014 Baz"
|
||||||
tr ',' '\n' | \
|
tr ',' '\n' | \
|
||||||
# Remove whitespaces resulting from the previous split
|
# Remove whitespaces resulting from the previous split
|
||||||
sed "s/^[ \t]*//" | \
|
sed "s/^[ \t]*//" | \
|
||||||
|
|
221
resources/releasedocs/README.html
Normal file
221
resources/releasedocs/README.html
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Smack Readme</title>
|
||||||
|
<style type="text/css">
|
||||||
|
/* global font and body settings */
|
||||||
|
body {
|
||||||
|
font-size : 100%;
|
||||||
|
background-color : #d3d6d9;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 0 30px 0;
|
||||||
|
}
|
||||||
|
body, td, th {
|
||||||
|
font-family : arial, helvetica, sans-serif;
|
||||||
|
font-size : 10pt;
|
||||||
|
}
|
||||||
|
pre, tt, code {
|
||||||
|
font-family : courier new, monospace;
|
||||||
|
font-size : 9pt;
|
||||||
|
}
|
||||||
|
#pageContainer {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
clear: both;
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #999;
|
||||||
|
padding: 40px;
|
||||||
|
margin: 30px;
|
||||||
|
-moz-border-radius: 6px;
|
||||||
|
}
|
||||||
|
#pageHeader {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
height: 80px;
|
||||||
|
background-color: #e7eaee;
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
border-bottom: none;
|
||||||
|
-moz-border-radius: 5px 5px 0 0;
|
||||||
|
margin: 10px 0 0 0;
|
||||||
|
}
|
||||||
|
#pageBody {
|
||||||
|
margin: 0 18px 0 20px;
|
||||||
|
}
|
||||||
|
/* anchors */
|
||||||
|
a:link {
|
||||||
|
color: #11568c;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: #571c8d;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #7a1d42;
|
||||||
|
text-decoration : underline;
|
||||||
|
}
|
||||||
|
a:active {
|
||||||
|
color: #7a1d42;
|
||||||
|
}
|
||||||
|
/* page header elements (logo and navigation) */
|
||||||
|
.navigation {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
height: 20px;
|
||||||
|
background-color: #335588;
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
border-top: none;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 18px;
|
||||||
|
padding: 0 0 0 0;
|
||||||
|
margin: 0 0 25px 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.navigation a {
|
||||||
|
margin: 0 20px 0 20px;
|
||||||
|
}
|
||||||
|
.navigation a:link { color: #ffffff; }
|
||||||
|
.navigation a:visited { color: #ffffff; }
|
||||||
|
.navigation a:hover { color: #ffffff; }
|
||||||
|
.navigation a:active { color: #ffffff; }
|
||||||
|
/* headings */
|
||||||
|
h1 {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
font-size : 1.7em;
|
||||||
|
font-weight : bold;
|
||||||
|
color: #670e15;
|
||||||
|
padding: 0;
|
||||||
|
margin: 30px 0 0 20px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size : 1.3em;
|
||||||
|
font-weight : bold;
|
||||||
|
margin: 40px 0 6px 0;
|
||||||
|
padding: 0;
|
||||||
|
color: #335588;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-size : 1.0em;
|
||||||
|
font-weight : bold;
|
||||||
|
margin: 25px 0 3px 0;
|
||||||
|
padding: 0;
|
||||||
|
color: #334466;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* general elements */
|
||||||
|
p {
|
||||||
|
margin: 0 0 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
margin: 5px 0 15px 15px;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
padding-bottom : 4px;
|
||||||
|
}
|
||||||
|
tt {
|
||||||
|
font-family : courier new, monospace;
|
||||||
|
font-weight : bold;
|
||||||
|
color : #060;
|
||||||
|
}
|
||||||
|
hr {
|
||||||
|
display: block;
|
||||||
|
height: 1px;
|
||||||
|
background-color: #999999;
|
||||||
|
border: none;
|
||||||
|
margin: 40px 0 20px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="pageContainer">
|
||||||
|
|
||||||
|
<div id="pageHeader">
|
||||||
|
<h1>Smack Readme</h1>
|
||||||
|
</div>
|
||||||
|
<div class="navigation">
|
||||||
|
<a href="README.html">Readme</a>|<a href="changelog.html"><strong>Changelog</strong></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pageBody">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<table border=0>
|
||||||
|
<tr>
|
||||||
|
<td align="right">version:</td>
|
||||||
|
<td><b>@version@</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">released:</td>
|
||||||
|
<td><b>@releasedate@</b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Thank you for downloading Smack! This version of Smack is compatible
|
||||||
|
with JVMs @targetCompatibility@ or higher. Using a build system which
|
||||||
|
is able to consume Maven artifacts, like gradle or Maven, is highly
|
||||||
|
recommended when using Smack.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>This is not the real README.</b> Please visit
|
||||||
|
<center>
|
||||||
|
<a href="https://www.igniterealtime.org/projects/smack/readme">https://www.igniterealtime.org/projects/smack/readme</a>
|
||||||
|
</center>
|
||||||
|
for the README of the current stable Smack version.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Smack tries to depend on as few as possible libraries. The only
|
||||||
|
requirement is <a href="http://jxmpp.org">jXMPP</a>. For DNS
|
||||||
|
resolution we recommend to
|
||||||
|
use <a href="http://minidns.org">MiniDNS</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Start off by viewing the <a href="documentation/index.html">documentation</a>
|
||||||
|
that can be found in the "documentation" directory included with this distribution.
|
||||||
|
</p>
|
||||||
|
Further information can be found on the <a href="http://www.igniterealtime.org/projects/smack">
|
||||||
|
Smack website</a>. If you need help using or would like to make contributions or
|
||||||
|
fixes to the code, please visit the
|
||||||
|
<a href="https://community.igniterealtime.org">online forum</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><b>Changelog and Upgrading</b><p>
|
||||||
|
|
||||||
|
View the <a href="changelog.html">changelog</a> for a list of changes since the
|
||||||
|
last release.
|
||||||
|
|
||||||
|
<p><b>License Agreements</b><p>
|
||||||
|
<ul>
|
||||||
|
<li>Use of the Smack source code is governed by the Apache License Version 2.0:
|
||||||
|
<pre>
|
||||||
|
Copyright 2002-2008 Jive Software.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
</pre></li>
|
||||||
|
|
||||||
|
<li>Smack contains icons and images licensed from INCORS GmbH. You are not licensed
|
||||||
|
to use these icons outside of Smack.</li>
|
||||||
|
|
||||||
|
<li>Third-party source code is licensed as noted in their source files.
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,7 +1,3 @@
|
||||||
pluginManagement {
|
|
||||||
includeBuild('build-logic')
|
|
||||||
}
|
|
||||||
|
|
||||||
// The name of the root project.
|
// The name of the root project.
|
||||||
// If we would not set the name, then gradle would use the directory
|
// If we would not set the name, then gradle would use the directory
|
||||||
// name of the root directory
|
// name of the root directory
|
||||||
|
@ -27,8 +23,8 @@ include 'smack-core',
|
||||||
'smack-bosh',
|
'smack-bosh',
|
||||||
'smack-android',
|
'smack-android',
|
||||||
'smack-android-extensions',
|
'smack-android-extensions',
|
||||||
'smack-java11',
|
'smack-java8',
|
||||||
'smack-java11-full',
|
'smack-java8-full',
|
||||||
'smack-integration-test',
|
'smack-integration-test',
|
||||||
'smack-omemo',
|
'smack-omemo',
|
||||||
'smack-omemo-signal',
|
'smack-omemo-signal',
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
plugins {
|
|
||||||
id 'org.igniterealtime.smack.java-common-conventions'
|
|
||||||
id 'org.igniterealtime.smack.android-conventions'
|
|
||||||
id 'org.igniterealtime.smack.android-boot-classpath-conventions'
|
|
||||||
}
|
|
||||||
|
|
||||||
description = """\
|
description = """\
|
||||||
Extra Smack extensions for Android."""
|
Extra Smack extensions for Android."""
|
||||||
|
|
||||||
|
@ -14,5 +8,5 @@ dependencies {
|
||||||
api project(':smack-extensions')
|
api project(':smack-extensions')
|
||||||
|
|
||||||
// Add the Android jar to the Eclipse .classpath.
|
// Add the Android jar to the Eclipse .classpath.
|
||||||
implementation files(androidBootClasspath)
|
compileClasspath files(androidBootClasspath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
../../../../../../../smack-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2024 Florian Schmaus
|
* Copyright © 2014-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.
|
||||||
|
@ -36,7 +36,6 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +121,6 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
|
|
||||||
private static final BroadcastReceiver ALARM_BROADCAST_RECEIVER = new BroadcastReceiver() {
|
private static final BroadcastReceiver ALARM_BROADCAST_RECEIVER = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("LockOnNonEnclosingClassLiteral")
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
LOGGER.fine("Ping Alarm broadcast received");
|
LOGGER.fine("Ping Alarm broadcast received");
|
||||||
Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
|
Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
|
||||||
|
@ -165,7 +163,7 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
private static AlarmManager sAlarmManager;
|
private static AlarmManager sAlarmManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a pending intent with the AlarmManager to be broadcast every half hour and
|
* Register a pending intent with the AlarmManager to be broadcasted every half hour and
|
||||||
* register the alarm broadcast receiver to receive this intent. The receiver will check all
|
* register the alarm broadcast receiver to receive this intent. The receiver will check all
|
||||||
* known questions if a ping is Necessary when invoked by the alarm intent.
|
* known questions if a ping is Necessary when invoked by the alarm intent.
|
||||||
*
|
*
|
||||||
|
@ -175,11 +173,7 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
sContext = context;
|
sContext = context;
|
||||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
||||||
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
int pendingIntentFlags = 0;
|
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), 0);
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
|
||||||
pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE;
|
|
||||||
}
|
|
||||||
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), pendingIntentFlags);
|
|
||||||
sAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
sAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR,
|
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR,
|
||||||
AlarmManager.INTERVAL_HALF_HOUR, sPendingIntent);
|
AlarmManager.INTERVAL_HALF_HOUR, sPendingIntent);
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
plugins {
|
|
||||||
id 'org.igniterealtime.smack.java-common-conventions'
|
|
||||||
id 'org.igniterealtime.smack.android-conventions'
|
|
||||||
id 'org.igniterealtime.smack.android-boot-classpath-conventions'
|
|
||||||
}
|
|
||||||
|
|
||||||
description = """\
|
description = """\
|
||||||
Smack for Android.
|
Smack for Android.
|
||||||
All the required dependencies to run Smack on Android.
|
All the required dependencies to run Smack on Android.
|
||||||
|
@ -22,13 +16,13 @@ dependencies {
|
||||||
// used in non-Android projects.
|
// used in non-Android projects.
|
||||||
implementation "org.minidns:minidns-android21:$miniDnsVersion"
|
implementation "org.minidns:minidns-android21:$miniDnsVersion"
|
||||||
|
|
||||||
api project(':smack-core')
|
// androidProjects lists all projects that are checked to compile against android.jar
|
||||||
api project(':smack-im')
|
// Filter out the optional Smack dependencies from androidProjects
|
||||||
api project(':smack-resolver-minidns')
|
(androidProjects - androidOptionalProjects)
|
||||||
api project(':smack-sasl-provided')
|
.each { project ->
|
||||||
api project(':smack-xmlparser')
|
api project
|
||||||
api project(':smack-xmlparser-xpp3')
|
}
|
||||||
|
|
||||||
// Add the Android jar to the Eclipse .classpath.
|
// Add the Android jar to the Eclipse .classpath.
|
||||||
implementation files(androidBootClasspath)
|
compileClasspath files(androidBootClasspath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ import org.minidns.dnsserverlookup.android21.AndroidUsingLinkProperties;
|
||||||
public class AndroidSmackInitializer implements SmackInitializer {
|
public class AndroidSmackInitializer implements SmackInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Android deprecated StrictHostnameVerifier in API level 22
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public List<Exception> initialize() {
|
public List<Exception> initialize() {
|
||||||
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
|
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
|
||||||
Base64.setEncoder(AndroidBase64Encoder.INSTANCE);
|
Base64.setEncoder(AndroidBase64Encoder.INSTANCE);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import android.util.Log;
|
||||||
* implementation, therefore {@link org.jivesoftware.smack.debugger.JulDebugger} is preferred.
|
* implementation, therefore {@link org.jivesoftware.smack.debugger.JulDebugger} is preferred.
|
||||||
* </p>
|
* </p>
|
||||||
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
||||||
* packets by Smack. By default,interpreted packets won't be printed. To enable this feature
|
* packets by Smack. By default interpreted packets won't be printed. To enable this feature
|
||||||
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
../../../../../../../smack-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -1,8 +1,3 @@
|
||||||
plugins {
|
|
||||||
id 'org.igniterealtime.smack.java-common-conventions'
|
|
||||||
id 'org.igniterealtime.smack.android-conventions'
|
|
||||||
}
|
|
||||||
|
|
||||||
description = """\
|
description = """\
|
||||||
Smack BOSH API.
|
Smack BOSH API.
|
||||||
This API is considered beta quality."""
|
This API is considered beta quality."""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
plugins {
|
// Note that this is also declared in the main build.gradle for
|
||||||
id 'org.igniterealtime.smack.java-common-conventions'
|
// subprojects, but since evaluationDependsOnChildren is enabled we
|
||||||
id 'org.igniterealtime.smack.android-conventions'
|
// need to declare it here too to have bundle{bnd{...}} available
|
||||||
}
|
apply plugin: 'biz.aQute.bnd.builder'
|
||||||
|
|
||||||
description = """\
|
description = """\
|
||||||
Smack core components."""
|
Smack core components."""
|
||||||
|
@ -16,9 +16,6 @@ dependencies {
|
||||||
api "org.jxmpp:jxmpp-jid:$jxmppVersion"
|
api "org.jxmpp:jxmpp-jid:$jxmppVersion"
|
||||||
api "org.minidns:minidns-core:$miniDnsVersion"
|
api "org.minidns:minidns-core:$miniDnsVersion"
|
||||||
|
|
||||||
// TODO: Migrate Junit4 tests to Junit5.
|
|
||||||
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
|
|
||||||
|
|
||||||
testFixturesImplementation project(':smack-xmlparser-stax')
|
testFixturesImplementation project(':smack-xmlparser-stax')
|
||||||
testFixturesImplementation project(':smack-xmlparser-xpp3')
|
testFixturesImplementation project(':smack-xmlparser-xpp3')
|
||||||
|
|
||||||
|
@ -31,7 +28,7 @@ dependencies {
|
||||||
|
|
||||||
testFixturesApi "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
|
testFixturesApi "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
|
||||||
testFixturesApi "org.xmlunit:xmlunit-core:$xmlUnitVersion"
|
testFixturesApi "org.xmlunit:xmlunit-core:$xmlUnitVersion"
|
||||||
// Explicitly add assertj-core which is a dependency of
|
// Explictily add assertj-core which is a dependency of
|
||||||
// xmlunit-assertj, but gradle fails to resolves it with:
|
// xmlunit-assertj, but gradle fails to resolves it with:
|
||||||
// Execution failed for task ':smack-core:compileTestJava'.
|
// Execution failed for task ':smack-core:compileTestJava'.
|
||||||
// > Could not resolve all files for configuration ':smack-core:testCompileClasspath'.
|
// > Could not resolve all files for configuration ':smack-core:testCompileClasspath'.
|
||||||
|
@ -62,7 +59,7 @@ task createVersionResource(type: CreateFileTask) {
|
||||||
outputFile = new File(projectDir, 'src/main/resources/org.jivesoftware.smack/version')
|
outputFile = new File(projectDir, 'src/main/resources/org.jivesoftware.smack/version')
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources.dependsOn(createVersionResource)
|
compileJava.dependsOn(createVersionResource)
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
bundle {
|
bundle {
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class MessageTest extends SmackTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = (Message) collector.nextResult(2500);
|
Message message = (Message) collector.nextResult(2500);
|
||||||
assertNotNull("Message not received from remote user", message);
|
assertNotNull("Message not recieved from remote user", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -487,7 +487,7 @@ public abstract class SmackTestCase extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the configuration file related to <b>this</b> test case. By default,all
|
* Returns the name of the configuration file related to <b>this</b> test case. By default all
|
||||||
* the test cases will use the same configuration file. However, it's possible to override the
|
* the test cases will use the same configuration file. However, it's possible to override the
|
||||||
* default configuration by providing a file of the form <test case class name>.xml
|
* default configuration by providing a file of the form <test case class name>.xml
|
||||||
* (e.g. RosterTest.xml).
|
* (e.g. RosterTest.xml).
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2009 the original author or authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AbstractConnectionListener class provides an empty implementation for all
|
||||||
|
* methods defined by the {@link ConnectionListener} interface. This is a
|
||||||
|
* convenience class which should be used in case you do not need to implement
|
||||||
|
* all methods.
|
||||||
|
*
|
||||||
|
* @author Henning Staib
|
||||||
|
* @deprecated use {@link ConnectionListener} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public class AbstractConnectionListener implements ConnectionListener {
|
||||||
|
@Override
|
||||||
|
public void connected(XMPPConnection connection) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionClosed() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionClosedOnError(Exception e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2009 Jive Software, 2018-2024 Florian Schmaus.
|
* Copyright 2009 Jive Software, 2018-2022 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.
|
||||||
|
@ -19,7 +19,6 @@ package org.jivesoftware.smack;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -129,7 +128,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
import org.jxmpp.util.XmppStringUtils;
|
import org.jxmpp.util.XmppStringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This abstract class is commonly used as super class for XMPP connection mechanisms like TCP and BOSH. Hence, it
|
* This abstract class is commonly used as super class for XMPP connection mechanisms like TCP and BOSH. Hence it
|
||||||
* provides the methods for connection state management, like {@link #connect()}, {@link #login()} and
|
* provides the methods for connection state management, like {@link #connect()}, {@link #login()} and
|
||||||
* {@link #disconnect()} (which are deliberately not provided by the {@link XMPPConnection} interface).
|
* {@link #disconnect()} (which are deliberately not provided by the {@link XMPPConnection} interface).
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -388,7 +387,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
*
|
*
|
||||||
* @param configuration The configuration which is used to establish the connection.
|
* @param configuration The configuration which is used to establish the connection.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
|
protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
|
||||||
saslAuthentication = new SASLAuthentication(this, configuration);
|
saslAuthentication = new SASLAuthentication(this, configuration);
|
||||||
config = configuration;
|
config = configuration;
|
||||||
|
@ -1069,7 +1067,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
StanzaCollector collector = createStanzaCollectorAndSend(request);
|
StanzaCollector collector = createStanzaCollectorAndSend(request);
|
||||||
|
@ -1217,7 +1214,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
Stanza packet = (Stanza) sendTopLevelStreamElement;
|
Stanza packet = (Stanza) sendTopLevelStreamElement;
|
||||||
|
|
||||||
final List<StanzaListener> listenersToNotify = new ArrayList<>();
|
final List<StanzaListener> listenersToNotify = new LinkedList<>();
|
||||||
synchronized (sendListeners) {
|
synchronized (sendListeners) {
|
||||||
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
|
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
|
||||||
if (listenerWrapper.filterMatches(packet)) {
|
if (listenerWrapper.filterMatches(packet)) {
|
||||||
|
@ -1245,6 +1242,27 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void addStanzaInterceptor(StanzaListener packetInterceptor,
|
||||||
|
StanzaFilter packetFilter) {
|
||||||
|
if (packetInterceptor == null) {
|
||||||
|
throw new NullPointerException("Packet interceptor is null.");
|
||||||
|
}
|
||||||
|
InterceptorWrapper interceptorWrapper = new InterceptorWrapper(packetInterceptor, packetFilter);
|
||||||
|
synchronized (interceptors) {
|
||||||
|
interceptors.put(packetInterceptor, interceptorWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void removeStanzaInterceptor(StanzaListener packetInterceptor) {
|
||||||
|
synchronized (interceptors) {
|
||||||
|
interceptors.remove(packetInterceptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static <MPB extends MessageOrPresenceBuilder<MP, MPB>, MP extends MessageOrPresence<MPB>> void addInterceptor(
|
private static <MPB extends MessageOrPresenceBuilder<MP, MPB>, MP extends MessageOrPresence<MPB>> void addInterceptor(
|
||||||
Map<Consumer<MPB>, GenericInterceptorWrapper<MPB, MP>> interceptors, Consumer<MPB> interceptor,
|
Map<Consumer<MPB>, GenericInterceptorWrapper<MPB, MP>> interceptors, Consumer<MPB> interceptor,
|
||||||
Predicate<MP> filter) {
|
Predicate<MP> filter) {
|
||||||
|
@ -1287,7 +1305,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
private static <MPB extends MessageOrPresenceBuilder<MP, MPB>, MP extends MessageOrPresence<MPB>> MP fireMessageOrPresenceInterceptors(
|
private static <MPB extends MessageOrPresenceBuilder<MP, MPB>, MP extends MessageOrPresence<MPB>> MP fireMessageOrPresenceInterceptors(
|
||||||
MP messageOrPresence, Map<Consumer<MPB>, GenericInterceptorWrapper<MPB, MP>> interceptors) {
|
MP messageOrPresence, Map<Consumer<MPB>, GenericInterceptorWrapper<MPB, MP>> interceptors) {
|
||||||
List<Consumer<MPB>> interceptorsToInvoke = new ArrayList<>();
|
List<Consumer<MPB>> interceptorsToInvoke = new LinkedList<>();
|
||||||
synchronized (interceptors) {
|
synchronized (interceptors) {
|
||||||
for (GenericInterceptorWrapper<MPB, MP> interceptorWrapper : interceptors.values()) {
|
for (GenericInterceptorWrapper<MPB, MP> interceptorWrapper : interceptors.values()) {
|
||||||
if (interceptorWrapper.filterMatches(messageOrPresence)) {
|
if (interceptorWrapper.filterMatches(messageOrPresence)) {
|
||||||
|
@ -1322,7 +1340,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
* @return the, potentially modified stanza, after the interceptors are run.
|
* @return the, potentially modified stanza, after the interceptors are run.
|
||||||
*/
|
*/
|
||||||
private Stanza firePacketInterceptors(Stanza packet) {
|
private Stanza firePacketInterceptors(Stanza packet) {
|
||||||
List<StanzaListener> interceptorsToInvoke = new ArrayList<>();
|
List<StanzaListener> interceptorsToInvoke = new LinkedList<>();
|
||||||
synchronized (interceptors) {
|
synchronized (interceptors) {
|
||||||
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
|
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
|
||||||
if (interceptorWrapper.filterMatches(packet)) {
|
if (interceptorWrapper.filterMatches(packet)) {
|
||||||
|
@ -1607,7 +1625,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
|
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
|
||||||
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
|
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
|
||||||
// their own thread.
|
// their own thread.
|
||||||
final Collection<StanzaListener> listenersToNotify = new ArrayList<>();
|
final Collection<StanzaListener> listenersToNotify = new LinkedList<>();
|
||||||
extractMatchingListeners(packet, asyncRecvListeners, listenersToNotify);
|
extractMatchingListeners(packet, asyncRecvListeners, listenersToNotify);
|
||||||
for (final StanzaListener listener : listenersToNotify) {
|
for (final StanzaListener listener : listenersToNotify) {
|
||||||
asyncGoLimited(new Runnable() {
|
asyncGoLimited(new Runnable() {
|
||||||
|
@ -1933,7 +1951,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
// Default implementation does nothing
|
// Default implementation does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <F extends XmlElement> F getFeature(QName qname) {
|
public <F extends XmlElement> F getFeature(QName qname) {
|
||||||
return (F) streamFeatures.get(qname);
|
return (F) streamFeatures.get(qname);
|
||||||
|
@ -2178,7 +2196,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
* {@link #maxAsyncRunnables}. Note that we use a {@code LinkedList} in order to avoid space blowups in case the
|
* {@link #maxAsyncRunnables}. Note that we use a {@code LinkedList} in order to avoid space blowups in case the
|
||||||
* list ever becomes very big and shrinks again.
|
* list ever becomes very big and shrinks again.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("JdkObsolete")
|
|
||||||
private final Queue<Runnable> deferredAsyncRunnables = new LinkedList<>();
|
private final Queue<Runnable> deferredAsyncRunnables = new LinkedList<>();
|
||||||
|
|
||||||
private int deferredAsyncRunnablesCount;
|
private int deferredAsyncRunnablesCount;
|
||||||
|
|
|
@ -53,14 +53,14 @@ import java.util.concurrent.Executor;
|
||||||
public class AsyncButOrdered<K> {
|
public class AsyncButOrdered<K> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map with the currently pending runnables for a given key. Note that this is a weak hash map, so we do not have
|
* A map with the currently pending runnables for a given key. Note that this is a weak hash map so we do not have
|
||||||
* to take care of removing the keys ourselves from the map.
|
* to take care of removing the keys ourselfs from the map.
|
||||||
*/
|
*/
|
||||||
private final Map<K, Queue<Runnable>> pendingRunnables = new WeakHashMap<>();
|
private final Map<K, Queue<Runnable>> pendingRunnables = new WeakHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A marker map if there is an active thread for the given key. Holds the responsible handler thread if one is
|
* A marker map if there is an active thread for the given key. Holds the responsible handler thread if one is
|
||||||
* active, otherwise the key is non-existent in the map.
|
* active, otherwise the key is non-existend in the map.
|
||||||
*/
|
*/
|
||||||
private final Map<K, Handler> threadActiveMap = new HashMap<>();
|
private final Map<K, Handler> threadActiveMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2017-2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2017-2022 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.
|
||||||
|
@ -88,7 +88,7 @@ import org.minidns.util.InetAddressUtil;
|
||||||
/**
|
/**
|
||||||
* The connection configuration used for XMPP client-to-server connections. A well configured XMPP service will
|
* The connection configuration used for XMPP client-to-server connections. A well configured XMPP service will
|
||||||
* typically only require you to provide two parameters: The XMPP address, also known as the JID, of the user and the
|
* typically only require you to provide two parameters: The XMPP address, also known as the JID, of the user and the
|
||||||
* password. All other configuration parameters could ideally be determined automatically by Smack. Hence, it is often
|
* password. All other configuration parameters could ideally be determined automatically by Smack. Hence it is often
|
||||||
* enough to call {@link Builder#setXmppAddressAndPassword(CharSequence, String)}.
|
* enough to call {@link Builder#setXmppAddressAndPassword(CharSequence, String)}.
|
||||||
* <p>
|
* <p>
|
||||||
* Technically there are typically at least two parameters required: Some kind of credentials for authentication. And
|
* Technically there are typically at least two parameters required: Some kind of credentials for authentication. And
|
||||||
|
@ -248,7 +248,7 @@ public abstract class ConnectionConfiguration {
|
||||||
|
|
||||||
stanzaIdSourceFactory = builder.stanzaIdSourceFactory;
|
stanzaIdSourceFactory = builder.stanzaIdSourceFactory;
|
||||||
|
|
||||||
// If the enabledSaslMechanisms are set, then they must not be empty
|
// If the enabledSaslmechanisms are set, then they must not be empty
|
||||||
assert enabledSaslMechanisms == null || !enabledSaslMechanisms.isEmpty();
|
assert enabledSaslMechanisms == null || !enabledSaslMechanisms.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ public abstract class ConnectionConfiguration {
|
||||||
context = SSLContext.getInstance("TLS");
|
context = SSLContext.getInstance("TLS");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove the block below once we removed setKeystorePath(), setKeystoreType(), setCallbackHandler() and
|
// TODO: Remove the block below once we removed setKeystorePath(), setKeystoreType(), setCallbackHanlder() and
|
||||||
// setPKCS11Library() in the builder, and all related fields and the parameters of this function.
|
// setPKCS11Library() in the builder, and all related fields and the parameters of this function.
|
||||||
if (keyManagers == null) {
|
if (keyManagers == null) {
|
||||||
keyManagers = Builder.getKeyManagersFrom(keystoreType, keystorePath, callbackHandler, pkcs11Library);
|
keyManagers = Builder.getKeyManagersFrom(keystoreType, keystorePath, callbackHandler, pkcs11Library);
|
||||||
|
@ -534,7 +534,7 @@ public abstract class ConnectionConfiguration {
|
||||||
/**
|
/**
|
||||||
* Returns the stream language to use when connecting to the server.
|
* Returns the stream language to use when connecting to the server.
|
||||||
*
|
*
|
||||||
* @return the stream language to use when connecting to the server or <code>null</code>.
|
* @return the stream language to use when connecting to the server.
|
||||||
*/
|
*/
|
||||||
public Locale getLanguage() {
|
public Locale getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -544,21 +544,19 @@ public abstract class ConnectionConfiguration {
|
||||||
* Returns the xml:lang string of the stream language to use when connecting to the server.
|
* Returns the xml:lang string of the stream language to use when connecting to the server.
|
||||||
*
|
*
|
||||||
* <p>If the developer sets the language to null, this will also return null, leading to
|
* <p>If the developer sets the language to null, this will also return null, leading to
|
||||||
* the removal of the xml:lang tag from the stream.</p>
|
* the removal of the xml:lang tag from the stream. If a Locale("") is configured, this will
|
||||||
|
* return "", which can be used as an override.</p>
|
||||||
*
|
*
|
||||||
* @return the stream language to use when connecting to the server or <code>null</code>.
|
* @return the stream language to use when connecting to the server.
|
||||||
*/
|
*/
|
||||||
public String getXmlLang() {
|
public String getXmlLang() {
|
||||||
if (language == null) {
|
// TODO: Change to Locale.toLanguageTag() once Smack's minimum Android API level is 21 or higher.
|
||||||
return null;
|
// This will need a workaround for new Locale("").getLanguageTag() returning "und". Expected
|
||||||
}
|
// behavior of this function:
|
||||||
|
// - returns null if language is null
|
||||||
String languageTag = language.toLanguageTag();
|
// - returns "" if language.getLanguage() returns the empty string
|
||||||
if (languageTag.equals("und")) {
|
// - returns language.toLanguageTag() otherwise
|
||||||
return null;
|
return language != null ? language.toString().replace("_", "-") : null;
|
||||||
}
|
|
||||||
|
|
||||||
return languageTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -585,7 +583,7 @@ public abstract class ConnectionConfiguration {
|
||||||
* Returns true if the connection is going to use stream compression. Stream compression
|
* Returns true if the connection is going to use stream compression. Stream compression
|
||||||
* will be requested after TLS was established (if TLS was enabled) and only if the server
|
* will be requested after TLS was established (if TLS was enabled) and only if the server
|
||||||
* offered stream compression. With stream compression network traffic can be reduced
|
* offered stream compression. With stream compression network traffic can be reduced
|
||||||
* up to 90%. By default,compression is disabled.
|
* up to 90%. By default compression is disabled.
|
||||||
*
|
*
|
||||||
* @return true if the connection is going to use stream compression.
|
* @return true if the connection is going to use stream compression.
|
||||||
*/
|
*/
|
||||||
|
@ -594,7 +592,7 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given SASL mechanism is enabled in this connection configuration.
|
* Check if the given SASL mechansism is enabled in this connection configuration.
|
||||||
*
|
*
|
||||||
* @param saslMechanism TODO javadoc me please
|
* @param saslMechanism TODO javadoc me please
|
||||||
* @return true if the given SASL mechanism is enabled, false otherwise.
|
* @return true if the given SASL mechanism is enabled, false otherwise.
|
||||||
|
@ -609,7 +607,7 @@ public abstract class ConnectionConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the explicitly enabled SASL mechanisms. May return <code>null</code> if no SASL mechanisms where
|
* Return the explicitly enabled SASL mechanisms. May return <code>null</code> if no SASL mechanisms where
|
||||||
* explicitly enabled, i.e. all SASL mechanisms supported and announced by the service will be considered.
|
* explicitly enabled, i.e. all SALS mechanisms supported and announced by the service will be considered.
|
||||||
*
|
*
|
||||||
* @return the enabled SASL mechanisms or <code>null</code>.
|
* @return the enabled SASL mechanisms or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -672,7 +670,6 @@ public abstract class ConnectionConfiguration {
|
||||||
private boolean compressionEnabled = false;
|
private boolean compressionEnabled = false;
|
||||||
private StanzaIdSourceFactory stanzaIdSourceFactory = new StandardStanzaIdSource.Factory();
|
private StanzaIdSourceFactory stanzaIdSourceFactory = new StandardStanzaIdSource.Factory();
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
protected Builder() {
|
protected Builder() {
|
||||||
if (SmackConfiguration.DEBUG) {
|
if (SmackConfiguration.DEBUG) {
|
||||||
enableDefaultDebugger();
|
enableDefaultDebugger();
|
||||||
|
@ -860,6 +857,22 @@ public abstract class ConnectionConfiguration {
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the host to connect to by either its fully qualified domain name (FQDN) or its IP.
|
||||||
|
*
|
||||||
|
* @param fqdnOrIp a CharSequence either representing the FQDN or the IP of the host.
|
||||||
|
* @return a reference to this builder.
|
||||||
|
* @see #setHost(DnsName)
|
||||||
|
* @see #setHostAddress(InetAddress)
|
||||||
|
* @since 4.3.2
|
||||||
|
* @deprecated use {@link #setHost(CharSequence)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public B setHostAddressByNameOrIp(CharSequence fqdnOrIp) {
|
||||||
|
return setHost(fqdnOrIp);
|
||||||
|
}
|
||||||
|
|
||||||
public B setPort(int port) {
|
public B setPort(int port) {
|
||||||
if (port < 0 || port > 65535) {
|
if (port < 0 || port > 65535) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -1008,6 +1021,25 @@ public abstract class ConnectionConfiguration {
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a custom SSLContext for creating SSL sockets.
|
||||||
|
* <p>
|
||||||
|
* For more information on how to create a SSLContext see <a href=
|
||||||
|
* "http://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#X509TrustManager"
|
||||||
|
* >Java Secure Socket Extension (JSEE) Reference Guide: Creating Your Own X509TrustManager</a>
|
||||||
|
*
|
||||||
|
* @param context the custom SSLContext for new sockets.
|
||||||
|
* @return a reference to this builder.
|
||||||
|
* @deprecated use {@link #setSslContextFactory(SslContextFactory)} instead}.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public B setCustomSSLContext(SSLContext context) {
|
||||||
|
return setSslContextFactory(() -> {
|
||||||
|
return context;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a custom SSLContext for creating SSL sockets.
|
* Sets a custom SSLContext for creating SSL sockets.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -1058,7 +1090,8 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if an initial available presence will be sent to the server. By default, * an available presence will be sent to the server indicating that this presence
|
* Sets if an initial available presence will be sent to the server. By default
|
||||||
|
* an available presence will be sent to the server indicating that this presence
|
||||||
* is not online and available to receive messages. If you want to log in without
|
* is not online and available to receive messages. If you want to log in without
|
||||||
* being 'noticed' then pass a <code>false</code> value.
|
* being 'noticed' then pass a <code>false</code> value.
|
||||||
*
|
*
|
||||||
|
@ -1154,9 +1187,7 @@ public abstract class ConnectionConfiguration {
|
||||||
if (!SASLAuthentication.isSaslMechanismRegistered(SASLMechanism.EXTERNAL)) {
|
if (!SASLAuthentication.isSaslMechanismRegistered(SASLMechanism.EXTERNAL)) {
|
||||||
throw new IllegalArgumentException("SASL " + SASLMechanism.EXTERNAL + " is not registered");
|
throw new IllegalArgumentException("SASL " + SASLMechanism.EXTERNAL + " is not registered");
|
||||||
}
|
}
|
||||||
setSslContextFactory(() -> {
|
setCustomSSLContext(sslContext);
|
||||||
return sslContext;
|
|
||||||
});
|
|
||||||
throwIfEnabledSaslMechanismsSet();
|
throwIfEnabledSaslMechanismsSet();
|
||||||
|
|
||||||
allowEmptyOrNullUsernames();
|
allowEmptyOrNullUsernames();
|
||||||
|
@ -1235,7 +1266,7 @@ public abstract class ConnectionConfiguration {
|
||||||
* Sets if the connection is going to use compression (default false).
|
* Sets if the connection is going to use compression (default false).
|
||||||
*
|
*
|
||||||
* Compression is only activated if the server offers compression. With compression network
|
* Compression is only activated if the server offers compression. With compression network
|
||||||
* traffic can be reduced up to 90%. By default,compression is disabled.
|
* traffic can be reduced up to 90%. By default compression is disabled.
|
||||||
*
|
*
|
||||||
* @param compressionEnabled if the connection is going to use compression on the HTTP level.
|
* @param compressionEnabled if the connection is going to use compression on the HTTP level.
|
||||||
* @return a reference to this object.
|
* @return a reference to this object.
|
||||||
|
@ -1293,7 +1324,7 @@ public abstract class ConnectionConfiguration {
|
||||||
} else {
|
} else {
|
||||||
InputStream stream = TLSUtils.getDefaultTruststoreStreamIfPossible();
|
InputStream stream = TLSUtils.getDefaultTruststoreStreamIfPossible();
|
||||||
try {
|
try {
|
||||||
// Note that PKCS12 keystores need a password one some Java platforms. Hence, we try the famous
|
// Note that PKCS12 keystores need a password one some Java platforms. Hence we try the famous
|
||||||
// 'changeit' here. See https://bugs.openjdk.java.net/browse/JDK-8194702
|
// 'changeit' here. See https://bugs.openjdk.java.net/browse/JDK-8194702
|
||||||
char[] password = "changeit".toCharArray();
|
char[] password = "changeit".toCharArray();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.jxmpp.jid.EntityBareJid;
|
||||||
*
|
*
|
||||||
* <p>Once TLS has been negotiated (i.e. the connection has been secured) it is possible to
|
* <p>Once TLS has been negotiated (i.e. the connection has been secured) it is possible to
|
||||||
* register with the server or authenticate using SASL. If the
|
* register with the server or authenticate using SASL. If the
|
||||||
* server supports SASL then Smack will try to authenticate using SASL.</p>
|
* server supports SASL then Smack will try to authenticate using SASL..</p>
|
||||||
*
|
*
|
||||||
* <p>The server may support many SASL mechanisms to use for authenticating. Out of the box
|
* <p>The server may support many SASL mechanisms to use for authenticating. Out of the box
|
||||||
* Smack provides several SASL mechanisms, but it is possible to register new SASL Mechanisms. Use
|
* Smack provides several SASL mechanisms, but it is possible to register new SASL Mechanisms. Use
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2024 Florian Schmaus
|
* Copyright 2018 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.
|
||||||
|
@ -50,13 +50,11 @@ public class ScheduledAction implements Delayed {
|
||||||
return smackReactor.cancel(this);
|
return smackReactor.cancel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("JavaUtilDate")
|
|
||||||
public boolean isDue() {
|
public boolean isDue() {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
return now.after(releaseTime);
|
return now.after(releaseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("JavaUtilDate")
|
|
||||||
public long getTimeToDueMillis() {
|
public long getTimeToDueMillis() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
return releaseTime.getTime() - now;
|
return releaseTime.getTime() - now;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class Smack {
|
||||||
public static final String SMACK_PACKAGE = SMACK_ORG + ".smack";
|
public static final String SMACK_PACKAGE = SMACK_ORG + ".smack";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Smack version information, e.g."1.3.0".
|
* Returns the Smack version information, eg "1.3.0".
|
||||||
*
|
*
|
||||||
* @return the Smack version information.
|
* @return the Smack version information.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -102,7 +102,7 @@ public final class SmackConfiguration {
|
||||||
private static HostnameVerifier defaultHostnameVerififer;
|
private static HostnameVerifier defaultHostnameVerififer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Smack version information, e.g."1.3.0".
|
* Returns the Smack version information, eg "1.3.0".
|
||||||
*
|
*
|
||||||
* @return the Smack version information.
|
* @return the Smack version information.
|
||||||
* @deprecated use {@link Smack#getVersion()} instead.
|
* @deprecated use {@link Smack#getVersion()} instead.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2014-2024 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2014-2020 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.
|
||||||
|
@ -63,7 +63,7 @@ public final class SmackInitialization {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(SmackInitialization.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(SmackInitialization.class.getName());
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Loads the configuration from the smack-config.xml and system properties file.
|
* Loads the configuration from the smack-config.xml and system properties file.
|
||||||
* <p>
|
* <p>
|
||||||
* So far this means that:
|
* So far this means that:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2024 Florian Schmaus
|
* Copyright 2018-2023 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.
|
||||||
|
@ -144,7 +144,6 @@ public class SmackReactor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("JavaUtilDate")
|
|
||||||
ScheduledAction schedule(Runnable runnable, long delay, TimeUnit unit, ScheduledAction.Kind scheduledActionKind) {
|
ScheduledAction schedule(Runnable runnable, long delay, TimeUnit unit, ScheduledAction.Kind scheduledActionKind) {
|
||||||
long releaseTimeEpoch = System.currentTimeMillis() + unit.toMillis(delay);
|
long releaseTimeEpoch = System.currentTimeMillis() + unit.toMillis(delay);
|
||||||
Date releaseTimeDate = new Date(releaseTimeEpoch);
|
Date releaseTimeDate = new Date(releaseTimeEpoch);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2016-2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2016-2019 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.
|
||||||
|
@ -117,7 +117,7 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @return the next stanza result, or <code>null</code> if there are no more
|
* @return the next stanza result, or <code>null</code> if there are no more
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
public synchronized <P extends Stanza> P pollResult() {
|
public synchronized <P extends Stanza> P pollResult() {
|
||||||
return (P) resultQueue.poll();
|
return (P) resultQueue.poll();
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,6 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @return the next available packet.
|
* @return the next available packet.
|
||||||
* @throws XMPPErrorException in case an error response.
|
* @throws XMPPErrorException in case an error response.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException {
|
public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException {
|
||||||
P result = pollResult();
|
P result = pollResult();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
@ -151,7 +150,7 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @return the next available packet.
|
* @return the next available packet.
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
// TODO: Consider removing this method as it is hardly ever useful.
|
// TODO: Consider removing this method as it is hardly ever useful.
|
||||||
public synchronized <P extends Stanza> P nextResultBlockForever() throws InterruptedException {
|
public synchronized <P extends Stanza> P nextResultBlockForever() throws InterruptedException {
|
||||||
throwIfCancelled();
|
throwIfCancelled();
|
||||||
|
@ -176,7 +175,6 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @return the next available packet.
|
* @return the next available packet.
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <P extends Stanza> P nextResult() throws InterruptedException {
|
public <P extends Stanza> P nextResult() throws InterruptedException {
|
||||||
return nextResult(connection.getReplyTimeout());
|
return nextResult(connection.getReplyTimeout());
|
||||||
}
|
}
|
||||||
|
@ -193,7 +191,7 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @return the next available stanza or <code>null</code> on timeout or connection error.
|
* @return the next available stanza or <code>null</code> on timeout or connection error.
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
public <P extends Stanza> P nextResult(long timeout) throws InterruptedException {
|
public <P extends Stanza> P nextResult(long timeout) throws InterruptedException {
|
||||||
throwIfCancelled();
|
throwIfCancelled();
|
||||||
P res = null;
|
P res = null;
|
||||||
|
@ -225,7 +223,6 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||||
* @see #nextResultOrThrow(long)
|
* @see #nextResultOrThrow(long)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException,
|
public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException,
|
||||||
InterruptedException, NotConnectedException {
|
InterruptedException, NotConnectedException {
|
||||||
return nextResultOrThrow(connection.getReplyTimeout());
|
return nextResultOrThrow(connection.getReplyTimeout());
|
||||||
|
@ -266,7 +263,6 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
* @throws NotConnectedException if there was no response and the connection got disconnected.
|
* @throws NotConnectedException if there was no response and the connection got disconnected.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException,
|
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException,
|
||||||
XMPPErrorException, InterruptedException, NotConnectedException {
|
XMPPErrorException, InterruptedException, NotConnectedException {
|
||||||
P result;
|
P result;
|
||||||
|
|
|
@ -27,6 +27,12 @@ import org.jivesoftware.smack.packet.Stanza;
|
||||||
* the {@link #processStanza(Stanza)} method will be called. This is the
|
* the {@link #processStanza(Stanza)} method will be called. This is the
|
||||||
* opposite approach to the functionality provided by a {@link StanzaCollector}
|
* opposite approach to the functionality provided by a {@link StanzaCollector}
|
||||||
* which lets you block while waiting for results.
|
* which lets you block while waiting for results.
|
||||||
|
* <p>
|
||||||
|
* Additionally you are able to intercept Packets that are going to be send and
|
||||||
|
* make modifications to them. You can register a PacketListener as interceptor
|
||||||
|
* by using {@link XMPPConnection#addStanzaInterceptor(StanzaListener,
|
||||||
|
* org.jivesoftware.smack.filter.StanzaFilter)}
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @see XMPPConnection#addAsyncStanzaListener(StanzaListener, org.jivesoftware.smack.filter.StanzaFilter)
|
* @see XMPPConnection#addAsyncStanzaListener(StanzaListener, org.jivesoftware.smack.filter.StanzaFilter)
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
|
|
|
@ -96,7 +96,7 @@ import org.jxmpp.jid.EntityFullJid;
|
||||||
* <li>other - e.g., {@link #addStanzaListener(StanzaListener, StanzaFilter)}</li>
|
* <li>other - e.g., {@link #addStanzaListener(StanzaListener, StanzaFilter)}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Asynchronous callbacks are run decoupled from the connections main event loop. Hence, a callback triggered by
|
* Asynchronous callbacks are run decoupled from the connections main event loop. Hence a callback triggered by
|
||||||
* stanza B may (appear to) invoked before a callback triggered by stanza A, even though stanza A arrived before B.
|
* stanza B may (appear to) invoked before a callback triggered by stanza A, even though stanza A arrived before B.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -242,7 +242,7 @@ public interface XMPPConnection {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param stanza the stanza to send.
|
* @param stanza the stanza to send.
|
||||||
* @return {@code true} if the stanza was successfully scheduled to be sent, {@code false} otherwise.
|
* @return {@code true} if the stanza was successfully scheduled to be send, {@code false} otherwise.
|
||||||
* @throws NotConnectedException if the connection is not connected.
|
* @throws NotConnectedException if the connection is not connected.
|
||||||
* @since 4.4.0
|
* @since 4.4.0
|
||||||
* @deprecated use {@link #sendStanzaNonBlocking(Stanza)} instead.
|
* @deprecated use {@link #sendStanzaNonBlocking(Stanza)} instead.
|
||||||
|
@ -265,7 +265,7 @@ public interface XMPPConnection {
|
||||||
* @param stanza the stanza to send.
|
* @param stanza the stanza to send.
|
||||||
* @param timeout how long to wait before giving up, in units of {@code unit}.
|
* @param timeout how long to wait before giving up, in units of {@code unit}.
|
||||||
* @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter.
|
* @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter.
|
||||||
* @return {@code true} if the stanza was successfully scheduled to be sent, {@code false} otherwise.
|
* @return {@code true} if the stanza was successfully scheduled to be send, {@code false} otherwise.
|
||||||
* @throws NotConnectedException if the connection is not connected.
|
* @throws NotConnectedException if the connection is not connected.
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
* @since 4.4.0
|
* @since 4.4.0
|
||||||
|
@ -318,7 +318,6 @@ public interface XMPPConnection {
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
<I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
<I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException;
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
|
@ -424,6 +423,7 @@ public interface XMPPConnection {
|
||||||
*
|
*
|
||||||
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
||||||
* @param stanzaFilter the stanza filter to use.
|
* @param stanzaFilter the stanza filter to use.
|
||||||
|
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
void addSyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
void addSyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
||||||
|
@ -449,6 +449,7 @@ public interface XMPPConnection {
|
||||||
*
|
*
|
||||||
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
||||||
* @param stanzaFilter the stanza filter to use.
|
* @param stanzaFilter the stanza filter to use.
|
||||||
|
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
void addAsyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
void addAsyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
||||||
|
@ -482,6 +483,34 @@ public interface XMPPConnection {
|
||||||
*/
|
*/
|
||||||
void removeStanzaSendingListener(StanzaListener stanzaListener);
|
void removeStanzaSendingListener(StanzaListener stanzaListener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a stanza interceptor with this connection. The interceptor will be
|
||||||
|
* invoked every time a stanza is about to be sent by this connection. Interceptors
|
||||||
|
* may modify the stanza to be sent. A stanza filter determines which stanzas
|
||||||
|
* will be delivered to the interceptor.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* NOTE: For a similar functionality on incoming stanzas, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param stanzaInterceptor the stanza interceptor to notify of stanzas about to be sent.
|
||||||
|
* @param stanzaFilter the stanza filter to use.
|
||||||
|
* @deprecated use {@link #addMessageInterceptor(Consumer, Predicate)} or {@link #addPresenceInterceptor(Consumer, Predicate)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
void addStanzaInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a stanza interceptor.
|
||||||
|
*
|
||||||
|
* @param stanzaInterceptor the stanza interceptor to remove.
|
||||||
|
* @deprecated use {@link #removeMessageInterceptor(Consumer)} or {@link #removePresenceInterceptor(Consumer)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
void removeStanzaInterceptor(StanzaListener stanzaInterceptor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a stanza interceptor with this connection. The interceptor will be
|
* Registers a stanza interceptor with this connection. The interceptor will be
|
||||||
* invoked every time a stanza is about to be sent by this connection. Interceptors
|
* invoked every time a stanza is about to be sent by this connection. Interceptors
|
||||||
|
@ -582,6 +611,23 @@ public interface XMPPConnection {
|
||||||
*/
|
*/
|
||||||
FromMode getFromMode();
|
FromMode getFromMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the feature stanza extensions for a given stream feature of the
|
||||||
|
* server, or <code>null</code> if the server doesn't support that feature.
|
||||||
|
*
|
||||||
|
* @param <F> {@link ExtensionElement} type of the feature.
|
||||||
|
* @param element TODO javadoc me please
|
||||||
|
* @param namespace TODO javadoc me please
|
||||||
|
* @return a stanza extensions of the feature or <code>null</code>
|
||||||
|
* @deprecated use {@link #getFeature(Class)} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
default <F extends XmlElement> F getFeature(String element, String namespace) {
|
||||||
|
QName qname = new QName(namespace, element);
|
||||||
|
return getFeature(qname);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the feature stanza extensions for a given stream feature of the
|
* Get the feature stanza extensions for a given stream feature of the
|
||||||
* server, or <code>null</code> if the server doesn't support that feature.
|
* server, or <code>null</code> if the server doesn't support that feature.
|
||||||
|
@ -591,7 +637,6 @@ public interface XMPPConnection {
|
||||||
* @return a stanza extensions of the feature or <code>null</code>
|
* @return a stanza extensions of the feature or <code>null</code>
|
||||||
* @since 4.4
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
<F extends XmlElement> F getFeature(QName qname);
|
<F extends XmlElement> F getFeature(QName qname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,8 +57,8 @@ public interface XmppInputOutputFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The returned {@link ByteBuffer} is going to get flipped by the caller. The callee must not flip the buffer.
|
* The returned {@link ByteBuffer} is going to get fliped by the caller. The callee must not flip the buffer.
|
||||||
* @param inputData the data this method needs to process.
|
* @param inputData the data this methods needs to process.
|
||||||
* @return a {@link ByteBuffer} or {@code null} if no data could be produced.
|
* @return a {@link ByteBuffer} or {@code null} if no data could be produced.
|
||||||
* @throws IOException in case an I/O exception occurs.
|
* @throws IOException in case an I/O exception occurs.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -301,7 +301,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
currentStateVertex = StateDescriptorGraph.convertToStateGraph(initialStateDescriptorVertex, connectionInternal);
|
currentStateVertex = StateDescriptorGraph.convertToStateGraph(initialStateDescriptorVertex, connectionInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
public <CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>> CM getConnectionModuleFor(
|
public <CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>> CM getConnectionModuleFor(
|
||||||
Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass) {
|
Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass) {
|
||||||
return (CM) connectionModules.get(descriptorClass);
|
return (CM) connectionModules.get(descriptorClass);
|
||||||
|
@ -390,7 +390,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
|
|
||||||
// Ignore successorStateVertex if the only way to the final state is via the initial state. This happens
|
// Ignore successorStateVertex if the only way to the final state is via the initial state. This happens
|
||||||
// typically if we are in the ConnectedButUnauthenticated state on the way to ResourceboundAndAuthenticated,
|
// typically if we are in the ConnectedButUnauthenticated state on the way to ResourceboundAndAuthenticated,
|
||||||
// where we do not want to walk via InstantShutdown/Shutdown in a cycle over the initial state towards this
|
// where we do not want to walk via InstantShutdown/Shtudown in a cycle over the initial state towards this
|
||||||
// state.
|
// state.
|
||||||
if (walkStateGraphContext.wouldCauseCycle(successorStateVertex)) {
|
if (walkStateGraphContext.wouldCauseCycle(successorStateVertex)) {
|
||||||
// Ignore this successor.
|
// Ignore this successor.
|
||||||
|
@ -658,7 +658,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
updateOutgoingStreamXmlEnvironmentOnStreamOpen(streamOpen);
|
updateOutgoingStreamXmlEnvironmentOnStreamOpen(streamOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public static class DisconnectedStateDescriptor extends StateDescriptor {
|
public static class DisconnectedStateDescriptor extends StateDescriptor {
|
||||||
protected DisconnectedStateDescriptor() {
|
protected DisconnectedStateDescriptor() {
|
||||||
super(DisconnectedState.class, StateDescriptor.Property.finalState);
|
super(DisconnectedState.class, StateDescriptor.Property.finalState);
|
||||||
|
@ -667,8 +666,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class DisconnectedState extends State {
|
private final class DisconnectedState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private DisconnectedState(StateDescriptor stateDescriptor,
|
private DisconnectedState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -709,8 +707,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
private final class LookupRemoteConnectionEndpointsState extends State {
|
private final class LookupRemoteConnectionEndpointsState extends State {
|
||||||
boolean outgoingElementsQueueWasShutdown;
|
boolean outgoingElementsQueueWasShutdown;
|
||||||
|
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private LookupRemoteConnectionEndpointsState(StateDescriptor stateDescriptor,
|
private LookupRemoteConnectionEndpointsState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -821,8 +817,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ConnectedButUnauthenticatedState extends State {
|
private final class ConnectedButUnauthenticatedState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private ConnectedButUnauthenticatedState(StateDescriptor stateDescriptor,
|
private ConnectedButUnauthenticatedState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -855,8 +849,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class SaslAuthenticationState extends State {
|
private final class SaslAuthenticationState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private SaslAuthenticationState(StateDescriptor stateDescriptor,
|
private SaslAuthenticationState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -900,8 +892,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ResourceBindingStateDescriptor extends StateDescriptor {
|
public static final class ResourceBindingStateDescriptor extends StateDescriptor {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private ResourceBindingStateDescriptor() {
|
private ResourceBindingStateDescriptor() {
|
||||||
super(ResourceBindingState.class, "RFC 6120 § 7");
|
super(ResourceBindingState.class, "RFC 6120 § 7");
|
||||||
addSuccessor(AuthenticatedAndResourceBoundStateDescriptor.class);
|
addSuccessor(AuthenticatedAndResourceBoundStateDescriptor.class);
|
||||||
|
@ -909,8 +899,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ResourceBindingState extends State {
|
private final class ResourceBindingState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private ResourceBindingState(StateDescriptor stateDescriptor,
|
private ResourceBindingState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -966,8 +954,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AuthenticatedAndResourceBoundState extends State {
|
private final class AuthenticatedAndResourceBoundState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private AuthenticatedAndResourceBoundState(StateDescriptor stateDescriptor,
|
private AuthenticatedAndResourceBoundState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -1008,8 +994,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ShutdownState extends State {
|
private final class ShutdownState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private ShutdownState(StateDescriptor stateDescriptor,
|
private ShutdownState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
@ -1072,8 +1056,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class InstantShutdownState extends NoOpState {
|
private static final class InstantShutdownState extends NoOpState {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private InstantShutdownState(ModularXmppClientToServerConnection connection, StateDescriptor stateDescriptor,
|
private InstantShutdownState(ModularXmppClientToServerConnection connection, StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(connection, stateDescriptor, connectionInternal);
|
super(connection, stateDescriptor, connectionInternal);
|
||||||
|
@ -1095,8 +1077,6 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class CloseConnectionState extends State {
|
private final class CloseConnectionState extends State {
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private CloseConnectionState(StateDescriptor stateDescriptor,
|
private CloseConnectionState(StateDescriptor stateDescriptor,
|
||||||
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
ModularXmppClientToServerConnectionInternal connectionInternal) {
|
||||||
super(stateDescriptor, connectionInternal);
|
super(stateDescriptor, connectionInternal);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2024 Florian Schmaus
|
* Copyright 2018-2020 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.
|
||||||
|
@ -41,8 +41,6 @@ public class CompressionModuleDescriptor extends ModularXmppClientToServerConnec
|
||||||
|
|
||||||
public static final class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder {
|
public static final class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder {
|
||||||
|
|
||||||
// Invoked via reflection.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private Builder(ModularXmppClientToServerConnectionConfiguration.Builder connectionConfigurationBuilder) {
|
private Builder(ModularXmppClientToServerConnectionConfiguration.Builder connectionConfigurationBuilder) {
|
||||||
super(connectionConfigurationBuilder);
|
super(connectionConfigurationBuilder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,9 +143,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
|
||||||
int bytesWritten = compressor.deflate(buffer, initialOutputBufferPosition, length, flushMode);
|
int bytesWritten = compressor.deflate(buffer, initialOutputBufferPosition, length, flushMode);
|
||||||
|
|
||||||
int newOutputBufferPosition = initialOutputBufferPosition + bytesWritten;
|
int newOutputBufferPosition = initialOutputBufferPosition + bytesWritten;
|
||||||
// Workaround for Android API not matching Java >=9 API.
|
outputBuffer.position(newOutputBufferPosition);
|
||||||
// See https://issuetracker.google.com/issues/369219141
|
|
||||||
((java.nio.Buffer) outputBuffer).position(newOutputBufferPosition);
|
|
||||||
|
|
||||||
totalBytesWritten += bytesWritten;
|
totalBytesWritten += bytesWritten;
|
||||||
|
|
||||||
|
@ -158,9 +156,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
|
||||||
increasedBufferSize = MINIMUM_OUTPUT_BUFFER_INCREASE;
|
increasedBufferSize = MINIMUM_OUTPUT_BUFFER_INCREASE;
|
||||||
}
|
}
|
||||||
ByteBuffer newCurrentOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
|
ByteBuffer newCurrentOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
|
||||||
// Workaround for Android API not matching Java >=9 API.
|
outputBuffer.flip();
|
||||||
// See https://issuetracker.google.com/issues/369219141
|
|
||||||
((java.nio.Buffer) outputBuffer).flip();
|
|
||||||
newCurrentOutputBuffer.put(outputBuffer);
|
newCurrentOutputBuffer.put(outputBuffer);
|
||||||
outputBuffer = newCurrentOutputBuffer;
|
outputBuffer = newCurrentOutputBuffer;
|
||||||
}
|
}
|
||||||
|
@ -206,9 +202,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for Android API not matching Java >=9 API.
|
outputBuffer.position(inflateOutputBufferOffset + bytesInflated);
|
||||||
// See https://issuetracker.google.com/issues/369219141
|
|
||||||
((java.nio.Buffer) outputBuffer).position(inflateOutputBufferOffset + bytesInflated);
|
|
||||||
|
|
||||||
decompressorOutBytes += bytesInflated;
|
decompressorOutBytes += bytesInflated;
|
||||||
|
|
||||||
|
@ -218,9 +212,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
|
||||||
|
|
||||||
int increasedBufferSize = outputBuffer.capacity() * 2;
|
int increasedBufferSize = outputBuffer.capacity() * 2;
|
||||||
ByteBuffer increasedOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
|
ByteBuffer increasedOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
|
||||||
// Workaround for Android API not matching Java >=9 API.
|
outputBuffer.flip();
|
||||||
// See https://issuetracker.google.com/issues/369219141
|
|
||||||
((java.nio.Buffer) outputBuffer).flip();
|
|
||||||
increasedOutputBuffer.put(outputBuffer);
|
increasedOutputBuffer.put(outputBuffer);
|
||||||
outputBuffer = increasedOutputBuffer;
|
outputBuffer = increasedOutputBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.datatypes;
|
||||||
import org.jivesoftware.smack.util.NumberUtil;
|
import org.jivesoftware.smack.util.NumberUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A number representing an unsigned 16-bit integer. Can be used for values with the XML schema type "xs:unsignedShort".
|
* A number representing an unsigned 16-bit integer. Can be used for values with the XML schema type "xs:unsingedShort".
|
||||||
*/
|
*/
|
||||||
public final class UInt16 extends Scalar implements Comparable<UInt16> {
|
public final class UInt16 extends Scalar implements Comparable<UInt16> {
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.ExceptionUtil;
|
||||||
* even block the thread since only one thread may print at a time.
|
* even block the thread since only one thread may print at a time.
|
||||||
* <p>
|
* <p>
|
||||||
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
||||||
* packets by Smack. By default,interpreted packets won't be printed. To enable this feature
|
* packets by Smack. By default interpreted packets won't be printed. To enable this feature
|
||||||
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,6 @@ public class ConsoleDebugger extends AbstractDebugger {
|
||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("JavaUtilDate")
|
|
||||||
@Override
|
@Override
|
||||||
protected void log(String logMessage) {
|
protected void log(String logMessage) {
|
||||||
String formatedDate;
|
String formatedDate;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||||
* even block the thread since only one thread may print at a time.
|
* even block the thread since only one thread may print at a time.
|
||||||
* <p>
|
* <p>
|
||||||
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
* It is possible to not only print the raw sent and received stanzas but also the interpreted
|
||||||
* packets by Smack. By default,interpreted packets won't be printed. To enable this feature
|
* packets by Smack. By default interpreted packets won't be printed. To enable this feature
|
||||||
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
* just change the <code>printInterpreted</code> static variable to <code>true</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,7 +57,7 @@ public abstract class SmackDebugger {
|
||||||
*
|
*
|
||||||
* @param user the user@host/resource that has just logged in
|
* @param user the user@host/resource that has just logged in
|
||||||
*/
|
*/
|
||||||
// TODO: Should be replaced with a connection listener authenticated().
|
// TODO: Should be replaced with a connection listener authenticed().
|
||||||
public abstract void userHasLogged(EntityFullJid user);
|
public abstract void userHasLogged(EntityFullJid user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software.
|
||||||
*
|
*
|
||||||
* 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,7 +17,6 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.filter;
|
package org.jivesoftware.smack.filter;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
|
||||||
|
@ -44,9 +43,4 @@ public class NotFilter implements StanzaFilter {
|
||||||
public boolean accept(Stanza packet) {
|
public boolean accept(Stanza packet) {
|
||||||
return !filter.accept(packet);
|
return !filter.accept(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E extends ExtensionElement> NotFilter of(Class<E> extensionElementClass) {
|
|
||||||
ExtensionElementFilter<E> extensionElementFilter = new ExtensionElementFilter<>(extensionElementClass);
|
|
||||||
return new NotFilter(extensionElementFilter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.jivesoftware.smack.filter;
|
package org.jivesoftware.smack.filter;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.packet.StanzaView;
|
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +34,7 @@ public class StanzaIdFilter implements StanzaFilter {
|
||||||
*
|
*
|
||||||
* @param stanza the stanza which the ID is taken from.
|
* @param stanza the stanza which the ID is taken from.
|
||||||
*/
|
*/
|
||||||
public StanzaIdFilter(StanzaView stanza) {
|
public StanzaIdFilter(Stanza stanza) {
|
||||||
this(stanza.getStanzaId());
|
this(stanza.getStanzaId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* <li>{@link StanzaIdFilter}: filters for stanzas with a particular stanza ID</li>
|
* <li>{@link StanzaIdFilter}: filters for stanzas with a particular stanza ID</li>
|
||||||
* <li>{@link ToMatchesFilter}: filters for stanzas that are sent to a particular address</li>
|
* <li>{@link ToMatchesFilter}: filters for stanzas that are sent to a particular address</li>
|
||||||
* <li>{@link FromMatchesFilter}: filters for stanzas that are sent from a particular address</li>
|
* <li>{@link FromMatchesFilter}: filters for stanzas that are sent from a particular address</li>
|
||||||
* <li>{@link ExtensionElementFilter}: filters for stanzas that have a particular stanza extension element</li>
|
* <li>{@link ExtensionElementFilter}: filters for stanzas that have a particular stanza exentsion element</li>
|
||||||
* <li>{@link AndFilter}: implements the logical AND operation over two or more filters</li>
|
* <li>{@link AndFilter}: implements the logical AND operation over two or more filters</li>
|
||||||
* <li>{@link OrFilter}: implements the logical OR operation over two or more filters</li>
|
* <li>{@link OrFilter}: implements the logical OR operation over two or more filters</li>
|
||||||
* <li>{@link NotFilter}: implements the logical NOT operation on a filter</li>
|
* <li>{@link NotFilter}: implements the logical NOT operation on a filter</li>
|
||||||
|
|
|
@ -118,7 +118,7 @@ public abstract class StateDescriptor {
|
||||||
if (stateClassConstructor != null) {
|
if (stateClassConstructor != null) {
|
||||||
stateClassConstructor.setAccessible(true);
|
stateClassConstructor.setAccessible(true);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Add validation check that if stateClassConstructor is 'null' the constructState() method is overridden.
|
// TODO: Add validation check that if stateClassConstructor is 'null' the cosntructState() method is overriden.
|
||||||
}
|
}
|
||||||
|
|
||||||
String className = getClass().getSimpleName();
|
String className = getClass().getSimpleName();
|
||||||
|
@ -155,7 +155,7 @@ public abstract class StateDescriptor {
|
||||||
clazz = Class.forName(clazzName);
|
clazz = Class.forName(clazzName);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// The state descriptor class is not in classpath, which probably means that the smack module is not loaded
|
// The state descriptor class is not in classpath, which probably means that the smack module is not loaded
|
||||||
// into the classpath. Hence, we can silently ignore that.
|
// into the classpath. Hence we can silently ignore that.
|
||||||
LOGGER.log(Level.FINEST, "Ignoring unknown state descriptor '" + clazzName + "'", e);
|
LOGGER.log(Level.FINEST, "Ignoring unknown state descriptor '" + clazzName + "'", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2024 Florian Schmaus
|
* Copyright 2018-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.
|
||||||
|
@ -215,7 +215,7 @@ public class StateDescriptorGraph {
|
||||||
inferredForwardEdges.put(predecessor, backwardsEdge);
|
inferredForwardEdges.put(predecessor, backwardsEdge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ensure that the initial node has their successors inferred.
|
// Ensure that the intial node has their successors inferred.
|
||||||
for (Class<? extends StateDescriptor> inferredSuccessorOfInitialStateDescriptor : inferredForwardEdges.getAll(initialStatedescriptorClass)) {
|
for (Class<? extends StateDescriptor> inferredSuccessorOfInitialStateDescriptor : inferredForwardEdges.getAll(initialStatedescriptorClass)) {
|
||||||
initialNode.getElement().addSuccessor(inferredSuccessorOfInitialStateDescriptor);
|
initialNode.getElement().addSuccessor(inferredSuccessorOfInitialStateDescriptor);
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ public class StateDescriptorGraph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stateDescriptorGraphToDot(Collection<GraphVertex<StateDescriptor>> vertexes,
|
public static <E> void stateDescriptorGraphToDot(Collection<GraphVertex<StateDescriptor>> vertexes,
|
||||||
PrintWriter dotOut, boolean breakStateName) {
|
PrintWriter dotOut, boolean breakStateName) {
|
||||||
dotOut.append("digraph {\n");
|
dotOut.append("digraph {\n");
|
||||||
dfs(vertexes,
|
dfs(vertexes,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2024 Florian Schmaus
|
* Copyright 2014-2018 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,7 +18,7 @@ package org.jivesoftware.smack.initializer;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -42,7 +42,7 @@ public abstract class UrlInitializer implements SmackInitializer {
|
||||||
public List<Exception> initialize() {
|
public List<Exception> initialize() {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
final ClassLoader classLoader = this.getClass().getClassLoader();
|
final ClassLoader classLoader = this.getClass().getClassLoader();
|
||||||
final List<Exception> exceptions = new ArrayList<Exception>();
|
final List<Exception> exceptions = new LinkedList<Exception>();
|
||||||
final String providerUriString = getProvidersUri();
|
final String providerUriString = getProvidersUri();
|
||||||
if (providerUriString != null) {
|
if (providerUriString != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,8 +41,6 @@ public class InstantStreamResumptionModuleDescriptor extends ModularXmppClientTo
|
||||||
|
|
||||||
public static final class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder {
|
public static final class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder {
|
||||||
|
|
||||||
// Unfinished implementation.
|
|
||||||
@SuppressWarnings("UnusedMethod")
|
|
||||||
private Builder(ModularXmppClientToServerConnectionConfiguration.Builder connectionConfigurationBuilder) {
|
private Builder(ModularXmppClientToServerConnectionConfiguration.Builder connectionConfigurationBuilder) {
|
||||||
super(connectionConfigurationBuilder);
|
super(connectionConfigurationBuilder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2024 Florian Schmaus
|
* Copyright 2014-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.
|
||||||
|
@ -108,7 +108,6 @@ public class AbstractError {
|
||||||
* @param <PE> type of the ExtensionElement.
|
* @param <PE> type of the ExtensionElement.
|
||||||
* @return the extension, or <code>null</code> if it doesn't exist.
|
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
|
||||||
public <PE extends XmlElement> PE getExtension(String elementName, String namespace) {
|
public <PE extends XmlElement> PE getExtension(String elementName, String namespace) {
|
||||||
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
|
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2017-2024 Florian Schmaus
|
* Copyright © 2017-2019 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.
|
||||||
|
@ -54,4 +54,15 @@ public abstract class AbstractTextElement implements ExtensionElement {
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @return deprecated
|
||||||
|
* @deprecated use {@link #getLanguage()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public final String getLang() {
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2024 Florian Schmaus
|
* Copyright © 2014-2023 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.
|
||||||
|
@ -23,7 +23,6 @@ public class EmptyResultIQ extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Deprecate when stanza builder and parsing logic is ready.
|
// TODO: Deprecate when stanza builder and parsing logic is ready.
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public EmptyResultIQ() {
|
public EmptyResultIQ() {
|
||||||
super((String) null, null);
|
super((String) null, null);
|
||||||
setType(IQ.Type.result);
|
setType(IQ.Type.result);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.packet;
|
||||||
/**
|
/**
|
||||||
* Interface to represent XMPP extension elements. Unlike {@link XmlElement}, every non-abstract class that implements
|
* Interface to represent XMPP extension elements. Unlike {@link XmlElement}, every non-abstract class that implements
|
||||||
* {@link ExtensionElement} must have a static final QNAME member of the type {@link javax.xml.namespace.QName}. This
|
* {@link ExtensionElement} must have a static final QNAME member of the type {@link javax.xml.namespace.QName}. This
|
||||||
* allows type-safe functions like {@link StanzaView#getExtension(Class)}. Hence, this is a marker interface.
|
* allows type-safe functions like {@link StanzaView#getExtension(Class)}. Hence this is a marker interface.
|
||||||
* <p>
|
* <p>
|
||||||
* Use this class when implementing new extension elements when possible. This means that every instance of your
|
* Use this class when implementing new extension elements when possible. This means that every instance of your
|
||||||
* implemented class must represent an XML element of the same qualified name.
|
* implemented class must represent an XML element of the same qualified name.
|
||||||
|
|
|
@ -88,14 +88,14 @@ public abstract class IQ extends Stanza implements IqView {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of the IQ packet.
|
* Sets the type of the IQ packet.
|
||||||
* <p>
|
* <p>
|
||||||
* Since the type of an IQ must present, an IllegalArgumentException will be thrown when type is
|
* Since the type of an IQ must present, an IllegalArgmentException will be thrown when type is
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
@ -182,7 +182,7 @@ public abstract class IQ extends Stanza implements IqView {
|
||||||
// Add the query section if there is one.
|
// Add the query section if there is one.
|
||||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
|
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
|
||||||
new IQChildElementXmlStringBuilder(getChildElementName(), getChildElementNamespace(), null, xml.getXmlEnvironment()));
|
new IQChildElementXmlStringBuilder(getChildElementName(), getChildElementNamespace(), null, xml.getXmlEnvironment()));
|
||||||
// TODO: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
||||||
// the logic.
|
// the logic.
|
||||||
if (iqChildElement == null) {
|
if (iqChildElement == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -287,6 +287,20 @@ public abstract class IQ extends Stanza implements IqView {
|
||||||
return ErrorIQ.createErrorResponse(request, error);
|
return ErrorIQ.createErrorResponse(request, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @param request the request.
|
||||||
|
* @param error the error.
|
||||||
|
* @return an error IQ.
|
||||||
|
* @deprecated use {@link #createErrorResponse(IQ, StanzaError)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Builder error) {
|
||||||
|
return createErrorResponse(request, error.build());
|
||||||
|
}
|
||||||
|
|
||||||
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Condition condition) {
|
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Condition condition) {
|
||||||
return createErrorResponse(request, StanzaError.getBuilder(condition).build());
|
return createErrorResponse(request, StanzaError.getBuilder(condition).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2024 Florian Schmaus
|
* Copyright © 2014-2020 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,9 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
@ -31,7 +31,7 @@ public class Mechanisms implements ExtensionElement {
|
||||||
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-sasl";
|
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-sasl";
|
||||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
public final List<String> mechanisms = new ArrayList<String>();
|
public final List<String> mechanisms = new LinkedList<String>();
|
||||||
|
|
||||||
public Mechanisms(String mechanism) {
|
public Mechanisms(String mechanism) {
|
||||||
mechanisms.add(mechanism);
|
mechanisms.add(mechanism);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
@ -28,6 +29,10 @@ 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;
|
||||||
|
|
||||||
|
import org.jxmpp.jid.Jid;
|
||||||
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents XMPP message packets. A message can be one of several types:
|
* Represents XMPP message packets. A message can be one of several types:
|
||||||
*
|
*
|
||||||
|
@ -58,7 +63,85 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
||||||
public static final String ELEMENT = "message";
|
public static final String ELEMENT = "message";
|
||||||
public static final String BODY = "body";
|
public static final String BODY = "body";
|
||||||
|
|
||||||
private final Type type;
|
private Type type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new, "normal" message.
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new "normal" message to the specified recipient.
|
||||||
|
*
|
||||||
|
* @param to the recipient of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message(Jid to) {
|
||||||
|
setTo(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new message of the specified type to a recipient.
|
||||||
|
*
|
||||||
|
* @param to the user to send the message to.
|
||||||
|
* @param type the message type.
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message(Jid to, Type type) {
|
||||||
|
this(to);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new message to the specified recipient and with the specified body.
|
||||||
|
*
|
||||||
|
* @param to the user to send the message to.
|
||||||
|
* @param body the body of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message(Jid to, String body) {
|
||||||
|
this(to);
|
||||||
|
setBody(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new message to the specified recipient and with the specified body.
|
||||||
|
*
|
||||||
|
* @param to the user to send the message to.
|
||||||
|
* @param body the body of the message.
|
||||||
|
* @throws XmppStringprepException if 'to' is not a valid XMPP address.
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message(String to, String body) throws XmppStringprepException {
|
||||||
|
this(JidCreate.from(to), body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new message with the specified recipient and extension element.
|
||||||
|
*
|
||||||
|
* @param to TODO javadoc me please
|
||||||
|
* @param extensionElement TODO javadoc me please
|
||||||
|
* @since 4.2
|
||||||
|
* @deprecated use {@link StanzaBuilder}, preferable via {@link StanzaFactory}, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Message(Jid to, ExtensionElement extensionElement) {
|
||||||
|
this(to);
|
||||||
|
addExtension(extensionElement);
|
||||||
|
}
|
||||||
|
|
||||||
Message(MessageBuilder messageBuilder) {
|
Message(MessageBuilder messageBuilder) {
|
||||||
super(messageBuilder);
|
super(messageBuilder);
|
||||||
|
@ -87,6 +170,197 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of the message.
|
||||||
|
*
|
||||||
|
* @param type the type of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the subject of the message. The subject is a short description of
|
||||||
|
* message contents.
|
||||||
|
*
|
||||||
|
* @param subject the subject of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public void setSubject(String subject) {
|
||||||
|
if (subject == null) {
|
||||||
|
removeSubject(""); // use empty string because #removeSubject(null) is ambiguous
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addSubject(null, subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a subject with a corresponding language.
|
||||||
|
*
|
||||||
|
* @param language the language of the subject being added.
|
||||||
|
* @param subject the subject being added to the message.
|
||||||
|
* @return the new {@link org.jivesoftware.smack.packet.Message.Subject}
|
||||||
|
* @throws NullPointerException if the subject is null, a null pointer exception is thrown
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public Subject addSubject(String language, String subject) {
|
||||||
|
language = Stanza.determineLanguage(this, language);
|
||||||
|
|
||||||
|
List<Subject> currentSubjects = getExtensions(Subject.class);
|
||||||
|
for (Subject currentSubject : currentSubjects) {
|
||||||
|
if (language.equals(currentSubject.getLanguage())) {
|
||||||
|
throw new IllegalArgumentException("Subject with the language " + language + " already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Subject messageSubject = new Subject(language, subject);
|
||||||
|
addExtension(messageSubject);
|
||||||
|
return messageSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the subject with the given language from the message.
|
||||||
|
*
|
||||||
|
* @param language the language of the subject which is to be removed
|
||||||
|
* @return true if a subject was removed and false if it was not.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public boolean removeSubject(String language) {
|
||||||
|
language = Stanza.determineLanguage(this, language);
|
||||||
|
for (Subject subject : getExtensions(Subject.class)) {
|
||||||
|
if (language.equals(subject.language)) {
|
||||||
|
return removeSubject(subject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the subject from the message and returns true if the subject was removed.
|
||||||
|
*
|
||||||
|
* @param subject the subject being removed from the message.
|
||||||
|
* @return true if the subject was successfully removed and false if it was not.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public boolean removeSubject(Subject subject) {
|
||||||
|
return removeExtension(subject) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the body of the message.
|
||||||
|
*
|
||||||
|
* @param body the body of the message.
|
||||||
|
* @see #setBody(String)
|
||||||
|
* @since 4.2
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public void setBody(CharSequence body) {
|
||||||
|
String bodyString;
|
||||||
|
if (body != null) {
|
||||||
|
bodyString = body.toString();
|
||||||
|
} else {
|
||||||
|
bodyString = null;
|
||||||
|
}
|
||||||
|
setBody(bodyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the body of the message. The body is the main message contents.
|
||||||
|
*
|
||||||
|
* @param body the body of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public void setBody(String body) {
|
||||||
|
if (body == null) {
|
||||||
|
removeBody(""); // use empty string because #removeBody(null) is ambiguous
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addBody(null, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a body with a corresponding language.
|
||||||
|
*
|
||||||
|
* @param language the language of the body being added.
|
||||||
|
* @param body the body being added to the message.
|
||||||
|
* @return the new {@link org.jivesoftware.smack.packet.Message.Body}
|
||||||
|
* @throws NullPointerException if the body is null, a null pointer exception is thrown
|
||||||
|
* @since 3.0.2
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public Body addBody(String language, String body) {
|
||||||
|
language = Stanza.determineLanguage(this, language);
|
||||||
|
|
||||||
|
removeBody(language);
|
||||||
|
|
||||||
|
Body messageBody = new Body(language, body);
|
||||||
|
addExtension(messageBody);
|
||||||
|
return messageBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the body with the given language from the message.
|
||||||
|
*
|
||||||
|
* @param language the language of the body which is to be removed
|
||||||
|
* @return true if a body was removed and false if it was not.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public boolean removeBody(String language) {
|
||||||
|
language = Stanza.determineLanguage(this, language);
|
||||||
|
for (Body body : getBodies()) {
|
||||||
|
String bodyLanguage = body.getLanguage();
|
||||||
|
if (Objects.equals(bodyLanguage, language)) {
|
||||||
|
removeExtension(body);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the body from the message and returns true if the body was removed.
|
||||||
|
*
|
||||||
|
* @param body the body being removed from the message.
|
||||||
|
* @return true if the body was successfully removed and false if it was not.
|
||||||
|
* @since 3.0.2
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public boolean removeBody(Body body) {
|
||||||
|
XmlElement removedElement = removeExtension(body);
|
||||||
|
return removedElement != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the thread id of the message, which is a unique identifier for a sequence
|
||||||
|
* of "chat" messages.
|
||||||
|
*
|
||||||
|
* @param thread the thread id of the message.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove when stanza builder is ready.
|
||||||
|
public void setThread(String thread) {
|
||||||
|
addExtension(new Message.Thread(thread));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT;
|
return ELEMENT;
|
||||||
|
@ -138,6 +412,22 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a copy of this message stanza.
|
||||||
|
* <p>
|
||||||
|
* This does not perform a deep clone, as extension elements are shared between the new and old
|
||||||
|
* instance.
|
||||||
|
* </p>
|
||||||
|
* @return a clone of this message.
|
||||||
|
* @deprecated use {@link #asBuilder()} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public Message clone() {
|
||||||
|
return new Message(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message subject, its language and the content of the subject.
|
* Represents a message subject, its language and the content of the subject.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,6 +20,11 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
public abstract class MessageOrPresence<MPB extends MessageOrPresenceBuilder<?, ?>> extends Stanza {
|
public abstract class MessageOrPresence<MPB extends MessageOrPresenceBuilder<?, ?>> extends Stanza {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
protected MessageOrPresence() {
|
||||||
|
}
|
||||||
|
|
||||||
protected MessageOrPresence(StanzaBuilder<?> stanzaBuilder) {
|
protected MessageOrPresence(StanzaBuilder<?> stanzaBuilder) {
|
||||||
super(stanzaBuilder);
|
super(stanzaBuilder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Nonza, i.e. everything that is <b>not a stanza</b> as defined
|
* A Nonza, i.e everything that is <b>not a stanza</b> as defined
|
||||||
* RFC 6120 8. Stanzas are {@link Message}, {@link Presence} and {@link IQ}.
|
* RFC 6120 8. Stanzas are {@link Message}, {@link Presence} and {@link IQ}.
|
||||||
* Everything else should sublcass this class instead of {@link Stanza}.
|
* Everything else should sublcass this class instead of {@link Stanza}.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2020-2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2020-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.
|
||||||
|
@ -21,9 +21,12 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import org.jxmpp.jid.Jid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents XMPP presence stanzas. Every presence stanza has a type, which is one of
|
* Represents XMPP presence stanzas. Every presence stanza has a type, which is one of
|
||||||
* the following values:
|
* the following values:
|
||||||
|
@ -75,6 +78,55 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
|
|
||||||
private Mode mode = null;
|
private Mode mode = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new presence update. Status, priority, and mode are left un-set.
|
||||||
|
*
|
||||||
|
* @param type the type.
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Presence(Type type) {
|
||||||
|
// Ensure that the stanza ID is set by calling super().
|
||||||
|
super();
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new presence with the given type and using the given XMPP address as recipient.
|
||||||
|
*
|
||||||
|
* @param to the recipient.
|
||||||
|
* @param type the type.
|
||||||
|
* @since 4.2
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public Presence(Jid to, Type type) {
|
||||||
|
this(type);
|
||||||
|
setTo(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new presence update with a specified status, priority, and mode.
|
||||||
|
*
|
||||||
|
* @param type the type.
|
||||||
|
* @param status a text message describing the presence update.
|
||||||
|
* @param priority the priority of this presence update.
|
||||||
|
* @param mode the mode type for this presence update.
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
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);
|
||||||
|
setMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
Presence(PresenceBuilder presenceBuilder) {
|
Presence(PresenceBuilder presenceBuilder) {
|
||||||
super(presenceBuilder);
|
super(presenceBuilder);
|
||||||
type = presenceBuilder.type;
|
type = presenceBuilder.type;
|
||||||
|
@ -134,11 +186,36 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of the presence packet.
|
||||||
|
*
|
||||||
|
* @param type the type of the presence packet.
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = Objects.requireNonNull(type, "Type cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status message of the presence update. The status is free-form text
|
||||||
|
* describing a user's presence (i.e., "gone to lunch").
|
||||||
|
*
|
||||||
|
* @param status the status message.
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority() {
|
public int getPriority() {
|
||||||
return getPriorityByte();
|
return getPriorityByte();
|
||||||
|
@ -156,11 +233,20 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
* Sets the priority of the presence. The valid range is -128 through 127.
|
* Sets the priority of the presence. The valid range is -128 through 127.
|
||||||
*
|
*
|
||||||
* @param priority the priority of the presence.
|
* @param priority the priority of the presence.
|
||||||
|
* @throws IllegalArgumentException if the priority is outside the valid range.
|
||||||
* @see <a href="https://tools.ietf.org/html/rfc6121#section-4.7.2.3">RFC 6121 § 4.7.2.3. Priority Element</a>
|
* @see <a href="https://tools.ietf.org/html/rfc6121#section-4.7.2.3">RFC 6121 § 4.7.2.3. Priority Element</a>
|
||||||
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// TODO: Remove in Smack 4.6.
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setPriority(int priority) {
|
||||||
|
if (priority < -128 || priority > 127) {
|
||||||
|
throw new IllegalArgumentException("Priority value " + priority +
|
||||||
|
" is not valid. Valid range is -128 through 127.");
|
||||||
|
}
|
||||||
|
setPriority((byte) priority);
|
||||||
|
}
|
||||||
|
|
||||||
public void setPriority(byte priority) {
|
public void setPriority(byte priority) {
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +259,19 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the mode of the presence update. A null presence mode value is interpreted
|
||||||
|
* to be the same thing as {@link Presence.Mode#available}.
|
||||||
|
*
|
||||||
|
* @param mode the mode.
|
||||||
|
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setMode(Mode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT;
|
return ELEMENT;
|
||||||
|
@ -247,6 +346,37 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a copy of this presence stanza.
|
||||||
|
* <p>
|
||||||
|
* This does not perform a deep clone, as extension elements are shared between the new and old
|
||||||
|
* instance.
|
||||||
|
* </p>
|
||||||
|
* @return a clone of this presence.
|
||||||
|
* @deprecated use {@link #asBuilder()} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public Presence clone() {
|
||||||
|
return new Presence(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone this presence and set a newly generated stanza ID as the clone's ID.
|
||||||
|
*
|
||||||
|
* @return a "clone" of this presence with a different stanza ID.
|
||||||
|
* @since 4.1.2
|
||||||
|
* @deprecated use {@link #asBuilder(XMPPConnection)} or {@link #asBuilder(String)}instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public Presence cloneWithNewId() {
|
||||||
|
Presence clone = clone();
|
||||||
|
clone.setNewStanzaId();
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum to represent the presence type. Note that presence type is often confused
|
* An enum to represent the presence type. Note that presence type is often confused
|
||||||
* with presence mode. Generally, if a user is signed in to a server, they have a presence
|
* with presence mode. Generally, if a user is signed in to a server, they have a presence
|
||||||
|
|
|
@ -39,7 +39,6 @@ public class Session extends SimpleIQ {
|
||||||
public static final String ELEMENT = "session";
|
public static final String ELEMENT = "session";
|
||||||
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-session";
|
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-session";
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public Session() {
|
public Session() {
|
||||||
super(ELEMENT, NAMESPACE);
|
super(ELEMENT, NAMESPACE);
|
||||||
setType(IQ.Type.set);
|
setType(IQ.Type.set);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2015-2024 Florian Schmaus.
|
* Copyright 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.
|
||||||
|
@ -53,7 +53,9 @@ public final class StandardExtensionElement implements XmlElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new extension element with the given name and namespace and nothing else.
|
* Constructs a new extension element with the given name and namespace and nothing else.
|
||||||
|
* <p>
|
||||||
* This is meant to construct extension elements used as simple flags in Stanzas.
|
* This is meant to construct extension elements used as simple flags in Stanzas.
|
||||||
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the name of the extension element.
|
* @param name the name of the extension element.
|
||||||
* @param namespace the namespace of the extension element.
|
* @param namespace the namespace of the extension element.
|
||||||
|
|
|
@ -98,7 +98,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
protected Stanza(StanzaBuilder<?> stanzaBuilder) {
|
protected Stanza(StanzaBuilder<?> stanzaBuilder) {
|
||||||
if (stanzaBuilder.stanzaIdSource != null) {
|
if (stanzaBuilder.stanzaIdSource != null) {
|
||||||
id = stanzaBuilder.stanzaIdSource.getNewStanzaId();
|
id = stanzaBuilder.stanzaIdSource.getNewStanzaId();
|
||||||
// Note that some stanza ID sources, e.g. StanzaBuilder.PresenceBuilder.EMPTY return null here. Hence, we
|
// Note that some stanza ID sources, e.g. StanzaBuilder.PresenceBuilder.EMPTY return null here. Hence we
|
||||||
// only check that the returned string is not empty.
|
// only check that the returned string is not empty.
|
||||||
assert StringUtils.isNullOrNotEmpty(id);
|
assert StringUtils.isNullOrNotEmpty(id);
|
||||||
usedStanzaIdSource = stanzaBuilder.stanzaIdSource;
|
usedStanzaIdSource = stanzaBuilder.stanzaIdSource;
|
||||||
|
@ -159,6 +159,22 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
return id != null;
|
return id != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the stanza id if none is set.
|
||||||
|
*
|
||||||
|
* @return the stanza id.
|
||||||
|
* @since 4.2
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public String setStanzaId() {
|
||||||
|
if (!hasStanzaIdSet()) {
|
||||||
|
setNewStanzaId();
|
||||||
|
}
|
||||||
|
return getStanzaId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an {@link IllegalArgumentException} if this stanza has no stanza ID set.
|
* Throws an {@link IllegalArgumentException} if this stanza has no stanza ID set.
|
||||||
*
|
*
|
||||||
|
@ -203,7 +219,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @param to who the packet is being sent to.
|
* @param to who the packet is being sent to.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
||||||
public final void setTo(Jid to) {
|
public void setTo(Jid to) {
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,11 +255,34 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
error = stanzaError;
|
error = stanzaError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
* @param stanzaError the stanza error.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setError(StanzaError.Builder stanzaError) {
|
||||||
|
setError(stanzaError.build());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String getLanguage() {
|
public final String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the xml:lang of this Stanza.
|
||||||
|
*
|
||||||
|
* @param language the xml:lang of this Stanza.
|
||||||
|
* @deprecated use {@link StanzaBuilder#setLanguage(String)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public void setLanguage(String language) {
|
||||||
|
this.language = language;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<XmlElement> getExtensions() {
|
public final List<XmlElement> getExtensions() {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
|
@ -335,6 +374,22 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
return packetExtension;
|
return packetExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is deprecated. Use preferably {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)}.
|
||||||
|
*
|
||||||
|
* @param <E> the type to cast to.
|
||||||
|
* @param elementName the XML element name of the extension. (May be null)
|
||||||
|
* @param namespace the XML element namespace of the extension.
|
||||||
|
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||||
|
* @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Deprecated
|
||||||
|
public final <E extends ExtensionElement> E getExtension(String elementName, String namespace) {
|
||||||
|
return (E) getExtensionElement(elementName, namespace);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final XmlElement getExtension(QName qname) {
|
public final XmlElement getExtension(QName qname) {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
|
@ -446,6 +501,27 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a stanza extension from the packet.
|
||||||
|
*
|
||||||
|
* @param extension the stanza extension to remove.
|
||||||
|
* @return the removed stanza extension or null.
|
||||||
|
* @deprecated use {@link StanzaBuilder} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public final XmlElement removeExtension(XmlElement extension) {
|
||||||
|
QName key = extension.getQName();
|
||||||
|
synchronized (extensionElements) {
|
||||||
|
List<XmlElement> list = extensionElements.getAll(key);
|
||||||
|
boolean removed = list.remove(extension);
|
||||||
|
if (removed) {
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a short String describing the Stanza. This method is suited for log purposes.
|
* Returns a short String describing the Stanza. This method is suited for log purposes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -87,9 +87,9 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the recipient address of the stanza.
|
* Set the recipent address of the stanza.
|
||||||
*
|
*
|
||||||
* @param to whom the stanza is being sent.
|
* @param to whoe the stanza is being sent to.
|
||||||
* @return a reference to this builder.
|
* @return a reference to this builder.
|
||||||
* @throws XmppStringprepException if the provided character sequence is not a valid XMPP address.
|
* @throws XmppStringprepException if the provided character sequence is not a valid XMPP address.
|
||||||
* @see #to(Jid)
|
* @see #to(Jid)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019-2024 Florian Schmaus
|
* Copyright 2019-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.
|
||||||
|
@ -36,7 +36,7 @@ public interface StanzaView extends XmlLangElement {
|
||||||
/**
|
/**
|
||||||
* Returns who the stanza is being sent "to", or <code>null</code> if
|
* Returns who the stanza is being sent "to", or <code>null</code> if
|
||||||
* the value is not set. The XMPP protocol often makes the "to"
|
* the value is not set. The XMPP protocol often makes the "to"
|
||||||
* attribute optional, so it does not always need to be set.
|
* attribute optional, so it does not always need to be set.<p>
|
||||||
*
|
*
|
||||||
* @return who the stanza is being sent to, or <code>null</code> if the
|
* @return who the stanza is being sent to, or <code>null</code> if the
|
||||||
* value has not been set.
|
* value has not been set.
|
||||||
|
@ -46,7 +46,7 @@ public interface StanzaView extends XmlLangElement {
|
||||||
/**
|
/**
|
||||||
* Returns who the stanza is being sent "from" or <code>null</code> if
|
* Returns who the stanza is being sent "from" or <code>null</code> if
|
||||||
* the value is not set. The XMPP protocol often makes the "from"
|
* the value is not set. The XMPP protocol often makes the "from"
|
||||||
* attribute optional, so it does not always need to be set.
|
* attribute optional, so it does not always need to be set.<p>
|
||||||
*
|
*
|
||||||
* @return who the stanza is being sent from, or <code>null</code> if the
|
* @return who the stanza is being sent from, or <code>null</code> if the
|
||||||
* value has not been set.
|
* value has not been set.
|
||||||
|
|
|
@ -58,9 +58,9 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* stream has been authenticated </td></tr>
|
* stream has been authenticated </td></tr>
|
||||||
* <tr><td> policy-violation </td><td> the entity has violated some local service
|
* <tr><td> policy-violation </td><td> the entity has violated some local service
|
||||||
* policy. </td></tr>
|
* policy. </td></tr>
|
||||||
* <tr><td> remote-connection-failed </td><td> the server is unable to properly connect
|
* <tr><td> remote-connection-failed </td><td> Rthe server is unable to properly connect
|
||||||
* to a remote entity. </td></tr>
|
* to a remote entity. </td></tr>
|
||||||
* <tr><td> resource-constraint </td><td> the server lacks the system resources necessary
|
* <tr><td> resource-constraint </td><td> Rthe server lacks the system resources necessary
|
||||||
* to service the stream. </td></tr>
|
* to service the stream. </td></tr>
|
||||||
* <tr><td> restricted-xml </td><td> the entity has attempted to send restricted XML
|
* <tr><td> restricted-xml </td><td> the entity has attempted to send restricted XML
|
||||||
* features. </td></tr>
|
* features. </td></tr>
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An IQ stanzas that could not be parsed because no provider was found.
|
* An IQ stanzas that could not be parsed because no provider was found.
|
||||||
*/
|
*/
|
||||||
|
@ -36,12 +34,7 @@ public class UnparsedIQ extends IQ {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
if (StringUtils.isEmpty(content)) {
|
xml.escape(content);
|
||||||
xml.setEmptyElement();
|
|
||||||
} else {
|
|
||||||
xml.rightAngleBracket();
|
|
||||||
xml.escape(content);
|
|
||||||
}
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -39,11 +39,11 @@ import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
public class ProviderFileLoader implements ProviderLoader {
|
public class ProviderFileLoader implements ProviderLoader {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
|
||||||
|
|
||||||
private final Collection<IQProviderInfo> iqProviders = new ArrayList<IQProviderInfo>();
|
private final Collection<IQProviderInfo> iqProviders = new LinkedList<IQProviderInfo>();
|
||||||
private final Collection<ExtensionProviderInfo> extProviders = new ArrayList<ExtensionProviderInfo>();
|
private final Collection<ExtensionProviderInfo> extProviders = new LinkedList<ExtensionProviderInfo>();
|
||||||
private final Collection<StreamFeatureProviderInfo> sfProviders = new ArrayList<StreamFeatureProviderInfo>();
|
private final Collection<StreamFeatureProviderInfo> sfProviders = new LinkedList<StreamFeatureProviderInfo>();
|
||||||
|
|
||||||
private List<Exception> exceptions = new ArrayList<Exception>();
|
private List<Exception> exceptions = new LinkedList<Exception>();
|
||||||
|
|
||||||
public ProviderFileLoader(InputStream providerStream) {
|
public ProviderFileLoader(InputStream providerStream) {
|
||||||
this(providerStream, ProviderFileLoader.class.getClassLoader());
|
this(providerStream, ProviderFileLoader.class.getClassLoader());
|
||||||
|
|
|
@ -97,7 +97,6 @@ import org.jivesoftware.smack.util.XmppElementUtil;
|
||||||
* </extensionProvider>
|
* </extensionProvider>
|
||||||
* </smackProviders></pre>
|
* </smackProviders></pre>
|
||||||
*
|
*
|
||||||
* <p>
|
|
||||||
* If multiple provider entries attempt to register to handle the same element name and namespace,
|
* If multiple provider entries attempt to register to handle the same element name and namespace,
|
||||||
* the first entry loaded from the classpath will take precedence. Whenever a stanza extension
|
* the first entry loaded from the classpath will take precedence. Whenever a stanza extension
|
||||||
* is found in a packet, parsing will be passed to the correct provider. Each provider
|
* is found in a packet, parsing will be passed to the correct provider. Each provider
|
||||||
|
@ -107,8 +106,7 @@ import org.jivesoftware.smack.util.XmppElementUtil;
|
||||||
* set the properties of th class using the values in the stanza extension sub-element. When an
|
* set the properties of th class using the values in the stanza extension sub-element. When an
|
||||||
* extension provider is not registered for an element name and namespace combination, Smack will
|
* extension provider is not registered for an element name and namespace combination, Smack will
|
||||||
* store all top-level elements of the sub-packet in DefaultPacketExtension object and then
|
* store all top-level elements of the sub-packet in DefaultPacketExtension object and then
|
||||||
* attach it to the packet.
|
* attach it to the packet.<p>
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Smack provider architecture is a system for plugging in custom XML parsing of stanza extensions
|
* The Smack provider architecture is a system for plugging in custom XML parsing of staza extensions
|
||||||
* ({@link org.jivesoftware.smack.packet.ExtensionElement}, {@link org.jivesoftware.smack.packet.IQ} stanzas and
|
* ({@link org.jivesoftware.smack.packet.ExtensionElement}, {@link org.jivesoftware.smack.packet.IQ} stanzas and
|
||||||
* {@link org.jivesoftware.smack.packet.Nonza}. Hence, there are the the following providers:
|
* {@link org.jivesoftware.smack.packet.Nonza}. Hence, there are the the following providers:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.io.StringReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
|
||||||
proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password);
|
proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password);
|
||||||
}
|
}
|
||||||
socket.getOutputStream().write((hostport + " HTTP/1.1\r\nHost: "
|
socket.getOutputStream().write((hostport + " HTTP/1.1\r\nHost: "
|
||||||
+ host + ":" + port + proxyLine + "\r\n\r\n").getBytes(StandardCharsets.UTF_8));
|
+ host + ":" + port + proxyLine + "\r\n\r\n").getBytes("UTF-8"));
|
||||||
|
|
||||||
InputStream in = socket.getInputStream();
|
InputStream in = socket.getInputStream();
|
||||||
StringBuilder got = new StringBuilder(100);
|
StringBuilder got = new StringBuilder(100);
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class ProxyInfo {
|
||||||
private ProxyType proxyType;
|
private ProxyType proxyType;
|
||||||
private final ProxySocketConnection proxySocketConnection;
|
private final ProxySocketConnection proxySocketConnection;
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser,
|
public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser,
|
||||||
String pPass) {
|
String pPass) {
|
||||||
this.proxyType = pType;
|
this.proxyType = pType;
|
||||||
|
|
|
@ -358,7 +358,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
||||||
* SASLprep the given String. The resulting String is in UTF-8.
|
* SASLprep the given String. The resulting String is in UTF-8.
|
||||||
*
|
*
|
||||||
* @param string the String to sasl prep.
|
* @param string the String to sasl prep.
|
||||||
* @return the given String SASL prepped
|
* @return the given String SASL preped
|
||||||
* @see <a href="http://tools.ietf.org/html/rfc4013">RFC 4013 - SASLprep: Stringprep Profile for User Names and Passwords</a>
|
* @see <a href="http://tools.ietf.org/html/rfc4013">RFC 4013 - SASLprep: Stringprep Profile for User Names and Passwords</a>
|
||||||
*/
|
*/
|
||||||
protected static String saslPrep(String string) {
|
protected static String saslPrep(String string) {
|
||||||
|
|
|
@ -271,7 +271,6 @@ public abstract class ScramMechanism extends SASLMechanism {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("MixedMutabilityReturnType")
|
|
||||||
private static Map<Character, String> parseAttributes(String string) throws SmackSaslException {
|
private static Map<Character, String> parseAttributes(String string) throws SmackSaslException {
|
||||||
if (string.length() == 0) {
|
if (string.length() == 0) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class CollectionUtil {
|
||||||
boolean test(T t);
|
boolean test(T t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("NonApiType")
|
|
||||||
public static <T> ArrayList<T> newListWith(Collection<? extends T> collection) {
|
public static <T> ArrayList<T> newListWith(Collection<? extends T> collection) {
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MAC {
|
||||||
HMAC_SHA1 = Mac.getInstance(HMACSHA1);
|
HMAC_SHA1 = Mac.getInstance(HMACSHA1);
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
// Smack won't be able to function normally if this exception is thrown, wrap it into
|
// Smack wont be able to function normally if this exception is thrown, wrap it into
|
||||||
// an ISE and make the user aware of the problem.
|
// an ISE and make the user aware of the problem.
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class MD5 {
|
||||||
MD5_DIGEST = MessageDigest.getInstance(StringUtils.MD5);
|
MD5_DIGEST = MessageDigest.getInstance(StringUtils.MD5);
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
// Smack won't be able to function normally if this exception is thrown, wrap it into
|
// Smack wont be able to function normally if this exception is thrown, wrap it into
|
||||||
// an ISE and make the user aware of the problem.
|
// an ISE and make the user aware of the problem.
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2015-2024 Florian Schmaus
|
* Copyright © 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.
|
||||||
|
@ -184,14 +184,13 @@ public class MultiMap<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the given number of values for a given key. May return less values than requested.
|
* Remove the given number of values for a given key. May return less values then requested.
|
||||||
*
|
*
|
||||||
* @param key the key to remove from.
|
* @param key the key to remove from.
|
||||||
* @param num the number of values to remove.
|
* @param num the number of values to remove.
|
||||||
* @return a list of the removed values.
|
* @return a list of the removed values.
|
||||||
* @since 4.4.0
|
* @since 4.4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("MixedMutabilityReturnType")
|
|
||||||
public List<V> remove(K key, int num) {
|
public List<V> remove(K key, int num) {
|
||||||
List<V> values = map.get(key);
|
List<V> values = map.get(key);
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2015-2024 Florian Schmaus
|
* Copyright © 2015-2020 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,18 @@ package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
public class NumberUtil {
|
public class NumberUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
|
||||||
|
*
|
||||||
|
* @param value TODO javadoc me please
|
||||||
|
* @deprecated use {@link #requireUInt32(long)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public static void checkIfInUInt32Range(long value) {
|
||||||
|
requireUInt32(value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
|
* Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2019-2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2019-2023 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.
|
||||||
|
@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -86,7 +87,7 @@ public class PacketParserUtils {
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
public static <S extends Stanza> S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
|
public static <S extends Stanza> S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
|
||||||
return (S) parseStanza(getParserFor(stanza), XmlEnvironment.EMPTY);
|
return (S) parseStanza(getParserFor(stanza), XmlEnvironment.EMPTY);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +230,7 @@ public class PacketParserUtils {
|
||||||
// Assume this is the end tag of the start tag at the
|
// Assume this is the end tag of the start tag at the
|
||||||
// beginning of this method. Typical examples where this
|
// beginning of this method. Typical examples where this
|
||||||
// happens are body elements containing the empty string,
|
// happens are body elements containing the empty string,
|
||||||
// i.e. <body></body>, which appears to be valid XMPP, or a
|
// ie. <body></body>, which appears to be valid XMPP, or a
|
||||||
// least it's not explicitly forbidden by RFC 6121 5.2.3
|
// least it's not explicitly forbidden by RFC 6121 5.2.3
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -643,7 +644,7 @@ public class PacketParserUtils {
|
||||||
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
|
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
|
||||||
String name;
|
String name;
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
List<String> methods = new ArrayList<>();
|
List<String> methods = new LinkedList<>();
|
||||||
outerloop: while (true) {
|
outerloop: while (true) {
|
||||||
XmlPullParser.Event eventType = parser.next();
|
XmlPullParser.Event eventType = parser.next();
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
@ -849,7 +850,7 @@ public class PacketParserUtils {
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
ParserUtils.assertAtStartTag(parser);
|
ParserUtils.assertAtStartTag(parser);
|
||||||
assert parser.getNamespace().equals(StartTls.NAMESPACE);
|
assert parser.getNamespace().equals(StartTls.NAMESPACE);
|
||||||
int initialDepth = parser.getDepth();
|
int initalDepth = parser.getDepth();
|
||||||
boolean required = false;
|
boolean required = false;
|
||||||
outerloop: while (true) {
|
outerloop: while (true) {
|
||||||
XmlPullParser.Event event = parser.next();
|
XmlPullParser.Event event = parser.next();
|
||||||
|
@ -863,7 +864,7 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END_ELEMENT:
|
case END_ELEMENT:
|
||||||
if (parser.getDepth() == initialDepth) {
|
if (parser.getDepth() == initalDepth) {
|
||||||
break outerloop;
|
break outerloop;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2024 Florian Schmaus
|
* Copyright © 2014-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.
|
||||||
|
@ -32,7 +32,7 @@ public class PacketUtil {
|
||||||
*
|
*
|
||||||
* @return the extension element
|
* @return the extension element
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
@SuppressWarnings("unchecked")
|
||||||
public static <PE extends XmlElement> PE extensionElementFrom(Collection<XmlElement> collection,
|
public static <PE extends XmlElement> PE extensionElementFrom(Collection<XmlElement> collection,
|
||||||
String element, String namespace) {
|
String element, String namespace) {
|
||||||
for (XmlElement packetExtension : collection) {
|
for (XmlElement packetExtension : collection) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020-2024 Florian Schmaus.
|
* Copyright 2020 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.
|
||||||
|
@ -26,12 +26,11 @@ public final class Pair<F, S> {
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <F, S> Pair<F, S> create(F first, S second) {
|
public static <F extends Object, S extends Object> Pair<F, S> create(F first, S second) {
|
||||||
return new Pair<>(first, second);
|
return new Pair<>(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ReturnValueIgnored")
|
public static <F extends Object, S extends Object> Pair<F, S> createAndInitHashCode(F first, S second) {
|
||||||
public static <F, S> Pair<F, S> createAndInitHashCode(F first, S second) {
|
|
||||||
Pair<F, S> pair = new Pair<>(first, second);
|
Pair<F, S> pair = new Pair<>(first, second);
|
||||||
pair.hashCode();
|
pair.hashCode();
|
||||||
return pair;
|
return pair;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2024 Florian Schmaus
|
* Copyright © 2014-2023 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.
|
||||||
|
@ -23,6 +23,8 @@ import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.datatypes.UInt16;
|
import org.jivesoftware.smack.datatypes.UInt16;
|
||||||
import org.jivesoftware.smack.datatypes.UInt32;
|
import org.jivesoftware.smack.datatypes.UInt32;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
@ -144,7 +146,7 @@ public class ParserUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Phrase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
|
* Prase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
|
||||||
*
|
*
|
||||||
* @param booleanString the input string.
|
* @param booleanString the input string.
|
||||||
* @return the boolean representation of the input string
|
* @return the boolean representation of the input string
|
||||||
|
@ -365,6 +367,19 @@ public class ParserUtils {
|
||||||
return parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");
|
return parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the QName of the current element.
|
||||||
|
*
|
||||||
|
* @param parser the parser.
|
||||||
|
* @return the Qname.
|
||||||
|
* @deprecated use {@link XmlPullParser#getQName()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5
|
||||||
|
public static QName getQName(XmlPullParser parser) {
|
||||||
|
return parser.getQName();
|
||||||
|
}
|
||||||
|
|
||||||
public static InternetAddress getInternetAddressIngoringZoneIdAttribute(XmlPullParser parser, String attribute) {
|
public static InternetAddress getInternetAddressIngoringZoneIdAttribute(XmlPullParser parser, String attribute) {
|
||||||
String inetAddressString = parser.getAttributeValue(attribute);
|
String inetAddressString = parser.getAttributeValue(attribute);
|
||||||
if (inetAddressString == null) {
|
if (inetAddressString == null) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SHA1 {
|
||||||
SHA1_DIGEST = MessageDigest.getInstance(StringUtils.SHA1);
|
SHA1_DIGEST = MessageDigest.getInstance(StringUtils.SHA1);
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
// Smack won't be able to function normally if this exception is thrown, wrap it into
|
// Smack wont be able to function normally if this exception is thrown, wrap it into
|
||||||
// an ISE and make the user aware of the problem.
|
// an ISE and make the user aware of the problem.
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019-2024 Florian Schmaus.
|
* Copyright 2019 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.
|
||||||
|
@ -26,7 +26,6 @@ public class SecurityUtil {
|
||||||
|
|
||||||
private static final LruCache<Class<? extends Provider>, Void> INSERTED_PROVIDERS_CACHE = new LruCache<>(8);
|
private static final LruCache<Class<? extends Provider>, Void> INSERTED_PROVIDERS_CACHE = new LruCache<>(8);
|
||||||
|
|
||||||
@SuppressWarnings("LockOnNonEnclosingClassLiteral")
|
|
||||||
public static void ensureProviderAtFirstPosition(Class<? extends Provider> providerClass) {
|
public static void ensureProviderAtFirstPosition(Class<? extends Provider> providerClass) {
|
||||||
if (INSERTED_PROVIDERS_CACHE.containsKey(providerClass)) {
|
if (INSERTED_PROVIDERS_CACHE.containsKey(providerClass)) {
|
||||||
return;
|
return;
|
||||||
|
@ -42,7 +41,7 @@ public class SecurityUtil {
|
||||||
|
|
||||||
String providerName = provider.getName();
|
String providerName = provider.getName();
|
||||||
|
|
||||||
int installedPosition;
|
int installedPosition ;
|
||||||
synchronized (Security.class) {
|
synchronized (Security.class) {
|
||||||
Security.removeProvider(providerName);
|
Security.removeProvider(providerName);
|
||||||
installedPosition = Security.insertProviderAt(provider, 1);
|
installedPosition = Security.insertProviderAt(provider, 1);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2016-2024 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2016-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.
|
||||||
|
@ -36,6 +36,24 @@ public class StringUtils {
|
||||||
public static final String MD5 = "MD5";
|
public static final String MD5 = "MD5";
|
||||||
public static final String SHA1 = "SHA-1";
|
public static final String SHA1 = "SHA-1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated, do not use.
|
||||||
|
*
|
||||||
|
* @deprecated use StandardCharsets.UTF_8 instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated, do not use.
|
||||||
|
*
|
||||||
|
* @deprecated use StandardCharsets.US_ASCII instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public static final String USASCII = "US-ASCII";
|
||||||
|
|
||||||
public static final String QUOTE_ENCODE = """;
|
public static final String QUOTE_ENCODE = """;
|
||||||
public static final String APOS_ENCODE = "'";
|
public static final String APOS_ENCODE = "'";
|
||||||
public static final String AMP_ENCODE = "&";
|
public static final String AMP_ENCODE = "&";
|
||||||
|
@ -325,14 +343,11 @@ public class StringUtils {
|
||||||
try {
|
try {
|
||||||
randomString(charBuffer, random, alphabet, numRandomChars);
|
randomString(charBuffer, random, alphabet, numRandomChars);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// This should never happen if we calculate the buffer size correctly.
|
// This should never happen if we calcuate the buffer size correctly.
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for Android API not matching Java >=9 API.
|
return charBuffer.flip().toString();
|
||||||
// See https://issuetracker.google.com/issues/369219141
|
|
||||||
((java.nio.Buffer) charBuffer).flip();
|
|
||||||
return charBuffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void randomString(Appendable appendable, Random random, char[] alphabet, int numRandomChars)
|
private static void randomString(Appendable appendable, Random random, char[] alphabet, int numRandomChars)
|
||||||
|
@ -464,7 +479,7 @@ public class StringUtils {
|
||||||
appendTo(collection, ", ", sb);
|
appendTo(collection, ", ", sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <O> void appendTo(Collection<O> collection, StringBuilder sb,
|
public static <O extends Object> void appendTo(Collection<O> collection, StringBuilder sb,
|
||||||
Consumer<O> appendFunction) {
|
Consumer<O> appendFunction) {
|
||||||
appendTo(collection, ", ", sb, appendFunction);
|
appendTo(collection, ", ", sb, appendFunction);
|
||||||
}
|
}
|
||||||
|
@ -473,7 +488,7 @@ public class StringUtils {
|
||||||
appendTo(collection, delimiter, sb, o -> sb.append(o));
|
appendTo(collection, delimiter, sb, o -> sb.append(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <O> void appendTo(Collection<O> collection, String delimiter, StringBuilder sb,
|
public static <O extends Object> void appendTo(Collection<O> collection, String delimiter, StringBuilder sb,
|
||||||
Consumer<O> appendFunction) {
|
Consumer<O> appendFunction) {
|
||||||
for (Iterator<O> it = collection.iterator(); it.hasNext();) {
|
for (Iterator<O> it = collection.iterator(); it.hasNext();) {
|
||||||
O cs = it.next();
|
O cs = it.next();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2024 Florian Schmaus
|
* Copyright 2014-2020 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.
|
||||||
|
@ -68,6 +68,52 @@ public class TLSUtils {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable only TLS. Connections created with the given ConnectionConfiguration will only support TLS.
|
||||||
|
* <p>
|
||||||
|
* According to the <a
|
||||||
|
* href="https://raw.githubusercontent.com/stpeter/manifesto/master/manifesto.txt">Encrypted
|
||||||
|
* XMPP Manifesto</a>, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and
|
||||||
|
* TLSv1.1. This method goes one step beyond and upgrades the handshake to use TLSv1 or better.
|
||||||
|
* This method requires the underlying OS to support all of TLSv1.2 , 1.1 and 1.0.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param builder the configuration builder to apply this setting to
|
||||||
|
* @param <B> Type of the ConnectionConfiguration builder.
|
||||||
|
*
|
||||||
|
* @return the given builder
|
||||||
|
* @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public static <B extends ConnectionConfiguration.Builder<B, ?>> B setTLSOnly(B builder) {
|
||||||
|
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 });
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable only TLS and SSLv3. Connections created with the given ConnectionConfiguration will
|
||||||
|
* only support TLS and SSLv3.
|
||||||
|
* <p>
|
||||||
|
* According to the <a
|
||||||
|
* href="https://raw.githubusercontent.com/stpeter/manifesto/master/manifesto.txt">Encrypted
|
||||||
|
* XMPP Manifesto</a>, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and
|
||||||
|
* TLSv1.1.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param builder the configuration builder to apply this setting to
|
||||||
|
* @param <B> Type of the ConnectionConfiguration builder.
|
||||||
|
*
|
||||||
|
* @return the given builder
|
||||||
|
* @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
@Deprecated
|
||||||
|
public static <B extends ConnectionConfiguration.Builder<B, ?>> B setSSLv3AndTLSOnly(B builder) {
|
||||||
|
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 });
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept all TLS certificates.
|
* Accept all TLS certificates.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2024 Florian Schmaus
|
* Copyright 2014-2023 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.
|
||||||
|
@ -47,7 +47,6 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
this(pe, null);
|
this(pe, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public XmlStringBuilder(NamedElement e) {
|
public XmlStringBuilder(NamedElement e) {
|
||||||
this();
|
this();
|
||||||
halfOpenElement(e.getElementName());
|
halfOpenElement(e.getElementName());
|
||||||
|
@ -57,7 +56,6 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
this(element.getElementName(), element.getNamespace(), element.getLanguage(), enclosingXmlEnvironment);
|
this(element.getElementName(), element.getNamespace(), element.getLanguage(), enclosingXmlEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("this-escape")
|
|
||||||
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) {
|
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) {
|
||||||
sb = new LazyStringBuilder();
|
sb = new LazyStringBuilder();
|
||||||
halfOpenElement(elementName);
|
halfOpenElement(elementName);
|
||||||
|
@ -140,6 +138,20 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @param element deprecated.
|
||||||
|
* @return deprecated.
|
||||||
|
* @deprecated use {@link #append(Element)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.5.
|
||||||
|
public XmlStringBuilder element(Element element) {
|
||||||
|
assert element != null;
|
||||||
|
return append(element.toXML());
|
||||||
|
}
|
||||||
|
|
||||||
public XmlStringBuilder optElement(String name, String content) {
|
public XmlStringBuilder optElement(String name, String content) {
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
element(name, content);
|
element(name, content);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue