Compare commits
1 Commits
misc-code-
...
1473-displ
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccf2694475 |
@@ -32,11 +32,11 @@ import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
|||||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||||
import org.briarproject.briar.client.ConversationClientImpl;
|
import org.briarproject.briar.client.ConversationClientImpl;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static org.briarproject.bramble.util.StringUtils.fromHexString;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -219,8 +219,18 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
long timestamp = meta.getLong("timestamp");
|
long timestamp = meta.getLong("timestamp");
|
||||||
boolean local = meta.getBoolean("local");
|
boolean local = meta.getBoolean("local");
|
||||||
boolean read = meta.getBoolean("read");
|
boolean read = meta.getBoolean("read");
|
||||||
|
// TODO replace fake attachments by real ones
|
||||||
|
int num = (int) (timestamp % 5);
|
||||||
|
boolean hasText = num == 0 || id.hashCode() % 2 == 0;
|
||||||
|
List<AttachmentHeader> attachments = new ArrayList<>(num);
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
byte[] aIdBytes = id.getBytes().clone();
|
||||||
|
aIdBytes[0] = (byte) i;
|
||||||
|
MessageId aId = new MessageId(aIdBytes);
|
||||||
|
attachments.add(new AttachmentHeader(aId, "image/jpeg"));
|
||||||
|
}
|
||||||
headers.add(new PrivateMessageHeader(id, g, timestamp, local,
|
headers.add(new PrivateMessageHeader(id, g, timestamp, local,
|
||||||
read, s.isSent(), s.isSeen(), true, emptyList()));
|
read, s.isSent(), s.isSeen(), hasText, attachments));
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
@@ -241,11 +251,30 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
@Override
|
@Override
|
||||||
public Attachment getAttachment(MessageId m) {
|
public Attachment getAttachment(MessageId m) {
|
||||||
// TODO add real implementation
|
// TODO add real implementation
|
||||||
byte[] bytes = fromHexString("89504E470D0A1A0A0000000D49484452" +
|
String[] files = new String[] {
|
||||||
"000000010000000108060000001F15C4" +
|
// "error_animated.gif",
|
||||||
"890000000A49444154789C6300010000" +
|
// "error_high.jpg",
|
||||||
"0500010D0A2DB40000000049454E44AE426082");
|
// "error_wide.jpg",
|
||||||
return new Attachment(new ByteArrayInputStream(bytes));
|
// "error_huge.gif",
|
||||||
|
// "error_large.gif",
|
||||||
|
// "error_malformed.jpg",
|
||||||
|
// "wide.jpg",
|
||||||
|
// "high.jpg",
|
||||||
|
// "small.png",
|
||||||
|
"kitten1.jpg",
|
||||||
|
"kitten2.jpg",
|
||||||
|
"kitten3.gif",
|
||||||
|
"kitten4.jpg",
|
||||||
|
"kitten5.jpg",
|
||||||
|
"kitten6.png",
|
||||||
|
};
|
||||||
|
int index = Math.abs(m.hashCode() % files.length);
|
||||||
|
String file = files[index];
|
||||||
|
getLogger(MessagingManagerImpl.class.getName())
|
||||||
|
.warning("Loading file: " + file);
|
||||||
|
|
||||||
|
InputStream is = getClass().getClassLoader().getResourceAsStream(file);
|
||||||
|
return new Attachment(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
briar-core/src/main/resources/error_animated.gif
Normal file
|
After Width: | Height: | Size: 43 B |
BIN
briar-core/src/main/resources/error_high.jpg
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
briar-core/src/main/resources/error_huge.gif
Normal file
|
After Width: | Height: | Size: 43 B |
BIN
briar-core/src/main/resources/error_large.gif
Normal file
|
After Width: | Height: | Size: 43 B |
0
briar-core/src/main/resources/error_malformed.jpg
Normal file
BIN
briar-core/src/main/resources/error_wide.jpg
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
briar-core/src/main/resources/high.jpg
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
briar-core/src/main/resources/kitten1.jpg
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
briar-core/src/main/resources/kitten2.jpg
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
briar-core/src/main/resources/kitten3.gif
Normal file
|
After Width: | Height: | Size: 288 KiB |
BIN
briar-core/src/main/resources/kitten4.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
briar-core/src/main/resources/kitten5.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
briar-core/src/main/resources/kitten6.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
briar-core/src/main/resources/small.png
Normal file
|
After Width: | Height: | Size: 133 B |
BIN
briar-core/src/main/resources/wide.jpg
Normal file
|
After Width: | Height: | Size: 1.2 KiB |