aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/http
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-13 21:04:05 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-15 15:34:11 +0100
commit7a90ca429bb46fae4cbd600bd4c2274f4a731a16 (patch)
tree0ec0d753e32f0c361e43bf2bac627bda39a7899d /src/main/java/eu/siacs/conversations/http
parent4c504dea7ac7b0413df89ec630408b91f4abddb4 (diff)
basic arbitrary file transfer
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpConnection.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnection.java b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
index 147ac42f..fd6b9c1a 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
@@ -37,6 +37,7 @@ public class HttpConnection implements Downloadable {
private DownloadableFile file;
private int mStatus = Downloadable.STATUS_UNKNOWN;
private boolean acceptedAutomatically = false;
+ private int mProgress = 0;
public HttpConnection(HttpConnectionManager manager) {
this.mHttpConnectionManager = manager;
@@ -235,10 +236,14 @@ public class HttpConnection implements Downloadable {
if (os == null) {
throw new IOException();
}
+ long transmitted = 0;
+ long expected = file.getExpectedSize();
int count = -1;
byte[] buffer = new byte[1024];
while ((count = is.read(buffer)) != -1) {
+ transmitted += count;
os.write(buffer, 0, count);
+ mProgress = (int) (expected * 100 / transmitted);
}
os.flush();
os.close();
@@ -272,4 +277,14 @@ public class HttpConnection implements Downloadable {
return 0;
}
}
+
+ @Override
+ public int getProgress() {
+ return this.mProgress;
+ }
+
+ @Override
+ public String getMimeType() {
+ return "";
+ }
} \ No newline at end of file