diff options
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities')
4 files changed, 45 insertions, 17 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Account.java b/src/main/java/de/thedevstack/conversationsplus/entities/Account.java index f7dee013..bc956364 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Account.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Account.java @@ -55,8 +55,12 @@ public class Account extends AbstractEntity { public static final int OPTION_USECOMPRESSION = 3; public final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>(); + public boolean httpUploadAvailable(long filesize) { + return xmppConnection != null && xmppConnection.getFeatures().httpUpload(filesize); + } + public boolean httpUploadAvailable() { - return xmppConnection != null && xmppConnection.getFeatures().httpUpload(); + return httpUploadAvailable(0); } public void setDisplayName(String displayName) { diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java index 424d0301..101475c3 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java @@ -52,20 +52,16 @@ public class DownloadableFile extends File { public void setKeyAndIv(byte[] keyIvCombo) { if (keyIvCombo.length == 48) { - byte[] secretKey = new byte[32]; - byte[] iv = new byte[16]; - System.arraycopy(keyIvCombo, 0, iv, 0, 16); - System.arraycopy(keyIvCombo, 16, secretKey, 0, 32); - this.aeskey = secretKey; - this.iv = iv; + this.aeskey = new byte[32]; + this.iv = new byte[16]; + System.arraycopy(keyIvCombo, 0, this.iv, 0, 16); + System.arraycopy(keyIvCombo, 16, this.aeskey, 0, 32); } else if (keyIvCombo.length >= 32) { - byte[] secretKey = new byte[32]; - System.arraycopy(keyIvCombo, 0, secretKey, 0, 32); - this.aeskey = secretKey; + this.aeskey = new byte[32]; + System.arraycopy(keyIvCombo, 0, aeskey, 0, 32); } else if (keyIvCombo.length >= 16) { - byte[] secretKey = new byte[16]; - System.arraycopy(keyIvCombo, 0, secretKey, 0, 16); - this.aeskey = secretKey; + this.aeskey = new byte[16]; + System.arraycopy(keyIvCombo, 0, this.aeskey, 0, 16); } } diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java index 39fcdfb2..6a6a5e50 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java @@ -710,11 +710,11 @@ public class Message extends AbstractEntity { public int height = 0; } - public void setAxolotlFingerprint(String fingerprint) { + public void setFingerprint(String fingerprint) { this.axolotlFingerprint = fingerprint; } - public String getAxolotlFingerprint() { + public String getFingerprint() { return axolotlFingerprint; } diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java b/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java index cfba7c4f..562d95b7 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java @@ -17,6 +17,7 @@ import org.json.JSONObject; import de.thedevstack.conversationsplus.xml.Element; import de.thedevstack.conversationsplus.xmpp.forms.Data; +import de.thedevstack.conversationsplus.xmpp.forms.Field; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; public class ServiceDiscoveryResult { @@ -189,6 +190,19 @@ public class ServiceDiscoveryResult { return false; } + public String getExtendedDiscoInformation(String formType, String name) { + for(Data form : this.forms) { + if (formType.equals(form.getFormType())) { + for(Field field: form.getFields()) { + if (name.equals(field.getFieldName())) { + return field.getValue(); + } + } + } + } + return null; + } + protected byte[] mkCapHash() { StringBuilder s = new StringBuilder(); @@ -219,8 +233,22 @@ public class ServiceDiscoveryResult { }); for(Data form : forms) { - s.append(form.getFormType()+"<"); - //TODO append fields and values + s.append(form.getFormType() + "<"); + List<Field> fields = form.getFields(); + Collections.sort(fields, new Comparator<Field>() { + @Override + public int compare(Field lhs, Field rhs) { + return lhs.getFieldName().compareTo(rhs.getFieldName()); + } + }); + for(Field field : fields) { + s.append(field.getFieldName()+"<"); + List<String> values = field.getValues(); + Collections.sort(values); + for(String value : values) { + s.append(value+"<"); + } + } } MessageDigest md; |