aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/http
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-17 15:23:46 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-17 15:23:46 +0200
commit0f405c2e112ebd5dbb6be535bbadd1c4a109d341 (patch)
treeb6d361cdf369a4bdf4719d53201da462dd5a8c01 /src/main/java/eu/siacs/conversations/http
parente9e31b1c9bb8c0e1e78207b843c5799b98f06cdd (diff)
allow redownloading files from remote hosts. fixes #1504
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
index 5fa7bf81..792a71e8 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
@@ -22,6 +22,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Transferable;
+import eu.siacs.conversations.entities.TransferablePlaceholder;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.services.AbstractConnectionManager;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -66,7 +67,11 @@ public class HttpDownloadConnection implements Transferable {
this.message = message;
this.message.setTransferable(this);
try {
- mUrl = new URL(message.getBody());
+ if (message.hasFileOnRemoteHost()) {
+ mUrl = message.getFileParams().url;
+ } else {
+ mUrl = new URL(message.getBody());
+ }
String[] parts = mUrl.getPath().toLowerCase().split("\\.");
String lastPart = parts.length >= 1 ? parts[parts.length - 1] : null;
String secondToLast = parts.length >= 2 ? parts[parts.length -2] : null;
@@ -106,7 +111,11 @@ public class HttpDownloadConnection implements Transferable {
public void cancel() {
mHttpConnectionManager.finishConnection(this);
- message.setTransferable(null);
+ if (message.isFileOrImage()) {
+ message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
+ } else {
+ message.setTransferable(null);
+ }
mXmppConnectionService.updateConversationUi();
}