introduced downloadable interface. reverted some of the changes made to OTR
This commit is contained in:
parent
a6f0f0cb6e
commit
b23f8bd472
|
@ -240,7 +240,6 @@
|
|||
<string name="missing_presence_updates">Missing presence updates from contact</string>
|
||||
<string name="request_presence_updates">Please request presence updates from your contact first.\n\n<small>This will be used to determine what client(s) your contact is using.</small></string>
|
||||
<string name="request_now">Request now</string>
|
||||
<string name="unable_to_decrypt_otr_message"><i>Unable to decrypt OTR message</i></string>
|
||||
<string name="delete_fingerprint">Delete Fingerprint</string>
|
||||
<string name="sure_delete_fingerprint">Are you sure you would like to delete this fingerprint?</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
|
|
|
@ -174,21 +174,7 @@ public class OtrEngine implements OtrEngineHost {
|
|||
|
||||
@Override
|
||||
public void messageFromAnotherInstanceReceived(SessionID id) {
|
||||
String jid = id.getAccountID();
|
||||
Conversation conversation = mXmppConnectionService
|
||||
.findOrCreateConversation(account, jid, false);
|
||||
Message error = new Message(conversation, null, Message.ENCRYPTION_OTR);
|
||||
conversation.getMessages().add(error);
|
||||
error.setStatus(Message.STATUS_RECEPTION_FAILED);
|
||||
mXmppConnectionService.databaseBackend.createMessage(error);
|
||||
SessionImpl session = conversation.getOtrSession();
|
||||
if (session != null
|
||||
&& session.getSessionStatus() != SessionStatus.ENCRYPTED) {
|
||||
try {
|
||||
session.startSession();
|
||||
} catch (OtrException e) {
|
||||
}
|
||||
}
|
||||
Log.d(Config.LOGTAG,"unreadable message received from "+id.getAccountID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
5
src/eu/siacs/conversations/entities/Downloadable.java
Normal file
5
src/eu/siacs/conversations/entities/Downloadable.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package eu.siacs.conversations.entities;
|
||||
|
||||
public interface Downloadable {
|
||||
public void start();
|
||||
}
|
|
@ -2,7 +2,6 @@ package eu.siacs.conversations.entities;
|
|||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
@ -60,7 +59,7 @@ public class Message extends AbstractEntity {
|
|||
|
||||
protected transient Conversation conversation = null;
|
||||
|
||||
protected transient JingleConnection jingleConnection = null;
|
||||
protected transient Downloadable downloadable = null;
|
||||
|
||||
private Message() {
|
||||
|
||||
|
@ -151,8 +150,6 @@ public class Message extends AbstractEntity {
|
|||
public String getReadableBody(Context context) {
|
||||
if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) {
|
||||
return context.getText(R.string.encrypted_message_received).toString();
|
||||
} else if (encryption == ENCRYPTION_OTR && type == TYPE_TEXT && status == STATUS_RECEPTION_FAILED) {
|
||||
return context.getText(R.string.unable_to_decrypt_otr_message).toString();
|
||||
} else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) {
|
||||
return context.getText(R.string.encrypted_image_received).toString();
|
||||
} else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
|
||||
|
@ -270,12 +267,12 @@ public class Message extends AbstractEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setJingleConnection(JingleConnection connection) {
|
||||
this.jingleConnection = connection;
|
||||
public void setDownloadable(Downloadable downloadable) {
|
||||
this.downloadable = downloadable;
|
||||
}
|
||||
|
||||
public JingleConnection getJingleConnection() {
|
||||
return this.jingleConnection;
|
||||
public Downloadable getDownloadable() {
|
||||
return this.downloadable;
|
||||
}
|
||||
|
||||
public static Message createStatusMessage(Conversation conversation) {
|
||||
|
|
|
@ -62,10 +62,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||
|
||||
if (latestMessage.getType() == Message.TYPE_TEXT
|
||||
|| latestMessage.getType() == Message.TYPE_PRIVATE) {
|
||||
if (latestMessage.getEncryption() == Message.ENCRYPTION_OTR
|
||||
&& latestMessage.getStatus() == Message.STATUS_RECEPTION_FAILED) {
|
||||
convLastMsg.setText(R.string.unable_to_decrypt_otr_message);
|
||||
} else if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
|
||||
if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
|
||||
&& (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
|
||||
String body = Config.PARSE_EMOTICONS ? UIHelper
|
||||
.transformAsciiEmoticons(latestMessage.getBody())
|
||||
|
|
|
@ -7,6 +7,7 @@ import eu.siacs.conversations.Config;
|
|||
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.Message;
|
||||
import eu.siacs.conversations.ui.ConversationActivity;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
|
@ -461,10 +462,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
JingleConnection connection = item
|
||||
.getJingleConnection();
|
||||
if (connection != null) {
|
||||
connection.accept();
|
||||
Downloadable downloadable = item.getDownloadable();
|
||||
if (downloadable != null) {
|
||||
downloadable.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -495,11 +495,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
displayDecryptionFailed(viewHolder);
|
||||
} else if (item.getEncryption() == Message.ENCRYPTION_OTR
|
||||
&& item.getStatus() == Message.STATUS_RECEPTION_FAILED
|
||||
&& item.getType() == Message.TYPE_TEXT) {
|
||||
displayInfoMessage(viewHolder,
|
||||
R.string.unable_to_decrypt_otr_message);
|
||||
} else {
|
||||
displayTextMessage(viewHolder, item);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.Message;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
|
@ -24,7 +25,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 {
|
||||
public class JingleConnection implements Downloadable {
|
||||
|
||||
private final String[] extensions = { "webp", "jpeg", "jpg", "png" };
|
||||
private final String[] cryptoExtensions = { "pgp", "gpg", "otr" };
|
||||
|
@ -259,7 +260,7 @@ public class JingleConnection {
|
|||
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||
this.message.setType(Message.TYPE_IMAGE);
|
||||
this.message.setStatus(Message.STATUS_RECEIVED_OFFER);
|
||||
this.message.setJingleConnection(this);
|
||||
this.message.setDownloadable(this);
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
this.message.setPresence(fromParts[1]);
|
||||
this.account = account;
|
||||
|
@ -866,7 +867,7 @@ public class JingleConnection {
|
|||
return this.transport;
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
public void start() {
|
||||
if (status == STATUS_INITIATED) {
|
||||
new Thread(new Runnable() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue