1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Merge branch '4.2'

This commit is contained in:
Florian Schmaus 2018-02-21 20:13:05 +01:00
commit a48e8ef843
155 changed files with 638 additions and 160 deletions

View file

@ -0,0 +1,37 @@
Consistent Colors
=================
[Back](index.md)
Since XMPP can be used on multiple platforms at the same time,
it might be a good idea to render given Strings like nicknames in the same
color on all platforms to provide a consistent user experience.
The utility class `ConsistentColor` allows the generation of colors to a given
string following the specification of [XEP-0392](https://xmpp.org/extensions/xep-0392.html).
##Usage
To generate a consistent color for a given string, call
```
float[] rgb = ConsistentColor.RGBFrom(input);
```
The resulting float array contains values for RGB in the range of 0 to 1.
##Color Deficiency Corrections
Some users might suffer from color vision deficiencies. To compensate those deficiencies,
the API allows for color correction. The color correction mode is a static value, which can be changed at any time.
To correct colors for users with red-green color deficiency use the following code:
```
ConsistentColor.activateRedGreenBlindnessCorrection();
```
For color correction for users with blue-blindness, call
```
ConsistentColor.activateBlueBlindnessCorrection();
```
To deactivate color vision deficiency correction, call
```
ConsistenColor.deactivateDeficiencyCorrection();
```

View file

@ -96,6 +96,7 @@ Experimental Smack Extensions and currently supported XEPs of smack-experimental
| HTTP File Upload | [XEP-0363](http://xmpp.org/extensions/xep-0363.html) | Protocol to request permissions to upload a file to an HTTP server and get a shareable URL. |
| [Multi-User Chat Light](muclight.md) | [XEP-xxxx](http://mongooseim.readthedocs.io/en/latest/open-extensions/xeps/xep-muc-light.html) | Multi-User Chats for mobile XMPP applications and specific enviroment. |
| [OMEMO Multi End Message and Object Encryption](omemo.md) | [XEP-XXXX](https://conversations.im/omemo/xep-omemo.html) | Encrypt messages using OMEMO encryption (currently only with smack-omemo-signal -> GPLv3). |
| [Consistent Color Generation](consistent_colors.md) | [XEP-0392](http://xmpp.org/extensions/xep-0392.html) | Generate consistent colors for identifiers like usernames to provide a consistent user experience. |
| Google GCM JSON payload | n/a | Semantically the same as XEP-0335: JSON Containers |

View file

@ -49,7 +49,7 @@ filters includes:
* `StanzaIdFilter` -- filters for packets with a particular packet ID.
* `ThreadFilter` -- filters for message packets with a particular thread ID.
* `ToContainsFilter` -- filters for packets that are sent to a particular address.
* `FromContainsFilter` -- filters for packets that are sent to a particular address.
* `FromContainsFilter` -- filters for packets that are sent from a particular address.
* `StanzaExtensionFilter` -- filters for packets that have a particular packet extension.
* `AndFilter` -- implements the logical AND operation over two filters.
* `OrFilter` -- implements the logical OR operation over two filters.

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Android classes for XEP-0199: XMPP Ping.
*/
package org.jivesoftware.smackx.ping.android;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Android classes for debugging purposes.
*/
package org.jivesoftware.smackx.debugger.android;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smack optional Debuggers.
*/
package org.jivesoftware.smackx.debugger;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smack classes for compression.
*/
package org.jivesoftware.smack.compression;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014 Florian Schmaus
* Copyright © 2014-2018 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,17 @@ import org.jivesoftware.smack.util.ParserUtils;
import org.xmlpull.v1.XmlPullParser;
/**
* Smack provider are the parsers used to deserialize raw XMPP into the according Java {@link Element}s.
* <p>
* At any time when {@link #parse(XmlPullParser, int)} is invoked any type of exception can be thrown. If the parsed
* element does not follow the specification, for example by putting a string where only integers are allowed, then a
* {@link org.jivesoftware.smack.SmackException} should be thrown.
* </p>
*
* @author Florian Schmaus
* @param <E> the type of the resulting element.
*/
public abstract class Provider<E extends Element> {
public final E parse(XmlPullParser parser) throws Exception {

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-280: Message Carbons.
* Smack's API for XEP-0280: Message Carbons.
*/
package org.jivesoftware.smackx.carbons;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-280: Message Carbons.
* Stanzas and extension elements for XEP-0280: Message Carbons.
*/
package org.jivesoftware.smackx.carbons.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Provider for XEP-280: Message Carbons.
* Provider for XEP-0280: Message Carbons.
*/
package org.jivesoftware.smackx.carbons.provider;

View file

@ -0,0 +1,218 @@
/**
*
* Copyright © 2018 Paul Schaub
*
* 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.smackx.colors;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.SHA1;
public class ConsistentColor {
private static final ConsistentColorSettings DEFAULT_SETTINGS = new ConsistentColorSettings();
// See XEP-0392 §13.1 Constants for YCbCr (BT.601)
private static final double KR = 0.299;
private static final double KG = 0.587;
private static final double KB = 0.114;
// See XEP-0392 §5.4 CbCr to RGB
private static final double Y = 0.732;
public enum Deficiency {
/**
* Do not apply measurements for color vision deficiency correction.
*/
none,
/**
* Activate color correction for users suffering from red-green-blindness.
*/
redGreenBlindness,
/**
* Activate color correction for users suffering from blue-blindness.
*/
blueBlindness
}
/**
* Generate an angle in the CbCr plane from the input string.
* @see <a href="https://xmpp.org/extensions/xep-0392.html#algorithm-angle">§5.1: Angle generation</a>
*
* @param input input string
* @return output angle
*/
private static double createAngle(CharSequence input) {
byte[] h = SHA1.bytes(input.toString());
double v = u(h[0]) + (256 * u(h[1]));
double d = v / 65536;
return d * 2 * Math.PI;
}
/**
* Apply correction for color vision deficiencies to an angle in the CbCr plane.
* @see <a href="https://xmpp.org/extensions/xep-0392.html#algorithm-cvd">§5.2: Corrections for Color Vision Deficiencies</a>
*
* @param angle angle in CbCr plane
* @param deficiency type of vision deficiency
* @return corrected angle in CbCr plane
*/
private static double applyColorDeficiencyCorrection(double angle, Deficiency deficiency) {
switch (deficiency) {
case none:
break;
case redGreenBlindness:
angle %= Math.PI;
break;
case blueBlindness:
angle -= Math.PI / 2;
angle %= Math.PI;
angle += Math.PI / 2;
break;
}
return angle;
}
/**
* Convert an angle in the CbCr plane to values cb,cr in the YCbCr color space.
* @see <a href="https://xmpp.org/extensions/xep-0392.html#algorithm-cbcr">§5.3: CbCr generation</a>
*
* @param angle angel in CbCr plane.
* @return value pair cb,cr
*/
private static double[] angleToCbCr(double angle) {
double cb = Math.cos(angle);
double cr = Math.sin(angle);
double acb = Math.abs(cb);
double acr = Math.abs(cr);
double factor;
if (acr > acb) {
factor = 0.5 / acr;
} else {
factor = 0.5 / acb;
}
cb *= factor;
cr *= factor;
return new double[] {cb, cr};
}
/**
* Convert a value pair cb,cr in the YCbCr color space to RGB.
* @see <a href="https://xmpp.org/extensions/xep-0392.html#algorithm-rgb">§5.4: CbCr to RGB</a>
*
* @param cbcr value pair from the YCbCr color space
* @return RGB value triple (R,G,B in [0,1])
*/
private static float[] CbCrToRGB(double[] cbcr, double y) {
double cb = cbcr[0];
double cr = cbcr[1];
double r = 2 * (1 - KR) * cr + y;
double b = 2 * (1 - KB) * cb + y;
double g = (y - KR * r - KB * b) / KG;
// Clip values to [0,1]
r = clip(r);
g = clip(g);
b = clip(b);
return new float[] {(float) r, (float) g, (float) b};
}
/**
* Clip values to stay in range(0,1).
*
* @param value input
* @return input clipped to stay in boundaries from 0 to 1.
*/
private static double clip(double value) {
double out = value;
if (value < 0) {
out = 0;
}
if (value > 1) {
out = 1;
}
return out;
}
/**
* Treat a signed java byte as unsigned to get its numerical value.
*
* @param b signed java byte
* @return integer value of its unsigned representation
*/
private static int u(byte b) {
// Get unsigned value of signed byte as an integer.
return b & 0xFF;
}
/**
* Return the consistent RGB color value of the input.
* This method uses the default {@link ConsistentColorSettings}.
*
* @param input input string (for example username)
* @return consistent color of that username as RGB values in range [0,1].
* @see #RGBFrom(CharSequence, ConsistentColorSettings)
*/
public static float[] RGBFrom(CharSequence input) {
return RGBFrom(input, DEFAULT_SETTINGS);
}
/**
* Return the consistent RGB color value for the input.
* This method respects the color vision deficiency mode set by the user.
*
* @param input input string (for example username)
* @param settings the settings for consistent color creation.
* @return consistent color of that username as RGB values in range [0,1].
*/
public static float[] RGBFrom(CharSequence input, ConsistentColorSettings settings) {
double angle = createAngle(input);
double correctedAngle = applyColorDeficiencyCorrection(angle, settings.getDeficiency());
double[] CbCr = angleToCbCr(correctedAngle);
float[] rgb = CbCrToRGB(CbCr, Y);
return rgb;
}
public static class ConsistentColorSettings {
private final Deficiency deficiency;
public ConsistentColorSettings() {
this(Deficiency.none);
}
public ConsistentColorSettings(Deficiency deficiency) {
this.deficiency = Objects.requireNonNull(deficiency, "Deficiency must be given");
}
/**
* Return the deficiency setting.
*
* @return deficiency setting.
*/
public Deficiency getDeficiency() {
return deficiency;
}
}
}

View file

@ -0,0 +1,21 @@
/**
*
* Copyright © 2018 Paul Schaub
*
* 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.
*/
/**
* Smack's API for XEP-0392: Consistent Color Generation.
*/
package org.jivesoftware.smackx.colors;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-352: Client State Indication.
* Smack's API for XEP-0352: Client State Indication.
*/
package org.jivesoftware.smackx.csi;

View file

@ -16,6 +16,6 @@
*/
/**
* Plain stream elements for XEP-352: Client State Indication.
* Plain stream elements for XEP-0352: Client State Indication.
*/
package org.jivesoftware.smackx.csi.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Provider for XEP-352: Client State Indication.
* Provider for XEP-0352: Client State Indication.
*/
package org.jivesoftware.smackx.csi.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-332: HTTP over XMPP transport.
* Smack's API for XEP-0332: HTTP over XMPP transport.
*/
package org.jivesoftware.smackx.hoxt;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-332: HTTP over XMPP transport.
* Stanzas and extension elements for XEP-0332: HTTP over XMPP transport.
*/
package org.jivesoftware.smackx.hoxt.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-332: HTTP over XMPP transport.
* Providers for XEP-0332: HTTP over XMPP transport.
*/
package org.jivesoftware.smackx.hoxt.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Extension elements for XEP-295: JSON Encodings for XMPP.
* Extension elements for XEP-0295: JSON Encodings for XMPP.
*/
package org.jivesoftware.smackx.json.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-295: JSON Encodings for XMPP.
* Providers for XEP-0295: JSON Encodings for XMPP.
*/
package org.jivesoftware.smackx.json.provider;

View file

@ -0,0 +1,152 @@
/**
*
* Copyright © 2018 Paul Schaub
*
* 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.smackx.colors;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.colors.ConsistentColor.Deficiency;
import org.junit.Test;
public class ConsistentColorsTest extends SmackTestSuite {
// Margin of error we allow due to floating point arithmetic
private static final float EPS = 0.001f;
private static final ConsistentColor.ConsistentColorSettings noDeficiency = new ConsistentColor.ConsistentColorSettings(Deficiency.none);
private static final ConsistentColor.ConsistentColorSettings redGreenDeficiency = new ConsistentColor.ConsistentColorSettings(Deficiency.redGreenBlindness);
private static final ConsistentColor.ConsistentColorSettings blueBlindnessDeficiency = new ConsistentColor.ConsistentColorSettings(Deficiency.blueBlindness);
/*
Below tests check the test vectors from XEP-0392 §13.2.
*/
@Test
public void romeoNoDeficiencyTest() {
String value = "Romeo";
float[] expected = new float[] {0.281f, 0.790f, 1.000f};
float[] actual = ConsistentColor.RGBFrom(value, noDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void romeoRedGreenBlindnessTest() {
String value = "Romeo";
float[] expected = new float[] {1.000f, 0.674f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, redGreenDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void romeoBlueBlindnessTest() {
String value = "Romeo";
float[] expected = new float[] {1.000f, 0.674f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, blueBlindnessDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void julietNoDeficiencyTest() {
String value = "juliet@capulet.lit";
float[] expected = new float[] {0.337f, 1.000f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, noDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void julietRedGreenBlindnessTest() {
String value = "juliet@capulet.lit";
float[] expected = new float[] {1.000f, 0.359f, 1.000f};
float[] actual = ConsistentColor.RGBFrom(value, redGreenDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void julietBlueBlindnessTest() {
String value = "juliet@capulet.lit";
float[] expected = new float[] {0.337f, 1.000f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, blueBlindnessDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void emojiNoDeficiencyTest() {
String value = "\uD83D\uDE3A";
float[] expected = new float[] {0.347f, 0.756f, 1.000f};
float[] actual = ConsistentColor.RGBFrom(value, noDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void emojiRedGreenBlindnessTest() {
String value = "\uD83D\uDE3A";
float[] expected = new float[] {1.000f, 0.708f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, redGreenDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void emojiBlueBlindnessTest() {
String value = "\uD83D\uDE3A";
float[] expected = new float[] {1.000f, 0.708f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, blueBlindnessDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void councilNoDeficiencyTest() {
String value = "council";
float[] expected = new float[] {0.732f, 0.560f, 1.000f};
float[] actual = ConsistentColor.RGBFrom(value, noDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void councilRedGreenBlindnessTest() {
String value = "council";
float[] expected = new float[] {0.732f, 0.904f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, redGreenDeficiency);
assertRGBEquals(expected, actual, EPS);
}
@Test
public void councilBlueBlindnessTest() {
String value = "council";
float[] expected = new float[] {0.732f, 0.904f, 0.000f};
float[] actual = ConsistentColor.RGBFrom(value, blueBlindnessDeficiency);
assertRGBEquals(expected, actual, EPS);
}
/**
* Check, whether the values of two float arrays of size 3 are pairwise equal with an allowed error of eps.
*
* @param expected expected values
* @param actual actual values
* @param eps allowed error
*/
private static void assertRGBEquals(float[] expected, float[] actual, float eps) {
assertEquals(3, expected.length);
assertEquals(3, actual.length);
for (int i = 0; i < actual.length; i++) {
assertTrue(Math.abs(expected[i] - actual[i]) < eps);
}
}
}

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks initializer for extensions.
*/
package org.jivesoftware.smack.extensions;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-33: Extended Stanza Addressing.
* Smack's API for XEP-0033: Extended Stanza Addressing.
*/
package org.jivesoftware.smackx.address;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-33: Extended Stanzas Addressing.
* Stanzas and extension elements for XEP-0033: Extended Stanzas Addressing.
*/
package org.jivesoftware.smackx.address.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-33: Extended Stanza Addressing.
* Providers for XEP-0033: Extended Stanza Addressing.
*/
package org.jivesoftware.smackx.address.provider;

View file

@ -85,7 +85,7 @@ public class ServiceAdministrationManager extends Manager {
FormField passwordVerifyField = answerForm.getField("password-verify");
passwordVerifyField.addValue(password);
command.next(answerForm);
command.execute(answerForm);
assert (command.isCompleted());
}
@ -113,7 +113,7 @@ public class ServiceAdministrationManager extends Manager {
FormField accountJids = answerForm.getField("accountjids");
accountJids.addValues(JidUtil.toStringList(jidsToDelete));
command.next(answerForm);
command.execute(answerForm);
assert (command.isCompleted());
}
}

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-79: Advanced Message Processing.
* Smack's API for XEP-0079: Advanced Message Processing.
*/
package org.jivesoftware.smackx.amp;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-79: Advanced Message Processing.
* Stanzas and extension elements for XEP-0079: Advanced Message Processing.
*/
package org.jivesoftware.smackx.amp.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-79: Advanced Message Processing.
* Providers for XEP-0079: Advanced Message Processing.
*/
package org.jivesoftware.smackx.amp.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-224: Attention.
* Smack's API for XEP-0224: Attention.
*/
package org.jivesoftware.smackx.attention;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-224: Attention.
* Stanzas and extension elements for XEP-0224: Attention.
*/
package org.jivesoftware.smackx.attention.packet;

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
/**
* Classes and interfaces of Bits of Binary.
* Classes and interfaces of XEP-0231: Bits of Binary.
*
* @author Fernando Ramirez
* @see <a href="http://xmpp.org/extensions/xep-0231.html">XEP-0231: Bits of

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-48: Bookmarks.
* Smack's API for XEP-0048: Bookmarks.
*/
package org.jivesoftware.smackx.bookmarks;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-47: In-Band Bytestreams.
* Smack's API for XEP-0047: In-Band Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.ibb;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-47: In-Band Bytestreams.
* Stanzas and extension elements for XEP-0047: In-Band Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.ibb.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-47: In-Band Bytestreams.
* Providers for XEP-0047: In-Band Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.ibb.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-65: SOCKS5 Bytestreams.
* Smack's API for XEP-0065: SOCKS5 Bytestreams, as well as XEP-0047: In-Band Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-65: SOCKS5 Bytestreams.
* Smack's API for XEP-0065: SOCKS5 Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.socks5;

View file

@ -16,6 +16,6 @@
*/
/**
* Stanzas and extension elements for XEP-65: SOCKS5 Bytestreams.
* Stanzas and extension elements for XEP-0065: SOCKS5 Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.socks5.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Providers for XEP-65: SOCKS5 Bytestreams.
* Providers for XEP-0065: SOCKS5 Bytestreams.
*/
package org.jivesoftware.smackx.bytestreams.socks5.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Cache classes for XEP-0115: Entity Capabilities.
*/
package org.jivesoftware.smackx.caps.cache;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0115: Entity Capabilities.
*/
package org.jivesoftware.smackx.caps;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0115: Entity Capabilities.
*/
package org.jivesoftware.smackx.caps.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0115: Entity Capabilities.
*/
package org.jivesoftware.smackx.caps.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0085: Chat State Notifications.
*/
package org.jivesoftware.smackx.chatstates;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0085: Chat State Notifications.
*/
package org.jivesoftware.smackx.chatstates.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* Provider classes for Chat State Notifications (XEP-0085).
* Provider classes for XEP-0085: Chat State Notifications.
*/
package org.jivesoftware.smackx.chatstates.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0050: Ad-Hoc Commands.
*/
package org.jivesoftware.smackx.commands;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0050: Ad-Hoc Commands.
*/
package org.jivesoftware.smackx.commands.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0050: Ad-Hoc Commands.
*/
package org.jivesoftware.smackx.commands.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* StanzaFilter classes for XEP-0203: Delayed Delivery, as well as XEP-0091: Legacy Delayed Delivery.
*/
package org.jivesoftware.smackx.delay.filter;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0203: Delayed Delivery, as well as XEP-0091: Legacy Delayed Delivery.
*/
package org.jivesoftware.smackx.delay;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0203: Delayed Delivery, as well as XEP-0091: Legacy Delayed Delivery.
*/
package org.jivesoftware.smackx.delay.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0203: Delayed Delivery, as well as XEP-0091: Legacy Delayed Delivery.
*/
package org.jivesoftware.smackx.delay.provider;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software.
* Copyright 2003-2007 Jive Software, 2018 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -43,6 +43,7 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.caps.EntityCapsManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
@ -66,6 +67,7 @@ import org.jxmpp.util.cache.ExpirationCache;
* </ol>
*
* @author Gaston Dombiak
* @author Florian Schmaus
*/
public final class ServiceDiscoveryManager extends Manager {
@ -875,20 +877,26 @@ public final class ServiceDiscoveryManager extends Manager {
public DomainBareJid findService(String feature, boolean useCache, String category, String type)
throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException {
List<DiscoverInfo> services = findServicesDiscoverInfo(feature, true, useCache);
boolean noCategory = StringUtils.isNullOrEmpty(category);
boolean noType = StringUtils.isNullOrEmpty(type);
if (noType != noCategory) {
throw new IllegalArgumentException("Must specify either both, category and type, or none");
}
List<DiscoverInfo> services = findServicesDiscoverInfo(feature, false, useCache);
if (services.isEmpty()) {
return null;
}
DiscoverInfo info = services.get(0);
if (category != null && type != null) {
if (!info.hasIdentity(category, type)) {
return null;
if (!noCategory && !noType) {
for (DiscoverInfo info : services) {
if (info.hasIdentity(category, type)) {
return info.getFrom().asDomainBareJid();
}
}
}
else if (category != null || type != null) {
throw new IllegalArgumentException("Must specify either both, category and type, or none");
}
return info.getFrom().asDomainBareJid();
return services.get(0).getFrom().asDomainBareJid();
}
public DomainBareJid findService(String feature, boolean useCache) throws NoResponseException,

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0030: Service Discovery.
*/
package org.jivesoftware.smackx.disco;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0030: Service Discovery.
*/
package org.jivesoftware.smackx.disco.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0030: Service Discovery.
*/
package org.jivesoftware.smackx.disco.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* File Transfers via XEP-0095: Stream Initialization.
*/
package org.jivesoftware.smackx.filetransfer;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0297: Stanza Forwarding.
*/
package org.jivesoftware.smackx.forward;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0297: Stanza Forwarding.
*/
package org.jivesoftware.smackx.forward.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0297: Stanza Forwarding.
*/
package org.jivesoftware.smackx.forward.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0080: User Location.
*/
package org.jivesoftware.smackx.geoloc;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0080: User Location.
*/
package org.jivesoftware.smackx.geoloc.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0080: User Location.
*/
package org.jivesoftware.smackx.geoloc.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0012: Last Activity.
*/
package org.jivesoftware.smackx.iqlast;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0012: Last Activity.
*/
package org.jivesoftware.smackx.iqlast.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0049: Private XML Storage.
*/
package org.jivesoftware.smackx.iqprivate;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0049: Private XML Storage.
*/
package org.jivesoftware.smackx.iqprivate.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0049: Private XML Storage.
*/
package org.jivesoftware.smackx.iqprivate.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0077: In-Band Registration.
*/
package org.jivesoftware.smackx.iqregister;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0077: In-Band Registration.
*/
package org.jivesoftware.smackx.iqregister.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0077: In-Band Registration.
*/
package org.jivesoftware.smackx.iqregister.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0092: Software Version.
*/
package org.jivesoftware.smackx.iqversion;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0092: Software Version.
*/
package org.jivesoftware.smackx.iqversion.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0092: Software Version.
*/
package org.jivesoftware.smackx.iqversion.provider;

View file

@ -16,6 +16,7 @@
*/
/**
* TODO describe me.
* Smacks implementation for attaching arbitrary properties to packets according to
* https://docs.jivesoftware.com/smack/latest/documentation/properties.html.
*/
package org.jivesoftware.smackx.jiveproperties;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes.
*/
package org.jivesoftware.smackx.jiveproperties.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes.
*/
package org.jivesoftware.smackx.jiveproperties.provider;

View file

@ -14,4 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* XMPP stream element providers for Last Message Correction as defined in XEP-0308.
*/
package org.jivesoftware.smackx.message_correct.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Classes and Interfaces that implement Multi-User Chat (MUC) as defined in XEP-45.
* Classes and Interfaces that implement Multi-User Chat (MUC) as defined in XEP-0045.
*/
package org.jivesoftware.smackx.muc;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0045: Multi-User Chat.
*/
package org.jivesoftware.smackx.muc.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0045: Multi-User Chat.
*/
package org.jivesoftware.smackx.muc.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0172: User Nickname.
*/
package org.jivesoftware.smackx.nick;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0172: User Nickname.
*/
package org.jivesoftware.smackx.nick.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0013: Flexible Offline Message Retrieval.
*/
package org.jivesoftware.smackx.offline;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0013: Flexible Offline Message Retrieval.
*/
package org.jivesoftware.smackx.offline.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Integration tests.
*/
package org.jivesoftware.smackx;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation XEP-0163: Personal Eventing Protocol.
*/
package org.jivesoftware.smackx.pep;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0199: XMPP Ping.
*/
package org.jivesoftware.smackx.ping;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0199: XMPP Ping.
*/
package org.jivesoftware.smackx.ping.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0199: XMPP Ping.
*/
package org.jivesoftware.smackx.ping.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Filters for XEP-0016: Privacy Lists.
*/
package org.jivesoftware.smackx.privacy.filter;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Smacks implementation of XEP-0016: Privacy Lists.
*/
package org.jivesoftware.smackx.privacy;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Element classes for XEP-0016: Privacy Lists.
*/
package org.jivesoftware.smackx.privacy.packet;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* Provider classes for XEP-0016: Privacy Lists.
*/
package org.jivesoftware.smackx.privacy.provider;

View file

@ -16,6 +16,6 @@
*/
/**
* Smack's API for XEP-60: Publish-Subscribe.
* Smack's API for XEP-0060: Publish-Subscribe.
*/
package org.jivesoftware.smackx.pubsub;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* XEP-0184: Message Delivery Receipts.
*/
package org.jivesoftware.smackx.receipts;

View file

@ -16,6 +16,6 @@
*/
/**
* TODO describe me.
* XEP-0059: Result Set Management.
*/
package org.jivesoftware.smackx.rsm;

Some files were not shown because too many files have changed in this diff Show more