mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Refactor PrivateMessageHeader to ConversationMessageHeader base-class
This is preparation for adding attachments to private messages
This commit is contained in:
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.sharing.InvitationRequest;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -21,7 +21,7 @@ public class BlogInvitationRequest extends InvitationRequest<Blog> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitBlogInvitationRequest(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||
|
||||
@NotNullByDefault
|
||||
@@ -18,7 +18,7 @@ public class BlogInvitationResponse extends InvitationResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitBlogInvitationResponse(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package org.briarproject.briar.api.blog.event;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.blog.Blog;
|
||||
import org.briarproject.briar.api.messaging.PrivateRequest;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class BlogInvitationRequestReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<PrivateRequest<Blog>> {
|
||||
ConversationMessageReceivedEvent<ConversationRequest<Blog>> {
|
||||
|
||||
public BlogInvitationRequestReceivedEvent(PrivateRequest<Blog> request,
|
||||
public BlogInvitationRequestReceivedEvent(ConversationRequest<Blog> request,
|
||||
ContactId contactId) {
|
||||
super(request, contactId);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ package org.briarproject.briar.api.blog.event;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.blog.BlogInvitationResponse;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class BlogInvitationResponseReceivedEvent
|
||||
extends PrivateMessageReceivedEvent<BlogInvitationResponse> {
|
||||
extends ConversationMessageReceivedEvent<BlogInvitationResponse> {
|
||||
|
||||
public BlogInvitationResponseReceivedEvent(BlogInvitationResponse response,
|
||||
ContactId contactId) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.api.messaging;
|
||||
package org.briarproject.briar.api.conversation;
|
||||
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.sync.Group;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -27,7 +28,7 @@ public interface ConversationManager {
|
||||
* Only {@link MessagingManager} returns only headers.
|
||||
* The others also return the message text.
|
||||
*/
|
||||
Collection<PrivateMessageHeader> getMessageHeaders(ContactId c)
|
||||
Collection<ConversationMessageHeader> getMessageHeaders(ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ public interface ConversationManager {
|
||||
|
||||
Group getContactGroup(Contact c);
|
||||
|
||||
Collection<PrivateMessageHeader> getMessageHeaders(Transaction txn,
|
||||
Collection<ConversationMessageHeader> getMessageHeaders(Transaction txn,
|
||||
ContactId contactId) throws DbException;
|
||||
|
||||
GroupCount getGroupCount(Transaction txn, ContactId c)
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.briarproject.briar.api.conversation;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public abstract class ConversationMessageHeader {
|
||||
|
||||
private final MessageId id;
|
||||
private final GroupId groupId;
|
||||
private final long timestamp;
|
||||
private final boolean local, sent, seen, read;
|
||||
|
||||
public ConversationMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
||||
boolean local, boolean read, boolean sent, boolean seen) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.timestamp = timestamp;
|
||||
this.local = local;
|
||||
this.sent = sent;
|
||||
this.seen = seen;
|
||||
this.read = read;
|
||||
}
|
||||
|
||||
public MessageId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public boolean isSent() {
|
||||
return sent;
|
||||
}
|
||||
|
||||
public boolean isSeen() {
|
||||
return seen;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public abstract <T> T accept(ConversationMessageVisitor<T> v);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.api.messaging;
|
||||
package org.briarproject.briar.api.conversation;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.blog.BlogInvitationRequest;
|
||||
@@ -7,11 +7,12 @@ import org.briarproject.briar.api.forum.ForumInvitationRequest;
|
||||
import org.briarproject.briar.api.forum.ForumInvitationResponse;
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface PrivateMessageVisitor<T> {
|
||||
public interface ConversationMessageVisitor<T> {
|
||||
|
||||
T visitPrivateMessageHeader(PrivateMessageHeader h);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.api.messaging;
|
||||
package org.briarproject.briar.api.conversation;
|
||||
|
||||
import org.briarproject.bramble.api.Nameable;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
@@ -11,7 +11,8 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class PrivateRequest<N extends Nameable> extends PrivateMessageHeader {
|
||||
public abstract class ConversationRequest<N extends Nameable>
|
||||
extends ConversationMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final N nameable;
|
||||
@@ -19,7 +20,7 @@ public class PrivateRequest<N extends Nameable> extends PrivateMessageHeader {
|
||||
private final String text;
|
||||
private final boolean answered;
|
||||
|
||||
public PrivateRequest(MessageId messageId, GroupId groupId, long time,
|
||||
public ConversationRequest(MessageId messageId, GroupId groupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read,
|
||||
SessionId sessionId, N nameable, @Nullable String text,
|
||||
boolean answered) {
|
||||
@@ -50,4 +51,5 @@ public class PrivateRequest<N extends Nameable> extends PrivateMessageHeader {
|
||||
public boolean wasAnswered() {
|
||||
return answered;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.api.messaging;
|
||||
package org.briarproject.briar.api.conversation;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
@@ -9,12 +9,12 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public abstract class PrivateResponse extends PrivateMessageHeader {
|
||||
public abstract class ConversationResponse extends ConversationMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final boolean accepted;
|
||||
|
||||
public PrivateResponse(MessageId id, GroupId groupId, long time,
|
||||
public ConversationResponse(MessageId id, GroupId groupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read,
|
||||
SessionId sessionId, boolean accepted) {
|
||||
super(id, groupId, time, local, sent, seen, read);
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.briarproject.briar.api.conversation.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageHeader;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* An event that is broadcast when a new conversation message is received.
|
||||
*/
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ConversationMessageReceivedEvent<H extends ConversationMessageHeader>
|
||||
extends Event {
|
||||
|
||||
private final H messageHeader;
|
||||
private final ContactId contactId;
|
||||
|
||||
public ConversationMessageReceivedEvent(H messageHeader, ContactId contactId) {
|
||||
this.messageHeader = messageHeader;
|
||||
this.contactId = contactId;
|
||||
}
|
||||
|
||||
public H getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.sharing.InvitationRequest;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -23,7 +23,7 @@ public class ForumInvitationRequest extends InvitationRequest<Forum> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitForumInvitationRequest(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -21,7 +21,7 @@ public class ForumInvitationResponse extends InvitationResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitForumInvitationResponse(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@ package org.briarproject.briar.api.forum.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.forum.Forum;
|
||||
import org.briarproject.briar.api.messaging.PrivateRequest;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ForumInvitationRequestReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<PrivateRequest<Forum>> {
|
||||
ConversationMessageReceivedEvent<ConversationRequest<Forum>> {
|
||||
|
||||
public ForumInvitationRequestReceivedEvent(PrivateRequest<Forum> request,
|
||||
public ForumInvitationRequestReceivedEvent(ConversationRequest<Forum> request,
|
||||
ContactId contactId) {
|
||||
super(request, contactId);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@ package org.briarproject.briar.api.forum.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.forum.ForumInvitationResponse;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ForumInvitationResponseReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<ForumInvitationResponse> {
|
||||
ConversationMessageReceivedEvent<ForumInvitationResponse> {
|
||||
|
||||
public ForumInvitationResponseReceivedEvent(
|
||||
ForumInvitationResponse response, ContactId contactId) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.ClientId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.ConversationManager.ConversationClient;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.messaging.PrivateRequest;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionRequest extends PrivateRequest<Author> {
|
||||
public class IntroductionRequest extends ConversationRequest<Author> {
|
||||
|
||||
private final AuthorInfo authorInfo;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class IntroductionRequest extends PrivateRequest<Author> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitIntroductionRequest(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.messaging.PrivateResponse;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationResponse;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@@ -15,7 +15,7 @@ import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionResponse extends PrivateResponse {
|
||||
public class IntroductionResponse extends ConversationResponse {
|
||||
|
||||
private final Author introducedAuthor;
|
||||
private final AuthorInfo introducedAuthorInfo;
|
||||
@@ -45,7 +45,7 @@ public class IntroductionResponse extends PrivateResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitIntroductionResponse(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@ package org.briarproject.briar.api.introduction.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionRequestReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<IntroductionRequest> {
|
||||
public class IntroductionRequestReceivedEvent
|
||||
extends ConversationMessageReceivedEvent<IntroductionRequest> {
|
||||
|
||||
public IntroductionRequestReceivedEvent(
|
||||
IntroductionRequest introductionRequest, ContactId contactId) {
|
||||
|
||||
@@ -2,15 +2,15 @@ package org.briarproject.briar.api.introduction.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionResponseReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<IntroductionResponse> {
|
||||
ConversationMessageReceivedEvent<IntroductionResponse> {
|
||||
|
||||
public IntroductionResponseReceivedEvent(
|
||||
IntroductionResponse introductionResponse, ContactId contactId) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.ClientId;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.messaging.ConversationManager.ConversationClient;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface MessagingManager extends ConversationClient {
|
||||
|
||||
@@ -3,58 +3,23 @@ package org.briarproject.briar.api.messaging;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageHeader;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class PrivateMessageHeader {
|
||||
|
||||
private final MessageId id;
|
||||
private final GroupId groupId;
|
||||
private final long timestamp;
|
||||
private final boolean local, sent, seen, read;
|
||||
public class PrivateMessageHeader extends ConversationMessageHeader {
|
||||
|
||||
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
||||
boolean local, boolean read, boolean sent, boolean seen) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.timestamp = timestamp;
|
||||
this.local = local;
|
||||
this.sent = sent;
|
||||
this.seen = seen;
|
||||
this.read = read;
|
||||
super(id, groupId, timestamp, local, read, sent, seen);
|
||||
}
|
||||
|
||||
public MessageId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public boolean isSent() {
|
||||
return sent;
|
||||
}
|
||||
|
||||
public boolean isSeen() {
|
||||
return seen;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
@Override
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitPrivateMessageHeader(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.briar.api.messaging.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -12,22 +12,12 @@ import javax.annotation.concurrent.Immutable;
|
||||
*/
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class PrivateMessageReceivedEvent<H extends PrivateMessageHeader>
|
||||
extends Event {
|
||||
public class PrivateMessageReceivedEvent
|
||||
extends ConversationMessageReceivedEvent<PrivateMessageHeader> {
|
||||
|
||||
private final H messageHeader;
|
||||
private final ContactId contactId;
|
||||
|
||||
public PrivateMessageReceivedEvent(H messageHeader, ContactId contactId) {
|
||||
this.messageHeader = messageHeader;
|
||||
this.contactId = contactId;
|
||||
public PrivateMessageReceivedEvent(PrivateMessageHeader messageHeader,
|
||||
ContactId contactId) {
|
||||
super(messageHeader, contactId);
|
||||
}
|
||||
|
||||
public H getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.briarproject.briar.api.privategroup.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -10,7 +10,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class GroupInvitationRequestReceivedEvent extends
|
||||
PrivateMessageReceivedEvent<GroupInvitationRequest> {
|
||||
ConversationMessageReceivedEvent<GroupInvitationRequest> {
|
||||
|
||||
public GroupInvitationRequestReceivedEvent(GroupInvitationRequest request,
|
||||
ContactId contactId) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.briarproject.briar.api.privategroup.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -10,7 +10,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class GroupInvitationResponseReceivedEvent
|
||||
extends PrivateMessageReceivedEvent<GroupInvitationResponse> {
|
||||
extends ConversationMessageReceivedEvent<GroupInvitationResponse> {
|
||||
|
||||
public GroupInvitationResponseReceivedEvent(
|
||||
GroupInvitationResponse response, ContactId contactId) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.briarproject.bramble.api.sync.ClientId;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.briar.api.client.ProtocolStateException;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.ConversationManager.ConversationClient;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
|
||||
import org.briarproject.briar.api.privategroup.PrivateGroup;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.privategroup.PrivateGroup;
|
||||
import org.briarproject.briar.api.sharing.InvitationRequest;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GroupInvitationRequest extends InvitationRequest<PrivateGroup> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitGroupInvitationRequest(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageVisitor;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageVisitor;
|
||||
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -21,7 +21,7 @@ public class GroupInvitationResponse extends InvitationResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(PrivateMessageVisitor<T> v) {
|
||||
public <T> T accept(ConversationMessageVisitor<T> v) {
|
||||
return v.visitGroupInvitationResponse(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package org.briarproject.briar.api.sharing;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateRequest;
|
||||
import org.briarproject.briar.api.conversation.ConversationRequest;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class InvitationRequest<S extends Shareable> extends
|
||||
PrivateRequest<S> {
|
||||
ConversationRequest<S> {
|
||||
|
||||
private final boolean canBeOpened;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package org.briarproject.briar.api.sharing;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.PrivateResponse;
|
||||
import org.briarproject.briar.api.conversation.ConversationResponse;
|
||||
|
||||
public abstract class InvitationResponse extends PrivateResponse {
|
||||
public abstract class InvitationResponse extends ConversationResponse {
|
||||
|
||||
private final GroupId shareableId;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.ConversationManager.ConversationClient;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user