diff options
author | lookshe <github@lookshe.org> | 2016-03-08 21:13:24 +0100 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-03-08 21:13:24 +0100 |
commit | 74d6d10cb76b7440f57db193a3c38e476206969c (patch) | |
tree | 665b7787c0f7bcb6d759e849972fa9658e84423f /src/main/java/de/thedevstack/conversationsplus/entities/Message.java | |
parent | 7be757de90fb71042b79b88a76cd36fc07b2ee87 (diff) | |
parent | f051dd0bcdbd35d101420fb1f75f33a565a1e0f8 (diff) |
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/Message.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/entities/Message.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java index d03cab92..f1da885e 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java @@ -51,6 +51,7 @@ public class Message extends AbstractEntity { public static final String STATUS = "status"; public static final String TYPE = "type"; public static final String CARBON = "carbon"; + public static final String OOB = "oob"; public static final String EDITED = "edited"; public static final String REMOTE_MSG_ID = "remoteMsgId"; public static final String SERVER_MSG_ID = "serverMsgId"; @@ -71,6 +72,7 @@ public class Message extends AbstractEntity { protected int status; protected int type; protected boolean carbon = false; + protected boolean oob = false; protected String edited = null; protected String relativeFilePath; protected boolean read = true; @@ -106,7 +108,8 @@ public class Message extends AbstractEntity { null, null, true, - null); + null, + false); this.conversation = conversation; } @@ -115,7 +118,7 @@ public class Message extends AbstractEntity { final int encryption, final int status, final int type, final boolean carbon, final String remoteMsgId, final String relativeFilePath, final String serverMsgId, final String fingerprint, final boolean read, - final String edited) { + final String edited, final boolean oob) { this.uuid = uuid; this.conversationUuid = conversationUUid; this.counterpart = counterpart; @@ -132,6 +135,7 @@ public class Message extends AbstractEntity { this.axolotlFingerprint = fingerprint; this.read = read; this.edited = edited; + this.oob = oob; } public static Message fromCursor(Cursor cursor) { @@ -172,7 +176,8 @@ public class Message extends AbstractEntity { cursor.getString(cursor.getColumnIndex(SERVER_MSG_ID)), cursor.getString(cursor.getColumnIndex(FINGERPRINT)), cursor.getInt(cursor.getColumnIndex(READ)) > 0, - cursor.getString(cursor.getColumnIndex(EDITED))); + cursor.getString(cursor.getColumnIndex(EDITED)), + cursor.getInt(cursor.getColumnIndex(OOB)) > 0); } public static Message createStatusMessage(Conversation conversation, String body) { @@ -210,6 +215,7 @@ public class Message extends AbstractEntity { values.put(FINGERPRINT, axolotlFingerprint); values.put(READ,read ? 1 : 0); values.put(EDITED, edited); + values.put(OOB, oob ? 1 : 0); return values; } @@ -543,6 +549,10 @@ public class Message extends AbstractEntity { return edited; } + public void setOob(boolean isOob) { + this.oob = isOob; + } + public enum Decision { MUST, SHOULD, @@ -565,7 +575,7 @@ public class Message extends AbstractEntity { if (dotPosition != -1) { String extension = filename.substring(dotPosition + 1); // we want the real file extension, not the crypto one - if (Arrays.asList(Transferable.VALID_CRYPTO_EXTENSIONS).contains(extension)) { + if (Transferable.VALID_CRYPTO_EXTENSIONS.contains(extension)) { return extractRelevantExtension(filename.substring(0,dotPosition)); } else { return extension; @@ -604,6 +614,8 @@ public class Message extends AbstractEntity { URL url = new URL(body); if (!url.getProtocol().equalsIgnoreCase("http") && !url.getProtocol().equalsIgnoreCase("https")) { return Decision.NEVER; + } else if (oob) { + return Decision.MUST; } String extension = extractRelevantExtension(url); if (extension == null) { @@ -618,8 +630,8 @@ public class Message extends AbstractEntity { } else { return Decision.NEVER; } - } else if (Arrays.asList(Transferable.VALID_IMAGE_EXTENSIONS).contains(extension) - || Arrays.asList(Transferable.WELL_KNOWN_EXTENSIONS).contains(extension)) { + } else if (Transferable.VALID_IMAGE_EXTENSIONS.contains(extension) + || Transferable.WELL_KNOWN_EXTENSIONS.contains(extension)) { return Decision.SHOULD; } else { return Decision.NEVER; |