mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Facade for private message headers. #173
This commit is contained in:
@@ -7,12 +7,16 @@ import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.messaging.MessagingManager;
|
||||
import org.briarproject.api.messaging.PrivateConversation;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageHeader;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
// Temporary facade during sync protocol refactoring
|
||||
class MessagingManagerImpl implements MessagingManager {
|
||||
@@ -40,9 +44,14 @@ class MessagingManagerImpl implements MessagingManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<MessageHeader> getMessageHeaders(ContactId c)
|
||||
public Collection<PrivateMessageHeader> getMessageHeaders(ContactId c)
|
||||
throws DbException {
|
||||
return db.getInboxMessageHeaders(c);
|
||||
Collection<MessageHeader> headers = db.getInboxMessageHeaders(c);
|
||||
List<PrivateMessageHeader> privateHeaders =
|
||||
new ArrayList<PrivateMessageHeader>(headers.size());
|
||||
for (MessageHeader m : headers)
|
||||
privateHeaders.add(new PrivateMessageHeaderImpl(m));
|
||||
return Collections.unmodifiableList(privateHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.briarproject.messaging;
|
||||
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.sync.MessageHeader;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
// Temporary facade during sync protocol refactoring
|
||||
public class PrivateMessageHeaderImpl implements PrivateMessageHeader {
|
||||
|
||||
private final MessageHeader messageHeader;
|
||||
|
||||
PrivateMessageHeaderImpl(MessageHeader messageHeader) {
|
||||
this.messageHeader = messageHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageId getId() {
|
||||
return messageHeader.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Author getAuthor() {
|
||||
return messageHeader.getAuthor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return messageHeader.getContentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return messageHeader.getTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return messageHeader.isLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRead() {
|
||||
return messageHeader.isRead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
switch (messageHeader.getStatus()) {
|
||||
case STORED:
|
||||
return Status.STORED;
|
||||
case SENT:
|
||||
return Status.SENT;
|
||||
case DELIVERED:
|
||||
return Status.DELIVERED;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user