diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-05 21:20:42 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-05 21:20:42 +0200 |
commit | c408c78630c86472806f9d34fc8d20943cba653e (patch) | |
tree | 2d885ca68eb718dfc2f784483c8a31264d09d592 /src/main/java/de/pixart/messenger/http | |
parent | 8e8ea0845e3c98785ef7d259a5c3f02b65cee686 (diff) |
Support both new and old http upload namespaces
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/http/HttpUploadConnection.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java index cd73d6895..fb2d1d49e 100644 --- a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java +++ b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java @@ -129,17 +129,25 @@ public class HttpUploadConnection implements Transferable { this.file.setExpectedSize(pair.second); message.resetFileParams(); this.mFileInputStream = pair.first; - Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD); - IqPacket request = mXmppConnectionService.getIqGenerator().requestHttpUploadSlot(host, file, mime); + String http_upload_namespace = account.getXmppConnection().getFeatures().http_upload_namespace; + Jid host = account.getXmppConnection().findDiscoItemByFeature(http_upload_namespace); + IqPacket request = mXmppConnectionService.getIqGenerator().requestHttpUploadSlot(host, file, mime, http_upload_namespace); mXmppConnectionService.sendIqPacket(account, request, (a, packet) -> { if (packet.getType() == IqPacket.TYPE.RESULT) { - Element slot = packet.findChild("slot", Namespace.HTTP_UPLOAD); + Element slot = packet.findChild("slot", http_upload_namespace); if (slot != null) { try { final Element put = slot.findChild("put"); final Element get = slot.findChild("get"); - final String putUrl = put == null ? null : put.getAttribute("url"); - final String getUrl = get == null ? null : get.getAttribute("url"); + final String putUrl; + final String getUrl; + if (http_upload_namespace == Namespace.HTTP_UPLOAD) { + putUrl = put == null ? null : put.getAttribute("url"); + getUrl = get == null ? null : get.getAttribute("url"); + } else { + putUrl = put == null ? null : put.getContent(); + getUrl = get == null ? null : get.getContent(); + } if (getUrl != null && putUrl != null) { this.mGetUrl = new URL(getUrl); this.mPutUrl = new URL(putUrl); |