Move remote wipe MessageType enum to briar-api

This commit is contained in:
ameba23
2021-05-25 12:55:26 +02:00
parent 76c37431ba
commit d42c25ebf7
2 changed files with 11 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
package org.briarproject.briar.remotewipe; package org.briarproject.briar.api.remotewipe;
import org.briarproject.bramble.api.FormatException; import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault; import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@@ -7,7 +7,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
@NotNullByDefault @NotNullByDefault
enum MessageType { public enum MessageType {
SETUP(0), WIPE(1); SETUP(0), WIPE(1);
@@ -17,11 +17,11 @@ enum MessageType {
this.value = value; this.value = value;
} }
int getValue() { public int getValue() {
return value; return value;
} }
static MessageType fromValue(int value) throws public static MessageType fromValue(int value) throws
FormatException { FormatException {
for (MessageType m : values()) if (m.value == value) return m; for (MessageType m : values()) if (m.value == value) return m;
throw new FormatException(); throw new FormatException();

View File

@@ -16,18 +16,24 @@ import javax.annotation.concurrent.Immutable;
public class RemoteWipeMessageHeader extends ConversationMessageHeader { public class RemoteWipeMessageHeader extends ConversationMessageHeader {
private final List<AttachmentHeader> attachmentHeaders; private final List<AttachmentHeader> attachmentHeaders;
private final MessageType type;
public RemoteWipeMessageHeader(MessageId id, GroupId groupId, long timestamp, public RemoteWipeMessageHeader(MessageId id, GroupId groupId, long timestamp,
boolean local, boolean read, boolean sent, boolean seen, boolean local, boolean read, boolean sent, boolean seen,
List<AttachmentHeader> headers) { List<AttachmentHeader> headers, MessageType type) {
super(id, groupId, timestamp, local, read, sent, seen); super(id, groupId, timestamp, local, read, sent, seen);
this.attachmentHeaders = headers; this.attachmentHeaders = headers;
this.type = type;
} }
public List<AttachmentHeader> getAttachmentHeaders() { public List<AttachmentHeader> getAttachmentHeaders() {
return attachmentHeaders; return attachmentHeaders;
} }
public MessageType getMessageType() {
return type;
}
@Override @Override
public <T> T accept(ConversationMessageVisitor<T> v) { public <T> T accept(ConversationMessageVisitor<T> v) {
return v.visitRemoteWipeMessage(this); return v.visitRemoteWipeMessage(this);