mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Compare commits
269 commits
8d657db561
...
a8f16a1122
Author | SHA1 | Date | |
---|---|---|---|
a8f16a1122 | |||
|
de564689c6 | ||
|
fc76f81e95 | ||
|
e376f55ea9 | ||
|
e1cc1a4185 | ||
|
34f490ff15 | ||
|
c35443928c | ||
|
95900ea41f | ||
|
b0f0ee2330 | ||
|
4c7ec625c0 | ||
|
9a04224bd6 | ||
|
73c935cf95 | ||
|
ea8e15d10f | ||
|
8bd88180be | ||
|
220faa9d3d | ||
|
1fffb90783 | ||
|
c5e9e4832d | ||
|
6857ac6b87 | ||
|
c4d16a6d6c | ||
|
beacb5eb8e | ||
|
d217c32e72 | ||
|
55400633c8 | ||
|
07d9d694da | ||
|
5d2ca5d7d3 | ||
|
2eddf1949a | ||
|
348a3ab091 | ||
|
f59d7f3257 | ||
|
1e5d34eacf | ||
|
e4fcdb6879 | ||
|
d8d066b831 | ||
|
5a822a6631 | ||
|
fd1f692031 | ||
|
ab16e1a32c | ||
|
8d7952cec3 | ||
|
1c1f57d9ff | ||
|
49379afd3f | ||
|
94375e3208 | ||
|
b1071412e2 | ||
|
822115e9f6 | ||
|
4a101e2c99 | ||
|
af77e561c5 | ||
|
300106edb5 | ||
|
6f0499b7f7 | ||
|
63e25bc8cd | ||
|
5633d0e6c2 | ||
|
3dfd90dc34 | ||
|
7024151f5d | ||
|
fc2f258310 | ||
|
b44ade562a | ||
|
3bb07521bb | ||
|
b034e614d4 | ||
|
c85bcadd81 | ||
|
93efdf3eda | ||
|
609781b5ad | ||
|
4f840d1066 | ||
|
38c6dd21b4 | ||
|
4d790aa7db | ||
|
6c7e88f3a0 | ||
|
9c4fcc0931 | ||
|
c99318783e | ||
|
82385ab4d0 | ||
|
3534569a8d | ||
|
c74ebca955 | ||
|
b85be6572c | ||
|
854f847db3 | ||
|
7f3bc3d500 | ||
|
2019e0d943 | ||
|
17d9b742fc | ||
|
050acc4c53 | ||
|
f0b9955311 | ||
|
b3ef3c3477 | ||
|
9a87643429 | ||
|
7c27a707c8 | ||
|
59706d0294 | ||
|
8fcfe2cc33 | ||
|
426a5efb1d | ||
|
d27fef0bae | ||
|
c322ce8046 | ||
|
0c9d521084 | ||
|
47d4cbe094 | ||
|
ba02a868f6 | ||
|
a1e85d644f | ||
|
95adfb3cdf | ||
|
9254f735c7 | ||
|
68fa90435e | ||
|
98ff4d8a65 | ||
|
cf8a8466e4 | ||
|
98dbc0ee2e | ||
|
0bb3bf292c | ||
|
095ba0a3ee | ||
|
a4eb5a7b01 | ||
|
95c39d2a44 | ||
|
7e9a5713e9 | ||
|
440b497638 | ||
|
adafcdb6d1 | ||
|
fc1e670a02 | ||
|
7d618563f4 | ||
|
3f0933e90e | ||
|
2a6e6c7154 | ||
|
a40dd35eeb | ||
|
7e153d87d0 | ||
|
6b912f9aba | ||
|
9e0f20b748 | ||
|
03ee544e0e | ||
|
963c25799a | ||
|
f78766ad6e | ||
|
268c298264 | ||
|
8d66f78b3b | ||
|
b753c4a876 | ||
|
8b20d4b382 | ||
|
f5e5b4a913 | ||
|
cdbc431cdd | ||
|
973f37996f | ||
|
74614b00f7 | ||
|
febb0e8f24 | ||
|
4eafb0ceeb | ||
|
4f09244253 | ||
|
7c77cfbc20 | ||
|
5cbcd67645 | ||
|
b2331aaacf | ||
|
3e2d01ce63 | ||
|
0db1c7a988 | ||
|
6ae8234d25 | ||
|
a708387210 | ||
|
147071ff64 | ||
|
4ce926bd63 | ||
|
7acde2acab | ||
|
1f34f3e613 | ||
|
3749f524f5 | ||
|
34c2d5210e | ||
|
2a5cf149b2 | ||
|
41022d139b | ||
|
d2810cf9b6 | ||
|
bf6b7bd692 | ||
|
35f621be05 | ||
|
c5e3f89e21 | ||
|
9f58c992bd | ||
|
2a243fe3b6 | ||
|
482a117e0d | ||
|
1d498efd46 | ||
|
90c7dc4390 | ||
|
6cda9a6379 | ||
|
e69e7d2342 | ||
|
eed707f39d | ||
|
c87bb8aaa4 | ||
|
9447030cd4 | ||
|
c34c9bdb62 | ||
|
1836537c42 | ||
|
e70d0cd858 | ||
|
c4ce6b4707 | ||
|
1bf0aed0f5 | ||
|
121d4ac245 | ||
|
4cc9a7d7eb | ||
|
617d1bfff2 | ||
|
e08c95a0a1 | ||
|
e0f335be40 | ||
|
e79429e052 | ||
|
e79934938c | ||
|
1bba38decd | ||
|
36d6ff2995 | ||
|
855f01e6b2 | ||
|
5fcd0b56dd | ||
|
8efa4bd732 | ||
|
ad756810c1 | ||
|
26ec0d412d | ||
|
8a71029fbc | ||
|
37f4f35675 | ||
|
77dc527a63 | ||
|
5622bb07d1 | ||
|
2e94599d58 | ||
|
d515a24e1c | ||
|
355cc4eb53 | ||
|
900b25235c | ||
|
6b300ec279 | ||
|
78814d2f86 | ||
|
621dc48865 | ||
|
c67292ea86 | ||
|
2cbdfa0153 | ||
|
2298364384 | ||
|
211cf342a4 | ||
|
d204d24223 | ||
|
8839808746 | ||
|
f76f0791e6 | ||
|
dc96484d2b | ||
|
7139a43291 | ||
|
d92fef432e | ||
|
e3d12eed94 | ||
|
d24767c6a4 | ||
|
4c60986795 | ||
|
951588e4ed | ||
|
0ca22f22a9 | ||
|
505e1088b4 | ||
|
6918663760 | ||
|
435e736995 | ||
|
50a04d8556 | ||
|
92c45e0d29 | ||
|
84a55fa57e | ||
|
806106534d | ||
|
ec4caf6663 | ||
|
449ea73239 | ||
|
f4110ec388 | ||
|
a39e5baa74 | ||
|
e504bc23cf | ||
|
8133505050 | ||
|
8b9a9e0f3e | ||
|
b117d8c3d4 | ||
|
643d85c556 | ||
|
282d63da36 | ||
|
b5180f819f | ||
|
3d6fa5dbae | ||
|
1ad394f256 | ||
|
8425671b31 | ||
|
f6de30c218 | ||
|
bd70d6abc5 | ||
441d677644 | |||
|
90b8eee0d1 | ||
664a141190 | |||
|
726dbc0d27 | ||
|
b7218e3a72 | ||
|
39fe3fc5bb | ||
|
610e5dd803 | ||
|
9e5564a597 | ||
|
7135977cb7 | ||
|
f74f47f6d4 | ||
|
390f6f0fa7 | ||
|
1e666197a3 | ||
|
9acee05e5e | ||
|
844ebbf4c5 | ||
|
688c06020b | ||
|
7fcc8a9bd3 | ||
|
2337a446a5 | ||
|
dac06b04c3 | ||
|
04dc212db8 | ||
|
5a78534443 | ||
|
b35b67c360 | ||
|
6322f4f826 | ||
|
70e48300a6 | ||
|
9203907e66 | ||
|
38dd64835f | ||
|
0fb8bfdf6c | ||
|
472bee8497 | ||
|
535ecd67ee | ||
|
915626123d | ||
|
9055878748 | ||
|
6859de95d0 | ||
|
0469185b62 | ||
|
2dc12db6f4 | ||
|
7eabdaf8f7 | ||
|
097ab20485 | ||
|
2ebffa7615 | ||
|
0552440c1a | ||
|
84ec2c8c2f | ||
|
6d99ba7ffb | ||
|
b5b4418406 | ||
|
2e8f83c579 | ||
|
5560fb4752 | ||
|
a270542397 | ||
|
f593b6d0a0 | ||
|
ccfbf9f346 | ||
|
8c1fa1cc91 | ||
|
6244a213c8 | ||
|
c7f3e231d0 | ||
|
e2d136d992 | ||
|
92d4cf5c77 | ||
38844ee340 | |||
430795bb9e | |||
9bfaf674b1 | |||
|
3b8ebb24c7 | ||
198c51356d |
518 changed files with 10570 additions and 5589 deletions
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
|
@ -6,13 +6,14 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Smack
|
name: Build Smack
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java:
|
java:
|
||||||
- 11
|
- 17
|
||||||
|
- 21
|
||||||
env:
|
env:
|
||||||
PRIMARY_JAVA_VERSION: 11
|
PRIMARY_JAVA_VERSION: 21
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -52,10 +53,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@v2
|
uses: android-actions/setup-android@v3
|
||||||
- name: Install Android SDK
|
- name: Install Android SDK
|
||||||
run: |
|
run: |
|
||||||
sdkmanager "platforms;android-19"
|
sdkmanager "platforms;android-23"
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
- name: Gradle Check
|
- name: Gradle Check
|
||||||
|
@ -71,15 +72,22 @@ jobs:
|
||||||
run: ./gradlew javadocAll --stacktrace
|
run: ./gradlew javadocAll --stacktrace
|
||||||
|
|
||||||
# Test Coverage Report
|
# Test Coverage Report
|
||||||
- name: Jacoco Test Coverage
|
- name: Aggregated Jacoco Test Coverage Report
|
||||||
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
||||||
run: ./gradlew jacocoRootReport coveralls
|
run: |
|
||||||
env:
|
./gradlew smack-java11-full:testCodeCoverageReport
|
||||||
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@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: smack-java-${{ matrix.java }}
|
name: smack-java-${{ matrix.java }}
|
||||||
path: |
|
path: |
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
|
!.idea/icon.svg
|
||||||
|
|
||||||
# Mac OS X
|
# Mac OS X
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
@ -11,7 +12,6 @@
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
.gradle
|
.gradle
|
||||||
gradle.properties
|
|
||||||
|
|
||||||
build/
|
build/
|
||||||
core/build/
|
core/build/
|
||||||
|
|
89
.idea/icon.svg
Normal file
89
.idea/icon.svg
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
viewBox="0 0 399.2693 389.25732"
|
||||||
|
height="389.25732"
|
||||||
|
width="399.26932"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="smack-logo-plain.svg"><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="834"
|
||||||
|
inkscape:window-height="1044"
|
||||||
|
id="namedview3432"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:zoom="0.65684805"
|
||||||
|
inkscape:cx="238.37045"
|
||||||
|
inkscape:cy="159.12321"
|
||||||
|
inkscape:window-x="2520"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="svg2" /><metadata
|
||||||
|
id="metadata8"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs6"><clipPath
|
||||||
|
id="clipPath18"
|
||||||
|
clipPathUnits="userSpaceOnUse"><path
|
||||||
|
id="path16"
|
||||||
|
d="M 0,600 800,600 800,0 0,0 Z"
|
||||||
|
inkscape:connector-curvature="0" /></clipPath><clipPath
|
||||||
|
id="clipPath30"
|
||||||
|
clipPathUnits="userSpaceOnUse"><path
|
||||||
|
id="path28"
|
||||||
|
d="m 351.001,359.31 c -17.234,-7.3 -51.945,15.909 -51.945,15.909 l 0,0 c 0,0 31.115,-33.702 27.068,-47.102 l 0,0 c -4.048,-13.401 -44.827,-30.694 -44.827,-30.694 l 0,0 c 0,0 51.173,5.823 53.705,-8.205 l 0,0 c 2.528,-14.031 -3.951,-54.186 -3.951,-54.186 l 0,0 c 0,0 25.887,37.471 39.897,36.872 l 0,0 c 14.012,-0.597 39.902,-36.872 39.902,-36.872 l 0,0 c 0,0 -14.178,43.955 -3.952,54.186 l 0,0 c 10.225,10.229 53.706,8.205 53.706,8.205 l 0,0 c 0,0 -43.02,12.932 -44.827,30.694 l 0,0 c -1.81,17.759 27.07,47.102 27.07,47.102 l 0,0 c 0,0 -35.718,-23.04 -51.948,-15.909 l 0,0 c -16.232,7.13 -19.951,50.533 -19.951,50.533 l 0,0 c 0,0 -2.718,-43.232 -19.947,-50.533"
|
||||||
|
inkscape:connector-curvature="0" /></clipPath><radialGradient
|
||||||
|
id="radialGradient40"
|
||||||
|
spreadMethod="pad"
|
||||||
|
gradientTransform="matrix(89.254456,0,0,-89.254456,370.9502,322.4375)"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
r="1"
|
||||||
|
cy="0"
|
||||||
|
cx="0"
|
||||||
|
fy="0"
|
||||||
|
fx="0"><stop
|
||||||
|
id="stop36"
|
||||||
|
offset="0"
|
||||||
|
style="stop-opacity:1;stop-color:#fdbe10" /><stop
|
||||||
|
id="stop38"
|
||||||
|
offset="1"
|
||||||
|
style="stop-opacity:1;stop-color:#f16422" /></radialGradient></defs><g
|
||||||
|
transform="matrix(1.3333333,0,0,-1.3333333,-294.96293,630.13412)"
|
||||||
|
id="g10"><g
|
||||||
|
id="g12"><g
|
||||||
|
clip-path="url(#clipPath18)"
|
||||||
|
id="g14"><g
|
||||||
|
transform="translate(370.9482,472.6006)"
|
||||||
|
id="g20"><path
|
||||||
|
id="path22"
|
||||||
|
style="fill:#fdbe10;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||||
|
d="m 0,0 c 0,0 6.213,-72.485 33.318,-84.392 27.104,-11.905 86.753,26.569 86.753,26.569 0,0 -48.228,-49.006 -45.209,-78.665 3.022,-29.661 74.864,-51.262 74.864,-51.262 0,0 -72.61,3.382 -89.688,-13.703 -17.078,-17.084 6.597,-90.49 6.597,-90.49 0,0 -43.237,60.579 -66.635,61.578 -23.4,1.003 -66.633,-61.578 -66.633,-61.578 0,0 10.826,67.062 6.601,90.49 -4.229,23.431 -89.694,13.703 -89.694,13.703 0,0 68.108,28.882 74.865,51.262 6.757,22.378 -45.21,78.665 -45.21,78.665 0,0 57.978,-38.76 86.757,-26.569 C -4.54,-72.2 0,0 0,0"
|
||||||
|
inkscape:connector-curvature="0" /></g></g></g><g
|
||||||
|
id="g24"><g
|
||||||
|
clip-path="url(#clipPath30)"
|
||||||
|
id="g26"><g
|
||||||
|
id="g32"><g
|
||||||
|
id="g34"><path
|
||||||
|
id="path42"
|
||||||
|
style="fill:url(#radialGradient40);stroke:none"
|
||||||
|
d="m 351.001,359.31 c -17.234,-7.3 -51.945,15.909 -51.945,15.909 l 0,0 c 0,0 31.115,-33.702 27.068,-47.102 l 0,0 c -4.048,-13.401 -44.827,-30.694 -44.827,-30.694 l 0,0 c 0,0 51.173,5.823 53.705,-8.205 l 0,0 c 2.528,-14.031 -3.951,-54.186 -3.951,-54.186 l 0,0 c 0,0 25.887,37.471 39.897,36.872 l 0,0 c 14.012,-0.597 39.902,-36.872 39.902,-36.872 l 0,0 c 0,0 -14.178,43.955 -3.952,54.186 l 0,0 c 10.225,10.229 53.706,8.205 53.706,8.205 l 0,0 c 0,0 -43.02,12.932 -44.827,30.694 l 0,0 c -1.81,17.759 27.07,47.102 27.07,47.102 l 0,0 c 0,0 -35.718,-23.04 -51.948,-15.909 l 0,0 c -16.232,7.13 -19.951,50.533 -19.951,50.533 l 0,0 c 0,0 -2.718,-43.232 -19.947,-50.533"
|
||||||
|
inkscape:connector-curvature="0" /></g></g></g></g></g></svg>
|
After Width: | Height: | Size: 4.9 KiB |
26
CHANGELOG.md
26
CHANGELOG.md
|
@ -1,5 +1,31 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
### Improvement
|
||||||
|
|
||||||
|
- [SMACK-929](https://igniterealtime.atlassian.net/browse/SMACK-929) Ignore IPv6 Zone IDs in incoming Jingle candidates
|
||||||
|
- [SMACK-934](https://igniterealtime.atlassian.net/browse/SMACK-934) Deprecate and remove ChatMarkersManager.isSupportedByServer\(\)
|
||||||
|
- [SMACK-937](https://igniterealtime.atlassian.net/browse/SMACK-937) Avoid unnecessary feature lookups by making the EntityCaps listener synchronous
|
||||||
|
|
||||||
|
### Bug
|
||||||
|
|
||||||
|
- [SMACK-927](https://igniterealtime.atlassian.net/browse/SMACK-927) Deadlock due to recveive listeners may be invoked after AbstractXMPPConnection.invokeStanzaCollectorsAndNotifyRecvListeners\(\) returned
|
||||||
|
- [SMACK-930](https://igniterealtime.atlassian.net/browse/SMACK-930) Rename ELEMENT 'candidate-activated' to 'activated' per XEP-0260
|
||||||
|
- [SMACK-931](https://igniterealtime.atlassian.net/browse/SMACK-931) IQ error stanza generation does not allow adding of an extension element
|
||||||
|
|
||||||
# 4.4.6 -- 2022-06-29
|
# 4.4.6 -- 2022-06-29
|
||||||
|
|
||||||
### Bug
|
### Bug
|
||||||
|
|
30
Makefile
Normal file
30
Makefile
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
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"
|
14
build-logic/build.gradle
Normal file
14
build-logic/build.gradle
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
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
build-logic/settings.gradle
Normal file
1
build-logic/settings.gradle
Normal file
|
@ -0,0 +1 @@
|
||||||
|
rootProject.name = 'smack-build-logic'
|
|
@ -0,0 +1,6 @@
|
||||||
|
compileJava {
|
||||||
|
options.bootstrapClasspath = files(androidBootClasspath)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
classpath += files(androidBootClasspath)
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
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]
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
plugins {
|
||||||
|
id 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
applicationDefaultJvmArgs = ["-enableassertions"]
|
||||||
|
}
|
||||||
|
|
||||||
|
run {
|
||||||
|
// Pass all system properties down to the "application" run
|
||||||
|
systemProperties System.getProperties()
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -0,0 +1,367 @@
|
||||||
|
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()
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
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"
|
||||||
|
}
|
722
build.gradle
722
build.gradle
|
@ -1,347 +1,20 @@
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'ru.vyarus.animalsniffer' version '1.5.0'
|
// The scalastyle plugin of smack-repl wants the root project to
|
||||||
id 'net.ltgt.errorprone' version '1.3.0'
|
// have a ideaProject task, so let's add one.
|
||||||
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
|
id 'idea'
|
||||||
id 'com.dorongold.task-tree' version '1.5'
|
|
||||||
id 'com.github.kt3k.coveralls' version '2.10.2'
|
id 'org.igniterealtime.smack.javadoc-conventions'
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
java11Projects = [
|
javadocAllDir = new File(buildDir, 'javadoc')
|
||||||
|
integrationTestProjects = [
|
||||||
':smack-integration-test',
|
':smack-integration-test',
|
||||||
':smack-omemo-signal-integration-test',
|
':smack-omemo-signal-integration-test',
|
||||||
':smack-repl',
|
].collect{ project(it) }
|
||||||
':smack-websocket-java11',
|
javadocAllProjects = subprojects - integrationTestProjects
|
||||||
].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-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.71'
|
|
||||||
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 ->
|
||||||
|
@ -390,315 +63,6 @@ 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
|
||||||
|
@ -706,7 +70,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 project(':smack-omemo-signal-integration-test').tasks.run
|
dependsOn 'smack-omemo-signal-integration-test:run'
|
||||||
}
|
}
|
||||||
|
|
||||||
task sinttestAll {
|
task sinttestAll {
|
||||||
|
@ -717,70 +81,6 @@ 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
|
||||||
|
@ -791,7 +91,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*Artifcat*Identifier, and we check the
|
// Component*Artifact*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
|
||||||
}
|
}
|
||||||
|
|
20
config/checkstyle/smack-examples-gplv3-license-header.txt
Normal file
20
config/checkstyle/smack-examples-gplv3-license-header.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 20XX John Doe
|
||||||
|
*
|
||||||
|
* This file is part of smack-examples.
|
||||||
|
*
|
||||||
|
* smack-examples is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
5
gradle.properties
Normal file
5
gradle.properties
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# 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,5 +1,7 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
297
gradlew
vendored
297
gradlew
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original 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,69 +15,104 @@
|
||||||
# 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 UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# 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
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) 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
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$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* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
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
|
||||||
|
@ -87,9 +122,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
|
||||||
|
@ -98,88 +133,120 @@ 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
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
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
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -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
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# 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,8 +13,10 @@
|
||||||
@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
|
||||||
|
@ -25,7 +27,8 @@
|
||||||
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%
|
||||||
|
|
||||||
|
@ -40,13 +43,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%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -75,13 +78,15 @@ 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%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 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!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=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,7 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -euo pipefail
|
||||||
set -u
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
JDWP=false
|
JDWP=false
|
||||||
JDWP_PORT=8000
|
JDWP_PORT=8000
|
||||||
|
@ -37,12 +35,13 @@ 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 :smack-repl:printClasspath --quiet |\
|
GRADLE_CLASSPATH="$(${GRADLE_BIN:-./gradlew} :smack-repl:printClasspath --quiet |\
|
||||||
tail -n1)"
|
tail -n1)"
|
||||||
echo "Finished, starting REPL"
|
echo "Finished, starting REPL"
|
||||||
|
|
||||||
java "${EXTRA_JAVA_ARGS[@]}" \
|
exec java \
|
||||||
|
"${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 serivce."
|
SMACK_EXCEPTIONS[NotAMucServiceException]="if the entity is not a MUC service."
|
||||||
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 availble."
|
SMACK_EXCEPTIONS[NoSuchPaddingException]="if the requested padding mechanism is not available."
|
||||||
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 statemtents, e.g. "2001-2013 FooBar, 2014 Baz"
|
# Split multi Copyright statements, 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]*//" | \
|
||||||
|
|
|
@ -1,221 +0,0 @@
|
||||||
<!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,3 +1,7 @@
|
||||||
|
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
|
||||||
|
@ -6,6 +10,7 @@ rootProject.name = 'Smack'
|
||||||
include 'smack-core',
|
include 'smack-core',
|
||||||
'smack-im',
|
'smack-im',
|
||||||
'smack-tcp',
|
'smack-tcp',
|
||||||
|
'smack-examples',
|
||||||
'smack-extensions',
|
'smack-extensions',
|
||||||
'smack-experimental',
|
'smack-experimental',
|
||||||
'smack-debug',
|
'smack-debug',
|
||||||
|
@ -22,8 +27,8 @@ include 'smack-core',
|
||||||
'smack-bosh',
|
'smack-bosh',
|
||||||
'smack-android',
|
'smack-android',
|
||||||
'smack-android-extensions',
|
'smack-android-extensions',
|
||||||
'smack-java8',
|
'smack-java11',
|
||||||
'smack-java8-full',
|
'smack-java11-full',
|
||||||
'smack-integration-test',
|
'smack-integration-test',
|
||||||
'smack-omemo',
|
'smack-omemo',
|
||||||
'smack-omemo-signal',
|
'smack-omemo-signal',
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
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."""
|
||||||
|
|
||||||
|
@ -8,5 +14,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.
|
||||||
compileClasspath files(androidBootClasspath)
|
implementation files(androidBootClasspath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
../../../../../../../smack-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2021 Florian Schmaus
|
* Copyright © 2014-2024 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,7 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,6 +122,7 @@ 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;
|
||||||
|
@ -163,7 +165,7 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
private static AlarmManager sAlarmManager;
|
private static AlarmManager sAlarmManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a pending intent with the AlarmManager to be broadcasted every half hour and
|
* Register a pending intent with the AlarmManager to be broadcast 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.
|
||||||
*
|
*
|
||||||
|
@ -173,7 +175,11 @@ 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);
|
||||||
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), 0);
|
int pendingIntentFlags = 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,3 +1,9 @@
|
||||||
|
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.
|
||||||
|
@ -16,13 +22,13 @@ dependencies {
|
||||||
// used in non-Android projects.
|
// used in non-Android projects.
|
||||||
implementation "org.minidns:minidns-android21:$miniDnsVersion"
|
implementation "org.minidns:minidns-android21:$miniDnsVersion"
|
||||||
|
|
||||||
// androidProjects lists all projects that are checked to compile against android.jar
|
api project(':smack-core')
|
||||||
// Filter out the optional Smack dependencies from androidProjects
|
api project(':smack-im')
|
||||||
(androidProjects - androidOptionalProjects)
|
api project(':smack-resolver-minidns')
|
||||||
.each { project ->
|
api project(':smack-sasl-provided')
|
||||||
api project
|
api project(':smack-xmlparser')
|
||||||
}
|
api project(':smack-xmlparser-xpp3')
|
||||||
|
|
||||||
// Add the Android jar to the Eclipse .classpath.
|
// Add the Android jar to the Eclipse .classpath.
|
||||||
compileClasspath files(androidBootClasspath)
|
implementation files(androidBootClasspath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ 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-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -1,3 +1,8 @@
|
||||||
|
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."""
|
||||||
|
|
|
@ -172,14 +172,15 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
client = BOSHClient.create(cfgBuilder.build());
|
client = BOSHClient.create(cfgBuilder.build());
|
||||||
|
|
||||||
client.addBOSHClientConnListener(new BOSHConnectionListener());
|
// Initialize the debugger before addBOSHClientResponseListener(new BOSHPacketReader());
|
||||||
client.addBOSHClientResponseListener(new BOSHPacketReader());
|
// BOSHPacketReader may hold and send response prior to display of the request i.e. <response/> before <challenge/>
|
||||||
|
|
||||||
// Initialize the debugger
|
|
||||||
if (debugger != null) {
|
if (debugger != null) {
|
||||||
initDebugger();
|
initDebugger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.addBOSHClientConnListener(new BOSHConnectionListener());
|
||||||
|
client.addBOSHClientResponseListener(new BOSHPacketReader());
|
||||||
|
|
||||||
// Send the session creation request
|
// Send the session creation request
|
||||||
client.send(ComposableBody.builder()
|
client.send(ComposableBody.builder()
|
||||||
.setNamespaceDefinition("xmpp", XMPP_BOSH_NS)
|
.setNamespaceDefinition("xmpp", XMPP_BOSH_NS)
|
||||||
|
@ -359,10 +360,11 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
CloseableUtil.maybeClose(reader, LOGGER);
|
CloseableUtil.maybeClose(reader, LOGGER);
|
||||||
CloseableUtil.maybeClose(writer, LOGGER);
|
CloseableUtil.maybeClose(writer, LOGGER);
|
||||||
|
|
||||||
|
// set readerConsumer = null before reader to avoid NPE reference
|
||||||
|
readerConsumer = null;
|
||||||
readerPipe = null;
|
readerPipe = null;
|
||||||
reader = null;
|
reader = null;
|
||||||
writer = null;
|
writer = null;
|
||||||
readerConsumer = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,6 +442,8 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
if (event.getBody() != null) {
|
if (event.getBody() != null) {
|
||||||
try {
|
try {
|
||||||
writer.write(event.getBody().toXML());
|
writer.write(event.getBody().toXML());
|
||||||
|
// Fix all BOSH sent debug messages not shown
|
||||||
|
writer.flush();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Note that this is also declared in the main build.gradle for
|
plugins {
|
||||||
// subprojects, but since evaluationDependsOnChildren is enabled we
|
id 'org.igniterealtime.smack.java-common-conventions'
|
||||||
// need to declare it here too to have bundle{bnd{...}} available
|
id 'org.igniterealtime.smack.android-conventions'
|
||||||
apply plugin: 'biz.aQute.bnd.builder'
|
}
|
||||||
|
|
||||||
description = """\
|
description = """\
|
||||||
Smack core components."""
|
Smack core components."""
|
||||||
|
@ -16,6 +16,9 @@ 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')
|
||||||
|
|
||||||
|
@ -28,7 +31,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"
|
||||||
// Explictily add assertj-core which is a dependency of
|
// Explicitly 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'.
|
||||||
|
@ -59,7 +62,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')
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.dependsOn(createVersionResource)
|
processResources.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 recieved from remote user", message);
|
assertNotNull("Message not received 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).
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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-2022 Florian Schmaus.
|
* Copyright 2009 Jive Software, 2018-2024 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,6 +19,7 @@ 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;
|
||||||
|
@ -128,7 +129,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>
|
||||||
|
@ -387,6 +388,7 @@ 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;
|
||||||
|
@ -1067,6 +1069,7 @@ 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);
|
||||||
|
@ -1214,7 +1217,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
Stanza packet = (Stanza) sendTopLevelStreamElement;
|
Stanza packet = (Stanza) sendTopLevelStreamElement;
|
||||||
|
|
||||||
final List<StanzaListener> listenersToNotify = new LinkedList<>();
|
final List<StanzaListener> listenersToNotify = new ArrayList<>();
|
||||||
synchronized (sendListeners) {
|
synchronized (sendListeners) {
|
||||||
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
|
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
|
||||||
if (listenerWrapper.filterMatches(packet)) {
|
if (listenerWrapper.filterMatches(packet)) {
|
||||||
|
@ -1242,27 +1245,6 @@ 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) {
|
||||||
|
@ -1305,7 +1287,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 LinkedList<>();
|
List<Consumer<MPB>> interceptorsToInvoke = new ArrayList<>();
|
||||||
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)) {
|
||||||
|
@ -1340,7 +1322,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 LinkedList<>();
|
List<StanzaListener> interceptorsToInvoke = new ArrayList<>();
|
||||||
synchronized (interceptors) {
|
synchronized (interceptors) {
|
||||||
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
|
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
|
||||||
if (interceptorWrapper.filterMatches(packet)) {
|
if (interceptorWrapper.filterMatches(packet)) {
|
||||||
|
@ -1625,7 +1607,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 LinkedList<>();
|
final Collection<StanzaListener> listenersToNotify = new ArrayList<>();
|
||||||
extractMatchingListeners(packet, asyncRecvListeners, listenersToNotify);
|
extractMatchingListeners(packet, asyncRecvListeners, listenersToNotify);
|
||||||
for (final StanzaListener listener : listenersToNotify) {
|
for (final StanzaListener listener : listenersToNotify) {
|
||||||
asyncGoLimited(new Runnable() {
|
asyncGoLimited(new Runnable() {
|
||||||
|
@ -1951,7 +1933,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
// Default implementation does nothing
|
// Default implementation does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
@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);
|
||||||
|
@ -2196,6 +2178,7 @@ 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 ourselfs from the map.
|
* to take care of removing the keys ourselves 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-existend in the map.
|
* active, otherwise the key is non-existent 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-2022 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2017-2024 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(), setCallbackHanlder() and
|
// TODO: Remove the block below once we removed setKeystorePath(), setKeystoreType(), setCallbackHandler() 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.
|
* @return the stream language to use when connecting to the server or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public Locale getLanguage() {
|
public Locale getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -544,19 +544,21 @@ 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. If a Locale("") is configured, this will
|
* the removal of the xml:lang tag from the stream.</p>
|
||||||
* return "", which can be used as an override.</p>
|
|
||||||
*
|
*
|
||||||
* @return 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>.
|
||||||
*/
|
*/
|
||||||
public String getXmlLang() {
|
public String getXmlLang() {
|
||||||
// TODO: Change to Locale.toLanguageTag() once Smack's minimum Android API level is 21 or higher.
|
if (language == null) {
|
||||||
// This will need a workaround for new Locale("").getLanguageTag() returning "und". Expected
|
return null;
|
||||||
// behavior of this function:
|
}
|
||||||
// - returns null if language is null
|
|
||||||
// - returns "" if language.getLanguage() returns the empty string
|
String languageTag = language.toLanguageTag();
|
||||||
// - returns language.toLanguageTag() otherwise
|
if (languageTag.equals("und")) {
|
||||||
return language != null ? language.toString().replace("_", "-") : null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return languageTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -583,7 +585,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.
|
||||||
*/
|
*/
|
||||||
|
@ -592,7 +594,7 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given SASL mechansism is enabled in this connection configuration.
|
* Check if the given SASL mechanism 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.
|
||||||
|
@ -607,7 +609,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 SALS mechanisms supported and announced by the service will be considered.
|
* explicitly enabled, i.e. all SASL 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>.
|
||||||
*/
|
*/
|
||||||
|
@ -670,6 +672,7 @@ 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();
|
||||||
|
@ -857,22 +860,6 @@ 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(
|
||||||
|
@ -1021,25 +1008,6 @@ 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>
|
||||||
|
@ -1090,8 +1058,7 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if an initial available presence will be sent to the server. By default
|
* 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
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
@ -1187,7 +1154,9 @@ 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");
|
||||||
}
|
}
|
||||||
setCustomSSLContext(sslContext);
|
setSslContextFactory(() -> {
|
||||||
|
return sslContext;
|
||||||
|
});
|
||||||
throwIfEnabledSaslMechanismsSet();
|
throwIfEnabledSaslMechanismsSet();
|
||||||
|
|
||||||
allowEmptyOrNullUsernames();
|
allowEmptyOrNullUsernames();
|
||||||
|
@ -1266,7 +1235,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.
|
||||||
|
@ -1324,7 +1293,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 Florian Schmaus
|
* Copyright 2018-2024 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,11 +50,13 @@ 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, eg "1.3.0".
|
* Returns the Smack version information, e.g."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, eg "1.3.0".
|
* Returns the Smack version information, e.g."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-2020 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2014-2024 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-2020 Florian Schmaus
|
* Copyright 2018-2024 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,6 +144,7 @@ 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);
|
||||||
|
@ -276,8 +277,7 @@ public class SmackReactor {
|
||||||
setInterestOpsCancelledKeySafe(selectionKey, 0);
|
setInterestOpsCancelledKeySafe(selectionKey, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedKeys = new ArrayList<>(selectedKeySet.size());
|
selectedKeys = new ArrayList<>(selectedKeySet);
|
||||||
selectedKeys.addAll(selectedKeySet);
|
|
||||||
selectedKeySet.clear();
|
selectedKeySet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +327,12 @@ public class SmackReactor {
|
||||||
|
|
||||||
int currentReactorThreadCount = reactorThreads.size();
|
int currentReactorThreadCount = reactorThreads.size();
|
||||||
int myKeyCount = pendingSelectionKeysSize / currentReactorThreadCount;
|
int myKeyCount = pendingSelectionKeysSize / currentReactorThreadCount;
|
||||||
|
// The division could result in myKeyCount being zero, even though there are pending selection keys.
|
||||||
|
// Therefore, ensure that this thread tries to get at least one pending selection key by invoking poll().
|
||||||
|
// Otherwise, it could happen that we end up in a busy loop, where myKeyCount is zero and this thread invokes
|
||||||
|
// selector.wakeup() below because pendingSelectionsKeys is not empty, but the woken up reactor thread wil
|
||||||
|
// end up with myKeyCount being zero again, restarting the busy-loop cycle.
|
||||||
|
if (myKeyCount == 0) myKeyCount = 1;
|
||||||
Collection<SelectionKey> selectedKeys = new ArrayList<>(myKeyCount);
|
Collection<SelectionKey> selectedKeys = new ArrayList<>(myKeyCount);
|
||||||
for (int i = 0; i < myKeyCount; i++) {
|
for (int i = 0; i < myKeyCount; i++) {
|
||||||
SelectionKey selectionKey = pendingSelectionKeys.poll();
|
SelectionKey selectionKey = pendingSelectionKeys.poll();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2016-2024 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")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
public synchronized <P extends Stanza> P pollResult() {
|
public synchronized <P extends Stanza> P pollResult() {
|
||||||
return (P) resultQueue.poll();
|
return (P) resultQueue.poll();
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,7 @@ 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) {
|
||||||
|
@ -150,7 +151,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")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
// 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();
|
||||||
|
@ -175,6 +176,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("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());
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,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")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
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;
|
||||||
|
@ -223,6 +225,7 @@ 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());
|
||||||
|
@ -263,6 +266,7 @@ 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,12 +27,6 @@ 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
|
||||||
|
|
|
@ -91,23 +91,24 @@ import org.jxmpp.jid.EntityFullJid;
|
||||||
* <h2>Incoming Stanza Listeners</h2>
|
* <h2>Incoming Stanza Listeners</h2>
|
||||||
* Most callbacks (listeners, handlers, …) than you can add to a connection come in three different variants:
|
* Most callbacks (listeners, handlers, …) than you can add to a connection come in three different variants:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>standard</li>
|
* <li>asynchronous - e.g., {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}</li>
|
||||||
* <li>async (asynchronous)</li>
|
* <li>synchronous - e.g., {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)}</li>
|
||||||
* <li>sync (synchronous)</li>
|
* <li>other - e.g., {@link #addStanzaListener(StanzaListener, StanzaFilter)}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Standard callbacks are invoked concurrently, but it is ensured that the same callback is never run concurrently.
|
* Asynchronous callbacks are run decoupled from the connections main event loop. Hence, a callback triggered by
|
||||||
* The callback's identity is used as key for that. The events delivered to the callback preserve the order of the
|
|
||||||
* causing events of the connection.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* 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>
|
||||||
* Synchronous callbacks are run synchronous to the main event loop of a connection. Hence they are invoked in the
|
* Synchronous callbacks are invoked concurrently, but it is ensured that the same callback is never run concurrently
|
||||||
* exact order of how events happen there, most importantly the arrival order of incoming stanzas. You should only
|
* and that they are executed in order. That is, if both stanza A and B trigger the same callback, and A arrives before
|
||||||
* use synchronous callbacks in rare situations.
|
* B, then the callback will be invoked with A first, and then B. Furthermore, those callbacks are not executed within
|
||||||
|
* the main loop. However it is still advisable that those callbacks do not block or only block briefly.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Other callbacks are run synchronous to the main event loop of a connection and are executed within the main loop.
|
||||||
|
* <b>This means that if such a callback blocks, the main event loop also blocks, which can easily cause deadlocks.
|
||||||
|
* Therefore, you should avoid using those callbacks unless you know what you are doing.</b>
|
||||||
* </p>
|
* </p>
|
||||||
* <h2>Stanza Filters</h2>
|
* <h2>Stanza Filters</h2>
|
||||||
* Stanza filters allow you to define the predicates for which listeners or collectors should be invoked. For more
|
* Stanza filters allow you to define the predicates for which listeners or collectors should be invoked. For more
|
||||||
|
@ -241,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 send, {@code false} otherwise.
|
* @return {@code true} if the stanza was successfully scheduled to be sent, {@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.
|
||||||
|
@ -264,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 send, {@code false} otherwise.
|
* @return {@code true} if the stanza was successfully scheduled to be sent, {@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
|
||||||
|
@ -317,6 +318,7 @@ 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;
|
||||||
|
|
||||||
|
@ -409,7 +411,7 @@ public interface XMPPConnection {
|
||||||
boolean removeStanzaListener(StanzaListener stanzaListener);
|
boolean removeStanzaListener(StanzaListener stanzaListener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a <b>synchronous</b> stanza listener with this connection. A stanza listener will be invoked only when
|
* Registers a <b>synchronous</b> stanza listener with this connection. A stanza listener will be invoked only when
|
||||||
* an incoming stanza is received. A stanza filter determines which stanzas will be delivered to the listener. If
|
* an incoming stanza is received. A stanza filter determines which stanzas will be delivered to the listener. If
|
||||||
* the same stanza listener is added again with a different filter, only the new filter will be used.
|
* the same stanza listener is added again with a different filter, only the new filter will be used.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -422,7 +424,6 @@ 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);
|
||||||
|
@ -448,7 +449,6 @@ 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,34 +482,6 @@ 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
|
||||||
|
@ -610,23 +582,6 @@ 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.
|
||||||
|
@ -636,6 +591,7 @@ 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 fliped by the caller. The callee must not flip the buffer.
|
* The returned {@link ByteBuffer} is going to get flipped by the caller. The callee must not flip the buffer.
|
||||||
* @param inputData the data this methods needs to process.
|
* @param inputData the data this method 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")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
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/Shtudown in a cycle over the initial state towards this
|
// where we do not want to walk via InstantShutdown/Shutdown 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,6 +658,7 @@ 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);
|
||||||
|
@ -666,7 +667,8 @@ 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);
|
||||||
|
@ -707,6 +709,8 @@ 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);
|
||||||
|
@ -817,6 +821,8 @@ 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);
|
||||||
|
@ -849,6 +855,8 @@ 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);
|
||||||
|
@ -892,6 +900,8 @@ 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);
|
||||||
|
@ -899,6 +909,8 @@ 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);
|
||||||
|
@ -954,6 +966,8 @@ 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);
|
||||||
|
@ -994,6 +1008,8 @@ 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);
|
||||||
|
@ -1056,6 +1072,8 @@ 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);
|
||||||
|
@ -1077,6 +1095,8 @@ 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-2020 Florian Schmaus
|
* Copyright 2018-2024 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,6 +41,8 @@ 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,7 +143,9 @@ 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;
|
||||||
outputBuffer.position(newOutputBufferPosition);
|
// Workaround for Android API not matching Java >=9 API.
|
||||||
|
// See https://issuetracker.google.com/issues/369219141
|
||||||
|
((java.nio.Buffer) outputBuffer).position(newOutputBufferPosition);
|
||||||
|
|
||||||
totalBytesWritten += bytesWritten;
|
totalBytesWritten += bytesWritten;
|
||||||
|
|
||||||
|
@ -156,7 +158,9 @@ 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);
|
||||||
outputBuffer.flip();
|
// Workaround for Android API not matching Java >=9 API.
|
||||||
|
// See https://issuetracker.google.com/issues/369219141
|
||||||
|
((java.nio.Buffer) outputBuffer).flip();
|
||||||
newCurrentOutputBuffer.put(outputBuffer);
|
newCurrentOutputBuffer.put(outputBuffer);
|
||||||
outputBuffer = newCurrentOutputBuffer;
|
outputBuffer = newCurrentOutputBuffer;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +206,9 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
outputBuffer.position(inflateOutputBufferOffset + bytesInflated);
|
// Workaround for Android API not matching Java >=9 API.
|
||||||
|
// See https://issuetracker.google.com/issues/369219141
|
||||||
|
((java.nio.Buffer) outputBuffer).position(inflateOutputBufferOffset + bytesInflated);
|
||||||
|
|
||||||
decompressorOutBytes += bytesInflated;
|
decompressorOutBytes += bytesInflated;
|
||||||
|
|
||||||
|
@ -212,7 +218,9 @@ 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);
|
||||||
outputBuffer.flip();
|
// Workaround for Android API not matching Java >=9 API.
|
||||||
|
// 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:unsingedShort".
|
* A number representing an unsigned 16-bit integer. Can be used for values with the XML schema type "xs:unsignedShort".
|
||||||
*/
|
*/
|
||||||
public final class UInt16 extends Scalar implements Comparable<UInt16> {
|
public final class UInt16 extends Scalar implements Comparable<UInt16> {
|
||||||
|
|
||||||
|
|
|
@ -28,19 +28,20 @@ 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>
|
||||||
*
|
*
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class ConsoleDebugger extends AbstractDebugger {
|
public class ConsoleDebugger extends AbstractDebugger {
|
||||||
private final SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss");
|
private final SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.S");
|
||||||
|
|
||||||
public ConsoleDebugger(XMPPConnection connection) {
|
public ConsoleDebugger(XMPPConnection connection) {
|
||||||
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 authenticed().
|
// TODO: Should be replaced with a connection listener authenticated().
|
||||||
public abstract void userHasLogged(EntityFullJid user);
|
public abstract void userHasLogged(EntityFullJid user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software.
|
* Copyright 2003-2007 Jive Software, 2024 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -43,4 +44,9 @@ 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,6 +18,7 @@
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,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(Stanza stanza) {
|
public StanzaIdFilter(StanzaView 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 exentsion element</li>
|
* <li>{@link ExtensionElementFilter}: filters for stanzas that have a particular stanza extension 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 cosntructState() method is overriden.
|
// TODO: Add validation check that if stateClassConstructor is 'null' the constructState() method is overridden.
|
||||||
}
|
}
|
||||||
|
|
||||||
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-2021 Florian Schmaus
|
* Copyright 2018-2024 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 intial node has their successors inferred.
|
// Ensure that the initial 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 <E> void stateDescriptorGraphToDot(Collection<GraphVertex<StateDescriptor>> vertexes,
|
public static 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-2018 Florian Schmaus
|
* Copyright 2014-2024 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.LinkedList;
|
import java.util.ArrayList;
|
||||||
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 LinkedList<Exception>();
|
final List<Exception> exceptions = new ArrayList<Exception>();
|
||||||
final String providerUriString = getProvidersUri();
|
final String providerUriString = getProvidersUri();
|
||||||
if (providerUriString != null) {
|
if (providerUriString != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,6 +41,8 @@ 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-2021 Florian Schmaus
|
* Copyright 2014-2024 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,6 +108,7 @@ 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-2019 Florian Schmaus
|
* Copyright © 2017-2024 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,15 +54,4 @@ 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-2023 Florian Schmaus
|
* Copyright © 2014-2024 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,7 @@ 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 Type getType() {
|
public final 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 IllegalArgmentException will be thrown when type is
|
* Since the type of an IQ must present, an IllegalArgumentException 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()));
|
||||||
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
// TODO: 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,20 +287,6 @@ 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-2020 Florian Schmaus
|
* Copyright © 2014-2024 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 LinkedList<String>();
|
public final List<String> mechanisms = new ArrayList<String>();
|
||||||
|
|
||||||
public Mechanisms(String mechanism) {
|
public Mechanisms(String mechanism) {
|
||||||
mechanisms.add(mechanism);
|
mechanisms.add(mechanism);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
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;
|
||||||
|
@ -29,10 +28,6 @@ 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:
|
||||||
*
|
*
|
||||||
|
@ -63,85 +58,7 @@ 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 Type type;
|
private final 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);
|
||||||
|
@ -170,197 +87,6 @@ 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;
|
||||||
|
@ -412,22 +138,6 @@ 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,11 +20,6 @@ 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-2021 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2020-2024 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,12 +21,9 @@ 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:
|
||||||
|
@ -78,55 +75,6 @@ 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;
|
||||||
|
@ -186,36 +134,11 @@ 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();
|
||||||
|
@ -233,20 +156,11 @@ 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.5.
|
// TODO: Remove in Smack 4.6.
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -259,19 +173,6 @@ 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;
|
||||||
|
@ -346,37 +247,6 @@ 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,6 +39,7 @@ 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-2021 Florian Schmaus.
|
* Copyright 2015-2024 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,9 +53,7 @@ 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,22 +159,6 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -219,7 +203,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 void setTo(Jid to) {
|
public final void setTo(Jid to) {
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,34 +239,11 @@ 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) {
|
||||||
|
@ -374,22 +335,6 @@ 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) {
|
||||||
|
@ -501,27 +446,6 @@ 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 recipent address of the stanza.
|
* Set the recipient address of the stanza.
|
||||||
*
|
*
|
||||||
* @param to whoe the stanza is being sent to.
|
* @param to whom the stanza is being sent.
|
||||||
* @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-2021 Florian Schmaus
|
* Copyright 2019-2024 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.<p>
|
* attribute optional, so it does not always need to be set.
|
||||||
*
|
*
|
||||||
* @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.<p>
|
* attribute optional, so it does not always need to be set.
|
||||||
*
|
*
|
||||||
* @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> Rthe server is unable to properly connect
|
* <tr><td> remote-connection-failed </td><td> the server is unable to properly connect
|
||||||
* to a remote entity. </td></tr>
|
* to a remote entity. </td></tr>
|
||||||
* <tr><td> resource-constraint </td><td> Rthe server lacks the system resources necessary
|
* <tr><td> resource-constraint </td><td> the 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,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +36,12 @@ public class UnparsedIQ extends IQ {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
xml.escape(content);
|
if (StringUtils.isEmpty(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 LinkedList<IQProviderInfo>();
|
private final Collection<IQProviderInfo> iqProviders = new ArrayList<IQProviderInfo>();
|
||||||
private final Collection<ExtensionProviderInfo> extProviders = new LinkedList<ExtensionProviderInfo>();
|
private final Collection<ExtensionProviderInfo> extProviders = new ArrayList<ExtensionProviderInfo>();
|
||||||
private final Collection<StreamFeatureProviderInfo> sfProviders = new LinkedList<StreamFeatureProviderInfo>();
|
private final Collection<StreamFeatureProviderInfo> sfProviders = new ArrayList<StreamFeatureProviderInfo>();
|
||||||
|
|
||||||
private List<Exception> exceptions = new LinkedList<Exception>();
|
private List<Exception> exceptions = new ArrayList<Exception>();
|
||||||
|
|
||||||
public ProviderFileLoader(InputStream providerStream) {
|
public ProviderFileLoader(InputStream providerStream) {
|
||||||
this(providerStream, ProviderFileLoader.class.getClassLoader());
|
this(providerStream, ProviderFileLoader.class.getClassLoader());
|
||||||
|
|
|
@ -97,6 +97,7 @@ 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
|
||||||
|
@ -106,7 +107,8 @@ 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.<p>
|
* attach it to the packet.
|
||||||
|
* </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 staza extensions
|
* The Smack provider architecture is a system for plugging in custom XML parsing of stanza 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,6 +23,7 @@ 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;
|
||||||
|
|
||||||
|
@ -58,7 +59,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("UTF-8"));
|
+ host + ":" + port + proxyLine + "\r\n\r\n").getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
InputStream in = socket.getInputStream();
|
InputStream in = socket.getInputStream();
|
||||||
StringBuilder got = new StringBuilder(100);
|
StringBuilder got = new StringBuilder(100);
|
||||||
|
|
|
@ -41,6 +41,7 @@ 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 preped
|
* @return the given String SASL prepped
|
||||||
* @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,6 +271,7 @@ 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,6 +55,7 @@ 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;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2019 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.
|
||||||
|
@ -24,10 +24,12 @@ public class LazyStringBuilder implements Appendable, CharSequence {
|
||||||
|
|
||||||
private final List<CharSequence> list;
|
private final List<CharSequence> list;
|
||||||
|
|
||||||
private String cache;
|
private transient String cache;
|
||||||
|
private int cachedLength = -1;
|
||||||
|
|
||||||
private void invalidateCache() {
|
private void invalidateCache() {
|
||||||
cache = null;
|
cache = null;
|
||||||
|
cachedLength = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LazyStringBuilder() {
|
public LazyStringBuilder() {
|
||||||
|
@ -65,9 +67,10 @@ public class LazyStringBuilder implements Appendable, CharSequence {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int length() {
|
public int length() {
|
||||||
if (cache != null) {
|
if (cachedLength >= 0) {
|
||||||
return cache.length();
|
return cachedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
try {
|
try {
|
||||||
for (CharSequence csq : list) {
|
for (CharSequence csq : list) {
|
||||||
|
@ -78,6 +81,8 @@ public class LazyStringBuilder implements Appendable, CharSequence {
|
||||||
StringBuilder sb = safeToStringBuilder();
|
StringBuilder sb = safeToStringBuilder();
|
||||||
throw new RuntimeException("The following LazyStringBuilder threw a NullPointerException: " + sb, npe);
|
throw new RuntimeException("The following LazyStringBuilder threw a NullPointerException: " + sb, npe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cachedLength = length;
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MAC {
|
||||||
HMAC_SHA1 = Mac.getInstance(HMACSHA1);
|
HMAC_SHA1 = Mac.getInstance(HMACSHA1);
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
// Smack wont be able to function normally if this exception is thrown, wrap it into
|
// Smack won't 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 wont be able to function normally if this exception is thrown, wrap it into
|
// Smack won't 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-2021 Florian Schmaus
|
* Copyright © 2015-2024 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,13 +184,14 @@ public class MultiMap<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the given number of values for a given key. May return less values then requested.
|
* Remove the given number of values for a given key. May return less values than 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-2020 Florian Schmaus
|
* Copyright © 2015-2024 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,18 +18,6 @@ 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-2023 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2019-2024 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,7 +25,6 @@ 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;
|
||||||
|
@ -87,7 +86,7 @@ public class PacketParserUtils {
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -230,7 +229,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,
|
||||||
// ie. <body></body>, which appears to be valid XMPP, or a
|
// i.e. <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 {
|
||||||
|
@ -644,7 +643,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 LinkedList<>();
|
List<String> methods = new ArrayList<>();
|
||||||
outerloop: while (true) {
|
outerloop: while (true) {
|
||||||
XmlPullParser.Event eventType = parser.next();
|
XmlPullParser.Event eventType = parser.next();
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
@ -850,7 +849,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 initalDepth = parser.getDepth();
|
int initialDepth = parser.getDepth();
|
||||||
boolean required = false;
|
boolean required = false;
|
||||||
outerloop: while (true) {
|
outerloop: while (true) {
|
||||||
XmlPullParser.Event event = parser.next();
|
XmlPullParser.Event event = parser.next();
|
||||||
|
@ -864,7 +863,7 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END_ELEMENT:
|
case END_ELEMENT:
|
||||||
if (parser.getDepth() == initalDepth) {
|
if (parser.getDepth() == initialDepth) {
|
||||||
break outerloop;
|
break outerloop;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2021 Florian Schmaus
|
* Copyright © 2014-2024 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")
|
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
|
||||||
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 Florian Schmaus.
|
* Copyright 2020-2024 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,11 +26,12 @@ public final class Pair<F, S> {
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <F extends Object, S extends Object> Pair<F, S> create(F first, S second) {
|
public static <F, S> Pair<F, S> create(F first, S second) {
|
||||||
return new Pair<>(first, second);
|
return new Pair<>(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <F extends Object, S extends Object> Pair<F, S> createAndInitHashCode(F first, S second) {
|
@SuppressWarnings("ReturnValueIgnored")
|
||||||
|
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-2023 Florian Schmaus
|
* Copyright © 2014-2024 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,8 +23,6 @@ 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;
|
||||||
|
@ -146,7 +144,7 @@ public class ParserUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
|
* Phrase 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
|
||||||
|
@ -367,19 +365,6 @@ 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 wont be able to function normally if this exception is thrown, wrap it into
|
// Smack won't 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);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue