aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-07-10 15:11:03 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-07-10 15:11:03 +0200
commitce79f4bbe3e6f4254d143125807327ff02f1a29c (patch)
tree630746e04ef93fc4498d918abb97f5e2662cf7a7 /src
parent925801c14e7500313069b2bc04abd066798a881c (diff)
renamed downloadable to transferable
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java24
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Transferable.java (renamed from src/main/java/eu/siacs/conversations/entities/Downloadable.java)2
-rw-r--r--src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java (renamed from src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java)4
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpConnection.java22
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java10
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/FileBackend.java4
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java8
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java22
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java22
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java19
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java31
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java5
14 files changed, 87 insertions, 101 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 078a4565..28ef89df 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -70,7 +70,7 @@ public class Message extends AbstractEntity {
protected String remoteMsgId = null;
protected String serverMsgId = null;
protected Conversation conversation = null;
- protected Downloadable downloadable = null;
+ protected Transferable transferable = null;
private Message mNextMessage = null;
private Message mPreviousMessage = null;
@@ -308,12 +308,12 @@ public class Message extends AbstractEntity {
this.trueCounterpart = trueCounterpart;
}
- public Downloadable getDownloadable() {
- return this.downloadable;
+ public Transferable getTransferable() {
+ return this.transferable;
}
- public void setDownloadable(Downloadable downloadable) {
- this.downloadable = downloadable;
+ public void setTransferable(Transferable transferable) {
+ this.transferable = transferable;
}
public boolean equals(Message message) {
@@ -364,8 +364,8 @@ public class Message extends AbstractEntity {
public boolean mergeable(final Message message) {
return message != null &&
(message.getType() == Message.TYPE_TEXT &&
- this.getDownloadable() == null &&
- message.getDownloadable() == null &&
+ this.getTransferable() == null &&
+ message.getTransferable() == null &&
message.getEncryption() != Message.ENCRYPTION_PGP &&
this.getType() == message.getType() &&
//this.getStatus() == message.getStatus() &&
@@ -471,7 +471,7 @@ public class Message extends AbstractEntity {
if (extensionParts.length == 2) {
return extensionParts[extensionParts.length - 1];
} else if (extensionParts.length == 3 && Arrays
- .asList(Downloadable.VALID_CRYPTO_EXTENSIONS)
+ .asList(Transferable.VALID_CRYPTO_EXTENSIONS)
.contains(extensionParts[extensionParts.length - 1])) {
return extensionParts[extensionParts.length -2];
}
@@ -517,8 +517,8 @@ public class Message extends AbstractEntity {
} else {
return Decision.NEVER;
}
- } else if (Arrays.asList(Downloadable.VALID_IMAGE_EXTENSIONS).contains(extension)
- || Arrays.asList(Downloadable.WELL_KNOWN_EXTENSIONS).contains(extension)) {
+ } else if (Arrays.asList(Transferable.VALID_IMAGE_EXTENSIONS).contains(extension)
+ || Arrays.asList(Transferable.WELL_KNOWN_EXTENSIONS).contains(extension)) {
return Decision.SHOULD;
} else {
return Decision.NEVER;
@@ -539,8 +539,8 @@ public class Message extends AbstractEntity {
return params;
}
params = new FileParams();
- if (this.downloadable != null) {
- params.size = this.downloadable.getFileSize();
+ if (this.transferable != null) {
+ params.size = this.transferable.getFileSize();
}
if (body == null) {
return params;
diff --git a/src/main/java/eu/siacs/conversations/entities/Downloadable.java b/src/main/java/eu/siacs/conversations/entities/Transferable.java
index 8fae91bb..2db6e3c9 100644
--- a/src/main/java/eu/siacs/conversations/entities/Downloadable.java
+++ b/src/main/java/eu/siacs/conversations/entities/Transferable.java
@@ -1,6 +1,6 @@
package eu.siacs.conversations.entities;
-public interface Downloadable {
+public interface Transferable {
String[] VALID_IMAGE_EXTENSIONS = {"webp", "jpeg", "jpg", "png", "jpe"};
String[] VALID_CRYPTO_EXTENSIONS = {"pgp", "gpg", "otr"};
diff --git a/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java b/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java
index cce22ea3..e065953e 100644
--- a/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
+++ b/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java
@@ -1,10 +1,10 @@
package eu.siacs.conversations.entities;
-public class DownloadablePlaceholder implements Downloadable {
+public class TransferablePlaceholder implements Transferable {
private int status;
- public DownloadablePlaceholder(int status) {
+ public TransferablePlaceholder(int status) {
this.status = status;
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnection.java b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
index fb3f08e3..74e16e7b 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
@@ -5,34 +5,26 @@ import android.net.Uri;
import android.os.SystemClock;
import android.util.Log;
-import org.apache.http.conn.ssl.StrictHostnameVerifier;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
-import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.X509TrustManager;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
-public class HttpConnection implements Downloadable {
+public class HttpConnection implements Transferable {
private HttpConnectionManager mHttpConnectionManager;
private XmppConnectionService mXmppConnectionService;
@@ -40,7 +32,7 @@ public class HttpConnection implements Downloadable {
private URL mUrl;
private Message message;
private DownloadableFile file;
- private int mStatus = Downloadable.STATUS_UNKNOWN;
+ private int mStatus = Transferable.STATUS_UNKNOWN;
private boolean acceptedAutomatically = false;
private int mProgress = 0;
private long mLastGuiRefresh = 0;
@@ -65,12 +57,12 @@ public class HttpConnection implements Downloadable {
}
public void init(Message message) {
- init(message,false);
+ init(message, false);
}
public void init(Message message, boolean interactive) {
this.message = message;
- this.message.setDownloadable(this);
+ this.message.setTransferable(this);
try {
mUrl = new URL(message.getBody());
String[] parts = mUrl.getPath().toLowerCase().split("\\.");
@@ -110,7 +102,7 @@ public class HttpConnection implements Downloadable {
public void cancel() {
mHttpConnectionManager.finishConnection(this);
- message.setDownloadable(null);
+ message.setTransferable(null);
mXmppConnectionService.updateConversationUi();
}
@@ -118,7 +110,7 @@ public class HttpConnection implements Downloadable {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
mXmppConnectionService.sendBroadcast(intent);
- message.setDownloadable(null);
+ message.setTransferable(null);
mHttpConnectionManager.finishConnection(this);
mXmppConnectionService.updateConversationUi();
if (acceptedAutomatically) {
diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
index 61e87715..dd842754 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
@@ -14,7 +14,7 @@ import javax.net.ssl.HttpsURLConnection;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.persistance.FileBackend;
@@ -27,7 +27,7 @@ import eu.siacs.conversations.xmpp.OnIqPacketReceived;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
-public class HttpUploadConnection implements Downloadable {
+public class HttpUploadConnection implements Transferable {
private HttpConnectionManager mHttpConnectionManager;
private XmppConnectionService mXmppConnectionService;
@@ -76,13 +76,13 @@ public class HttpUploadConnection implements Downloadable {
private void fail() {
mHttpConnectionManager.finishUploadConnection(this);
- message.setDownloadable(null);
+ message.setTransferable(null);
mXmppConnectionService.markMessage(message,Message.STATUS_SEND_FAILED);
}
public void init(Message message) {
this.message = message;
- message.setDownloadable(this);
+ message.setTransferable(this);
mXmppConnectionService.markMessage(message,Message.STATUS_UNSEND);
this.account = message.getConversation().getAccount();
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
@@ -164,7 +164,7 @@ public class HttpUploadConnection implements Downloadable {
mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
}
mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl);
- message.setDownloadable(null);
+ message.setTransferable(null);
message.setCounterpart(message.getConversation().getJid().toBareJid());
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
mXmppConnectionService.getPgpEngine().encrypt(message, new UiCallback<Message>() {
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
index 52373fef..ee53e90e 100644
--- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
@@ -33,7 +33,7 @@ import android.webkit.MimeTypeMap;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -80,7 +80,7 @@ public class FileBackend {
if (path.startsWith("/")) {
return new DownloadableFile(path);
} else {
- if (Arrays.asList(Downloadable.VALID_IMAGE_EXTENSIONS).contains(extension)) {
+ if (Arrays.asList(Transferable.VALID_IMAGE_EXTENSIONS).contains(extension)) {
return new DownloadableFile(getConversationsFileDirectory() + path);
} else {
return new DownloadableFile(getConversationsImageDirectory() + path);
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 49543eeb..2b59e473 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -18,7 +18,6 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.TaskStackBuilder;
import android.text.Html;
import android.util.DisplayMetrics;
-import android.util.Log;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -42,7 +41,6 @@ import eu.siacs.conversations.ui.ManageAccountActivity;
import eu.siacs.conversations.ui.TimePreference;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.UIHelper;
-import eu.siacs.conversations.xmpp.XmppConnection;
public class NotificationService {
@@ -303,7 +301,7 @@ public class NotificationService {
final ArrayList<Message> tmp = new ArrayList<>();
for (final Message msg : messages) {
if (msg.getType() == Message.TYPE_TEXT
- && msg.getDownloadable() == null) {
+ && msg.getTransferable() == null) {
tmp.add(msg);
}
}
@@ -335,7 +333,7 @@ public class NotificationService {
private Message getImage(final Iterable<Message> messages) {
for (final Message message : messages) {
if (message.getType() == Message.TYPE_IMAGE
- && message.getDownloadable() == null
+ && message.getTransferable() == null
&& message.getEncryption() != Message.ENCRYPTION_PGP) {
return message;
}
@@ -346,7 +344,7 @@ public class NotificationService {
private Message getFirstDownloadableMessage(final Iterable<Message> messages) {
for (final Message message : messages) {
if ((message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) &&
- message.getDownloadable() != null) {
+ message.getTransferable() != null) {
return message;
}
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index e3cfb09e..2dd0f04c 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -57,12 +57,11 @@ import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
-import eu.siacs.conversations.entities.DownloadablePlaceholder;
+import eu.siacs.conversations.entities.Transferable;
+import eu.siacs.conversations.entities.TransferablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
-import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.generator.IqGenerator;
import eu.siacs.conversations.generator.MessageGenerator;
import eu.siacs.conversations.generator.PresenceGenerator;
@@ -975,7 +974,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void onMessageFound(Message message) {
if (!getFileBackend().isFileAvailable(message)) {
- message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
+ message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
}
}
});
@@ -986,7 +985,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
Message message = conversation.findMessageWithFileAndUuid(uuid);
if (message != null) {
if (!getFileBackend().isFileAvailable(message)) {
- message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
+ message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
updateConversationUi();
}
return;
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 20c6681b..fb7070ee 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -45,9 +45,9 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
-import eu.siacs.conversations.entities.DownloadablePlaceholder;
+import eu.siacs.conversations.entities.TransferablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
@@ -439,14 +439,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
MenuItem downloadFile = menu.findItem(R.id.download_file);
MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission);
if ((m.getType() == Message.TYPE_TEXT || m.getType() == Message.TYPE_PRIVATE)
- && m.getDownloadable() == null
+ && m.getTransferable() == null
&& !GeoHelper.isGeoUri(m.getBody())
&& m.treatAsDownloadable() != Message.Decision.MUST) {
copyText.setVisible(true);
}
if ((m.getType() != Message.TYPE_TEXT
&& m.getType() != Message.TYPE_PRIVATE
- && m.getDownloadable() == null)
+ && m.getTransferable() == null)
|| (GeoHelper.isGeoUri(m.getBody()))) {
shareWith.setVisible(true);
}
@@ -458,11 +458,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|| m.treatAsDownloadable() == Message.Decision.MUST) {
copyUrl.setVisible(true);
}
- if (m.getType() == Message.TYPE_TEXT && m.getDownloadable() == null && m.treatAsDownloadable() != Message.Decision.NEVER) {
+ if (m.getType() == Message.TYPE_TEXT && m.getTransferable() == null && m.treatAsDownloadable() != Message.Decision.NEVER) {
downloadFile.setVisible(true);
downloadFile.setTitle(activity.getString(R.string.download_x_file,UIHelper.getFileDescriptionString(activity, m)));
}
- if ((m.getDownloadable() != null && !(m.getDownloadable() instanceof DownloadablePlaceholder))
+ if ((m.getTransferable() != null && !(m.getTransferable() instanceof TransferablePlaceholder))
|| (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING
|| m.getStatus() == Message.STATUS_OFFERED))) {
cancelTransmission.setVisible(true);
@@ -529,7 +529,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
if (!file.exists()) {
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
- message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
+ message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
return;
}
}
@@ -561,9 +561,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
private void cancelTransmission(Message message) {
- Downloadable downloadable = message.getDownloadable();
- if (downloadable != null) {
- downloadable.cancel();
+ Transferable transferable = message.getTransferable();
+ if (transferable != null) {
+ transferable.cancel();
} else {
activity.xmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
}
@@ -757,7 +757,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (message.getEncryption() == Message.ENCRYPTION_PGP
&& (message.getStatus() == Message.STATUS_RECEIVED || message
.getStatus() >= Message.STATUS_SEND)
- && message.getDownloadable() == null) {
+ && message.getTransferable() == null) {
if (!mEncryptedMessages.contains(message)) {
mEncryptedMessages.add(message);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index 5cbc73ec..bfe44326 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -21,7 +21,7 @@ import java.util.concurrent.RejectedExecutionException;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.ui.XmppActivity;
@@ -69,8 +69,8 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
}
if (message.getFileParams().width > 0
- && (message.getDownloadable() == null
- || message.getDownloadable().getStatus() != Downloadable.STATUS_DELETED)) {
+ && (message.getTransferable() == null
+ || message.getTransferable().getStatus() != Transferable.STATUS_DELETED)) {
mLastMessage.setVisibility(View.GONE);
imagePreview.setVisibility(View.VISIBLE);
activity.loadBitmap(message, imagePreview);
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index d0a05c37..4d4e2679 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -29,7 +29,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Message.FileParams;
@@ -99,14 +99,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
&& message.getMergedStatus() <= Message.STATUS_RECEIVED;
- if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.getDownloadable() != null) {
+ if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.getTransferable() != null) {
FileParams params = message.getFileParams();
if (params.size > (1.5 * 1024 * 1024)) {
filesize = params.size / (1024 * 1024)+ " MiB";
} else if (params.size > 0) {
filesize = params.size / 1024 + " KiB";
}
- if (message.getDownloadable() != null && message.getDownloadable().getStatus() == Downloadable.STATUS_FAILED) {
+ if (message.getTransferable() != null && message.getTransferable().getStatus() == Transferable.STATUS_FAILED) {
error = true;
}
}
@@ -115,7 +115,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
info = getContext().getString(R.string.waiting);
break;
case Message.STATUS_UNSEND:
- Downloadable d = message.getDownloadable();
+ Transferable d = message.getTransferable();
if (d!=null) {
info = getContext().getString(R.string.sending_file,d.getProgress());
} else {
@@ -482,11 +482,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
});
- final Downloadable downloadable = message.getDownloadable();
- if (downloadable != null && downloadable.getStatus() != Downloadable.STATUS_UPLOADING) {
- if (downloadable.getStatus() == Downloadable.STATUS_OFFER) {
+ final Transferable transferable = message.getTransferable();
+ if (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING) {
+ if (transferable.getStatus() == Transferable.STATUS_OFFER) {
displayDownloadableMessage(viewHolder,message,activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message)));
- } else if (downloadable.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
+ } else if (transferable.getStatus() == Transferable.STATUS_OFFER_CHECK_FILESIZE) {
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
} else {
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first);
@@ -536,9 +536,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
public void startDownloadable(Message message) {
- Downloadable downloadable = message.getDownloadable();
- if (downloadable != null) {
- if (!downloadable.start()) {
+ Transferable transferable = message.getTransferable();
+ if (transferable != null) {
+ if (!transferable.start()) {
Toast.makeText(activity, R.string.not_connected_try_again,
Toast.LENGTH_SHORT).show();
}
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index ddc4781c..8047993a 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.utils;
-import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -10,7 +9,7 @@ import java.util.Locale;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.xmpp.jid.Jid;
@@ -142,24 +141,24 @@ public class UIHelper {
}
public static Pair<String,Boolean> getMessagePreview(final Context context, final Message message) {
- final Downloadable d = message.getDownloadable();
+ final Transferable d = message.getTransferable();
if (d != null ) {
switch (d.getStatus()) {
- case Downloadable.STATUS_CHECKING:
+ case Transferable.STATUS_CHECKING:
return new Pair<>(context.getString(R.string.checking_image),true);
- case Downloadable.STATUS_DOWNLOADING:
+ case Transferable.STATUS_DOWNLOADING:
return new Pair<>(context.getString(R.string.receiving_x_file,
getFileDescriptionString(context,message),
d.getProgress()),true);
- case Downloadable.STATUS_OFFER:
- case Downloadable.STATUS_OFFER_CHECK_FILESIZE:
+ case Transferable.STATUS_OFFER:
+ case Transferable.STATUS_OFFER_CHECK_FILESIZE:
return new Pair<>(context.getString(R.string.x_file_offered_for_download,
getFileDescriptionString(context,message)),true);
- case Downloadable.STATUS_DELETED:
+ case Transferable.STATUS_DELETED:
return new Pair<>(context.getString(R.string.file_deleted),true);
- case Downloadable.STATUS_FAILED:
+ case Transferable.STATUS_FAILED:
return new Pair<>(context.getString(R.string.file_transmission_failed),true);
- case Downloadable.STATUS_UPLOADING:
+ case Transferable.STATUS_UPLOADING:
if (message.getStatus() == Message.STATUS_OFFERED) {
return new Pair<>(context.getString(R.string.offering_x_file,
getFileDescriptionString(context, message)), true);
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index 8e4282a9..33534724 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.xmpp.jingle;
-import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -16,9 +15,9 @@ import android.util.Log;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.DownloadableFile;
-import eu.siacs.conversations.entities.DownloadablePlaceholder;
+import eu.siacs.conversations.entities.TransferablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element;
@@ -29,7 +28,7 @@ import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
import eu.siacs.conversations.xmpp.jingle.stanzas.Reason;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
-public class JingleConnection implements Downloadable {
+public class JingleConnection implements Transferable {
private JingleConnectionManager mJingleConnectionManager;
private XmppConnectionService mXmppConnectionService;
@@ -43,7 +42,7 @@ public class JingleConnection implements Downloadable {
private int ibbBlockSize = 4096;
private int mJingleStatus = -1;
- private int mStatus = Downloadable.STATUS_UNKNOWN;
+ private int mStatus = Transferable.STATUS_UNKNOWN;
private Message message;
private String sessionId;
private Account account;
@@ -199,8 +198,8 @@ public class JingleConnection implements Downloadable {
this.contentCreator = "initiator";
this.contentName = this.mJingleConnectionManager.nextRandomId();
this.message = message;
- this.message.setDownloadable(this);
- this.mStatus = Downloadable.STATUS_UPLOADING;
+ this.message.setTransferable(this);
+ this.mStatus = Transferable.STATUS_UPLOADING;
this.account = message.getConversation().getAccount();
this.initiator = this.account.getJid();
this.responder = this.message.getCounterpart();
@@ -256,8 +255,8 @@ public class JingleConnection implements Downloadable {
packet.getFrom().toBareJid(), false);
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
this.message.setStatus(Message.STATUS_RECEIVED);
- this.mStatus = Downloadable.STATUS_OFFER;
- this.message.setDownloadable(this);
+ this.mStatus = Transferable.STATUS_OFFER;
+ this.message.setTransferable(this);
final Jid from = packet.getFrom();
this.message.setCounterpart(from);
this.account = account;
@@ -408,7 +407,7 @@ public class JingleConnection implements Downloadable {
private void sendAccept() {
mJingleStatus = JINGLE_STATUS_ACCEPTED;
- this.mStatus = Downloadable.STATUS_DOWNLOADING;
+ this.mStatus = Transferable.STATUS_DOWNLOADING;
mXmppConnectionService.updateConversationUi();
this.mJingleConnectionManager.getPrimaryCandidate(this.account, new OnPrimaryCandidateFound() {
@Override
@@ -639,7 +638,7 @@ public class JingleConnection implements Downloadable {
this.disconnectSocks5Connections();
this.mJingleStatus = JINGLE_STATUS_FINISHED;
this.message.setStatus(Message.STATUS_RECEIVED);
- this.message.setDownloadable(null);
+ this.message.setTransferable(null);
this.mXmppConnectionService.updateMessage(message);
this.mJingleConnectionManager.finishConnection(this);
}
@@ -716,7 +715,7 @@ public class JingleConnection implements Downloadable {
if (this.transport != null && this.transport instanceof JingleInbandTransport) {
this.transport.disconnect();
}
- this.message.setDownloadable(null);
+ this.message.setTransferable(null);
this.mJingleConnectionManager.finishConnection(this);
}
@@ -728,7 +727,7 @@ public class JingleConnection implements Downloadable {
this.sendCancel();
this.mJingleConnectionManager.finishConnection(this);
if (this.responder.equals(account.getJid())) {
- this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED));
+ this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
if (this.file!=null) {
file.delete();
}
@@ -736,7 +735,7 @@ public class JingleConnection implements Downloadable {
} else {
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND_FAILED);
- this.message.setDownloadable(null);
+ this.message.setTransferable(null);
}
}
@@ -748,7 +747,7 @@ public class JingleConnection implements Downloadable {
}
if (this.message != null) {
if (this.responder.equals(account.getJid())) {
- this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED));
+ this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
if (this.file!=null) {
file.delete();
}
@@ -756,7 +755,7 @@ public class JingleConnection implements Downloadable {
} else {
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND_FAILED);
- this.message.setDownloadable(null);
+ this.message.setTransferable(null);
}
}
this.mJingleConnectionManager.finishConnection(this);
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
index f0cf5d8a..cadf9df3 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
@@ -9,14 +9,13 @@ import android.annotation.SuppressLint;
import android.util.Log;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.AbstractConnectionManager;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.Xmlns;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
-import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
@@ -59,7 +58,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
public JingleConnection createNewConnection(Message message) {
- Downloadable old = message.getDownloadable();
+ Transferable old = message.getTransferable();
if (old != null) {
old.cancel();
}