Create PrivateGroupManager Facade and stub implementation

This commit is contained in:
Torsten Grote
2016-09-28 16:54:28 -03:00
parent 8b50cb1461
commit 6ece398a21
38 changed files with 691 additions and 146 deletions

View File

@@ -0,0 +1,46 @@
package org.briarproject.api.clients;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.GroupId;
import org.jetbrains.annotations.NotNull;
public abstract class BaseGroup {
private final Group group;
private final String name;
private final byte[] salt;
public BaseGroup(@NotNull Group group, @NotNull String name, byte[] salt) {
this.group = group;
this.name = name;
this.salt = salt;
}
public GroupId getId() {
return group.getId();
}
public Group getGroup() {
return group;
}
public String getName() {
return name;
}
public byte[] getSalt() {
return salt;
}
@Override
public int hashCode() {
return group.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof BaseGroup &&
getGroup().equals(((BaseGroup) o).getGroup());
}
}

View File

@@ -0,0 +1,28 @@
package org.briarproject.api.clients;
import org.briarproject.api.sync.Message;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class BaseMessage {
private final Message message;
private final MessageId parent;
public BaseMessage(@NotNull Message message, @Nullable MessageId parent) {
this.message = message;
this.parent = parent;
}
@NotNull
public Message getMessage() {
return message;
}
@Nullable
public MessageId getParent() {
return parent;
}
}

View File

@@ -0,0 +1,45 @@
package org.briarproject.api.clients;
import org.briarproject.api.sync.MessageId;
public abstract class BaseMessageHeader {
private final MessageId id;
private final long timestamp;
private final boolean local, read, sent, seen;
public BaseMessageHeader(MessageId id, long timestamp, boolean local,
boolean read, boolean sent, boolean seen) {
this.id = id;
this.timestamp = timestamp;
this.local = local;
this.read = read;
this.sent = sent;
this.seen = seen;
}
public MessageId getId() {
return id;
}
public long getTimestamp() {
return timestamp;
}
public boolean isLocal() {
return local;
}
public boolean isRead() {
return read;
}
public boolean isSent() {
return sent;
}
public boolean isSeen() {
return seen;
}
}

View File

@@ -3,12 +3,14 @@ package org.briarproject.api.clients;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.GroupFactory;
public interface PrivateGroupFactory {
public interface ContactGroupFactory {
/** Creates a group that is not shared with any contacts. */
Group createLocalGroup(ClientId clientId);
/** Creates a group for the given client to share with the given contact. */
Group createPrivateGroup(ClientId clientId, Contact contact);
Group createContactGroup(ClientId clientId, Contact contact);
}