diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionMessage.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionMessage.java new file mode 100644 index 000000000..a4b3999d1 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionMessage.java @@ -0,0 +1,43 @@ +package org.briarproject.briar.api.introduction2; + +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.BaseMessageHeader; +import org.briarproject.briar.api.client.SessionId; + +import javax.annotation.concurrent.Immutable; + +import static org.briarproject.briar.api.introduction2.Role.INTRODUCER; + +@Immutable +@NotNullByDefault +public class IntroductionMessage extends BaseMessageHeader { + + private final SessionId sessionId; + private final MessageId messageId; + private final Role role; + + IntroductionMessage(SessionId sessionId, MessageId messageId, + GroupId groupId, Role role, long time, boolean local, boolean sent, + boolean seen, boolean read) { + + super(messageId, groupId, time, local, sent, seen, read); + this.sessionId = sessionId; + this.messageId = messageId; + this.role = role; + } + + public SessionId getSessionId() { + return sessionId; + } + + public MessageId getMessageId() { + return messageId; + } + + public boolean isIntroducer() { + return role == INTRODUCER; + } + +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionRequest.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionRequest.java new file mode 100644 index 000000000..4494fa123 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionRequest.java @@ -0,0 +1,44 @@ +package org.briarproject.briar.api.introduction2; + +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 javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +public class IntroductionRequest extends IntroductionResponse { + + @Nullable + private final String message; + private final boolean answered, exists; + + public IntroductionRequest(SessionId sessionId, MessageId messageId, + GroupId groupId, Role role, long time, boolean local, boolean sent, + boolean seen, boolean read, String name, boolean accepted, + @Nullable String message, boolean answered, boolean exists) { + + super(sessionId, messageId, groupId, role, time, local, sent, seen, + read, name, accepted); + + this.message = message; + this.answered = answered; + this.exists = exists; + } + + @Nullable + public String getMessage() { + return message; + } + + public boolean wasAnswered() { + return answered; + } + + public boolean contactExists() { + return exists; + } +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionResponse.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionResponse.java new file mode 100644 index 000000000..b9d2bd993 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/IntroductionResponse.java @@ -0,0 +1,35 @@ +package org.briarproject.briar.api.introduction2; + +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 javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +public class IntroductionResponse extends IntroductionMessage { + + private final String name; + private final boolean accepted; + + public IntroductionResponse(SessionId sessionId, MessageId messageId, + GroupId groupId, Role role, long time, boolean local, boolean sent, + boolean seen, boolean read, String name, boolean accepted) { + super(sessionId, messageId, groupId, role, time, local, sent, seen, + read); + + this.name = name; + this.accepted = accepted; + } + + public String getName() { + return name; + } + + public boolean wasAccepted() { + return accepted; + } + +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionAbortedEvent.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionAbortedEvent.java new file mode 100644 index 000000000..610db3970 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionAbortedEvent.java @@ -0,0 +1,32 @@ +package org.briarproject.briar.api.introduction2.event; + +import org.briarproject.bramble.api.event.Event; +import org.briarproject.bramble.api.identity.AuthorId; +import org.briarproject.bramble.api.nullsafety.NotNullByDefault; +import org.briarproject.briar.api.client.SessionId; + +import javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +// TODO still needed? +public class IntroductionAbortedEvent extends Event { + + private final AuthorId remoteAuthorId; + private final SessionId sessionId; + + public IntroductionAbortedEvent(AuthorId remoteAuthorId, + SessionId sessionId) { + this.remoteAuthorId = remoteAuthorId; + this.sessionId = sessionId; + } + + public AuthorId getRemoteAuthorId() { + return remoteAuthorId; + } + + public SessionId getSessionId() { + return sessionId; + } + +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionRequestReceivedEvent.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionRequestReceivedEvent.java new file mode 100644 index 000000000..0798ac356 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionRequestReceivedEvent.java @@ -0,0 +1,32 @@ +package org.briarproject.briar.api.introduction2.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.introduction2.IntroductionRequest; + +import javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +public class IntroductionRequestReceivedEvent extends Event { + + private final ContactId contactId; + private final IntroductionRequest introductionRequest; + + public IntroductionRequestReceivedEvent(ContactId contactId, + IntroductionRequest introductionRequest) { + + this.contactId = contactId; + this.introductionRequest = introductionRequest; + } + + public ContactId getContactId() { + return contactId; + } + + public IntroductionRequest getIntroductionRequest() { + return introductionRequest; + } + +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionResponseReceivedEvent.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionResponseReceivedEvent.java new file mode 100644 index 000000000..a05731b59 --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionResponseReceivedEvent.java @@ -0,0 +1,31 @@ +package org.briarproject.briar.api.introduction2.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.introduction2.IntroductionResponse; + +import javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +public class IntroductionResponseReceivedEvent extends Event { + + private final ContactId contactId; + private final IntroductionResponse introductionResponse; + + public IntroductionResponseReceivedEvent(ContactId contactId, + IntroductionResponse introductionResponse) { + + this.contactId = contactId; + this.introductionResponse = introductionResponse; + } + + public ContactId getContactId() { + return contactId; + } + + public IntroductionResponse getIntroductionResponse() { + return introductionResponse; + } +} diff --git a/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionSucceededEvent.java b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionSucceededEvent.java new file mode 100644 index 000000000..11f85c2ce --- /dev/null +++ b/briar-api/src/main/java/org/briarproject/briar/api/introduction2/event/IntroductionSucceededEvent.java @@ -0,0 +1,23 @@ +package org.briarproject.briar.api.introduction2.event; + +import org.briarproject.bramble.api.contact.Contact; +import org.briarproject.bramble.api.event.Event; +import org.briarproject.bramble.api.nullsafety.NotNullByDefault; + +import javax.annotation.concurrent.Immutable; + +@Immutable +@NotNullByDefault +// TODO still needed? +public class IntroductionSucceededEvent extends Event { + + private final Contact contact; + + public IntroductionSucceededEvent(Contact contact) { + this.contact = contact; + } + + public Contact getContact() { + return contact; + } +}