fixed broken caps
This commit is contained in:
parent
f8b662e7f8
commit
3c64839daf
|
@ -8,13 +8,14 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
|
||||||
public abstract class AbstractGenerator {
|
public abstract class AbstractGenerator {
|
||||||
public final String[] FEATURES = {
|
private final String[] FEATURES = {
|
||||||
"urn:xmpp:jingle:1",
|
"urn:xmpp:jingle:1",
|
||||||
"urn:xmpp:jingle:apps:file-transfer:3",
|
"urn:xmpp:jingle:apps:file-transfer:3",
|
||||||
"urn:xmpp:jingle:transports:s5b:1",
|
"urn:xmpp:jingle:transports:s5b:1",
|
||||||
|
@ -25,7 +26,7 @@ public abstract class AbstractGenerator {
|
||||||
"http://jabber.org/protocol/disco#info",
|
"http://jabber.org/protocol/disco#info",
|
||||||
"urn:xmpp:avatar:metadata+notify",
|
"urn:xmpp:avatar:metadata+notify",
|
||||||
"urn:xmpp:ping"};
|
"urn:xmpp:ping"};
|
||||||
public final String[] MESSAGE_CONFIRMATION_FEATURES = {
|
private final String[] MESSAGE_CONFIRMATION_FEATURES = {
|
||||||
"urn:xmpp:chat-markers:0",
|
"urn:xmpp:chat-markers:0",
|
||||||
"urn:xmpp:receipts"
|
"urn:xmpp:receipts"
|
||||||
};
|
};
|
||||||
|
@ -49,13 +50,8 @@ public abstract class AbstractGenerator {
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList<String> features = new ArrayList<>();
|
|
||||||
features.addAll(Arrays.asList(FEATURES));
|
for (String feature : getFeatures()) {
|
||||||
if (mXmppConnectionService.confirmMessages()) {
|
|
||||||
features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
|
|
||||||
}
|
|
||||||
Collections.sort(features);
|
|
||||||
for (String feature : features) {
|
|
||||||
s.append(feature + "<");
|
s.append(feature + "<");
|
||||||
}
|
}
|
||||||
byte[] sha1 = md.digest(s.toString().getBytes());
|
byte[] sha1 = md.digest(s.toString().getBytes());
|
||||||
|
@ -66,4 +62,14 @@ public abstract class AbstractGenerator {
|
||||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
return DATE_FORMAT.format(time);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package eu.siacs.conversations.generator;
|
package eu.siacs.conversations.generator;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -33,9 +32,7 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
identity.setAttribute("category", "client");
|
identity.setAttribute("category", "client");
|
||||||
identity.setAttribute("type", this.IDENTITY_TYPE);
|
identity.setAttribute("type", this.IDENTITY_TYPE);
|
||||||
identity.setAttribute("name", IDENTITY_NAME);
|
identity.setAttribute("name", IDENTITY_NAME);
|
||||||
final List<String> features = Arrays.asList(FEATURES);
|
for (final String feature : getFeatures()) {
|
||||||
Collections.sort(features);
|
|
||||||
for (final String feature : features) {
|
|
||||||
query.addChild("feature").setAttribute("var", feature);
|
query.addChild("feature").setAttribute("var", feature);
|
||||||
}
|
}
|
||||||
return packet;
|
return packet;
|
||||||
|
|
Loading…
Reference in a new issue