From c408c78630c86472806f9d34fc8d20943cba653e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 5 May 2018 21:20:42 +0200 Subject: Support both new and old http upload namespaces --- .../java/de/pixart/messenger/xmpp/XmppConnection.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main/java/de/pixart/messenger/xmpp/XmppConnection.java') diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 775f7b430..1ea8174fe 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -1755,6 +1755,8 @@ public class XmppConnection implements Runnable { private boolean encryptionEnabled = false; private boolean blockListRequested = false; + public String http_upload_namespace = Namespace.HTTP_UPLOAD; + public Features(final XmppConnection connection) { this.connection = connection; } @@ -1844,10 +1846,15 @@ public class XmppConnection implements Runnable { if (Config.DISABLE_HTTP_UPLOAD) { return false; } else { - List> items = findDiscoItemsByFeature(Namespace.HTTP_UPLOAD); + List> items = findDiscoItemsByFeature(this.http_upload_namespace); + if (items.size() == 0) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": this server does not support the latest version of XEP-0363"); + this.http_upload_namespace = Namespace.HTTP_UPLOAD_LEGACY; + items = findDiscoItemsByFeature(this.http_upload_namespace); + } if (items.size() > 0) { try { - long maxsize = Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(Namespace.HTTP_UPLOAD, "max-file-size")); + long maxsize = Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(this.http_upload_namespace, "max-file-size")); if (filesize <= maxsize) { return true; } else { @@ -1864,10 +1871,10 @@ public class XmppConnection implements Runnable { } public long getMaxHttpUploadSize() { - List> items = findDiscoItemsByFeature(Namespace.HTTP_UPLOAD); + List> items = findDiscoItemsByFeature(this.http_upload_namespace); if (items.size() > 0) { try { - return Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(Namespace.HTTP_UPLOAD, "max-file-size")); + return Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(this.http_upload_namespace, "max-file-size")); } catch (Exception e) { return -1; } -- cgit v1.2.3