aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java24
-rw-r--r--src/main/java/eu/siacs/conversations/generator/IqGenerator.java7
2 files changed, 17 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index 7689a183b..04e114dae 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -8,13 +8,14 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import eu.siacs.conversations.services.XmppConnectionService;
public abstract class AbstractGenerator {
- public final String[] FEATURES = {
+ private final String[] FEATURES = {
"urn:xmpp:jingle:1",
"urn:xmpp:jingle:apps:file-transfer:3",
"urn:xmpp:jingle:transports:s5b:1",
@@ -25,7 +26,7 @@ public abstract class AbstractGenerator {
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
"urn:xmpp:ping"};
- public final String[] MESSAGE_CONFIRMATION_FEATURES = {
+ private final String[] MESSAGE_CONFIRMATION_FEATURES = {
"urn:xmpp:chat-markers:0",
"urn:xmpp:receipts"
};
@@ -49,13 +50,8 @@ public abstract class AbstractGenerator {
} catch (NoSuchAlgorithmException e) {
return null;
}
- ArrayList<String> features = new ArrayList<>();
- features.addAll(Arrays.asList(FEATURES));
- if (mXmppConnectionService.confirmMessages()) {
- features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
- }
- Collections.sort(features);
- for (String feature : features) {
+
+ for (String feature : getFeatures()) {
s.append(feature + "<");
}
byte[] sha1 = md.digest(s.toString().getBytes());
@@ -66,4 +62,14 @@ public abstract class AbstractGenerator {
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
return DATE_FORMAT.format(time);
}
+
+ public List<String> getFeatures() {
+ ArrayList<String> features = new ArrayList<>();
+ features.addAll(Arrays.asList(FEATURES));
+ if (mXmppConnectionService.confirmMessages()) {
+ features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
+ }
+ Collections.sort(features);
+ return features;
+ }
}
diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
index 290e0d608..161e6f890 100644
--- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
@@ -1,8 +1,7 @@
package eu.siacs.conversations.generator;
+
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import eu.siacs.conversations.entities.Account;
@@ -33,9 +32,7 @@ public class IqGenerator extends AbstractGenerator {
identity.setAttribute("category", "client");
identity.setAttribute("type", this.IDENTITY_TYPE);
identity.setAttribute("name", IDENTITY_NAME);
- final List<String> features = Arrays.asList(FEATURES);
- Collections.sort(features);
- for (final String feature : features) {
+ for (final String feature : getFeatures()) {
query.addChild("feature").setAttribute("var", feature);
}
return packet;