Added third group visibility state.

This commit is contained in:
akwizgran
2016-11-15 14:08:01 +00:00
parent 007df4288b
commit ec1f4dccdb
19 changed files with 563 additions and 408 deletions

View File

@@ -11,6 +11,7 @@ import org.briarproject.api.settings.Settings;
import org.briarproject.api.sync.Ack;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.Group.Visibility;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.Message;
import org.briarproject.api.sync.MessageId;
@@ -232,6 +233,15 @@ public interface DatabaseComponent {
*/
Collection<Group> getGroups(Transaction txn, ClientId c) throws DbException;
/**
* Returns the given group's visibility to the given contact, or
* {@link Visibility INVISIBLE} if the group is not in the database.
* <p/>
* Read-only.
*/
Visibility getGroupVisibility(Transaction txn, ContactId c, GroupId g)
throws DbException;
/**
* Returns the local pseudonym with the given ID.
* <p/>
@@ -388,14 +398,6 @@ public interface DatabaseComponent {
void incrementStreamCounter(Transaction txn, ContactId c, TransportId t,
long rotationPeriod) throws DbException;
/**
* Returns true if the given group is visible to the given contact.
* <p/>
* Read-only.
*/
boolean isVisibleToContact(Transaction txn, ContactId c, GroupId g)
throws DbException;
/**
* Merges the given metadata with the existing metadata for the given
* group.
@@ -470,6 +472,12 @@ public interface DatabaseComponent {
void setContactActive(Transaction txn, ContactId c, boolean active)
throws DbException;
/**
* Sets the given group's visibility to the given contact.
*/
void setGroupVisibility(Transaction txn, ContactId c, GroupId g,
Visibility v) throws DbException;
/**
* Marks the given message as shared.
*/
@@ -494,12 +502,6 @@ public interface DatabaseComponent {
void setReorderingWindow(Transaction txn, ContactId c, TransportId t,
long rotationPeriod, long base, byte[] bitmap) throws DbException;
/**
* Makes a group visible or invisible to a contact.
*/
void setVisibleToContact(Transaction txn, ContactId c, GroupId g,
boolean visible) throws DbException;
/**
* Stores the given transport keys, deleting any keys they have replaced.
*/

View File

@@ -2,6 +2,12 @@ package org.briarproject.api.sync;
public class Group {
public enum Visibility {
INVISIBLE, // The group is not visible
VISIBLE, // The group is visible but messages are not shared
SHARED // The group is visible and messages are shared
}
private final GroupId id;
private final ClientId clientId;
private final byte[] descriptor;