Skip to content
Snippets Groups Projects
Verified Commit 61b216f5 authored by Torsten Grote's avatar Torsten Grote
Browse files

Copy over Introduction API messages and events from old client

parent d57102ed
No related branches found
No related tags found
No related merge requests found
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment