aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-03-11 21:34:10 +0100
committersteckbrief <steckbrief@chefmail.de>2016-03-11 21:34:10 +0100
commit864bb77883b2f5d9f9122c102faa4af89d589653 (patch)
treec9d7b675da2b5eb38809dabdd599e43ff0acce3b /src/main/java/eu/siacs/conversations/entities
parent8585231be2844ab794cfa63454b1013bae8502f6 (diff)
parentbfc5000b6aa3d401ad80e04c43a6671aa9c2c619 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Conflicts: src/main/java/eu/siacs/conversations/entities/Message.java
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java6
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java103
2 files changed, 3 insertions, 106 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index 75477d3e..4a9e83a3 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -261,16 +261,12 @@ public class Conversation extends AbstractEntity implements Blockable {
return null;
}
+ // TODO Check if this is really necessary
public void populateWithMessages(final List<Message> messages) {
synchronized (this.messages) {
messages.clear();
messages.addAll(this.messages);
}
- for(Iterator<Message> iterator = messages.iterator(); iterator.hasNext();) {
- if (iterator.next().wasMergedIntoPrevious()) {
- iterator.remove();
- }
- }
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 599afc93..f463da54 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -5,11 +5,8 @@ import android.database.Cursor;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
-import eu.siacs.conversations.Config;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
-import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.MimeUtils;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
@@ -344,10 +341,6 @@ public class Message extends AbstractEntity {
this.carbon = carbon;
}
- public void setEdited(String edited) {
- this.edited = edited;
- }
-
public boolean edited() {
return this.edited != null;
}
@@ -356,10 +349,6 @@ public class Message extends AbstractEntity {
this.trueCounterpart = trueCounterpart;
}
- public Jid getTrueCounterpart() {
- return this.trueCounterpart;
- }
-
public Transferable getTransferable() {
return this.transferable;
}
@@ -391,8 +380,7 @@ public class Message extends AbstractEntity {
} else {
return this.remoteMsgId == null
&& this.counterpart.equals(message.getCounterpart())
- && body.equals(otherBody)
- && Math.abs(this.getTimeSent() - message.getTimeSent()) < Config.MESSAGE_MERGE_WINDOW * 1000;
+ && body.equals(otherBody);
}
}
}
@@ -425,95 +413,8 @@ public class Message extends AbstractEntity {
}
}
- public boolean isLastCorrectableMessage() {
- Message next = next();
- while(next != null) {
- if (next.isCorrectable()) {
- return false;
- }
- next = next.next();
- }
- return isCorrectable();
- }
-
- private boolean isCorrectable() {
- return getStatus() != STATUS_RECEIVED && !isCarbon();
- }
-
- public boolean mergeable(final Message message) {
- return message != null &&
- (message.getType() == Message.TYPE_TEXT &&
- this.getTransferable() == null &&
- message.getTransferable() == null &&
- message.getEncryption() != Message.ENCRYPTION_PGP &&
- message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED &&
- this.getType() == message.getType() &&
- //this.getStatus() == message.getStatus() &&
- isStatusMergeable(this.getStatus(), message.getStatus()) &&
- this.getEncryption() == message.getEncryption() &&
- this.getCounterpart() != null &&
- this.getCounterpart().equals(message.getCounterpart()) &&
- this.edited() == message.edited() &&
- (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
- !GeoHelper.isGeoUri(message.getBody()) &&
- !GeoHelper.isGeoUri(this.getBody()) &&
- message.treatAsDownloadable() == Decision.NEVER &&
- this.treatAsDownloadable() == Decision.NEVER &&
- !message.getBody().startsWith(ME_COMMAND) &&
- !this.getBody().startsWith(ME_COMMAND) &&
- this.isTrusted() == message.isTrusted()
- );
- }
-
- private static boolean isStatusMergeable(int a, int b) {
- return a == b || (
- (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_UNSEND)
- || (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_SEND)
- || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND)
- || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND_RECEIVED)
- || (a == Message.STATUS_SEND && b == Message.STATUS_UNSEND)
- || (a == Message.STATUS_SEND && b == Message.STATUS_SEND_RECEIVED)
- );
- }
-
- public String getMergedBody() {
- StringBuilder body = new StringBuilder(this.body);
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- body.append(MERGE_SEPARATOR);
- body.append(current.getBody());
- }
- return body.toString();
- }
-
public boolean hasMeCommand() {
- return getMergedBody().startsWith(ME_COMMAND);
- }
-
- public int getMergedStatus() {
- int status = this.status;
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- status = current.status;
- }
- return status;
- }
-
- public long getMergedTimeSent() {
- long time = this.timeSent;
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- time = current.timeSent;
- }
- return time;
- }
-
- public boolean wasMergedIntoPrevious() {
- Message prev = this.prev();
- return prev != null && prev.mergeable(this);
+ return getBody().startsWith(ME_COMMAND);
}
public boolean trusted() {