From cb4069f0f213ed1a38ce074d981b0c367dc2cdfd Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 15 Oct 2014 19:32:12 +0200 Subject: refactored file download status. make image http download available for carbon copied (sent) messages as well --- src/eu/siacs/conversations/entities/Conversation.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index b4c99dc1..5f204ec2 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -68,7 +68,7 @@ public class Conversation extends AbstractEntity { private transient MucOptions mucOptions = null; - //private transient String latestMarkableMessageId; + // private transient String latestMarkableMessageId; private byte[] symmetricKey; @@ -142,8 +142,9 @@ public class Conversation extends AbstractEntity { if (this.messages == null) { return null; } - for(int i = this.messages.size() - 1; i >= 0; --i) { - if (this.messages.get(i).getStatus() <= Message.STATUS_RECEIVED && this.messages.get(i).markable) { + for (int i = this.messages.size() - 1; i >= 0; --i) { + if (this.messages.get(i).getStatus() <= Message.STATUS_RECEIVED + && this.messages.get(i).markable) { if (this.messages.get(i).isRead()) { return null; } else { -- cgit v1.2.3 From c1a55608df588df12b562598e985f427cdd9a9db Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 16 Oct 2014 15:53:44 +0200 Subject: log ending otr sessions on disconnect --- src/eu/siacs/conversations/entities/Conversation.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index 5f204ec2..e29981fd 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -297,18 +297,23 @@ public class Conversation extends AbstractEntity { } } - public void endOtrIfNeeded() { + public boolean endOtrIfNeeded() { if (this.otrSession != null) { if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) { try { this.otrSession.endSession(); this.resetOtrSession(); + return true; } catch (OtrException e) { this.resetOtrSession(); + return false; } } else { this.resetOtrSession(); + return false; } + } else { + return false; } } -- cgit v1.2.3 From 0fd634ae52a0e6b8d58c88b687cffe9db7d39956 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 16 Oct 2014 16:09:54 +0200 Subject: simplified determination whether otr needs starting in a session --- src/eu/siacs/conversations/entities/Conversation.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index e29981fd..c984933f 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -72,8 +72,6 @@ public class Conversation extends AbstractEntity { private byte[] symmetricKey; - private boolean otrSessionNeedsStarting = false; - private Bookmark bookmark; public Conversation(String name, Account account, String contactJid, @@ -264,10 +262,7 @@ public class Conversation extends AbstractEntity { try { if (sendStart) { this.otrSession.startSession(); - this.otrSessionNeedsStarting = false; return this.otrSession; - } else { - this.otrSessionNeedsStarting = true; } return this.otrSession; } catch (OtrException e) { @@ -283,12 +278,12 @@ public class Conversation extends AbstractEntity { public void resetOtrSession() { this.otrFingerprint = null; - this.otrSessionNeedsStarting = false; this.otrSession = null; } public void startOtrIfNeeded() { - if (this.otrSession != null && this.otrSessionNeedsStarting) { + if (this.otrSession != null + && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) { try { this.otrSession.startSession(); } catch (OtrException e) { -- cgit v1.2.3 From a201f9e53f33109836a690488b9f8a98db4f5249 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sun, 19 Oct 2014 23:13:55 +0200 Subject: got rid of copyonwrite array list for messages --- .../siacs/conversations/entities/Conversation.java | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index c984933f..600b9d38 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -1,8 +1,8 @@ package eu.siacs.conversations.entities; import java.security.interfaces.DSAPublicKey; +import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import org.json.JSONException; import org.json.JSONObject; @@ -57,7 +57,7 @@ public class Conversation extends AbstractEntity { private String nextPresence; - private transient CopyOnWriteArrayList messages = null; + private transient ArrayList messages = new ArrayList(); private transient Account account = null; private transient SessionImpl otrSession; @@ -104,17 +104,6 @@ public class Conversation extends AbstractEntity { } public List getMessages() { - if (messages == null) { - this.messages = new CopyOnWriteArrayList(); // prevent null - // pointer - } - - // populate with Conversation (this) - - for (Message msg : messages) { - msg.setConversation(this); - } - return messages; } @@ -165,7 +154,7 @@ public class Conversation extends AbstractEntity { } } - public void setMessages(CopyOnWriteArrayList msgs) { + public void setMessages(ArrayList msgs) { this.messages = msgs; } @@ -507,4 +496,17 @@ public class Conversation extends AbstractEntity { } } } + + public void add(Message message) { + message.setConversation(this); + synchronized (this.messages) { + this.messages.add(message); + } + } + + public void addAll(int index, List messages) { + synchronized (this.messages) { + this.messages.addAll(index, messages); + } + } } -- cgit v1.2.3 From 0bb2c3c4d5b2a4b676610276fafd50ea55f43706 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 20 Oct 2014 17:01:37 +0200 Subject: keep reference to previous and next message in message --- src/eu/siacs/conversations/entities/Conversation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index 600b9d38..e9500a0c 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -57,8 +57,8 @@ public class Conversation extends AbstractEntity { private String nextPresence; - private transient ArrayList messages = new ArrayList(); - private transient Account account = null; + protected ArrayList messages = new ArrayList(); + protected Account account = null; private transient SessionImpl otrSession; -- cgit v1.2.3 From 21961673cbcb3132d2405c3d276058b94cbdbbfc Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 20 Oct 2014 21:08:33 +0200 Subject: refactored avatar generation. first step --- src/eu/siacs/conversations/entities/Conversation.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/eu/siacs/conversations/entities/Conversation.java') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index e9500a0c..9d4c36db 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -8,7 +8,6 @@ import org.json.JSONException; import org.json.JSONObject; import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.utils.UIHelper; import net.java.otr4j.OtrException; import net.java.otr4j.crypto.OtrCryptoEngineImpl; @@ -17,9 +16,7 @@ import net.java.otr4j.session.SessionID; import net.java.otr4j.session.SessionImpl; import net.java.otr4j.session.SessionStatus; import android.content.ContentValues; -import android.content.Context; import android.database.Cursor; -import android.graphics.Bitmap; import android.os.SystemClock; public class Conversation extends AbstractEntity { @@ -329,9 +326,8 @@ public class Conversation extends AbstractEntity { public synchronized MucOptions getMucOptions() { if (this.mucOptions == null) { - this.mucOptions = new MucOptions(this.getAccount()); + this.mucOptions = new MucOptions(this); } - this.mucOptions.setConversation(this); return this.mucOptions; } @@ -428,14 +424,6 @@ public class Conversation extends AbstractEntity { return this.bookmark; } - public Bitmap getImage(Context context, int size) { - if (mode == MODE_SINGLE) { - return getContact().getImage(size, context); - } else { - return UIHelper.getContactPicture(this, size, context, false); - } - } - public boolean hasDuplicateMessage(Message message) { for (int i = this.getMessages().size() - 1; i >= 0; --i) { if (this.messages.get(i).equals(message)) { @@ -496,7 +484,7 @@ public class Conversation extends AbstractEntity { } } } - + public void add(Message message) { message.setConversation(this); synchronized (this.messages) { -- cgit v1.2.3