aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-06-06 09:05:50 +0200
committersteckbrief <steckbrief@chefmail.de>2016-06-06 09:07:59 +0200
commitf45ad10b1baaf09fd4a40d6b63d1cd093623eedc (patch)
tree894e879ac98891879e9b97aa1df86b3b10c3d189 /src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java
parentb1ab7347b92329512bebe57f6624cae33c27036f (diff)
Related to FS#131, FS#129, FS#220:filetransfer
- FileTransferFailureReason including types introduced. A failure can be recoverable, non-recoverable or limited recoverable - in case file transfer with the highest weight factor fails, the next file transfer method is used - improved logging - javadoc comments added
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java
index 8efd498b..a8e5734f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/httpupload/HttpFileTransferEntity.java
@@ -1,9 +1,16 @@
package de.thedevstack.conversationsplus.services.filetransfer.httpupload;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.services.filetransfer.FileTransferEntity;
+import de.thedevstack.conversationsplus.services.filetransfer.FileTransferFailureReason;
+import de.thedevstack.conversationsplus.utils.CryptoHelper;
+import de.thedevstack.conversationsplus.utils.MessageUtil;
import de.thedevstack.conversationsplus.xmpp.httpupload.HttpUploadSlot;
/**
@@ -49,4 +56,32 @@ public class HttpFileTransferEntity extends FileTransferEntity {
public boolean isDelayed() {
return this.delayed;
}
+
+ @Override
+ public void fail(FileTransferFailureReason failureReason) {
+ this.getMessage().setHttpUploaded(false);
+ super.fail(failureReason);
+ }
+
+ @Override
+ public void cancel() {
+ this.getMessage().setHttpUploaded(false);
+ super.cancel();
+ }
+
+ @Override
+ public void transferred() {
+ try {
+ URL getUrl = new URL(this.getGetUrl());
+ if (this.getKey() != null) {
+ getUrl = new URL(getUrl.toString() + "#" + CryptoHelper.bytesToHex(this.getKey()));
+ }
+
+ MessageUtil.updateFileParams(this.getMessage(), getUrl);
+ } catch (MalformedURLException e) {
+ Logging.e("httpupload", "Not a valid get url");
+ }
+
+ super.transferred();
+ }
}