Merge branch '2229-mailbox-client' into 'master'

Add connectivity check tasks, refactor mailbox properties

See merge request briar/briar!1650
This commit is contained in:
Torsten Grote
2022-05-31 12:45:27 +00:00
28 changed files with 890 additions and 197 deletions

View File

@@ -1,9 +0,0 @@
package org.briarproject.bramble.api;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@NotNullByDefault
public interface Supplier<T> {
T get();
}

View File

@@ -4,6 +4,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@Immutable
@@ -14,13 +15,36 @@ public class MailboxProperties {
private final MailboxAuthToken authToken;
private final boolean owner;
private final List<MailboxVersion> serverSupports;
@Nullable
private final MailboxFolderId inboxId; // Null for own mailbox
@Nullable
private final MailboxFolderId outboxId; // Null for own mailbox
/**
* Constructor for properties used by the mailbox's owner.
*/
public MailboxProperties(String baseUrl, MailboxAuthToken authToken,
boolean owner, List<MailboxVersion> serverSupports) {
List<MailboxVersion> serverSupports) {
this.baseUrl = baseUrl;
this.authToken = authToken;
this.owner = owner;
this.owner = true;
this.serverSupports = serverSupports;
this.inboxId = null;
this.outboxId = null;
}
/**
* Constructor for properties used by a contact of the mailbox's owner.
*/
public MailboxProperties(String baseUrl, MailboxAuthToken authToken,
List<MailboxVersion> serverSupports, MailboxFolderId inboxId,
MailboxFolderId outboxId) {
this.baseUrl = baseUrl;
this.authToken = authToken;
this.owner = false;
this.serverSupports = serverSupports;
this.inboxId = inboxId;
this.outboxId = outboxId;
}
public String getBaseUrl() {
@@ -43,4 +67,14 @@ public class MailboxProperties {
public List<MailboxVersion> getServerSupports() {
return serverSupports;
}
@Nullable
public MailboxFolderId getInboxId() {
return inboxId;
}
@Nullable
public MailboxFolderId getOutboxId() {
return outboxId;
}
}

View File

@@ -9,48 +9,22 @@ import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class MailboxUpdateWithMailbox extends MailboxUpdate {
private final List<MailboxVersion> serverSupports;
private final String onion;
private final MailboxAuthToken authToken;
private final MailboxFolderId inboxId;
private final MailboxFolderId outboxId;
private final MailboxProperties properties;
public MailboxUpdateWithMailbox(List<MailboxVersion> clientSupports,
List<MailboxVersion> serverSupports, String onion,
MailboxAuthToken authToken, MailboxFolderId inboxId,
MailboxFolderId outboxId
) {
MailboxProperties properties) {
super(clientSupports, true);
this.serverSupports = serverSupports;
this.onion = onion;
this.authToken = authToken;
this.inboxId = inboxId;
this.outboxId = outboxId;
if (properties.isOwner()) throw new IllegalArgumentException();
this.properties = properties;
}
public MailboxUpdateWithMailbox(MailboxUpdateWithMailbox o,
List<MailboxVersion> newClientSupports) {
this(newClientSupports, o.serverSupports, o.onion, o.authToken,
o.inboxId, o.outboxId);
this(newClientSupports, o.getMailboxProperties());
}
public String getOnion() {
return onion;
}
public MailboxAuthToken getAuthToken() {
return authToken;
}
public MailboxFolderId getInboxId() {
return inboxId;
}
public MailboxFolderId getOutboxId() {
return outboxId;
}
public List<MailboxVersion> getServerSupports() {
return serverSupports;
public MailboxProperties getMailboxProperties() {
return properties;
}
}