aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2015-07-14 09:17:27 +0200
committerChristian S <christian@pix-art.de>2015-07-14 09:17:27 +0200
commit8f0459f8d6f509e0591248ab133504a9cfd031e9 (patch)
treed3c8d9a1aee4b9fae624db9fee4915ce3baaa8aa /src/main/java/eu
parent169b4ba97f576cb2cbd8477ea0d3d6ed40276658 (diff)
deleted old files
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Downloadable.java28
-rw-r--r--src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java34
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpConnection.java204
3 files changed, 0 insertions, 266 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Downloadable.java b/src/main/java/eu/siacs/conversations/entities/Downloadable.java
deleted file mode 100644
index 56489774b..000000000
--- a/src/main/java/eu/siacs/conversations/entities/Downloadable.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package eu.siacs.conversations.entities;
-
-public interface Transferable {
-
- String[] VALID_IMAGE_EXTENSIONS = {"webp", "jpeg", "jpg", "png", "jpe"};
- String[] VALID_CRYPTO_EXTENSIONS = {"pgp", "gpg", "otr"};
- String[] WELL_KNOWN_EXTENSIONS = {"pdf","m4a","mp3","avi","mp4","apk","vcf"};
-
- int STATUS_UNKNOWN = 0x200;
- int STATUS_CHECKING = 0x201;
- int STATUS_FAILED = 0x202;
- int STATUS_OFFER = 0x203;
- int STATUS_DOWNLOADING = 0x204;
- int STATUS_DELETED = 0x205;
- int STATUS_OFFER_CHECK_FILESIZE = 0x206;
- int STATUS_UPLOADING = 0x207;
-
-
- boolean start();
-
- int getStatus();
-
- long getFileSize();
-
- int getProgress();
-
- void cancel();
-}
diff --git a/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java b/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
deleted file mode 100644
index e065953ef..000000000
--- a/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package eu.siacs.conversations.entities;
-
-public class TransferablePlaceholder implements Transferable {
-
- private int status;
-
- public TransferablePlaceholder(int status) {
- this.status = status;
- }
- @Override
- public boolean start() {
- return false;
- }
-
- @Override
- public int getStatus() {
- return status;
- }
-
- @Override
- public long getFileSize() {
- return 0;
- }
-
- @Override
- public int getProgress() {
- return 0;
- }
-
- @Override
- public void cancel() {
-
- }
-}
diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnection.java b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
deleted file mode 100644
index dd8427541..000000000
--- a/src/main/java/eu/siacs/conversations/http/HttpConnection.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package eu.siacs.conversations.http;
-
-import android.app.PendingIntent;
-import android.util.Log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import eu.siacs.conversations.Config;
-import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.entities.Transferable;
-import eu.siacs.conversations.entities.DownloadableFile;
-import eu.siacs.conversations.entities.Message;
-import eu.siacs.conversations.persistance.FileBackend;
-import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.ui.UiCallback;
-import eu.siacs.conversations.utils.CryptoHelper;
-import eu.siacs.conversations.utils.Xmlns;
-import eu.siacs.conversations.xml.Element;
-import eu.siacs.conversations.xmpp.OnIqPacketReceived;
-import eu.siacs.conversations.xmpp.jid.Jid;
-import eu.siacs.conversations.xmpp.stanzas.IqPacket;
-
-public class HttpUploadConnection implements Transferable {
-
- private HttpConnectionManager mHttpConnectionManager;
- private XmppConnectionService mXmppConnectionService;
-
- private boolean canceled = false;
- private Account account;
- private DownloadableFile file;
- private Message message;
- private URL mGetUrl;
- private URL mPutUrl;
-
- private byte[] key = null;
-
- private long transmitted = 0;
- private long expected = 1;
-
- public HttpUploadConnection(HttpConnectionManager httpConnectionManager) {
- this.mHttpConnectionManager = httpConnectionManager;
- this.mXmppConnectionService = httpConnectionManager.getXmppConnectionService();
- }
-
- @Override
- public boolean start() {
- return false;
- }
-
- @Override
- public int getStatus() {
- return STATUS_UPLOADING;
- }
-
- @Override
- public long getFileSize() {
- return this.file.getExpectedSize();
- }
-
- @Override
- public int getProgress() {
- return (int) ((((double) transmitted) / expected) * 100);
- }
-
- @Override
- public void cancel() {
- this.canceled = true;
- }
-
- private void fail() {
- mHttpConnectionManager.finishUploadConnection(this);
- message.setTransferable(null);
- mXmppConnectionService.markMessage(message,Message.STATUS_SEND_FAILED);
- }
-
- public void init(Message message) {
- this.message = message;
- message.setTransferable(this);
- mXmppConnectionService.markMessage(message,Message.STATUS_UNSEND);
- this.account = message.getConversation().getAccount();
- this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
- this.file.setExpectedSize(this.file.getSize());
-
- if (Config.ENCRYPT_ON_HTTP_UPLOADED) {
- this.key = new byte[48];
- mXmppConnectionService.getRNG().nextBytes(this.key);
- this.file.setKey(this.key);
- }
-
- Jid host = account.getXmppConnection().findDiscoItemByFeature(Xmlns.HTTP_UPLOAD);
- IqPacket request = mXmppConnectionService.getIqGenerator().requestHttpUploadSlot(host,file);
- mXmppConnectionService.sendIqPacket(account, request, new OnIqPacketReceived() {
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- if (packet.getType() == IqPacket.TYPE.RESULT) {
- Element slot = packet.findChild("slot",Xmlns.HTTP_UPLOAD);
- if (slot != null) {
- try {
- mGetUrl = new URL(slot.findChildContent("get"));
- mPutUrl = new URL(slot.findChildContent("put"));
- if (!canceled) {
- new Thread(new FileUploader()).start();
- }
- } catch (MalformedURLException e) {
- fail();
- }
- } else {
- fail();
- }
- } else {
- fail();
- }
- }
- });
- }
-
- private class FileUploader implements Runnable {
-
- @Override
- public void run() {
- this.upload();
- }
-
- private void upload() {
- OutputStream os = null;
- InputStream is = null;
- HttpURLConnection connection = null;
- try {
- Log.d(Config.LOGTAG, "uploading to " + mPutUrl.toString());
- connection = (HttpURLConnection) mPutUrl.openConnection();
- if (connection instanceof HttpsURLConnection) {
- mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, true);
- }
- connection.setRequestMethod("PUT");
- connection.setFixedLengthStreamingMode((int) file.getExpectedSize());
- connection.setDoOutput(true);
- connection.connect();
- os = connection.getOutputStream();
- is = file.createInputStream();
- transmitted = 0;
- expected = file.getExpectedSize();
- int count = -1;
- byte[] buffer = new byte[4096];
- while (((count = is.read(buffer)) != -1) && !canceled) {
- transmitted += count;
- os.write(buffer, 0, count);
- mXmppConnectionService.updateConversationUi();
- }
- os.flush();
- os.close();
- is.close();
- int code = connection.getResponseCode();
- if (code == 200) {
- Log.d(Config.LOGTAG, "finished uploading file");
- Message.FileParams params = message.getFileParams();
- if (key != null) {
- mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
- }
- mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl);
- message.setTransferable(null);
- message.setCounterpart(message.getConversation().getJid().toBareJid());
- if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
- mXmppConnectionService.getPgpEngine().encrypt(message, new UiCallback<Message>() {
- @Override
- public void success(Message message) {
- mXmppConnectionService.resendMessage(message);
- }
-
- @Override
- public void error(int errorCode, Message object) {
- fail();
- }
-
- @Override
- public void userInputRequried(PendingIntent pi, Message object) {
- fail();
- }
- });
- } else {
- mXmppConnectionService.resendMessage(message);
- }
- } else {
- fail();
- }
- } catch (IOException e) {
- Log.d(Config.LOGTAG, e.getMessage());
- fail();
- } finally {
- FileBackend.close(is);
- FileBackend.close(os);
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
- }
-}